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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
9eb33ddf0f8891f585a85778dd078456128cdd78 | e98cd32546b613d2a24457f70cd9bf440623e3af | /功能测试/1.先前版本/projects/Projects/Fantasy-FT/Coptermaster/coptermaster/SupportClass/SupportClass.h | f9ffbaa4f46fe5f2316ba6ea5df3ef4c0de485be | [] | no_license | Kimicz20/Lab603 | 5f9ea48c08ad28f2a09cf3d8c1fc56863b4d1ce3 | 44aac79c61fb8f6a31553c31ff545b4f68abb551 | refs/heads/master | 2021-01-23T03:27:17.809795 | 2017-08-13T12:42:01 | 2017-08-13T12:42:01 | 86,073,286 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,172 | h | /*
* 辅助参数类
*用于重写 输入输出重定向 以及两个缓冲区参数
*/
#ifndef SupportClass_class
#define SupportClass_class
#include "../TestCase/TestCase.h"
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fcntl.h>
#include <iostream>
#include <list>
#include <signal.h>
#include <sstream>
#include <sys/shm.h>
#include <sys/types.h>
#include <unistd.h>
typedef list<string> StringList;
typedef list<TestCase *> TestCaseList;
#define TEXT_SZ 5*1024*1024
struct shared_use_st {
int currentIndex; //当前测试用例ID
int count;
char text[TEXT_SZ]; //记录写入和读取的文本
char result[TEXT_SZ];
};
class SupportClass {
private:
StringList testExecPath; //插桩路径保存
int currentIndex; //当前测试用例序号
public:
SupportClass();
/* 获取当前测试用例 */
TestCase *getCurrentTestCase();
/* 设置当前 测试用例实体类 从内存中获取*/
void setCurrentTestCase();
/* 设置当前 测试用例序号 同步到内存区域中 */
void setCurrentIndex();
/* 获取当前测试用例ID */
int getCurrentIndex();
/* 获取所有的测试用例数目 */
int getTestCaseCount();
/* 用例执行完成后 设置测试结果 */
void setCurTestCaseResult(string exeSituation);
/* 在当前 测试用例 中根据激励名称以及参数名 获取参数值 */
int getParamValueWithNameAndKey(string processName, string key);
/* 记录当前激励 执行情况 */
void setCurProcessResult(string processName, long mtime, int flag);
/* 路径 */
void showTestExecPath();
void cleanTestExecPath();
/* 类型转换 */
string ltos(long l);
/* 字符串 按某 字符 分割成list数组 */
list<string> stringSplit(string s, const char *str);
/* 信号处理以及设置定时器 */
void setHandler();
void setAlarm(int seconds);
/* 共享内存 创建并准备 */
void createMem();
/* 将 测试用例实体集 放入 共享内存中 */
void putTestCasesInMem();
/* 从 共享内存中 读写测试用例实体集 */
void getTestCasesInMem();
/* 分离 共享内存 */
void pullMem();
};
#endif
| [
"hz2z0421@163.com"
] | hz2z0421@163.com |
da0785a2766c8c7c9e34f6173cf59d99e022616c | 52564d0d44aff96c888badfb95d6cdfa8eeef292 | /zkbhShow/zkbhShow/mainFrame.cpp | 413117beca536175804236f423b4a3a0e3599831 | [] | no_license | geekxiaoxiao/zkbhShow | 73dbfc9728c4c61c3441d2165805eff6c989d32e | 0c0e986cd4143171a8f87fe419fc0e56d13e49cf | refs/heads/master | 2020-09-21T22:24:13.618724 | 2018-10-19T02:45:17 | 2018-10-19T02:45:17 | null | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 6,568 | cpp | #include "StdAfx.h"
#include "Resource.h"
#include "mainFrame.h"
MainFrame::MainFrame()
{
char cFullPath[MAX_PATH];
GetModuleFileName(NULL,cFullPath,MAX_PATH);
m_Path = cFullPath;
int pos = m_Path.find_last_of('\\',m_Path.length());
m_Path = m_Path.substr(0,pos);
CreateHandle(&m_handle);
}
MainFrame::~MainFrame()
{
if (m_Camera.isOpened())
{
m_Camera.release();
}
KillTimer(m_pm.GetPaintWindow(),12);
DestroyHandle(&m_handle);
PostQuitMessage(0);
}
LPCTSTR MainFrame::GetWindowClassName(void) const
{
return _T("PWSHOW");
}
CDuiString MainFrame::GetSkinFile()
{
return _T("mainSkin.xml");
}
LRESULT MainFrame::HandleMessage( UINT uMsg, WPARAM wParam, LPARAM lParam )
{
LRESULT lRes = __super::HandleMessage(uMsg, wParam, lParam);
BOOL bHandle = FALSE;
switch(wParam){
case WM_TIMER:
OnTimer(uMsg, wParam, lParam,bHandle);
break;
}
return lRes;
}
LRESULT MainFrame::OnTimer(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
bHandled = TRUE;
if (wParam==12)
{
if (m_Camera.isOpened())
{
if (!m_Camera.grab())
{
m_Camera.release();
m_Camera.open(m_sVideoFile.c_str());
}
Mat iframe;
if(!m_Camera.read(iframe))
{
return 0;
}
DetectMat(iframe);
}
}
return 0;
}
void MainFrame::DetectMat(Mat mat)
{
if (!m_flg)
{
m_flg=true;
mat.copyTo(m_FrameTemp);
return;
}
else
{
m_flg=false;
mat.copyTo(m_Frame);
}
DetectOut out;
int flg;
flg = find_target(m_handle,m_FrameTemp.data,m_Frame.data,m_Frame.rows,m_Frame.cols,m_Frame.channels(),&out);
Mat frame = m_Frame.clone();
if (flg==0)
{
vector<vector<Point>>lines;
cvtOut2Lines(out,lines);
vector<vector<Point>>::iterator it;
for (it=lines.begin();it!=lines.end();it++)
{
drawLine(frame,*it);
}
vector<Point>points;
cvtOut2Points(out,points);
vector<Point>::iterator it2;
for (it2=points.begin();it2!=points.end();it2++)
{
circle(frame,*it2,8,Scalar(0,0,255),-1);
}
}
OutputDestroy(&out);
ShowImage(frame,m_hwnd1);
ShowImage(mat,m_hwnd2);
}
void MainFrame::OnExit(TNotifyUI& msg)
{
Close();
}
void MainFrame::Notify(TNotifyUI& msg)
{
CDuiString name = msg.pSender->GetName();
if (msg.sType == _T("windowinit"))
{
return;
}
else if (msg.sType == _T("click"))
{
if (name == _T("closeBtn"))
{
Close();
}
return;
}
}
void MainFrame::InitWindow()
{
SetIcon(IDI_SMALL);
m_winShow1 = static_cast<CMownWndKitUI*>(m_pm.FindControl(_T("selfCtl1")));
if (!m_winShow1)
{
return;
}
m_hwnd1 = m_winShow1->GetHWND();
m_winShow2 = static_cast<CMownWndKitUI*>(m_pm.FindControl(_T("selfCtl2")));
if (!m_winShow2)
{
return;
}
m_hwnd2 = m_winShow2->GetHWND();
string sFilePath = m_Path;
sFilePath += "\\IniFile.ini";
char cVideo[32]="";
char cLogo[32]="";
GetPrivateProfileString(_T("ZKBH"),_T("VIDEO"),NULL,cVideo,MAX_PATH,sFilePath.c_str());
GetPrivateProfileString(_T("ZKBH"),_T("LOGO"),NULL,cLogo,MAX_PATH,sFilePath.c_str());
m_sVideoFile = m_Path + "\\" + cVideo;
m_Camera.open(m_sVideoFile.c_str());
if (!m_Camera.isOpened())
{
return;
}
string sLogoFile = m_Path + "\\" + cLogo;
m_logo = imread(sLogoFile,-1);
m_flg = false;
SetTimer(m_pm.GetPaintWindow(),12,50,NULL);
}
void MainFrame::OnFinalMessage(HWND hWnd)
{
WindowImplBase::OnFinalMessage(hWnd);
delete this;
}
LRESULT MainFrame::OnGetMinMaxInfo(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
bHandled = FALSE;
return 0;
}
CControlUI* MainFrame::CreateControl(LPCTSTR pstrClassName)
{
if (_tcsicmp(pstrClassName, _T("SelfCtl")) == 0)
{
return new CMownWndKitUI();
}
return NULL;
}
void MainFrame::ShowImage(Mat src,HWND hwnd)
{
if (src.empty()) return;
if (!::IsWindow(hwnd))
{
return;
}
ImageOverlay(m_logo,src);
HDC hDC = GetDC(hwnd); // 获取 HDC(设备句柄) 来进行绘图操作
RECT rect;
::GetClientRect(hwnd,&rect); // 获取控件尺寸位置
CvvImage cimg;
IplImage cpy = src;
cimg.CopyOf(&cpy); // 复制图片
cimg.DrawToHDC(hDC, &rect); // 将图片绘制到显示控件的指定区域内
cimg.Destroy();
DeleteDC(hDC);
}
LRESULT MainFrame::HandleCustomMessage(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
if(uMsg == WM_DESTROY)
{
::PostQuitMessage(0L);
bHandled = TRUE;
return 0;
}
LRESULT lRes = 0;
switch (uMsg)
{
case WM_TIMER: lRes = OnTimer(uMsg, wParam, lParam, bHandled); break;
}
return 0;
}
void MainFrame::ImageOverlay(const cv::Mat &mask, cv::Mat &image)
{
int nc = 3, alpha = 0;
for (int j = 0; j < mask.rows; j++)
{
for (int i = 0; i < mask.cols * 3; i += 3)
{
alpha = mask.ptr<uchar>(j)[i / 3 * 4 + 3];//第4字节通道
if (alpha == 255)//不透明
{
for (int k = 0; k < 3; k++)
{
if ((j < image.rows) && (j >= 0) && (i / 3 * 3 + k < image.cols * 3) && (i / 3 * 3 + k >= 0) &&
(i / nc * 4 + k < mask.cols * 4) && (i / nc * 4 + k >= 0))
{
image.ptr<uchar>(j)[i / nc * nc + k] = mask.ptr<uchar>(j)[(i) / nc * 4 + k];
}
}
}
else if (alpha > 0 && alpha < 255)//按照比例半透明
{
double rate = alpha / 255.0;
for (int k = 0; k < 3; k++)
{
if ((j < image.rows) && (j >= 0) && (i / 3 * 3 + k < image.cols * 3) && (i / 3 * 3 + k >= 0) &&
(i / nc * 4 + k < mask.cols * 4) && (i / nc * 4 + k >= 0))
{
image.ptr<uchar>(j)[i / nc * nc + k] = (uchar)(mask.ptr<uchar>(j)[(i) / nc * 4 + k] * rate + image.ptr<uchar>(j)[i / nc * nc + k] * (1 - rate));
}
}
}//alpha=0完全透明
}
}
}
void MainFrame::cvtOut2Lines(DetectOut result, vector<vector<cv::Point>>& lines)
{
for (int i = 0; i < result.num; i++){
vector<cv::Point> line;
for (int j = 0; j < result.lines[i].num; j++) {
cv::Point pt(result.lines[i].points[2*j], // x
result.lines[i].points[2*j + 1]);//y
line.push_back(pt);
}
lines.push_back(line);
}
}
void MainFrame::cvtOut2Points(DetectOut result, vector<cv::Point>& pts)
{
for (int i = 0; i < result.num; i++) {
int index = result.num - 1;
cv::Point pt(result.lines[i].points[2*index],
result.lines[i].points[2*index + 1]);
pts.push_back(pt);
}
}
void MainFrame::drawLine(Mat& img, const vector<cv::Point>& pts)
{
for(size_t i = 1; i < pts.size(); i++) {
line(img, pts[i - 1], pts[i], Scalar(0, 0, 255), 2);
}
} | [
"413683763@qq.com"
] | 413683763@qq.com |
031e426432bf0d7571859deed493250f51b19f9e | e80c5a2c5db97e5e6191cac5b68d23b73636c2ac | /spring2016/NLP/Assignments/Assignment_2/tools/openfst-1.5.1/src/bin/fstunion.cc | f396235da71d53410d899fc37b2e75958918302d | [
"Apache-2.0"
] | permissive | batu/codex | e2bdfbe8d0a6e86d21c6caedea80ac6375e000dc | 35171929dec936810b8994cc476f205b8af5adb6 | refs/heads/master | 2021-01-17T07:00:16.055807 | 2016-12-09T22:52:22 | 2016-12-09T22:52:22 | 51,299,933 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,119 | cc | // See www.openfst.org for extensive documentation on this weighted
// finite-state transducer library.
//
// Creates the union of two FSTs.
#include <fst/script/union.h>
int main(int argc, char **argv) {
namespace s = fst::script;
using fst::script::FstClass;
using fst::script::MutableFstClass;
string usage = "Creates the union of two FSTs.\n\n Usage: ";
usage += argv[0];
usage += " in1.fst in2.fst [out.fst]\n";
std::set_new_handler(FailedNewHandler);
SET_FLAGS(usage.c_str(), &argc, &argv, true);
if (argc < 3 || argc > 4) {
ShowUsage();
return 1;
}
string in1_name = strcmp(argv[1], "-") != 0 ? argv[1] : "";
string in2_name = strcmp(argv[2], "-") != 0 ? argv[2] : "";
string out_name = argc > 3 ? argv[3] : "";
if (in1_name == "" && in2_name == "") {
LOG(ERROR) << argv[0] << ": Can't use standard i/o for both inputs.";
return 1;
}
MutableFstClass *fst1 = MutableFstClass::Read(in1_name, true);
if (!fst1) return 1;
FstClass *fst2 = FstClass::Read(in2_name);
if (!fst2) return 1;
s::Union(fst1, *fst2);
fst1->Write(out_name);
return 0;
}
| [
"ba921@nyu.edu"
] | ba921@nyu.edu |
5f92f3b294a79080877f0053c61258fc7ba8ef5b | 3016f08184967b515c6e2acf70b25b76bc2edb77 | /class-1/10869/10869.cpp | c83aac967c37e7f12d74cb327da5cb03bce81d73 | [] | no_license | seonpilKim/solved.ac-class | 89835dfe4dc8d7410e75e12a600e21a6abbacda5 | 8e4ddaefc9a46387f3e128691b4a462e0be82053 | refs/heads/master | 2023-03-21T20:26:03.684426 | 2021-03-09T14:20:26 | 2021-03-09T14:20:26 | 325,022,351 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 181 | cpp | #include <iostream>
using namespace std;
int main() {
int A, B;
cin >> A >> B;
cout << A + B << "\n" << A - B << "\n" << A * B << "\n" << A / B << "\n" << A % B;
return 0;
}
| [
"seonpilKim@github.com"
] | seonpilKim@github.com |
bc19f492d845a643b0d37e02d4064511c7df39f8 | ece0db48604eeeace3e7c5b1e2dddc098e44652c | /app/src/main/jniLibs/jssc.cpp | 3db091f70787413079d212caa659925298904873 | [] | no_license | daixinghong/guinaSmart | 6e882e7def6cffd9ae3c285af3bcdb12b58fbecf | 7c4e03306dc3974857edb977ebfe9f5438f605e3 | refs/heads/master | 2020-04-04T10:30:09.176833 | 2018-12-25T01:51:00 | 2018-12-25T01:51:00 | 155,857,150 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 26,080 | cpp | /* jSSC (Java Simple Serial Connector) - serial port communication library.
* © Alexey Sokolov (scream3r), 2010-2014.
*
* This file is part of jSSC.
*
* jSSC is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* jSSC is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with jSSC. If not, see <http://www.gnu.org/licenses/>.
*
* If you use jSSC in public project you can inform me about this by e-mail,
* of course if you want it.
*
* e-mail: scream3r.org@gmail.com
* web-site: http://scream3r.org | http://code.google.com/p/java-simple-serial-connector/
*/
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <termios.h>
#include <time.h>
#include <errno.h>//-D_TS_ERRNO use for Solaris C++ compiler
#include <sys/select.h>//since 2.5.0
#ifdef __linux__
#include <linux/serial.h>
#endif
#ifdef __SunOS
#include <sys/filio.h>//Needed for FIONREAD in Solaris
#include <string.h>//Needed for select() function
#endif
#ifdef __APPLE__
#include <serial/ioss.h>//Needed for IOSSIOSPEED in Mac OS X (Non standard baudrate)
#endif
#include <jni.h>
#include "com_example_reallin_buyapp_jssc_SerialNativeInterface.h"
//#include <iostream> //-lCstd use for Solaris linker
JNIEXPORT jint JNICALL Java_com_example_reallin_buyapp_jssc_SerialNativeInterface_Count (JNIEnv *, jobject, jint a, jint b) {
return a + b;
}
/*
* Get native library version
*/
JNIEXPORT jstring JNICALL Java_com_example_reallin_buyapp_jssc_SerialNativeInterface_getNativeLibraryVersion(JNIEnv *env, jobject object) {
return env->NewStringUTF(jSSC_NATIVE_LIB_VERSION);
}
/* OK */
/*
* Port opening
*
* In 2.2.0 added useTIOCEXCL
*/
JNIEXPORT jlong JNICALL Java_com_example_reallin_buyapp_jssc_SerialNativeInterface_openPort(JNIEnv *env, jobject object, jstring portName, jboolean useTIOCEXCL){
const char* port = env->GetStringUTFChars(portName, JNI_FALSE);
jlong hComm = open(port, O_RDWR | O_NOCTTY | O_NDELAY);
if(hComm != -1){
//since 2.2.0 -> (check termios structure for separating real serial devices from others)
termios *settings = new termios();
if(tcgetattr(hComm, settings) == 0){
#if defined TIOCEXCL //&& !defined __SunOS
if(useTIOCEXCL == JNI_TRUE){
ioctl(hComm, TIOCEXCL);
}
#endif
int flags = fcntl(hComm, F_GETFL, 0);
flags &= ~O_NDELAY;
fcntl(hComm, F_SETFL, flags);
}
else {
close(hComm);//since 2.7.0
hComm = jssc_SerialNativeInterface_ERR_INCORRECT_SERIAL_PORT;//-4;
}
delete settings;
//<- since 2.2.0
}
else {//since 0.9 ->
if(errno == EBUSY){//Port busy
hComm = jssc_SerialNativeInterface_ERR_PORT_BUSY;//-1
}
else if(errno == ENOENT){//Port not found
hComm = jssc_SerialNativeInterface_ERR_PORT_NOT_FOUND;//-2;
}//-> since 2.2.0
else if(errno == EACCES){//Permission denied
hComm = jssc_SerialNativeInterface_ERR_PERMISSION_DENIED;//-3;
}
else {
hComm = jssc_SerialNativeInterface_ERR_PORT_NOT_FOUND;//-2;
}//<- since 2.2.0
}//<- since 0.9
env->ReleaseStringUTFChars(portName, port);
return hComm;
}
/* OK */
/*
* Choose baudrate
*/
speed_t getBaudRateByNum(jint baudRate) {
switch(baudRate){
case 0:
return B0;
case 50:
return B50;
case 75:
return B75;
case 110:
return B110;
case 134:
return B134;
case 150:
return B150;
case 200:
return B200;
case 300:
return B300;
case 600:
return B600;
case 1200:
return B1200;
case 1800:
return B1800;
case 2400:
return B2400;
case 4800:
return B4800;
case 9600:
return B9600;
case 19200:
return B19200;
case 38400:
return B38400;
#ifdef B57600
case 57600:
return B57600;
#endif
#ifdef B115200
case 115200:
return B115200;
#endif
#ifdef B230400
case 230400:
return B230400;
#endif
#ifdef B460800
case 460800:
return B460800;
#endif
#ifdef B500000
case 500000:
return B500000;
#endif
#ifdef B576000
case 576000:
return B576000;
#endif
#ifdef B921600
case 921600:
return B921600;
#endif
#ifdef B1000000
case 1000000:
return B1000000;
#endif
#ifdef B1152000
case 1152000:
return B1152000;
#endif
#ifdef B1500000
case 1500000:
return B1500000;
#endif
#ifdef B2000000
case 2000000:
return B2000000;
#endif
#ifdef B2500000
case 2500000:
return B2500000;
#endif
#ifdef B3000000
case 3000000:
return B3000000;
#endif
#ifdef B3500000
case 3500000:
return B3500000;
#endif
#ifdef B4000000
case 4000000:
return B4000000;
#endif
default:
return -1;
}
}
/* OK */
/*
* Choose data bits
*/
int getDataBitsByNum(jint byteSize) {
switch(byteSize){
case 5:
return CS5;
case 6:
return CS6;
case 7:
return CS7;
case 8:
return CS8;
default:
return -1;
}
}
//since 2.6.0 ->
const jint PARAMS_FLAG_IGNPAR = 1;
const jint PARAMS_FLAG_PARMRK = 2;
//<- since 2.6.0
/* OK */
/*
* Set serial port settings
*
* In 2.6.0 added flags parameter
*/
JNIEXPORT jboolean JNICALL Java_com_example_reallin_buyapp_jssc_SerialNativeInterface_setParams
(JNIEnv *env, jobject object, jlong portHandle, jint baudRate, jint byteSize, jint stopBits, jint parity, jboolean setRTS, jboolean setDTR, jint flags){
jboolean returnValue = JNI_FALSE;
speed_t baudRateValue = getBaudRateByNum(baudRate);
int dataBits = getDataBitsByNum(byteSize);
termios *settings = new termios();
if(tcgetattr(portHandle, settings) == 0){
if(baudRateValue != -1){
//Set standart baudrate from "termios.h"
if(cfsetispeed(settings, baudRateValue) < 0 || cfsetospeed(settings, baudRateValue) < 0){
goto methodEnd;
}
}
else {
#ifdef __SunOS
goto methodEnd;//Solaris don't support non standart baudrates
#elif defined __linux__
//Try to calculate a divisor for setting non standart baudrate
serial_struct *serial_info = new serial_struct();
if(ioctl(portHandle, TIOCGSERIAL, serial_info) < 0){ //Getting serial_info structure
delete serial_info;
goto methodEnd;
}
else {
serial_info->flags |= ASYNC_SPD_CUST;
serial_info->custom_divisor = (serial_info->baud_base/baudRate); //Calculate divisor
if(serial_info->custom_divisor == 0){ //If divisor == 0 go to method end to prevent "division by zero" error
delete serial_info;
goto methodEnd;
}
settings->c_cflag |= B38400;
if(cfsetispeed(settings, B38400) < 0 || cfsetospeed(settings, B38400) < 0){
delete serial_info;
goto methodEnd;
}
if(ioctl(portHandle, TIOCSSERIAL, serial_info) < 0){//Try to set new settings with non standart baudrate
delete serial_info;
goto methodEnd;
}
delete serial_info;
}
#endif
}
}
/*
* Setting data bits
*/
if(dataBits != -1){
settings->c_cflag &= ~CSIZE;
settings->c_cflag |= dataBits;
}
else {
goto methodEnd;
}
/*
* Setting stop bits
*/
if(stopBits == 0){ //1 stop bit (for info see ->> MSDN)
settings->c_cflag &= ~CSTOPB;
}
else if((stopBits == 1) || (stopBits == 2)){ //1 == 1.5 stop bits; 2 == 2 stop bits (for info see ->> MSDN)
settings->c_cflag |= CSTOPB;
}
else {
goto methodEnd;
}
settings->c_cflag |= (CREAD | CLOCAL);
settings->c_cflag &= ~CRTSCTS;
settings->c_lflag &= ~(ICANON | ECHO | ECHOE | ECHOK | ECHONL | ECHOCTL | ECHOPRT | ECHOKE | ISIG | IEXTEN);
settings->c_iflag &= ~(IXON | IXOFF | IXANY | INPCK | IGNPAR | PARMRK | ISTRIP | IGNBRK | BRKINT | INLCR | IGNCR| ICRNL);
#ifdef IUCLC
settings->c_iflag &= ~IUCLC;
#endif
settings->c_oflag &= ~OPOST;
//since 2.6.0 ->
if((flags & PARAMS_FLAG_IGNPAR) == PARAMS_FLAG_IGNPAR){
settings->c_iflag |= IGNPAR;
}
if((flags & PARAMS_FLAG_PARMRK) == PARAMS_FLAG_PARMRK){
settings->c_iflag |= PARMRK;
}
//<- since 2.6.0
//since 0.9 ->
settings->c_cc[VMIN] = 0;
settings->c_cc[VTIME] = 0;
//<- since 0.9
/*
* Parity bits
*/
#ifdef PAREXT
settings->c_cflag &= ~(PARENB | PARODD | PAREXT);//Clear parity settings
#elif defined CMSPAR
settings->c_cflag &= ~(PARENB | PARODD | CMSPAR);//Clear parity settings
#else
settings->c_cflag &= ~(PARENB | PARODD);//Clear parity settings
#endif
if(parity == 1){//Parity ODD
settings->c_cflag |= (PARENB | PARODD);
settings->c_iflag |= INPCK;
}
else if(parity == 2){//Parity EVEN
settings->c_cflag |= PARENB;
settings->c_iflag |= INPCK;
}
else if(parity == 3){//Parity MARK
#ifdef PAREXT
settings->c_cflag |= (PARENB | PARODD | PAREXT);
settings->c_iflag |= INPCK;
#elif defined CMSPAR
settings->c_cflag |= (PARENB | PARODD | CMSPAR);
settings->c_iflag |= INPCK;
#endif
}
else if(parity == 4){//Parity SPACE
#ifdef PAREXT
settings->c_cflag |= (PARENB | PAREXT);
settings->c_iflag |= INPCK;
#elif defined CMSPAR
settings->c_cflag |= (PARENB | CMSPAR);
settings->c_iflag |= INPCK;
#endif
}
else if(parity == 0){
//Do nothing (Parity NONE)
}
else {
goto methodEnd;
}
if(tcsetattr(portHandle, TCSANOW, settings) == 0){//Try to set all settings
#ifdef __APPLE__
//Try to set non-standard baud rate in Mac OS X
if(baudRateValue == -1){
speed_t speed = (speed_t)baudRate;
if(ioctl(portHandle, IOSSIOSPEED, &speed) < 0){//IOSSIOSPEED must be used only after tcsetattr
goto methodEnd;
}
}
#endif
int lineStatus;
if(ioctl(portHandle, TIOCMGET, &lineStatus) >= 0){
if(setRTS == JNI_TRUE){
lineStatus |= TIOCM_RTS;
}
else {
lineStatus &= ~TIOCM_RTS;
}
if(setDTR == JNI_TRUE){
lineStatus |= TIOCM_DTR;
}
else {
lineStatus &= ~TIOCM_DTR;
}
if(ioctl(portHandle, TIOCMSET, &lineStatus) >= 0){
returnValue = JNI_TRUE;
}
}
}
methodEnd: {
delete settings;
return returnValue;
}
}
const jint PURGE_RXABORT = 0x0002; //ignored
const jint PURGE_RXCLEAR = 0x0008;
const jint PURGE_TXABORT = 0x0001; //ignored
const jint PURGE_TXCLEAR = 0x0004;
/* OK */
/*
* PurgeComm
*/
JNIEXPORT jboolean JNICALL Java_com_example_reallin_buyapp_jssc_SerialNativeInterface_purgePort
(JNIEnv *env, jobject object, jlong portHandle, jint flags){
int clearValue = -1;
if((flags & PURGE_RXCLEAR) && (flags & PURGE_TXCLEAR)){
clearValue = TCIOFLUSH;
}
else if(flags & PURGE_RXCLEAR) {
clearValue = TCIFLUSH;
}
else if(flags & PURGE_TXCLEAR) {
clearValue = TCOFLUSH;
}
else if((flags & PURGE_RXABORT) || (flags & PURGE_TXABORT)){
return JNI_TRUE;
}
else {
return JNI_FALSE;
}
return tcflush(portHandle, clearValue) == 0 ? JNI_TRUE : JNI_FALSE;
}
/* OK */
/* Closing the port */
JNIEXPORT jboolean JNICALL Java_com_example_reallin_buyapp_jssc_SerialNativeInterface_closePort
(JNIEnv *env, jobject object, jlong portHandle){
#if defined TIOCNXCL //&& !defined __SunOS
ioctl(portHandle, TIOCNXCL);//since 2.1.0 Clear exclusive port access on closing
#endif
return close(portHandle) == 0 ? JNI_TRUE : JNI_FALSE;
}
/* OK */
/*
* Setting events mask
*/
JNIEXPORT jboolean JNICALL Java_com_example_reallin_buyapp_jssc_SerialNativeInterface_setEventsMask
(JNIEnv *env, jobject object, jlong portHandle, jint mask){
//Don't needed in linux, implemented in java code
return JNI_TRUE;
}
/* OK */
/*
* Getting events mask
*/
JNIEXPORT jint JNICALL Java_com_example_reallin_buyapp_jssc_SerialNativeInterface_getEventsMask
(JNIEnv *env, jobject object, jlong portHandle){
//Don't needed in linux, implemented in java code
return -1;
}
/* OK */
/*
* RTS line status changing (ON || OFF)
*/
JNIEXPORT jboolean JNICALL Java_com_example_reallin_buyapp_jssc_SerialNativeInterface_setRTS
(JNIEnv *env, jobject object, jlong portHandle, jboolean enabled){
int returnValue = 0;
int lineStatus;
ioctl(portHandle, TIOCMGET, &lineStatus);
if(enabled == JNI_TRUE){
lineStatus |= TIOCM_RTS;
}
else {
lineStatus &= ~TIOCM_RTS;
}
returnValue = ioctl(portHandle, TIOCMSET, &lineStatus);
return (returnValue >= 0 ? JNI_TRUE : JNI_FALSE);
}
/* OK */
/*
* DTR line status changing (ON || OFF)
*/
JNIEXPORT jboolean JNICALL Java_com_example_reallin_buyapp_jssc_SerialNativeInterface_setDTR
(JNIEnv *env, jobject object, jlong portHandle, jboolean enabled){
int returnValue = 0;
int lineStatus;
ioctl(portHandle, TIOCMGET, &lineStatus);
if(enabled == JNI_TRUE){
lineStatus |= TIOCM_DTR;
}
else {
lineStatus &= ~TIOCM_DTR;
}
returnValue = ioctl(portHandle, TIOCMSET, &lineStatus);
return (returnValue >= 0 ? JNI_TRUE : JNI_FALSE);
}
/* OK */
/*
* Writing data to the port
*/
JNIEXPORT jboolean JNICALL Java_com_example_reallin_buyapp_jssc_SerialNativeInterface_writeBytes
(JNIEnv *env, jobject object, jlong portHandle, jbyteArray buffer){
jbyte* jBuffer = env->GetByteArrayElements(buffer, JNI_FALSE);
jint bufferSize = env->GetArrayLength(buffer);
jint result = write(portHandle, jBuffer, (size_t)bufferSize);
env->ReleaseByteArrayElements(buffer, jBuffer, 0);
return result == bufferSize ? JNI_TRUE : JNI_FALSE;
}
/* OK */
/*
* Reading data from the port
*
* Rewrited in 2.5.0 (using select() function for correct block reading in MacOS X)
*/
JNIEXPORT jbyteArray JNICALL Java_com_example_reallin_buyapp_jssc_SerialNativeInterface_readBytes
(JNIEnv *env, jobject object, jlong portHandle, jint byteCount){
fd_set read_fd_set;
jbyte *lpBuffer = new jbyte[byteCount];
int byteRemains = byteCount;
while(byteRemains > 0) {
FD_ZERO(&read_fd_set);
FD_SET(portHandle, &read_fd_set);
select(portHandle + 1, &read_fd_set, NULL, NULL, NULL);
int result = read(portHandle, lpBuffer + (byteCount - byteRemains), byteRemains);
if(result > 0){
byteRemains -= result;
}
}
FD_CLR(portHandle, &read_fd_set);
jbyteArray returnArray = env->NewByteArray(byteCount);
env->SetByteArrayRegion(returnArray, 0, byteCount, lpBuffer);
delete lpBuffer;
return returnArray;
}
/* OK */
/*
* Get bytes count in serial port buffers (Input and Output)
*/
JNIEXPORT jintArray JNICALL Java_com_example_reallin_buyapp_jssc_SerialNativeInterface_getBuffersBytesCount
(JNIEnv *env, jobject object, jlong portHandle){
jint returnValues[2];
returnValues[0] = -1; //Input buffer
returnValues[1] = -1; //Output buffer
jintArray returnArray = env->NewIntArray(2);
ioctl(portHandle, FIONREAD, &returnValues[0]);
ioctl(portHandle, TIOCOUTQ, &returnValues[1]);
env->SetIntArrayRegion(returnArray, 0, 2, returnValues);
return returnArray;
}
const jint FLOWCONTROL_NONE = 0;
const jint FLOWCONTROL_RTSCTS_IN = 1;
const jint FLOWCONTROL_RTSCTS_OUT = 2;
const jint FLOWCONTROL_XONXOFF_IN = 4;
const jint FLOWCONTROL_XONXOFF_OUT = 8;
/* OK */
/*
* Setting flow control mode
*/
JNIEXPORT jboolean JNICALL Java_com_example_reallin_buyapp_jssc_SerialNativeInterface_setFlowControlMode
(JNIEnv *env, jobject object, jlong portHandle, jint mask){
jboolean returnValue = JNI_FALSE;
termios *settings = new termios();
if(tcgetattr(portHandle, settings) == 0){
settings->c_cflag &= ~CRTSCTS;
settings->c_iflag &= ~(IXON | IXOFF);
if(mask != FLOWCONTROL_NONE){
if(((mask & FLOWCONTROL_RTSCTS_IN) == FLOWCONTROL_RTSCTS_IN) || ((mask & FLOWCONTROL_RTSCTS_OUT) == FLOWCONTROL_RTSCTS_OUT)){
settings->c_cflag |= CRTSCTS;
}
if((mask & FLOWCONTROL_XONXOFF_IN) == FLOWCONTROL_XONXOFF_IN){
settings->c_iflag |= IXOFF;
}
if((mask & FLOWCONTROL_XONXOFF_OUT) == FLOWCONTROL_XONXOFF_OUT){
settings->c_iflag |= IXON;
}
}
if(tcsetattr(portHandle, TCSANOW, settings) == 0){
returnValue = JNI_TRUE;
}
}
delete settings;
return returnValue;
}
/* OK */
/*
* Getting flow control mode
*/
JNIEXPORT jint JNICALL Java_com_example_reallin_buyapp_jssc_SerialNativeInterface_getFlowControlMode
(JNIEnv *env, jobject object, jlong portHandle){
jint returnValue = 0;
termios *settings = new termios();
if(tcgetattr(portHandle, settings) == 0){
if(settings->c_cflag & CRTSCTS){
returnValue |= (FLOWCONTROL_RTSCTS_IN | FLOWCONTROL_RTSCTS_OUT);
}
if(settings->c_iflag & IXOFF){
returnValue |= FLOWCONTROL_XONXOFF_IN;
}
if(settings->c_iflag & IXON){
returnValue |= FLOWCONTROL_XONXOFF_OUT;
}
}
return returnValue;
}
/* OK */
/*
* Send break for setted duration
*/
JNIEXPORT jboolean JNICALL Java_com_example_reallin_buyapp_jssc_SerialNativeInterface_sendBreak
(JNIEnv *env, jobject object, jlong portHandle, jint duration){
jboolean returnValue = JNI_FALSE;
if(duration > 0){
if(ioctl(portHandle, TIOCSBRK, 0) >= 0){
int sec = (duration >= 1000 ? duration/1000 : 0);
int nanoSec = (sec > 0 ? duration - sec*1000 : duration)*1000000;
struct timespec *timeStruct = new timespec();
timeStruct->tv_sec = sec;
timeStruct->tv_nsec = nanoSec;
nanosleep(timeStruct, NULL);
delete(timeStruct);
if(ioctl(portHandle, TIOCCBRK, 0) >= 0){
returnValue = JNI_TRUE;
}
}
}
return returnValue;
}
/* OK */
/*
* Return "statusLines" from ioctl(portHandle, TIOCMGET, &statusLines)
* Need for "_waitEvents" and "_getLinesStatus"
*/
int getLinesStatus(jlong portHandle) {
int statusLines;
ioctl(portHandle, TIOCMGET, &statusLines);
return statusLines;
}
/* OK */
/*
* Not supported in Solaris and Mac OS X
*
* Get interrupts count for:
* 0 - Break(for BREAK event)
* 1 - TX(for TXEMPTY event)
* --ERRORS(for ERR event)--
* 2 - Frame
* 3 - Overrun
* 4 - Parity
*/
void getInterruptsCount(jlong portHandle, int intArray[]) {
#ifdef TIOCGICOUNT
struct serial_icounter_struct *icount = new serial_icounter_struct();
if(ioctl(portHandle, TIOCGICOUNT, icount) >= 0){
intArray[0] = icount->brk;
intArray[1] = icount->tx;
intArray[2] = icount->frame;
intArray[3] = icount->overrun;
intArray[4] = icount->parity;
}
delete icount;
#endif
}
const jint INTERRUPT_BREAK = 512;
const jint INTERRUPT_TX = 1024;
const jint INTERRUPT_FRAME = 2048;
const jint INTERRUPT_OVERRUN = 4096;
const jint INTERRUPT_PARITY = 8192;
const jint EV_CTS = 8;
const jint EV_DSR = 16;
const jint EV_RING = 256;
const jint EV_RLSD = 32;
const jint EV_RXCHAR = 1;
//const jint EV_RXFLAG = 2; //Not supported
const jint EV_TXEMPTY = 4;
const jint events[] = {INTERRUPT_BREAK,
INTERRUPT_TX,
INTERRUPT_FRAME,
INTERRUPT_OVERRUN,
INTERRUPT_PARITY,
EV_CTS,
EV_DSR,
EV_RING,
EV_RLSD,
EV_RXCHAR,
//EV_RXFLAG, //Not supported
EV_TXEMPTY};
/* OK */
/*
* Collecting data for EventListener class (Linux have no implementation of "WaitCommEvent" function from Windows)
*
*/
JNIEXPORT jobjectArray JNICALL Java_com_example_reallin_buyapp_jssc_SerialNativeInterface_waitEvents
(JNIEnv *env, jobject object, jlong portHandle) {
jclass intClass = env->FindClass("[I");
jobjectArray returnArray = env->NewObjectArray(sizeof(events)/sizeof(jint), intClass, NULL);
/*Input buffer*/
jint bytesCountIn = 0;
ioctl(portHandle, FIONREAD, &bytesCountIn);
/*Output buffer*/
jint bytesCountOut = 0;
ioctl(portHandle, TIOCOUTQ, &bytesCountOut);
/*Lines status*/
int statusLines = getLinesStatus(portHandle);
jint statusCTS = 0;
jint statusDSR = 0;
jint statusRING = 0;
jint statusRLSD = 0;
/*CTS status*/
if(statusLines & TIOCM_CTS){
statusCTS = 1;
}
/*DSR status*/
if(statusLines & TIOCM_DSR){
statusDSR = 1;
}
/*RING status*/
if(statusLines & TIOCM_RNG){
statusRING = 1;
}
/*RLSD(DCD) status*/
if(statusLines & TIOCM_CAR){
statusRLSD = 1;
}
/*Interrupts*/
int interrupts[] = {-1, -1, -1, -1, -1};
getInterruptsCount(portHandle, interrupts);
jint interruptBreak = interrupts[0];
jint interruptTX = interrupts[1];
jint interruptFrame = interrupts[2];
jint interruptOverrun = interrupts[3];
jint interruptParity = interrupts[4];
for(int i = 0; i < sizeof(events)/sizeof(jint); i++){
jint returnValues[2];
switch(events[i]) {
case INTERRUPT_BREAK: //Interrupt Break - for BREAK event
returnValues[1] = interruptBreak;
goto forEnd;
case INTERRUPT_TX: //Interrupt TX - for TXEMPTY event
returnValues[1] = interruptTX;
goto forEnd;
case INTERRUPT_FRAME: //Interrupt Frame - for ERR event
returnValues[1] = interruptFrame;
goto forEnd;
case INTERRUPT_OVERRUN: //Interrupt Overrun - for ERR event
returnValues[1] = interruptOverrun;
goto forEnd;
case INTERRUPT_PARITY: //Interrupt Parity - for ERR event
returnValues[1] = interruptParity;
goto forEnd;
case EV_CTS:
returnValues[1] = statusCTS;
goto forEnd;
case EV_DSR:
returnValues[1] = statusDSR;
goto forEnd;
case EV_RING:
returnValues[1] = statusRING;
goto forEnd;
case EV_RLSD: /*DCD*/
returnValues[1] = statusRLSD;
goto forEnd;
case EV_RXCHAR:
returnValues[1] = bytesCountIn;
goto forEnd;
/*case EV_RXFLAG: // Event RXFLAG - Not supported
returnValues[0] = EV_RXFLAG;
returnValues[1] = 0;
goto forEnd;*/
case EV_TXEMPTY:
returnValues[1] = bytesCountOut;
goto forEnd;
}
forEnd: {
returnValues[0] = events[i];
jintArray singleResultArray = env->NewIntArray(2);
env->SetIntArrayRegion(singleResultArray, 0, 2, returnValues);
env->SetObjectArrayElement(returnArray, i, singleResultArray);
};
}
return returnArray;
}
/* OK */
/*
* Getting serial ports names like an a String array (String[])
*/
JNIEXPORT jobjectArray JNICALL Java_com_example_reallin_buyapp_jssc_SerialNativeInterface_getSerialPortNames
(JNIEnv *env, jobject object){
//Don't needed in linux, implemented in java code (Note: null will be returned)
return NULL;
}
/* OK */
/*
* Getting lines status
*
* returnValues[0] - CTS
* returnValues[1] - DSR
* returnValues[2] - RING
* returnValues[3] - RLSD(DCD)
*/
JNIEXPORT jintArray JNICALL Java_com_example_reallin_buyapp_jssc_SerialNativeInterface_getLinesStatus
(JNIEnv *env, jobject object, jlong portHandle){
jint returnValues[4];
for(jint i = 0; i < 4; i++){
returnValues[i] = 0;
}
jintArray returnArray = env->NewIntArray(4);
/*Lines status*/
int statusLines = getLinesStatus(portHandle);
/*CTS status*/
if(statusLines & TIOCM_CTS){
returnValues[0] = 1;
}
/*DSR status*/
if(statusLines & TIOCM_DSR){
returnValues[1] = 1;
}
/*RING status*/
if(statusLines & TIOCM_RNG){
returnValues[2] = 1;
}
/*RLSD(DCD) status*/
if(statusLines & TIOCM_CAR){
returnValues[3] = 1;
}
env->SetIntArrayRegion(returnArray, 0, 4, returnValues);
return returnArray;
}
| [
"045510"
] | 045510 |
6f2bfe9b8b1a62873302ee91c2485c00496daca6 | a98cc8054fc6c9f253448ad188bb53fcf9e6084d | /csuy-4533/example/1/example.cpp | 56ea58e4970c8a2eb21a0f17119faa2b7b9671ca | [] | no_license | shi-kejian/nyu | 4168c3298ec5e45382740ca7d94f15783d32d279 | 25e06da14da59238fba1a5b96f802180652cd956 | refs/heads/master | 2021-10-09T05:45:58.917527 | 2018-12-22T04:00:14 | 2018-12-22T04:00:14 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,485 | cpp | /************************************
* Handout: example.cpp
*
* This program is to demonstrate the basic OpenGL program structure.
* Read the comments carefully for explanations.
************************************/
#include <stdio.h>
#include <math.h>
#ifdef __APPLE__ // include Mac OS X verions of headers
#include <GLUT/glut.h>
#else // non-Mac OS X operating systems
#include <GL/glut.h>
#endif
float f = 0.0;
void display(void);
void my_init(void);
void reshape(int w, int h);
void idle(void);
int main(int argc, char **argv) {
/*---- Initialize & Open Window ---*/
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB); // double-buffering and RGB color
// mode.
glutInitWindowSize(500, 500);
glutInitWindowPosition(30, 30); // Graphics window position
glutCreateWindow("Rectangle"); // Window title is "Rectangle"
/*--- Register call-back functions; any order is fine ---*/
/* Events: display, reshape, keyboard, mouse, idle, etc.
- display: Automatically called when the window is first opened.
Later, when the frame content needs to be changed, we need
to call display again From the Program to re-draw the objects.
This is essential for animation.
- reshape: Automatically called when the window is first opened,
or when the window is re-sized or moved by the user.
- keyboard: Automatically called when a keyboard event occurs.
- mouse: Automatically called when a mouse event occurs.
- idle: Automatically called when nothing occurs.
This is essential for animation.
* Once entering the event loop, the execution control always returns to
the event loop. When particular event occurs, the corresponding call-back
function is called; when that call-back function finishes, control again
goes back to the event loop, and the process is repeated.
*/
glutDisplayFunc(display); // Register our display() function as the display
// call-back function
glutReshapeFunc(reshape); // Register our reshape() function as the reshape
// call-back function
// glutMouseFunc(mouse); // for mouse
// glutKeyboardFunc(key); // for keyboard
glutIdleFunc(idle); // Register our idle() function
my_init(); // initialize variables
glutMainLoop(); // Enter the event loop
return 0;
}
void display(void) {
glClear(GL_COLOR_BUFFER_BIT); // clear frame buffer (also called the
// color buffer)
glColor3f(0.0, 1.0, 1.0); // draw in cyan.
// The color stays the same until we
// change it next time.
glBegin(GL_POLYGON); // Draw a polygon (can have many vertices)
// The vertex coordinates change by different
// values of f; see also function idle().
glVertex2f(100, 100 + f);
glVertex2f(200, 100 + f);
glVertex2f(200, 300 + f);
glVertex2f(100, 300 + f);
glEnd();
glFlush(); // Render (draw) the object
glutSwapBuffers(); // Swap buffers in double buffering.
}
void my_init() {
glClearColor(0.0, 0.0, 0.0, 0.0); // Use black as the color for clearing
// the frame buffer (also called the
// color buffer). This produces a
// black background.
}
void reshape(int w, int h) {
glViewport(0, 0, w, h); // Viewport within the graphics window.
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0, (GLdouble) w, 0.0, (GLdouble) h);
}
void idle(void) {
f += 1.0; // smaller number gives a slower but smoother animation
if (f > 180.0) f = 0.0;
glutPostRedisplay(); // or call display()
}
| [
"shin.junwoo97@gmail.com"
] | shin.junwoo97@gmail.com |
1c8d5c4034455ea0b60f60f63ef451086c083980 | 8288e4c8a393f917a44bdb18b1fed186fcf234a1 | /HilifeFrw/base_entity.cpp | 794867260a70d9f5cb0e6bd66451bdf0dd216d83 | [] | no_license | pulsar-git/hilifes | 9446900516186d8bdfe05d747623f3c1c30f9f79 | ec3cec92c25d59b64c3d7daf396ebb73f66794da | refs/heads/master | 2021-01-19T09:42:14.055475 | 2014-05-14T07:17:05 | 2014-05-14T07:17:05 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 238 | cpp | #include "stable_headers.h"
#include "base_entity.h"
#include "attribute_manager.h"
namespace hilife
{
base_entity::base_entity(void):_initialized(false),_attribute_manager(0),_parent(0)
{
}
base_entity::~base_entity(void)
{
}
}
| [
"pulsar-git@github.com"
] | pulsar-git@github.com |
c2c0dadd516a4debc71cc58d3f65eb6159a4cd41 | 10482a59e5a8457cbdf5b66f51f27513c88d8223 | /Samples/Shared/CharactersScene.cpp | 0f512bd29848e13673f6b3bf074f278701848904 | [
"MIT"
] | permissive | chltom/XLE | 5cb41db605dfb5ba521ebc4ba16b8278b1720fd2 | fd842841a8fc6789b4f6d4412e0fac2f3119fea6 | refs/heads/master | 2021-01-17T22:15:54.839903 | 2016-02-15T07:32:23 | 2016-02-15T07:32:23 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 17,951 | cpp | // Copyright 2015 XLGAMES Inc.
//
// Distributed under the MIT License (See
// accompanying file "LICENSE" or the website
// http://www.opensource.org/licenses/mit-license.php)
#include "CharactersScene.h"
#include "Character.h"
#include "SampleGlobals.h"
#include "../../RenderCore/Assets/ModelRunTime.h"
#include "../../RenderCore/Assets/SharedStateSet.h"
#include "../../RenderCore/Assets/AssetUtils.h"
#include "../../RenderCore/Assets/Services.h"
#include "../../RenderCore/Metal/DeviceContext.h"
#include "../../RenderCore/Metal/GPUProfiler.h"
#include "../../RenderCore/Techniques/CommonResources.h"
#include "../../RenderCore/Techniques/Techniques.h"
#include "../../ConsoleRig/Console.h"
#include "../../Math/Transformations.h"
#include "../../Math/ProjectionMath.h"
#include "../../Utility/Mixins.h"
#include "../../Utility/Profiling/CPUProfiler.h"
namespace Sample
{
class StateBin : noncopyable
{
public:
const CharacterModel* _model;
float _time;
uint64 _animation;
std::vector<Float4x4> _instances;
StateBin();
StateBin(StateBin&& moveFrom);
StateBin& operator=(StateBin&& moveFrom);
};
StateBin::StateBin()
{
_model = nullptr; _time = 0.f; _animation = 0;
}
StateBin::StateBin(StateBin&& moveFrom)
: _model (std::move(moveFrom._model))
, _time (moveFrom._time)
, _animation(moveFrom._animation)
, _instances(std::move(moveFrom._instances))
{
}
StateBin& StateBin::operator=(StateBin&& moveFrom)
{
_model = std::move(moveFrom._model);
_time = moveFrom._time;
_animation = moveFrom._animation;
_instances = std::move(moveFrom._instances);
return *this;
}
//////////////////////////////////////////////////////////////////////////////////////////////
class CharactersScene::Pimpl
{
public:
typedef RenderCore::Assets::ModelRenderer::PreparedAnimation PreparedAnimation;
std::shared_ptr<AnimationDecisionTree> _mainAnimDecisionTree;
std::unique_ptr<CharacterModel> _characterModel;
mutable std::vector<PreparedAnimation> _preallocatedState;
mutable RenderCore::Assets::SharedStateSet _charactersSharedStateSet;
std::shared_ptr<PlayerCharacter> _playerCharacter;
std::vector<NPCCharacter> _characters;
std::vector<NetworkCharacter> _networkCharacters;
std::vector<StateBin> _stateCache;
Pimpl()
: _charactersSharedStateSet(RenderCore::Assets::Services::GetTechniqueConfigDirs()) {}
};
//////////////////////////////////////////////////////////////////////////////////////////////
static const std::basic_string<utf8> StringAutoCotangent((const utf8*)"AUTO_COTANGENT");
void CharactersScene::Render(
RenderCore::Metal::DeviceContext* context,
SceneEngine::LightingParserContext& parserContext,
int techniqueIndex) const
{
using RenderCore::Metal::ConstantBuffer;
using namespace SceneEngine;
RenderCore::Metal::GPUProfiler::DebugAnnotation anno(*context, L"Characters");
CPUProfileEvent pEvnt("CharactersSceneRender", g_cpuProfiler);
// Turn on auto cotangents for character rendering
// This prevents us from having to transform the tangent frame through the skinning
// transforms (and avoids having to store those tangents in the prepared animation buffer)
auto& techEnv = parserContext.GetTechniqueContext()._globalEnvironmentState;
techEnv.SetParameter(StringAutoCotangent.c_str(), 1);
auto captureMarker = _pimpl->_charactersSharedStateSet.CaptureState(*context, parserContext.GetStateSetResolver(), parserContext.GetStateSetEnvironment());
RenderCore::Assets::ModelRendererContext modelContext(
*context, parserContext, techniqueIndex);
if (!_pimpl->_preallocatedState.empty()) {
const bool interleavedRender = Tweakable("InterleavedRender", false);
if (interleavedRender) {
auto si = _pimpl->_preallocatedState.begin();
for (auto i=_pimpl->_stateCache.begin(); i!=_pimpl->_stateCache.end(); ++i, ++si) {
CATCH_ASSETS_BEGIN
const auto& model = *i->_model;
si->_animState = RenderCore::Assets::AnimationState(i->_time, i->_animation);
model.GetPrepareMachine().PrepareAnimation(context, *si);
model.GetRenderer().PrepareAnimation(context, *si, model.GetPrepareMachine().GetSkeletonBinding());
for (auto i2=i->_instances.cbegin(); i2!=i->_instances.cend(); ++i2) {
RenderCore::Assets::MeshToModel meshToModel(
si->_finalMatrices.get(),
model.GetPrepareMachine().GetSkeletonOutputCount(),
&model.GetPrepareMachine().GetSkeletonBinding());
model.GetRenderer().Render(modelContext, _pimpl->_charactersSharedStateSet, *i2, meshToModel, AsPointer(si));
}
CATCH_ASSETS_END(parserContext)
}
} else {
//
// Use the skinned characters information calculated in PrepareCharacters
// This way, we can do the skinning once, but re-use the results while
// rendering the characters multiple times (for example, for shadows or
// other passes).
//
namespace GPUProfiler = RenderCore::Metal::GPUProfiler;
context->Bind(RenderCore::Techniques::CommonResources()._dssReadWrite);
context->Bind(RenderCore::Techniques::CommonResources()._blendOpaque);
GPUProfiler::TriggerEvent(*context, g_gpuProfiler.get(), "RenderCharacters", GPUProfiler::Begin);
auto si = _pimpl->_preallocatedState.begin();
for (auto i=_pimpl->_stateCache.begin(); i!=_pimpl->_stateCache.end(); ++i, ++si) {
CATCH_ASSETS_BEGIN
const auto& model = *i->_model;
for (auto i2=i->_instances.cbegin(); i2!=i->_instances.cend(); ++i2) {
CPUProfileEvent pEvnt("CharacterModelRender", g_cpuProfiler);
model.GetRenderer().Render(modelContext, _pimpl->_charactersSharedStateSet, *i2,
RenderCore::Assets::MeshToModel(model.GetModelScaffold()), AsPointer(si));
}
CATCH_ASSETS_END(parserContext)
}
GPUProfiler::TriggerEvent(*context, g_gpuProfiler.get(), "RenderCharacters", GPUProfiler::End);
}
} else {
//
// In some cases we can't allocate preallocated state... This will happen
// on hardware without geometry shader support. Here, we have to render
// without geometry shaders / stream output
//
// (this will currently render without any animation applied)
//
for (auto i=_pimpl->_stateCache.begin(); i!=_pimpl->_stateCache.end(); ++i) {
CATCH_ASSETS_BEGIN
const auto& model = *i->_model;
for (auto i2=i->_instances.cbegin(); i2!=i->_instances.cend(); ++i2) {
model.GetRenderer().Render(modelContext, _pimpl->_charactersSharedStateSet, *i2);
}
CATCH_ASSETS_END(parserContext)
}
}
techEnv.SetParameter(StringAutoCotangent.c_str(), 0);
}
void CharactersScene::Prepare(
RenderCore::Metal::DeviceContext* context)
{
CPUProfileEvent pEvnt("CharactersScenePrepare", g_cpuProfiler);
// We need to prepare the animation state for all of the visible characters for
// this frame. Build the animation state before we do any rendering -- so
// usually this is one of the first steps in rendering any given frame.
if (RenderCore::Assets::ModelRenderer::CanDoPrepareAnimation(context)) {
while (_pimpl->_preallocatedState.size() < _pimpl->_stateCache.size()) {
_pimpl->_preallocatedState.push_back(_pimpl->_stateCache[0]._model->GetRenderer().CreatePreparedAnimation());
}
}
const bool interleavedRender = Tweakable("InterleavedRender", false);
if (interleavedRender)
return;
namespace GPUProfiler = RenderCore::Metal::GPUProfiler;
GPUProfiler::TriggerEvent(*context, g_gpuProfiler.get(), "PrepareAnimation", GPUProfiler::Begin);
RenderCore::Metal::GPUProfiler::DebugAnnotation anno(*context, L"PrepareCharacters");
//
// Separate state preparation from rendering, so we can profile
// them both separately
//
auto si = _pimpl->_preallocatedState.begin();
for (auto i=_pimpl->_stateCache.begin(); i!=_pimpl->_stateCache.end(); ++i, ++si) {
TRY {
const auto& model = *i->_model;
// 2 prepare steps
// * first, we need to generate the transform matrices
// * second, we generate the animated vertex positions
si->_animState = RenderCore::Assets::AnimationState(i->_time, i->_animation);
model.GetPrepareMachine().PrepareAnimation(context, *si);
model.GetRenderer().PrepareAnimation(context, *si, model.GetPrepareMachine().GetSkeletonBinding());
} CATCH(const ::Assets::Exceptions::AssetException&) {
} CATCH_END
}
GPUProfiler::TriggerEvent(*context, g_gpuProfiler.get(), "PrepareAnimation", GPUProfiler::End);
}
void CharactersScene::Cull(const Float4x4& worldToProjection)
{
CPUProfileEvent pEvnt("CharactersSceneCull", g_cpuProfiler);
// Prepare the list of visible characters
// Here we do culling against the edge of the screen. We could do occlusion
// and/or distance culling also... This implementation is very primitive.
// There is a lot of excessive allocations and some inefficiency.
// But it's ok for a sample.
//
// We actually need to do the culling for the main scene and shadows at the same time.
// This is because we need to collect a list of all of the characters that need to
// have their animation prepared for a frame. The animation needs to be built if
// that character is visible in the main scene, or in the shadows -- and only once
// if it is visible in both.
//
// So an ideal implementation of this would check each character against multiple
// frustums, and also calculate the correct shadow frustum flags required.
auto roughBoundingBox = std::make_pair(Float3(-2.f, -2.f, -2.f), Float3(2.f, 2.f, 2.f));
_pimpl->_stateCache.clear();
std::sort(_pimpl->_characters.begin(), _pimpl->_characters.end());
if (!_pimpl->_characters.empty() && Tweakable("DrawNPCs", true)) {
const float epsilon = 1.0f / (1.5f*60.f);
auto blockStart = _pimpl->_characters.begin();
for (auto i=_pimpl->_characters.begin();;++i) {
if ( i==_pimpl->_characters.end()
|| i->_model != blockStart->_model
|| i->_animState._animation != blockStart->_animState._animation
|| (i->_animState._time - blockStart->_animState._time) > epsilon) {
StateBin newState;
newState._model = blockStart->_model;
newState._animation = blockStart->_animState._animation;
newState._time = (blockStart->_animState._time + (i-1)->_animState._time) * .5f;
for (auto i2=blockStart; i2<i; ++i2) {
Float4x4 final = i2->_localToWorld;
Combine_InPlace(i2->_animState._motionCompensation * newState._time, final);
__declspec(align(16)) auto localToCulling = Combine(i2->_localToWorld, worldToProjection);
if (!CullAABB_Aligned(AsFloatArray(localToCulling), roughBoundingBox.first, roughBoundingBox.second)) {
newState._instances.push_back(final);
}
}
if (!newState._instances.empty()) {
_pimpl->_stateCache.push_back(std::move(newState));
}
if (i==_pimpl->_characters.end()) break;
blockStart = i;
}
}
}
for (auto i=_pimpl->_networkCharacters.cbegin();i!=_pimpl->_networkCharacters.cend();++i) {
StateBin newState;
newState._model = i->_model;
newState._animation = i->_animState._animation;
newState._time = i->_animState._time;
Float4x4 final = i->_localToWorld;
Combine_InPlace(i->_animState._motionCompensation * i->_animState._time, final);
__declspec(align(16)) auto localToCulling = Combine(i->_localToWorld, worldToProjection);
if (!CullAABB_Aligned(AsFloatArray(localToCulling), roughBoundingBox.first, roughBoundingBox.second)) {
newState._instances.push_back(final);
_pimpl->_stateCache.push_back(std::move(newState));
}
}
StateBin newState;
newState._model = _pimpl->_playerCharacter->_model;
newState._animation = _pimpl->_playerCharacter->_animState._animation;
newState._time = _pimpl->_playerCharacter->_animState._time;
Float4x4 final = _pimpl->_playerCharacter->_localToWorld;
Combine_InPlace(_pimpl->_playerCharacter->_animState._motionCompensation * _pimpl->_playerCharacter->_animState._time, final);
__declspec(align(16)) auto localToCulling = Combine(_pimpl->_playerCharacter->_localToWorld, worldToProjection);
if (!CullAABB_Aligned(AsFloatArray(localToCulling), roughBoundingBox.first, roughBoundingBox.second)) {
newState._instances.push_back(final);
_pimpl->_stateCache.push_back(std::move(newState));
}
}
void CharactersScene::Update(float deltaTime)
{
CPUProfileEvent pEvnt("CharactersSceneUpdate", g_cpuProfiler);
// update the simulations state for all characters
for (auto i = _pimpl->_characters.begin(); i!=_pimpl->_characters.end(); ++i) {
i->Update(deltaTime);
}
for (auto i = _pimpl->_networkCharacters.begin(); i!=_pimpl->_networkCharacters.end(); ++i) {
i->Update(deltaTime);
}
_pimpl->_playerCharacter->Update(deltaTime);
}
std::shared_ptr<PlayerCharacter> CharactersScene::GetPlayerCharacter()
{
return _pimpl->_playerCharacter;
}
Float4x4 CharactersScene::DefaultCameraToWorld() const
{
std::pair<Float3, Float3> boundingBox(Float3(0.f, 0.f, 0.f), Float3(0.f, 0.f, 0.f));
if (_pimpl->_characterModel) {
boundingBox = _pimpl->_characterModel->GetModelScaffold().GetStaticBoundingBox();
}
auto cameraFocusPoint = LinearInterpolate(boundingBox.first, boundingBox.second, 0.5f);
const Float3 defaultForwardVector(0.f, -1.f, 0.f);
const Float3 defaultUpVector(0.f, 0.f, 1.f);
const float boundingBoxDimension = Magnitude(boundingBox.second - boundingBox.first);
return
MakeCameraToWorld(
defaultForwardVector, defaultUpVector,
cameraFocusPoint - boundingBoxDimension * defaultForwardVector);
}
class CharacterInputFiles
{
public:
std::string _skin;
std::string _animationSet;
std::string _skeleton;
CharacterInputFiles(const std::string& basePath);
};
CharacterInputFiles::CharacterInputFiles(const std::string& basePath)
{
_skin = basePath + "/skin/dragon003";
_animationSet = basePath + "/animation";
_skeleton = basePath + "/skeleton/all_co_sk_whirlwind_launch_mub";
}
CharactersScene::CharactersScene()
{
auto pimpl = std::make_unique<Pimpl>();
CharacterInputFiles inputFiles("game/chr/nu_f");
pimpl->_characterModel = std::make_unique<CharacterModel>(
inputFiles._skin.c_str(), inputFiles._skeleton.c_str(), inputFiles._animationSet.c_str(),
std::ref(pimpl->_charactersSharedStateSet));
pimpl->_mainAnimDecisionTree = std::shared_ptr<AnimationDecisionTree>(
new AnimationDecisionTree(
pimpl->_characterModel->GetAnimationData(), CharactersScale));
#if defined(_DEBUG)
const unsigned npcCount = 5;
#else
const unsigned npcCount = 5;
#endif
for (unsigned c=0; c<npcCount; ++c) {
pimpl->_characters.push_back(NPCCharacter(*pimpl->_characterModel, pimpl->_mainAnimDecisionTree));
}
pimpl->_playerCharacter = std::make_shared<PlayerCharacter>(std::ref(*pimpl->_characterModel), pimpl->_mainAnimDecisionTree);
_pimpl = std::move(pimpl);
}
CharactersScene::~CharactersScene()
{
}
}
| [
"djewsbury@xlgames.com"
] | djewsbury@xlgames.com |
cb0fe17485f3912ccd9955b738589099cbae4707 | 8dc84558f0058d90dfc4955e905dab1b22d12c08 | /components/gcm_driver/gcm_internals_helper.cc | 04866807b9d3d68bb478f760e6f7f0f0159185f8 | [
"LicenseRef-scancode-unknown-license-reference",
"BSD-3-Clause"
] | permissive | meniossin/src | 42a95cc6c4a9c71d43d62bc4311224ca1fd61e03 | 44f73f7e76119e5ab415d4593ac66485e65d700a | refs/heads/master | 2022-12-16T20:17:03.747113 | 2020-09-03T10:43:12 | 2020-09-03T10:43:12 | 263,710,168 | 1 | 0 | BSD-3-Clause | 2020-05-13T18:20:09 | 2020-05-13T18:20:08 | null | UTF-8 | C++ | false | false | 7,601 | cc | // Copyright 2015 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 "components/gcm_driver/gcm_internals_helper.h"
#include <memory>
#include <utility>
#include "base/format_macros.h"
#include "base/i18n/time_formatting.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
#include "components/gcm_driver/gcm_activity.h"
#include "components/gcm_driver/gcm_internals_constants.h"
#include "components/gcm_driver/gcm_profile_service.h"
namespace gcm_driver {
namespace {
void SetCheckinInfo(const std::vector<gcm::CheckinActivity>& checkins,
base::ListValue* checkin_info) {
for (const gcm::CheckinActivity& checkin : checkins) {
auto row = std::make_unique<base::ListValue>();
row->AppendDouble(checkin.time.ToJsTime());
row->AppendString(checkin.event);
row->AppendString(checkin.details);
checkin_info->Append(std::move(row));
}
}
void SetConnectionInfo(const std::vector<gcm::ConnectionActivity>& connections,
base::ListValue* connection_info) {
for (const gcm::ConnectionActivity& connection : connections) {
auto row = std::make_unique<base::ListValue>();
row->AppendDouble(connection.time.ToJsTime());
row->AppendString(connection.event);
row->AppendString(connection.details);
connection_info->Append(std::move(row));
}
}
void SetRegistrationInfo(
const std::vector<gcm::RegistrationActivity>& registrations,
base::ListValue* registration_info) {
for (const gcm::RegistrationActivity& registration : registrations) {
auto row = std::make_unique<base::ListValue>();
row->AppendDouble(registration.time.ToJsTime());
row->AppendString(registration.app_id);
row->AppendString(registration.source);
row->AppendString(registration.event);
row->AppendString(registration.details);
registration_info->Append(std::move(row));
}
}
void SetReceivingInfo(const std::vector<gcm::ReceivingActivity>& receives,
base::ListValue* receive_info) {
for (const gcm::ReceivingActivity& receive : receives) {
auto row = std::make_unique<base::ListValue>();
row->AppendDouble(receive.time.ToJsTime());
row->AppendString(receive.app_id);
row->AppendString(receive.from);
row->AppendString(base::IntToString(receive.message_byte_size));
row->AppendString(receive.event);
row->AppendString(receive.details);
receive_info->Append(std::move(row));
}
}
void SetSendingInfo(const std::vector<gcm::SendingActivity>& sends,
base::ListValue* send_info) {
for (const gcm::SendingActivity& send : sends) {
auto row = std::make_unique<base::ListValue>();
row->AppendDouble(send.time.ToJsTime());
row->AppendString(send.app_id);
row->AppendString(send.receiver_id);
row->AppendString(send.message_id);
row->AppendString(send.event);
row->AppendString(send.details);
send_info->Append(std::move(row));
}
}
void SetDecryptionFailureInfo(
const std::vector<gcm::DecryptionFailureActivity>& failures,
base::ListValue* failure_info) {
for (const gcm::DecryptionFailureActivity& failure : failures) {
auto row = std::make_unique<base::ListValue>();
row->AppendDouble(failure.time.ToJsTime());
row->AppendString(failure.app_id);
row->AppendString(failure.details);
failure_info->Append(std::move(row));
}
}
} // namespace
void SetGCMInternalsInfo(const gcm::GCMClient::GCMStatistics* stats,
gcm::GCMProfileService* profile_service,
PrefService* prefs,
base::DictionaryValue* results) {
auto device_info = std::make_unique<base::DictionaryValue>();
device_info->SetBoolean(kProfileServiceCreated, profile_service != nullptr);
device_info->SetBoolean(kGcmEnabled,
gcm::GCMProfileService::IsGCMEnabled(prefs));
if (stats) {
results->SetBoolean(kIsRecording, stats->is_recording);
device_info->SetBoolean(kGcmClientCreated, stats->gcm_client_created);
device_info->SetString(kGcmClientState, stats->gcm_client_state);
device_info->SetBoolean(kConnectionClientCreated,
stats->connection_client_created);
device_info->SetString(kRegisteredAppIds,
base::JoinString(stats->registered_app_ids, ","));
if (stats->connection_client_created)
device_info->SetString(kConnectionState, stats->connection_state);
if (!stats->last_checkin.is_null()) {
device_info->SetString(
kLastCheckin, base::UTF16ToUTF8(base::TimeFormatFriendlyDateAndTime(
stats->last_checkin)));
}
if (!stats->next_checkin.is_null()) {
device_info->SetString(
kNextCheckin, base::UTF16ToUTF8(base::TimeFormatFriendlyDateAndTime(
stats->next_checkin)));
}
if (stats->android_id > 0) {
device_info->SetString(
kAndroidId, base::StringPrintf("0x%" PRIx64, stats->android_id));
}
if (stats->android_secret > 0) {
device_info->SetString(kAndroidSecret,
base::NumberToString(stats->android_secret));
}
device_info->SetInteger(kSendQueueSize, stats->send_queue_size);
device_info->SetInteger(kResendQueueSize, stats->resend_queue_size);
results->Set(kDeviceInfo, std::move(device_info));
if (stats->recorded_activities.checkin_activities.size() > 0) {
auto checkin_info = std::make_unique<base::ListValue>();
SetCheckinInfo(stats->recorded_activities.checkin_activities,
checkin_info.get());
results->Set(kCheckinInfo, std::move(checkin_info));
}
if (stats->recorded_activities.connection_activities.size() > 0) {
auto connection_info = std::make_unique<base::ListValue>();
SetConnectionInfo(stats->recorded_activities.connection_activities,
connection_info.get());
results->Set(kConnectionInfo, std::move(connection_info));
}
if (stats->recorded_activities.registration_activities.size() > 0) {
auto registration_info = std::make_unique<base::ListValue>();
SetRegistrationInfo(stats->recorded_activities.registration_activities,
registration_info.get());
results->Set(kRegistrationInfo, std::move(registration_info));
}
if (stats->recorded_activities.receiving_activities.size() > 0) {
auto receive_info = std::make_unique<base::ListValue>();
SetReceivingInfo(stats->recorded_activities.receiving_activities,
receive_info.get());
results->Set(kReceiveInfo, std::move(receive_info));
}
if (stats->recorded_activities.sending_activities.size() > 0) {
auto send_info = std::make_unique<base::ListValue>();
SetSendingInfo(stats->recorded_activities.sending_activities,
send_info.get());
results->Set(kSendInfo, std::move(send_info));
}
if (stats->recorded_activities.decryption_failure_activities.size() > 0) {
auto failure_info = std::make_unique<base::ListValue>();
SetDecryptionFailureInfo(
stats->recorded_activities.decryption_failure_activities,
failure_info.get());
results->Set(kDecryptionFailureInfo, std::move(failure_info));
}
}
}
} // namespace gcm_driver
| [
"arnaud@geometry.ee"
] | arnaud@geometry.ee |
9f817e5096dfa008e768048cddbcf4604d8a4b3b | 07f3f79753805e0ba934baf7c05c3e79ca6227e1 | /Hons/Jaarprojek/Cutter/parse.cpp | c02953c17d1b83e526e298e0719bfb45a0f2e97d | [] | no_license | dtbinh/university-projects | a269081daa017bcedf75967beca2f87e8da62526 | ba1a3e4289cc0b7df316c49cdf4a5137d2ffa782 | refs/heads/master | 2021-04-12T11:30:07.647688 | 2012-05-07T12:31:51 | 2012-05-07T12:31:51 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,327 | cpp | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include "include/cutglobal.h"
#include "include/cut.h"
#include "include/split.h"
double picture_rates [9] = { 0., 24000./1001., 24., 25.,
30000./1001., 30., 50.,
60000./1001., 60. };
int FindNextMarker(offset* off,marker* mark){
offset myoffset=*off;
while(myoffset<FileSize-3){
// is there enough ?
if ((myoffset-Start) > (BUFFSIZE-16)){
FillBuffer(myoffset);
}
if ( (GetByte(myoffset+0) == 0x00) && (GetByte(myoffset+1) == 0x00) &&
(GetByte(myoffset+2) == 0x01)){
*off=myoffset+4;
*mark=GetByte(myoffset+3);
// printf("Trouv�marqueur %02x offset %ld [%04lx]\n",
// GetByte(myoffset+3),myoffset,myoffset);
return 1;
}
myoffset++;
}
EoF=1;
return 0;
}
void ReadGOPHeader(offset off, double* timestamp){
Byte hour,min,sec,count;
*timestamp=0;
// printf(" [%02x %02x %02x %02x]\n",
// GetByte(off),GetByte(off+1),GetByte(off+2),GetByte(off+3));
// printf(" Drop frame marker: ");
// if (GetByte(off)&0x80) printf("1\n");
// else printf("0\n");
hour=GetByte(off);
hour &= !0x80; //clears drop frame marker bit
hour >>=2; //hour :bits[6-2]
*timestamp+=hour*3600;
// printf(" hour : %d\n",hour);
min=GetByte(off+1);
min >>=4;
hour=GetByte(off);
hour <<= 6 ;
hour >>=2;
min ^= hour;
*timestamp+=min*60;
// printf(" minutes : %d\n",min);
min=GetByte(off+1);
min <<= 5;
min >>= 2;
sec=GetByte(off+2);
sec >>=5;
sec ^= min;
*timestamp+=sec;
// printf(" secondes : %d\n",sec);
count=GetByte(off+2);
count <<=3;
count >>=2;
sec=GetByte(off+3);
if (sec & 0x80) count |= 0x01;
*timestamp += count / FrameRate;
// printf(" count : %d\n",count);
// printf (" Closed GOP flag : ");
// if (sec & 0x40) printf("1\n");
// else printf("O\n");
// printf(" Broken link flag : ");
// if (sec & 0x20) printf("1\n");
// else printf("O\n");
}
void ParseVidSeq(offset* off){
int horsize,versize;
int pictrate;
marker mymark;
offset saveoff=*off;
starttime=-1;
VidSeqStart=(*off)-4;
horsize=(GetSize(*off)>>4);
versize=(GetSize((*off)+1)&0x0fff);
printf("mpeg video is %d x %d\n",horsize,versize);
pictrate=(GetByte((*off)+3)&0x0f);
if (pictrate>8) {
FrameRate=0;
printf("invalid picture rate... strange\n");
}
else {
FrameRate=picture_rates[pictrate];
printf("picture rate is %f fps\n",picture_rates[pictrate]);
}
//we'd have to really parse the remaining but too lazy
// let's just find next marker which should be a GOP
*off+=6; //at least
while (1==1){
if (FindNextMarker(off,&mymark)&&(mymark==0xb8)){
//we have it! aren't we too far?
if (((*off) - saveoff)<150 ){
//yeah Y 150? -> because (hint 2 matrix)
if (FileType==VIDEOFILE){
ReadGOPHeader(*off,&starttime); //get time written in first GOP
}/*else{
BackwardFindBoundaries(*off,&pstart,&pend);
if (GetByte(pstart+3)==0xe0) {
// that's a video packet ok
offset pstart2=pstart+6;
ReadPacketTS(&pstart2,&pts,&dts);
if(dts!=-1){
starttime=dts;
}else{
starttime=pts;
}
}
}*/
// printf("Video Sequence header seems to end at [0x%lx]\n",
// (*off)-4);
VidSeqEnd=(*off-4);
if (FileType==SYSTEMFILE){
MinimumCut=VidSeqStart;
while(1){
MinimumCut--;
if (MinimumCut<=0) {
printf("lost, exiting\n");
exit(1);
}
if (EnsureMarker(&MinimumCut,&mymark)){
if (mymark==0xba){
MinimumCut-=4;break;
}else{
MinimumCut -=4;
}
}
}
}else{
MinimumCut=(*off)-4;
}
break;
}else{
//mmm it seems we're lost let's givit a try
printf("Video Sequence header seems to end at [0x%lx] but we might be lost :/\n",
(*off)-4);
VidSeqEnd=(*off-4);
if (FileType==SYSTEMFILE){
MinimumCut=VidSeqStart;
while(1){
MinimumCut--;
if (MinimumCut<=0) {
printf("lost, exiting\n");
exit(1);
}
if (EnsureMarker(&MinimumCut,&mymark)) {
if (mymark==0xba){
MinimumCut-=4;break;
}else{
MinimumCut -=4;
}
}
}
}else{
MinimumCut=(*off)-4;
}
break;
}
}
if(EoF==1){ // end of file reached :/
printf("couldn't find first GOP! let's die\n");
exit(1);
}
//printf("Strange I just passed a 00 00 01 %02x sequence...\n",
// mymark);
}
}
int FindNext(offset* off,marker mark){
offset myoffset=*off;
while(myoffset<FileSize-3){
// is there enough ?
if ((myoffset-Start) > (BUFFSIZE-16)){
FillBuffer(myoffset);
}
if ( (GetByte(myoffset+0) == 0x00) &&
(GetByte(myoffset+1) == 0x00) &&
(GetByte(myoffset+2) == 0x01) &&
(GetByte(myoffset+3) == mark)){
*off=myoffset+4;
// printf("Trouv�marqueur %02x offset %ld [%04lx]\n",
// GetByte(myoffset+3),myoffset,myoffset);
return 1;
}
myoffset++;
}
// printf("Fin du fichier atteinte :/ \n");
EoF=1;
return 0;
}
int FindVideoSeqHeader(offset* off){
//we're parsing a system file...
//ugly way : find 00 00 01 B3
//smart way : parse PACK headers and packets type
// try to find a video seq in video packet
// let's be ugly :>
return FindNext(off,0xb3);
}
| [
"abriegreeff@gmail.com"
] | abriegreeff@gmail.com |
8554efb3927843864f785856815b70794ca0fbea | 5c584b783acb1a2345f0035b3a4fcb48131aa28a | /Atividades/mario/lista 01/code block potencia 2.cpp | 73fad777904e9ce459eb4239e1dc0796b54014fc | [] | no_license | eirinaga/APREM2-2019-2 | e9eb617a2d5aa5846a0809d229a576e750247f41 | 390ab758bf2c8c59e3d8ae248cd8b460ebe2d8f4 | refs/heads/master | 2020-09-09T22:40:22.741795 | 2019-11-13T20:47:50 | 2019-11-13T20:47:50 | 221,587,976 | 1 | 0 | null | 2019-11-14T01:48:52 | 2019-11-14T01:48:51 | null | ISO-8859-1 | C++ | false | false | 880 | cpp | /**********************************************************
- Autor: Seu nome
- Descrição: Breve descrição do programa
**********************************************************/
#include <iostream>
#include <locale.h>
#include <cstdlib>
using namespace std;
int main()
{
//Declaração de variáveis
float fcomodo1=0;
float fcomodo2=0;
float fareatotal=0;
float fconsumo=0;
//Configuração da tela de saída
setlocale(LC_ALL,"");
system("color F1");
//Código do programa
cout << " informe a área do comodo 1 em metros ";
cin >> fcomodo1;
cout << " informe a área do comodo 2 em metros ";
cin >> fcomodo2;
fareatotal= fcomodo1+fcomodo2;
fconsumo= fareatotal*18;
cout << " a área total dos comodos é " << fareatotal;
cout << " o total de Watts consumidos foram " << fconsumo << endl;
return 0;
}
| [
"noreply@github.com"
] | eirinaga.noreply@github.com |
2ed18f5738a917e59a807b80bd3d85410f387bb9 | 8a51ed60784042039aa955bd7659fb38983a43f6 | /math.cpp | 2636a07c597dbf72378382df6dd22f79c4898dd5 | [] | no_license | zasimov/kf | 55c782a9cd3f9ee768293327a7da44c62c56ac3f | b1922724d89c409ceb7c77176f52feeb03bd75bb | refs/heads/master | 2021-01-23T23:46:26.423173 | 2018-03-11T16:08:35 | 2018-03-11T16:08:35 | 122,736,420 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,884 | cpp | #include <cmath>
#include "logging.h"
#include "math.h"
bool IsZero(double d) {
return fabs(d) < kZero;
}
const unsigned kRadarZDim = 3;
Eigen::MatrixXd CalculateJacobian(const Eigen::VectorXd& x_predicted) {
Eigen::MatrixXd Hj(kRadarZDim, x_predicted.size());
// recover state parameters
double px = x_predicted(0);
double py = x_predicted(1);
double vx = x_predicted(2);
double vy = x_predicted(3);
// pre-compute a set of terms to avoid repeated calculation
double c1 = px * px + py * py;
// check division by zero
if (IsZero(c1)) {
logging::error("Division by zero in CalculateJacobian");
Hj.setZero();
return Hj;
}
double c2 = sqrt(c1);
double c3 = (c1 * c2);
// compute the Jacobian matrix
Hj << (px/c2), (py/c2), 0, 0,
-(py/c1), (px/c1), 0, 0,
py*(vx*py - vy*px)/c3, px*(px*vy - py*vx)/c3, px/c2, py/c2;
return Hj;
}
Eigen::VectorXd ToPolar(const Eigen::VectorXd &x) {
assert(x.size() == 4);
double px = x[0];
double py = x[1];
double vx = x[2];
double vy = x[3];
if (IsZero(px)) {
px = kZero;
}
double rho = sqrt(px * px + py * py);
double rho_dot;
if (IsZero(rho)) {
rho_dot = 0;
} else {
rho_dot = (px * vx + py * vy) / rho;
}
double phi = atan2(py, px);
Eigen::VectorXd polar(3);
polar << rho, phi, rho_dot;
return polar;
}
Eigen::VectorXd ToCartesian(const Eigen::VectorXd &v) {
double rho = v[0];
double phi = v[1];
double rho_dot = v[2];
Eigen::VectorXd cartesian(4);
cartesian << rho * cos(phi),
rho * sin(phi),
rho_dot * cos(phi),
rho_dot * sin(phi);
return cartesian;
}
Eigen::VectorXd CalculateRMSE(const std::vector<Eigen::VectorXd> &estimations,
const std::vector<Eigen::VectorXd> &ground_truth) {
Eigen::VectorXd rmse(4);
rmse << 0,0,0,0;
// check the validity of the following inputs:
// * the estimation vector size should not be zero
// * the estimation vector size should equal ground truth vector size
if (estimations.size() != ground_truth.size() || estimations.size() == 0){
return rmse;
}
// accumulate squared residuals
for(unsigned i = 0; i < estimations.size(); ++i){
Eigen::VectorXd residual = estimations[i] - ground_truth[i];
residual = residual.array() * residual.array();
rmse += residual;
}
// calculate the mean
rmse = rmse/estimations.size();
// calculate the squared root
rmse = rmse.array().sqrt();
// return the result
return rmse;
}
// normalize the angle to be within -pi to pi
double NormalizeAngle(const double angle)
{
double normalized_angle = angle;
if (fabs(angle) > M_PI) {
static const double two_pi = 2 * M_PI;
normalized_angle -= round(normalized_angle / two_pi) * two_pi;
}
return normalized_angle;
}
| [
"zasimov@gmail.com"
] | zasimov@gmail.com |
c047b664098d78c777e6f27e273f1301a67999ec | a4f138d473ffb3c019cdedd26fac94876c1ded30 | /src/Sequence IJ 3.cpp | 55fc18ddbead409eebe6937bd1a89074ad91d6cc | [] | no_license | TarekkMA/URI-Online-Judge-Solutions- | 469d05b8c8ca0aafc849b40dd8d1598ff1f5e5ad | 41b61e1bc59a254240fcc22d3b28118dc54d32dc | refs/heads/master | 2020-12-02T18:03:33.949843 | 2017-07-06T19:50:55 | 2017-07-06T19:50:55 | 96,465,834 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 255 | cpp | #include<stdio.h>
int main(){
int lowerBound = 5;
for(int i=1,j=7;j!=lowerBound-1;j--){
printf("I=%d J=%d\n",i,j);
if(j==lowerBound&&i!=9){
lowerBound+=2;
j=lowerBound+3;
i+=2;
}
}
} | [
"tarekkma@gmail.com"
] | tarekkma@gmail.com |
1c6dec5e197d313809c90afbf576205c945e26c4 | 6303a714ee0fc1d50cead52abe038da3475f0472 | /DiscImageCreator/execScsiCmdforCDCheck.cpp | 5198e016dc96273f096090abecfab7f84c5b44ec | [
"Apache-2.0",
"Zlib",
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | ArcadeHustle/DiscImageCreator | a94e90104699fc787574340e13f737a1212f19a1 | 70a4a2d889ef1f17762ca93a5dfbea4b4852f79e | refs/heads/master | 2020-07-29T19:23:09.395074 | 2019-08-28T13:22:12 | 2019-08-28T13:22:12 | null | 0 | 0 | null | null | null | null | SHIFT_JIS | C++ | false | false | 57,881 | cpp | /**
* Copyright 2011-2018 sarami
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "struct.h"
#include "calcHash.h"
#include "check.h"
#include "convert.h"
#include "execScsiCmd.h"
#include "execScsiCmdforCD.h"
#include "execScsiCmdforCDCheck.h"
#include "execScsiCmdforFileSystem.h"
#include "get.h"
#include "output.h"
#include "outputScsiCmdLogforCD.h"
#include "set.h"
BOOL ReadCDForSubChannelOffset(
PEXT_ARG pExtArg,
PDEVICE pDevice,
PDISC pDisc,
LPBYTE lpCmd,
INT nLBA,
LPBYTE lpBuf,
UINT uiBufLen
) {
BOOL bRet = TRUE;
LPBYTE pBuf = NULL;
LPBYTE lpBufTmp = NULL;
if (!GetAlignedCallocatedBuffer(pDevice, &pBuf,
uiBufLen, &lpBufTmp, _T(__FUNCTION__), __LINE__)) {
return FALSE;
}
memcpy(lpBufTmp, lpBuf, uiBufLen);
BYTE lpSubcode[CD_RAW_READ_SUBCODE_SIZE] = {};
for (INT i = 0; i < 5; i++) {
if (uiBufLen == CD_RAW_READ_SUBCODE_SIZE) {
AlignRowSubcode(lpSubcode, lpBufTmp);
}
else if (uiBufLen == CD_RAW_SECTOR_WITH_SUBCODE_SIZE) {
AlignRowSubcode(lpSubcode, lpBufTmp + CD_RAW_SECTOR_SIZE);
}
else if (uiBufLen == CD_RAW_SECTOR_WITH_C2_294_AND_SUBCODE_SIZE) {
if (pDevice->driveOrder == DRIVE_DATA_ORDER::MainSubC2) {
AlignRowSubcode(lpSubcode, lpBufTmp + CD_RAW_SECTOR_SIZE);
}
else {
AlignRowSubcode(lpSubcode, lpBufTmp + CD_RAW_SECTOR_WITH_C2_294_SIZE);
}
}
else if (uiBufLen == CD_RAW_SECTOR_WITH_C2_AND_SUBCODE_SIZE) {
if (pDevice->driveOrder == DRIVE_DATA_ORDER::MainSubC2) {
AlignRowSubcode(lpSubcode, lpBufTmp + CD_RAW_SECTOR_SIZE);
}
else {
AlignRowSubcode(lpSubcode, lpBufTmp + CD_RAW_SECTOR_WITH_C2_SIZE);
}
}
OutputCDSub96Align(fileDisc, lpSubcode, nLBA);
BOOL bCheckSubQAllZero = TRUE;
for (INT j = 12; j < 24; j++) {
if (lpSubcode[j] != 0) {
bCheckSubQAllZero = FALSE;
break;
}
}
if (bCheckSubQAllZero) {
OutputDiscLogA("SubQ is all zero... (BufLen: %d)\n", uiBufLen);
break;
}
if ((lpSubcode[12] & 0x0f) == ADR_ENCODES_CURRENT_POSITION) {
pDisc->SUB.nSubChannelOffset = MSFtoLBA(BcdToDec(lpSubcode[19]),
BcdToDec(lpSubcode[20]), BcdToDec(lpSubcode[21])) - 150 - nLBA;
break;
}
else {
if (!ExecReadCD(pExtArg, pDevice, lpCmd, ++nLBA
, lpBufTmp, uiBufLen, _T(__FUNCTION__), __LINE__)) {
bRet = FALSE;
break;
}
}
}
FreeAndNull(pBuf);
return bRet;
}
BOOL ExecSearchingOffset(
PEXEC_TYPE pExecType,
PEXT_ARG pExtArg,
PDEVICE pDevice,
PDISC pDisc,
LPBYTE lpCmd,
INT nLBA,
LPBYTE lpBuf,
UINT uiBufSize,
BOOL bGetDriveOffset,
INT nDriveSampleOffset,
INT nDriveOffset
) {
BOOL bRet = ExecReadCD(pExtArg, pDevice, lpCmd
, nLBA, lpBuf, uiBufSize, _T(__FUNCTION__), __LINE__);
if (!bRet) {
if (*pExecType == gd) {
OutputErrorString(
_T("Couldn't read a data sector at scrambled mode [OpCode: %#02x, C2flag: %x, SubCode: %x]\n")
, lpCmd[0], (lpCmd[9] & 0x6) >> 1, lpCmd[10]);
}
else {
if ((pExtArg->byD8 || pDevice->byPlxtrDrive) && !pExtArg->byBe) {
OutputLogA(standardError | fileDrive,
"This drive doesn't support [OpCode: %#02x, SubCode: %x]\n", lpCmd[0], lpCmd[10]);
}
else {
OutputErrorString(
_T("This drive can't read a data sector at scrambled mode [OpCode: %#02x, C2flag: %x, SubCode: %x]\n")
, lpCmd[0], (lpCmd[9] & 0x6) >> 1, lpCmd[10]);
}
}
return FALSE;
}
else {
if ((pExtArg->byD8 || pDevice->byPlxtrDrive) && !pExtArg->byBe) {
OutputLogA(standardOut | fileDrive,
"This drive supports [OpCode: %#02x, SubCode: %x]\n", lpCmd[0], lpCmd[10]);
}
else {
if (*pExecType != data) {
OutputLogA(standardOut | fileDrive,
"This drive can read a data sector at scrambled mode [OpCode: %#02x, C2flag: %x, SubCode: %x]\n"
, lpCmd[0], (lpCmd[9] & 0x6) >> 1, lpCmd[10]);
}
}
}
if ((pExtArg->byD8 || pDevice->byPlxtrDrive) && !pExtArg->byBe) {
if (lpCmd[10] == CDFLAG::_PLXTR_READ_CDDA::MainQ ||
lpCmd[10] == CDFLAG::_PLXTR_READ_CDDA::Raw) {
// because check only
return TRUE;
}
OutputDiscLogA(
OUTPUT_DHYPHEN_PLUS_STR_WITH_SUBCH_F(Check Drive + CD offset), lpCmd[0], lpCmd[10]);
}
else if ((!pExtArg->byD8 && !pDevice->byPlxtrDrive) || pExtArg->byBe) {
if (lpCmd[10] == CDFLAG::_READ_CD::Q) {
// because check only
return TRUE;
}
OutputDiscLogA(
OUTPUT_DHYPHEN_PLUS_STR_WITH_C2_SUBCH_F(Check Drive + CD offset), lpCmd[0], (lpCmd[9] & 0x6) >> 1, lpCmd[10]);
}
if (pDisc->SCSI.trackType != TRACK_TYPE::audioOnly || *pExecType == swap) {
if (*pExecType != data) {
OutputCDMain(fileDisc, lpBuf, nLBA, CD_RAW_SECTOR_SIZE);
}
}
if (uiBufSize == CD_RAW_SECTOR_WITH_SUBCODE_SIZE ||
uiBufSize == CD_RAW_SECTOR_WITH_C2_294_AND_SUBCODE_SIZE ||
uiBufSize == CD_RAW_SECTOR_WITH_C2_AND_SUBCODE_SIZE) {
if (!ReadCDForSubChannelOffset(pExtArg, pDevice, pDisc, lpCmd, nLBA, lpBuf, uiBufSize)) {
return FALSE;
}
}
if (*pExecType == data) {
if (pDisc->SUB.nSubChannelOffset != 0xff) {
OutputDiscLogA("\tSubChannel Offset: %d\n", pDisc->SUB.nSubChannelOffset);
}
}
else {
if (pDisc->SCSI.trackType != TRACK_TYPE::audioOnly || *pExecType == swap) {
BYTE aBuf[CD_RAW_SECTOR_SIZE * 2] = {};
memcpy(aBuf, lpBuf, CD_RAW_SECTOR_SIZE);
if (!ExecReadCD(pExtArg, pDevice, lpCmd, nLBA + 1
, lpBuf, uiBufSize, _T(__FUNCTION__), __LINE__)) {
return FALSE;
}
OutputCDMain(fileDisc, lpBuf, nLBA + 1, CD_RAW_SECTOR_SIZE);
memcpy(aBuf + CD_RAW_SECTOR_SIZE, lpBuf, CD_RAW_SECTOR_SIZE);
if (pDisc->SCSI.trackType != TRACK_TYPE::audioOnly || *pExecType == swap) {
if (!GetWriteOffset(pDisc, aBuf)) {
if (pDisc->SCSI.trackType == TRACK_TYPE::dataExist ||
pDisc->SCSI.trackType == TRACK_TYPE::pregapDataIn1stTrack) {
OutputLogA(standardError | fileDisc, _T("Failed to get write-offset\n"));
return FALSE;
}
OutputLogA(standardOut | fileDisc,
"There isn't data sector in pregap sector of track 1\n");
pDisc->SCSI.trackType = TRACK_TYPE::audioOnly;
}
}
}
else if (pDisc->SCSI.trackType == TRACK_TYPE::audioOnly &&
(pExtArg->byVideoNow || pExtArg->byVideoNowColor)) {
LPBYTE pBuf2 = NULL;
LPBYTE lpBuf2 = NULL;
if (!GetAlignedCallocatedBuffer(pDevice, &pBuf2,
CD_RAW_SECTOR_SIZE * 15, &lpBuf2, _T(__FUNCTION__), __LINE__)) {
return FALSE;
}
memcpy(lpBuf2, lpBuf, CD_RAW_SECTOR_SIZE);
BYTE aBuf[CD_RAW_SECTOR_WITH_C2_AND_SUBCODE_SIZE] = {};
for (INT k = 1; k < 15; k++) {
if (!ExecReadCD(pExtArg, pDevice, lpCmd, nLBA + k
, aBuf, uiBufSize, _T(__FUNCTION__), __LINE__)) {
return FALSE;
}
memcpy(lpBuf2 + CD_RAW_SECTOR_SIZE * k, aBuf, CD_RAW_SECTOR_SIZE);
}
// VideoNow Color Jr. XP
CONST BYTE aVideoNowBytes[] = {
0x81, 0xe3, 0xe3, 0xc7, 0xc7, 0x81, 0x81, 0xe3,
};
// VideoNow B&W
CONST BYTE aVideoNowBytesOrg[] = {
0xe1, 0xe1, 0xe1, 0x01, 0xe1, 0xe1, 0xe1, 0x00,
};
INT nSector = 1;
for (INT i = 0; i < CD_RAW_SECTOR_SIZE * 15; i++) {
for (size_t c = 0; c < sizeof(aVideoNowBytes); c++) {
if (lpBuf2[i + c] != aVideoNowBytes[c]) {
bRet = FALSE;
break;
}
if (c == sizeof(aVideoNowBytes) - 1) {
OutputLogA(standardOut | fileDisc, "Detected VideoNow Color or Jr. or XP\n");
bRet = TRUE;
if (pExtArg->byVideoNowColor) {
OutputLogA(standardOut | fileDisc, "Search incomplete frame of track 01\n");
LPBYTE pBuf3 = NULL;
LPBYTE lpBuf3 = NULL;
if (!GetAlignedCallocatedBuffer(pDevice, &pBuf3,
CD_RAW_SECTOR_SIZE * 9, &lpBuf3, _T(__FUNCTION__), __LINE__)) {
return FALSE;
}
INT tmpLBA = 883;
nSector--;
for (INT j = nSector; j < 9 + nSector; j++) {
if (!ExecReadCD(pExtArg, pDevice, lpCmd, tmpLBA + j
, aBuf, uiBufSize, _T(__FUNCTION__), __LINE__)) {
return FALSE;
}
memcpy(lpBuf3 + CD_RAW_SECTOR_SIZE * (j - nSector), aBuf, CD_RAW_SECTOR_SIZE);
OutputCDMain(fileMainInfo, lpBuf3 + CD_RAW_SECTOR_SIZE * (j - nSector), tmpLBA + j, CD_RAW_SECTOR_SIZE);
}
INT n1stHeaderOfs = 0;
INT n2ndHeaderOfs = 0;
for (INT m = 0; m < CD_RAW_SECTOR_SIZE * 9; m++) {
for (size_t d = 0; d < sizeof(aVideoNowBytes); d++) {
if (lpBuf3[m + d] != aVideoNowBytes[d]) {
bRet = FALSE;
break;
}
if (d == sizeof(aVideoNowBytes) - 1) {
if (n1stHeaderOfs == 0) {
n1stHeaderOfs = m;
OutputLogA(standardOut | fileDisc, "1stHeaderOfs: %d (0x%x)\n"
, n1stHeaderOfs, n1stHeaderOfs);
m += 400;
break;
}
else {
n2ndHeaderOfs = m;
OutputLogA(standardOut | fileDisc, "2ndHeaderOfs: %d (0x%x)\n"
, n2ndHeaderOfs, n2ndHeaderOfs);
OutputLogA(standardOut | fileDisc
, "Empty bytes which are needed in this disc: %d [18032 - (%d - %d)]\n"
, 18032 - (n2ndHeaderOfs - n1stHeaderOfs)
, n2ndHeaderOfs, n1stHeaderOfs
);
pExtArg->nAudioCDOffsetNum = 18032 - (n2ndHeaderOfs - n1stHeaderOfs);
bRet = TRUE;
break;
}
}
}
if (bRet) {
break;
}
}
FreeAndNull(pBuf3);
}
}
}
if (!bRet) {
for (size_t c = 0; c < sizeof(aVideoNowBytesOrg); c++) {
if (lpBuf2[i + c] != aVideoNowBytesOrg[c]) {
bRet = FALSE;
break;
}
if (c == sizeof(aVideoNowBytesOrg) - 1) {
OutputLogA(standardOut | fileDisc, "Detected VideoNow B&W\n");
bRet = TRUE;
}
}
}
if (bRet) {
pDisc->MAIN.nCombinedOffset = i - pExtArg->nAudioCDOffsetNum;
if (!pExtArg->byVideoNowColor) {
nSector--;
OutputCDMain(fileDisc, lpBuf2 + CD_RAW_SECTOR_SIZE * nSector, nLBA + nSector, CD_RAW_SECTOR_SIZE);
}
break;
}
else if (i == CD_RAW_SECTOR_SIZE * nSector - 1) {
nSector++;
}
}
FreeAndNull(pBuf2);
}
else if (pDisc->SCSI.trackType == TRACK_TYPE::audioOnly && pExtArg->byAtari) {
// Atari Jaguar CD Header
// 00 00 54 41 49 52 54 41 49 52 54 41 49 52 54 41 ..TAIRTAIRTAIRTA
// 49 52 54 41 49 52 54 41 49 52 54 41 49 52 54 41 IRTAIRTAIRTAIRTA
// 49 52 54 41 49 52 54 41 49 52 54 41 49 52 54 41 IRTAIRTAIRTAIRTA
// 49 52 54 41 49 52 54 41 49 52 54 41 49 52 54 41 IRTAIRTAIRTAIRTA
// 49 52 54 41 52 41 20 49 50 41 52 50 56 4F 44 45 IRTARA IPARPVODE
// 44 20 54 41 20 41 45 48 44 41 52 45 41 20 52 54 D TA AEHDAREA RT
// 20 49 I
// => "ATRIATRI ... ATARI APPROVED DATA HEADER ATRI "
// Atari Jaguar CD Tailer
// 54 41 52 41 20 49 50 41 52 50 56 4F 44 45 TARA IPARPVODE
// 44 20 54 41 20 41 41 54 4C 49 52 45 41 20 52 54 D TA AATLIREA RT
// 20 49 54 41 49 52 54 41 49 52 54 41 49 52 54 41 ITAIRTAIRTAIRTA
// 49 52 54 41 49 52 54 41 49 52 54 41 49 52 54 41 IRTAIRTAIRTAIRTA
// 49 52 54 41 49 52 54 41 49 52 54 41 49 52 54 41 IRTAIRTAIRTAIRTA
// 49 52 54 41 49 52 54 41 49 52 54 41 49 52 54 41 IRTAIRTAIRTAIRTA
// 49 52 IR
// => "ATARI APPROVED DATA TAILER ATRI ATRIATRI ..."
CONST BYTE aAtariBytes[] = {
0x54, 0x41, 0x49, 0x52, 0x54, 0x41, 0x49, 0x52,
};
INT nSector = 0;
nLBA = pDisc->SCSI.nFirstLBAof2ndSession;
do {
if (!ExecReadCD(pExtArg, pDevice, lpCmd, nLBA
, lpBuf, uiBufSize, _T(__FUNCTION__), __LINE__)) {
return FALSE;
}
for (INT i = 0; i < CD_RAW_SECTOR_SIZE; i++) {
for (size_t c = 0; c < sizeof(aAtariBytes); c++) {
if (lpBuf[i + c] != aAtariBytes[c]) {
bRet = FALSE;
break;
}
if (c == sizeof(aAtariBytes) - 1) {
OutputLogA(standardOut | fileDisc, "Detected Atari Jaguar CD Header\n");
bRet = TRUE;
}
}
if (bRet) {
pDisc->MAIN.nCombinedOffset = i - 2 + CD_RAW_SECTOR_SIZE * nSector;
OutputCDMain(fileDisc, lpBuf, nLBA, CD_RAW_SECTOR_SIZE);
break;
}
}
if (!bRet) {
nSector--;
nLBA += nSector;
}
} while (!bRet);
}
OutputCDOffset(pExtArg, pDisc, bGetDriveOffset
, nDriveSampleOffset, nDriveOffset, pDisc->SUB.nSubChannelOffset);
}
return TRUE;
}
BOOL ReadCDForSearchingOffset(
PEXEC_TYPE pExecType,
PEXT_ARG pExtArg,
PDEVICE pDevice,
PDISC pDisc
) {
BOOL bRet = TRUE;
INT nDriveSampleOffset = 0;
BOOL bGetDriveOffset = GetDriveOffsetAuto(pDevice->szProductId, &nDriveSampleOffset);
#ifdef _DEBUG
if (pDevice->byPlxtrDrive == PLXTR_DRIVE_TYPE::PX760A ||
pDevice->byPlxtrDrive == PLXTR_DRIVE_TYPE::PX755A ||
pDevice->byPlxtrDrive == PLXTR_DRIVE_TYPE::PX716AL ||
pDevice->byPlxtrDrive == PLXTR_DRIVE_TYPE::PX716A ||
pDevice->byPlxtrDrive == PLXTR_DRIVE_TYPE::PX714A ||
pDevice->byPlxtrDrive == PLXTR_DRIVE_TYPE::PX712A ||
pDevice->byPlxtrDrive == PLXTR_DRIVE_TYPE::PX708A2 ||
pDevice->byPlxtrDrive == PLXTR_DRIVE_TYPE::PX708A ||
pDevice->byPlxtrDrive == PLXTR_DRIVE_TYPE::PX704A ||
pDevice->byPlxtrDrive == PLXTR_DRIVE_TYPE::PREMIUM2 ||
pDevice->byPlxtrDrive == PLXTR_DRIVE_TYPE::PREMIUM ||
pDevice->byPlxtrDrive == PLXTR_DRIVE_TYPE::PXW5224A
) {
nDriveSampleOffset = 30;
bGetDriveOffset = TRUE;
}
else if (
pDevice->byPlxtrDrive == PLXTR_DRIVE_TYPE::PXW4824A ||
pDevice->byPlxtrDrive == PLXTR_DRIVE_TYPE::PXW4012A ||
pDevice->byPlxtrDrive == PLXTR_DRIVE_TYPE::PXW4012S
) {
nDriveSampleOffset = 98;
bGetDriveOffset = TRUE;
}
else if (!strncmp(pDevice->szProductId, "DVD-ROM TS-H353A", 16)) {
nDriveSampleOffset = 6;
bGetDriveOffset = TRUE;
}
#endif
if (!bGetDriveOffset) {
GetDriveOffsetManually(&nDriveSampleOffset);
}
INT nDriveOffset = nDriveSampleOffset * 4; // byte size * 4 = sample size
if (pDisc->SCSI.trackType != TRACK_TYPE::dataExist &&
pDisc->SCSI.trackType != TRACK_TYPE::pregapDataIn1stTrack) {
pDisc->MAIN.nCombinedOffset = nDriveOffset;
}
LPBYTE pBuf = NULL;
LPBYTE lpBuf = NULL;
if (!GetAlignedCallocatedBuffer(pDevice, &pBuf,
CD_RAW_SECTOR_WITH_C2_AND_SUBCODE_SIZE, &lpBuf, _T(__FUNCTION__), __LINE__)) {
return FALSE;
}
if (*pExecType == gd) {
pDisc->SCSI.nFirstLBAofDataTrack = FIRST_LBA_FOR_GD;
}
FlushLog();
BYTE lpCmd[CDB12GENERIC_LENGTH] = {};
if ((pExtArg->byD8 || pDevice->byPlxtrDrive) && !pExtArg->byBe) {
CDB::_PLXTR_READ_CDDA cdb = {};
SetReadD8Command(pDevice, &cdb, 1, CDFLAG::_PLXTR_READ_CDDA::NoSub);
memcpy(lpCmd, &cdb, CDB12GENERIC_LENGTH);
INT nLBA = pDisc->SCSI.nFirstLBAofDataTrack;
ZeroMemory(lpBuf, CD_RAW_SECTOR_WITH_C2_294_AND_SUBCODE_SIZE);
if (pDisc->SCSI.trackType != TRACK_TYPE::audioOnly) {
if (!ExecSearchingOffset(pExecType, pExtArg, pDevice, pDisc, lpCmd, nLBA, lpBuf
, CD_RAW_SECTOR_SIZE, bGetDriveOffset, nDriveSampleOffset, nDriveOffset)) {
bRet = FALSE;
}
}
lpCmd[10] = (BYTE)CDFLAG::_PLXTR_READ_CDDA::MainQ;
if (!ExecSearchingOffset(pExecType, pExtArg, pDevice, pDisc, lpCmd, nLBA, lpBuf
, CD_RAW_SECTOR_SIZE + 16, bGetDriveOffset, nDriveSampleOffset, nDriveOffset)) {
// not return FALSE
}
lpCmd[10] = (BYTE)CDFLAG::_PLXTR_READ_CDDA::MainPack;
for (INT n = 1; n <= 10; n++) {
if (!ExecSearchingOffset(pExecType, pExtArg, pDevice, pDisc, lpCmd, nLBA, lpBuf
, CD_RAW_SECTOR_WITH_SUBCODE_SIZE, bGetDriveOffset, nDriveSampleOffset, nDriveOffset)) {
if (n == 10) {
bRet = FALSE;
break;
}
StartStopUnit(pExtArg, pDevice, STOP_UNIT_CODE, STOP_UNIT_CODE);
UINT milliseconds = 10000;
OutputErrorString(_T("Retry %d/10 after %d milliseconds\n"), n, milliseconds);
Sleep(milliseconds);
continue;
}
else {
break;
}
}
#if 0
lpCmd[10] = (BYTE)CDFLAG::_PLXTR_READ_CDDA::Raw;
if (!ExecSearchingOffset(pExecType, pExtArg, pDevice, pDisc, lpCmd, nLBA, lpBuf
, CD_RAW_READ_SUBCODE_SIZE, bGetDriveOffset, nDriveSampleOffset, nDriveOffset)) {
// not return FALSE
}
#endif
lpCmd[10] = (BYTE)CDFLAG::_PLXTR_READ_CDDA::MainC2Raw;
if (!ExecSearchingOffset(pExecType, pExtArg, pDevice, pDisc, lpCmd, nLBA, lpBuf
, CD_RAW_SECTOR_WITH_C2_294_AND_SUBCODE_SIZE, bGetDriveOffset, nDriveSampleOffset, nDriveOffset)) {
pExtArg->byC2 = FALSE;
pDevice->FEATURE.byC2ErrorData = FALSE;
// not return FALSE
}
}
else {
CDFLAG::_READ_CD::_EXPECTED_SECTOR_TYPE flg = CDFLAG::_READ_CD::CDDA;
if (*pExecType == data) {
flg = CDFLAG::_READ_CD::All;
}
CDB::_READ_CD cdb = {};
SetReadCDCommand(pDevice, &cdb, flg
, 1, CDFLAG::_READ_CD::NoC2, CDFLAG::_READ_CD::Raw);
memcpy(lpCmd, &cdb, CDB12GENERIC_LENGTH);
INT nLBA = pDisc->SCSI.nFirstLBAofDataTrack;
ZeroMemory(lpBuf, CD_RAW_SECTOR_WITH_C2_294_AND_SUBCODE_SIZE);
if (pExtArg->byC2 && pDevice->FEATURE.byC2ErrorData) {
SetReadCDCommand(pDevice, &cdb, flg
, 1, CDFLAG::_READ_CD::byte294, CDFLAG::_READ_CD::NoSub);
memcpy(lpCmd, &cdb, CDB12GENERIC_LENGTH);
if (pDisc->SCSI.trackType != TRACK_TYPE::audioOnly) {
// Audio only disc doesn't call this because of NoSub mode
if (!ExecSearchingOffset(pExecType, pExtArg, pDevice, pDisc, lpCmd, nLBA, lpBuf
, CD_RAW_SECTOR_WITH_C2_294_SIZE, bGetDriveOffset, nDriveSampleOffset, nDriveOffset)) {
// not return FALSE
}
}
lpCmd[10] = (BYTE)CDFLAG::_READ_CD::Raw;
if (!ExecSearchingOffset(pExecType, pExtArg, pDevice, pDisc, lpCmd, nLBA, lpBuf
, CD_RAW_SECTOR_WITH_C2_294_AND_SUBCODE_SIZE, bGetDriveOffset, nDriveSampleOffset, nDriveOffset)) {
bRet = FALSE;
}
lpCmd[10] = (BYTE)CDFLAG::_READ_CD::Q;
if (!ExecSearchingOffset(pExecType, pExtArg, pDevice, pDisc, lpCmd, nLBA, lpBuf
, CD_RAW_SECTOR_WITH_C2_294_SIZE + 16, bGetDriveOffset, nDriveSampleOffset, nDriveOffset)) {
// not return FALSE
}
lpCmd[10] = (BYTE)CDFLAG::_READ_CD::Pack;
if (!ExecSearchingOffset(pExecType, pExtArg, pDevice, pDisc, lpCmd, nLBA, lpBuf
, CD_RAW_SECTOR_WITH_C2_294_AND_SUBCODE_SIZE, bGetDriveOffset, nDriveSampleOffset, nDriveOffset)) {
// not return FALSE
}
if (bRet) {
pDevice->supportedC2Type = CDFLAG::_READ_CD::byte294;
}
else {
bRet = TRUE;
SetReadCDCommand(pDevice, &cdb, flg
, 1, CDFLAG::_READ_CD::byte296, CDFLAG::_READ_CD::NoSub);
memcpy(lpCmd, &cdb, CDB12GENERIC_LENGTH);
if (pDisc->SCSI.trackType != TRACK_TYPE::audioOnly) {
if (!ExecSearchingOffset(pExecType, pExtArg, pDevice, pDisc, lpCmd, nLBA, lpBuf
, CD_RAW_SECTOR_WITH_C2_SIZE, bGetDriveOffset, nDriveSampleOffset, nDriveOffset)) {
// not return FALSE
}
}
lpCmd[10] = (BYTE)CDFLAG::_READ_CD::Raw;
if (!ExecSearchingOffset(pExecType, pExtArg, pDevice, pDisc, lpCmd, nLBA, lpBuf
, CD_RAW_SECTOR_WITH_C2_AND_SUBCODE_SIZE, bGetDriveOffset, nDriveSampleOffset, nDriveOffset)) {
bRet = FALSE;
}
lpCmd[10] = (BYTE)CDFLAG::_READ_CD::Q;
if (!ExecSearchingOffset(pExecType, pExtArg, pDevice, pDisc, lpCmd, nLBA, lpBuf
, CD_RAW_SECTOR_WITH_C2_SIZE + 16, bGetDriveOffset, nDriveSampleOffset, nDriveOffset)) {
// not return FALSE
}
lpCmd[10] = (BYTE)CDFLAG::_READ_CD::Pack;
if (!ExecSearchingOffset(pExecType, pExtArg, pDevice, pDisc, lpCmd, nLBA, lpBuf
, CD_RAW_SECTOR_WITH_C2_AND_SUBCODE_SIZE, bGetDriveOffset, nDriveSampleOffset, nDriveOffset)) {
// not return FALSE
}
if (bRet) {
pDevice->supportedC2Type = CDFLAG::_READ_CD::byte296;
pDevice->TRANSFER.uiBufLen = CD_RAW_SECTOR_WITH_C2_AND_SUBCODE_SIZE;
pDevice->TRANSFER.uiBufSubOffset = CD_RAW_SECTOR_WITH_C2_SIZE;
}
else {
pDevice->supportedC2Type = CDFLAG::_READ_CD::NoC2;
}
}
}
else {
if (*pExecType != data && pDisc->SCSI.trackType != TRACK_TYPE::audioOnly) {
lpCmd[10] = (BYTE)CDFLAG::_READ_CD::NoSub;
// Audio only disc doesn't call this because of NoSub mode
if (!ExecSearchingOffset(pExecType, pExtArg, pDevice, pDisc, lpCmd, nLBA, lpBuf
, CD_RAW_SECTOR_SIZE, bGetDriveOffset, nDriveSampleOffset, nDriveOffset)) {
// not return FALSE
}
}
lpCmd[10] = (BYTE)CDFLAG::_READ_CD::Raw;
for (INT n = 1; n <= 10; n++) {
if (!ExecSearchingOffset(pExecType, pExtArg, pDevice, pDisc, lpCmd, nLBA, lpBuf
, CD_RAW_SECTOR_WITH_SUBCODE_SIZE, bGetDriveOffset, nDriveSampleOffset, nDriveOffset)) {
if (n == 10) {
bRet = FALSE;
break;
}
StartStopUnit(pExtArg, pDevice, STOP_UNIT_CODE, STOP_UNIT_CODE);
UINT milliseconds = 10000;
OutputErrorString(_T("Retry %d/10 after %d milliseconds\n"), n, milliseconds);
Sleep(milliseconds);
continue;
}
else {
break;
}
}
lpCmd[10] = (BYTE)CDFLAG::_READ_CD::Q;
if (!ExecSearchingOffset(pExecType, pExtArg, pDevice, pDisc, lpCmd, nLBA, lpBuf
, CD_RAW_SECTOR_SIZE + 16, bGetDriveOffset, nDriveSampleOffset, nDriveOffset)) {
// not return FALSE
}
lpCmd[10] = (BYTE)CDFLAG::_READ_CD::Pack;
if (!ExecSearchingOffset(pExecType, pExtArg, pDevice, pDisc, lpCmd, nLBA, lpBuf
, CD_RAW_SECTOR_WITH_SUBCODE_SIZE, bGetDriveOffset, nDriveSampleOffset, nDriveOffset)) {
// not return FALSE
}
}
}
FreeAndNull(pBuf);
return bRet;
}
BOOL ReadCDForCheckingReadInOut(
PEXEC_TYPE pExecType,
PEXT_ARG pExtArg,
PDEVICE pDevice,
PDISC pDisc
) {
BOOL bRet = TRUE;
BYTE lpCmd[CDB12GENERIC_LENGTH] = {};
SetReadDiscCommand(pExecType, pExtArg, pDevice, 1, CDFLAG::_READ_CD::NoC2, CDFLAG::_READ_CD::NoSub, lpCmd, FALSE);
INT nLBA = 0;
if (pDisc->MAIN.nCombinedOffset < 0) {
OutputLogA(standardOut | fileDrive, "Checking reading lead-in -> ");
nLBA = -1;
}
else if (0 < pDisc->MAIN.nCombinedOffset && *pExecType == cd) {
OutputLogA(standardOut | fileDrive, "Checking reading lead-out -> ");
nLBA = pDisc->SCSI.nAllLength;
}
// buffer is unused but buf null and size zero is semaphore error...
BYTE aBuf[CD_RAW_SECTOR_SIZE] = {};
BYTE byScsiStatus = 0;
if (!ExecReadCD(pExtArg, pDevice, lpCmd, nLBA, aBuf,
CD_RAW_SECTOR_SIZE, _T(__FUNCTION__), __LINE__)
|| byScsiStatus >= SCSISTAT_CHECK_CONDITION) {
if (pDisc->MAIN.nCombinedOffset < 0) {
OutputLogA(standardOut | fileDrive, "This drive can't read the lead-in\n");
}
else if (0 < pDisc->MAIN.nCombinedOffset) {
OutputLogA(standardOut | fileDrive, "This drive can't read the lead-out\n");
}
return FALSE;
}
else {
if (nLBA != 0) {
OutputLogA(standardOut | fileDrive, "OK\n");
}
}
#if 0
OutputCDMain(fileMainInfo, aBuf, nLBA, CD_RAW_SECTOR_SIZE);
#endif
return bRet;
}
BOOL ReadCDForCheckingSubQAdrFirst(
PEXT_ARG pExtArg,
PDEVICE pDevice,
PDISC pDisc,
LPBYTE* ppBuf,
LPBYTE* lpBuf,
LPBYTE lpCmd,
LPUINT uiBufLen,
LPINT nOfs
) {
if (!GetAlignedCallocatedBuffer(pDevice, ppBuf,
CD_RAW_SECTOR_WITH_C2_294_AND_SUBCODE_SIZE * 2, lpBuf, _T(__FUNCTION__), __LINE__)) {
return FALSE;
}
CDFLAG::_READ_CD::_ERROR_FLAGS c2 = CDFLAG::_READ_CD::NoC2;
if (pExtArg->byC2 && pDevice->FEATURE.byC2ErrorData) {
c2 = CDFLAG::_READ_CD::byte294;
*uiBufLen = CD_RAW_SECTOR_WITH_C2_294_AND_SUBCODE_SIZE * 2;
}
SetReadDiscCommand(NULL, pExtArg, pDevice, 2, c2, CDFLAG::_READ_CD::Raw, lpCmd, FALSE);
*nOfs = pDisc->MAIN.nCombinedOffset % CD_RAW_SECTOR_SIZE;
if (pDisc->MAIN.nCombinedOffset < 0) {
*nOfs = CD_RAW_SECTOR_SIZE + *nOfs;
}
return TRUE;
}
BOOL ReadCDForCheckingSubQAdr(
PEXT_ARG pExtArg,
PDEVICE pDevice,
PDISC pDisc,
PDISC_PER_SECTOR pDiscPerSector,
LPBYTE lpCmd,
LPBYTE lpBuf,
UINT uiBufLen,
INT nOfs,
BYTE byIdxOfTrack,
LPBYTE byMode,
BYTE bySessionNum,
FILE* fpCcd
) {
BOOL bCheckMCN = FALSE;
BOOL bCheckISRC = FALSE;
CHAR szTmpCatalog[META_CATALOG_SIZE] = {};
CHAR szTmpISRC[META_ISRC_SIZE] = {};
INT nMCNIdx = 0;
INT nISRCIdx = 0;
INT nTmpMCNLBAList[25] = { -1 };
INT nTmpISRCLBAList[25] = { -1 };
INT nTmpLBA = pDisc->SCSI.lpFirstLBAListOnToc[byIdxOfTrack];
INT nTmpNextLBA = 0;
if (byIdxOfTrack + 1 < pDisc->SCSI.byLastDataTrackNum) {
nTmpNextLBA = pDisc->SCSI.lpFirstLBAListOnToc[byIdxOfTrack + 1] - nTmpLBA;
}
else {
nTmpNextLBA = pDisc->SCSI.nAllLength - nTmpLBA;
}
pDiscPerSector->byTrackNum = BYTE(byIdxOfTrack + 1);
INT nSubOfs = CD_RAW_SECTOR_SIZE;
if (pDevice->driveOrder == DRIVE_DATA_ORDER::MainC2Sub) {
nSubOfs = CD_RAW_SECTOR_WITH_C2_294_SIZE;
}
OutputDiscLogA(OUTPUT_DHYPHEN_PLUS_STR_WITH_TRACK_F(Check MCN and/or ISRC), lpCmd[0], lpCmd[10], byIdxOfTrack + 1);
for (INT nLBA = nTmpLBA; nLBA < nTmpLBA + 400; nLBA++) {
if (400 > nTmpNextLBA) {
bCheckMCN = FALSE;
bCheckISRC = FALSE;
break;
}
if (!ExecReadCD(pExtArg, pDevice, lpCmd, nLBA, lpBuf,
uiBufLen, _T(__FUNCTION__), __LINE__)) {
// skip checking
return TRUE;
}
AlignRowSubcode(pDiscPerSector->subcode.current, lpBuf + nSubOfs);
#if 0
OutputCDMain(lpBuf2, nLBA, CD_RAW_SECTOR_SIZE);
OutputCDSub96Align(pDiscPerSector->subcode.current, nLBA);
#endif
if (nLBA == nTmpLBA) {
memcpy(pDiscPerSector->mainHeader.current, lpBuf + nOfs, MAINHEADER_MODE1_SIZE);
// this func is used to get a SubChannel Offset
SetTmpSubQDataFromBuffer(&pDiscPerSector->subQ.current, pDiscPerSector->subcode.current);
pDiscPerSector->subQ.current.byCtl = (BYTE)((BYTE)(pDiscPerSector->subcode.current[12] >> 4) & 0x0f);
*byMode = GetMode(pDiscPerSector, unscrambled);
}
BOOL bCRC = FALSE;
WORD crc16 = (WORD)GetCrc16CCITT(10, &pDiscPerSector->subcode.current[12]);
BYTE tmp1 = HIBYTE(crc16);
BYTE tmp2 = LOBYTE(crc16);
if (pDiscPerSector->subcode.current[22] == tmp1 && pDiscPerSector->subcode.current[23] == tmp2) {
bCRC = TRUE;
}
BYTE byAdr = (BYTE)(pDiscPerSector->subcode.current[12] & 0x0f);
if (byAdr == ADR_ENCODES_MEDIA_CATALOG) {
#if 0
if (!bCRC) {
SetBufferFromMCN(pDisc, pDiscPerSector->subcode.current);
bCRC = TRUE;
}
#endif
BOOL bMCN = IsValidSubQAdrMCN(pDiscPerSector->subcode.current);
#if 0
if (!bMCN && bCRC) {
// force a invalid MCN to valid MCN
bMCN = bCRC;
}
#endif
if (bMCN && bCRC) {
nTmpMCNLBAList[nMCNIdx++] = nLBA;
CHAR szCatalog[META_CATALOG_SIZE] = {};
if (!bCheckMCN) {
SetMCNToString(pDisc, pDiscPerSector->subcode.current, szCatalog, FALSE);
strncpy(szTmpCatalog, szCatalog, sizeof(szTmpCatalog) / sizeof(szTmpCatalog[0]));
szTmpCatalog[META_CATALOG_SIZE - 1] = 0;
bCheckMCN = bMCN;
}
else if (!pDisc->SUB.byCatalog) {
SetMCNToString(pDisc, pDiscPerSector->subcode.current, szCatalog, FALSE);
if (!strncmp(szTmpCatalog, szCatalog, sizeof(szTmpCatalog) / sizeof(szTmpCatalog[0]))) {
strncpy(pDisc->SUB.szCatalog, szCatalog, sizeof(pDisc->SUB.szCatalog) / sizeof(pDisc->SUB.szCatalog[0]));
pDisc->SUB.byCatalog = (BYTE)bMCN;
OutputCDSub96Align(fileDisc, pDiscPerSector->subcode.current, nLBA);
OutputDiscLogA("\tMCN: [%s]\n", szCatalog);
WriteCcdForDiscCatalog(pDisc, fpCcd);
}
}
}
}
else if (byAdr == ADR_ENCODES_ISRC) {
BOOL bISRC = IsValidSubQAdrISRC(pDiscPerSector->subcode.current);
#if 0
if (!bISRC && bCRC) {
// force a invalid ISRC to valid ISRC
bISRC = bCRC;
}
#endif
if (bISRC && bCRC) {
nTmpISRCLBAList[nISRCIdx++] = nLBA;
CHAR szISRC[META_ISRC_SIZE] = {};
if (!bCheckISRC) {
SetISRCToString(pDisc, pDiscPerSector, szISRC, FALSE);
strncpy(szTmpISRC, szISRC, sizeof(szTmpISRC) / sizeof(szTmpISRC[0]));
szTmpISRC[META_ISRC_SIZE - 1] = 0;
bCheckISRC = bISRC;
}
else if (!pDisc->SUB.lpISRCList[byIdxOfTrack]) {
SetISRCToString(pDisc, pDiscPerSector, szISRC, FALSE);
if (!strncmp(szTmpISRC, szISRC, sizeof(szISRC) / sizeof(szISRC[0]))) {
strncpy(pDisc->SUB.pszISRC[byIdxOfTrack], szISRC, META_ISRC_SIZE);
pDisc->SUB.lpISRCList[byIdxOfTrack] = bISRC;
OutputCDSub96Align(fileDisc, pDiscPerSector->subcode.current, nLBA);
OutputDiscLogA("\tISRC: [%s]\n", szISRC);
}
}
}
}
}
if (bCheckMCN) {
SetLBAForFirstAdr(pDisc->SUB.nFirstLBAForMCN, pDisc->SUB.nRangeLBAForMCN,
"MCN", nTmpMCNLBAList, (BYTE)(bySessionNum - 1), pDevice->byPlxtrDrive);
}
if (bCheckISRC) {
SetLBAForFirstAdr(pDisc->SUB.nFirstLBAForISRC, pDisc->SUB.nRangeLBAForISRC,
"ISRC", nTmpISRCLBAList, (BYTE)(bySessionNum - 1), pDevice->byPlxtrDrive);
}
if (!bCheckMCN && !bCheckISRC) {
OutputDiscLogA("\tNothing\n");
}
return TRUE;
}
BOOL ReadCDForCheckingSubRtoW(
PEXT_ARG pExtArg,
PDEVICE pDevice,
PDISC pDisc
) {
BOOL bRet = TRUE;
LPBYTE pBuf = NULL;
LPBYTE lpBuf = NULL;
if (!GetAlignedCallocatedBuffer(pDevice, &pBuf,
CD_RAW_SECTOR_WITH_C2_294_AND_SUBCODE_SIZE, &lpBuf, _T(__FUNCTION__), __LINE__)) {
return FALSE;
}
BYTE lpCmd[CDB12GENERIC_LENGTH] = {};
UINT uiBufLen = CD_RAW_SECTOR_SIZE + CD_RAW_READ_SUBCODE_SIZE;
CDFLAG::_READ_CD::_ERROR_FLAGS c2 = CDFLAG::_READ_CD::NoC2;
if (pExtArg->byC2 && pDevice->FEATURE.byC2ErrorData) {
c2 = CDFLAG::_READ_CD::byte294;
uiBufLen = CD_RAW_SECTOR_WITH_C2_294_AND_SUBCODE_SIZE;
}
SetReadDiscCommand(NULL, pExtArg, pDevice, 1, c2, CDFLAG::_READ_CD::Raw, lpCmd, FALSE);
for (BYTE i = (BYTE)(pDisc->SCSI.toc.FirstTrack - 1); i < pDisc->SCSI.toc.LastTrack; i++) {
try {
OutputDiscLogA(OUTPUT_DHYPHEN_PLUS_STR_WITH_TRACK_F(Check CD + G), lpCmd[0], lpCmd[10], i + 1);
INT nTmpLBA = pDisc->SCSI.lpFirstLBAListOnToc[i] + 100;
if (!ExecReadCD(pExtArg, pDevice, lpCmd, nTmpLBA, lpBuf,
uiBufLen, _T(__FUNCTION__), __LINE__)) {
// skip checking
continue;
}
BYTE lpSubcode[CD_RAW_READ_SUBCODE_SIZE] = {};
BYTE lpSubcodeOrg[CD_RAW_READ_SUBCODE_SIZE] = {};
if (uiBufLen == CD_RAW_SECTOR_WITH_C2_294_AND_SUBCODE_SIZE) {
AlignRowSubcode(lpSubcode, lpBuf + CD_RAW_SECTOR_WITH_C2_294_SIZE);
memcpy(lpSubcodeOrg, lpBuf + CD_RAW_SECTOR_WITH_C2_294_SIZE, CD_RAW_READ_SUBCODE_SIZE);
}
else {
AlignRowSubcode(lpSubcode, lpBuf + CD_RAW_SECTOR_SIZE);
memcpy(lpSubcodeOrg, lpBuf + CD_RAW_SECTOR_SIZE, CD_RAW_READ_SUBCODE_SIZE);
}
OutputCDSub96Align(fileDisc, lpSubcode, nTmpLBA);
SUB_R_TO_W scRW[4] = {};
BYTE tmpCode[24] = {};
INT nRtoW = 0;
BOOL bCDG = FALSE;
BOOL bCDEG = FALSE;
for (INT k = 0; k < 4; k++) {
for (INT j = 0; j < 24; j++) {
tmpCode[j] = (BYTE)(*(lpSubcodeOrg + (k * 24 + j)) & 0x3f);
}
memcpy(&scRW[k], tmpCode, sizeof(scRW[k]));
switch (scRW[k].command) {
case 0: // MODE 0, ITEM 0
break;
case 8: // MODE 1, ITEM 0
break;
case 9: // MODE 1, ITEM 1
bCDG = TRUE;
break;
case 10: // MODE 1, ITEM 2
bCDEG = TRUE;
break;
case 20: // MODE 2, ITEM 4
break;
case 24: // MODE 3, ITEM 0
break;
case 56: // MODE 7, ITEM 0
break;
default:
break;
}
}
INT nR = 0;
INT nS = 0;
INT nT = 0;
INT nU = 0;
INT nV = 0;
INT nW = 0;
for (INT j = 24; j < CD_RAW_READ_SUBCODE_SIZE; j++) {
if (24 <= j && j < 36) {
nR += lpSubcode[j];
}
else if (36 <= j && j < 48) {
nS += lpSubcode[j];
}
else if (48 <= j && j < 60) {
nT += lpSubcode[j];
}
else if (60 <= j && j < 72) {
nU += lpSubcode[j];
}
else if (72 <= j && j < 84) {
nV += lpSubcode[j];
}
else if (84 <= j && j < CD_RAW_READ_SUBCODE_SIZE) {
nW += lpSubcode[j];
}
nRtoW += lpSubcode[j];
}
// 0xff * 72 = 0x47b8
if (nRtoW == 0x47b8) {
// Why R-W bit is full? Basically, a R-W bit should be off except CD+G or CD-MIDI
// Alanis Morissette - Jagged Little Pill (UK)
// WipEout 2097: The Soundtrack
// and more..
// Sub Channel LBA 75
// +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B
// P 00 00 00 00 00 00 00 00 00 00 00 00
// Q 01 01 01 00 01 00 00 00 03 00 2c b9
// R ff ff ff ff ff ff ff ff ff ff ff ff
// S ff ff ff ff ff ff ff ff ff ff ff ff
// T ff ff ff ff ff ff ff ff ff ff ff ff
// U ff ff ff ff ff ff ff ff ff ff ff ff
// V ff ff ff ff ff ff ff ff ff ff ff ff
// W ff ff ff ff ff ff ff ff ff ff ff ff
pDisc->SUB.lpRtoWList[i] = SUB_RTOW_TYPE::Full;
OutputDiscLogA("\tAll RtoW is 0xff\n");
}
// (0x57 + 0x33 + 0x16) * 24 = 0xeb8
else if (nRtoW == 0xeb8) {
// [3DO] MegaRace (Japan) subch 0x02 on Plextor
// ========== LBA[000000, 0000000], Sub Channel ==========
// +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B
// P ff ff ff ff ff ff ff ff ff ff ff ff
// Q 41 01 01 00 00 00 00 00 02 00 28 32
// R 57 33 13 57 33 13 57 33 13 57 33 13
// S 57 33 13 57 33 13 57 33 13 57 33 13
// T 57 33 13 57 33 13 57 33 13 57 33 13
// U 57 33 13 57 33 13 57 33 13 57 33 13
// V 57 33 13 57 33 13 57 33 13 57 33 13
// W 57 33 13 57 33 13 57 33 13 57 33 13
pDisc->SUB.lpRtoWList[i] = SUB_RTOW_TYPE::Full;
OutputDiscLogA("\tAll RtoW is 0x57, 0x33, 0x13\n");
}
// 0x33 * 72 = 0xe58
else if (nRtoW == 0xe58) {
// [3DO] MegaRace (Japan) subch 0x08 on Plextor
// ========== LBA[000100, 0x00064], Sub Channel ==========
// +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B
// P 00 00 00 00 00 00 00 00 00 00 00 00
// Q 41 01 01 00 01 25 00 00 03 25 01 87
// R 33 33 33 33 33 33 33 33 33 33 33 33
// S 33 33 33 33 33 33 33 33 33 33 33 33
// T 33 33 33 33 33 33 33 33 33 33 33 33
// U 33 33 33 33 33 33 33 33 33 33 33 33
// V 33 33 33 33 33 33 33 33 33 33 33 33
// W 33 33 33 33 33 33 33 33 33 33 33 33
pDisc->SUB.lpRtoWList[i] = SUB_RTOW_TYPE::Full;
OutputDiscLogA("\tAll RtoW is 0x33\n");
}
else {
BOOL bAnyFull = FALSE;
// 0xff * 12 = 0xbf4
if (nR == 0xbf4) {
OutputDiscLogA("\tAll R is 0xff\n");
bAnyFull = TRUE;
}
if (nS == 0xbf4) {
OutputDiscLogA("\tAll S is 0xff\n");
bAnyFull = TRUE;
}
if (nT == 0xbf4) {
OutputDiscLogA("\tAll T is 0xff\n");
bAnyFull = TRUE;
}
if (nU == 0xbf4) {
OutputDiscLogA("\tAll U is 0xff\n");
bAnyFull = TRUE;
}
if (nV == 0xbf4) {
OutputDiscLogA("\tAll V is 0xff\n");
bAnyFull = TRUE;
}
if (nW == 0xbf4) {
OutputDiscLogA("\tAll W is 0xff\n");
bAnyFull = TRUE;
}
if (bAnyFull) {
pDisc->SUB.lpRtoWList[i] = SUB_RTOW_TYPE::AnyFull;
}
else {
if (bCDG && nRtoW > 0 && nRtoW != 0x200) {
pDisc->SUB.lpRtoWList[i] = SUB_RTOW_TYPE::CDG;
OutputDiscLogA("\tCD+G\n");
}
else if (bCDEG && nRtoW > 0 && nRtoW != 0x200) {
pDisc->SUB.lpRtoWList[i] = SUB_RTOW_TYPE::CDG;
OutputDiscLogA("\tCD+EG\n");
}
else if ((0 <= nR && nR <= 0x03) && (0 <= nS && nS <= 0x03) &&
(0 <= nT && nT <= 0x03) && (0 <= nU && nU <= 0x03) &&
(0 <= nV && nV <= 0x03) && (0 <= nW && nW <= 0x03) && nRtoW != 0) {
pDisc->SUB.lpRtoWList[i] = SUB_RTOW_TYPE::PSXSpecific;
OutputDiscLogA("\tRandom data exists (PSX)\n");
}
else {
pDisc->SUB.lpRtoWList[i] = SUB_RTOW_TYPE::Zero;
OutputDiscLogA("\tNothing\n");
}
}
}
}
catch (BOOL bErr) {
bRet = bErr;
}
OutputString(
_T("\rChecking SubRtoW (Track) %2u/%2u"), i + 1, pDisc->SCSI.toc.LastTrack);
}
OutputString(_T("\n"));
FreeAndNull(pBuf);
return bRet;
}
#if 0
LRESULT WINAPI CabinetCallback(
IN PVOID pMyInstallData,
IN UINT Notification,
IN UINT Param1,
IN UINT Param2
) {
UNREFERENCED_PARAMETER(Param2);
LRESULT lRetVal = NO_ERROR;
TCHAR szTarget[_MAX_PATH];
FILE_IN_CABINET_INFO *pInfo = NULL;
FILEPATHS *pFilePaths = NULL;
memcpy(szTarget, pMyInstallData, _MAX_PATH);
switch (Notification) {
case SPFILENOTIFY_CABINETINFO:
break;
case SPFILENOTIFY_FILEINCABINET:
pInfo = (FILE_IN_CABINET_INFO *)Param1;
lstrcat(szTarget, pInfo->NameInCabinet);
lstrcpy(pInfo->FullTargetName, szTarget);
lRetVal = FILEOP_DOIT; // Extract the file.
break;
case SPFILENOTIFY_NEEDNEWCABINET: // Unexpected.
break;
case SPFILENOTIFY_FILEEXTRACTED:
pFilePaths = (FILEPATHS *)Param1;
printf("Extracted %s\n", pFilePaths->Target);
break;
case SPFILENOTIFY_FILEOPDELAYED:
break;
}
return lRetVal;
}
BOOL IterateCabinet(
PTSTR pszCabFile
) {
_TCHAR szExtractdir[_MAX_PATH];
if (!GetCurrentDirectory(sizeof(szExtractdir) / sizeof(szExtractdir[0]), szExtractdir)) {
OutputLastErrorNumAndString(_T(__FUNCTION__), __LINE__);
return FALSE;
}
lstrcat(szExtractdir, "\\extract_cab\\");
_TCHAR szExtractdirFind[_MAX_PATH];
memcpy(szExtractdirFind, szExtractdir, _MAX_PATH);
lstrcat(szExtractdirFind, "*");
if (PathFileExists(szExtractdir)) {
WIN32_FIND_DATA fd;
HANDLE hFind = FindFirstFile(szExtractdirFind, &fd);
if (INVALID_HANDLE_VALUE == hFind) {
return FALSE;
}
do {
if (0 != _tcscmp(fd.cFileName, _T("."))
&& 0 != _tcscmp(fd.cFileName, _T(".."))) {
TCHAR szFoundFilePathName[_MAX_PATH];
_tcsncpy(szFoundFilePathName, szExtractdir, _MAX_PATH);
_tcsncat(szFoundFilePathName, fd.cFileName, _MAX_PATH);
if (!(FILE_ATTRIBUTE_DIRECTORY & fd.dwFileAttributes)) {
if (!DeleteFile(szFoundFilePathName)) {
FindClose(hFind);
return FALSE;
}
}
}
} while (FindNextFile(hFind, &fd));
FindClose(hFind);
}
if (!MakeSureDirectoryPathExists(szExtractdir)) {
OutputLastErrorNumAndString(_T(__FUNCTION__), __LINE__);
return FALSE;
}
if (!SetupIterateCabinet(pszCabFile,
0, (PSP_FILE_CALLBACK)CabinetCallback, szExtractdir)) {
OutputLastErrorNumAndString(_T(__FUNCTION__), __LINE__);
return FALSE;
}
return TRUE;
}
#endif
BOOL ReadCDForCheckingExe(
PEXEC_TYPE pExecType,
PEXT_ARG pExtArg,
PDEVICE pDevice,
PDISC pDisc,
LPBYTE pCdb,
LPBYTE lpBuf
) {
BOOL bRet = TRUE;
DWORD dwSize = DISC_RAW_READ_SIZE;
BYTE byTransferLen = 1;
BYTE byRoopLen = byTransferLen;
SetCommandForTransferLength(pExecType, pDevice, pCdb, dwSize, &byTransferLen, &byRoopLen);
for (INT n = 0; pDisc->PROTECT.pExtentPosForExe[n] != 0; n++) {
#if 0
if (strstr(pDisc->PROTECT.pNameForExe[n], ".CAB") || strstr(pDisc->PROTECT.pNameForExe[n], ".cab")) {
// Get the absPath of cab file from path table
IterateCabinet(pDisc->PROTECT.pNameForExe[n]);
IterateCabinet("C:\\test\\disk1\\1.cab");
// Search exe, dll from extracted file
// Open exe, dll
// Read
}
else {
#endif
if (!ExecReadCD(pExtArg, pDevice, pCdb, pDisc->PROTECT.pExtentPosForExe[n],
lpBuf, dwSize, _T(__FUNCTION__), __LINE__)) {
// return FALSE;
// FIFA 99 (Europe) on PX-5224A
// LBA[000000, 0000000], [F:ReadCDForCheckingExe][L:734]
// OperationCode: 0xa8
// ScsiStatus: 0x02 = CHECK_CONDITION
// SenseData Key-Asc-Ascq: 03-02-83 = MEDIUM_ERROR - OTHER
// => The reason is unknown...
continue;
}
#if 0
}
#endif
WORD wMagic = MAKEWORD(lpBuf[0], lpBuf[1]);
if (wMagic == IMAGE_DOS_SIGNATURE) {
PIMAGE_DOS_HEADER pIDh = (PIMAGE_DOS_HEADER)&lpBuf[0];
if (dwSize < (DWORD)pIDh->e_lfanew) {
if (pDevice->dwMaxTransferLength < (DWORD)pIDh->e_lfanew) {
OutputVolDescLogA("%s: offset is very big (%lu). read skip [TODO]\n"
, pDisc->PROTECT.pNameForExe[n], pIDh->e_lfanew);
}
else {
SetCommandForTransferLength(pExecType, pDevice, pCdb, (DWORD)pIDh->e_lfanew, &byTransferLen, &byRoopLen);
dwSize = DWORD(DISC_RAW_READ_SIZE) * byTransferLen;
n--;
}
continue;
}
OutputVolDescLogA(OUTPUT_DHYPHEN_PLUS_STR_WITH_LBA
, pDisc->PROTECT.pExtentPosForExe[n], pDisc->PROTECT.pExtentPosForExe[n], pDisc->PROTECT.pNameForExe[n]);
OutputFsImageDosHeader(pIDh);
WORD wMagic2 = MAKEWORD(lpBuf[pIDh->e_lfanew], lpBuf[pIDh->e_lfanew + 1]);
if (wMagic2 == IMAGE_NT_SIGNATURE) {
PIMAGE_NT_HEADERS32 pINH = (PIMAGE_NT_HEADERS32)&lpBuf[pIDh->e_lfanew];
OutputFsImageNtHeader(pINH);
ULONG nOfs = pIDh->e_lfanew + sizeof(IMAGE_NT_HEADERS32);
for (INT i = 0; i < pINH->FileHeader.NumberOfSections; i++) {
OutputFsImageSectionHeader(pDisc, (PIMAGE_SECTION_HEADER)&lpBuf[nOfs]);
nOfs += sizeof(IMAGE_SECTION_HEADER);
}
}
else if (wMagic2 == IMAGE_OS2_SIGNATURE) {
OutputFsImageOS2Header((PIMAGE_OS2_HEADER)&lpBuf[pIDh->e_lfanew]);
}
else if (wMagic2 == IMAGE_OS2_SIGNATURE_LE) {
// TODO
}
else {
OutputVolDescLogA(
"%s: ImageNT,NE,LEHeader doesn't exist\n", pDisc->PROTECT.pNameForExe[n]);
}
}
else {
OutputVolDescLogA(
"%s: ImageDosHeader doesn't exist\n", pDisc->PROTECT.pNameForExe[n]);
}
OutputString(_T("\rChecking EXE %4d"), n + 1);
}
OutputString(_T("\n"));
return bRet;
}
BOOL ReadCDForSegaDisc(
PEXT_ARG pExtArg,
PDEVICE pDevice
) {
BYTE buf[DISC_RAW_READ_SIZE] = {};
CDB::_READ12 cdb = {};
cdb.OperationCode = SCSIOP_READ12;
cdb.TransferLength[3] = 1;
if (!ExecReadCD(pExtArg, pDevice, (LPBYTE)&cdb, 0, buf,
DISC_RAW_READ_SIZE, _T(__FUNCTION__), __LINE__)) {
}
if (!memcmp(buf, "SEGA", 4)) {
OutputCDMain(fileMainInfo, buf, 0, DISC_RAW_READ_SIZE);
}
return TRUE;
}
BOOL ReadCDForCheckingPsxRegion(
PEXT_ARG pExtArg,
PDEVICE pDevice
) {
BYTE buf[DISC_RAW_READ_SIZE] = {};
CONST CHAR regionPal[] =
" Licensed by Sony Computer Entertainment Euro pe ";
CONST CHAR regionPal2[] =
" Licensed by Sony Computer Entertainment(Europe)";
CDB::_READ12 cdb = {};
cdb.OperationCode = SCSIOP_READ12;
cdb.TransferLength[3] = 1;
if (!ExecReadCD(pExtArg, pDevice, (LPBYTE)&cdb, 4, buf,
DISC_RAW_READ_SIZE, _T(__FUNCTION__), __LINE__)) {
return TRUE;
}
OutputCDMain(fileMainInfo, buf, 4, 80);
if (!memcmp(buf, regionPal, sizeof(regionPal))) {
return TRUE;
}
else if (!memcmp(buf, regionPal2, sizeof(regionPal2))) {
return TRUE;
}
OutputString(
_T("[INFO] This disc isn't PSX PAL. /nl is ignored.\n"));
return FALSE;
}
VOID ReadCDForScanningPsxAntiMod(
PEXT_ARG pExtArg,
PDEVICE pDevice,
PDISC pDisc
) {
BOOL bRet = FALSE;
BYTE buf[DISC_RAW_READ_SIZE] = {};
CONST CHAR antiModStrEn[] =
" SOFTWARE TERMINATED\nCONSOLE MAY HAVE BEEN MODIFIED\n CALL 1-888-780-7690";
CONST CHAR antiModStrJp[] =
"強制終了しました。\n本体が改造されている\nおそれがあります。";
CDB::_READ12 cdb = {};
cdb.OperationCode = SCSIOP_READ12;
cdb.TransferLength[3] = 1;
for (INT nLBA = 18; nLBA < pDisc->SCSI.nLastLBAofDataTrack - 150; nLBA++) {
if (!ExecReadCD(pExtArg, pDevice, (LPBYTE)&cdb, nLBA, buf,
DISC_RAW_READ_SIZE, _T(__FUNCTION__), __LINE__)) {
return;
}
for (INT i = 0; i < DISC_RAW_READ_SIZE; i++) {
if (!memcmp(&buf[i], antiModStrEn, sizeof(antiModStrEn))) {
OutputLogA(fileDisc | standardOut, "\nDetected anti-mod string (en): LBA %d", nLBA);
OutputCDMain(fileMainInfo, buf, nLBA, DISC_RAW_READ_SIZE);
bRet += TRUE;
}
if (!memcmp(&buf[i], antiModStrJp, sizeof(antiModStrJp))) {
OutputLogA(fileDisc | standardOut, "\nDetected anti-mod string (jp): LBA %d\n", nLBA);
if (!bRet) {
OutputCDMain(fileMainInfo, buf, nLBA, DISC_RAW_READ_SIZE);
}
bRet += TRUE;
}
if (bRet == 2) {
break;
}
}
if (bRet == 2) {
break;
}
OutputString(_T("\rScanning sector for anti-mod string (LBA) %6d/%6d"), nLBA, pDisc->SCSI.nLastLBAofDataTrack - 150 - 1);
}
if (!bRet) {
OutputLogA(fileDisc | standardOut, "\nNo anti-mod string\n");
}
return;
}
BOOL ReadCDForScanningProtectViaSector(
PEXT_ARG pExtArg,
PDEVICE pDevice,
PDISC pDisc
) {
BYTE lpCmd[CDB12GENERIC_LENGTH] = {};
DWORD dwBufLen = CD_RAW_SECTOR_SIZE + CD_RAW_READ_SUBCODE_SIZE;
CDFLAG::_READ_CD::_ERROR_FLAGS c2 = CDFLAG::_READ_CD::NoC2;
if (pExtArg->byC2 && pDevice->FEATURE.byC2ErrorData) {
dwBufLen = CD_RAW_SECTOR_WITH_C2_294_AND_SUBCODE_SIZE;
c2 = CDFLAG::_READ_CD::byte294;
}
SetReadDiscCommand(NULL, pExtArg, pDevice, 1, c2, CDFLAG::_READ_CD::Raw, lpCmd, FALSE);
BYTE aBuf[CD_RAW_SECTOR_WITH_C2_294_AND_SUBCODE_SIZE] = {};
BYTE byScsiStatus = 0;
for (INT nLBA = 0; nLBA < pDisc->SCSI.nAllLength; nLBA++) {
if (!ExecReadCD(pExtArg, pDevice, lpCmd, nLBA, aBuf,
dwBufLen, _T(__FUNCTION__), __LINE__)
|| byScsiStatus >= SCSISTAT_CHECK_CONDITION) {
return FALSE;
}
INT nOfs = 0;
if (pDisc->MAIN.nCombinedOffset > 0) {
nOfs = pDisc->MAIN.nCombinedOffset % CD_RAW_SECTOR_SIZE;
}
else if (pDisc->MAIN.nCombinedOffset < 0) {
nOfs = CD_RAW_SECTOR_SIZE + pDisc->MAIN.nCombinedOffset;
}
if (aBuf[nOfs] == 0 && aBuf[nOfs + 1] == 0xff && aBuf[nOfs + 2] == 0 && aBuf[nOfs + 3] == 0xff &&
aBuf[nOfs + 4] == 0 && aBuf[nOfs + 5] == 0xff && aBuf[nOfs + 6] == 0 && aBuf[nOfs + 7] == 0xff &&
aBuf[nOfs + 8] == 0 && aBuf[nOfs + 9] == 0xff && aBuf[nOfs + 10] == 0 && aBuf[nOfs + 11] == 0xff) {
OutputLogA(standardOut | fileDisc, "\nDetected ProtectCD VOB. It begins from %d sector", nLBA);
pDisc->PROTECT.ERROR_SECTOR.nExtentPos = nLBA;
pDisc->PROTECT.ERROR_SECTOR.nSectorSize = pDisc->SCSI.nAllLength - nLBA - 1;
pDisc->PROTECT.byExist = protectCDVOB;
pExtArg->byScanProtectViaFile = pExtArg->byScanProtectViaSector;
break;
}
OutputString(_T("\rScanning sector (LBA) %6d/%6d"), nLBA, pDisc->SCSI.nAllLength - 1);
}
OutputLogA(standardOut | fileDisc, "\n");
return TRUE;
}
BOOL ReadCDForCheckingSecuROM(
PEXT_ARG pExtArg,
PDEVICE pDevice,
PDISC pDisc,
PDISC_PER_SECTOR pDiscPerSector,
LPBYTE lpCmd
) {
#ifdef _DEBUG
WORD w = (WORD)GetCrc16CCITT(10, &pDiscPerSector->subcode.current[12]);
OutputSubInfoWithLBALogA(
"CRC-16 is original:[%02x%02x], recalc:[%04x] and XORed with 0x8001:[%02x%02x]\n"
, -1, 0, pDiscPerSector->subcode.current[22], pDiscPerSector->subcode.current[23]
, w, pDiscPerSector->subcode.current[22] ^ 0x80, pDiscPerSector->subcode.current[23] ^ 0x01);
#endif
if (pExtArg->byIntentionalSub && pDisc->PROTECT.byExist != securomV1 &&
(pDiscPerSector->subcode.current[12] == 0x41 || pDiscPerSector->subcode.current[12] == 0x61)) {
// WORD crc16 = (WORD)GetCrc16CCITT(10, &pDiscPerSector->subcode.current[12]);
// WORD bufcrc = MAKEWORD(pDiscPerSector->subcode.current[23], pDiscPerSector->subcode.current[22]);
INT nRLBA = MSFtoLBA(BcdToDec(pDiscPerSector->subcode.current[15])
, BcdToDec(pDiscPerSector->subcode.current[16]), BcdToDec(pDiscPerSector->subcode.current[17]));
INT nALBA = MSFtoLBA(BcdToDec(pDiscPerSector->subcode.current[19])
, BcdToDec(pDiscPerSector->subcode.current[20]), BcdToDec(pDiscPerSector->subcode.current[21]));
// if (crc16 != bufcrc) {
if ((nRLBA == 3000 || nRLBA == 3001) && nALBA == 299) { // 3001(00:40:01), 299(00:03:74)
OutputSubInfoWithLBALogA(
"Detected intentional error. CRC-16 is original:[%02x%02x] and XORed with 0x8001:[%02x%02x] "
, -1, 0, pDiscPerSector->subcode.current[22] ^ 0x80, pDiscPerSector->subcode.current[23] ^ 0x01
, pDiscPerSector->subcode.current[22], pDiscPerSector->subcode.current[23]);
OutputSubInfoLogA(
"RMSF[%02x:%02x:%02x] AMSF[%02x:%02x:%02x]\n"
, pDiscPerSector->subcode.current[15], pDiscPerSector->subcode.current[16], pDiscPerSector->subcode.current[17]
, pDiscPerSector->subcode.current[19], pDiscPerSector->subcode.current[20], pDiscPerSector->subcode.current[21]);
OutputLogA(standardOut | fileDisc, "Detected intentional subchannel in LBA -1 => SecuROM Type 4 (a.k.a. NEW)\n");
OutputIntentionalSubchannel(-1, &pDiscPerSector->subcode.current[12]);
pDisc->PROTECT.byExist = securomV4;
pDiscPerSector->subQ.prev.nRelativeTime = -1;
pDiscPerSector->subQ.prev.nAbsoluteTime = 149;
}
else if ((nRLBA == 167295 || nRLBA == 0) && nALBA == 150) { // 167295(37:10:45), 150(00:02:00)
OutputSubInfoWithLBALogA(
"Detected shifted sub. RMSF[%02x:%02x:%02x] AMSF[%02x:%02x:%02x]\n"
, -1, 0, pDiscPerSector->subcode.current[15], pDiscPerSector->subcode.current[16], pDiscPerSector->subcode.current[17]
, pDiscPerSector->subcode.current[19], pDiscPerSector->subcode.current[20], pDiscPerSector->subcode.current[21]);
// Colin McRae Rally 2.0 http://redump.org/disc/31587/
if (nRLBA == 167295) {
OutputLogA(standardOut | fileDisc, "Detected intentional subchannel in LBA -1 => SecuROM Type 3_1 (a.k.a. NEW)\n");
pDisc->PROTECT.byExist = securomV3_1;
}
// Empire Earth http://redump.org/disc/45559/ Diablo II: Lord of Destruction (Expansion Set) http://redump.org/disc/58232/
else if (nRLBA == 0) {
OutputLogA(standardOut | fileDisc, "Detected intentional subchannel in LBA -1 => SecuROM Type 3_2 (a.k.a. NEW)\n");
pDisc->PROTECT.byExist = securomV3_2;
}
OutputIntentionalSubchannel(-1, &pDiscPerSector->subcode.current[12]);
if (pDisc->SUB.nSubChannelOffset) {
pDisc->SUB.nSubChannelOffset -= 1;
}
pDiscPerSector->subQ.prev.nRelativeTime = -1;
pDiscPerSector->subQ.prev.nAbsoluteTime = 149;
}
else if (pDisc->SCSI.nAllLength > 5000) {
BYTE byTransferLen = 2;
if (lpCmd[0] == 0xd8) {
byTransferLen = lpCmd[9];
lpCmd[9] = 1;
}
else {
byTransferLen = lpCmd[8];
lpCmd[8] = 1;
}
if (!ExecReadCD(pExtArg, pDevice, lpCmd, 5000, pDiscPerSector->data.current,
pDevice->TRANSFER.uiBufLen, _T(__FUNCTION__), __LINE__)) {
return FALSE;
}
AlignRowSubcode(pDiscPerSector->subcode.current, pDiscPerSector->data.current + pDevice->TRANSFER.uiBufSubOffset);
nRLBA = MSFtoLBA(BcdToDec(pDiscPerSector->subcode.current[15])
, BcdToDec(pDiscPerSector->subcode.current[16]), BcdToDec(pDiscPerSector->subcode.current[17]));
nALBA = MSFtoLBA(BcdToDec(pDiscPerSector->subcode.current[19])
, BcdToDec(pDiscPerSector->subcode.current[20]), BcdToDec(pDiscPerSector->subcode.current[21]));
if (nRLBA == 5001 && nALBA == 5151) { // 5001(01:06:51), 5151(01:08:51)
OutputLogA(standardOut | fileDisc, "Detected intentional subchannel in LBA 5000 => SecuROM Type 2 (a.k.a. NEW)\n");
pDisc->PROTECT.byExist = securomV2;
}
else if (pDisc->PROTECT.byExist == securomTmp) {
pDisc->PROTECT.byExist = securomV1;
}
else {
for (INT nTmpLBA = 40000; nTmpLBA < 45800; nTmpLBA++) {
if (pDisc->SCSI.nAllLength > nTmpLBA) {
if (!ExecReadCD(pExtArg, pDevice, lpCmd, nTmpLBA, pDiscPerSector->data.current,
pDevice->TRANSFER.uiBufLen, _T(__FUNCTION__), __LINE__)) {
return FALSE;
}
WORD reCalcCrc16 = (WORD)GetCrc16CCITT(10, &pDiscPerSector->subcode.current[12]);
WORD reCalcXorCrc16 = (WORD)(reCalcCrc16 ^ 0x0080);
if (pDiscPerSector->subcode.current[22] == HIBYTE(reCalcXorCrc16) &&
pDiscPerSector->subcode.current[23] == LOBYTE(reCalcXorCrc16)) {
OutputLogA(standardOut | fileDisc
, "Detected intentional subchannel in LBA %d => SecuROM Type 1 (a.k.a. OLD)\n", nTmpLBA);
pDisc->PROTECT.byExist = securomV1;
break;
}
}
}
if (pDisc->PROTECT.byExist != securomV1) {
OutputLogA(standardOut | fileDisc, "[INFO] SecuROM sector not found \n");
}
}
if (lpCmd[0] == 0xd8) {
lpCmd[9] = byTransferLen;
}
else {
lpCmd[8] = byTransferLen;
}
}
else {
OutputLogA(standardOut | fileDisc, "[INFO] SecuROM sector not found \n");
}
}
return TRUE;
}
BOOL ExecCheckingByteOrder(
PEXT_ARG pExtArg,
PDEVICE pDevice,
CDFLAG::_READ_CD::_ERROR_FLAGS c2,
CDFLAG::_READ_CD::_SUB_CHANNEL_SELECTION sub
) {
LPBYTE pBuf = NULL;
LPBYTE lpBuf = NULL;
if (!GetAlignedCallocatedBuffer(pDevice, &pBuf,
CD_RAW_SECTOR_WITH_C2_294_AND_SUBCODE_SIZE, &lpBuf, _T(__FUNCTION__), __LINE__)) {
return FALSE;
}
BYTE lpCmd[CDB12GENERIC_LENGTH] = {};
pExtArg->byBe = TRUE;
SetReadDiscCommand(NULL, pExtArg, pDevice, 1, c2, sub, lpCmd, FALSE);
pExtArg->byBe = FALSE;
BOOL bRet = TRUE;
if (!ExecReadCD(pExtArg, pDevice, lpCmd, 0, lpBuf
, CD_RAW_SECTOR_WITH_C2_294_AND_SUBCODE_SIZE, _T(__FUNCTION__), __LINE__)) {
OutputLogA(standardError | fileDrive,
"This drive doesn't support [OpCode: %#02x, C2flag: %x, SubCode: %x]\n"
, lpCmd[0], (lpCmd[9] & 0x6) >> 1, lpCmd[10]);
bRet = FALSE;
}
else {
OutputDriveLogA(OUTPUT_DHYPHEN_PLUS_STR(Check main + c2 + sub));
OutputCDC2Error296(fileDrive, lpBuf + CD_RAW_SECTOR_SIZE, 0);
OutputCDSub96Raw(fileDrive, lpBuf + CD_RAW_SECTOR_WITH_C2_294_SIZE, 0);
OutputDriveLogA(OUTPUT_DHYPHEN_PLUS_STR(Check main + sub + c2));
OutputCDSub96Raw(fileDrive, lpBuf + CD_RAW_SECTOR_SIZE, 0);
OutputCDC2Error296(fileDrive, lpBuf + CD_RAW_SECTOR_WITH_SUBCODE_SIZE, 0);
BYTE subcode[CD_RAW_READ_SUBCODE_SIZE] = {};
memcpy(subcode, lpBuf + CD_RAW_SECTOR_WITH_C2_294_SIZE, CD_RAW_READ_SUBCODE_SIZE);
// check main + c2 + sub order
BOOL bMainSubC2 = TRUE;
for (INT i = 0; i < CD_RAW_READ_SUBCODE_SIZE; i++) {
if (subcode[i]) {
bMainSubC2 = FALSE;
break;
}
}
if (bMainSubC2) {
pDevice->driveOrder = DRIVE_DATA_ORDER::MainSubC2;
}
}
FreeAndNull(pBuf);
return bRet;
}
VOID ReadCDForCheckingByteOrder(
PEXT_ARG pExtArg,
PDEVICE pDevice,
CDFLAG::_READ_CD::_ERROR_FLAGS* c2
) {
SetBufferSizeForReadCD(pDevice, DRIVE_DATA_ORDER::NoC2);
if (pExtArg->byC2 && pDevice->FEATURE.byC2ErrorData) {
*c2 = CDFLAG::_READ_CD::byte294;
SetBufferSizeForReadCD(pDevice, DRIVE_DATA_ORDER::MainC2Sub);
pDevice->driveOrder = DRIVE_DATA_ORDER::MainC2Sub;
CDFLAG::_READ_CD::_SUB_CHANNEL_SELECTION sub = CDFLAG::_READ_CD::Raw;
if (!ExecCheckingByteOrder(pExtArg, pDevice, *c2, sub)) {
BOOL bRet = FALSE;
if (!pExtArg->byD8 && !pDevice->byPlxtrDrive) {
bRet = TRUE;
sub = CDFLAG::_READ_CD::Q;
if (!ExecCheckingByteOrder(pExtArg, pDevice, *c2, sub)) {
// not return FALSE
}
sub = CDFLAG::_READ_CD::Pack;
if (!ExecCheckingByteOrder(pExtArg, pDevice, *c2, sub)) {
// not return FALSE
}
*c2 = CDFLAG::_READ_CD::byte296;
sub = CDFLAG::_READ_CD::Raw;
if (!ExecCheckingByteOrder(pExtArg, pDevice, *c2, sub)) {
bRet = FALSE;
}
sub = CDFLAG::_READ_CD::Q;
if (!ExecCheckingByteOrder(pExtArg, pDevice, *c2, sub)) {
// not return FALSE
}
sub = CDFLAG::_READ_CD::Pack;
if (!ExecCheckingByteOrder(pExtArg, pDevice, *c2, sub)) {
// not return FALSE
}
}
if (!bRet) {
OutputLogA(standardError | fileDrive,
"[WARNING] This drive doesn't support reporting C2 error. Disabled /c2\n");
*c2 = CDFLAG::_READ_CD::NoC2;
pDevice->driveOrder = DRIVE_DATA_ORDER::NoC2;
pDevice->FEATURE.byC2ErrorData = FALSE;
SetBufferSizeForReadCD(pDevice, DRIVE_DATA_ORDER::NoC2);
}
}
if (pDevice->driveOrder == DRIVE_DATA_ORDER::MainSubC2) {
OutputDriveLogA(
"\tByte order of this drive is main + sub + c2\n");
SetBufferSizeForReadCD(pDevice, DRIVE_DATA_ORDER::MainSubC2);
}
else if (pDevice->driveOrder == DRIVE_DATA_ORDER::MainC2Sub) {
OutputDriveLogA(
"\tByte order of this drive is main + c2 + sub\n");
}
}
#ifdef _DEBUG
OutputString(
_T("BufLen %ubyte, BufC2Offset %ubyte, BufSubOffset %ubyte\n"),
pDevice->TRANSFER.uiBufLen, pDevice->TRANSFER.uiBufC2Offset, pDevice->TRANSFER.uiBufSubOffset);
#endif
}
BOOL ReadCDCheck(
PEXEC_TYPE pExecType,
PEXT_ARG pExtArg,
PDEVICE pDevice,
PDISC pDisc
) {
// needs to call ReadTOCFull
if (!pDisc->SCSI.bMultiSession && pExtArg->byMultiSession) {
OutputString(
_T("[INFO] This disc isn't Multi-Session. /ms is ignored.\n"));
pExtArg->byMultiSession = FALSE;
}
else if (pDisc->SCSI.bMultiSession && !pExtArg->byMultiSession) {
OutputString(
_T("[INFO] This disc is Multi-Session. /ms is set.\n"));
pExtArg->byMultiSession = TRUE;
}
if (!pExtArg->byReverse) {
// Typically, CD+G data is included in audio only disc
// But exceptionally, WonderMega Collection (SCD)(mixed disc) exists CD+G data.
if (!ReadCDForCheckingSubRtoW(pExtArg, pDevice, pDisc)) {
return FALSE;
}
if (pDisc->SCSI.trackType != TRACK_TYPE::audioOnly) {
if (*pExecType == gd) {
if (!ReadGDForFileSystem(pExecType, pExtArg, pDevice, pDisc)) {
return FALSE;
}
}
else {
if (pDisc->SCSI.byFirstDataTrackNum == 1) {
ReadCDForSegaDisc(pExtArg, pDevice);
}
if (pExtArg->byLibCrypt) {
// PSX PAL only
if (!ReadCDForCheckingPsxRegion(pExtArg, pDevice)) {
pExtArg->byLibCrypt = FALSE;
}
}
if (pExtArg->byScanAntiModStr) {
// PSX only
ReadCDForScanningPsxAntiMod(pExtArg, pDevice, pDisc);
}
if (pExtArg->byScanProtectViaSector) {
// Now ProtectCD VOB can be detected
if (!ReadCDForScanningProtectViaSector(pExtArg, pDevice, pDisc)) {
return FALSE;
}
}
if (!ReadCDForFileSystem(pExecType, pExtArg, pDevice, pDisc)) {
return FALSE;
}
if ((pExtArg->byScanProtectViaFile || pExtArg->byScanProtectViaSector) &&
pDisc->PROTECT.byExist == PROTECT_TYPE_CD::no) {
OutputString(
_T("[INFO] Protection can't be detected. /sf, /ss is ignored.\n"));
pExtArg->byScanProtectViaFile = FALSE;
pExtArg->byScanProtectViaSector = FALSE;
}
}
}
}
return TRUE;
}
BOOL ReadGDForCheckingSubQAdr(
PEXT_ARG pExtArg,
PDEVICE pDevice,
PDISC pDisc,
PDISC_PER_SECTOR pDiscPerSector
) {
LPBYTE pBuf = NULL;
LPBYTE lpBuf = NULL;
BYTE lpCmd[CDB12GENERIC_LENGTH] = {};
INT nOfs = 0;
BYTE byMode = DATA_BLOCK_MODE0;
UINT uiBufLen = CD_RAW_SECTOR_SIZE + CD_RAW_READ_SUBCODE_SIZE;
if (!ReadCDForCheckingSubQAdrFirst(pExtArg
, pDevice, pDisc, &pBuf, &lpBuf, lpCmd, &uiBufLen, &nOfs)) {
return FALSE;
}
for (BYTE i = (BYTE)(pDisc->SCSI.toc.FirstTrack - 1); i < pDisc->SCSI.toc.LastTrack; i++) {
if (!ReadCDForCheckingSubQAdr(pExtArg, pDevice, pDisc
, pDiscPerSector, lpCmd, lpBuf, uiBufLen, nOfs, i, &byMode, 1, NULL)) {
return FALSE;
}
OutputString(
_T("\rChecking SubQ adr (Track) %2u/%2u"), i + 1, pDisc->SCSI.toc.LastTrack);
}
OutputString(_T("\n"));
return TRUE;
}
| [
"upswbsbj_20150526@yahoo.co.jp"
] | upswbsbj_20150526@yahoo.co.jp |
0f9d152e54221b8a7d5558dfdd2fbd30a6925849 | 349251d9b110063cde04a77179e98094df9d3e65 | /ndt_omp/include/pclomp/voxel_grid_covariance_omp_impl.hpp | 4efef65b654d4c76310bac503f80d26be18b593b | [] | no_license | mfkiwl/slam | 728bb4e142f0eee6800c66504500eef85dd8a4db | aa7d4d69c92247e4bc1e232a3568a0568ae47e2f | refs/heads/master | 2022-04-08T09:24:33.747950 | 2020-01-19T01:32:33 | 2020-01-19T01:32:33 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 20,956 | hpp | /*
* Software License Agreement (BSD License)
*
* Point Cloud Library (PCL) - www.pointclouds.org
* Copyright (c) 2010-2011, Willow Garage, Inc.
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of the copyright holder(s) nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef PCL_VOXEL_GRID_COVARIANCE_IMPL_OMP_H_
#define PCL_VOXEL_GRID_COVARIANCE_IMPL_OMP_H_
#include <pcl/common/common.h>
#include <pcl/filters/boost.h>
#include "voxel_grid_covariance_omp.h"
#include <Eigen/Dense>
#include <Eigen/Cholesky>
//////////////////////////////////////////////////////////////////////////////////////////
template<typename PointT> void
pclomp::VoxelGridCovariance<PointT>::applyFilter (PointCloud &output) {
voxel_centroids_leaf_indices_.clear ();
// Has the input dataset been set already?
if (!input_) {
PCL_WARN ("[pcl::%s::applyFilter] No input dataset given!\n", getClassName ().c_str ());
output.width = output.height = 0;
output.points.clear ();
return;
}
// Copy the header (and thus the frame_id) + allocate enough space for points
output.height = 1; // downsampling breaks the organized structure
output.is_dense = true; // we filter out invalid points
output.points.clear ();
Eigen::Vector4f min_p, max_p;
// Get the minimum and maximum dimensions
if (!filter_field_name_.empty ()) // If we don't want to process the entire cloud...
pcl::getMinMax3D<PointT> (input_, filter_field_name_, static_cast<float> (filter_limit_min_), static_cast<float> (filter_limit_max_), min_p, max_p, filter_limit_negative_);
else
pcl::getMinMax3D<PointT> (*input_, min_p, max_p);
// Check that the leaf size is not too small, given the size of the data
int64_t dx = static_cast<int64_t>((max_p[0] - min_p[0]) * inverse_leaf_size_[0]) + 1;
int64_t dy = static_cast<int64_t>((max_p[1] - min_p[1]) * inverse_leaf_size_[1]) + 1;
int64_t dz = static_cast<int64_t>((max_p[2] - min_p[2]) * inverse_leaf_size_[2]) + 1;
if ((dx * dy * dz) > std::numeric_limits<int32_t>::max()) {
PCL_WARN("[pcl::%s::applyFilter] Leaf size is too small for the input dataset. Integer indices would overflow.", getClassName().c_str());
output.clear();
return;
}
// Compute the minimum and maximum bounding box values
min_b_[0] = static_cast<int> (floor (min_p[0] * inverse_leaf_size_[0]));
max_b_[0] = static_cast<int> (floor (max_p[0] * inverse_leaf_size_[0]));
min_b_[1] = static_cast<int> (floor (min_p[1] * inverse_leaf_size_[1]));
max_b_[1] = static_cast<int> (floor (max_p[1] * inverse_leaf_size_[1]));
min_b_[2] = static_cast<int> (floor (min_p[2] * inverse_leaf_size_[2]));
max_b_[2] = static_cast<int> (floor (max_p[2] * inverse_leaf_size_[2]));
// Compute the number of divisions needed along all axis
div_b_ = max_b_ - min_b_ + Eigen::Vector4i::Ones ();
div_b_[3] = 0;
// Clear the leaves
leaves_.clear ();
// leaves_.reserve(8192);
// Set up the division multiplier
divb_mul_ = Eigen::Vector4i (1, div_b_[0], div_b_[0] * div_b_[1], 0);
int centroid_size = 4;
if (downsample_all_data_)
centroid_size = boost::mpl::size<FieldList>::value;
// ---[ RGB special case
std::vector<pcl::PCLPointField> fields;
int rgba_index = -1;
rgba_index = pcl::getFieldIndex (*input_, "rgb", fields);
if (rgba_index == -1)
rgba_index = pcl::getFieldIndex (*input_, "rgba", fields);
if (rgba_index >= 0) {
rgba_index = fields[rgba_index].offset;
centroid_size += 3;
}
// If we don't want to process the entire cloud, but rather filter points far away from the viewpoint first...
if (!filter_field_name_.empty ()) {
// Get the distance field index
std::vector<pcl::PCLPointField> fields;
int distance_idx = pcl::getFieldIndex (*input_, filter_field_name_, fields);
if (distance_idx == -1)
PCL_WARN ("[pcl::%s::applyFilter] Invalid filter field name. Index is %d.\n", getClassName ().c_str (), distance_idx);
// First pass: go over all points and insert them into the right leaf
for (size_t cp = 0; cp < input_->points.size (); ++cp) {
if (!input_->is_dense)
// Check if the point is invalid
if (!pcl_isfinite (input_->points[cp].x) ||
!pcl_isfinite (input_->points[cp].y) ||
!pcl_isfinite (input_->points[cp].z))
continue;
// Get the distance value
const uint8_t* pt_data = reinterpret_cast<const uint8_t*> (&input_->points[cp]);
float distance_value = 0;
memcpy (&distance_value, pt_data + fields[distance_idx].offset, sizeof (float));
if (filter_limit_negative_) {
// Use a threshold for cutting out points which inside the interval
if ((distance_value < filter_limit_max_) && (distance_value > filter_limit_min_))
continue;
} else {
// Use a threshold for cutting out points which are too close/far away
if ((distance_value > filter_limit_max_) || (distance_value < filter_limit_min_))
continue;
}
int ijk0 = static_cast<int> (floor (input_->points[cp].x * inverse_leaf_size_[0]) - static_cast<float> (min_b_[0]));
int ijk1 = static_cast<int> (floor (input_->points[cp].y * inverse_leaf_size_[1]) - static_cast<float> (min_b_[1]));
int ijk2 = static_cast<int> (floor (input_->points[cp].z * inverse_leaf_size_[2]) - static_cast<float> (min_b_[2]));
// Compute the centroid leaf index
int idx = ijk0 * divb_mul_[0] + ijk1 * divb_mul_[1] + ijk2 * divb_mul_[2];
Leaf& leaf = leaves_[idx];
if (leaf.nr_points == 0) {
leaf.centroid.resize (centroid_size);
leaf.centroid.setZero ();
}
Eigen::Vector3d pt3d (input_->points[cp].x, input_->points[cp].y, input_->points[cp].z);
// Accumulate point sum for centroid calculation
leaf.mean_ += pt3d;
// Accumulate x*xT for single pass covariance calculation
leaf.cov_ += pt3d * pt3d.transpose ();
// Do we need to process all the fields?
if (!downsample_all_data_) {
Eigen::Vector4f pt (input_->points[cp].x, input_->points[cp].y, input_->points[cp].z, 0);
leaf.centroid.template head<4> () += pt;
} else {
// Copy all the fields
Eigen::VectorXf centroid = Eigen::VectorXf::Zero (centroid_size);
// ---[ RGB special case
if (rgba_index >= 0) {
// fill r/g/b data
int rgb;
memcpy (&rgb, reinterpret_cast<const char*> (&input_->points[cp]) + rgba_index, sizeof (int));
centroid[centroid_size - 3] = static_cast<float> ((rgb >> 16) & 0x0000ff);
centroid[centroid_size - 2] = static_cast<float> ((rgb >> 8) & 0x0000ff);
centroid[centroid_size - 1] = static_cast<float> ((rgb) & 0x0000ff);
}
pcl::for_each_type<FieldList> (pcl::NdCopyPointEigenFunctor<PointT> (input_->points[cp], centroid));
leaf.centroid += centroid;
}
++leaf.nr_points;
}
}
// No distance filtering, process all data
else {
// First pass: go over all points and insert them into the right leaf
for (size_t cp = 0; cp < input_->points.size (); ++cp) {
if (!input_->is_dense)
// Check if the point is invalid
if (!pcl_isfinite (input_->points[cp].x) ||
!pcl_isfinite (input_->points[cp].y) ||
!pcl_isfinite (input_->points[cp].z))
continue;
int ijk0 = static_cast<int> (floor (input_->points[cp].x * inverse_leaf_size_[0]) - static_cast<float> (min_b_[0]));
int ijk1 = static_cast<int> (floor (input_->points[cp].y * inverse_leaf_size_[1]) - static_cast<float> (min_b_[1]));
int ijk2 = static_cast<int> (floor (input_->points[cp].z * inverse_leaf_size_[2]) - static_cast<float> (min_b_[2]));
// Compute the centroid leaf index
int idx = ijk0 * divb_mul_[0] + ijk1 * divb_mul_[1] + ijk2 * divb_mul_[2];
//int idx = (((input_->points[cp].getArray4fmap () * inverse_leaf_size_).template cast<int> ()).matrix () - min_b_).dot (divb_mul_);
Leaf& leaf = leaves_[idx];
if (leaf.nr_points == 0) {
leaf.centroid.resize (centroid_size);
leaf.centroid.setZero ();
}
Eigen::Vector3d pt3d (input_->points[cp].x, input_->points[cp].y, input_->points[cp].z);
// Accumulate point sum for centroid calculation
leaf.mean_ += pt3d;
// Accumulate x*xT for single pass covariance calculation
leaf.cov_ += pt3d * pt3d.transpose ();
// Do we need to process all the fields?
if (!downsample_all_data_) {
Eigen::Vector4f pt (input_->points[cp].x, input_->points[cp].y, input_->points[cp].z, 0);
leaf.centroid.template head<4> () += pt;
} else {
// Copy all the fields
Eigen::VectorXf centroid = Eigen::VectorXf::Zero (centroid_size);
// ---[ RGB special case
if (rgba_index >= 0) {
// Fill r/g/b data, assuming that the order is BGRA
int rgb;
memcpy (&rgb, reinterpret_cast<const char*> (&input_->points[cp]) + rgba_index, sizeof (int));
centroid[centroid_size - 3] = static_cast<float> ((rgb >> 16) & 0x0000ff);
centroid[centroid_size - 2] = static_cast<float> ((rgb >> 8) & 0x0000ff);
centroid[centroid_size - 1] = static_cast<float> ((rgb) & 0x0000ff);
}
pcl::for_each_type<FieldList> (pcl::NdCopyPointEigenFunctor<PointT> (input_->points[cp], centroid));
leaf.centroid += centroid;
}
++leaf.nr_points;
}
}
// Second pass: go over all leaves and compute centroids and covariance matrices
output.points.reserve (leaves_.size ());
if (searchable_)
voxel_centroids_leaf_indices_.reserve (leaves_.size ());
int cp = 0;
if (save_leaf_layout_)
leaf_layout_.resize (div_b_[0] * div_b_[1] * div_b_[2], -1);
// Eigen values and vectors calculated to prevent near singluar matrices
Eigen::SelfAdjointEigenSolver<Eigen::Matrix3d> eigensolver;
Eigen::Matrix3d eigen_val;
Eigen::Vector3d pt_sum;
// Eigen values less than a threshold of max eigen value are inflated to a set fraction of the max eigen value.
double min_covar_eigvalue;
for (auto it = leaves_.begin (); it != leaves_.end (); ++it) {
// Normalize the centroid
Leaf& leaf = it->second;
// Normalize the centroid
leaf.centroid /= static_cast<float> (leaf.nr_points);
// Point sum used for single pass covariance calculation
pt_sum = leaf.mean_;
// Normalize mean
leaf.mean_ /= leaf.nr_points;
// If the voxel contains sufficient points, its covariance is calculated and is added to the voxel centroids and output clouds.
// Points with less than the minimum points will have a can not be accuratly approximated using a normal distribution.
if (leaf.nr_points >= min_points_per_voxel_) {
if (save_leaf_layout_)
leaf_layout_[it->first] = cp++;
output.push_back (PointT ());
// Do we need to process all the fields?
if (!downsample_all_data_) {
output.points.back ().x = leaf.centroid[0];
output.points.back ().y = leaf.centroid[1];
output.points.back ().z = leaf.centroid[2];
} else {
pcl::for_each_type<FieldList> (pcl::NdCopyEigenPointFunctor<PointT> (leaf.centroid, output.back ()));
// ---[ RGB special case
if (rgba_index >= 0) {
// pack r/g/b into rgb
float r = leaf.centroid[centroid_size - 3], g = leaf.centroid[centroid_size - 2], b = leaf.centroid[centroid_size - 1];
int rgb = (static_cast<int> (r)) << 16 | (static_cast<int> (g)) << 8 | (static_cast<int> (b));
memcpy (reinterpret_cast<char*> (&output.points.back ()) + rgba_index, &rgb, sizeof (float));
}
}
// Stores the voxel indice for fast access searching
if (searchable_)
voxel_centroids_leaf_indices_.push_back (static_cast<int> (it->first));
// Single pass covariance calculation
leaf.cov_ = (leaf.cov_ - 2 * (pt_sum * leaf.mean_.transpose ())) / leaf.nr_points + leaf.mean_ * leaf.mean_.transpose ();
leaf.cov_ *= (leaf.nr_points - 1.0) / leaf.nr_points;
//Normalize Eigen Val such that max no more than 100x min.
eigensolver.compute (leaf.cov_);
eigen_val = eigensolver.eigenvalues ().asDiagonal ();
leaf.evecs_ = eigensolver.eigenvectors ();
if (eigen_val (0, 0) < 0 || eigen_val (1, 1) < 0 || eigen_val (2, 2) <= 0) {
leaf.nr_points = -1;
continue;
}
// Avoids matrices near singularities (eq 6.11)[Magnusson 2009]
min_covar_eigvalue = min_covar_eigvalue_mult_ * eigen_val (2, 2);
if (eigen_val (0, 0) < min_covar_eigvalue) {
eigen_val (0, 0) = min_covar_eigvalue;
if (eigen_val (1, 1) < min_covar_eigvalue) {
eigen_val (1, 1) = min_covar_eigvalue;
}
leaf.cov_ = leaf.evecs_ * eigen_val * leaf.evecs_.inverse ();
}
leaf.evals_ = eigen_val.diagonal ();
leaf.icov_ = leaf.cov_.inverse ();
if (leaf.icov_.maxCoeff () == std::numeric_limits<float>::infinity ( )
|| leaf.icov_.minCoeff () == -std::numeric_limits<float>::infinity ( ) ) {
leaf.nr_points = -1;
}
}
}
output.width = static_cast<uint32_t> (output.points.size ());
}
//////////////////////////////////////////////////////////////////////////////////////////
template<typename PointT> int
pclomp::VoxelGridCovariance<PointT>::getNeighborhoodAtPoint(const Eigen::MatrixXi& relative_coordinates, const PointT& reference_point, std::vector<LeafConstPtr> &neighbors) const {
neighbors.clear();
// Find displacement coordinates
Eigen::Vector4i ijk(static_cast<int> (floor(reference_point.x / leaf_size_[0])),
static_cast<int> (floor(reference_point.y / leaf_size_[1])),
static_cast<int> (floor(reference_point.z / leaf_size_[2])), 0);
Eigen::Array4i diff2min = min_b_ - ijk;
Eigen::Array4i diff2max = max_b_ - ijk;
neighbors.reserve(relative_coordinates.cols());
// Check each neighbor to see if it is occupied and contains sufficient points
// Slower than radius search because needs to check 26 indices
for (int ni = 0; ni < relative_coordinates.cols(); ni++) {
Eigen::Vector4i displacement = (Eigen::Vector4i() << relative_coordinates.col(ni), 0).finished();
// Checking if the specified cell is in the grid
if ((diff2min <= displacement.array()).all() && (diff2max >= displacement.array()).all()) {
auto leaf_iter = leaves_.find(((ijk + displacement - min_b_).dot(divb_mul_)));
if (leaf_iter != leaves_.end() && leaf_iter->second.nr_points >= min_points_per_voxel_) {
LeafConstPtr leaf = &(leaf_iter->second);
neighbors.push_back(leaf);
}
}
}
return (static_cast<int> (neighbors.size()));
}
//////////////////////////////////////////////////////////////////////////////////////////
template<typename PointT> int
pclomp::VoxelGridCovariance<PointT>::getNeighborhoodAtPoint(const PointT& reference_point, std::vector<LeafConstPtr> &neighbors) const {
neighbors.clear();
// Find displacement coordinates
Eigen::MatrixXi relative_coordinates = pcl::getAllNeighborCellIndices();
return getNeighborhoodAtPoint(relative_coordinates, reference_point, neighbors);
}
//////////////////////////////////////////////////////////////////////////////////////////
template<typename PointT> int
pclomp::VoxelGridCovariance<PointT>::getNeighborhoodAtPoint7(const PointT& reference_point, std::vector<LeafConstPtr> &neighbors) const {
neighbors.clear();
Eigen::MatrixXi relative_coordinates(3, 7);
relative_coordinates.setZero();
relative_coordinates(0, 1) = 1;
relative_coordinates(0, 2) = -1;
relative_coordinates(1, 3) = 1;
relative_coordinates(1, 4) = -1;
relative_coordinates(2, 5) = 1;
relative_coordinates(2, 6) = -1;
return getNeighborhoodAtPoint(relative_coordinates, reference_point, neighbors);
}
//////////////////////////////////////////////////////////////////////////////////////////
template<typename PointT> int
pclomp::VoxelGridCovariance<PointT>::getNeighborhoodAtPoint1(const PointT& reference_point, std::vector<LeafConstPtr> &neighbors) const {
neighbors.clear();
return getNeighborhoodAtPoint(Eigen::MatrixXi::Zero(3, 1), reference_point, neighbors);
}
//////////////////////////////////////////////////////////////////////////////////////////
template<typename PointT> void
pclomp::VoxelGridCovariance<PointT>::getDisplayCloud (pcl::PointCloud<pcl::PointXYZ>& cell_cloud) {
cell_cloud.clear ();
int pnt_per_cell = 1000;
boost::mt19937 rng;
boost::normal_distribution<> nd (0.0, leaf_size_.head (3).norm ());
boost::variate_generator<boost::mt19937&, boost::normal_distribution<> > var_nor (rng, nd);
Eigen::LLT<Eigen::Matrix3d> llt_of_cov;
Eigen::Matrix3d cholesky_decomp;
Eigen::Vector3d cell_mean;
Eigen::Vector3d rand_point;
Eigen::Vector3d dist_point;
// Generate points for each occupied voxel with sufficient points.
for (auto it = leaves_.begin (); it != leaves_.end (); ++it) {
Leaf& leaf = it->second;
if (leaf.nr_points >= min_points_per_voxel_) {
cell_mean = leaf.mean_;
llt_of_cov.compute (leaf.cov_);
cholesky_decomp = llt_of_cov.matrixL ();
// Random points generated by sampling the normal distribution given by voxel mean and covariance matrix
for (int i = 0; i < pnt_per_cell; i++) {
rand_point = Eigen::Vector3d (var_nor (), var_nor (), var_nor ());
dist_point = cell_mean + cholesky_decomp * rand_point;
cell_cloud.push_back (pcl::PointXYZ (static_cast<float> (dist_point (0)), static_cast<float> (dist_point (1)), static_cast<float> (dist_point (2))));
}
}
}
}
#define PCL_INSTANTIATE_VoxelGridCovariance(T) template class PCL_EXPORTS pcl::VoxelGridCovariance<T>;
#endif // PCL_VOXEL_GRID_COVARIANCE_IMPL_H_
| [
"j.z.feng@foxmail.com"
] | j.z.feng@foxmail.com |
3df35ac09faaa5f60c68c044364fbf4c52d2dabb | 5531368b3bf3a99e66130459c771767132673a29 | /Depressia/io/skillloader.cpp | 7eda07918362bf352ea037d0e995662579d3be87 | [] | no_license | Emadon13/RPGQuest | 1e7673c98888df9f45e26a31d542682bd715ecd0 | ead21644164b8e4a1cf8f7a29c9e66ddeb857f51 | refs/heads/master | 2020-04-01T20:35:10.900281 | 2019-01-08T00:10:23 | 2019-01-08T00:10:23 | 153,610,956 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,737 | cpp | #include "skillloader.h"
using namespace std;
SkillLoader::SkillLoader()
{
}
Skill* SkillLoader::generate()
{
return new Skill();
}
Skill* SkillLoader::generate(string path)
{
ifstream file(path);
string name, text, sprite, mpc, skill, ra, co, rng, od, buffAtt, buffDef, buffSpd;
if(file)
{
getline(file, name);
getline(file, text);
getline(file, sprite);
getline(file, mpc);
getline(file,rng);
getline(file, skill);
if(skill == "attack")
{
getline(file, co);
return new Attack(name, text, sprite, int(stoi(mpc)), SkillLoader::compareRange(rng), float(stoi(co)));
}
else if(skill == "recover")
{
getline(file, co);
getline(file, od);
if(od=="reborn")
return new Recover(name, text, sprite, int(stoi(mpc)), reborn, float(stoi(co)));
else
return new Recover(name, text, sprite, int(stoi(mpc)), SkillLoader::compareRange(rng), float(stoi(co)));
}
else if(skill == "buff")
{
getline(file, buffAtt);
getline(file, buffDef);
getline(file, buffSpd);
return new Buff(name, text, sprite, int(stoi(mpc)),
SkillLoader::compareRange(rng),
SkillLoader::compareWayToBuff(buffAtt),
SkillLoader::compareWayToBuff(buffDef),
SkillLoader::compareWayToBuff(buffSpd));
}
else
{
cout << "ERREUR : type de skill '" << skill << "' non reconnu" << endl;
return new Attack();
}
}
else
{
cout << "ERREUR : fichier de sort " << path << " non trouvé ";
return new Attack();
}
}
Range SkillLoader::compareRange(string range)
{
if (range == "self")
return self;
else if (range == "one_ally")
return one_ally;
else if (range == "one_enemy")
return one_enemy;
else if (range == "group_allies")
return group_allies;
else if (range == "group_enemies")
return group_enemies;
else if (range == "all_entities")
return all_entities;
else if (range == "several")
return several;
else
{
cout << "ERREUR : range inconnu" << endl;
return one_enemy;
}
}
WayToBuff SkillLoader::compareWayToBuff(string wtb)
{
if (wtb == "noBuff")
return noBuff;
else if (wtb == "buffUp")
return buffUp;
else if (wtb == "buffDown")
return buffDown;
else
{
cout << "ERREUR : wtb inconnu" << wtb << endl;
return noBuff;
}
}
| [
"38349700+Emadon13@users.noreply.github.com"
] | 38349700+Emadon13@users.noreply.github.com |
ec5a295e337a9377c28d8d0eabaf90ae04a52621 | 02de5760198ef5bfe3a6d6df4241bba31fe5121a | /main.cpp | 3197bc591f262963932671b94f8462dbdf67cd93 | [] | no_license | kisdy502/DataStruct | 040799ae4230bb1b4385e74a252d1e87afc23274 | 2074249b6ddc188753b96ee85f596cec1860ebc0 | refs/heads/master | 2020-03-07T09:49:43.105824 | 2018-03-30T10:46:10 | 2018-03-30T10:46:10 | 127,416,688 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,495 | cpp | #include <iostream>
#include "SelectSort.h"
#include "QuickSort.h"
#include "BubbleSort.h"
#include "InsertSort.h"
#include "Printer.h"
#include "ShellSort.h"
#include "MergeSort.h"
int main() {
int array[] = {7, 4, 12, 25, 6, 9, 5, 17, 2, 0};
int left = 0;
int length = sizeof(array) / sizeof(int);
int right = length - 1;
std::cout << "left:" << left << std::endl;
std::cout << "right:" << right << std::endl;
std::cout << "source array:" << std::endl;
printfArray(array, length);
// std::cout << "sorting:" << std::endl;
// bubleSort(array, length);
// std::cout << "after sort:" << std::endl;
// printfArray(array, length);
// std::cout << "sorting:" << std::endl;
// selectSort(array, length);
// std::cout << "after sort:" << std::endl;
// printfArray(array, length);
// std::cout << "sorting:" << std::endl;
// quickSort(array, 0, right);
// std::cout << "after sort:" << std::endl;
// printfArray(array, length);
// std::cout << "sorting:" << std::endl;
// insertSort(array, length);
// std::cout << "after sort:" << std::endl;
// printfArray(array, length);
// std::cout << "sorting:" << std::endl;
// shellInsertSort(array, length);
// std::cout << "after sort:" << std::endl;
// printfArray(array, length);
std::cout << "sorting:" << std::endl;
mergeSort(array, length);
std::cout << "after sort:" << std::endl;
printfArray(array, length);
return 0;
}
| [
"bwply2009@163.com"
] | bwply2009@163.com |
bd38c39e4941cf3d3c9258417064499793b78299 | 185b00fc2b448497991418a5214b49445afe18e7 | /SDK/PUBG_UMG_classes.hpp | d4866482eaafb642219b94c42b7fbe222e76f196 | [] | no_license | cpkt9762/PPLAY_SDK | f562e3391df2a46abca33d202884705fdd03a1f8 | 30bf1a7fadab2ed07635e55c9c9749720cd79528 | refs/heads/master | 2021-04-28T10:19:19.392994 | 2018-02-19T07:20:44 | 2018-02-19T07:20:44 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 170,407 | hpp | #pragma once
// PlayerUnknown's Battlegrounds (2.6.23) SDK
#ifdef _MSC_VER
#pragma pack(push, 0x8)
#endif
namespace Classes
{
//---------------------------------------------------------------------------
//Classes
//---------------------------------------------------------------------------
// Class UMG.Visual
// 0x0000 (0x0028 - 0x0028)
class UVisual : public UObject
{
public:
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("Class UMG.Visual");
return ptr;
}
};
// Class UMG.Widget
// 0x0100 (0x0128 - 0x0028)
class UWidget : public UVisual
{
public:
bool bIsVariable; // 0x0028(0x0001) (ZeroConstructor, IsPlainOldData)
bool bCreatedByConstructionScript; // 0x0029(0x0001) (ZeroConstructor, Transient, IsPlainOldData)
unsigned char UnknownData00[0x6]; // 0x002A(0x0006) MISSED OFFSET
class UPanelSlot* Slot; // 0x0030(0x0008) (Edit, BlueprintVisible, ExportObject, BlueprintReadOnly, ZeroConstructor, InstancedReference, IsPlainOldData)
bool bIsEnabled; // 0x0038(0x0001) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
unsigned char UnknownData01[0x7]; // 0x0039(0x0007) MISSED OFFSET
struct FScriptDelegate bIsEnabledDelegate; // 0x0040(0x0014) (ZeroConstructor, InstancedReference)
struct FScriptDelegate OnPrepass; // 0x0050(0x0014) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, InstancedReference)
struct FText ToolTipText; // 0x0060(0x0018) (Edit, BlueprintVisible, BlueprintReadOnly)
struct FScriptDelegate ToolTipTextDelegate; // 0x0078(0x0014) (ZeroConstructor, InstancedReference)
class UWidget* ToolTipWidget; // 0x0088(0x0008) (Edit, BlueprintVisible, ExportObject, BlueprintReadOnly, ZeroConstructor, InstancedReference, IsPlainOldData)
struct FScriptDelegate ToolTipWidgetDelegate; // 0x0090(0x0014) (ZeroConstructor, InstancedReference)
ESlateVisibility Visiblity; // 0x00A0(0x0001) (ZeroConstructor, Deprecated, IsPlainOldData)
ESlateVisibility Visibility; // 0x00A1(0x0001) (Edit, ZeroConstructor, IsPlainOldData)
unsigned char UnknownData02[0x6]; // 0x00A2(0x0006) MISSED OFFSET
struct FScriptDelegate VisibilityDelegate; // 0x00A8(0x0014) (ZeroConstructor, InstancedReference)
unsigned char bOverride_Cursor : 1; // 0x00B8(0x0001) (Edit)
unsigned char UnknownData03[0x3]; // 0x00B9(0x0003) MISSED OFFSET
TEnumAsByte<EMouseCursor> Cursor; // 0x00BC(0x0001) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
bool bIsVolatile; // 0x00BD(0x0001) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
unsigned char UnknownData04[0x2]; // 0x00BE(0x0002) MISSED OFFSET
struct FWidgetTransform RenderTransform; // 0x00C0(0x001C) (Edit, BlueprintVisible, BlueprintReadOnly)
struct FVector2D RenderTransformPivot; // 0x00DC(0x0008) (Edit, BlueprintVisible, BlueprintReadOnly, IsPlainOldData)
unsigned char UnknownData05[0x4]; // 0x00E4(0x0004) MISSED OFFSET
class UWidgetNavigation* Navigation; // 0x00E8(0x0008) (Edit, BlueprintVisible, ExportObject, BlueprintReadOnly, ZeroConstructor, InstancedReference, IsPlainOldData)
unsigned char UnknownData06[0x28]; // 0x00F0(0x0028) MISSED OFFSET
TArray<class UPropertyBinding*> NativeBindings; // 0x0118(0x0010) (ZeroConstructor, Transient)
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("Class UMG.Widget");
return ptr;
}
void SetVisibility(ESlateVisibility InVisibility);
void SetUserFocus(class APlayerController* PlayerController);
void SetToolTipText(const struct FText& InToolTipText);
void SetToolTip(class UWidget* Widget);
void SetRenderTranslation(const struct FVector2D& Translation);
void SetRenderTransformPivot(const struct FVector2D& Pivot);
void SetRenderTransform(const struct FWidgetTransform& InTransform);
void SetRenderShear(const struct FVector2D& Shear);
void SetRenderScale(const struct FVector2D& Scale);
void SetRenderAngle(float Angle);
void SetNavigationRule(EUINavigation Direction, EUINavigationRule Rule, const struct FName& WidgetToFocus);
void SetKeyboardFocus();
void SetIsEnabled(bool bInIsEnabled);
void SetCursor(TEnumAsByte<EMouseCursor> InCursor);
void SetAllNavigationRules(EUINavigationRule Rule, const struct FName& WidgetToFocus);
void ResetCursor();
void RemoveFromParent();
struct FEventReply OnReply__DelegateSignature();
struct FEventReply OnPointerEvent__DelegateSignature(const struct FGeometry& MyGeometry, const struct FPointerEvent& MouseEvent);
bool IsVisible();
bool IsHovered();
void InvalidateLayoutAndVolatility();
bool HasUserFocusedDescendants(class APlayerController* PlayerController);
bool HasUserFocus(class APlayerController* PlayerController);
bool HasMouseCapture();
bool HasKeyboardFocus();
bool HasFocusedDescendants();
bool HasAnyUserFocus();
class UWidget* GetWidget__DelegateSignature();
ESlateVisibility GetVisibility();
struct FText GetText__DelegateSignature();
ESlateVisibility GetSlateVisibility__DelegateSignature();
struct FSlateColor GetSlateColor__DelegateSignature();
struct FSlateBrush GetSlateBrush__DelegateSignature();
class UPanelWidget* GetParent();
class APlayerController* GetOwningPlayer();
TEnumAsByte<EMouseCursor> GetMouseCursor__DelegateSignature();
struct FLinearColor GetLinearColor__DelegateSignature();
bool GetIsEnabled();
int GetInt32__DelegateSignature();
float GetFloat__DelegateSignature();
struct FVector2D GetDesiredSize();
ECheckBoxState GetCheckBoxState__DelegateSignature();
struct FGeometry GetCachedGeometry();
bool GetBool__DelegateSignature();
class UWidget* GenerateWidgetForString__DelegateSignature(const struct FString& Item);
class UWidget* GenerateWidgetForObject__DelegateSignature(class UObject* Item);
void ForceVolatile(bool bForce);
void ForceLayoutPrepass();
void EventForWidget__DelegateSignature(class UWidget* BoundWidget);
};
// Class UMG.UserWidget
// 0x0118 (0x0240 - 0x0128)
class UUserWidget : public UWidget
{
public:
unsigned char UnknownData00[0x8]; // 0x0128(0x0008) MISSED OFFSET
struct FLinearColor ColorAndOpacity; // 0x0130(0x0010) (Edit, BlueprintVisible, BlueprintReadOnly, IsPlainOldData)
struct FScriptDelegate ColorAndOpacityDelegate; // 0x0140(0x0014) (ZeroConstructor, InstancedReference)
struct FSlateColor ForegroundColor; // 0x0150(0x0028) (Edit, BlueprintVisible, BlueprintReadOnly)
struct FScriptDelegate ForegroundColorDelegate; // 0x0178(0x0014) (ZeroConstructor, InstancedReference)
struct FMargin Padding; // 0x0188(0x0010) (Edit, BlueprintVisible, BlueprintReadOnly)
bool bSupportsKeyboardFocus; // 0x0198(0x0001) (ZeroConstructor, Deprecated, IsPlainOldData)
bool bIsFocusable; // 0x0199(0x0001) (Edit, BlueprintVisible, ZeroConstructor, IsPlainOldData)
unsigned char UnknownData01[0x6]; // 0x019A(0x0006) MISSED OFFSET
TArray<class UUMGSequencePlayer*> ActiveSequencePlayers; // 0x01A0(0x0010) (ZeroConstructor, Transient)
TArray<class UUMGSequencePlayer*> StoppedSequencePlayers; // 0x01B0(0x0010) (ZeroConstructor, Transient)
bool bStopAction; // 0x01C0(0x0001) (Edit, BlueprintVisible, ZeroConstructor, IsPlainOldData)
unsigned char UnknownData02[0x3]; // 0x01C1(0x0003) MISSED OFFSET
int Priority; // 0x01C4(0x0004) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
TArray<struct FNamedSlotBinding> NamedSlotBindings; // 0x01C8(0x0010) (ZeroConstructor)
class UWidgetTree* WidgetTree; // 0x01D8(0x0008) (ExportObject, ZeroConstructor, InstancedReference, IsPlainOldData)
unsigned char bCanEverTick : 1; // 0x01E0(0x0001)
unsigned char bCanEverPaint : 1; // 0x01E0(0x0001)
unsigned char UnknownData03 : 1; // 0x01E0(0x0001)
unsigned char bCookedWidgetTree : 1; // 0x01E0(0x0001)
unsigned char UnknownData04[0x7]; // 0x01E1(0x0007) MISSED OFFSET
class UInputComponent* InputComponent; // 0x01E8(0x0008) (ExportObject, ZeroConstructor, Transient, InstancedReference, DuplicateTransient, IsPlainOldData)
unsigned char UnknownData05[0x50]; // 0x01F0(0x0050) MISSED OFFSET
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("Class UMG.UserWidget");
return ptr;
}
void UnregisterInputComponent();
void Tick(const struct FGeometry& MyGeometry, float InDeltaTime);
void StopListeningForInputAction(const struct FName& ActionName, TEnumAsByte<EInputEvent> EventType);
void StopListeningForAllInputActions();
void StopAnimation(class UWidgetAnimation* InAnimation);
void SetPositionInViewport(const struct FVector2D& Position, bool bRemoveDPIScale);
void SetPlaybackSpeed(class UWidgetAnimation* InAnimation, float PlaybackSpeed);
void SetPadding(const struct FMargin& InPadding);
void SetOwningPlayer(class APlayerController* LocalPlayerController);
void SetOwningLocalPlayer(class ULocalPlayer* LocalPlayer);
void SetNumLoopsToPlay(class UWidgetAnimation* InAnimation, int NumLoopsToPlay);
void SetInputActionPriority(int NewPriority);
void SetInputActionBlocking(bool bShouldBlock);
void SetForegroundColor(const struct FSlateColor& InForegroundColor);
void SetDesiredSizeInViewport(const struct FVector2D& Size);
void SetColorAndOpacity(const struct FLinearColor& InColorAndOpacity);
void SetAnchorsInViewport(const struct FAnchors& Anchors);
void SetAlignmentInViewport(const struct FVector2D& Alignment);
void ReverseAnimation(class UWidgetAnimation* InAnimation);
void RemoveFromViewport();
void RegisterInputComponent();
void PreConstruct(bool IsDesignTime);
void PlaySound(class USoundBase* SoundToPlay);
void PlayAnimationTo(class UWidgetAnimation* InAnimation, float StartAtTime, float EndAtTime, int NumLoopsToPlay, TEnumAsByte<EUMGSequencePlayMode> PlayMode, float PlaybackSpeed);
void PlayAnimation(class UWidgetAnimation* InAnimation, float StartAtTime, int NumLoopsToPlay, TEnumAsByte<EUMGSequencePlayMode> PlayMode, float PlaybackSpeed);
float PauseAnimation(class UWidgetAnimation* InAnimation);
struct FEventReply OnTouchStarted(const struct FGeometry& MyGeometry, const struct FPointerEvent& InTouchEvent);
struct FEventReply OnTouchMoved(const struct FGeometry& MyGeometry, const struct FPointerEvent& InTouchEvent);
struct FEventReply OnTouchGesture(const struct FGeometry& MyGeometry, const struct FPointerEvent& GestureEvent);
struct FEventReply OnTouchEnded(const struct FGeometry& MyGeometry, const struct FPointerEvent& InTouchEvent);
struct FEventReply OnPreviewMouseButtonDown(const struct FGeometry& MyGeometry, const struct FPointerEvent& MouseEvent);
struct FEventReply OnPreviewKeyDown(const struct FGeometry& MyGeometry, const struct FKeyEvent& InKeyEvent);
void OnPaint(struct FPaintContext* Context);
struct FEventReply OnMouseWheel(const struct FGeometry& MyGeometry, const struct FPointerEvent& MouseEvent);
struct FEventReply OnMouseMove(const struct FGeometry& MyGeometry, const struct FPointerEvent& MouseEvent);
void OnMouseLeave(const struct FPointerEvent& MouseEvent);
void OnMouseEnter(const struct FGeometry& MyGeometry, const struct FPointerEvent& MouseEvent);
struct FEventReply OnMouseButtonUp(const struct FGeometry& MyGeometry, const struct FPointerEvent& MouseEvent);
struct FEventReply OnMouseButtonDown(const struct FGeometry& MyGeometry, const struct FPointerEvent& MouseEvent);
struct FEventReply OnMouseButtonDoubleClick(const struct FGeometry& InMyGeometry, const struct FPointerEvent& InMouseEvent);
struct FEventReply OnMotionDetected(const struct FGeometry& MyGeometry, const struct FMotionEvent& InMotionEvent);
struct FEventReply OnKeyUp(const struct FGeometry& MyGeometry, const struct FKeyEvent& InKeyEvent);
struct FEventReply OnKeyDown(const struct FGeometry& MyGeometry, const struct FKeyEvent& InKeyEvent);
struct FEventReply OnKeyChar(const struct FGeometry& MyGeometry, const struct FCharacterEvent& InCharacterEvent);
struct FEventReply OnFocusReceived(const struct FGeometry& MyGeometry, const struct FFocusEvent& InFocusEvent);
void OnFocusLost(const struct FFocusEvent& InFocusEvent);
bool OnDrop(const struct FGeometry& MyGeometry, const struct FPointerEvent& PointerEvent, class UDragDropOperation* Operation);
bool OnDragOver(const struct FGeometry& MyGeometry, const struct FPointerEvent& PointerEvent, class UDragDropOperation* Operation);
void OnDragLeave(const struct FPointerEvent& PointerEvent, class UDragDropOperation* Operation);
void OnDragEnter(const struct FGeometry& MyGeometry, const struct FPointerEvent& PointerEvent, class UDragDropOperation* Operation);
void OnDragDetected(const struct FGeometry& MyGeometry, const struct FPointerEvent& PointerEvent, class UDragDropOperation** Operation);
void OnDragCancelled(const struct FPointerEvent& PointerEvent, class UDragDropOperation* Operation);
struct FEventReply OnControllerButtonReleased(const struct FGeometry& MyGeometry, const struct FControllerEvent& ControllerEvent);
struct FEventReply OnControllerButtonPressed(const struct FGeometry& MyGeometry, const struct FControllerEvent& ControllerEvent);
struct FEventReply OnControllerAnalogValueChanged(const struct FGeometry& MyGeometry, const struct FControllerEvent& ControllerEvent);
void OnAnimationStarted(class UWidgetAnimation* Animation);
void OnAnimationFinished(class UWidgetAnimation* Animation);
struct FEventReply OnAnalogValueChanged(const struct FGeometry& MyGeometry, const struct FAnalogInputEvent& InAnalogInputEvent);
void ListenForInputAction(const struct FName& ActionName, TEnumAsByte<EInputEvent> EventType, bool bConsume, const struct FScriptDelegate& Callback);
bool IsPlayingAnimation();
bool IsListeningForInputAction(const struct FName& ActionName);
bool IsInViewport();
bool IsInteractable();
bool IsAnyAnimationPlaying();
bool IsAnimationPlaying(class UWidgetAnimation* InAnimation);
class APawn* GetOwningPlayerPawn();
class APlayerController* GetOwningPlayer();
class ULocalPlayer* GetOwningLocalPlayer();
bool GetIsVisible();
float GetAnimationCurrentTime(class UWidgetAnimation* InAnimation);
struct FAnchors GetAnchorsInViewport();
struct FVector2D GetAlignmentInViewport();
void Destruct();
void Construct();
void AddToViewport(int ZOrder);
bool AddToPlayerScreen(int ZOrder);
};
// Class UMG.AsyncTaskDownloadImage
// 0x0020 (0x0048 - 0x0028)
class UAsyncTaskDownloadImage : public UBlueprintAsyncActionBase
{
public:
struct FScriptMulticastDelegate OnSuccess; // 0x0028(0x0010) (ZeroConstructor, InstancedReference, BlueprintAssignable)
struct FScriptMulticastDelegate OnFail; // 0x0038(0x0010) (ZeroConstructor, InstancedReference, BlueprintAssignable)
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("Class UMG.AsyncTaskDownloadImage");
return ptr;
}
class UAsyncTaskDownloadImage* STATIC_DownloadImage(const struct FString& URL);
};
// Class UMG.DragDropOperation
// 0x0060 (0x0088 - 0x0028)
class UDragDropOperation : public UObject
{
public:
struct FString Tag; // 0x0028(0x0010) (Edit, BlueprintVisible, ZeroConstructor)
class UObject* payload; // 0x0038(0x0008) (Edit, BlueprintVisible, ZeroConstructor, IsPlainOldData)
class UWidget* DefaultDragVisual; // 0x0040(0x0008) (Edit, BlueprintVisible, ExportObject, BlueprintReadOnly, ZeroConstructor, InstancedReference, IsPlainOldData)
EDragPivot Pivot; // 0x0048(0x0001) (Edit, BlueprintVisible, ZeroConstructor, IsPlainOldData)
unsigned char UnknownData00[0x3]; // 0x0049(0x0003) MISSED OFFSET
struct FVector2D Offset; // 0x004C(0x0008) (Edit, BlueprintVisible, IsPlainOldData)
unsigned char UnknownData01[0x4]; // 0x0054(0x0004) MISSED OFFSET
struct FScriptMulticastDelegate OnDrop; // 0x0058(0x0010) (ZeroConstructor, InstancedReference, BlueprintAssignable)
struct FScriptMulticastDelegate OnDragCancelled; // 0x0068(0x0010) (ZeroConstructor, InstancedReference, BlueprintAssignable)
struct FScriptMulticastDelegate OnDragged; // 0x0078(0x0010) (ZeroConstructor, InstancedReference, BlueprintAssignable)
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("Class UMG.DragDropOperation");
return ptr;
}
void Drop(const struct FPointerEvent& PointerEvent);
void Dragged(const struct FPointerEvent& PointerEvent);
void DragCancelled(const struct FPointerEvent& PointerEvent);
};
// Class UMG.MovieScene2DTransformSection
// 0x0320 (0x03F0 - 0x00D0)
class UMovieScene2DTransformSection : public UMovieSceneSection
{
public:
unsigned char UnknownData00[0x8]; // 0x00D0(0x0008) MISSED OFFSET
struct FRichCurve Translation[0x2]; // 0x00D8(0x0070)
struct FRichCurve Rotation; // 0x01B8(0x0070)
struct FRichCurve Scale[0x2]; // 0x0228(0x0070)
struct FRichCurve Shear[0x2]; // 0x0308(0x0070)
unsigned char UnknownData01[0x8]; // 0x03E8(0x0008) MISSED OFFSET
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("Class UMG.MovieScene2DTransformSection");
return ptr;
}
};
// Class UMG.MovieScene2DTransformTrack
// 0x0000 (0x00E0 - 0x00E0)
class UMovieScene2DTransformTrack : public UMovieScenePropertyTrack
{
public:
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("Class UMG.MovieScene2DTransformTrack");
return ptr;
}
};
// Class UMG.MovieSceneMarginSection
// 0x01D0 (0x02A0 - 0x00D0)
class UMovieSceneMarginSection : public UMovieSceneSection
{
public:
unsigned char UnknownData00[0x8]; // 0x00D0(0x0008) MISSED OFFSET
struct FRichCurve TopCurve; // 0x00D8(0x0070)
struct FRichCurve LeftCurve; // 0x0148(0x0070)
struct FRichCurve RightCurve; // 0x01B8(0x0070)
struct FRichCurve BottomCurve; // 0x0228(0x0070)
unsigned char UnknownData01[0x8]; // 0x0298(0x0008) MISSED OFFSET
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("Class UMG.MovieSceneMarginSection");
return ptr;
}
};
// Class UMG.MovieSceneMarginTrack
// 0x0000 (0x00E0 - 0x00E0)
class UMovieSceneMarginTrack : public UMovieScenePropertyTrack
{
public:
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("Class UMG.MovieSceneMarginTrack");
return ptr;
}
};
// Class UMG.MovieSceneWidgetMaterialTrack
// 0x0010 (0x00E0 - 0x00D0)
class UMovieSceneWidgetMaterialTrack : public UMovieSceneMaterialTrack
{
public:
unsigned char UnknownData00[0x8]; // 0x00D0(0x0008) MISSED OFFSET
struct FName TrackName; // 0x00D8(0x0008) (ZeroConstructor, IsPlainOldData)
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("Class UMG.MovieSceneWidgetMaterialTrack");
return ptr;
}
};
// Class UMG.NamedSlotInterface
// 0x0000 (0x0028 - 0x0028)
class UNamedSlotInterface : public UInterface
{
public:
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("Class UMG.NamedSlotInterface");
return ptr;
}
};
// Class UMG.PropertyBinding
// 0x0020 (0x0048 - 0x0028)
class UPropertyBinding : public UObject
{
public:
TWeakObjectPtr<class UObject> SourceObject; // 0x0028(0x0008) (ZeroConstructor, IsPlainOldData)
struct FDynamicPropertyPath SourcePath; // 0x0030(0x0010)
struct FName DestinationProperty; // 0x0040(0x0008) (ZeroConstructor, IsPlainOldData)
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("Class UMG.PropertyBinding");
return ptr;
}
};
// Class UMG.BoolBinding
// 0x0000 (0x0048 - 0x0048)
class UBoolBinding : public UPropertyBinding
{
public:
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("Class UMG.BoolBinding");
return ptr;
}
bool GetValue();
};
// Class UMG.BrushBinding
// 0x0008 (0x0050 - 0x0048)
class UBrushBinding : public UPropertyBinding
{
public:
unsigned char UnknownData00[0x8]; // 0x0048(0x0008) MISSED OFFSET
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("Class UMG.BrushBinding");
return ptr;
}
struct FSlateBrush GetValue();
};
// Class UMG.CheckedStateBinding
// 0x0008 (0x0050 - 0x0048)
class UCheckedStateBinding : public UPropertyBinding
{
public:
unsigned char UnknownData00[0x8]; // 0x0048(0x0008) MISSED OFFSET
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("Class UMG.CheckedStateBinding");
return ptr;
}
ECheckBoxState GetValue();
};
// Class UMG.ColorBinding
// 0x0008 (0x0050 - 0x0048)
class UColorBinding : public UPropertyBinding
{
public:
unsigned char UnknownData00[0x8]; // 0x0048(0x0008) MISSED OFFSET
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("Class UMG.ColorBinding");
return ptr;
}
struct FSlateColor GetSlateValue();
struct FLinearColor GetLinearValue();
};
// Class UMG.FloatBinding
// 0x0000 (0x0048 - 0x0048)
class UFloatBinding : public UPropertyBinding
{
public:
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("Class UMG.FloatBinding");
return ptr;
}
float GetValue();
};
// Class UMG.Int32Binding
// 0x0000 (0x0048 - 0x0048)
class UInt32Binding : public UPropertyBinding
{
public:
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("Class UMG.Int32Binding");
return ptr;
}
int GetValue();
};
// Class UMG.MouseCursorBinding
// 0x0000 (0x0048 - 0x0048)
class UMouseCursorBinding : public UPropertyBinding
{
public:
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("Class UMG.MouseCursorBinding");
return ptr;
}
TEnumAsByte<EMouseCursor> GetValue();
};
// Class UMG.TextBinding
// 0x0008 (0x0050 - 0x0048)
class UTextBinding : public UPropertyBinding
{
public:
unsigned char UnknownData00[0x8]; // 0x0048(0x0008) MISSED OFFSET
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("Class UMG.TextBinding");
return ptr;
}
struct FText GetTextValue();
struct FString GetStringValue();
};
// Class UMG.VisibilityBinding
// 0x0000 (0x0048 - 0x0048)
class UVisibilityBinding : public UPropertyBinding
{
public:
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("Class UMG.VisibilityBinding");
return ptr;
}
ESlateVisibility GetValue();
};
// Class UMG.WidgetBinding
// 0x0000 (0x0048 - 0x0048)
class UWidgetBinding : public UPropertyBinding
{
public:
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("Class UMG.WidgetBinding");
return ptr;
}
class UWidget* GetValue();
};
// Class UMG.RichTextBlockDecorator
// 0x0008 (0x0030 - 0x0028)
class URichTextBlockDecorator : public UObject
{
public:
bool bReveal; // 0x0028(0x0001) (Edit, BlueprintVisible, ZeroConstructor, IsPlainOldData)
unsigned char UnknownData00[0x3]; // 0x0029(0x0003) MISSED OFFSET
int RevealedIndex; // 0x002C(0x0004) (Edit, BlueprintVisible, ZeroConstructor, IsPlainOldData)
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("Class UMG.RichTextBlockDecorator");
return ptr;
}
};
// Class UMG.SlateBlueprintLibrary
// 0x0000 (0x0028 - 0x0028)
class USlateBlueprintLibrary : public UBlueprintFunctionLibrary
{
public:
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("Class UMG.SlateBlueprintLibrary");
return ptr;
}
void STATIC_ScreenToWidgetLocal(class UObject* WorldContextObject, const struct FGeometry& Geometry, const struct FVector2D& ScreenPosition, struct FVector2D* LocalCoordinate);
void STATIC_ScreenToWidgetAbsolute(class UObject* WorldContextObject, const struct FVector2D& ScreenPosition, struct FVector2D* AbsoluteCoordinate);
void STATIC_ScreenToViewport(class UObject* WorldContextObject, const struct FVector2D& ScreenPosition, struct FVector2D* ViewportPosition);
void STATIC_LocalToViewport(class UObject* WorldContextObject, const struct FGeometry& Geometry, const struct FVector2D& LocalCoordinate, struct FVector2D* PixelPosition, struct FVector2D* ViewportPosition);
struct FVector2D STATIC_LocalToAbsolute(const struct FGeometry& Geometry, const struct FVector2D& LocalCoordinate);
bool STATIC_IsUnderLocation(const struct FGeometry& Geometry, const struct FVector2D& AbsoluteCoordinate);
struct FVector2D STATIC_GetLocalSize(const struct FGeometry& Geometry);
bool STATIC_EqualEqual_SlateBrush(const struct FSlateBrush& A, const struct FSlateBrush& B);
void STATIC_AbsoluteToViewport(class UObject* WorldContextObject, const struct FVector2D& AbsoluteDesktopCoordinate, struct FVector2D* PixelPosition, struct FVector2D* ViewportPosition);
struct FVector2D STATIC_AbsoluteToLocal(const struct FGeometry& Geometry, const struct FVector2D& AbsoluteCoordinate);
};
// Class UMG.SlateDataSheet
// 0x0408 (0x0430 - 0x0028)
class USlateDataSheet : public UObject
{
public:
class UTexture2D* DataTexture; // 0x0028(0x0008) (ZeroConstructor, Transient, IsPlainOldData)
unsigned char UnknownData00[0x400]; // 0x0030(0x0400) MISSED OFFSET
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("Class UMG.SlateDataSheet");
return ptr;
}
};
// Class UMG.SlateVectorArtData
// 0x0038 (0x0060 - 0x0028)
class USlateVectorArtData : public UObject
{
public:
TArray<struct FSlateMeshVertex> VertexData; // 0x0028(0x0010) (ZeroConstructor)
TArray<uint32_t> IndexData; // 0x0038(0x0010) (ZeroConstructor)
class UMaterialInterface* Material; // 0x0048(0x0008) (ZeroConstructor, IsPlainOldData)
struct FVector2D ExtentMin; // 0x0050(0x0008) (IsPlainOldData)
struct FVector2D ExtentMax; // 0x0058(0x0008) (IsPlainOldData)
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("Class UMG.SlateVectorArtData");
return ptr;
}
};
// Class UMG.WidgetBlueprintGeneratedClass
// 0x0070 (0x03C8 - 0x0358)
class UWidgetBlueprintGeneratedClass : public UBlueprintGeneratedClass
{
public:
class UWidgetTree* WidgetTree; // 0x0358(0x0008) (ZeroConstructor, IsPlainOldData)
bool bAllowTemplate; // 0x0360(0x0001) (ZeroConstructor, IsPlainOldData)
unsigned char UnknownData00[0x7]; // 0x0361(0x0007) MISSED OFFSET
TArray<struct FDelegateRuntimeBinding> Bindings; // 0x0368(0x0010) (ZeroConstructor)
TArray<class UWidgetAnimation*> Animations; // 0x0378(0x0010) (ExportObject, ZeroConstructor)
TArray<struct FName> NamedSlots; // 0x0388(0x0010) (ZeroConstructor)
bool bValidTemplate; // 0x0398(0x0001) (ZeroConstructor, IsPlainOldData)
bool bTemplateInitialized; // 0x0399(0x0001) (ZeroConstructor, Transient, IsPlainOldData)
bool bCookedTemplate; // 0x039A(0x0001) (ZeroConstructor, Transient, IsPlainOldData)
unsigned char UnknownData01[0x5]; // 0x039B(0x0005) MISSED OFFSET
TAssetPtr<class UUserWidget> TemplateAsset; // 0x03A0(0x0020) (ExportObject, InstancedReference)
class UUserWidget* Template; // 0x03C0(0x0008) (ExportObject, ZeroConstructor, Transient, InstancedReference, IsPlainOldData)
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("Class UMG.WidgetBlueprintGeneratedClass");
return ptr;
}
};
// Class UMG.UMGSequencePlayer
// 0x0678 (0x06A0 - 0x0028)
class UUMGSequencePlayer : public UObject
{
public:
unsigned char UnknownData00[0x348]; // 0x0028(0x0348) MISSED OFFSET
class UWidgetAnimation* Animation; // 0x0370(0x0008) (ExportObject, ZeroConstructor, InstancedReference, IsPlainOldData)
unsigned char UnknownData01[0x328]; // 0x0378(0x0328) MISSED OFFSET
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("Class UMG.UMGSequencePlayer");
return ptr;
}
};
// Class UMG.PanelSlot
// 0x0010 (0x0038 - 0x0028)
class UPanelSlot : public UVisual
{
public:
class UPanelWidget* Parent; // 0x0028(0x0008) (ExportObject, ZeroConstructor, InstancedReference, IsPlainOldData)
class UWidget* Content; // 0x0030(0x0008) (ExportObject, ZeroConstructor, InstancedReference, IsPlainOldData)
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("Class UMG.PanelSlot");
return ptr;
}
};
// Class UMG.BackgroundBlurSlot
// 0x0028 (0x0060 - 0x0038)
class UBackgroundBlurSlot : public UPanelSlot
{
public:
struct FMargin Padding; // 0x0038(0x0010) (Edit)
TEnumAsByte<EHorizontalAlignment> HorizontalAlignment; // 0x0048(0x0001) (Edit, ZeroConstructor, IsPlainOldData)
TEnumAsByte<EVerticalAlignment> VerticalAlignment; // 0x0049(0x0001) (Edit, ZeroConstructor, IsPlainOldData)
unsigned char UnknownData00[0x16]; // 0x004A(0x0016) MISSED OFFSET
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("Class UMG.BackgroundBlurSlot");
return ptr;
}
void SetVerticalAlignment(TEnumAsByte<EVerticalAlignment> InVerticalAlignment);
void SetPadding(const struct FMargin& InPadding);
void SetHorizontalAlignment(TEnumAsByte<EHorizontalAlignment> InHorizontalAlignment);
};
// Class UMG.BorderSlot
// 0x0028 (0x0060 - 0x0038)
class UBorderSlot : public UPanelSlot
{
public:
struct FMargin Padding; // 0x0038(0x0010) (Edit)
TEnumAsByte<EHorizontalAlignment> HorizontalAlignment; // 0x0048(0x0001) (Edit, ZeroConstructor, IsPlainOldData)
TEnumAsByte<EVerticalAlignment> VerticalAlignment; // 0x0049(0x0001) (Edit, ZeroConstructor, IsPlainOldData)
unsigned char UnknownData00[0x16]; // 0x004A(0x0016) MISSED OFFSET
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("Class UMG.BorderSlot");
return ptr;
}
void SetVerticalAlignment(TEnumAsByte<EVerticalAlignment> InVerticalAlignment);
void SetPadding(const struct FMargin& InPadding);
void SetHorizontalAlignment(TEnumAsByte<EHorizontalAlignment> InHorizontalAlignment);
};
// Class UMG.ButtonSlot
// 0x0028 (0x0060 - 0x0038)
class UButtonSlot : public UPanelSlot
{
public:
struct FMargin Padding; // 0x0038(0x0010) (Edit, BlueprintVisible, BlueprintReadOnly)
TEnumAsByte<EHorizontalAlignment> HorizontalAlignment; // 0x0048(0x0001) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
TEnumAsByte<EVerticalAlignment> VerticalAlignment; // 0x0049(0x0001) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
unsigned char UnknownData00[0x16]; // 0x004A(0x0016) MISSED OFFSET
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("Class UMG.ButtonSlot");
return ptr;
}
void SetVerticalAlignment(TEnumAsByte<EVerticalAlignment> InVerticalAlignment);
void SetPadding(const struct FMargin& InPadding);
void SetHorizontalAlignment(TEnumAsByte<EHorizontalAlignment> InHorizontalAlignment);
};
// Class UMG.CanvasPanelSlot
// 0x0038 (0x0070 - 0x0038)
class UCanvasPanelSlot : public UPanelSlot
{
public:
struct FAnchorData LayoutData; // 0x0038(0x0028) (Edit, BlueprintVisible, BlueprintReadOnly)
bool bAutoSize; // 0x0060(0x0001) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
unsigned char UnknownData00[0x3]; // 0x0061(0x0003) MISSED OFFSET
int ZOrder; // 0x0064(0x0004) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
unsigned char UnknownData01[0x8]; // 0x0068(0x0008) MISSED OFFSET
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("Class UMG.CanvasPanelSlot");
return ptr;
}
void SetZOrder(int InZOrder);
void SetSize(const struct FVector2D& InSize);
void SetPosition(const struct FVector2D& InPosition);
void SetOffsets(const struct FMargin& InOffset);
void SetMinimum(const struct FVector2D& InMinimumAnchors);
void SetMaximum(const struct FVector2D& InMaximumAnchors);
void SetLayout(const struct FAnchorData& InLayoutData);
void SetAutoSize(bool InbAutoSize);
void SetAnchors(const struct FAnchors& InAnchors);
void SetAlignment(const struct FVector2D& InAlignment);
int GetZOrder();
struct FVector2D GetSize();
struct FVector2D GetPosition();
struct FMargin GetOffsets();
struct FAnchorData GetLayout();
bool GetAutoSize();
struct FAnchors GetAnchors();
struct FVector2D GetAlignment();
};
// Class UMG.GridSlot
// 0x0038 (0x0070 - 0x0038)
class UGridSlot : public UPanelSlot
{
public:
struct FMargin Padding; // 0x0038(0x0010) (Edit, BlueprintVisible, BlueprintReadOnly)
TEnumAsByte<EHorizontalAlignment> HorizontalAlignment; // 0x0048(0x0001) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
TEnumAsByte<EVerticalAlignment> VerticalAlignment; // 0x0049(0x0001) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
unsigned char UnknownData00[0x2]; // 0x004A(0x0002) MISSED OFFSET
int Row; // 0x004C(0x0004) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
int RowSpan; // 0x0050(0x0004) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
int Column; // 0x0054(0x0004) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
int ColumnSpan; // 0x0058(0x0004) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
int Layer; // 0x005C(0x0004) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
struct FVector2D Nudge; // 0x0060(0x0008) (Edit, BlueprintVisible, BlueprintReadOnly, IsPlainOldData)
unsigned char UnknownData01[0x8]; // 0x0068(0x0008) MISSED OFFSET
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("Class UMG.GridSlot");
return ptr;
}
void SetVerticalAlignment(TEnumAsByte<EVerticalAlignment> InVerticalAlignment);
void SetRowSpan(int InRowSpan);
void SetRow(int InRow);
void SetPadding(const struct FMargin& InPadding);
void SetLayer(int InLayer);
void SetHorizontalAlignment(TEnumAsByte<EHorizontalAlignment> InHorizontalAlignment);
void SetColumnSpan(int InColumnSpan);
void SetColumn(int InColumn);
};
// Class UMG.HorizontalBoxSlot
// 0x0028 (0x0060 - 0x0038)
class UHorizontalBoxSlot : public UPanelSlot
{
public:
struct FMargin Padding; // 0x0038(0x0010) (Edit, BlueprintVisible, BlueprintReadOnly)
struct FSlateChildSize Size; // 0x0048(0x0008) (Edit, BlueprintVisible, BlueprintReadOnly)
TEnumAsByte<EHorizontalAlignment> HorizontalAlignment; // 0x0050(0x0001) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
TEnumAsByte<EVerticalAlignment> VerticalAlignment; // 0x0051(0x0001) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
unsigned char UnknownData00[0xE]; // 0x0052(0x000E) MISSED OFFSET
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("Class UMG.HorizontalBoxSlot");
return ptr;
}
void SetVerticalAlignment(TEnumAsByte<EVerticalAlignment> InVerticalAlignment);
void SetSize(const struct FSlateChildSize& InSize);
void SetPadding(const struct FMargin& InPadding);
void SetHorizontalAlignment(TEnumAsByte<EHorizontalAlignment> InHorizontalAlignment);
};
// Class UMG.OverlaySlot
// 0x0020 (0x0058 - 0x0038)
class UOverlaySlot : public UPanelSlot
{
public:
struct FMargin Padding; // 0x0038(0x0010) (Edit, BlueprintVisible, BlueprintReadOnly)
TEnumAsByte<EHorizontalAlignment> HorizontalAlignment; // 0x0048(0x0001) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
TEnumAsByte<EVerticalAlignment> VerticalAlignment; // 0x0049(0x0001) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
unsigned char UnknownData00[0xE]; // 0x004A(0x000E) MISSED OFFSET
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("Class UMG.OverlaySlot");
return ptr;
}
void SetVerticalAlignment(TEnumAsByte<EVerticalAlignment> InVerticalAlignment);
void SetPadding(const struct FMargin& InPadding);
void SetHorizontalAlignment(TEnumAsByte<EHorizontalAlignment> InHorizontalAlignment);
};
// Class UMG.SafeZoneSlot
// 0x0028 (0x0060 - 0x0038)
class USafeZoneSlot : public UPanelSlot
{
public:
bool bIsTitleSafe; // 0x0038(0x0001) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
unsigned char UnknownData00[0x3]; // 0x0039(0x0003) MISSED OFFSET
struct FMargin SafeAreaScale; // 0x003C(0x0010) (Edit, BlueprintVisible, BlueprintReadOnly)
TEnumAsByte<EHorizontalAlignment> HAlign; // 0x004C(0x0001) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
TEnumAsByte<EVerticalAlignment> VAlign; // 0x004D(0x0001) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
unsigned char UnknownData01[0x2]; // 0x004E(0x0002) MISSED OFFSET
struct FMargin Padding; // 0x0050(0x0010) (Edit, BlueprintVisible, BlueprintReadOnly)
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("Class UMG.SafeZoneSlot");
return ptr;
}
};
// Class UMG.ScaleBoxSlot
// 0x0028 (0x0060 - 0x0038)
class UScaleBoxSlot : public UPanelSlot
{
public:
struct FMargin Padding; // 0x0038(0x0010) (Edit, BlueprintVisible, BlueprintReadOnly)
TEnumAsByte<EHorizontalAlignment> HorizontalAlignment; // 0x0048(0x0001) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
TEnumAsByte<EVerticalAlignment> VerticalAlignment; // 0x0049(0x0001) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
unsigned char UnknownData00[0x16]; // 0x004A(0x0016) MISSED OFFSET
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("Class UMG.ScaleBoxSlot");
return ptr;
}
void SetVerticalAlignment(TEnumAsByte<EVerticalAlignment> InVerticalAlignment);
void SetPadding(const struct FMargin& InPadding);
void SetHorizontalAlignment(TEnumAsByte<EHorizontalAlignment> InHorizontalAlignment);
};
// Class UMG.ScrollBoxSlot
// 0x0020 (0x0058 - 0x0038)
class UScrollBoxSlot : public UPanelSlot
{
public:
struct FMargin Padding; // 0x0038(0x0010) (Edit, BlueprintVisible, BlueprintReadOnly)
TEnumAsByte<EHorizontalAlignment> HorizontalAlignment; // 0x0048(0x0001) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
unsigned char UnknownData00[0xF]; // 0x0049(0x000F) MISSED OFFSET
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("Class UMG.ScrollBoxSlot");
return ptr;
}
void SetPadding(const struct FMargin& InPadding);
void SetHorizontalAlignment(TEnumAsByte<EHorizontalAlignment> InHorizontalAlignment);
};
// Class UMG.SizeBoxSlot
// 0x0028 (0x0060 - 0x0038)
class USizeBoxSlot : public UPanelSlot
{
public:
struct FMargin Padding; // 0x0038(0x0010) (Edit, BlueprintVisible, BlueprintReadOnly)
TEnumAsByte<EHorizontalAlignment> HorizontalAlignment; // 0x0048(0x0001) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
TEnumAsByte<EVerticalAlignment> VerticalAlignment; // 0x0049(0x0001) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
unsigned char UnknownData00[0x16]; // 0x004A(0x0016) MISSED OFFSET
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("Class UMG.SizeBoxSlot");
return ptr;
}
void SetVerticalAlignment(TEnumAsByte<EVerticalAlignment> InVerticalAlignment);
void SetPadding(const struct FMargin& InPadding);
void SetHorizontalAlignment(TEnumAsByte<EHorizontalAlignment> InHorizontalAlignment);
};
// Class UMG.UniformGridSlot
// 0x0018 (0x0050 - 0x0038)
class UUniformGridSlot : public UPanelSlot
{
public:
TEnumAsByte<EHorizontalAlignment> HorizontalAlignment; // 0x0038(0x0001) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
TEnumAsByte<EVerticalAlignment> VerticalAlignment; // 0x0039(0x0001) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
unsigned char UnknownData00[0x2]; // 0x003A(0x0002) MISSED OFFSET
int Row; // 0x003C(0x0004) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
int Column; // 0x0040(0x0004) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
unsigned char UnknownData01[0xC]; // 0x0044(0x000C) MISSED OFFSET
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("Class UMG.UniformGridSlot");
return ptr;
}
void SetVerticalAlignment(TEnumAsByte<EVerticalAlignment> InVerticalAlignment);
void SetRow(int InRow);
void SetHorizontalAlignment(TEnumAsByte<EHorizontalAlignment> InHorizontalAlignment);
void SetColumn(int InColumn);
};
// Class UMG.VerticalBoxSlot
// 0x0028 (0x0060 - 0x0038)
class UVerticalBoxSlot : public UPanelSlot
{
public:
struct FMargin Padding; // 0x0038(0x0010) (Edit, BlueprintVisible, BlueprintReadOnly)
struct FSlateChildSize Size; // 0x0048(0x0008) (Edit, BlueprintVisible, BlueprintReadOnly)
TEnumAsByte<EHorizontalAlignment> HorizontalAlignment; // 0x0050(0x0001) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
TEnumAsByte<EVerticalAlignment> VerticalAlignment; // 0x0051(0x0001) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
unsigned char UnknownData00[0xE]; // 0x0052(0x000E) MISSED OFFSET
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("Class UMG.VerticalBoxSlot");
return ptr;
}
void SetVerticalAlignment(TEnumAsByte<EVerticalAlignment> InVerticalAlignment);
void SetSize(const struct FSlateChildSize& InSize);
void SetPadding(const struct FMargin& InPadding);
void SetHorizontalAlignment(TEnumAsByte<EHorizontalAlignment> InHorizontalAlignment);
};
// Class UMG.WidgetSwitcherSlot
// 0x0020 (0x0058 - 0x0038)
class UWidgetSwitcherSlot : public UPanelSlot
{
public:
struct FMargin Padding; // 0x0038(0x0010) (Edit, BlueprintVisible, BlueprintReadOnly)
TEnumAsByte<EHorizontalAlignment> HorizontalAlignment; // 0x0048(0x0001) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
TEnumAsByte<EVerticalAlignment> VerticalAlignment; // 0x0049(0x0001) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
unsigned char UnknownData00[0xE]; // 0x004A(0x000E) MISSED OFFSET
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("Class UMG.WidgetSwitcherSlot");
return ptr;
}
void SetVerticalAlignment(TEnumAsByte<EVerticalAlignment> InVerticalAlignment);
void SetPadding(const struct FMargin& InPadding);
void SetHorizontalAlignment(TEnumAsByte<EHorizontalAlignment> InHorizontalAlignment);
};
// Class UMG.PanelWidget
// 0x0018 (0x0140 - 0x0128)
class UPanelWidget : public UWidget
{
public:
TArray<class UPanelSlot*> Slots; // 0x0128(0x0010) (ExportObject, ZeroConstructor)
unsigned char UnknownData00[0x8]; // 0x0138(0x0008) MISSED OFFSET
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("Class UMG.PanelWidget");
return ptr;
}
bool RemoveChildAt(int Index);
bool RemoveChild(class UWidget* Content);
bool HasChild(class UWidget* Content);
bool HasAnyChildren();
int GetChildrenCount();
int GetChildIndex(class UWidget* Content);
class UWidget* GetChildAt(int Index);
void ClearChildren();
class UPanelSlot* AddChild(class UWidget* Content);
};
// Class UMG.ContentWidget
// 0x0000 (0x0140 - 0x0140)
class UContentWidget : public UPanelWidget
{
public:
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("Class UMG.ContentWidget");
return ptr;
}
class UPanelSlot* SetContent(class UWidget* Content);
class UPanelSlot* GetContentSlot();
class UWidget* GetContent();
};
// Class UMG.WindowTitleBarArea
// 0x0020 (0x0160 - 0x0140)
class UWindowTitleBarArea : public UContentWidget
{
public:
bool bDoubleClickTogglesFullscreen; // 0x0140(0x0001) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
unsigned char UnknownData00[0x1F]; // 0x0141(0x001F) MISSED OFFSET
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("Class UMG.WindowTitleBarArea");
return ptr;
}
void SetVerticalAlignment(TEnumAsByte<EVerticalAlignment> InVerticalAlignment);
void SetPadding(const struct FMargin& InPadding);
void SetHorizontalAlignment(TEnumAsByte<EHorizontalAlignment> InHorizontalAlignment);
};
// Class UMG.WindowTitleBarAreaSlot
// 0x0028 (0x0060 - 0x0038)
class UWindowTitleBarAreaSlot : public UPanelSlot
{
public:
struct FMargin Padding; // 0x0038(0x0010) (Edit, BlueprintVisible, BlueprintReadOnly)
TEnumAsByte<EHorizontalAlignment> HorizontalAlignment; // 0x0048(0x0001) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
TEnumAsByte<EVerticalAlignment> VerticalAlignment; // 0x0049(0x0001) (Edit, ZeroConstructor, IsPlainOldData)
unsigned char UnknownData00[0x16]; // 0x004A(0x0016) MISSED OFFSET
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("Class UMG.WindowTitleBarAreaSlot");
return ptr;
}
void SetVerticalAlignment(TEnumAsByte<EVerticalAlignment> InVerticalAlignment);
void SetPadding(const struct FMargin& InPadding);
void SetHorizontalAlignment(TEnumAsByte<EHorizontalAlignment> InHorizontalAlignment);
};
// Class UMG.WrapBoxSlot
// 0x0028 (0x0060 - 0x0038)
class UWrapBoxSlot : public UPanelSlot
{
public:
struct FMargin Padding; // 0x0038(0x0010) (Edit, BlueprintVisible, BlueprintReadOnly)
bool bFillEmptySpace; // 0x0048(0x0001) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
unsigned char UnknownData00[0x3]; // 0x0049(0x0003) MISSED OFFSET
float FillSpanWhenLessThan; // 0x004C(0x0004) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
TEnumAsByte<EHorizontalAlignment> HorizontalAlignment; // 0x0050(0x0001) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
TEnumAsByte<EVerticalAlignment> VerticalAlignment; // 0x0051(0x0001) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
unsigned char UnknownData01[0xE]; // 0x0052(0x000E) MISSED OFFSET
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("Class UMG.WrapBoxSlot");
return ptr;
}
void SetVerticalAlignment(TEnumAsByte<EVerticalAlignment> InVerticalAlignment);
void SetPadding(const struct FMargin& InPadding);
void SetHorizontalAlignment(TEnumAsByte<EHorizontalAlignment> InHorizontalAlignment);
void SetFillSpanWhenLessThan(float InFillSpanWhenLessThan);
void SetFillEmptySpace(bool InbFillEmptySpace);
};
// Class UMG.CircularThrobber
// 0x00C0 (0x01E8 - 0x0128)
class UCircularThrobber : public UWidget
{
public:
int NumberOfPieces; // 0x0128(0x0004) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
float Period; // 0x012C(0x0004) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
float Radius; // 0x0130(0x0004) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
unsigned char UnknownData00[0x4]; // 0x0134(0x0004) MISSED OFFSET
class USlateBrushAsset* PieceImage; // 0x0138(0x0008) (ZeroConstructor, Deprecated, IsPlainOldData)
struct FSlateBrush Image; // 0x0140(0x0090) (Edit, BlueprintVisible, BlueprintReadOnly)
bool bEnableRadius; // 0x01D0(0x0001) (Edit, ZeroConstructor, Transient, IsPlainOldData)
unsigned char UnknownData01[0x17]; // 0x01D1(0x0017) MISSED OFFSET
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("Class UMG.CircularThrobber");
return ptr;
}
void SetRadius(float InRadius);
void SetPeriod(float InPeriod);
void SetNumberOfPieces(int InNumberOfPieces);
};
// Class UMG.ComboBox
// 0x0038 (0x0160 - 0x0128)
class UComboBox : public UWidget
{
public:
TArray<class UObject*> Items; // 0x0128(0x0010) (Edit, BlueprintVisible, ZeroConstructor)
struct FScriptDelegate OnGenerateWidgetEvent; // 0x0138(0x0014) (Edit, ZeroConstructor, InstancedReference)
bool bIsFocusable; // 0x0148(0x0001) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
unsigned char UnknownData00[0x17]; // 0x0149(0x0017) MISSED OFFSET
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("Class UMG.ComboBox");
return ptr;
}
};
// Class UMG.ComboBoxString
// 0x0C80 (0x0DA8 - 0x0128)
class UComboBoxString : public UWidget
{
public:
TArray<struct FString> DefaultOptions; // 0x0128(0x0010) (Edit, ZeroConstructor)
struct FString SelectedOption; // 0x0138(0x0010) (Edit, ZeroConstructor)
struct FComboBoxStyle WidgetStyle; // 0x0148(0x0428) (Edit, BlueprintVisible)
struct FTableRowStyle ItemStyle; // 0x0570(0x0718) (Edit, BlueprintVisible)
struct FMargin ContentPadding; // 0x0C88(0x0010) (Edit, BlueprintVisible, BlueprintReadOnly)
float MaxListHeight; // 0x0C98(0x0004) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
bool HasDownArrow; // 0x0C9C(0x0001) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
bool EnableGamepadNavigationMode; // 0x0C9D(0x0001) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
unsigned char UnknownData00[0x2]; // 0x0C9E(0x0002) MISSED OFFSET
struct FSlateFontInfo Font; // 0x0CA0(0x0068) (Edit, BlueprintVisible, BlueprintReadOnly)
struct FSlateColor ForegroundColor; // 0x0D08(0x0028) (Edit, BlueprintVisible, BlueprintReadOnly)
bool bIsFocusable; // 0x0D30(0x0001) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
unsigned char UnknownData01[0x7]; // 0x0D31(0x0007) MISSED OFFSET
struct FScriptDelegate OnGenerateWidgetEvent; // 0x0D38(0x0014) (Edit, ZeroConstructor, InstancedReference)
struct FScriptMulticastDelegate OnSelectionChanged; // 0x0D48(0x0010) (ZeroConstructor, InstancedReference, BlueprintAssignable)
struct FScriptMulticastDelegate OnOpening; // 0x0D58(0x0010) (ZeroConstructor, InstancedReference, BlueprintAssignable)
unsigned char UnknownData02[0x40]; // 0x0D68(0x0040) MISSED OFFSET
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("Class UMG.ComboBoxString");
return ptr;
}
void SetSelectedOption(const struct FString& Option);
bool RemoveOption(const struct FString& Option);
void RefreshOptions();
void OnSelectionChangedEvent__DelegateSignature(const struct FString& SelectedItem, TEnumAsByte<ESelectInfo> SelectionType);
void OnOpeningEvent__DelegateSignature();
struct FString GetSelectedOption();
int GetOptionCount();
struct FString GetOptionAtIndex(int Index);
int FindOptionIndex(const struct FString& Option);
void ClearSelection();
void ClearOptions();
void AddOption(const struct FString& Option);
};
// Class UMG.TextLayoutWidget
// 0x0028 (0x0150 - 0x0128)
class UTextLayoutWidget : public UWidget
{
public:
struct FShapedTextOptions ShapedTextOptions; // 0x0128(0x0008) (Edit, BlueprintVisible, BlueprintReadOnly)
TEnumAsByte<ETextJustify> Justification; // 0x0130(0x0001) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
bool AutoWrapText; // 0x0131(0x0001) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
unsigned char UnknownData00[0x2]; // 0x0132(0x0002) MISSED OFFSET
float WrapTextAt; // 0x0134(0x0004) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
ETextWrappingPolicy WrappingPolicy; // 0x0138(0x0001) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
unsigned char UnknownData01[0x3]; // 0x0139(0x0003) MISSED OFFSET
struct FMargin Margin; // 0x013C(0x0010) (Edit, BlueprintVisible, BlueprintReadOnly)
float LineHeightPercentage; // 0x014C(0x0004) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("Class UMG.TextLayoutWidget");
return ptr;
}
};
// Class UMG.EditableText
// 0x0390 (0x04B8 - 0x0128)
class UEditableText : public UWidget
{
public:
struct FText Text; // 0x0128(0x0018) (Edit)
struct FScriptDelegate TextDelegate; // 0x0140(0x0014) (ZeroConstructor, InstancedReference)
struct FText HintText; // 0x0150(0x0018) (Edit, BlueprintVisible, BlueprintReadOnly)
struct FScriptDelegate HintTextDelegate; // 0x0168(0x0014) (ZeroConstructor, InstancedReference)
struct FEditableTextStyle WidgetStyle; // 0x0178(0x0248) (Edit, BlueprintVisible)
class USlateWidgetStyleAsset* Style; // 0x03C0(0x0008) (ZeroConstructor, Deprecated, IsPlainOldData)
class USlateBrushAsset* BackgroundImageSelected; // 0x03C8(0x0008) (ZeroConstructor, Deprecated, IsPlainOldData)
class USlateBrushAsset* BackgroundImageComposing; // 0x03D0(0x0008) (ZeroConstructor, Deprecated, IsPlainOldData)
class USlateBrushAsset* CaretImage; // 0x03D8(0x0008) (ZeroConstructor, Deprecated, IsPlainOldData)
struct FSlateFontInfo Font; // 0x03E0(0x0068) (Deprecated)
struct FSlateColor ColorAndOpacity; // 0x0448(0x0028) (Deprecated)
bool IsReadOnly; // 0x0470(0x0001) (Edit, ZeroConstructor, IsPlainOldData)
bool IsPassword; // 0x0471(0x0001) (Edit, ZeroConstructor, IsPlainOldData)
unsigned char UnknownData00[0x2]; // 0x0472(0x0002) MISSED OFFSET
float MinimumDesiredWidth; // 0x0474(0x0004) (Edit, ZeroConstructor, IsPlainOldData)
bool IsCaretMovedWhenGainFocus; // 0x0478(0x0001) (Edit, ZeroConstructor, IsPlainOldData)
bool SelectAllTextWhenFocused; // 0x0479(0x0001) (Edit, ZeroConstructor, IsPlainOldData)
bool RevertTextOnEscape; // 0x047A(0x0001) (Edit, ZeroConstructor, IsPlainOldData)
bool ClearKeyboardFocusOnCommit; // 0x047B(0x0001) (Edit, ZeroConstructor, IsPlainOldData)
bool SelectAllTextOnCommit; // 0x047C(0x0001) (Edit, ZeroConstructor, IsPlainOldData)
bool AllowContextMenu; // 0x047D(0x0001) (Edit, ZeroConstructor, IsPlainOldData)
TEnumAsByte<EVirtualKeyboardType> KeyboardType; // 0x047E(0x0001) (Edit, ZeroConstructor, IsPlainOldData)
unsigned char UnknownData01[0x1]; // 0x047F(0x0001) MISSED OFFSET
struct FShapedTextOptions ShapedTextOptions; // 0x0480(0x0008) (Edit, BlueprintVisible, BlueprintReadOnly)
struct FScriptMulticastDelegate OnTextChanged; // 0x0488(0x0010) (ZeroConstructor, InstancedReference, BlueprintAssignable)
struct FScriptMulticastDelegate OnTextCommitted; // 0x0498(0x0010) (ZeroConstructor, InstancedReference, BlueprintAssignable)
unsigned char UnknownData02[0x10]; // 0x04A8(0x0010) MISSED OFFSET
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("Class UMG.EditableText");
return ptr;
}
void SetText(const struct FText& InText);
void SetIsReadOnly(bool InbIsReadyOnly);
void SetIsPassword(bool InbIsPassword);
void SetHintText(const struct FText& InHintText);
void OnEditableTextCommittedEvent__DelegateSignature(const struct FText& Text, TEnumAsByte<ETextCommit> CommitMethod);
void OnEditableTextChangedEvent__DelegateSignature(const struct FText& Text);
struct FText GetText();
};
// Class UMG.EditableTextBox
// 0x09B8 (0x0AE0 - 0x0128)
class UEditableTextBox : public UWidget
{
public:
struct FText Text; // 0x0128(0x0018) (Edit)
struct FScriptDelegate TextDelegate; // 0x0140(0x0014) (ZeroConstructor, InstancedReference)
struct FEditableTextBoxStyle WidgetStyle; // 0x0150(0x0870) (Edit, BlueprintVisible)
class USlateWidgetStyleAsset* Style; // 0x09C0(0x0008) (ZeroConstructor, Deprecated, IsPlainOldData)
struct FText HintText; // 0x09C8(0x0018) (Edit, BlueprintVisible, BlueprintReadOnly)
struct FScriptDelegate HintTextDelegate; // 0x09E0(0x0014) (ZeroConstructor, InstancedReference)
struct FSlateFontInfo Font; // 0x09F0(0x0068) (Deprecated)
struct FLinearColor ForegroundColor; // 0x0A58(0x0010) (Deprecated, IsPlainOldData)
struct FLinearColor BackgroundColor; // 0x0A68(0x0010) (Deprecated, IsPlainOldData)
struct FLinearColor ReadOnlyForegroundColor; // 0x0A78(0x0010) (Deprecated, IsPlainOldData)
bool IsReadOnly; // 0x0A88(0x0001) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
bool IsPassword; // 0x0A89(0x0001) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
unsigned char UnknownData00[0x2]; // 0x0A8A(0x0002) MISSED OFFSET
float MinimumDesiredWidth; // 0x0A8C(0x0004) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
struct FMargin Padding; // 0x0A90(0x0010) (Deprecated)
bool IsCaretMovedWhenGainFocus; // 0x0AA0(0x0001) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
bool SelectAllTextWhenFocused; // 0x0AA1(0x0001) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
bool RevertTextOnEscape; // 0x0AA2(0x0001) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
bool ClearKeyboardFocusOnCommit; // 0x0AA3(0x0001) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
bool SelectAllTextOnCommit; // 0x0AA4(0x0001) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
bool AllowContextMenu; // 0x0AA5(0x0001) (Edit, ZeroConstructor, IsPlainOldData)
TEnumAsByte<EVirtualKeyboardType> KeyboardType; // 0x0AA6(0x0001) (Edit, ZeroConstructor, IsPlainOldData)
unsigned char UnknownData01[0x1]; // 0x0AA7(0x0001) MISSED OFFSET
struct FShapedTextOptions ShapedTextOptions; // 0x0AA8(0x0008) (Edit, BlueprintVisible, BlueprintReadOnly)
struct FScriptMulticastDelegate OnTextChanged; // 0x0AB0(0x0010) (ZeroConstructor, InstancedReference, BlueprintAssignable)
struct FScriptMulticastDelegate OnTextCommitted; // 0x0AC0(0x0010) (ZeroConstructor, InstancedReference, BlueprintAssignable)
unsigned char UnknownData02[0x10]; // 0x0AD0(0x0010) MISSED OFFSET
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("Class UMG.EditableTextBox");
return ptr;
}
void SetText(const struct FText& InText);
void SetIsReadOnly(bool bReadOnly);
void SetHintText(const struct FText& InText);
void SetError(const struct FText& InError);
void OnEditableTextBoxCommittedEvent__DelegateSignature(const struct FText& Text, TEnumAsByte<ETextCommit> CommitMethod);
void OnEditableTextBoxChangedEvent__DelegateSignature(const struct FText& Text);
bool HasError();
struct FText GetText();
void ClearError();
};
// Class UMG.ExpandableArea
// 0x0248 (0x0370 - 0x0128)
class UExpandableArea : public UWidget
{
public:
unsigned char UnknownData00[0x8]; // 0x0128(0x0008) MISSED OFFSET
struct FExpandableAreaStyle Style; // 0x0130(0x0130) (Edit, BlueprintVisible, BlueprintReadOnly)
struct FSlateBrush BorderBrush; // 0x0260(0x0090) (Edit, BlueprintVisible, BlueprintReadOnly)
struct FSlateColor BorderColor; // 0x02F0(0x0028) (Edit, BlueprintVisible, BlueprintReadOnly)
bool bIsExpanded; // 0x0318(0x0001) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
unsigned char UnknownData01[0x3]; // 0x0319(0x0003) MISSED OFFSET
float MaxHeight; // 0x031C(0x0004) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
struct FMargin HeaderPadding; // 0x0320(0x0010) (Edit, BlueprintVisible, BlueprintReadOnly)
struct FMargin AreaPadding; // 0x0330(0x0010) (Edit, BlueprintVisible, BlueprintReadOnly)
struct FScriptMulticastDelegate OnExpansionChanged; // 0x0340(0x0010) (ZeroConstructor, InstancedReference, BlueprintAssignable)
class UWidget* HeaderContent; // 0x0350(0x0008) (ExportObject, ZeroConstructor, InstancedReference, IsPlainOldData)
class UWidget* BodyContent; // 0x0358(0x0008) (ExportObject, ZeroConstructor, InstancedReference, IsPlainOldData)
unsigned char UnknownData02[0x10]; // 0x0360(0x0010) MISSED OFFSET
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("Class UMG.ExpandableArea");
return ptr;
}
void SetIsExpanded_Animated(bool IsExpanded);
void SetIsExpanded(bool IsExpanded);
bool GetIsExpanded();
};
// Class UMG.Image
// 0x00E8 (0x0210 - 0x0128)
class UImage : public UWidget
{
public:
class USlateBrushAsset* Image; // 0x0128(0x0008) (ZeroConstructor, Deprecated, IsPlainOldData)
struct FSlateBrush Brush; // 0x0130(0x0090) (Edit, BlueprintVisible, BlueprintReadOnly)
struct FScriptDelegate BrushDelegate; // 0x01C0(0x0014) (ZeroConstructor, InstancedReference)
struct FLinearColor ColorAndOpacity; // 0x01D0(0x0010) (Edit, BlueprintVisible, BlueprintReadOnly, IsPlainOldData)
struct FScriptDelegate ColorAndOpacityDelegate; // 0x01E0(0x0014) (ZeroConstructor, InstancedReference)
struct FScriptDelegate OnMouseButtonDownEvent; // 0x01F0(0x0014) (Edit, ZeroConstructor, InstancedReference)
unsigned char UnknownData00[0x10]; // 0x0200(0x0010) MISSED OFFSET
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("Class UMG.Image");
return ptr;
}
void SetOpacity(float InOpacity);
void SetColorAndOpacity(const struct FLinearColor& InColorAndOpacity);
void SetBrushFromTextureDynamic(class UTexture2DDynamic* Texture, bool bMatchSize);
void SetBrushFromTexture(class UTexture2D* Texture, bool bMatchSize);
void SetBrushFromMaterial(class UMaterialInterface* Material);
void SetBrushFromAsset(class USlateBrushAsset* Asset);
void SetBrush(const struct FSlateBrush& InBrush);
class UMaterialInstanceDynamic* GetDynamicMaterial();
};
// Class UMG.InputKeySelector
// 0x0100 (0x0228 - 0x0128)
class UInputKeySelector : public UWidget
{
public:
struct FInputChord SelectedKey; // 0x0128(0x0020) (BlueprintVisible, BlueprintReadOnly)
struct FSlateFontInfo Font; // 0x0148(0x0068) (Edit, BlueprintVisible, BlueprintReadOnly)
struct FMargin Margin; // 0x01B0(0x0010) (Edit, BlueprintVisible, BlueprintReadOnly)
struct FLinearColor ColorAndOpacity; // 0x01C0(0x0010) (Edit, BlueprintVisible, BlueprintReadOnly, IsPlainOldData)
struct FText KeySelectionText; // 0x01D0(0x0018) (Edit, BlueprintVisible, BlueprintReadOnly)
bool bAllowModifierKeys; // 0x01E8(0x0001) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
unsigned char UnknownData00[0x7]; // 0x01E9(0x0007) MISSED OFFSET
struct FScriptMulticastDelegate OnKeySelected; // 0x01F0(0x0010) (ZeroConstructor, InstancedReference, BlueprintAssignable)
struct FScriptMulticastDelegate OnIsSelectingKeyChanged; // 0x0200(0x0010) (ZeroConstructor, InstancedReference, BlueprintAssignable)
unsigned char UnknownData01[0x18]; // 0x0210(0x0018) MISSED OFFSET
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("Class UMG.InputKeySelector");
return ptr;
}
void SetSelectedKey(const struct FInputChord& InSelectedKey);
void SetKeySelectionText(const struct FText& InKeySelectionText);
void SetAllowModifierKeys(bool bInAllowModifierKeys);
void OnKeySelected__DelegateSignature(const struct FInputChord& SelectedKey);
void OnIsSelectingKeyChanged__DelegateSignature();
bool GetIsSelectingKey();
};
// Class UMG.NativeWidgetHost
// 0x0010 (0x0138 - 0x0128)
class UNativeWidgetHost : public UWidget
{
public:
unsigned char UnknownData00[0x10]; // 0x0128(0x0010) MISSED OFFSET
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("Class UMG.NativeWidgetHost");
return ptr;
}
};
// Class UMG.CanvasPanel
// 0x0010 (0x0150 - 0x0140)
class UCanvasPanel : public UPanelWidget
{
public:
unsigned char UnknownData00[0x10]; // 0x0140(0x0010) MISSED OFFSET
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("Class UMG.CanvasPanel");
return ptr;
}
class UCanvasPanelSlot* AddChildToCanvas(class UWidget* Content);
};
// Class UMG.BackgroundBlur
// 0x00C0 (0x0200 - 0x0140)
class UBackgroundBlur : public UContentWidget
{
public:
struct FMargin Padding; // 0x0140(0x0010) (Edit, BlueprintVisible, BlueprintReadOnly)
TEnumAsByte<EHorizontalAlignment> HorizontalAlignment; // 0x0150(0x0001) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
TEnumAsByte<EVerticalAlignment> VerticalAlignment; // 0x0151(0x0001) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
bool bApplyAlphaToBlur; // 0x0152(0x0001) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
unsigned char UnknownData00[0x1]; // 0x0153(0x0001) MISSED OFFSET
float BlurStrength; // 0x0154(0x0004) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
bool bOverrideAutoRadiusCalculation; // 0x0158(0x0001) (ZeroConstructor, IsPlainOldData)
unsigned char UnknownData01[0x3]; // 0x0159(0x0003) MISSED OFFSET
int BlurRadius; // 0x015C(0x0004) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
struct FSlateBrush LowQualityFallbackBrush; // 0x0160(0x0090) (Edit, BlueprintVisible, BlueprintReadOnly)
unsigned char UnknownData02[0x10]; // 0x01F0(0x0010) MISSED OFFSET
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("Class UMG.BackgroundBlur");
return ptr;
}
void SetVerticalAlignment(TEnumAsByte<EVerticalAlignment> InVerticalAlignment);
void SetPadding(const struct FMargin& InPadding);
void SetLowQualityFallbackBrush(const struct FSlateBrush& InBrush);
void SetHorizontalAlignment(TEnumAsByte<EHorizontalAlignment> InHorizontalAlignment);
void SetBlurStrength(float InStrength);
void SetBlurRadius(int InBlurRadius);
void SetApplyAlphaToBlur(bool bInApplyAlphaToBlur);
};
// Class UMG.Border
// 0x0160 (0x02A0 - 0x0140)
class UBorder : public UContentWidget
{
public:
struct FLinearColor ContentColorAndOpacity; // 0x0140(0x0010) (Edit, BlueprintVisible, BlueprintReadOnly, IsPlainOldData)
struct FScriptDelegate ContentColorAndOpacityDelegate; // 0x0150(0x0014) (ZeroConstructor, InstancedReference)
struct FMargin Padding; // 0x0160(0x0010) (Edit, BlueprintVisible, BlueprintReadOnly)
TEnumAsByte<EHorizontalAlignment> HorizontalAlignment; // 0x0170(0x0001) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
TEnumAsByte<EVerticalAlignment> VerticalAlignment; // 0x0171(0x0001) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
unsigned char UnknownData00[0x6]; // 0x0172(0x0006) MISSED OFFSET
struct FSlateBrush Background; // 0x0178(0x0090) (Edit, BlueprintVisible, BlueprintReadOnly)
struct FScriptDelegate BackgroundDelegate; // 0x0208(0x0014) (ZeroConstructor, InstancedReference)
struct FLinearColor BrushColor; // 0x0218(0x0010) (Edit, BlueprintVisible, BlueprintReadOnly, IsPlainOldData)
struct FScriptDelegate BrushColorDelegate; // 0x0228(0x0014) (ZeroConstructor, InstancedReference)
struct FVector2D DesiredSizeScale; // 0x0238(0x0008) (Edit, BlueprintVisible, BlueprintReadOnly, IsPlainOldData)
bool bShowEffectWhenDisabled; // 0x0240(0x0001) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
unsigned char UnknownData01[0x7]; // 0x0241(0x0007) MISSED OFFSET
struct FScriptDelegate OnMouseButtonDownEvent; // 0x0248(0x0014) (Edit, ZeroConstructor, InstancedReference)
struct FScriptDelegate OnMouseButtonUpEvent; // 0x0258(0x0014) (Edit, ZeroConstructor, InstancedReference)
struct FScriptDelegate OnMouseMoveEvent; // 0x0268(0x0014) (Edit, ZeroConstructor, InstancedReference)
struct FScriptDelegate OnMouseDoubleClickEvent; // 0x0278(0x0014) (Edit, ZeroConstructor, InstancedReference)
unsigned char UnknownData02[0x10]; // 0x0288(0x0010) MISSED OFFSET
class USlateBrushAsset* Brush; // 0x0298(0x0008) (ZeroConstructor, Deprecated, IsPlainOldData)
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("Class UMG.Border");
return ptr;
}
void SetVerticalAlignment(TEnumAsByte<EVerticalAlignment> InVerticalAlignment);
void SetPadding(const struct FMargin& InPadding);
void SetHorizontalAlignment(TEnumAsByte<EHorizontalAlignment> InHorizontalAlignment);
void SetDesiredSizeScale(const struct FVector2D& InScale);
void SetContentColorAndOpacity(const struct FLinearColor& InContentColorAndOpacity);
void SetBrushFromTexture(class UTexture2D* Texture);
void SetBrushFromMaterial(class UMaterialInterface* Material);
void SetBrushFromAsset(class USlateBrushAsset* Asset);
void SetBrushColor(const struct FLinearColor& InBrushColor);
void SetBrush(const struct FSlateBrush& InBrush);
class UMaterialInstanceDynamic* GetDynamicMaterial();
};
// Class UMG.Button
// 0x0338 (0x0478 - 0x0140)
class UButton : public UContentWidget
{
public:
class USlateWidgetStyleAsset* Style; // 0x0140(0x0008) (ZeroConstructor, Deprecated, IsPlainOldData)
struct FButtonStyle WidgetStyle; // 0x0148(0x02A8) (Edit, BlueprintVisible)
struct FLinearColor ColorAndOpacity; // 0x03F0(0x0010) (Edit, BlueprintVisible, BlueprintReadOnly, IsPlainOldData)
struct FLinearColor BackgroundColor; // 0x0400(0x0010) (Edit, BlueprintVisible, BlueprintReadOnly, IsPlainOldData)
TEnumAsByte<EButtonClickMethod> ClickMethod; // 0x0410(0x0001) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
TEnumAsByte<EButtonTouchMethod> TouchMethod; // 0x0411(0x0001) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
bool IsFocusable; // 0x0412(0x0001) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
unsigned char UnknownData00[0x5]; // 0x0413(0x0005) MISSED OFFSET
struct FScriptMulticastDelegate OnClicked; // 0x0418(0x0010) (ZeroConstructor, InstancedReference, BlueprintAssignable)
struct FScriptMulticastDelegate OnPressed; // 0x0428(0x0010) (ZeroConstructor, InstancedReference, BlueprintAssignable)
struct FScriptMulticastDelegate OnReleased; // 0x0438(0x0010) (ZeroConstructor, InstancedReference, BlueprintAssignable)
struct FScriptMulticastDelegate OnHovered; // 0x0448(0x0010) (ZeroConstructor, InstancedReference, BlueprintAssignable)
struct FScriptMulticastDelegate OnUnhovered; // 0x0458(0x0010) (ZeroConstructor, InstancedReference, BlueprintAssignable)
unsigned char UnknownData01[0x10]; // 0x0468(0x0010) MISSED OFFSET
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("Class UMG.Button");
return ptr;
}
void SetStyle(const struct FButtonStyle& InStyle);
void SetColorAndOpacity(const struct FLinearColor& InColorAndOpacity);
void SetBackgroundColor(const struct FLinearColor& InBackgroundColor);
bool IsPressed();
};
// Class UMG.CheckBox
// 0x06B0 (0x07F0 - 0x0140)
class UCheckBox : public UContentWidget
{
public:
ECheckBoxState CheckedState; // 0x0140(0x0001) (Edit, ZeroConstructor, IsPlainOldData)
unsigned char UnknownData00[0x7]; // 0x0141(0x0007) MISSED OFFSET
struct FScriptDelegate CheckedStateDelegate; // 0x0148(0x0014) (ZeroConstructor, InstancedReference)
struct FCheckBoxStyle WidgetStyle; // 0x0158(0x05E0) (Edit, BlueprintVisible)
class USlateWidgetStyleAsset* Style; // 0x0738(0x0008) (ZeroConstructor, Deprecated, IsPlainOldData)
class USlateBrushAsset* UncheckedImage; // 0x0740(0x0008) (ZeroConstructor, Deprecated, IsPlainOldData)
class USlateBrushAsset* UncheckedHoveredImage; // 0x0748(0x0008) (ZeroConstructor, Deprecated, IsPlainOldData)
class USlateBrushAsset* UncheckedPressedImage; // 0x0750(0x0008) (ZeroConstructor, Deprecated, IsPlainOldData)
class USlateBrushAsset* CheckedImage; // 0x0758(0x0008) (ZeroConstructor, Deprecated, IsPlainOldData)
class USlateBrushAsset* CheckedHoveredImage; // 0x0760(0x0008) (ZeroConstructor, Deprecated, IsPlainOldData)
class USlateBrushAsset* CheckedPressedImage; // 0x0768(0x0008) (ZeroConstructor, Deprecated, IsPlainOldData)
class USlateBrushAsset* UndeterminedImage; // 0x0770(0x0008) (ZeroConstructor, Deprecated, IsPlainOldData)
class USlateBrushAsset* UndeterminedHoveredImage; // 0x0778(0x0008) (ZeroConstructor, Deprecated, IsPlainOldData)
class USlateBrushAsset* UndeterminedPressedImage; // 0x0780(0x0008) (ZeroConstructor, Deprecated, IsPlainOldData)
TEnumAsByte<EHorizontalAlignment> HorizontalAlignment; // 0x0788(0x0001) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
unsigned char UnknownData01[0x3]; // 0x0789(0x0003) MISSED OFFSET
struct FMargin Padding; // 0x078C(0x0010) (Deprecated)
unsigned char UnknownData02[0x4]; // 0x079C(0x0004) MISSED OFFSET
struct FSlateColor BorderBackgroundColor; // 0x07A0(0x0028) (Deprecated)
bool IsFocusable; // 0x07C8(0x0001) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
unsigned char UnknownData03[0x7]; // 0x07C9(0x0007) MISSED OFFSET
struct FScriptMulticastDelegate OnCheckStateChanged; // 0x07D0(0x0010) (ZeroConstructor, InstancedReference, BlueprintAssignable)
unsigned char UnknownData04[0x10]; // 0x07E0(0x0010) MISSED OFFSET
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("Class UMG.CheckBox");
return ptr;
}
void SetIsChecked(bool InIsChecked);
void SetCheckedState(ECheckBoxState InCheckedState);
bool IsPressed();
bool IsChecked();
ECheckBoxState GetCheckedState();
};
// Class UMG.InvalidationBox
// 0x0018 (0x0158 - 0x0140)
class UInvalidationBox : public UContentWidget
{
public:
bool bCanCache; // 0x0140(0x0001) (Edit, ZeroConstructor, IsPlainOldData)
bool CacheRelativeTransforms; // 0x0141(0x0001) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
unsigned char UnknownData00[0x16]; // 0x0142(0x0016) MISSED OFFSET
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("Class UMG.InvalidationBox");
return ptr;
}
void SetCanCache(bool CanCache);
void InvalidateCache();
bool GetCanCache();
};
// Class UMG.MenuAnchor
// 0x0040 (0x0180 - 0x0140)
class UMenuAnchor : public UContentWidget
{
public:
class UClass* MenuClass; // 0x0140(0x0008) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
struct FScriptDelegate OnGetMenuContentEvent; // 0x0148(0x0014) (Edit, ZeroConstructor, InstancedReference)
TEnumAsByte<EMenuPlacement> Placement; // 0x0158(0x0001) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
bool ShouldDeferPaintingAfterWindowContent; // 0x0159(0x0001) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
bool UseApplicationMenuStack; // 0x015A(0x0001) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
unsigned char UnknownData00[0x5]; // 0x015B(0x0005) MISSED OFFSET
struct FScriptMulticastDelegate OnMenuOpenChanged; // 0x0160(0x0010) (ZeroConstructor, InstancedReference, BlueprintAssignable)
unsigned char UnknownData01[0x10]; // 0x0170(0x0010) MISSED OFFSET
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("Class UMG.MenuAnchor");
return ptr;
}
void ToggleOpen(bool bFocusOnOpen);
bool ShouldOpenDueToClick();
void Open(bool bFocusMenu);
bool IsOpen();
bool HasOpenSubMenus();
struct FVector2D GetMenuPosition();
void Close();
};
// Class UMG.NamedSlot
// 0x0010 (0x0150 - 0x0140)
class UNamedSlot : public UContentWidget
{
public:
unsigned char UnknownData00[0x10]; // 0x0140(0x0010) MISSED OFFSET
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("Class UMG.NamedSlot");
return ptr;
}
};
// Class UMG.RetainerBox
// 0x0028 (0x0168 - 0x0140)
class URetainerBox : public UContentWidget
{
public:
int Phase; // 0x0140(0x0004) (Edit, ZeroConstructor, IsPlainOldData)
int PhaseCount; // 0x0144(0x0004) (Edit, ZeroConstructor, IsPlainOldData)
class UMaterialInterface* EffectMaterial; // 0x0148(0x0008) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
struct FName TextureParameter; // 0x0150(0x0008) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
unsigned char UnknownData00[0x10]; // 0x0158(0x0010) MISSED OFFSET
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("Class UMG.RetainerBox");
return ptr;
}
void SetTextureParameter(const struct FName& TextureParameter);
void SetEffectMaterial(class UMaterialInterface* EffectMaterial);
class UMaterialInstanceDynamic* GetEffectMaterial();
};
// Class UMG.SafeZone
// 0x0018 (0x0158 - 0x0140)
class USafeZone : public UContentWidget
{
public:
bool PadLeft; // 0x0140(0x0001) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
bool PadRight; // 0x0141(0x0001) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
bool PadTop; // 0x0142(0x0001) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
bool PadBottom; // 0x0143(0x0001) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
unsigned char UnknownData00[0x14]; // 0x0144(0x0014) MISSED OFFSET
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("Class UMG.SafeZone");
return ptr;
}
};
// Class UMG.ScaleBox
// 0x0020 (0x0160 - 0x0140)
class UScaleBox : public UContentWidget
{
public:
TEnumAsByte<EStretch> Stretch; // 0x0140(0x0001) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
TEnumAsByte<EStretchDirection> StretchDirection; // 0x0141(0x0001) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
unsigned char UnknownData00[0x2]; // 0x0142(0x0002) MISSED OFFSET
float UserSpecifiedScale; // 0x0144(0x0004) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
bool IgnoreInheritedScale; // 0x0148(0x0001) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
unsigned char UnknownData01[0x17]; // 0x0149(0x0017) MISSED OFFSET
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("Class UMG.ScaleBox");
return ptr;
}
void SetUserSpecifiedScale(float InUserSpecifiedScale);
void SetStretchDirection(TEnumAsByte<EStretchDirection> InStretchDirection);
void SetStretch(TEnumAsByte<EStretch> InStretch);
void SetIgnoreInheritedScale(bool bInIgnoreInheritedScale);
};
// Class UMG.SizeBox
// 0x0030 (0x0170 - 0x0140)
class USizeBox : public UContentWidget
{
public:
unsigned char bOverride_WidthOverride : 1; // 0x0140(0x0001) (Edit)
unsigned char bOverride_HeightOverride : 1; // 0x0140(0x0001) (Edit)
unsigned char bOverride_MinDesiredWidth : 1; // 0x0140(0x0001) (Edit)
unsigned char bOverride_MinDesiredHeight : 1; // 0x0140(0x0001) (Edit)
unsigned char bOverride_MaxDesiredWidth : 1; // 0x0140(0x0001) (Edit)
unsigned char bOverride_MaxDesiredHeight : 1; // 0x0140(0x0001) (Edit)
unsigned char bOverride_MaxAspectRatio : 1; // 0x0140(0x0001) (Edit)
unsigned char UnknownData00[0x3]; // 0x0141(0x0003) MISSED OFFSET
float WidthOverride; // 0x0144(0x0004) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
float HeightOverride; // 0x0148(0x0004) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
float MinDesiredWidth; // 0x014C(0x0004) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
float MinDesiredHeight; // 0x0150(0x0004) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
float MaxDesiredWidth; // 0x0154(0x0004) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
float MaxDesiredHeight; // 0x0158(0x0004) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
float MaxAspectRatio; // 0x015C(0x0004) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
unsigned char UnknownData01[0x10]; // 0x0160(0x0010) MISSED OFFSET
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("Class UMG.SizeBox");
return ptr;
}
void SetWidthOverride(float InWidthOverride);
void SetMinDesiredWidth(float InMinDesiredWidth);
void SetMinDesiredHeight(float InMinDesiredHeight);
void SetMaxDesiredWidth(float InMaxDesiredWidth);
void SetMaxDesiredHeight(float InMaxDesiredHeight);
void SetMaxAspectRatio(float InMaxAspectRatio);
void SetHeightOverride(float InHeightOverride);
void ClearWidthOverride();
void ClearMinDesiredWidth();
void ClearMinDesiredHeight();
void ClearMaxDesiredWidth();
void ClearMaxDesiredHeight();
void ClearMaxAspectRatio();
void ClearHeightOverride();
};
// Class UMG.Viewport
// 0x0028 (0x0168 - 0x0140)
class UViewport : public UContentWidget
{
public:
struct FLinearColor BackgroundColor; // 0x0140(0x0010) (Edit, IsPlainOldData)
unsigned char UnknownData00[0x18]; // 0x0150(0x0018) MISSED OFFSET
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("Class UMG.Viewport");
return ptr;
}
class AActor* Spawn(class UClass* ActorClass);
void SetViewRotation(const struct FRotator& Rotation);
void SetViewLocation(const struct FVector& Location);
struct FRotator GetViewRotation();
class UWorld* GetViewportWorld();
struct FVector GetViewLocation();
};
// Class UMG.GridPanel
// 0x0030 (0x0170 - 0x0140)
class UGridPanel : public UPanelWidget
{
public:
TArray<float> ColumnFill; // 0x0140(0x0010) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor)
TArray<float> RowFill; // 0x0150(0x0010) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor)
unsigned char UnknownData00[0x10]; // 0x0160(0x0010) MISSED OFFSET
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("Class UMG.GridPanel");
return ptr;
}
class UGridSlot* AddChildToGrid(class UWidget* Content);
};
// Class UMG.HorizontalBox
// 0x0010 (0x0150 - 0x0140)
class UHorizontalBox : public UPanelWidget
{
public:
unsigned char UnknownData00[0x10]; // 0x0140(0x0010) MISSED OFFSET
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("Class UMG.HorizontalBox");
return ptr;
}
class UHorizontalBoxSlot* AddChildToHorizontalBox(class UWidget* Content);
};
// Class UMG.Overlay
// 0x0010 (0x0150 - 0x0140)
class UOverlay : public UPanelWidget
{
public:
unsigned char UnknownData00[0x10]; // 0x0140(0x0010) MISSED OFFSET
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("Class UMG.Overlay");
return ptr;
}
class UOverlaySlot* AddChildToOverlay(class UWidget* Content);
};
// Class UMG.ScrollBox
// 0x0798 (0x08D8 - 0x0140)
class UScrollBox : public UPanelWidget
{
public:
struct FScrollBoxStyle WidgetStyle; // 0x0140(0x0248) (Edit, BlueprintVisible)
struct FScrollBarStyle WidgetBarStyle; // 0x0388(0x0518) (Edit, BlueprintVisible)
class USlateWidgetStyleAsset* Style; // 0x08A0(0x0008) (ZeroConstructor, Deprecated, IsPlainOldData)
class USlateWidgetStyleAsset* BarStyle; // 0x08A8(0x0008) (ZeroConstructor, Deprecated, IsPlainOldData)
TEnumAsByte<EOrientation> Orientation; // 0x08B0(0x0001) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
ESlateVisibility ScrollBarVisibility; // 0x08B1(0x0001) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
EConsumeMouseWheel ConsumeMouseWheel; // 0x08B2(0x0001) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
unsigned char UnknownData00[0x1]; // 0x08B3(0x0001) MISSED OFFSET
struct FVector2D ScrollbarThickness; // 0x08B4(0x0008) (Edit, BlueprintVisible, BlueprintReadOnly, IsPlainOldData)
bool AlwaysShowScrollbar; // 0x08BC(0x0001) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
unsigned char UnknownData01[0x1B]; // 0x08BD(0x001B) MISSED OFFSET
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("Class UMG.ScrollBox");
return ptr;
}
void SetScrollOffset(float NewScrollOffset);
void ScrollWidgetIntoView(class UWidget* WidgetToFind, bool AnimateScroll);
void ScrollToStart();
void ScrollToEnd();
float GetScrollOffset();
};
// Class UMG.UniformGridPanel
// 0x0028 (0x0168 - 0x0140)
class UUniformGridPanel : public UPanelWidget
{
public:
struct FMargin SlotPadding; // 0x0140(0x0010) (Edit, BlueprintVisible, BlueprintReadOnly)
float MinDesiredSlotWidth; // 0x0150(0x0004) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
float MinDesiredSlotHeight; // 0x0154(0x0004) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
unsigned char UnknownData00[0x10]; // 0x0158(0x0010) MISSED OFFSET
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("Class UMG.UniformGridPanel");
return ptr;
}
void SetSlotPadding(const struct FMargin& InSlotPadding);
void SetMinDesiredSlotWidth(float InMinDesiredSlotWidth);
void SetMinDesiredSlotHeight(float InMinDesiredSlotHeight);
class UUniformGridSlot* AddChildToUniformGrid(class UWidget* Content);
};
// Class UMG.VerticalBox
// 0x0010 (0x0150 - 0x0140)
class UVerticalBox : public UPanelWidget
{
public:
unsigned char UnknownData00[0x10]; // 0x0140(0x0010) MISSED OFFSET
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("Class UMG.VerticalBox");
return ptr;
}
class UVerticalBoxSlot* AddChildToVerticalBox(class UWidget* Content);
};
// Class UMG.WidgetSwitcher
// 0x0018 (0x0158 - 0x0140)
class UWidgetSwitcher : public UPanelWidget
{
public:
int ActiveWidgetIndex; // 0x0140(0x0004) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
unsigned char UnknownData00[0x14]; // 0x0144(0x0014) MISSED OFFSET
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("Class UMG.WidgetSwitcher");
return ptr;
}
void SetActiveWidgetIndex(int Index);
void SetActiveWidget(class UWidget* Widget);
class UWidget* GetWidgetAtIndex(int Index);
int GetNumWidgets();
int GetActiveWidgetIndex();
};
// Class UMG.WrapBox
// 0x0020 (0x0160 - 0x0140)
class UWrapBox : public UPanelWidget
{
public:
struct FVector2D InnerSlotPadding; // 0x0140(0x0008) (Edit, BlueprintVisible, BlueprintReadOnly, IsPlainOldData)
float WrapWidth; // 0x0148(0x0004) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
bool bExplicitWrapWidth; // 0x014C(0x0001) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
unsigned char UnknownData00[0x13]; // 0x014D(0x0013) MISSED OFFSET
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("Class UMG.WrapBox");
return ptr;
}
void SetInnerSlotPadding(const struct FVector2D& InPadding);
class UWrapBoxSlot* AddChildWrapBox(class UWidget* Content);
};
// Class UMG.ProgressBar
// 0x0220 (0x0348 - 0x0128)
class UProgressBar : public UWidget
{
public:
struct FProgressBarStyle WidgetStyle; // 0x0128(0x01B8) (Edit, BlueprintVisible)
class USlateWidgetStyleAsset* Style; // 0x02E0(0x0008) (ZeroConstructor, Deprecated, IsPlainOldData)
class USlateBrushAsset* BackgroundImage; // 0x02E8(0x0008) (ZeroConstructor, Deprecated, IsPlainOldData)
class USlateBrushAsset* FillImage; // 0x02F0(0x0008) (ZeroConstructor, Deprecated, IsPlainOldData)
class USlateBrushAsset* MarqueeImage; // 0x02F8(0x0008) (ZeroConstructor, Deprecated, IsPlainOldData)
float Percent; // 0x0300(0x0004) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
TEnumAsByte<EProgressBarFillType> BarFillType; // 0x0304(0x0001) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
bool bIsMarquee; // 0x0305(0x0001) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
unsigned char UnknownData00[0x2]; // 0x0306(0x0002) MISSED OFFSET
struct FScriptDelegate PercentDelegate; // 0x0308(0x0014) (ZeroConstructor, InstancedReference)
struct FLinearColor FillColorAndOpacity; // 0x0318(0x0010) (Edit, BlueprintVisible, BlueprintReadOnly, IsPlainOldData)
struct FScriptDelegate FillColorAndOpacityDelegate; // 0x0328(0x0014) (ZeroConstructor, InstancedReference)
unsigned char UnknownData01[0x10]; // 0x0338(0x0010) MISSED OFFSET
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("Class UMG.ProgressBar");
return ptr;
}
void SetPercent(float InPercent);
void SetIsMarquee(bool InbIsMarquee);
void SetFillColorAndOpacity(const struct FLinearColor& InColor);
};
// Class UMG.ScrollBar
// 0x0540 (0x0668 - 0x0128)
class UScrollBar : public UWidget
{
public:
struct FScrollBarStyle WidgetStyle; // 0x0128(0x0518) (Edit, BlueprintVisible)
class USlateWidgetStyleAsset* Style; // 0x0640(0x0008) (ZeroConstructor, Deprecated, IsPlainOldData)
bool bAlwaysShowScrollbar; // 0x0648(0x0001) (Edit, ZeroConstructor, IsPlainOldData)
TEnumAsByte<EOrientation> Orientation; // 0x0649(0x0001) (Edit, ZeroConstructor, IsPlainOldData)
unsigned char UnknownData00[0x2]; // 0x064A(0x0002) MISSED OFFSET
struct FVector2D Thickness; // 0x064C(0x0008) (Edit, IsPlainOldData)
unsigned char UnknownData01[0x14]; // 0x0654(0x0014) MISSED OFFSET
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("Class UMG.ScrollBar");
return ptr;
}
void SetState(float InOffsetFraction, float InThumbSizeFraction);
};
// Class UMG.Slider
// 0x02F8 (0x0420 - 0x0128)
class USlider : public UWidget
{
public:
float Value; // 0x0128(0x0004) (Edit, ZeroConstructor, IsPlainOldData)
unsigned char UnknownData00[0x4]; // 0x012C(0x0004) MISSED OFFSET
struct FScriptDelegate ValueDelegate; // 0x0130(0x0014) (ZeroConstructor, InstancedReference)
struct FSliderStyle WidgetStyle; // 0x0140(0x0250) (Edit, BlueprintVisible)
TEnumAsByte<EOrientation> Orientation; // 0x0390(0x0001) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
unsigned char UnknownData01[0x3]; // 0x0391(0x0003) MISSED OFFSET
struct FLinearColor SliderBarColor; // 0x0394(0x0010) (Edit, BlueprintVisible, BlueprintReadOnly, IsPlainOldData)
struct FLinearColor SliderHandleColor; // 0x03A4(0x0010) (Edit, BlueprintVisible, BlueprintReadOnly, IsPlainOldData)
bool IndentHandle; // 0x03B4(0x0001) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
bool Locked; // 0x03B5(0x0001) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
unsigned char UnknownData02[0x2]; // 0x03B6(0x0002) MISSED OFFSET
float StepSize; // 0x03B8(0x0004) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
bool IsFocusable; // 0x03BC(0x0001) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
unsigned char UnknownData03[0x3]; // 0x03BD(0x0003) MISSED OFFSET
struct FScriptMulticastDelegate OnMouseCaptureBegin; // 0x03C0(0x0010) (ZeroConstructor, InstancedReference, BlueprintAssignable)
struct FScriptMulticastDelegate OnMouseCaptureEnd; // 0x03D0(0x0010) (ZeroConstructor, InstancedReference, BlueprintAssignable)
struct FScriptMulticastDelegate OnControllerCaptureBegin; // 0x03E0(0x0010) (ZeroConstructor, InstancedReference, BlueprintAssignable)
struct FScriptMulticastDelegate OnControllerCaptureEnd; // 0x03F0(0x0010) (ZeroConstructor, InstancedReference, BlueprintAssignable)
struct FScriptMulticastDelegate OnValueChanged; // 0x0400(0x0010) (ZeroConstructor, InstancedReference, BlueprintAssignable)
unsigned char UnknownData04[0x10]; // 0x0410(0x0010) MISSED OFFSET
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("Class UMG.Slider");
return ptr;
}
void SetValue(float InValue);
void SetStepSize(float InValue);
void SetSliderHandleColor(const struct FLinearColor& InValue);
void SetSliderBarColor(const struct FLinearColor& InValue);
void SetLocked(bool InValue);
void SetIndentHandle(bool InValue);
float GetValue();
};
// Class UMG.Spacer
// 0x0018 (0x0140 - 0x0128)
class USpacer : public UWidget
{
public:
struct FVector2D Size; // 0x0128(0x0008) (Edit, BlueprintVisible, BlueprintReadOnly, IsPlainOldData)
unsigned char UnknownData00[0x10]; // 0x0130(0x0010) MISSED OFFSET
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("Class UMG.Spacer");
return ptr;
}
void SetSize(const struct FVector2D& InSize);
};
// Class UMG.SpinBox
// 0x0438 (0x0560 - 0x0128)
class USpinBox : public UWidget
{
public:
float Value; // 0x0128(0x0004) (Edit, ZeroConstructor, IsPlainOldData)
unsigned char UnknownData00[0x4]; // 0x012C(0x0004) MISSED OFFSET
struct FScriptDelegate ValueDelegate; // 0x0130(0x0014) (ZeroConstructor, InstancedReference)
struct FSpinBoxStyle WidgetStyle; // 0x0140(0x0310) (Edit, BlueprintVisible)
class USlateWidgetStyleAsset* Style; // 0x0450(0x0008) (ZeroConstructor, Deprecated, IsPlainOldData)
float Delta; // 0x0458(0x0004) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
float SliderExponent; // 0x045C(0x0004) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
struct FSlateFontInfo Font; // 0x0460(0x0068) (Edit, BlueprintVisible, BlueprintReadOnly)
float MinDesiredWidth; // 0x04C8(0x0004) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
bool ClearKeyboardFocusOnCommit; // 0x04CC(0x0001) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
bool SelectAllTextOnCommit; // 0x04CD(0x0001) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
unsigned char UnknownData01[0x2]; // 0x04CE(0x0002) MISSED OFFSET
struct FSlateColor ForegroundColor; // 0x04D0(0x0028) (Edit, BlueprintVisible, BlueprintReadOnly)
struct FScriptMulticastDelegate OnValueChanged; // 0x04F8(0x0010) (ZeroConstructor, InstancedReference, BlueprintAssignable)
struct FScriptMulticastDelegate OnValueCommitted; // 0x0508(0x0010) (ZeroConstructor, InstancedReference, BlueprintAssignable)
struct FScriptMulticastDelegate OnBeginSliderMovement; // 0x0518(0x0010) (ZeroConstructor, InstancedReference, BlueprintAssignable)
struct FScriptMulticastDelegate OnEndSliderMovement; // 0x0528(0x0010) (ZeroConstructor, InstancedReference, BlueprintAssignable)
unsigned char bOverride_MinValue : 1; // 0x0538(0x0001) (Edit)
unsigned char bOverride_MaxValue : 1; // 0x0538(0x0001) (Edit)
unsigned char bOverride_MinSliderValue : 1; // 0x0538(0x0001) (Edit)
unsigned char bOverride_MaxSliderValue : 1; // 0x0538(0x0001) (Edit)
unsigned char UnknownData02[0x3]; // 0x0539(0x0003) MISSED OFFSET
float MinValue; // 0x053C(0x0004) (Edit, ZeroConstructor, IsPlainOldData)
float MaxValue; // 0x0540(0x0004) (Edit, ZeroConstructor, IsPlainOldData)
float MinSliderValue; // 0x0544(0x0004) (Edit, ZeroConstructor, IsPlainOldData)
float MaxSliderValue; // 0x0548(0x0004) (Edit, ZeroConstructor, IsPlainOldData)
unsigned char UnknownData03[0x14]; // 0x054C(0x0014) MISSED OFFSET
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("Class UMG.SpinBox");
return ptr;
}
void SetValue(float NewValue);
void SetMinValue(float NewValue);
void SetMinSliderValue(float NewValue);
void SetMaxValue(float NewValue);
void SetMaxSliderValue(float NewValue);
void SetForegroundColor(const struct FSlateColor& InForegroundColor);
void OnSpinBoxValueCommittedEvent__DelegateSignature(float InValue, TEnumAsByte<ETextCommit> CommitMethod);
void OnSpinBoxValueChangedEvent__DelegateSignature(float InValue);
void OnSpinBoxBeginSliderMovement__DelegateSignature();
float GetValue();
float GetMinValue();
float GetMinSliderValue();
float GetMaxValue();
float GetMaxSliderValue();
void ClearMinValue();
void ClearMinSliderValue();
void ClearMaxValue();
void ClearMaxSliderValue();
};
// Class UMG.TableViewBase
// 0x0000 (0x0128 - 0x0128)
class UTableViewBase : public UWidget
{
public:
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("Class UMG.TableViewBase");
return ptr;
}
class UWidget* OnGenerateRowUObject__DelegateSignature(class UObject* Item);
};
// Class UMG.ListView
// 0x0040 (0x0168 - 0x0128)
class UListView : public UTableViewBase
{
public:
float ItemHeight; // 0x0128(0x0004) (Edit, ZeroConstructor, IsPlainOldData)
unsigned char UnknownData00[0x4]; // 0x012C(0x0004) MISSED OFFSET
TArray<class UObject*> Items; // 0x0130(0x0010) (Edit, BlueprintVisible, ZeroConstructor)
TEnumAsByte<ESelectionMode> SelectionMode; // 0x0140(0x0001) (Edit, ZeroConstructor, IsPlainOldData)
unsigned char UnknownData01[0x7]; // 0x0141(0x0007) MISSED OFFSET
struct FScriptDelegate OnGenerateRowEvent; // 0x0148(0x0014) (Edit, ZeroConstructor, InstancedReference)
unsigned char UnknownData02[0x10]; // 0x0158(0x0010) MISSED OFFSET
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("Class UMG.ListView");
return ptr;
}
};
// Class UMG.TileView
// 0x0040 (0x0168 - 0x0128)
class UTileView : public UTableViewBase
{
public:
float ItemWidth; // 0x0128(0x0004) (Edit, ZeroConstructor, IsPlainOldData)
float ItemHeight; // 0x012C(0x0004) (Edit, ZeroConstructor, IsPlainOldData)
TArray<class UObject*> Items; // 0x0130(0x0010) (Edit, BlueprintVisible, ZeroConstructor)
TEnumAsByte<ESelectionMode> SelectionMode; // 0x0140(0x0001) (Edit, ZeroConstructor, IsPlainOldData)
unsigned char UnknownData00[0x7]; // 0x0141(0x0007) MISSED OFFSET
struct FScriptDelegate OnGenerateTileEvent; // 0x0148(0x0014) (Edit, ZeroConstructor, InstancedReference)
unsigned char UnknownData01[0x10]; // 0x0158(0x0010) MISSED OFFSET
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("Class UMG.TileView");
return ptr;
}
void SetItemWidth(float Width);
void SetItemHeight(float Height);
void RequestListRefresh();
};
// Class UMG.MultiLineEditableText
// 0x02F0 (0x0440 - 0x0150)
class UMultiLineEditableText : public UTextLayoutWidget
{
public:
struct FText Text; // 0x0150(0x0018) (Edit)
struct FText HintText; // 0x0168(0x0018) (Edit)
struct FScriptDelegate HintTextDelegate; // 0x0180(0x0014) (ZeroConstructor, InstancedReference)
struct FTextBlockStyle WidgetStyle; // 0x0190(0x0208) (Edit, BlueprintVisible)
bool bIsReadOnly; // 0x0398(0x0001) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
unsigned char UnknownData00[0x7]; // 0x0399(0x0007) MISSED OFFSET
struct FSlateFontInfo Font; // 0x03A0(0x0068) (Deprecated)
bool AllowContextMenu; // 0x0408(0x0001) (Edit, ZeroConstructor, IsPlainOldData)
unsigned char UnknownData01[0x7]; // 0x0409(0x0007) MISSED OFFSET
struct FScriptMulticastDelegate OnTextChanged; // 0x0410(0x0010) (ZeroConstructor, InstancedReference, BlueprintAssignable)
struct FScriptMulticastDelegate OnTextCommitted; // 0x0420(0x0010) (ZeroConstructor, InstancedReference, BlueprintAssignable)
unsigned char UnknownData02[0x10]; // 0x0430(0x0010) MISSED OFFSET
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("Class UMG.MultiLineEditableText");
return ptr;
}
void SetText(const struct FText& InText);
void SetIsReadOnly(bool bReadOnly);
void OnMultiLineEditableTextCommittedEvent__DelegateSignature(const struct FText& Text, TEnumAsByte<ETextCommit> CommitMethod);
void OnMultiLineEditableTextChangedEvent__DelegateSignature(const struct FText& Text);
struct FText GetText();
};
// Class UMG.MultiLineEditableTextBox
// 0x0B90 (0x0CE0 - 0x0150)
class UMultiLineEditableTextBox : public UTextLayoutWidget
{
public:
struct FText Text; // 0x0150(0x0018) (Edit)
struct FText HintText; // 0x0168(0x0018) (Edit)
struct FScriptDelegate HintTextDelegate; // 0x0180(0x0014) (ZeroConstructor, InstancedReference)
struct FEditableTextBoxStyle WidgetStyle; // 0x0190(0x0870) (Edit, BlueprintVisible)
struct FTextBlockStyle TextStyle; // 0x0A00(0x0208) (Edit, BlueprintVisible)
bool bIsReadOnly; // 0x0C08(0x0001) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
bool AllowContextMenu; // 0x0C09(0x0001) (Edit, ZeroConstructor, IsPlainOldData)
unsigned char UnknownData00[0x6]; // 0x0C0A(0x0006) MISSED OFFSET
class USlateWidgetStyleAsset* Style; // 0x0C10(0x0008) (ZeroConstructor, Deprecated, IsPlainOldData)
struct FSlateFontInfo Font; // 0x0C18(0x0068) (Deprecated)
struct FLinearColor ForegroundColor; // 0x0C80(0x0010) (Deprecated, IsPlainOldData)
struct FLinearColor BackgroundColor; // 0x0C90(0x0010) (Deprecated, IsPlainOldData)
struct FLinearColor ReadOnlyForegroundColor; // 0x0CA0(0x0010) (Deprecated, IsPlainOldData)
struct FScriptMulticastDelegate OnTextChanged; // 0x0CB0(0x0010) (ZeroConstructor, InstancedReference, BlueprintAssignable)
struct FScriptMulticastDelegate OnTextCommitted; // 0x0CC0(0x0010) (ZeroConstructor, InstancedReference, BlueprintAssignable)
unsigned char UnknownData01[0x10]; // 0x0CD0(0x0010) MISSED OFFSET
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("Class UMG.MultiLineEditableTextBox");
return ptr;
}
void SetText(const struct FText& InText);
void SetIsReadOnly(bool bReadOnly);
void SetError(const struct FText& InError);
void OnMultiLineEditableTextBoxCommittedEvent__DelegateSignature(const struct FText& Text, TEnumAsByte<ETextCommit> CommitMethod);
void OnMultiLineEditableTextBoxChangedEvent__DelegateSignature(const struct FText& Text);
struct FText GetText();
};
// Class UMG.RichTextBlock
// 0x02C8 (0x0418 - 0x0150)
class URichTextBlock : public UTextLayoutWidget
{
public:
struct FText Text; // 0x0150(0x0018) (Edit)
struct FScriptDelegate TextDelegate; // 0x0168(0x0014) (ZeroConstructor, InstancedReference)
struct FSlateFontInfo Font; // 0x0178(0x0068) (Edit, BlueprintVisible, BlueprintReadOnly)
struct FLinearColor Color; // 0x01E0(0x0010) (Edit, BlueprintVisible, BlueprintReadOnly, IsPlainOldData)
TArray<class URichTextBlockDecorator*> Decorators; // 0x01F0(0x0010) (Edit, ExportObject, ZeroConstructor)
unsigned char UnknownData00[0x218]; // 0x0200(0x0218) MISSED OFFSET
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("Class UMG.RichTextBlock");
return ptr;
}
};
// Class UMG.TextBlock
// 0x0108 (0x0258 - 0x0150)
class UTextBlock : public UTextLayoutWidget
{
public:
struct FText Text; // 0x0150(0x0018) (Edit)
struct FScriptDelegate TextDelegate; // 0x0168(0x0014) (ZeroConstructor, InstancedReference)
struct FSlateColor ColorAndOpacity; // 0x0178(0x0028) (Edit, BlueprintVisible, BlueprintReadOnly)
struct FScriptDelegate ColorAndOpacityDelegate; // 0x01A0(0x0014) (ZeroConstructor, InstancedReference)
struct FSlateFontInfo Font; // 0x01B0(0x0068) (Edit, BlueprintVisible, BlueprintReadOnly)
struct FVector2D ShadowOffset; // 0x0218(0x0008) (Edit, BlueprintVisible, BlueprintReadOnly, IsPlainOldData)
struct FLinearColor ShadowColorAndOpacity; // 0x0220(0x0010) (Edit, BlueprintVisible, BlueprintReadOnly, IsPlainOldData)
struct FScriptDelegate ShadowColorAndOpacityDelegate; // 0x0230(0x0014) (ZeroConstructor, InstancedReference)
float MinDesiredWidth; // 0x0240(0x0004) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
bool bWrapWithInvalidationPanel; // 0x0244(0x0001) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
unsigned char UnknownData00[0x13]; // 0x0245(0x0013) MISSED OFFSET
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("Class UMG.TextBlock");
return ptr;
}
void SetText(const struct FText& InText);
void SetShadowOffset(const struct FVector2D& InShadowOffset);
void SetShadowColorAndOpacity(const struct FLinearColor& InShadowColorAndOpacity);
void SetOpacity(float InOpacity);
void SetMinDesiredWidth(float InMinDesiredWidth);
void SetJustification(TEnumAsByte<ETextJustify> InJustification);
void SetFont(const struct FSlateFontInfo& InFontInfo);
void SetColorAndOpacity(const struct FSlateColor& InColorAndOpacity);
struct FText GetText();
};
// Class UMG.Throbber
// 0x00B0 (0x01D8 - 0x0128)
class UThrobber : public UWidget
{
public:
int NumberOfPieces; // 0x0128(0x0004) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
bool bAnimateHorizontally; // 0x012C(0x0001) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
bool bAnimateVertically; // 0x012D(0x0001) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
bool bAnimateOpacity; // 0x012E(0x0001) (Edit, BlueprintVisible, BlueprintReadOnly, ZeroConstructor, IsPlainOldData)
unsigned char UnknownData00[0x1]; // 0x012F(0x0001) MISSED OFFSET
class USlateBrushAsset* PieceImage; // 0x0130(0x0008) (ZeroConstructor, Deprecated, IsPlainOldData)
struct FSlateBrush Image; // 0x0138(0x0090) (Edit, BlueprintVisible, BlueprintReadOnly)
unsigned char UnknownData01[0x10]; // 0x01C8(0x0010) MISSED OFFSET
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("Class UMG.Throbber");
return ptr;
}
void SetNumberOfPieces(int InNumberOfPieces);
void SetAnimateVertically(bool bInAnimateVertically);
void SetAnimateOpacity(bool bInAnimateOpacity);
void SetAnimateHorizontally(bool bInAnimateHorizontally);
};
// Class UMG.WidgetAnimation
// 0x0040 (0x0370 - 0x0330)
class UWidgetAnimation : public UMovieSceneSequence
{
public:
struct FScriptMulticastDelegate OnAnimationStarted; // 0x0330(0x0010) (ZeroConstructor, InstancedReference, BlueprintAssignable)
struct FScriptMulticastDelegate OnAnimationFinished; // 0x0340(0x0010) (ZeroConstructor, InstancedReference, BlueprintAssignable)
class UMovieScene* MovieScene; // 0x0350(0x0008) (ExportObject, ZeroConstructor, InstancedReference, IsPlainOldData)
TArray<struct FWidgetAnimationBinding> AnimationBindings; // 0x0358(0x0010) (ZeroConstructor)
unsigned char UnknownData00[0x8]; // 0x0368(0x0008) MISSED OFFSET
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("Class UMG.WidgetAnimation");
return ptr;
}
float GetStartTime();
float GetEndTime();
};
// Class UMG.WidgetBlueprintLibrary
// 0x0000 (0x0028 - 0x0028)
class UWidgetBlueprintLibrary : public UBlueprintFunctionLibrary
{
public:
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("Class UMG.WidgetBlueprintLibrary");
return ptr;
}
struct FEventReply STATIC_UnlockMouse(struct FEventReply* Reply);
struct FEventReply STATIC_Unhandled();
struct FEventReply STATIC_SetUserFocus(class UWidget* FocusWidget, bool bInAllUsers, struct FEventReply* Reply);
struct FEventReply STATIC_SetMousePosition(const struct FVector2D& NewMousePosition, struct FEventReply* Reply);
void STATIC_SetInputMode_UIOnlyEx(class APlayerController* Target, class UWidget* InWidgetToFocus, EMouseLockMode InMouseLockMode);
void STATIC_SetInputMode_UIOnly(class APlayerController* Target, class UWidget* InWidgetToFocus, bool bLockMouseToViewport);
void STATIC_SetInputMode_GameOnly(class APlayerController* Target);
void STATIC_SetInputMode_GameAndUIEx(class APlayerController* Target, class UWidget* InWidgetToFocus, EMouseLockMode InMouseLockMode, bool bHideCursorDuringCapture);
void STATIC_SetInputMode_GameAndUI(class APlayerController* Target, class UWidget* InWidgetToFocus, bool bLockMouseToViewport, bool bHideCursorDuringCapture);
bool STATIC_SetHardwareCursor(class UObject* WorldContextObject, TEnumAsByte<EMouseCursor> CursorShape, const struct FName& CursorName, const struct FVector2D& HotSpot);
void STATIC_SetFocusToGameViewport();
void STATIC_SetBrushResourceToTexture(class UTexture2D* Texture, struct FSlateBrush* Brush);
void STATIC_SetBrushResourceToMaterial(class UMaterialInterface* Material, struct FSlateBrush* Brush);
struct FEventReply STATIC_ReleaseMouseCapture(struct FEventReply* Reply);
struct FEventReply STATIC_ReleaseJoystickCapture(bool bInAllJoysticks, struct FEventReply* Reply);
struct FSlateBrush STATIC_NoResourceBrush();
struct FSlateBrush STATIC_MakeBrushFromTexture(class UTexture2D* Texture, int Width, int Height);
struct FSlateBrush STATIC_MakeBrushFromMaterial(class UMaterialInterface* Material, int Width, int Height);
struct FSlateBrush STATIC_MakeBrushFromAsset(class USlateBrushAsset* BrushAsset);
struct FEventReply STATIC_LockMouse(class UWidget* CapturingWidget, struct FEventReply* Reply);
bool STATIC_IsDragDropping();
struct FEventReply STATIC_Handled();
void STATIC_GetSafeZonePadding(class UObject* WorldContextObject, struct FVector2D* SafePadding, struct FVector2D* SafePaddingScale, struct FVector2D* SpillOverPadding);
struct FKeyEvent STATIC_GetKeyEventFromAnalogInputEvent(const struct FAnalogInputEvent& Event);
struct FInputEvent STATIC_GetInputEventFromPointerEvent(const struct FPointerEvent& Event);
struct FInputEvent STATIC_GetInputEventFromNavigationEvent(const struct FNavigationEvent& Event);
struct FInputEvent STATIC_GetInputEventFromKeyEvent(const struct FKeyEvent& Event);
struct FInputEvent STATIC_GetInputEventFromControllerEvent(const struct FControllerEvent& Event);
struct FInputEvent STATIC_GetInputEventFromCharacterEvent(const struct FCharacterEvent& Event);
class UMaterialInstanceDynamic* STATIC_GetDynamicMaterial(struct FSlateBrush* Brush);
class UDragDropOperation* STATIC_GetDragDroppingContent();
class UTexture2D* STATIC_GetBrushResourceAsTexture2D(struct FSlateBrush* Brush);
class UMaterialInterface* STATIC_GetBrushResourceAsMaterial(struct FSlateBrush* Brush);
class UObject* STATIC_GetBrushResource(struct FSlateBrush* Brush);
void STATIC_GetAllWidgetsWithInterface(class UObject* WorldContextObject, class UClass* Interface, bool TopLevelOnly, TArray<class UUserWidget*>* FoundWidgets);
void STATIC_GetAllWidgetsOfClass(class UObject* WorldContextObject, class UClass* WidgetClass, bool TopLevelOnly, TArray<class UUserWidget*>* FoundWidgets);
struct FEventReply STATIC_EndDragDrop(struct FEventReply* Reply);
void STATIC_DrawTextFormatted(const struct FText& Text, const struct FVector2D& Position, class UFont* Font, int FontSize, const struct FName& FontTypeFace, const struct FLinearColor& Tint, struct FPaintContext* Context);
void STATIC_DrawText(const struct FString& inString, const struct FVector2D& Position, const struct FLinearColor& Tint, struct FPaintContext* Context);
void STATIC_DrawLines(TArray<struct FVector2D> Points, const struct FLinearColor& Tint, bool bAntiAlias, struct FPaintContext* Context);
void STATIC_DrawLine(const struct FVector2D& PositionA, const struct FVector2D& PositionB, const struct FLinearColor& Tint, bool bAntiAlias, struct FPaintContext* Context);
void STATIC_DrawBox(const struct FVector2D& Position, const struct FVector2D& Size, class USlateBrushAsset* Brush, const struct FLinearColor& Tint, struct FPaintContext* Context);
void STATIC_DismissAllMenus();
struct FEventReply STATIC_DetectDragIfPressed(const struct FPointerEvent& PointerEvent, class UWidget* WidgetDetectingDrag, const struct FKey& DragKey);
struct FEventReply STATIC_DetectDrag(class UWidget* WidgetDetectingDrag, const struct FKey& DragKey, struct FEventReply* Reply);
class UDragDropOperation* STATIC_CreateDragDropOperation(class UClass* OperationClass);
class UUserWidget* STATIC_Create(class UObject* WorldContextObject, class UClass* WidgetType, class APlayerController* OwningPlayer);
struct FEventReply STATIC_ClearUserFocus(bool bInAllUsers, struct FEventReply* Reply);
struct FEventReply STATIC_CaptureMouse(class UWidget* CapturingWidget, struct FEventReply* Reply);
struct FEventReply STATIC_CaptureJoystick(class UWidget* CapturingWidget, bool bInAllJoysticks, struct FEventReply* Reply);
void STATIC_CancelDragDrop();
};
// Class UMG.WidgetComponent
// 0x0130 (0x0A80 - 0x0950)
class UWidgetComponent : public UMeshComponent
{
public:
EWidgetSpace Space; // 0x0950(0x0001) (Edit, ZeroConstructor, IsPlainOldData)
EWidgetTimingPolicy TimingPolicy; // 0x0951(0x0001) (Edit, ZeroConstructor, IsPlainOldData)
unsigned char UnknownData00[0x6]; // 0x0952(0x0006) MISSED OFFSET
class UClass* WidgetClass; // 0x0958(0x0008) (Edit, ZeroConstructor, IsPlainOldData)
struct FIntPoint DrawSize; // 0x0960(0x0008) (Edit, IsPlainOldData)
bool bManuallyRedraw; // 0x0968(0x0001) (Edit, ZeroConstructor, IsPlainOldData)
bool bRedrawRequested; // 0x0969(0x0001) (ZeroConstructor, IsPlainOldData)
unsigned char UnknownData01[0x2]; // 0x096A(0x0002) MISSED OFFSET
float RedrawTime; // 0x096C(0x0004) (Edit, ZeroConstructor, IsPlainOldData)
unsigned char UnknownData02[0x8]; // 0x0970(0x0008) MISSED OFFSET
struct FIntPoint CurrentDrawSize; // 0x0978(0x0008) (IsPlainOldData)
bool bDrawAtDesiredSize; // 0x0980(0x0001) (Edit, ZeroConstructor, IsPlainOldData)
unsigned char UnknownData03[0x3]; // 0x0981(0x0003) MISSED OFFSET
struct FVector2D Pivot; // 0x0984(0x0008) (Edit, IsPlainOldData)
bool bReceiveHardwareInput; // 0x098C(0x0001) (Edit, ZeroConstructor, IsPlainOldData)
bool bWindowFocusable; // 0x098D(0x0001) (Edit, ZeroConstructor, IsPlainOldData)
unsigned char UnknownData04[0x2]; // 0x098E(0x0002) MISSED OFFSET
class ULocalPlayer* OwnerPlayer; // 0x0990(0x0008) (ZeroConstructor, IsPlainOldData)
struct FLinearColor BackgroundColor; // 0x0998(0x0010) (Edit, IsPlainOldData)
struct FLinearColor TintColorAndOpacity; // 0x09A8(0x0010) (Edit, IsPlainOldData)
float OpacityFromTexture; // 0x09B8(0x0004) (Edit, ZeroConstructor, IsPlainOldData)
EWidgetBlendMode BlendMode; // 0x09BC(0x0001) (Edit, ZeroConstructor, IsPlainOldData)
bool bIsTwoSided; // 0x09BD(0x0001) (Edit, ZeroConstructor, IsPlainOldData)
bool TickWhenOffscreen; // 0x09BE(0x0001) (Edit, ZeroConstructor, IsPlainOldData)
unsigned char UnknownData05[0x1]; // 0x09BF(0x0001) MISSED OFFSET
class UUserWidget* Widget; // 0x09C0(0x0008) (ExportObject, ZeroConstructor, Transient, InstancedReference, DuplicateTransient, IsPlainOldData)
unsigned char UnknownData06[0x20]; // 0x09C8(0x0020) MISSED OFFSET
class UBodySetup* BodySetup; // 0x09E8(0x0008) (ZeroConstructor, Transient, DuplicateTransient, IsPlainOldData)
class UMaterialInterface* TranslucentMaterial; // 0x09F0(0x0008) (ZeroConstructor, IsPlainOldData)
class UMaterialInterface* TranslucentMaterial_OneSided; // 0x09F8(0x0008) (ZeroConstructor, IsPlainOldData)
class UMaterialInterface* OpaqueMaterial; // 0x0A00(0x0008) (ZeroConstructor, IsPlainOldData)
class UMaterialInterface* OpaqueMaterial_OneSided; // 0x0A08(0x0008) (ZeroConstructor, IsPlainOldData)
class UMaterialInterface* MaskedMaterial; // 0x0A10(0x0008) (ZeroConstructor, IsPlainOldData)
class UMaterialInterface* MaskedMaterial_OneSided; // 0x0A18(0x0008) (ZeroConstructor, IsPlainOldData)
class UTextureRenderTarget2D* RenderTarget; // 0x0A20(0x0008) (ZeroConstructor, Transient, DuplicateTransient, IsPlainOldData)
class UMaterialInstanceDynamic* MaterialInstance; // 0x0A28(0x0008) (ZeroConstructor, Transient, DuplicateTransient, IsPlainOldData)
bool bAddedToScreen; // 0x0A30(0x0001) (ZeroConstructor, Transient, DuplicateTransient, IsPlainOldData)
bool bEditTimeUsable; // 0x0A31(0x0001) (ZeroConstructor, IsPlainOldData)
unsigned char UnknownData07[0x6]; // 0x0A32(0x0006) MISSED OFFSET
struct FName SharedLayerName; // 0x0A38(0x0008) (Edit, ZeroConstructor, DisableEditOnInstance, IsPlainOldData)
int LayerZOrder; // 0x0A40(0x0004) (Edit, ZeroConstructor, DisableEditOnInstance, IsPlainOldData)
EWidgetGeometryMode GeometryMode; // 0x0A44(0x0001) (Edit, ZeroConstructor, IsPlainOldData)
unsigned char UnknownData08[0x3]; // 0x0A45(0x0003) MISSED OFFSET
float CylinderArcAngle; // 0x0A48(0x0004) (Edit, ZeroConstructor, IsPlainOldData)
unsigned char UnknownData09[0x34]; // 0x0A4C(0x0034) MISSED OFFSET
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("Class UMG.WidgetComponent");
return ptr;
}
void SetWidget(class UUserWidget* Widget);
void SetOwnerPlayer(class ULocalPlayer* LocalPlayer);
void SetDrawSize(const struct FVector2D& Size);
void SetBackgroundColor(const struct FLinearColor& NewBackgroundColor);
void RequestRedraw();
class UUserWidget* GetUserWidgetObject();
class UTextureRenderTarget2D* GetRenderTarget();
class ULocalPlayer* GetOwnerPlayer();
class UMaterialInstanceDynamic* GetMaterialInstance();
struct FVector2D GetDrawSize();
};
// Class UMG.WidgetInteractionComponent
// 0x01F0 (0x05E0 - 0x03F0)
class UWidgetInteractionComponent : public USceneComponent
{
public:
struct FScriptMulticastDelegate OnHoveredWidgetChanged; // 0x03F0(0x0010) (ZeroConstructor, InstancedReference, BlueprintAssignable)
unsigned char UnknownData00[0x10]; // 0x0400(0x0010) MISSED OFFSET
int VirtualUserIndex; // 0x0410(0x0004) (Edit, BlueprintVisible, ZeroConstructor, IsPlainOldData)
float PointerIndex; // 0x0414(0x0004) (Edit, BlueprintVisible, ZeroConstructor, IsPlainOldData)
TEnumAsByte<ECollisionChannel> TraceChannel; // 0x0418(0x0001) (Edit, BlueprintVisible, ZeroConstructor, IsPlainOldData)
unsigned char UnknownData01[0x3]; // 0x0419(0x0003) MISSED OFFSET
float InteractionDistance; // 0x041C(0x0004) (Edit, BlueprintVisible, ZeroConstructor, IsPlainOldData)
EWidgetInteractionSource InteractionSource; // 0x0420(0x0001) (Edit, BlueprintVisible, ZeroConstructor, IsPlainOldData)
bool bEnableHitTesting; // 0x0421(0x0001) (Edit, BlueprintVisible, ZeroConstructor, IsPlainOldData)
bool bShowDebug; // 0x0422(0x0001) (Edit, BlueprintVisible, ZeroConstructor, IsPlainOldData)
unsigned char UnknownData02[0x1]; // 0x0423(0x0001) MISSED OFFSET
struct FLinearColor DebugColor; // 0x0424(0x0010) (Edit, BlueprintVisible, IsPlainOldData)
unsigned char UnknownData03[0x7C]; // 0x0434(0x007C) MISSED OFFSET
struct FHitResult CustomHitResult; // 0x04B0(0x0088) (Transient, IsPlainOldData)
struct FVector2D LocalHitLocation; // 0x0538(0x0008) (Transient, IsPlainOldData)
struct FVector2D LastLocalHitLocation; // 0x0540(0x0008) (Transient, IsPlainOldData)
class UWidgetComponent* HoveredWidgetComponent; // 0x0548(0x0008) (ExportObject, ZeroConstructor, Transient, InstancedReference, IsPlainOldData)
struct FHitResult LastHitResult; // 0x0550(0x0088) (Transient, IsPlainOldData)
bool bIsHoveredWidgetInteractable; // 0x05D8(0x0001) (ZeroConstructor, Transient, IsPlainOldData)
bool bIsHoveredWidgetFocusable; // 0x05D9(0x0001) (ZeroConstructor, Transient, IsPlainOldData)
bool bIsHoveredWidgetHitTestVisible; // 0x05DA(0x0001) (ZeroConstructor, Transient, IsPlainOldData)
unsigned char UnknownData04[0x5]; // 0x05DB(0x0005) MISSED OFFSET
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("Class UMG.WidgetInteractionComponent");
return ptr;
}
void SetCustomHitResult(const struct FHitResult& HitResult);
bool SendKeyChar(const struct FString& Characters, bool bRepeat);
void ScrollWheel(float ScrollDelta);
void ReleasePointerKey(const struct FKey& Key);
bool ReleaseKey(const struct FKey& Key);
void PressPointerKey(const struct FKey& Key);
bool PressKey(const struct FKey& Key, bool bRepeat);
bool PressAndReleaseKey(const struct FKey& Key);
bool IsOverInteractableWidget();
bool IsOverHitTestVisibleWidget();
bool IsOverFocusableWidget();
struct FHitResult GetLastHitResult();
class UWidgetComponent* GetHoveredWidgetComponent();
struct FVector2D Get2DHitLocation();
};
// Class UMG.WidgetLayoutLibrary
// 0x0000 (0x0028 - 0x0028)
class UWidgetLayoutLibrary : public UBlueprintFunctionLibrary
{
public:
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("Class UMG.WidgetLayoutLibrary");
return ptr;
}
class UVerticalBoxSlot* STATIC_SlotAsVerticalBoxSlot(class UWidget* Widget);
class UUniformGridSlot* STATIC_SlotAsUniformGridSlot(class UWidget* Widget);
class UOverlaySlot* STATIC_SlotAsOverlaySlot(class UWidget* Widget);
class UHorizontalBoxSlot* STATIC_SlotAsHorizontalBoxSlot(class UWidget* Widget);
class UGridSlot* STATIC_SlotAsGridSlot(class UWidget* Widget);
class UCanvasPanelSlot* STATIC_SlotAsCanvasSlot(class UWidget* Widget);
class UBorderSlot* STATIC_SlotAsBorderSlot(class UWidget* Widget);
void STATIC_RemoveAllWidgets(class UObject* WorldContextObject);
bool STATIC_ProjectWorldLocationToWidgetPosition(class APlayerController* PlayerController, const struct FVector& WorldLocation, struct FVector2D* ScreenPosition);
struct FVector2D STATIC_GetViewportSize(class UObject* WorldContextObject);
float STATIC_GetViewportScale(class UObject* WorldContextObject);
bool STATIC_GetMousePositionScaledByDPI(class APlayerController* Player, float* LocationX, float* LocationY);
};
// Class UMG.WidgetNavigation
// 0x0090 (0x00B8 - 0x0028)
class UWidgetNavigation : public UObject
{
public:
struct FWidgetNavigationData Up; // 0x0028(0x0018) (Edit, BlueprintVisible, BlueprintReadOnly)
struct FWidgetNavigationData Down; // 0x0040(0x0018) (Edit, BlueprintVisible, BlueprintReadOnly)
struct FWidgetNavigationData Left; // 0x0058(0x0018) (Edit, BlueprintVisible, BlueprintReadOnly)
struct FWidgetNavigationData Right; // 0x0070(0x0018) (Edit, BlueprintVisible, BlueprintReadOnly)
struct FWidgetNavigationData Next; // 0x0088(0x0018) (Edit, BlueprintVisible, BlueprintReadOnly)
struct FWidgetNavigationData Previous; // 0x00A0(0x0018) (Edit, BlueprintVisible, BlueprintReadOnly)
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("Class UMG.WidgetNavigation");
return ptr;
}
};
// Class UMG.WidgetTree
// 0x0018 (0x0040 - 0x0028)
class UWidgetTree : public UObject
{
public:
class UWidget* RootWidget; // 0x0028(0x0008) (ExportObject, ZeroConstructor, InstancedReference, IsPlainOldData)
TArray<class UWidget*> AllWidgets; // 0x0030(0x0010) (ExportObject, ZeroConstructor)
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("Class UMG.WidgetTree");
return ptr;
}
};
}
#ifdef _MSC_VER
#pragma pack(pop)
#endif
| [
"915188949@qq.com"
] | 915188949@qq.com |
678408fa36a52ee2ba16f10f8fdf57fb3049c8fb | ba26fe12fefceecd5f5f50962889fcacd669604c | /cxxreflect/metadata/relationships.hpp | d640c02bb57551bd56a72a9763ad1460458c1f7b | [
"BSL-1.0"
] | permissive | dbremner/cxxreflect | 4fda46ddb362e98a1ac48135d50884f8c820b754 | bbf1649b00755f8463e4a73b28dec4cd5b609493 | refs/heads/master | 2021-01-10T11:54:57.634465 | 2013-01-02T06:45:18 | 2013-01-02T06:45:18 | 46,352,008 | 6 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 4,133 | hpp |
// Copyright James P. McNellis 2011 - 2013. //
// Distributed under the Boost Software License, Version 1.0. //
// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) //
#ifndef CXXREFLECT_METADATA_RELATIONSHIPS_HPP_
#define CXXREFLECT_METADATA_RELATIONSHIPS_HPP_
#include "cxxreflect/metadata/database.hpp"
namespace cxxreflect { namespace metadata {
/// \defgroup cxxreflect_metadata_relationships Metadata -> Relationships
///
/// Utility functions that map between tables in a metadata database
///
/// These functions compute the targets of 1:1 and 1:N relationships in a metadata database.
/// Some relationships are trivial to compute, for example, getting the range of fields defined
/// by a given type definition. These trivial relationships are defined directly in the row
/// types: in the case of the type -> field example, they are defined in the `type_def_row`
/// class.
///
/// The relationships mapped in this set of functions here are the nontrivial relationships.
/// Each of these queries requires either a binary search over a metadata table to find a row
/// or range of rows, or a thunk through a mapping table.
///
/// We could define these as members of the row classes, but it is simpler to define them all
/// here so they are defined in one place, and to distinguish them from the less expensive-to-
/// call trivial relationships described before.
///
/// For each 1:N relationship, there are three functions:
///
/// * `find_{relationship}_range`: Computes the range of target values that map to the
/// parent (in effect, it computes an `equal_range`).
///
/// * `begin_{relationship}`: Equivalent to `find_{relationship}_range(parent).first`.
///
/// * `end_{relationship}`: Equivalent to `find_{relationship}_range(parent).second`.
///
/// Because these sets of three functions always have the same meaning, we do not document them
/// individually.
///
/// @{
auto find_owner_of_event (event_token const& element) -> type_def_row;
auto find_owner_of_method_def(method_def_token const& element) -> type_def_row;
auto find_owner_of_field (field_token const& element) -> type_def_row;
auto find_owner_of_property (property_token const& element) -> type_def_row;
auto find_owner_of_param (param_token const& element) -> method_def_row;
auto find_constant (has_constant_token const& parent) -> constant_row;
auto find_field_layout (field_token const& parent) -> field_layout_row;
auto find_custom_attributes (has_custom_attribute_token const& parent) -> custom_attribute_row_range;
auto find_events (type_def_token const& parent) -> event_row_range;
auto find_fields (type_def_token const& parent) -> field_row_range;
auto find_generic_params (type_or_method_def_token const& parent) -> generic_param_row_range;
auto find_generic_param (type_or_method_def_token const& parent, core::size_type index) -> generic_param_row;
auto find_generic_param_constraints(generic_param_token const& parent) -> generic_param_constraint_row_range;
auto find_interface_impls (type_def_token const& parent) -> interface_impl_row_range;
auto find_method_defs (type_def_token const& parent) -> method_def_row_range;
auto find_method_impls (type_def_token const& parent) -> method_impl_row_range;
auto find_method_semantics (has_semantics_token const& parent) -> method_semantics_row_range;
auto find_properties (type_def_token const& parent) -> property_row_range;
/// @}
} }
#endif
| [
"JamesMcNellis@localhost"
] | JamesMcNellis@localhost |
aeec52c24ce266864dabeea564db680a9b88bee9 | 7d428c0c6dd7634fbf4769575f8344ca353b2e48 | /src/data/FileMetaDataManager.cpp | 2a9c4c7e24f0af5582f38920ec784ab58abccdc7 | [
"Apache-2.0"
] | permissive | jimhuaang/qsfs-boost | ce63089248d9a0fc1ecf5f19645403d9fceeda34 | 67b69a4e376f5dc7b2744cd5af1d0655d6c4d981 | refs/heads/master | 2021-09-10T11:35:51.179932 | 2018-03-25T19:01:14 | 2018-03-25T19:15:26 | 113,832,991 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 10,818 | cpp | // +-------------------------------------------------------------------------
// | Copyright (C) 2017 Yunify, Inc.
// +-------------------------------------------------------------------------
// | Licensed under the Apache License, Version 2.0 (the "License");
// | You may not use this work except in compliance with the License.
// | You may obtain a copy of the License in the LICENSE file, or at:
// |
// | http://www.apache.org/licenses/LICENSE-2.0
// |
// | Unless required by applicable law or agreed to in writing, software
// | distributed under the License is distributed on an "AS IS" BASIS,
// | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// | See the License for the specific language governing permissions and
// | limitations under the License.
// +-------------------------------------------------------------------------
#include "data/FileMetaDataManager.h"
#include <string>
#include <utility>
#include <vector>
#include "boost/exception/to_string.hpp"
#include "boost/foreach.hpp"
#include "boost/shared_ptr.hpp"
#include "boost/thread/locks.hpp"
#include "base/LogMacros.h"
#include "base/Size.h"
#include "base/StringUtils.h"
#include "base/Utils.h"
#include "data/DirectoryTree.h"
#include "configure/Options.h"
namespace QS {
namespace Data {
using boost::lock_guard;
using boost::recursive_mutex;
using boost::shared_ptr;
using boost::to_string;
using QS::StringUtils::FormatPath;
using QS::Utils::GetDirName;
using QS::Utils::IsRootDirectory;
using std::pair;
using std::string;
// --------------------------------------------------------------------------
MetaDataListConstIterator FileMetaDataManager::Get(
const string &filePath) const {
lock_guard<recursive_mutex> lock(m_mutex);
return const_cast<FileMetaDataManager *>(this)->Get(filePath);
}
// --------------------------------------------------------------------------
MetaDataListIterator FileMetaDataManager::Get(const string &filePath) {
lock_guard<recursive_mutex> lock(m_mutex);
MetaDataListIterator pos = m_metaDatas.end();
FileIdToMetaDataMapIterator it = m_map.find(filePath);
if (it != m_map.end()) {
pos = UnguardedMakeMetaDataMostRecentlyUsed(it->second);
} else {
DebugInfo("File not exist " + FormatPath(filePath));
}
return pos;
}
// --------------------------------------------------------------------------
MetaDataListConstIterator FileMetaDataManager::Begin() const {
lock_guard<recursive_mutex> lock(m_mutex);
return m_metaDatas.begin();
}
// --------------------------------------------------------------------------
MetaDataListIterator FileMetaDataManager::Begin() {
lock_guard<recursive_mutex> lock(m_mutex);
return m_metaDatas.begin();
}
// --------------------------------------------------------------------------
MetaDataListConstIterator FileMetaDataManager::End() const {
lock_guard<recursive_mutex> lock(m_mutex);
return m_metaDatas.end();
}
// --------------------------------------------------------------------------
MetaDataListIterator FileMetaDataManager::End() {
lock_guard<recursive_mutex> lock(m_mutex);
return m_metaDatas.end();
}
// --------------------------------------------------------------------------
bool FileMetaDataManager::Has(const string &filePath) const {
lock_guard<recursive_mutex> lock(m_mutex);
return this->Get(filePath) != m_metaDatas.end();
}
// --------------------------------------------------------------------------
bool FileMetaDataManager::HasFreeSpace(size_t needCount) const {
lock_guard<recursive_mutex> lock(m_mutex);
return m_metaDatas.size() + needCount <= GetMaxCount();
}
// --------------------------------------------------------------------------
MetaDataListIterator FileMetaDataManager::AddNoLock(
const shared_ptr<FileMetaData> &fileMetaData) {
const string &filePath = fileMetaData->GetFilePath();
FileIdToMetaDataMapIterator it = m_map.find(filePath);
if (it == m_map.end()) { // not exist in manager
if (!HasFreeSpaceNoLock(1)) {
bool success = FreeNoLock(1, filePath);
if (!success) {
m_maxCount += static_cast<size_t>(m_maxCount / 5);
Warning("Enlarge max stat to " + to_string(m_maxCount));
}
}
m_metaDatas.push_front(std::make_pair(filePath, fileMetaData));
if (m_metaDatas.begin()->first == filePath) { // insert sucessfully
pair<FileIdToMetaDataMapIterator, bool> res =
m_map.emplace(filePath, m_metaDatas.begin());
if(res.second) {
return m_metaDatas.begin();
} else {
DebugWarning("Fail to add file "+ FormatPath(filePath));
return m_metaDatas.end();
}
} else {
DebugWarning("Fail to add file " + FormatPath(filePath));
return m_metaDatas.end();
}
} else { // exist already, update it
MetaDataListIterator pos =
UnguardedMakeMetaDataMostRecentlyUsed(it->second);
pos->second = fileMetaData;
return pos;
}
}
// --------------------------------------------------------------------------
MetaDataListIterator FileMetaDataManager::Add(
const shared_ptr<FileMetaData> &fileMetaData) {
lock_guard<recursive_mutex> lock(m_mutex);
return AddNoLock(fileMetaData);
}
// --------------------------------------------------------------------------
MetaDataListIterator FileMetaDataManager::Add(
const std::vector<shared_ptr<FileMetaData> > &fileMetaDatas) {
lock_guard<recursive_mutex> lock(m_mutex);
MetaDataListIterator pos = m_metaDatas.end();
BOOST_FOREACH(const shared_ptr<FileMetaData> &meta, fileMetaDatas) {
pos = AddNoLock(meta);
if (pos == m_metaDatas.end()) break; // if fail to add an item
}
return pos;
}
// --------------------------------------------------------------------------
MetaDataListIterator FileMetaDataManager::Erase(const string &filePath) {
lock_guard<recursive_mutex> lock(m_mutex);
MetaDataListIterator next = m_metaDatas.end();
FileIdToMetaDataMapIterator it = m_map.find(filePath);
if (it != m_map.end()) {
next = m_metaDatas.erase(it->second);
m_map.erase(it);
} else {
DebugWarning("File not exist, no remove " + FormatPath(filePath));
}
return next;
}
// --------------------------------------------------------------------------
void FileMetaDataManager::Clear() {
lock_guard<recursive_mutex> lock(m_mutex);
m_map.clear();
m_metaDatas.clear();
}
// --------------------------------------------------------------------------
void FileMetaDataManager::Rename(const string &oldFilePath,
const string &newFilePath) {
if (oldFilePath == newFilePath) {
// Disable following info
// DebugInfo("File exist, no rename" + FormatPath(newFilePath) );
return;
}
lock_guard<recursive_mutex> lock(m_mutex);
if (m_map.find(newFilePath) != m_map.end()) {
DebugWarning("File exist, no rename " +
FormatPath(oldFilePath, newFilePath));
return;
}
FileIdToMetaDataMapIterator it = m_map.find(oldFilePath);
if (it != m_map.end()) {
it->second->first = newFilePath;
it->second->second->m_filePath = newFilePath;
MetaDataListIterator pos =
UnguardedMakeMetaDataMostRecentlyUsed(it->second);
pair<FileIdToMetaDataMapIterator, bool> res =
m_map.emplace(newFilePath, pos);
if (!res.second) {
DebugWarning("Fail to rename " + FormatPath(oldFilePath, newFilePath));
}
m_map.erase(it);
} else {
DebugWarning("File not exist, no rename " + FormatPath(oldFilePath));
}
}
// --------------------------------------------------------------------------
void FileMetaDataManager::SetDirectoryTree(QS::Data::DirectoryTree *tree) {
lock_guard<recursive_mutex> lock(m_mutex);
m_dirTree = tree;
}
// --------------------------------------------------------------------------
MetaDataListIterator FileMetaDataManager::UnguardedMakeMetaDataMostRecentlyUsed(
MetaDataListIterator pos) {
m_metaDatas.splice(m_metaDatas.begin(), m_metaDatas, pos);
// no iterators or references become invalidated, so no need to update m_map.
return m_metaDatas.begin();
}
// --------------------------------------------------------------------------
bool FileMetaDataManager::HasFreeSpaceNoLock(size_t needCount) const {
return m_metaDatas.size() + needCount <= GetMaxCount();
}
// --------------------------------------------------------------------------
bool FileMetaDataManager::FreeNoLock(size_t needCount, string fileUnfreeable) {
if (needCount > GetMaxCount()) {
DebugError("Try to free file meta data manager of " + to_string(needCount) +
" items which surpass the maximum file meta data count (" +
to_string(GetMaxCount()) + "). Do nothing");
return false;
}
if (HasFreeSpaceNoLock(needCount)) {
// DebugInfo("Try to free file meta data manager of " + to_string(needCount)
// + " items while free space is still availabe. Go on");
return true;
}
assert(!m_metaDatas.empty());
size_t freedCount = 0;
// free all in once
MetaDataList::reverse_iterator it = m_metaDatas.rbegin();
while (it !=m_metaDatas.rend() && !HasFreeSpaceNoLock(needCount)) {
string fileId = it->first;
if (IsRootDirectory(fileId)) {
// cannot free root
++it;
continue;
}
if (it->second) {
if (it->second->IsFileOpen() || it->second->IsNeedUpload()) {
++it;
continue;
}
if(fileId[fileId.size() - 1] == '/') { // do not free dir
++it;
continue;
}
if (fileId == fileUnfreeable) {
++it;
continue;
}
if(GetDirName(fileId) == GetDirName(fileUnfreeable)) {
++it;
continue;
}
} else {
DebugWarning("file metadata null" + FormatPath(fileId));
}
DebugInfo("Free file " + FormatPath(fileId));
// Must invoke callback to update directory tree before erasing,
// as directory node depend on the file meta data
if (m_dirTree) {
m_dirTree->Remove(fileId);
}
// Node destructor will inovke FileMetaDataManger::Erase,
// so double checking before earsing file meta
FileIdToMetaDataMapIterator p = m_map.find(fileId);
if(p != m_map.end()) {
m_metaDatas.erase(p->second);
m_map.erase(p);
}
++freedCount;
}
if (HasFreeSpaceNoLock(needCount)) {
return true;
} else {
Warning("Fail to free " + to_string(needCount) +
" items for file " + FormatPath(fileUnfreeable));
return false;
}
}
// --------------------------------------------------------------------------
FileMetaDataManager::FileMetaDataManager() {
m_maxCount = static_cast<size_t>(
QS::Configure::Options::Instance().GetMaxStatCountInK() * QS::Size::K1);
m_dirTree = NULL;
}
} // namespace Data
} // namespace QS
| [
"jimhuang@yunify.com"
] | jimhuang@yunify.com |
5d6e987068b51031b76f2076532bcfae2348cd33 | d8ca1ea0f085ff7b0f62533209e4a1598768f1ba | /vendor/capnproto/c++/src/capnp/compiler/module-loader.c++ | 3fd470aae0ed83789c603e572a2c570b2ac837b9 | [
"MIT",
"BSD-2-Clause"
] | permissive | patrickToca/goq | ff26a365ce09ba21fafcc8b8b83159316d088018 | 7fbfeaa8d5a736252b7862d0d7dbdf5cd352a47f | refs/heads/master | 2021-01-21T01:56:17.274767 | 2015-02-27T20:46:06 | 2015-02-27T20:46:06 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 10,141 | // Copyright (c) 2013-2014 Sandstorm Development Group, Inc. and contributors
// Licensed under the MIT License:
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#include "module-loader.h"
#include "lexer.h"
#include "parser.h"
#include <kj/vector.h>
#include <kj/mutex.h>
#include <kj/debug.h>
#include <kj/io.h>
#include <capnp/message.h>
#include <map>
#include <unistd.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
namespace capnp {
namespace compiler {
namespace {
class MmapDisposer: public kj::ArrayDisposer {
protected:
void disposeImpl(void* firstElement, size_t elementSize, size_t elementCount,
size_t capacity, void (*destroyElement)(void*)) const {
munmap(firstElement, elementSize * elementCount);
}
};
constexpr MmapDisposer mmapDisposer = MmapDisposer();
kj::Array<const char> mmapForRead(kj::StringPtr filename) {
int fd;
// We already established that the file exists, so this should not fail.
KJ_SYSCALL(fd = open(filename.cStr(), O_RDONLY), filename);
kj::AutoCloseFd closer(fd);
struct stat stats;
KJ_SYSCALL(fstat(fd, &stats));
if (S_ISREG(stats.st_mode)) {
if (stats.st_size == 0) {
// mmap()ing zero bytes will fail.
return nullptr;
}
// Regular file. Just mmap() it.
const void* mapping = mmap(NULL, stats.st_size, PROT_READ, MAP_SHARED, fd, 0);
if (mapping == MAP_FAILED) {
KJ_FAIL_SYSCALL("mmap", errno, filename);
}
return kj::Array<const char>(
reinterpret_cast<const char*>(mapping), stats.st_size, mmapDisposer);
} else {
// This could be a stream of some sort, like a pipe. Fall back to read().
// TODO(cleanup): This does a lot of copies. Not sure I care.
kj::Vector<char> data(8192);
char buffer[4096];
for (;;) {
ssize_t n;
KJ_SYSCALL(n = read(fd, buffer, sizeof(buffer)));
if (n == 0) break;
data.addAll(buffer, buffer + n);
}
return data.releaseAsArray();
}
}
static char* canonicalizePath(char* path) {
// Taken from some old C code of mine.
// Preconditions:
// - path has already been determined to be relative, perhaps because the pointer actually points
// into the middle of some larger path string, in which case it must point to the character
// immediately after a '/'.
// Invariants:
// - src points to the beginning of a path component.
// - dst points to the location where the path component should end up, if it is not special.
// - src == path or src[-1] == '/'.
// - dst == path or dst[-1] == '/'.
char* src = path;
char* dst = path;
char* locked = dst; // dst cannot backtrack past this
char* partEnd;
bool hasMore;
for (;;) {
while (*src == '/') {
// Skip duplicate slash.
++src;
}
partEnd = strchr(src, '/');
hasMore = partEnd != NULL;
if (hasMore) {
*partEnd = '\0';
} else {
partEnd = src + strlen(src);
}
if (strcmp(src, ".") == 0) {
// Skip it.
} else if (strcmp(src, "..") == 0) {
if (dst > locked) {
// Backtrack over last path component.
--dst;
while (dst > locked && dst[-1] != '/') --dst;
} else {
locked += 3;
goto copy;
}
} else {
// Copy if needed.
copy:
if (dst < src) {
memmove(dst, src, partEnd - src);
dst += partEnd - src;
} else {
dst = partEnd;
}
*dst++ = '/';
}
if (hasMore) {
src = partEnd + 1;
} else {
// Oops, we have to remove the trailing '/'.
if (dst == path) {
// Oops, there is no trailing '/'. We have to return ".".
strcpy(path, ".");
return path + 1;
} else {
// Remove the trailing '/'. Note that this means that opening the file will work even
// if it is not a directory, where normally it should fail on non-directories when a
// trailing '/' is present. If this is a problem, we need to add some sort of special
// handling for this case where we stat() it separately to check if it is a directory,
// because Ekam findInput will not accept a trailing '/'.
--dst;
*dst = '\0';
return dst;
}
}
}
}
kj::String canonicalizePath(kj::StringPtr path) {
KJ_STACK_ARRAY(char, result, path.size() + 1, 128, 512);
strcpy(result.begin(), path.begin());
char* start = path.startsWith("/") ? result.begin() + 1 : result.begin();
char* end = canonicalizePath(start);
return kj::heapString(result.slice(0, end - result.begin()));
}
kj::String catPath(kj::StringPtr base, kj::StringPtr add) {
if (add.size() > 0 && add[0] == '/') {
return kj::heapString(add);
}
const char* pos = base.end();
while (pos > base.begin() && pos[-1] != '/') {
--pos;
}
return kj::str(base.slice(0, pos - base.begin()), add);
}
} // namespace
class ModuleLoader::Impl {
public:
Impl(GlobalErrorReporter& errorReporter): errorReporter(errorReporter) {}
void addImportPath(kj::String path) {
searchPath.add(kj::heapString(kj::mv(path)));
}
kj::Maybe<Module&> loadModule(kj::StringPtr localName, kj::StringPtr sourceName);
kj::Maybe<Module&> loadModuleFromSearchPath(kj::StringPtr sourceName);
GlobalErrorReporter& getErrorReporter() { return errorReporter; }
private:
GlobalErrorReporter& errorReporter;
kj::Vector<kj::String> searchPath;
std::map<kj::StringPtr, kj::Own<Module>> modules;
};
class ModuleLoader::ModuleImpl final: public Module {
public:
ModuleImpl(ModuleLoader::Impl& loader, kj::String localName, kj::String sourceName)
: loader(loader), localName(kj::mv(localName)), sourceName(kj::mv(sourceName)) {}
kj::StringPtr getLocalName() {
return localName;
}
kj::StringPtr getSourceName() override {
return sourceName;
}
Orphan<ParsedFile> loadContent(Orphanage orphanage) override {
kj::Array<const char> content = mmapForRead(localName);
lineBreaks = nullptr; // In case loadContent() is called multiple times.
lineBreaks = lineBreaksSpace.construct(content);
MallocMessageBuilder lexedBuilder;
auto statements = lexedBuilder.initRoot<LexedStatements>();
lex(content, statements, *this);
auto parsed = orphanage.newOrphan<ParsedFile>();
parseFile(statements.getStatements(), parsed.get(), *this);
return parsed;
}
kj::Maybe<Module&> importRelative(kj::StringPtr importPath) override {
if (importPath.size() > 0 && importPath[0] == '/') {
return loader.loadModuleFromSearchPath(importPath.slice(1));
} else {
return loader.loadModule(catPath(localName, importPath), catPath(sourceName, importPath));
}
}
void addError(uint32_t startByte, uint32_t endByte, kj::StringPtr message) override {
auto& lines = *KJ_REQUIRE_NONNULL(lineBreaks,
"Can't report errors until loadContent() is called.");
loader.getErrorReporter().addError(
localName, lines.toSourcePos(startByte), lines.toSourcePos(endByte), message);
}
bool hadErrors() override {
return loader.getErrorReporter().hadErrors();
}
private:
ModuleLoader::Impl& loader;
kj::String localName;
kj::String sourceName;
kj::SpaceFor<LineBreakTable> lineBreaksSpace;
kj::Maybe<kj::Own<LineBreakTable>> lineBreaks;
};
// =======================================================================================
kj::Maybe<Module&> ModuleLoader::Impl::loadModule(
kj::StringPtr localName, kj::StringPtr sourceName) {
kj::String canonicalLocalName = canonicalizePath(localName);
kj::String canonicalSourceName = canonicalizePath(sourceName);
auto iter = modules.find(canonicalLocalName);
if (iter != modules.end()) {
// Return existing file.
return *iter->second;
}
if (access(canonicalLocalName.cStr(), F_OK) < 0) {
// No such file.
return nullptr;
}
auto module = kj::heap<ModuleImpl>(
*this, kj::mv(canonicalLocalName), kj::mv(canonicalSourceName));
auto& result = *module;
modules.insert(std::make_pair(result.getLocalName(), kj::mv(module)));
return result;
}
kj::Maybe<Module&> ModuleLoader::Impl::loadModuleFromSearchPath(kj::StringPtr sourceName) {
for (auto& search: searchPath) {
kj::String candidate = kj::str(search, "/", sourceName);
char* end = canonicalizePath(candidate.begin() + (candidate[0] == '/'));
KJ_IF_MAYBE(module, loadModule(
kj::heapString(candidate.slice(0, end - candidate.begin())), sourceName)) {
return *module;
}
}
return nullptr;
}
// =======================================================================================
ModuleLoader::ModuleLoader(GlobalErrorReporter& errorReporter)
: impl(kj::heap<Impl>(errorReporter)) {}
ModuleLoader::~ModuleLoader() noexcept(false) {}
void ModuleLoader::addImportPath(kj::String path) { impl->addImportPath(kj::mv(path)); }
kj::Maybe<Module&> ModuleLoader::loadModule(kj::StringPtr localName, kj::StringPtr sourceName) {
return impl->loadModule(localName, sourceName);
}
} // namespace compiler
} // namespace capnp
| [
"j.e.aten@gmail.com"
] | j.e.aten@gmail.com | |
567f30453a453a8308b95dbc4f114a9fbadf583e | 961714d4298245d9c762e59c716c070643af2213 | /ThirdParty-mod/java2cpp/android/content/pm/InstrumentationInfo.hpp | e7ae5b842bf4bc97cf0bb08205e0e5d50a41879b | [
"MIT"
] | permissive | blockspacer/HQEngine | b072ff13d2c1373816b40c29edbe4b869b4c69b1 | 8125b290afa7c62db6cc6eac14e964d8138c7fd0 | refs/heads/master | 2023-04-22T06:11:44.953694 | 2018-10-02T15:24:43 | 2018-10-02T15:24:43 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,938 | hpp | /*================================================================================
code generated by: java2cpp
author: Zoran Angelov, mailto://baldzar@gmail.com
class: android.content.pm.InstrumentationInfo
================================================================================*/
#ifndef J2CPP_INCLUDE_IMPLEMENTATION
#ifndef J2CPP_ANDROID_CONTENT_PM_INSTRUMENTATIONINFO_HPP_DECL
#define J2CPP_ANDROID_CONTENT_PM_INSTRUMENTATIONINFO_HPP_DECL
namespace j2cpp { namespace java { namespace lang { class String; } } }
namespace j2cpp { namespace android { namespace content { namespace pm { class PackageItemInfo; } } } }
namespace j2cpp { namespace android { namespace os { class Parcel; } } }
namespace j2cpp { namespace android { namespace os { class Parcelable; } } }
namespace j2cpp { namespace android { namespace os { namespace Parcelable_ { class Creator; } } } }
#include <android/content/pm/PackageItemInfo.hpp>
#include <android/os/Parcel.hpp>
#include <android/os/Parcelable.hpp>
#include <java/lang/String.hpp>
namespace j2cpp {
namespace android { namespace content { namespace pm {
class InstrumentationInfo;
class InstrumentationInfo
: public object<InstrumentationInfo>
{
public:
J2CPP_DECLARE_CLASS
J2CPP_DECLARE_METHOD(0)
J2CPP_DECLARE_METHOD(1)
J2CPP_DECLARE_METHOD(2)
J2CPP_DECLARE_METHOD(3)
J2CPP_DECLARE_METHOD(4)
J2CPP_DECLARE_METHOD(5)
J2CPP_DECLARE_FIELD(0)
J2CPP_DECLARE_FIELD(1)
J2CPP_DECLARE_FIELD(2)
J2CPP_DECLARE_FIELD(3)
J2CPP_DECLARE_FIELD(4)
J2CPP_DECLARE_FIELD(5)
J2CPP_DECLARE_FIELD(6)
explicit InstrumentationInfo(jobject jobj)
: object<InstrumentationInfo>(jobj)
, targetPackage(jobj)
, sourceDir(jobj)
, publicSourceDir(jobj)
, dataDir(jobj)
, handleProfiling(jobj)
, functionalTest(jobj)
{
}
operator local_ref<android::content::pm::PackageItemInfo>() const;
operator local_ref<android::os::Parcelable>() const;
InstrumentationInfo();
InstrumentationInfo(local_ref< android::content::pm::InstrumentationInfo > const&);
local_ref< java::lang::String > toString();
jint describeContents();
void writeToParcel(local_ref< android::os::Parcel > const&, jint);
field< J2CPP_CLASS_NAME, J2CPP_FIELD_NAME(0), J2CPP_FIELD_SIGNATURE(0), local_ref< java::lang::String > > targetPackage;
field< J2CPP_CLASS_NAME, J2CPP_FIELD_NAME(1), J2CPP_FIELD_SIGNATURE(1), local_ref< java::lang::String > > sourceDir;
field< J2CPP_CLASS_NAME, J2CPP_FIELD_NAME(2), J2CPP_FIELD_SIGNATURE(2), local_ref< java::lang::String > > publicSourceDir;
field< J2CPP_CLASS_NAME, J2CPP_FIELD_NAME(3), J2CPP_FIELD_SIGNATURE(3), local_ref< java::lang::String > > dataDir;
field< J2CPP_CLASS_NAME, J2CPP_FIELD_NAME(4), J2CPP_FIELD_SIGNATURE(4), jboolean > handleProfiling;
field< J2CPP_CLASS_NAME, J2CPP_FIELD_NAME(5), J2CPP_FIELD_SIGNATURE(5), jboolean > functionalTest;
static static_field< J2CPP_CLASS_NAME, J2CPP_FIELD_NAME(6), J2CPP_FIELD_SIGNATURE(6), local_ref< android::os::Parcelable_::Creator > > CREATOR;
}; //class InstrumentationInfo
} //namespace pm
} //namespace content
} //namespace android
} //namespace j2cpp
#endif //J2CPP_ANDROID_CONTENT_PM_INSTRUMENTATIONINFO_HPP_DECL
#else //J2CPP_INCLUDE_IMPLEMENTATION
#ifndef J2CPP_ANDROID_CONTENT_PM_INSTRUMENTATIONINFO_HPP_IMPL
#define J2CPP_ANDROID_CONTENT_PM_INSTRUMENTATIONINFO_HPP_IMPL
namespace j2cpp {
android::content::pm::InstrumentationInfo::operator local_ref<android::content::pm::PackageItemInfo>() const
{
return local_ref<android::content::pm::PackageItemInfo>(get_jobject());
}
android::content::pm::InstrumentationInfo::operator local_ref<android::os::Parcelable>() const
{
return local_ref<android::os::Parcelable>(get_jobject());
}
android::content::pm::InstrumentationInfo::InstrumentationInfo()
: object<android::content::pm::InstrumentationInfo>(
call_new_object<
android::content::pm::InstrumentationInfo::J2CPP_CLASS_NAME,
android::content::pm::InstrumentationInfo::J2CPP_METHOD_NAME(0),
android::content::pm::InstrumentationInfo::J2CPP_METHOD_SIGNATURE(0)
>()
)
, targetPackage(get_jobject())
, sourceDir(get_jobject())
, publicSourceDir(get_jobject())
, dataDir(get_jobject())
, handleProfiling(get_jobject())
, functionalTest(get_jobject())
{
}
android::content::pm::InstrumentationInfo::InstrumentationInfo(local_ref< android::content::pm::InstrumentationInfo > const &a0)
: object<android::content::pm::InstrumentationInfo>(
call_new_object<
android::content::pm::InstrumentationInfo::J2CPP_CLASS_NAME,
android::content::pm::InstrumentationInfo::J2CPP_METHOD_NAME(1),
android::content::pm::InstrumentationInfo::J2CPP_METHOD_SIGNATURE(1)
>(a0)
)
, targetPackage(get_jobject())
, sourceDir(get_jobject())
, publicSourceDir(get_jobject())
, dataDir(get_jobject())
, handleProfiling(get_jobject())
, functionalTest(get_jobject())
{
}
local_ref< java::lang::String > android::content::pm::InstrumentationInfo::toString()
{
return call_method<
android::content::pm::InstrumentationInfo::J2CPP_CLASS_NAME,
android::content::pm::InstrumentationInfo::J2CPP_METHOD_NAME(2),
android::content::pm::InstrumentationInfo::J2CPP_METHOD_SIGNATURE(2),
local_ref< java::lang::String >
>(get_jobject());
}
jint android::content::pm::InstrumentationInfo::describeContents()
{
return call_method<
android::content::pm::InstrumentationInfo::J2CPP_CLASS_NAME,
android::content::pm::InstrumentationInfo::J2CPP_METHOD_NAME(3),
android::content::pm::InstrumentationInfo::J2CPP_METHOD_SIGNATURE(3),
jint
>(get_jobject());
}
void android::content::pm::InstrumentationInfo::writeToParcel(local_ref< android::os::Parcel > const &a0, jint a1)
{
return call_method<
android::content::pm::InstrumentationInfo::J2CPP_CLASS_NAME,
android::content::pm::InstrumentationInfo::J2CPP_METHOD_NAME(4),
android::content::pm::InstrumentationInfo::J2CPP_METHOD_SIGNATURE(4),
void
>(get_jobject(), a0, a1);
}
static_field<
android::content::pm::InstrumentationInfo::J2CPP_CLASS_NAME,
android::content::pm::InstrumentationInfo::J2CPP_FIELD_NAME(6),
android::content::pm::InstrumentationInfo::J2CPP_FIELD_SIGNATURE(6),
local_ref< android::os::Parcelable_::Creator >
> android::content::pm::InstrumentationInfo::CREATOR;
J2CPP_DEFINE_CLASS(android::content::pm::InstrumentationInfo,"android/content/pm/InstrumentationInfo")
J2CPP_DEFINE_METHOD(android::content::pm::InstrumentationInfo,0,"<init>","()V")
J2CPP_DEFINE_METHOD(android::content::pm::InstrumentationInfo,1,"<init>","(Landroid/content/pm/InstrumentationInfo;)V")
J2CPP_DEFINE_METHOD(android::content::pm::InstrumentationInfo,2,"toString","()Ljava/lang/String;")
J2CPP_DEFINE_METHOD(android::content::pm::InstrumentationInfo,3,"describeContents","()I")
J2CPP_DEFINE_METHOD(android::content::pm::InstrumentationInfo,4,"writeToParcel","(Landroid/os/Parcel;I)V")
J2CPP_DEFINE_METHOD(android::content::pm::InstrumentationInfo,5,"<clinit>","()V")
J2CPP_DEFINE_FIELD(android::content::pm::InstrumentationInfo,0,"targetPackage","Ljava/lang/String;")
J2CPP_DEFINE_FIELD(android::content::pm::InstrumentationInfo,1,"sourceDir","Ljava/lang/String;")
J2CPP_DEFINE_FIELD(android::content::pm::InstrumentationInfo,2,"publicSourceDir","Ljava/lang/String;")
J2CPP_DEFINE_FIELD(android::content::pm::InstrumentationInfo,3,"dataDir","Ljava/lang/String;")
J2CPP_DEFINE_FIELD(android::content::pm::InstrumentationInfo,4,"handleProfiling","Z")
J2CPP_DEFINE_FIELD(android::content::pm::InstrumentationInfo,5,"functionalTest","Z")
J2CPP_DEFINE_FIELD(android::content::pm::InstrumentationInfo,6,"CREATOR","Landroid/os/Parcelable$Creator;")
} //namespace j2cpp
#endif //J2CPP_ANDROID_CONTENT_PM_INSTRUMENTATIONINFO_HPP_IMPL
#endif //J2CPP_INCLUDE_IMPLEMENTATION
| [
"le.hoang.q@gmail.com@2e56ffda-155b-7872-b1f3-609f5c043f28"
] | le.hoang.q@gmail.com@2e56ffda-155b-7872-b1f3-609f5c043f28 |
a400d0f72a51fbcbf4cf2ce8888fef703b169931 | b2484b4305faba9dc04fd032987b90e5c9f24865 | /src/mainwindow.cpp | 8d5c93a23664509b31eda02f497d9bb29b644ee0 | [] | no_license | lucianosantosdev/qml-responsive-livereload | 45ad0e5ef054a000a67d153ede057d05163ddec5 | c822a0963a9a0bff99c230532ae48fed63cef352 | refs/heads/master | 2023-02-26T15:25:08.504701 | 2020-07-03T18:38:26 | 2020-07-03T18:38:26 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,198 | cpp | #include "mainwindow.h"
#include "enhancedqmlapplicationengine.h"
#include "ui_mainwindow.h"
#include <QHBoxLayout>
#include <QtQml/QQmlApplicationEngine>
#include <QtQuick/QQuickWindow>
#include <QtWidgets/QApplication>
#include <QtWidgets>
MainWindow::MainWindow(QWidget* parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
, m_layout(new QHBoxLayout)
{
ui->setupUi(this);
setWindowTitle("Qml Responsive Livereload");
ui->widget->setLayout(m_layout);
appendNewWindow(320, 240);
appendNewWindow(240, 320);
appendNewWindow(480, 800);
QSettings settings;
QUrl qmlUrl = settings.value("qmlApplicationFolder").toUrl();
if (!qmlUrl.isValid()) {
on_actionOpen_folder_triggered();
} else {
loadQml(qmlUrl);
}
}
void
MainWindow::appendNewWindow(int width, int height)
{
QSharedPointer<EnhancedQmlApplicationEngine> engine(
new EnhancedQmlApplicationEngine);
engine->load(QUrl(QStringLiteral("qrc:/main.qml")));
QWindow* w = qobject_cast<QWindow*>(engine->rootObjects().at(0));
w->resize(width, height);
QWidget* container = QWidget::createWindowContainer(w);
container->setFixedSize(w->size());
container->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
m_layout->addWidget(container);
m_qmlAppEngineList.push_back(engine);
w->installEventFilter(this);
}
MainWindow::~MainWindow()
{
delete ui;
}
bool
MainWindow::eventFilter(QObject* watched, QEvent* event)
{
QWindow* watchedWindow = dynamic_cast<QWindow*>(watched);
if (watchedWindow == nullptr) {
return QMainWindow::eventFilter(watched, event);
}
for (auto engine : m_qmlAppEngineList) {
QWindow* w = qobject_cast<QWindow*>(engine->rootObjects().at(0));
if (w != watched) {
QMouseEvent* mouseEvent = dynamic_cast<QMouseEvent*>(event);
if (mouseEvent != nullptr) {
float x =
(mouseEvent->x() / (float)watchedWindow->width()) * w->size().width();
float y = (mouseEvent->y() / (float)watchedWindow->height()) *
w->size().height();
QPointF newPos(x, y);
QMouseEvent eventScaled(mouseEvent->type(),
newPos,
mouseEvent->button(),
mouseEvent->buttons(),
mouseEvent->modifiers());
w->removeEventFilter(this);
QApplication::sendEvent(w, &eventScaled);
w->installEventFilter(this);
update();
} else {
}
}
}
return QMainWindow::eventFilter(watched, event);
}
void
MainWindow::on_actionOpen_folder_triggered()
{
QUrl qmlUrl =
QFileDialog::getOpenFileUrl(this, tr("Open File"), tr("Qml (qml.png)"));
if (qmlUrl.isValid()) {
QSettings settings;
settings.setValue("qmlApplicationFolder", qmlUrl);
loadQml(qmlUrl);
}
}
void
MainWindow::loadQml(const QUrl& qmlUrl)
{
QString fileDir = QFileInfo(qmlUrl.toLocalFile()).absolutePath();
qputenv("QT_QUICK_CONTROLS_CONF",
(fileDir + "/qtquickcontrols2.conf").toLatin1());
for (auto& qmlAppEngine : m_qmlAppEngineList) {
qmlAppEngine->addImportPath(QStringLiteral("qrc:///"));
qmlAppEngine->setMainUrl(qmlUrl);
}
}
| [
"luciano.santos@aditum.com.br"
] | luciano.santos@aditum.com.br |
e48734151afced1482a188bad01a2b2074837191 | 3bee15e5c499481935b7c716964d5b95e3743aeb | /libvast/vast/concept/parseable/vast/offset.hpp | e2abd84269fab9d06c7abb2ce9e69b3774125017 | [
"BSD-3-Clause"
] | permissive | sangminoh/vast | 113d62ddbbc00d88711e9731122fa025eb4e22bc | 4ea59c45ffabe23d35d8b13b5e58a48d47d86aee | refs/heads/master | 2021-01-19T10:18:14.768229 | 2017-02-04T23:32:21 | 2017-02-04T23:32:21 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 828 | hpp | #ifndef VAST_CONCEPT_PARSEABLE_VAST_OFFSET_HPP
#define VAST_CONCEPT_PARSEABLE_VAST_OFFSET_HPP
#include "vast/offset.hpp"
#include "vast/concept/parseable/core/list.hpp"
#include "vast/concept/parseable/core/operators.hpp"
#include "vast/concept/parseable/core/parser.hpp"
#include "vast/concept/parseable/numeric/integral.hpp"
namespace vast {
struct offset_parser : parser<offset_parser> {
using attribute = offset;
template <typename Iterator, typename Attribute>
bool parse(Iterator& f, Iterator const& l, Attribute& a) const {
static auto p = parsers::u32 % ',';
return p.parse(f, l, a);
}
};
template <>
struct parser_registry<offset> {
using type = offset_parser;
};
namespace parsers {
static auto const offset = make_parser<vast::offset>();
} // namespace parsers
} // namespace vast
#endif
| [
"vallentin@icir.org"
] | vallentin@icir.org |
493449be64435240ebfc2f0c8cdfb1ba4ee85eb8 | 48dfa4685aeac52ce9cca101af5f1c5f1c0de893 | /src/Timer.cpp | cfb6b859f3c212ebd14002fbd3323c7ff1fe519f | [] | no_license | Zetagon/Game-Project | 2050c2536a1e943414a1102e516e7699ebad099a | 2874fd8490b452e536714f3d725169cc288aa069 | refs/heads/master | 2021-01-13T10:29:43.475733 | 2016-10-22T19:43:58 | 2016-10-22T19:43:58 | 72,221,441 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 616 | cpp | #include "Timer.h"
#include <iostream>
Timer::Timer()
{
//ctor
prevSysTime = 0;
timeSince = 0;
}
Timer::~Timer()
{
//dtor
}
/** \brief Start or restart the timer
*
*/
void Timer::start()
{
timeSince = SDL_GetTicks() - prevSysTime;
prevSysTime = SDL_GetTicks();
// std::cout << "TimeSince: " << timeSince << "\n";
}
/** \brief
*
* \return the time that has passed since \r start was called, or 0
*
*/
double Timer::getTime()
{
double temp = (SDL_GetTicks() - prevSysTime);
// std::cout << temp << " " << SDL_GetTicks()<< " " << prevSysTime << "\n";
return temp;
}
| [
"leo.ericson@yahoo.se"
] | leo.ericson@yahoo.se |
893b058bed3697d3ab8dcd3fba516942d9ea3954 | 983eb5f991890fda0a096993ada7afbdb65ce49c | /firmware/DnD20/Devices.ino | 35b09d3c2132709e5c0d9bc7af2e2b6247d66a07 | [] | no_license | MatthewCLind/DnD20 | c7a9b28bc891b4171c4333c5309b42f6aa88e5ac | d58b7953abb8a215aaa7baea8745141678314581 | refs/heads/master | 2020-03-30T22:33:53.161759 | 2018-12-03T03:39:34 | 2018-12-03T03:39:34 | 151,671,108 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,657 | ino | // ----------------------------------
// NeoPixel
// ----------------------------------
// change the neopixel to a pre-defined color
void set_neopixel_color(RgbColor c)
{
for(int i = 0; i < NUM_NEOPIXELS; i++)
{
neopixel.SetPixelColor(i, c);
}
neopixel.Show();
}
// ----------------------------------
// OLED
// ----------------------------------
// write something to the OLED,
// the text will be resized based on the number of characters
void update_OLED(String value)
{
// font sizes 1 2 3 4
const int char_width[] = {6, 12, 18, 24};
const int char_height[] = {8, 16, 24, 32};
// maximum number of characters at font 1 = 84
int num_chars = (value.length() < 84) ? value.length() : 84;
int font_size;
int x_offset = 0;
int y_offset = 0;
if(num_chars <= 5)
{
font_size = 4;
y_offset = (32 - char_height[3]) / 2;
x_offset = (128 - (char_width[3] * num_chars)) / 2;
}
else if(num_chars <= 7)
{
font_size = 3;
y_offset = (32 - char_height[2]) / 2;
x_offset = (128 - (char_width[2] * num_chars))/2;
}
else if(num_chars <= 20) // size 2 accomodates 2 rows of 10 chars
{
font_size = 2;
x_offset = (num_chars <= 10) ? (128 - (char_width[1] * num_chars))/2 : 0;
int rows = (num_chars <= 10) ? 1 : 2;
y_offset = (32 - (char_height[1] * rows)) / 2;
}
else
{
int max_columns = 21;
font_size = 1;
x_offset = (num_chars <= 21) ? (128 - (char_width[0] * num_chars))/2 : 0;
int rows;
if(num_chars <= max_columns)
{
rows = 1;
}
else if(num_chars <= 2*max_columns)
{
rows = 2;
}
else if(num_chars <= 3*max_columns)
{
rows = 3;
}
else if(num_chars <= 4*max_columns)
{
rows = 4;
}
y_offset = (32 - (char_height[0] * rows)) / 2;
}
display.clearDisplay();
display.setTextSize(font_size);
display.setCursor(x_offset, y_offset);
display.println(value);
display.display();
}
// display a die type on the OLED
void display_dN(int N)
{
String die_type = "d";
die_type.concat(N);
update_OLED(die_type);
}
void display_mode(int zmode)
{
String display_string = mode_display_strings[zmode];
update_OLED(display_string);
}
// ----------------------------------
// Button
// ----------------------------------
// cycle through the modes,
// button_press will be set to true if the button was only clicked
int button_mode_select(bool* button_press)
{
*button_press = false;
bool mode_change = false;
int next_mode = device_state.mode;
long start_time = millis();
int elapsed_time;
while(digitalRead(BUTTON_PIN) == LOW)
{
elapsed_time = millis() - start_time;
if(elapsed_time > 1500)
{
mode_change = true;
next_mode++;
next_mode = next_mode % NUM_MODES;
String display_string = mode_display_strings[next_mode];
update_OLED(display_string);
start_time = millis(); // so you can continue to cycle through
}
yield();
}
if(!mode_change && elapsed_time > 10 && elapsed_time < 1000)
{
*button_press = true;
}
return next_mode;
}
// cycle through the button modes
int button_mode_select()
{
int next_mode = device_state.mode;
long start_time = millis();
int elapsed_time;
while(digitalRead(BUTTON_PIN) == LOW)
{
elapsed_time = millis() - start_time;
if(elapsed_time > 1500)
{
next_mode++;
next_mode = next_mode % NUM_MODES;
display_mode(next_mode);
start_time = millis(); // so you can continue to cycle through
}
yield();
}
return next_mode;
}
| [
"32720559+MatthewCLind@users.noreply.github.com"
] | 32720559+MatthewCLind@users.noreply.github.com |
d9906b2bbfeff6cb88dd40dca9198fb183f3f5f0 | 08b0b4544980309a12dbf6d4c0cb036245b39ab7 | /src/findmf/apps/parseargExtract.h | 81ccc6121fa5b4aadba9754a0fb9708a0c7e22db | [
"BSD-3-Clause"
] | permissive | findMF/findMFHCS | f7e5012a02acbfb990c1ec5d541f73fa36ad6267 | 1be1da010c1d4b0e06a685734fba475d4c1369da | refs/heads/master | 2021-01-10T11:30:50.659830 | 2015-07-03T10:55:17 | 2015-07-03T10:55:17 | 8,410,408 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,674 | h | // Copyright : ETH Zurich
// License : three-clause BSD license
// Authors : Witold Wolski
// for full text refer to files: LICENSE, AUTHORS and COPYRIGHT
#ifndef PARSEARGEXTRACT_H
#define PARSEARGEXTRACT_H
#include <boost/program_options.hpp>
#include <boost/filesystem.hpp>
#include <fstream>
#include "findmf/apps/toolparameters.h"
namespace b_po = boost::program_options;
namespace b_fs = boost::filesystem;
/*!
*\brief parses the command line arguments using boost::program_options
*/
inline void analysisParameters(ralab::findmf::apps::Params & ap,b_po::variables_map & vmgeneral){
if(vmgeneral.count("in"))
{
ap.infile = vmgeneral["in"].as<std::string>();
}
else{
std::cerr << "in file argument is required" << std::endl;
return;
}
if(vmgeneral.count("outdir"))
{
ap.outdir = vmgeneral["outdir"].as<std::string>();
}
else{
boost::filesystem::path p(ap.infile);
ap.outdir = p.parent_path().string();
}
ap.nrthreads = vmgeneral["nrthreads"].as< uint32_t >();
//image generation options
ap.ppm=1/vmgeneral["resolution"].as<double>()* 1.e6;
ap.minmass = vmgeneral["minMass"].as<double>();
if(vmgeneral.count("maxMass")){
ap.maxmass = vmgeneral["maxMass"].as<double>();
}
else{
ap.maxmass = std::numeric_limits<double>::max();
}
ap.rt2sum_ = vmgeneral["rt2sum"].as<uint32_t>();
// filtering options
ap.mzpixelwidth = vmgeneral["width-MZ"].as<unsigned int>();
if(vmgeneral.count("width-RT")){
ap.rtpixelwidth = vmgeneral["width-RT"].as<unsigned int>();
}else{
ap.rtpixelwidth = ap.mzpixelwidth;
}
ap.mzscale = vmgeneral["mzscale"].as< double >();
if(vmgeneral.count("rtscale")){
ap.rtscale = vmgeneral["rtscale"].as< double >();
}
else{
ap.rtscale = ap.mzscale;
}
ap.dofilter = vmgeneral["filter"].as<bool>();
// segmentation options
ap.minintensity=vmgeneral["minintensity"].as<double>();
ap.writeprojections_ = vmgeneral["writeprojections"].as<bool>();
}
/// set up the parameters and pars them.
inline int parsecommandlineExtract(
int ac,
char* av[],
b_po::variables_map & vmgeneral
)
{
try
{
b_po::options_description general("File Handling:");
general.add_options()
("help,H", "produce help message")
("version,V", "produces version information")
("in,I", b_po::value<std::string>(), "input file")
("outdir,O", b_po::value<std::string>(), "output directory (default same as input)")
("config-file,I", b_po::value<std::string>(), "configuration file")
("nrthreads", b_po::value<uint32_t>()->default_value(4), "nr threads");
b_po::options_description generation("Image Generation Options:");
generation.add_options()
("resolution",b_po::value<double>()->default_value(50000.),
"instrument resolution (default 50000).")
("minMass",b_po::value<double>()->default_value(400.), "minimum mass to consider (default 400)")
("maxMass",b_po::value<double>(),"maximum mass to consider")
("rt2sum",b_po::value<uint32_t>()->default_value(1u),"downsampling - number spectra to average (not supported yet)");
b_po::options_description filtering("Image Preprocessing Options :");
filtering.add_options()
("filter",b_po::value<bool>()->default_value(1),"should filtering be performed?")
("mzscale",b_po::value<double>()->default_value(1.5),
"scale parameter for gausian smoothing in mz (default 1.5)")
("rtscale",b_po::value<double>(),
"scale parameter for gausian smoothing in rt (default same as mzscale)")
("width-MZ", b_po::value<unsigned int>()->default_value(9),
"width of MZ peak in pixel - used by background subtraction (default = 9)")
("width-RT", b_po::value<unsigned int>(),
"width of RT peak in pixel - used by background subtraction (default = width-MZ)");
b_po::options_description segment("Feature extraction and storage options :");
segment.add_options()
("minintensity",b_po::value<double>()->default_value(5.),"minimum intensity")
("writeprojections",b_po::value<bool>()->default_value(true),"should feature projections be stored in database");
b_po::options_description cmdloptions;
cmdloptions.add(general).add(generation).add(filtering).add(segment);
b_po::store(b_po::parse_command_line(ac, av, cmdloptions), vmgeneral);
b_po::notify(vmgeneral);
std::string configfile;
if(vmgeneral.count("config-file"))
{
configfile = vmgeneral["config-file"].as<std::string>();
}
b_po::options_description config_file_options;
config_file_options.add(general).add(generation).add(filtering).add(segment);
if(configfile.size() > 0 && b_fs::exists(configfile))
{
std::ifstream ifs(configfile.c_str());
store(parse_config_file(ifs, config_file_options), vmgeneral);
b_po::notify(vmgeneral);
}
else if(configfile.size() == 0){
}
else
{
std::cerr << "Could not find config file." << std::endl;
exit(0);
}
if(!vmgeneral.count("in"))
{
std::cerr << "input file is obligatory" << std::endl;
std::cerr << cmdloptions << "\n";
exit(0);
}
if(vmgeneral.count("help"))
{
std::cerr << cmdloptions << "\n";
exit(0);
}
if(vmgeneral.count("version"))
{
std::cerr << "1.0.0.3" << "\n";
exit(0);
}
}
catch(std::exception& e)
{
std::cerr << "error: " << e.what() << "\n";
exit(0);
}
catch(...)
{
std::cerr << "Exception of unknown type!\n";
}
return 1;
}//end parse command line
#endif // PARSEARGEXTRACT_H
| [
"wewolski@gmail.com"
] | wewolski@gmail.com |
158f8f36a90aa613c0e3e5d79447ff04df5ca8b1 | 09e33c5c1d80f684fcc924b8fc37e1ff3fe00013 | /matrix.ino | a15ee0ff4ac8e889e3969b47ba37c13709016fd0 | [] | no_license | shawnlg/Arduino-LED-Matrix-Message-Display | c050214c4b4c2fedf6f281a56e3cd5f7843d281a | 6510d105161294c68c141ef67699bf152d4451d0 | refs/heads/master | 2016-09-14T06:04:04.456617 | 2016-04-28T00:33:57 | 2016-04-28T00:33:57 | 57,257,249 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 8,267 | ino | // The frame is 64 bits. Each byte holds one column of display data.
// 64 bits, 8 columns for the 64 LEDs in the matrix.
byte _frame[8] = {0,0,0,0,0,0,0,0};
// clear all pins going to matrix (input mode)
void clearMatrix() {
for (byte i=0; i<sizeof(pins); i++) {
pinMode(pins[i], INPUT);
}
}
// copy a font character (row-bytes) into matrix frame (column-bytes)
void copyFontCharacterToFrame(char ch) {
// Serial.println("copyFontCharacterToFrame");
int fontOffset = ch*8; // first byte of character in font table
for (byte row=0; row<8; row++) {
// Serial.print("row: "); Serial.print(row);
byte rowOfDots = pgm_read_byte_near(FONT + fontOffset++);
// Serial.print(" rowOfDots: "); Serial.println(rowOfDots,BIN);
for (byte col=0; col<8; col++) {
// Serial.print(" col: "); Serial.print(col);
// get the column bit in the row data from the font
int bit = rowOfDots << col;
bit &= 0x80;
bit >>= 7;
// Serial.print(bit==1?". ":" ");
// get the column byte in the frame
byte columnByte = _frame[col];
// add the bit to the right most row, shifting the others to the left
columnByte = (columnByte << 1) + bit;
_frame[col] = columnByte;
// Serial.print(" col byte: "); Serial.print(bit,BIN);
} // columns
// Serial.println();
} // rows
} // copyFontCharacterToFrame
// print frame to serial
void printFrame() {
Serial.println("printFrame");
for (byte row=0; row<8; row++) {
for (byte col=0; col<8; col++) {
byte colOfDots = _frame[col];
// get the row bit in the column data from the frame
int bit = colOfDots << row;
bit &= 0x80;
bit >>= 7;
// print the bit in the row
Serial.print(bit==1 ? ". " : " ");
} // columns
Serial.println();
} // rows
Serial.println("end printFrame");
} // printFrame
// display frame to matrix once - one refresh cycle
void displayFrame() {
long frameStart = millis();
// Serial.println("displayFrame");
long timeLeft = REFRESH_TIME;
for (byte col=0; col<8; col++) {
byte rowOfDots = _frame[col];
byte numLEDs = 0; // how many LEDs lit in column
for (byte row=0; row<8; row++) {
// get the row bit in the column data from the frame
int bit = rowOfDots << row;
bit &= 0x80;
bit >>= 7;
// set the pin for that row bit if it is a 1
if (bit == 1) { // light this row
numLEDs++; // count lit LEDs
byte pin = _rows[row];
pin = pins[pin]; // real arduino pin
// turn on the LED
pinMode(pin, OUTPUT);
digitalWrite(pin, _rowVoltage);
} // if row lit
} // rows
// we lit all the rows. Calculate the delay for showing that many LEDs
if (numLEDs > 0) { // at least 1 light in this column lit
long onTime = _brightness[numLEDs-1];
timeLeft -= onTime; // how much left of the refresh cycle
// turn on the column pin to light all column dots selected
byte pin = _cols[col];
pin = pins[pin]; // real arduino pin
pinMode(pin, OUTPUT);
digitalWrite(pin, _columnVoltage);
delayMicroseconds(onTime);
clearMatrix(); // turn off all the pins
} // at least one light in column
} // columns
// if there is still time left in the refresh cycle, wait it out
if (timeLeft > 0) {
delayMicroseconds(timeLeft);
}
// Serial.println("end displayFrame");
long frameEnd = millis();
} // displayFrame
// temporary message length variable so we don't have to change EEPROM too much
int _messageLength;
void startMessage() {
// add 8 blank columns to message so it can scroll the first letter
_messageLength = 0;
setMessageLength(_messageLength); // store the length permanently at start and end of message creation
for (int i=0; i<8; i++) {
addColumnToMessage(0);
}
}
void endMessage() {
// add 8 blank columns to end of message so it can scroll off the last letter
for (int i=0; i<8; i++) {
addColumnToMessage(0);
}
setMessageLength(_messageLength);
}
void addColumnToMessage(byte c) {
// Serial.print("addColumnToMessage: "); Serial.print(c); Serial.print(" location: "); Serial.println(_messageLength);
EEPROM.update(EE_DISPLAY_COLS+_messageLength++, c);
// Serial.println("end addColumnToMessage");
}
void addCharToMessage(char ch) {
// if EEPROM is almost full, don't add the character
int bytesLeft = EEPROM.length() - EE_DISPLAY_COLS - _messageLength;
if (bytesLeft < 10) {
return;
}
// Serial.print("addCharToMessage: "); Serial.println(ch);
copyFontCharacterToFrame(ch); // 8 column bytes
// printFrame();
// we only leave 1 blank column between characters unless it's a space
byte firstByte=99, lastByte=99;
for (byte i=0; i<sizeof(_frame); i++) {
if (_frame[i] != 0) {
lastByte = i;
if (firstByte == 99) {
firstByte = i;
} // first non-blank
} // last non-blank
} // read all columns of frame
// if we have a space, add some blank columns to message since the last
// column of the message is already blank
if (firstByte == 99) { // a blank frame
// Serial.println("blank frame");
addColumnToMessage(0);
addColumnToMessage(0);
addColumnToMessage(0);
} else {
// Serial.print("firstByte = "); Serial.println(firstByte);
// Serial.print("lastByte = "); Serial.println(lastByte);
// add columns to message from first to last byte
for (byte i=firstByte; i<=lastByte; i++) {
addColumnToMessage(_frame[i]);
}
addColumnToMessage(0); // end character with one blank column
}
// Serial.println("end addCharToMessage");
}
void addStringToMessage(char s[]) {
for (int i=0; s[i] != 0; i++) {
addCharToMessage(s[i]);
}
}
void createMessage(char s[]) {
startMessage();
addStringToMessage(s);
endMessage();
}
void displayMessage() {
_messageLength = getMessageLength();
while (1) { // loop until button long pressed
for (int i=0; i<_messageLength-8; i++) {
// get knob reading and use it to control speed
int reduceDelay = getKnobReading(SCROLL_MAX_DELAY - SCROLL_MIN_DELAY);
// copy 8 bytes of message into display frame
// Serial.print("frame: ");
for (byte j=0; j<8; j++) {
_frame[j] = EEPROM.read(EE_DISPLAY_COLS+i+j);
// Serial.print(_frame[j]); Serial.print(" ");
} // copy into frame
// Serial.println();
// display frame for a bit
long endTime = millis()+SCROLL_MAX_DELAY-reduceDelay; // when to stop displaying
while (millis() < endTime) {
displayFrame();
} // display frame until time is up
// test for button press. Short press is ignored, long press means exit
byte pressed = isButtonPressed();
if (pressed == BUTTON_LONG_PRESS) {
goto endLoop;
}
} // scroll one column through message
} // loop forever
endLoop: ;
} // displayMessage
void enterMessage() {
byte numChars = sizeof(MESSAGE_CHARACTERS);
begin: // start entering message
startMessage();
while (1) { // enter characters over and over
// read the knob and display that character
byte charIndex = getKnobReading(numChars);
char ch = MESSAGE_CHARACTERS[charIndex];
copyFontCharacterToFrame(ch);
displayFrame();
// read button. A short press adds the character to the message,
// a long press starts the message over
byte pressed = isButtonPressed();
if (pressed == BUTTON_LONG_PRESS) {
goto begin; // start over, abandoning entered message
} else if (pressed == BUTTON_SHORT_PRESS) {
// if the knob is turned to the last character, that means we are done
// with the message. Instead of entering the character, go to the end
// of the loop.
if (charIndex == numChars-1) { // last character
break;
} else { // enter character at end of message
addCharToMessage(ch);
// blink character to show it was entered
for (byte i=0; i<3; i++) {
for (byte j=0; j<5; j++) {
displayFrame();
} // keep on for awhile
delay(100);
} // blink
}
}
} // entering characters
end: // done entering message
endMessage();
}
| [
"shawn@gordhamer.com"
] | shawn@gordhamer.com |
d0915657213076356dfe19a3852fae7f937ae652 | ffc778ece64c4b39d8fabce384d1f4d2ed342915 | /Exercícios Funções/Exercício 4.cpp | 4d16f713db85dc475fa5f6f801e9fa0805a62284 | [] | no_license | MateusKaufmann/Linguagem-C | b8a2db309229080c9349be66a23076c27d710a54 | 0c1eb6e2ffeed72ccaceaa02fd8530e367cd3328 | refs/heads/main | 2023-07-20T10:22:04.131856 | 2021-08-27T20:33:37 | 2021-08-27T20:33:37 | null | 0 | 0 | null | null | null | null | ISO-8859-1 | C++ | false | false | 3,050 | cpp | #include <stdio.h>
#include <stdlib.h>
#include <locale.h>
#include <string.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int soma (int a, int b) {
puts("\n Digite o primeiro número");
scanf("%d", &a);
puts("\n Digite o segundo número");
scanf("%d", &b);
puts("\n Somando os números, aguarde...");
return a+b;
}
int produto (int a, int b) {
puts("\n Digite o primeiro número (base)");
scanf("%d", &a);
puts("\n Digite o segundo número (multiplicador)");
scanf("%d", &b);
puts("\n Multiplicando os números, aguarde...");
return a*b;
}
int razao (int a, int b) {
puts("\n Digite o primeiro número (base)");
scanf("%d", &a);
puts("\n Digite o segundo número (divisor)");
scanf("%d", &b);
puts("\n Dividindo os números, aguarde...");
return a/b;
}
int subtracao (int a, int b) {
puts("\n Digite o primeiro número");
scanf("%d", &a);
puts("\n Digite o segundo número");
scanf("%d", &b);
puts("\n Multiplicando os números, aguarde...");
return a-b;
}
int fatorial (int a) {
puts("\n Digite o número a ser fatorado");
scanf("%d", &a);
puts("\n Fatorando o número, aguarde...");
int result = 1;
while (a > 1) {
result *= a;
a--;
}
return result;
}
int potencia (int a, int b) {
puts("\n Digite o primeiro número (base)");
scanf("%d", &a);
puts("\n Digite o segundo número (expoente)");
scanf("%d", &b);
puts("\n Calculando a potência dos números, aguarde...");
int result = 1;
while (b >= 1) {
result *= a;
b--;
}
return result;
}
int main() {
setlocale(LC_ALL, "Portuguese");
int a, b, resultado;
char op;
puts("\n Digite código correspondente à operação desejada, conforme a tabela abaixo:");
puts("\n Código | Operação ");
puts("\n a | Somar os números ");
puts("\n b | Multiplicar os números ");
puts("\n c | Dividir os números ");
puts("\n d | Subtrair os números ");
puts("\n e | Fatorar número ");
puts("\n f | Potência de números ");
puts("\n g | Sair ");
puts("\n Digite:");
scanf("%c", &op);
switch (op){
case 'a':
resultado = soma(a,b);
printf("\n A soma dos valores é %d", resultado);
break;
case 'b':
resultado = subtracao(a,b);
printf("\n A subtração dos valores é %d", resultado);
break;
case 'c':
resultado = razao(a,b);
printf("\n A divisão dos valores é %d", resultado);
break;
case 'd':
resultado = produto(a,b);
printf("\n A multiplicação dos valores é %d", resultado);
break;
case 'e':
resultado = fatorial(a);
printf("\n O fatorial do número é %d", resultado);
break;
case 'f':
resultado = potencia(a, b);
printf("\n A potência dos números é %d", resultado);
break;
case 'g':
break;
default:
printf("Código Inválido");
}
system("pause");
}
| [
"noreply@github.com"
] | MateusKaufmann.noreply@github.com |
3dcf968d871687c75e52ab471bf3f56cae670b6a | 3e85351787b37cf51d0bfe2bc8ac5aabe5755e0a | /src/GPIO_core/GPIO_core.cpp | 0e94b8683c3d9b8c28fb0045b3a7a5d0e048766d | [] | no_license | mroctavious/CentzonThinClient | 46c239d55c0cb9a9980975b6fb12d530c02fa510 | 8337c7ffd1753ba7285f1de052e2b048076c4245 | refs/heads/master | 2022-04-16T22:49:32.288460 | 2020-04-15T21:36:15 | 2020-04-15T21:36:15 | 256,041,639 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,825 | cpp | #include <fstream>
#include <string>
#include <iostream>
#include <sstream>
#include "GPIO_core.h"
using namespace std;
GPIOClass::GPIOClass()
{
this->gpionum = "4"; //GPIO4 is default
}
GPIOClass::GPIOClass(string gnum)
{
this->gpionum = gnum; //Instatiate GPIOClass object for GPIO pin number "gnum"
}
int GPIOClass::export_gpio()
{
string export_str = "/sys/class/gpio/export";
ofstream exportgpio(export_str.c_str()); // Open "export" file. Convert C++ string to C string. Required for all Linux pathnames
if ( exportgpio.is_open() == false ){
cout << " OPERATION FAILED: Unable to export GPIO"<< this->gpionum <<" ."<< endl;
return -1;
}
exportgpio << this->gpionum ; //write GPIO number to export
exportgpio.close(); //close export file
return 0;
}
int GPIOClass::unexport_gpio()
{
string unexport_str = "/sys/class/gpio/unexport";
ofstream unexportgpio(unexport_str.c_str()); //Open unexport file
if ( unexportgpio.is_open() == false ){
cout << " OPERATION FAILED: Unable to unexport GPIO"<< this->gpionum <<" ."<< endl;
return -1;
}
unexportgpio << this->gpionum ; //write GPIO number to unexport
unexportgpio.close(); //close unexport file
return 0;
}
int GPIOClass::setdir_gpio(string dir)
{
string setdir_str ="/sys/class/gpio/gpio" + this->gpionum + "/direction";
ofstream setdirgpio(setdir_str.c_str()); // open direction file for gpio
if ( setdirgpio.is_open() == false ){
cout << " OPERATION FAILED: Unable to set direction of GPIO"<< this->gpionum <<" ."<< endl;
return -1;
}
setdirgpio << dir; //write direction to direction file
setdirgpio.close(); // close direction file
return 0;
}
int GPIOClass::setval_gpio(string val)
{
string setval_str = "/sys/class/gpio/gpio" + this->gpionum + "/value";
ofstream setvalgpio(setval_str.c_str()); // open value file for gpio
if ( setvalgpio.is_open() == false ){
cout << " OPERATION FAILED: Unable to set the value of GPIO"<< this->gpionum <<" ."<< endl;
return -1;
}
setvalgpio << val ;//write value to value file
setvalgpio.close();// close value file
return 0;
}
int GPIOClass::getval_gpio(string& val){
string getval_str = "/sys/class/gpio/gpio" + this->gpionum + "/value";
ifstream getvalgpio(getval_str.c_str());// open value file for gpio
if ( getvalgpio.is_open() == false ){
cout << " OPERATION FAILED: Unable to get value of GPIO"<< this->gpionum <<" ."<< endl;
return -1;
}
getvalgpio >> val ; //read gpio value
if(val != "0")
val = "1";
else
val = "0";
getvalgpio.close(); //close the value file
return 0;
}
string GPIOClass::get_gpionum(){
return this->gpionum;
}
| [
"erodriguez35@alumnos.uaq.mx"
] | erodriguez35@alumnos.uaq.mx |
af6b081d4d0d5b96683b96f916cb42c9df65070c | 47ab511d1e5f2418745f6319b7584221e578a705 | /EliminatingCastingEx/shape.h | 3870f8d73ed866f775e1bef7aef20bc8f8cb9318 | [] | no_license | sdaingade/cpplabs | f460936a6e2e4d68e13a9745b6edaae9aa75ba83 | fa6e644c1f83cbd73d4d6494a1d07f942915b62f | refs/heads/master | 2021-05-29T23:53:37.281887 | 2015-10-04T16:14:06 | 2015-10-04T16:14:06 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,356 | h | #ifndef SHAPE_H
#define SHAPE_H
/**************************************************************
*
* File: shape.h
*
* Description: Class Shape is defined in this class. shape.cpp
* has the implementation.
*
* Author: SciSpike
*
* Modification History:
*
***************************************************************/
/* Include Files */
/* Pre-Declarations */
/* Constants and defines */
/****************************************************************
*
* Description: The Shape is the base class for set of geometric
* Shapes that can be drawn, moved, etc on any
* drawing area.
*
* Exceptions: None
*
***************************************************************/
class Shape
{
public:
Shape( const char* name, const int _x, const int _y );
Shape( const Shape& shape );
virtual ~Shape();
Shape& operator=( const Shape& shape );
int getX() const;
int getY() const;
void setX( const int x );
void setY( const int y );
const char* getName() const;
// TODO Implement virtual draw method here with no code
// in implementation of it
protected:
char* myName;
int myX; // X Coordinate of the Shape
int myY; // Y Coordinate of the Shape
void initialize( const char* name, const int x, const int y );
};
#endif // SHAPE_H | [
"petter.graff@scispike.com"
] | petter.graff@scispike.com |
723d4f2191b03a841ee8c8b7b5258a5fec8dc0d7 | 4eb4242f67eb54c601885461bac58b648d91d561 | /third_part/mcpack/public/mc_pack_bits/indexer.h | f6d62b3cdc9c760b7125f26bbf2f070e8e52fd32 | [] | no_license | biebipan/coding | 630c873ecedc43a9a8698c0f51e26efb536dabd1 | 7709df7e979f2deb5401d835d0e3b119a7cd88d8 | refs/heads/master | 2022-01-06T18:52:00.969411 | 2018-07-18T04:30:02 | 2018-07-18T04:30:02 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,701 | h | #ifndef __INDEXER__
#define __INDEXER__
#include <stdint.h>
template<typename Key, typename Value>
class inner_hash {
struct node {
Key key;
Value value;
};
int buck_size;
node buckets[0];
public:
static uint64_t calc_size(uint32_t node_num) {
return (uint64_t)node_num * sizeof(node) + sizeof(inner_hash);
}
inner_hash(int node_num) {
buck_size = node_num;
memset(buckets, 0, node_num * sizeof(node));
};
inline Value get(const Key key) {
if(buck_size == 0) return 0;
int p = key % buck_size;
int t = p;
while(buckets[p].key != key) {
p++;
if( p >= buck_size) p -= buck_size;
if( p == t) return 0;
}
return buckets[p].value;
}
inline int set(Key key, Value value) {
int p = key % buck_size;
int t = p;
while(buckets[p].key != key && buckets[p].key != 0) {
p++;
if( p >= buck_size) p -= buck_size;
if( p == t) return -1;
}
if(buckets[p].key == key) {
buckets[p].value = (void *)-1;
return -1;
} else {
buckets[p].key = key;
buckets[p].value = value;
return 0;
}
}
};
template<typename Value>
class inner_map {
int buck_size;
Value buckets[0];
public:
inline static uint64_t calc_size(uint32_t node_num) {
return (uint64_t)node_num * sizeof(Value) + sizeof(inner_map);
}
inner_map(int node_num) {
buck_size = node_num;
memset(buckets, 0, node_num * sizeof(Value));
};
inline Value get(const int i) {
if(i<buck_size) return buckets[i];
else return 0;
}
inline int set(const int i, Value value) {
if(i<buck_size) {
buckets[i] = value;
return 0;
} else return -1;
}
};
#endif
| [
"guoliqiang@ubuntu.(none)"
] | guoliqiang@ubuntu.(none) |
629606a06d12330c297ad54462d842eebfa03513 | e220eb257fd2d58a0dafca096e5bb275888e8824 | /clientC++/ServeurIceMP3.h | e83fa222a582d71b634e8a3c67a67668083575e6 | [] | no_license | Moquetteman/ServeurMp3 | cd3351598e9dae095c597809ba78302b9edca2ee | efc2651c19e757c0c9ecaa9f1616162935e154e8 | refs/heads/master | 2020-04-10T04:00:58.616561 | 2015-04-07T15:05:08 | 2015-04-07T15:05:08 | 31,264,583 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 88,375 | h | // **********************************************************************
//
// Copyright (c) 2003-2013 ZeroC, Inc. All rights reserved.
//
// This copy of Ice is licensed to you under the terms described in the
// ICE_LICENSE file included in this distribution.
//
// **********************************************************************
//
// Ice version 3.5.1
//
// <auto-generated>
//
// Generated from file `ServeurIceMP3.ice'
//
// Warning: do not edit this file.
//
// </auto-generated>
//
#ifndef __ServeurIceMP3_h__
#define __ServeurIceMP3_h__
#include <Ice/ProxyF.h>
#include <Ice/ObjectF.h>
#include <Ice/Exception.h>
#include <Ice/LocalObject.h>
#include <Ice/StreamHelpers.h>
#include <Ice/Proxy.h>
#include <Ice/Object.h>
#include <Ice/Outgoing.h>
#include <Ice/OutgoingAsync.h>
#include <Ice/Incoming.h>
#include <Ice/Direct.h>
#include <IceUtil/ScopedArray.h>
#include <IceUtil/Optional.h>
#include <Ice/StreamF.h>
#include <Ice/UndefSysMacros.h>
#ifndef ICE_IGNORE_VERSION
# if ICE_INT_VERSION / 100 != 305
# error Ice version mismatch!
# endif
# if ICE_INT_VERSION % 100 > 50
# error Beta header file detected
# endif
# if ICE_INT_VERSION % 100 < 1
# error Ice patch level mismatch!
# endif
#endif
namespace IceProxy
{
namespace serveur
{
class ServeurIceMP3;
void __read(::IceInternal::BasicStream*, ::IceInternal::ProxyHandle< ::IceProxy::serveur::ServeurIceMP3>&);
::IceProxy::Ice::Object* upCast(::IceProxy::serveur::ServeurIceMP3*);
}
}
namespace serveur
{
class ServeurIceMP3;
bool operator==(const ServeurIceMP3&, const ServeurIceMP3&);
bool operator<(const ServeurIceMP3&, const ServeurIceMP3&);
::Ice::Object* upCast(::serveur::ServeurIceMP3*);
typedef ::IceInternal::Handle< ::serveur::ServeurIceMP3> ServeurIceMP3Ptr;
typedef ::IceInternal::ProxyHandle< ::IceProxy::serveur::ServeurIceMP3> ServeurIceMP3Prx;
void __patch(ServeurIceMP3Ptr&, const ::Ice::ObjectPtr&);
}
namespace serveur
{
typedef ::std::vector< ::std::string> listetitre;
typedef ::std::vector< ::std::string> listeauteur;
}
namespace serveur
{
class Callback_ServeurIceMP3_ajoutfichier_Base : virtual public ::IceInternal::CallbackBase { };
typedef ::IceUtil::Handle< Callback_ServeurIceMP3_ajoutfichier_Base> Callback_ServeurIceMP3_ajoutfichierPtr;
class Callback_ServeurIceMP3_recherche_Base : virtual public ::IceInternal::CallbackBase { };
typedef ::IceUtil::Handle< Callback_ServeurIceMP3_recherche_Base> Callback_ServeurIceMP3_recherchePtr;
class Callback_ServeurIceMP3_rechercheTitre_Base : virtual public ::IceInternal::CallbackBase { };
typedef ::IceUtil::Handle< Callback_ServeurIceMP3_rechercheTitre_Base> Callback_ServeurIceMP3_rechercheTitrePtr;
class Callback_ServeurIceMP3_rechercheAuteur_Base : virtual public ::IceInternal::CallbackBase { };
typedef ::IceUtil::Handle< Callback_ServeurIceMP3_rechercheAuteur_Base> Callback_ServeurIceMP3_rechercheAuteurPtr;
class Callback_ServeurIceMP3_suppression_Base : virtual public ::IceInternal::CallbackBase { };
typedef ::IceUtil::Handle< Callback_ServeurIceMP3_suppression_Base> Callback_ServeurIceMP3_suppressionPtr;
class Callback_ServeurIceMP3_lireMp3_Base : virtual public ::IceInternal::CallbackBase { };
typedef ::IceUtil::Handle< Callback_ServeurIceMP3_lireMp3_Base> Callback_ServeurIceMP3_lireMp3Ptr;
class Callback_ServeurIceMP3_lireMp3ParFichier_Base : virtual public ::IceInternal::CallbackBase { };
typedef ::IceUtil::Handle< Callback_ServeurIceMP3_lireMp3ParFichier_Base> Callback_ServeurIceMP3_lireMp3ParFichierPtr;
class Callback_ServeurIceMP3_stopMp3_Base : virtual public ::IceInternal::CallbackBase { };
typedef ::IceUtil::Handle< Callback_ServeurIceMP3_stopMp3_Base> Callback_ServeurIceMP3_stopMp3Ptr;
}
namespace IceProxy
{
namespace serveur
{
class ServeurIceMP3 : virtual public ::IceProxy::Ice::Object
{
public:
void ajoutfichier(const ::std::string& titre, const ::std::string& auteur, const ::std::string& fichier)
{
ajoutfichier(titre, auteur, fichier, 0);
}
void ajoutfichier(const ::std::string& titre, const ::std::string& auteur, const ::std::string& fichier, const ::Ice::Context& __ctx)
{
ajoutfichier(titre, auteur, fichier, &__ctx);
}
#ifdef ICE_CPP11
::Ice::AsyncResultPtr
begin_ajoutfichier(const ::std::string& titre, const ::std::string& auteur, const ::std::string& fichier, const ::IceInternal::Function<void ()>& __response, const ::IceInternal::Function<void (const ::Ice::Exception&)>& __exception = ::IceInternal::Function<void (const ::Ice::Exception&)>(), const ::IceInternal::Function<void (bool)>& __sent = ::IceInternal::Function<void (bool)>())
{
return begin_ajoutfichier(titre, auteur, fichier, 0, new ::IceInternal::Cpp11FnOnewayCallbackNC(__response, __exception, __sent));
}
::Ice::AsyncResultPtr
begin_ajoutfichier(const ::std::string& titre, const ::std::string& auteur, const ::std::string& fichier, const ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>& __completed, const ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>& __sent = ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>())
{
return begin_ajoutfichier(titre, auteur, fichier, 0, ::Ice::newCallback(__completed, __sent), 0);
}
::Ice::AsyncResultPtr
begin_ajoutfichier(const ::std::string& titre, const ::std::string& auteur, const ::std::string& fichier, const ::Ice::Context& __ctx, const ::IceInternal::Function<void ()>& __response, const ::IceInternal::Function<void (const ::Ice::Exception&)>& __exception = ::IceInternal::Function<void (const ::Ice::Exception&)>(), const ::IceInternal::Function<void (bool)>& __sent = ::IceInternal::Function<void (bool)>())
{
return begin_ajoutfichier(titre, auteur, fichier, &__ctx, new ::IceInternal::Cpp11FnOnewayCallbackNC(__response, __exception, __sent), 0);
}
::Ice::AsyncResultPtr
begin_ajoutfichier(const ::std::string& titre, const ::std::string& auteur, const ::std::string& fichier, const ::Ice::Context& __ctx, const ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>& __completed, const ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>& __sent = ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>())
{
return begin_ajoutfichier(titre, auteur, fichier, &__ctx, ::Ice::newCallback(__completed, __sent));
}
#endif
::Ice::AsyncResultPtr begin_ajoutfichier(const ::std::string& titre, const ::std::string& auteur, const ::std::string& fichier)
{
return begin_ajoutfichier(titre, auteur, fichier, 0, ::IceInternal::__dummyCallback, 0);
}
::Ice::AsyncResultPtr begin_ajoutfichier(const ::std::string& titre, const ::std::string& auteur, const ::std::string& fichier, const ::Ice::Context& __ctx)
{
return begin_ajoutfichier(titre, auteur, fichier, &__ctx, ::IceInternal::__dummyCallback, 0);
}
::Ice::AsyncResultPtr begin_ajoutfichier(const ::std::string& titre, const ::std::string& auteur, const ::std::string& fichier, const ::Ice::CallbackPtr& __del, const ::Ice::LocalObjectPtr& __cookie = 0)
{
return begin_ajoutfichier(titre, auteur, fichier, 0, __del, __cookie);
}
::Ice::AsyncResultPtr begin_ajoutfichier(const ::std::string& titre, const ::std::string& auteur, const ::std::string& fichier, const ::Ice::Context& __ctx, const ::Ice::CallbackPtr& __del, const ::Ice::LocalObjectPtr& __cookie = 0)
{
return begin_ajoutfichier(titre, auteur, fichier, &__ctx, __del, __cookie);
}
::Ice::AsyncResultPtr begin_ajoutfichier(const ::std::string& titre, const ::std::string& auteur, const ::std::string& fichier, const ::serveur::Callback_ServeurIceMP3_ajoutfichierPtr& __del, const ::Ice::LocalObjectPtr& __cookie = 0)
{
return begin_ajoutfichier(titre, auteur, fichier, 0, __del, __cookie);
}
::Ice::AsyncResultPtr begin_ajoutfichier(const ::std::string& titre, const ::std::string& auteur, const ::std::string& fichier, const ::Ice::Context& __ctx, const ::serveur::Callback_ServeurIceMP3_ajoutfichierPtr& __del, const ::Ice::LocalObjectPtr& __cookie = 0)
{
return begin_ajoutfichier(titre, auteur, fichier, &__ctx, __del, __cookie);
}
void end_ajoutfichier(const ::Ice::AsyncResultPtr&);
private:
void ajoutfichier(const ::std::string&, const ::std::string&, const ::std::string&, const ::Ice::Context*);
::Ice::AsyncResultPtr begin_ajoutfichier(const ::std::string&, const ::std::string&, const ::std::string&, const ::Ice::Context*, const ::IceInternal::CallbackBasePtr&, const ::Ice::LocalObjectPtr& __cookie = 0);
public:
::std::string recherche(const ::std::string& titre, const ::std::string& auteur)
{
return recherche(titre, auteur, 0);
}
::std::string recherche(const ::std::string& titre, const ::std::string& auteur, const ::Ice::Context& __ctx)
{
return recherche(titre, auteur, &__ctx);
}
#ifdef ICE_CPP11
::Ice::AsyncResultPtr
begin_recherche(const ::std::string& titre, const ::std::string& auteur, const ::IceInternal::Function<void (const ::std::string&)>& __response, const ::IceInternal::Function<void (const ::Ice::Exception&)>& __exception = ::IceInternal::Function<void (const ::Ice::Exception&)>(), const ::IceInternal::Function<void (bool)>& __sent = ::IceInternal::Function<void (bool)>())
{
return __begin_recherche(titre, auteur, 0, __response, __exception, __sent);
}
::Ice::AsyncResultPtr
begin_recherche(const ::std::string& titre, const ::std::string& auteur, const ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>& __completed, const ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>& __sent = ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>())
{
return begin_recherche(titre, auteur, 0, ::Ice::newCallback(__completed, __sent), 0);
}
::Ice::AsyncResultPtr
begin_recherche(const ::std::string& titre, const ::std::string& auteur, const ::Ice::Context& __ctx, const ::IceInternal::Function<void (const ::std::string&)>& __response, const ::IceInternal::Function<void (const ::Ice::Exception&)>& __exception = ::IceInternal::Function<void (const ::Ice::Exception&)>(), const ::IceInternal::Function<void (bool)>& __sent = ::IceInternal::Function<void (bool)>())
{
return __begin_recherche(titre, auteur, &__ctx, __response, __exception, __sent);
}
::Ice::AsyncResultPtr
begin_recherche(const ::std::string& titre, const ::std::string& auteur, const ::Ice::Context& __ctx, const ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>& __completed, const ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>& __sent = ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>())
{
return begin_recherche(titre, auteur, &__ctx, ::Ice::newCallback(__completed, __sent));
}
private:
::Ice::AsyncResultPtr __begin_recherche(const ::std::string& titre, const ::std::string& auteur, const ::Ice::Context* __ctx, const ::IceInternal::Function<void (const ::std::string&)>& __response, const ::IceInternal::Function<void (const ::Ice::Exception&)>& __exception, const ::IceInternal::Function<void (bool)>& __sent)
{
class Cpp11CB : public ::IceInternal::Cpp11FnCallbackNC
{
public:
Cpp11CB(const ::std::function<void (const ::std::string&)>& responseFunc, const ::std::function<void (const ::Ice::Exception&)>& exceptionFunc, const ::std::function<void (bool)>& sentFunc) :
::IceInternal::Cpp11FnCallbackNC(exceptionFunc, sentFunc),
_response(responseFunc)
{
CallbackBase::checkCallback(true, responseFunc || exceptionFunc != nullptr);
}
virtual void __completed(const ::Ice::AsyncResultPtr& __result) const
{
::serveur::ServeurIceMP3Prx __proxy = ::serveur::ServeurIceMP3Prx::uncheckedCast(__result->getProxy());
::std::string __ret;
try
{
__ret = __proxy->end_recherche(__result);
}
catch(::Ice::Exception& ex)
{
Cpp11FnCallbackNC::__exception(__result, ex);
return;
}
if(_response != nullptr)
{
_response(__ret);
}
}
private:
::std::function<void (const ::std::string&)> _response;
};
return begin_recherche(titre, auteur, __ctx, new Cpp11CB(__response, __exception, __sent));
}
public:
#endif
::Ice::AsyncResultPtr begin_recherche(const ::std::string& titre, const ::std::string& auteur)
{
return begin_recherche(titre, auteur, 0, ::IceInternal::__dummyCallback, 0);
}
::Ice::AsyncResultPtr begin_recherche(const ::std::string& titre, const ::std::string& auteur, const ::Ice::Context& __ctx)
{
return begin_recherche(titre, auteur, &__ctx, ::IceInternal::__dummyCallback, 0);
}
::Ice::AsyncResultPtr begin_recherche(const ::std::string& titre, const ::std::string& auteur, const ::Ice::CallbackPtr& __del, const ::Ice::LocalObjectPtr& __cookie = 0)
{
return begin_recherche(titre, auteur, 0, __del, __cookie);
}
::Ice::AsyncResultPtr begin_recherche(const ::std::string& titre, const ::std::string& auteur, const ::Ice::Context& __ctx, const ::Ice::CallbackPtr& __del, const ::Ice::LocalObjectPtr& __cookie = 0)
{
return begin_recherche(titre, auteur, &__ctx, __del, __cookie);
}
::Ice::AsyncResultPtr begin_recherche(const ::std::string& titre, const ::std::string& auteur, const ::serveur::Callback_ServeurIceMP3_recherchePtr& __del, const ::Ice::LocalObjectPtr& __cookie = 0)
{
return begin_recherche(titre, auteur, 0, __del, __cookie);
}
::Ice::AsyncResultPtr begin_recherche(const ::std::string& titre, const ::std::string& auteur, const ::Ice::Context& __ctx, const ::serveur::Callback_ServeurIceMP3_recherchePtr& __del, const ::Ice::LocalObjectPtr& __cookie = 0)
{
return begin_recherche(titre, auteur, &__ctx, __del, __cookie);
}
::std::string end_recherche(const ::Ice::AsyncResultPtr&);
private:
::std::string recherche(const ::std::string&, const ::std::string&, const ::Ice::Context*);
::Ice::AsyncResultPtr begin_recherche(const ::std::string&, const ::std::string&, const ::Ice::Context*, const ::IceInternal::CallbackBasePtr&, const ::Ice::LocalObjectPtr& __cookie = 0);
public:
::serveur::listetitre rechercheTitre(const ::std::string& titre)
{
return rechercheTitre(titre, 0);
}
::serveur::listetitre rechercheTitre(const ::std::string& titre, const ::Ice::Context& __ctx)
{
return rechercheTitre(titre, &__ctx);
}
#ifdef ICE_CPP11
::Ice::AsyncResultPtr
begin_rechercheTitre(const ::std::string& titre, const ::IceInternal::Function<void (const ::serveur::listetitre&)>& __response, const ::IceInternal::Function<void (const ::Ice::Exception&)>& __exception = ::IceInternal::Function<void (const ::Ice::Exception&)>(), const ::IceInternal::Function<void (bool)>& __sent = ::IceInternal::Function<void (bool)>())
{
return __begin_rechercheTitre(titre, 0, __response, __exception, __sent);
}
::Ice::AsyncResultPtr
begin_rechercheTitre(const ::std::string& titre, const ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>& __completed, const ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>& __sent = ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>())
{
return begin_rechercheTitre(titre, 0, ::Ice::newCallback(__completed, __sent), 0);
}
::Ice::AsyncResultPtr
begin_rechercheTitre(const ::std::string& titre, const ::Ice::Context& __ctx, const ::IceInternal::Function<void (const ::serveur::listetitre&)>& __response, const ::IceInternal::Function<void (const ::Ice::Exception&)>& __exception = ::IceInternal::Function<void (const ::Ice::Exception&)>(), const ::IceInternal::Function<void (bool)>& __sent = ::IceInternal::Function<void (bool)>())
{
return __begin_rechercheTitre(titre, &__ctx, __response, __exception, __sent);
}
::Ice::AsyncResultPtr
begin_rechercheTitre(const ::std::string& titre, const ::Ice::Context& __ctx, const ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>& __completed, const ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>& __sent = ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>())
{
return begin_rechercheTitre(titre, &__ctx, ::Ice::newCallback(__completed, __sent));
}
private:
::Ice::AsyncResultPtr __begin_rechercheTitre(const ::std::string& titre, const ::Ice::Context* __ctx, const ::IceInternal::Function<void (const ::serveur::listetitre&)>& __response, const ::IceInternal::Function<void (const ::Ice::Exception&)>& __exception, const ::IceInternal::Function<void (bool)>& __sent)
{
class Cpp11CB : public ::IceInternal::Cpp11FnCallbackNC
{
public:
Cpp11CB(const ::std::function<void (const ::serveur::listetitre&)>& responseFunc, const ::std::function<void (const ::Ice::Exception&)>& exceptionFunc, const ::std::function<void (bool)>& sentFunc) :
::IceInternal::Cpp11FnCallbackNC(exceptionFunc, sentFunc),
_response(responseFunc)
{
CallbackBase::checkCallback(true, responseFunc || exceptionFunc != nullptr);
}
virtual void __completed(const ::Ice::AsyncResultPtr& __result) const
{
::serveur::ServeurIceMP3Prx __proxy = ::serveur::ServeurIceMP3Prx::uncheckedCast(__result->getProxy());
::serveur::listetitre __ret;
try
{
__ret = __proxy->end_rechercheTitre(__result);
}
catch(::Ice::Exception& ex)
{
Cpp11FnCallbackNC::__exception(__result, ex);
return;
}
if(_response != nullptr)
{
_response(__ret);
}
}
private:
::std::function<void (const ::serveur::listetitre&)> _response;
};
return begin_rechercheTitre(titre, __ctx, new Cpp11CB(__response, __exception, __sent));
}
public:
#endif
::Ice::AsyncResultPtr begin_rechercheTitre(const ::std::string& titre)
{
return begin_rechercheTitre(titre, 0, ::IceInternal::__dummyCallback, 0);
}
::Ice::AsyncResultPtr begin_rechercheTitre(const ::std::string& titre, const ::Ice::Context& __ctx)
{
return begin_rechercheTitre(titre, &__ctx, ::IceInternal::__dummyCallback, 0);
}
::Ice::AsyncResultPtr begin_rechercheTitre(const ::std::string& titre, const ::Ice::CallbackPtr& __del, const ::Ice::LocalObjectPtr& __cookie = 0)
{
return begin_rechercheTitre(titre, 0, __del, __cookie);
}
::Ice::AsyncResultPtr begin_rechercheTitre(const ::std::string& titre, const ::Ice::Context& __ctx, const ::Ice::CallbackPtr& __del, const ::Ice::LocalObjectPtr& __cookie = 0)
{
return begin_rechercheTitre(titre, &__ctx, __del, __cookie);
}
::Ice::AsyncResultPtr begin_rechercheTitre(const ::std::string& titre, const ::serveur::Callback_ServeurIceMP3_rechercheTitrePtr& __del, const ::Ice::LocalObjectPtr& __cookie = 0)
{
return begin_rechercheTitre(titre, 0, __del, __cookie);
}
::Ice::AsyncResultPtr begin_rechercheTitre(const ::std::string& titre, const ::Ice::Context& __ctx, const ::serveur::Callback_ServeurIceMP3_rechercheTitrePtr& __del, const ::Ice::LocalObjectPtr& __cookie = 0)
{
return begin_rechercheTitre(titre, &__ctx, __del, __cookie);
}
::serveur::listetitre end_rechercheTitre(const ::Ice::AsyncResultPtr&);
private:
::serveur::listetitre rechercheTitre(const ::std::string&, const ::Ice::Context*);
::Ice::AsyncResultPtr begin_rechercheTitre(const ::std::string&, const ::Ice::Context*, const ::IceInternal::CallbackBasePtr&, const ::Ice::LocalObjectPtr& __cookie = 0);
public:
::serveur::listeauteur rechercheAuteur(const ::std::string& auteur)
{
return rechercheAuteur(auteur, 0);
}
::serveur::listeauteur rechercheAuteur(const ::std::string& auteur, const ::Ice::Context& __ctx)
{
return rechercheAuteur(auteur, &__ctx);
}
#ifdef ICE_CPP11
::Ice::AsyncResultPtr
begin_rechercheAuteur(const ::std::string& auteur, const ::IceInternal::Function<void (const ::serveur::listeauteur&)>& __response, const ::IceInternal::Function<void (const ::Ice::Exception&)>& __exception = ::IceInternal::Function<void (const ::Ice::Exception&)>(), const ::IceInternal::Function<void (bool)>& __sent = ::IceInternal::Function<void (bool)>())
{
return __begin_rechercheAuteur(auteur, 0, __response, __exception, __sent);
}
::Ice::AsyncResultPtr
begin_rechercheAuteur(const ::std::string& auteur, const ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>& __completed, const ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>& __sent = ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>())
{
return begin_rechercheAuteur(auteur, 0, ::Ice::newCallback(__completed, __sent), 0);
}
::Ice::AsyncResultPtr
begin_rechercheAuteur(const ::std::string& auteur, const ::Ice::Context& __ctx, const ::IceInternal::Function<void (const ::serveur::listeauteur&)>& __response, const ::IceInternal::Function<void (const ::Ice::Exception&)>& __exception = ::IceInternal::Function<void (const ::Ice::Exception&)>(), const ::IceInternal::Function<void (bool)>& __sent = ::IceInternal::Function<void (bool)>())
{
return __begin_rechercheAuteur(auteur, &__ctx, __response, __exception, __sent);
}
::Ice::AsyncResultPtr
begin_rechercheAuteur(const ::std::string& auteur, const ::Ice::Context& __ctx, const ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>& __completed, const ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>& __sent = ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>())
{
return begin_rechercheAuteur(auteur, &__ctx, ::Ice::newCallback(__completed, __sent));
}
private:
::Ice::AsyncResultPtr __begin_rechercheAuteur(const ::std::string& auteur, const ::Ice::Context* __ctx, const ::IceInternal::Function<void (const ::serveur::listeauteur&)>& __response, const ::IceInternal::Function<void (const ::Ice::Exception&)>& __exception, const ::IceInternal::Function<void (bool)>& __sent)
{
class Cpp11CB : public ::IceInternal::Cpp11FnCallbackNC
{
public:
Cpp11CB(const ::std::function<void (const ::serveur::listeauteur&)>& responseFunc, const ::std::function<void (const ::Ice::Exception&)>& exceptionFunc, const ::std::function<void (bool)>& sentFunc) :
::IceInternal::Cpp11FnCallbackNC(exceptionFunc, sentFunc),
_response(responseFunc)
{
CallbackBase::checkCallback(true, responseFunc || exceptionFunc != nullptr);
}
virtual void __completed(const ::Ice::AsyncResultPtr& __result) const
{
::serveur::ServeurIceMP3Prx __proxy = ::serveur::ServeurIceMP3Prx::uncheckedCast(__result->getProxy());
::serveur::listeauteur __ret;
try
{
__ret = __proxy->end_rechercheAuteur(__result);
}
catch(::Ice::Exception& ex)
{
Cpp11FnCallbackNC::__exception(__result, ex);
return;
}
if(_response != nullptr)
{
_response(__ret);
}
}
private:
::std::function<void (const ::serveur::listeauteur&)> _response;
};
return begin_rechercheAuteur(auteur, __ctx, new Cpp11CB(__response, __exception, __sent));
}
public:
#endif
::Ice::AsyncResultPtr begin_rechercheAuteur(const ::std::string& auteur)
{
return begin_rechercheAuteur(auteur, 0, ::IceInternal::__dummyCallback, 0);
}
::Ice::AsyncResultPtr begin_rechercheAuteur(const ::std::string& auteur, const ::Ice::Context& __ctx)
{
return begin_rechercheAuteur(auteur, &__ctx, ::IceInternal::__dummyCallback, 0);
}
::Ice::AsyncResultPtr begin_rechercheAuteur(const ::std::string& auteur, const ::Ice::CallbackPtr& __del, const ::Ice::LocalObjectPtr& __cookie = 0)
{
return begin_rechercheAuteur(auteur, 0, __del, __cookie);
}
::Ice::AsyncResultPtr begin_rechercheAuteur(const ::std::string& auteur, const ::Ice::Context& __ctx, const ::Ice::CallbackPtr& __del, const ::Ice::LocalObjectPtr& __cookie = 0)
{
return begin_rechercheAuteur(auteur, &__ctx, __del, __cookie);
}
::Ice::AsyncResultPtr begin_rechercheAuteur(const ::std::string& auteur, const ::serveur::Callback_ServeurIceMP3_rechercheAuteurPtr& __del, const ::Ice::LocalObjectPtr& __cookie = 0)
{
return begin_rechercheAuteur(auteur, 0, __del, __cookie);
}
::Ice::AsyncResultPtr begin_rechercheAuteur(const ::std::string& auteur, const ::Ice::Context& __ctx, const ::serveur::Callback_ServeurIceMP3_rechercheAuteurPtr& __del, const ::Ice::LocalObjectPtr& __cookie = 0)
{
return begin_rechercheAuteur(auteur, &__ctx, __del, __cookie);
}
::serveur::listeauteur end_rechercheAuteur(const ::Ice::AsyncResultPtr&);
private:
::serveur::listeauteur rechercheAuteur(const ::std::string&, const ::Ice::Context*);
::Ice::AsyncResultPtr begin_rechercheAuteur(const ::std::string&, const ::Ice::Context*, const ::IceInternal::CallbackBasePtr&, const ::Ice::LocalObjectPtr& __cookie = 0);
public:
void suppression(const ::std::string& titre, const ::std::string& auteur)
{
suppression(titre, auteur, 0);
}
void suppression(const ::std::string& titre, const ::std::string& auteur, const ::Ice::Context& __ctx)
{
suppression(titre, auteur, &__ctx);
}
#ifdef ICE_CPP11
::Ice::AsyncResultPtr
begin_suppression(const ::std::string& titre, const ::std::string& auteur, const ::IceInternal::Function<void ()>& __response, const ::IceInternal::Function<void (const ::Ice::Exception&)>& __exception = ::IceInternal::Function<void (const ::Ice::Exception&)>(), const ::IceInternal::Function<void (bool)>& __sent = ::IceInternal::Function<void (bool)>())
{
return begin_suppression(titre, auteur, 0, new ::IceInternal::Cpp11FnOnewayCallbackNC(__response, __exception, __sent));
}
::Ice::AsyncResultPtr
begin_suppression(const ::std::string& titre, const ::std::string& auteur, const ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>& __completed, const ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>& __sent = ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>())
{
return begin_suppression(titre, auteur, 0, ::Ice::newCallback(__completed, __sent), 0);
}
::Ice::AsyncResultPtr
begin_suppression(const ::std::string& titre, const ::std::string& auteur, const ::Ice::Context& __ctx, const ::IceInternal::Function<void ()>& __response, const ::IceInternal::Function<void (const ::Ice::Exception&)>& __exception = ::IceInternal::Function<void (const ::Ice::Exception&)>(), const ::IceInternal::Function<void (bool)>& __sent = ::IceInternal::Function<void (bool)>())
{
return begin_suppression(titre, auteur, &__ctx, new ::IceInternal::Cpp11FnOnewayCallbackNC(__response, __exception, __sent), 0);
}
::Ice::AsyncResultPtr
begin_suppression(const ::std::string& titre, const ::std::string& auteur, const ::Ice::Context& __ctx, const ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>& __completed, const ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>& __sent = ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>())
{
return begin_suppression(titre, auteur, &__ctx, ::Ice::newCallback(__completed, __sent));
}
#endif
::Ice::AsyncResultPtr begin_suppression(const ::std::string& titre, const ::std::string& auteur)
{
return begin_suppression(titre, auteur, 0, ::IceInternal::__dummyCallback, 0);
}
::Ice::AsyncResultPtr begin_suppression(const ::std::string& titre, const ::std::string& auteur, const ::Ice::Context& __ctx)
{
return begin_suppression(titre, auteur, &__ctx, ::IceInternal::__dummyCallback, 0);
}
::Ice::AsyncResultPtr begin_suppression(const ::std::string& titre, const ::std::string& auteur, const ::Ice::CallbackPtr& __del, const ::Ice::LocalObjectPtr& __cookie = 0)
{
return begin_suppression(titre, auteur, 0, __del, __cookie);
}
::Ice::AsyncResultPtr begin_suppression(const ::std::string& titre, const ::std::string& auteur, const ::Ice::Context& __ctx, const ::Ice::CallbackPtr& __del, const ::Ice::LocalObjectPtr& __cookie = 0)
{
return begin_suppression(titre, auteur, &__ctx, __del, __cookie);
}
::Ice::AsyncResultPtr begin_suppression(const ::std::string& titre, const ::std::string& auteur, const ::serveur::Callback_ServeurIceMP3_suppressionPtr& __del, const ::Ice::LocalObjectPtr& __cookie = 0)
{
return begin_suppression(titre, auteur, 0, __del, __cookie);
}
::Ice::AsyncResultPtr begin_suppression(const ::std::string& titre, const ::std::string& auteur, const ::Ice::Context& __ctx, const ::serveur::Callback_ServeurIceMP3_suppressionPtr& __del, const ::Ice::LocalObjectPtr& __cookie = 0)
{
return begin_suppression(titre, auteur, &__ctx, __del, __cookie);
}
void end_suppression(const ::Ice::AsyncResultPtr&);
private:
void suppression(const ::std::string&, const ::std::string&, const ::Ice::Context*);
::Ice::AsyncResultPtr begin_suppression(const ::std::string&, const ::std::string&, const ::Ice::Context*, const ::IceInternal::CallbackBasePtr&, const ::Ice::LocalObjectPtr& __cookie = 0);
public:
::std::string lireMp3(const ::std::string& titre, const ::std::string& auteur)
{
return lireMp3(titre, auteur, 0);
}
::std::string lireMp3(const ::std::string& titre, const ::std::string& auteur, const ::Ice::Context& __ctx)
{
return lireMp3(titre, auteur, &__ctx);
}
#ifdef ICE_CPP11
::Ice::AsyncResultPtr
begin_lireMp3(const ::std::string& titre, const ::std::string& auteur, const ::IceInternal::Function<void (const ::std::string&)>& __response, const ::IceInternal::Function<void (const ::Ice::Exception&)>& __exception = ::IceInternal::Function<void (const ::Ice::Exception&)>(), const ::IceInternal::Function<void (bool)>& __sent = ::IceInternal::Function<void (bool)>())
{
return __begin_lireMp3(titre, auteur, 0, __response, __exception, __sent);
}
::Ice::AsyncResultPtr
begin_lireMp3(const ::std::string& titre, const ::std::string& auteur, const ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>& __completed, const ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>& __sent = ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>())
{
return begin_lireMp3(titre, auteur, 0, ::Ice::newCallback(__completed, __sent), 0);
}
::Ice::AsyncResultPtr
begin_lireMp3(const ::std::string& titre, const ::std::string& auteur, const ::Ice::Context& __ctx, const ::IceInternal::Function<void (const ::std::string&)>& __response, const ::IceInternal::Function<void (const ::Ice::Exception&)>& __exception = ::IceInternal::Function<void (const ::Ice::Exception&)>(), const ::IceInternal::Function<void (bool)>& __sent = ::IceInternal::Function<void (bool)>())
{
return __begin_lireMp3(titre, auteur, &__ctx, __response, __exception, __sent);
}
::Ice::AsyncResultPtr
begin_lireMp3(const ::std::string& titre, const ::std::string& auteur, const ::Ice::Context& __ctx, const ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>& __completed, const ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>& __sent = ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>())
{
return begin_lireMp3(titre, auteur, &__ctx, ::Ice::newCallback(__completed, __sent));
}
private:
::Ice::AsyncResultPtr __begin_lireMp3(const ::std::string& titre, const ::std::string& auteur, const ::Ice::Context* __ctx, const ::IceInternal::Function<void (const ::std::string&)>& __response, const ::IceInternal::Function<void (const ::Ice::Exception&)>& __exception, const ::IceInternal::Function<void (bool)>& __sent)
{
class Cpp11CB : public ::IceInternal::Cpp11FnCallbackNC
{
public:
Cpp11CB(const ::std::function<void (const ::std::string&)>& responseFunc, const ::std::function<void (const ::Ice::Exception&)>& exceptionFunc, const ::std::function<void (bool)>& sentFunc) :
::IceInternal::Cpp11FnCallbackNC(exceptionFunc, sentFunc),
_response(responseFunc)
{
CallbackBase::checkCallback(true, responseFunc || exceptionFunc != nullptr);
}
virtual void __completed(const ::Ice::AsyncResultPtr& __result) const
{
::serveur::ServeurIceMP3Prx __proxy = ::serveur::ServeurIceMP3Prx::uncheckedCast(__result->getProxy());
::std::string __ret;
try
{
__ret = __proxy->end_lireMp3(__result);
}
catch(::Ice::Exception& ex)
{
Cpp11FnCallbackNC::__exception(__result, ex);
return;
}
if(_response != nullptr)
{
_response(__ret);
}
}
private:
::std::function<void (const ::std::string&)> _response;
};
return begin_lireMp3(titre, auteur, __ctx, new Cpp11CB(__response, __exception, __sent));
}
public:
#endif
::Ice::AsyncResultPtr begin_lireMp3(const ::std::string& titre, const ::std::string& auteur)
{
return begin_lireMp3(titre, auteur, 0, ::IceInternal::__dummyCallback, 0);
}
::Ice::AsyncResultPtr begin_lireMp3(const ::std::string& titre, const ::std::string& auteur, const ::Ice::Context& __ctx)
{
return begin_lireMp3(titre, auteur, &__ctx, ::IceInternal::__dummyCallback, 0);
}
::Ice::AsyncResultPtr begin_lireMp3(const ::std::string& titre, const ::std::string& auteur, const ::Ice::CallbackPtr& __del, const ::Ice::LocalObjectPtr& __cookie = 0)
{
return begin_lireMp3(titre, auteur, 0, __del, __cookie);
}
::Ice::AsyncResultPtr begin_lireMp3(const ::std::string& titre, const ::std::string& auteur, const ::Ice::Context& __ctx, const ::Ice::CallbackPtr& __del, const ::Ice::LocalObjectPtr& __cookie = 0)
{
return begin_lireMp3(titre, auteur, &__ctx, __del, __cookie);
}
::Ice::AsyncResultPtr begin_lireMp3(const ::std::string& titre, const ::std::string& auteur, const ::serveur::Callback_ServeurIceMP3_lireMp3Ptr& __del, const ::Ice::LocalObjectPtr& __cookie = 0)
{
return begin_lireMp3(titre, auteur, 0, __del, __cookie);
}
::Ice::AsyncResultPtr begin_lireMp3(const ::std::string& titre, const ::std::string& auteur, const ::Ice::Context& __ctx, const ::serveur::Callback_ServeurIceMP3_lireMp3Ptr& __del, const ::Ice::LocalObjectPtr& __cookie = 0)
{
return begin_lireMp3(titre, auteur, &__ctx, __del, __cookie);
}
::std::string end_lireMp3(const ::Ice::AsyncResultPtr&);
private:
::std::string lireMp3(const ::std::string&, const ::std::string&, const ::Ice::Context*);
::Ice::AsyncResultPtr begin_lireMp3(const ::std::string&, const ::std::string&, const ::Ice::Context*, const ::IceInternal::CallbackBasePtr&, const ::Ice::LocalObjectPtr& __cookie = 0);
public:
::std::string lireMp3ParFichier(const ::std::string& fichier)
{
return lireMp3ParFichier(fichier, 0);
}
::std::string lireMp3ParFichier(const ::std::string& fichier, const ::Ice::Context& __ctx)
{
return lireMp3ParFichier(fichier, &__ctx);
}
#ifdef ICE_CPP11
::Ice::AsyncResultPtr
begin_lireMp3ParFichier(const ::std::string& fichier, const ::IceInternal::Function<void (const ::std::string&)>& __response, const ::IceInternal::Function<void (const ::Ice::Exception&)>& __exception = ::IceInternal::Function<void (const ::Ice::Exception&)>(), const ::IceInternal::Function<void (bool)>& __sent = ::IceInternal::Function<void (bool)>())
{
return __begin_lireMp3ParFichier(fichier, 0, __response, __exception, __sent);
}
::Ice::AsyncResultPtr
begin_lireMp3ParFichier(const ::std::string& fichier, const ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>& __completed, const ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>& __sent = ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>())
{
return begin_lireMp3ParFichier(fichier, 0, ::Ice::newCallback(__completed, __sent), 0);
}
::Ice::AsyncResultPtr
begin_lireMp3ParFichier(const ::std::string& fichier, const ::Ice::Context& __ctx, const ::IceInternal::Function<void (const ::std::string&)>& __response, const ::IceInternal::Function<void (const ::Ice::Exception&)>& __exception = ::IceInternal::Function<void (const ::Ice::Exception&)>(), const ::IceInternal::Function<void (bool)>& __sent = ::IceInternal::Function<void (bool)>())
{
return __begin_lireMp3ParFichier(fichier, &__ctx, __response, __exception, __sent);
}
::Ice::AsyncResultPtr
begin_lireMp3ParFichier(const ::std::string& fichier, const ::Ice::Context& __ctx, const ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>& __completed, const ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>& __sent = ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>())
{
return begin_lireMp3ParFichier(fichier, &__ctx, ::Ice::newCallback(__completed, __sent));
}
private:
::Ice::AsyncResultPtr __begin_lireMp3ParFichier(const ::std::string& fichier, const ::Ice::Context* __ctx, const ::IceInternal::Function<void (const ::std::string&)>& __response, const ::IceInternal::Function<void (const ::Ice::Exception&)>& __exception, const ::IceInternal::Function<void (bool)>& __sent)
{
class Cpp11CB : public ::IceInternal::Cpp11FnCallbackNC
{
public:
Cpp11CB(const ::std::function<void (const ::std::string&)>& responseFunc, const ::std::function<void (const ::Ice::Exception&)>& exceptionFunc, const ::std::function<void (bool)>& sentFunc) :
::IceInternal::Cpp11FnCallbackNC(exceptionFunc, sentFunc),
_response(responseFunc)
{
CallbackBase::checkCallback(true, responseFunc || exceptionFunc != nullptr);
}
virtual void __completed(const ::Ice::AsyncResultPtr& __result) const
{
::serveur::ServeurIceMP3Prx __proxy = ::serveur::ServeurIceMP3Prx::uncheckedCast(__result->getProxy());
::std::string __ret;
try
{
__ret = __proxy->end_lireMp3ParFichier(__result);
}
catch(::Ice::Exception& ex)
{
Cpp11FnCallbackNC::__exception(__result, ex);
return;
}
if(_response != nullptr)
{
_response(__ret);
}
}
private:
::std::function<void (const ::std::string&)> _response;
};
return begin_lireMp3ParFichier(fichier, __ctx, new Cpp11CB(__response, __exception, __sent));
}
public:
#endif
::Ice::AsyncResultPtr begin_lireMp3ParFichier(const ::std::string& fichier)
{
return begin_lireMp3ParFichier(fichier, 0, ::IceInternal::__dummyCallback, 0);
}
::Ice::AsyncResultPtr begin_lireMp3ParFichier(const ::std::string& fichier, const ::Ice::Context& __ctx)
{
return begin_lireMp3ParFichier(fichier, &__ctx, ::IceInternal::__dummyCallback, 0);
}
::Ice::AsyncResultPtr begin_lireMp3ParFichier(const ::std::string& fichier, const ::Ice::CallbackPtr& __del, const ::Ice::LocalObjectPtr& __cookie = 0)
{
return begin_lireMp3ParFichier(fichier, 0, __del, __cookie);
}
::Ice::AsyncResultPtr begin_lireMp3ParFichier(const ::std::string& fichier, const ::Ice::Context& __ctx, const ::Ice::CallbackPtr& __del, const ::Ice::LocalObjectPtr& __cookie = 0)
{
return begin_lireMp3ParFichier(fichier, &__ctx, __del, __cookie);
}
::Ice::AsyncResultPtr begin_lireMp3ParFichier(const ::std::string& fichier, const ::serveur::Callback_ServeurIceMP3_lireMp3ParFichierPtr& __del, const ::Ice::LocalObjectPtr& __cookie = 0)
{
return begin_lireMp3ParFichier(fichier, 0, __del, __cookie);
}
::Ice::AsyncResultPtr begin_lireMp3ParFichier(const ::std::string& fichier, const ::Ice::Context& __ctx, const ::serveur::Callback_ServeurIceMP3_lireMp3ParFichierPtr& __del, const ::Ice::LocalObjectPtr& __cookie = 0)
{
return begin_lireMp3ParFichier(fichier, &__ctx, __del, __cookie);
}
::std::string end_lireMp3ParFichier(const ::Ice::AsyncResultPtr&);
private:
::std::string lireMp3ParFichier(const ::std::string&, const ::Ice::Context*);
::Ice::AsyncResultPtr begin_lireMp3ParFichier(const ::std::string&, const ::Ice::Context*, const ::IceInternal::CallbackBasePtr&, const ::Ice::LocalObjectPtr& __cookie = 0);
public:
bool stopMp3(const ::std::string& nom)
{
return stopMp3(nom, 0);
}
bool stopMp3(const ::std::string& nom, const ::Ice::Context& __ctx)
{
return stopMp3(nom, &__ctx);
}
#ifdef ICE_CPP11
::Ice::AsyncResultPtr
begin_stopMp3(const ::std::string& nom, const ::IceInternal::Function<void (bool)>& __response, const ::IceInternal::Function<void (const ::Ice::Exception&)>& __exception = ::IceInternal::Function<void (const ::Ice::Exception&)>(), const ::IceInternal::Function<void (bool)>& __sent = ::IceInternal::Function<void (bool)>())
{
return __begin_stopMp3(nom, 0, __response, __exception, __sent);
}
::Ice::AsyncResultPtr
begin_stopMp3(const ::std::string& nom, const ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>& __completed, const ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>& __sent = ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>())
{
return begin_stopMp3(nom, 0, ::Ice::newCallback(__completed, __sent), 0);
}
::Ice::AsyncResultPtr
begin_stopMp3(const ::std::string& nom, const ::Ice::Context& __ctx, const ::IceInternal::Function<void (bool)>& __response, const ::IceInternal::Function<void (const ::Ice::Exception&)>& __exception = ::IceInternal::Function<void (const ::Ice::Exception&)>(), const ::IceInternal::Function<void (bool)>& __sent = ::IceInternal::Function<void (bool)>())
{
return __begin_stopMp3(nom, &__ctx, __response, __exception, __sent);
}
::Ice::AsyncResultPtr
begin_stopMp3(const ::std::string& nom, const ::Ice::Context& __ctx, const ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>& __completed, const ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>& __sent = ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>())
{
return begin_stopMp3(nom, &__ctx, ::Ice::newCallback(__completed, __sent));
}
private:
::Ice::AsyncResultPtr __begin_stopMp3(const ::std::string& nom, const ::Ice::Context* __ctx, const ::IceInternal::Function<void (bool)>& __response, const ::IceInternal::Function<void (const ::Ice::Exception&)>& __exception, const ::IceInternal::Function<void (bool)>& __sent)
{
class Cpp11CB : public ::IceInternal::Cpp11FnCallbackNC
{
public:
Cpp11CB(const ::std::function<void (bool)>& responseFunc, const ::std::function<void (const ::Ice::Exception&)>& exceptionFunc, const ::std::function<void (bool)>& sentFunc) :
::IceInternal::Cpp11FnCallbackNC(exceptionFunc, sentFunc),
_response(responseFunc)
{
CallbackBase::checkCallback(true, responseFunc || exceptionFunc != nullptr);
}
virtual void __completed(const ::Ice::AsyncResultPtr& __result) const
{
::serveur::ServeurIceMP3Prx __proxy = ::serveur::ServeurIceMP3Prx::uncheckedCast(__result->getProxy());
bool __ret;
try
{
__ret = __proxy->end_stopMp3(__result);
}
catch(::Ice::Exception& ex)
{
Cpp11FnCallbackNC::__exception(__result, ex);
return;
}
if(_response != nullptr)
{
_response(__ret);
}
}
private:
::std::function<void (bool)> _response;
};
return begin_stopMp3(nom, __ctx, new Cpp11CB(__response, __exception, __sent));
}
public:
#endif
::Ice::AsyncResultPtr begin_stopMp3(const ::std::string& nom)
{
return begin_stopMp3(nom, 0, ::IceInternal::__dummyCallback, 0);
}
::Ice::AsyncResultPtr begin_stopMp3(const ::std::string& nom, const ::Ice::Context& __ctx)
{
return begin_stopMp3(nom, &__ctx, ::IceInternal::__dummyCallback, 0);
}
::Ice::AsyncResultPtr begin_stopMp3(const ::std::string& nom, const ::Ice::CallbackPtr& __del, const ::Ice::LocalObjectPtr& __cookie = 0)
{
return begin_stopMp3(nom, 0, __del, __cookie);
}
::Ice::AsyncResultPtr begin_stopMp3(const ::std::string& nom, const ::Ice::Context& __ctx, const ::Ice::CallbackPtr& __del, const ::Ice::LocalObjectPtr& __cookie = 0)
{
return begin_stopMp3(nom, &__ctx, __del, __cookie);
}
::Ice::AsyncResultPtr begin_stopMp3(const ::std::string& nom, const ::serveur::Callback_ServeurIceMP3_stopMp3Ptr& __del, const ::Ice::LocalObjectPtr& __cookie = 0)
{
return begin_stopMp3(nom, 0, __del, __cookie);
}
::Ice::AsyncResultPtr begin_stopMp3(const ::std::string& nom, const ::Ice::Context& __ctx, const ::serveur::Callback_ServeurIceMP3_stopMp3Ptr& __del, const ::Ice::LocalObjectPtr& __cookie = 0)
{
return begin_stopMp3(nom, &__ctx, __del, __cookie);
}
bool end_stopMp3(const ::Ice::AsyncResultPtr&);
private:
bool stopMp3(const ::std::string&, const ::Ice::Context*);
::Ice::AsyncResultPtr begin_stopMp3(const ::std::string&, const ::Ice::Context*, const ::IceInternal::CallbackBasePtr&, const ::Ice::LocalObjectPtr& __cookie = 0);
public:
::IceInternal::ProxyHandle<ServeurIceMP3> ice_context(const ::Ice::Context& __context) const
{
return dynamic_cast<ServeurIceMP3*>(::IceProxy::Ice::Object::ice_context(__context).get());
}
::IceInternal::ProxyHandle<ServeurIceMP3> ice_adapterId(const ::std::string& __id) const
{
return dynamic_cast<ServeurIceMP3*>(::IceProxy::Ice::Object::ice_adapterId(__id).get());
}
::IceInternal::ProxyHandle<ServeurIceMP3> ice_endpoints(const ::Ice::EndpointSeq& __endpoints) const
{
return dynamic_cast<ServeurIceMP3*>(::IceProxy::Ice::Object::ice_endpoints(__endpoints).get());
}
::IceInternal::ProxyHandle<ServeurIceMP3> ice_locatorCacheTimeout(int __timeout) const
{
return dynamic_cast<ServeurIceMP3*>(::IceProxy::Ice::Object::ice_locatorCacheTimeout(__timeout).get());
}
::IceInternal::ProxyHandle<ServeurIceMP3> ice_connectionCached(bool __cached) const
{
return dynamic_cast<ServeurIceMP3*>(::IceProxy::Ice::Object::ice_connectionCached(__cached).get());
}
::IceInternal::ProxyHandle<ServeurIceMP3> ice_endpointSelection(::Ice::EndpointSelectionType __est) const
{
return dynamic_cast<ServeurIceMP3*>(::IceProxy::Ice::Object::ice_endpointSelection(__est).get());
}
::IceInternal::ProxyHandle<ServeurIceMP3> ice_secure(bool __secure) const
{
return dynamic_cast<ServeurIceMP3*>(::IceProxy::Ice::Object::ice_secure(__secure).get());
}
::IceInternal::ProxyHandle<ServeurIceMP3> ice_preferSecure(bool __preferSecure) const
{
return dynamic_cast<ServeurIceMP3*>(::IceProxy::Ice::Object::ice_preferSecure(__preferSecure).get());
}
::IceInternal::ProxyHandle<ServeurIceMP3> ice_router(const ::Ice::RouterPrx& __router) const
{
return dynamic_cast<ServeurIceMP3*>(::IceProxy::Ice::Object::ice_router(__router).get());
}
::IceInternal::ProxyHandle<ServeurIceMP3> ice_locator(const ::Ice::LocatorPrx& __locator) const
{
return dynamic_cast<ServeurIceMP3*>(::IceProxy::Ice::Object::ice_locator(__locator).get());
}
::IceInternal::ProxyHandle<ServeurIceMP3> ice_collocationOptimized(bool __co) const
{
return dynamic_cast<ServeurIceMP3*>(::IceProxy::Ice::Object::ice_collocationOptimized(__co).get());
}
::IceInternal::ProxyHandle<ServeurIceMP3> ice_twoway() const
{
return dynamic_cast<ServeurIceMP3*>(::IceProxy::Ice::Object::ice_twoway().get());
}
::IceInternal::ProxyHandle<ServeurIceMP3> ice_oneway() const
{
return dynamic_cast<ServeurIceMP3*>(::IceProxy::Ice::Object::ice_oneway().get());
}
::IceInternal::ProxyHandle<ServeurIceMP3> ice_batchOneway() const
{
return dynamic_cast<ServeurIceMP3*>(::IceProxy::Ice::Object::ice_batchOneway().get());
}
::IceInternal::ProxyHandle<ServeurIceMP3> ice_datagram() const
{
return dynamic_cast<ServeurIceMP3*>(::IceProxy::Ice::Object::ice_datagram().get());
}
::IceInternal::ProxyHandle<ServeurIceMP3> ice_batchDatagram() const
{
return dynamic_cast<ServeurIceMP3*>(::IceProxy::Ice::Object::ice_batchDatagram().get());
}
::IceInternal::ProxyHandle<ServeurIceMP3> ice_compress(bool __compress) const
{
return dynamic_cast<ServeurIceMP3*>(::IceProxy::Ice::Object::ice_compress(__compress).get());
}
::IceInternal::ProxyHandle<ServeurIceMP3> ice_timeout(int __timeout) const
{
return dynamic_cast<ServeurIceMP3*>(::IceProxy::Ice::Object::ice_timeout(__timeout).get());
}
::IceInternal::ProxyHandle<ServeurIceMP3> ice_connectionId(const ::std::string& __id) const
{
return dynamic_cast<ServeurIceMP3*>(::IceProxy::Ice::Object::ice_connectionId(__id).get());
}
::IceInternal::ProxyHandle<ServeurIceMP3> ice_encodingVersion(const ::Ice::EncodingVersion& __v) const
{
return dynamic_cast<ServeurIceMP3*>(::IceProxy::Ice::Object::ice_encodingVersion(__v).get());
}
static const ::std::string& ice_staticId();
private:
virtual ::IceInternal::Handle< ::IceDelegateM::Ice::Object> __createDelegateM();
virtual ::IceInternal::Handle< ::IceDelegateD::Ice::Object> __createDelegateD();
virtual ::IceProxy::Ice::Object* __newInstance() const;
};
}
}
namespace IceDelegate
{
namespace serveur
{
class ServeurIceMP3 : virtual public ::IceDelegate::Ice::Object
{
public:
virtual void ajoutfichier(const ::std::string&, const ::std::string&, const ::std::string&, const ::Ice::Context*, ::IceInternal::InvocationObserver&) = 0;
virtual ::std::string recherche(const ::std::string&, const ::std::string&, const ::Ice::Context*, ::IceInternal::InvocationObserver&) = 0;
virtual ::serveur::listetitre rechercheTitre(const ::std::string&, const ::Ice::Context*, ::IceInternal::InvocationObserver&) = 0;
virtual ::serveur::listeauteur rechercheAuteur(const ::std::string&, const ::Ice::Context*, ::IceInternal::InvocationObserver&) = 0;
virtual void suppression(const ::std::string&, const ::std::string&, const ::Ice::Context*, ::IceInternal::InvocationObserver&) = 0;
virtual ::std::string lireMp3(const ::std::string&, const ::std::string&, const ::Ice::Context*, ::IceInternal::InvocationObserver&) = 0;
virtual ::std::string lireMp3ParFichier(const ::std::string&, const ::Ice::Context*, ::IceInternal::InvocationObserver&) = 0;
virtual bool stopMp3(const ::std::string&, const ::Ice::Context*, ::IceInternal::InvocationObserver&) = 0;
};
}
}
namespace IceDelegateM
{
namespace serveur
{
class ServeurIceMP3 : virtual public ::IceDelegate::serveur::ServeurIceMP3,
virtual public ::IceDelegateM::Ice::Object
{
public:
virtual void ajoutfichier(const ::std::string&, const ::std::string&, const ::std::string&, const ::Ice::Context*, ::IceInternal::InvocationObserver&);
virtual ::std::string recherche(const ::std::string&, const ::std::string&, const ::Ice::Context*, ::IceInternal::InvocationObserver&);
virtual ::serveur::listetitre rechercheTitre(const ::std::string&, const ::Ice::Context*, ::IceInternal::InvocationObserver&);
virtual ::serveur::listeauteur rechercheAuteur(const ::std::string&, const ::Ice::Context*, ::IceInternal::InvocationObserver&);
virtual void suppression(const ::std::string&, const ::std::string&, const ::Ice::Context*, ::IceInternal::InvocationObserver&);
virtual ::std::string lireMp3(const ::std::string&, const ::std::string&, const ::Ice::Context*, ::IceInternal::InvocationObserver&);
virtual ::std::string lireMp3ParFichier(const ::std::string&, const ::Ice::Context*, ::IceInternal::InvocationObserver&);
virtual bool stopMp3(const ::std::string&, const ::Ice::Context*, ::IceInternal::InvocationObserver&);
};
}
}
namespace IceDelegateD
{
namespace serveur
{
class ServeurIceMP3 : virtual public ::IceDelegate::serveur::ServeurIceMP3,
virtual public ::IceDelegateD::Ice::Object
{
public:
virtual void ajoutfichier(const ::std::string&, const ::std::string&, const ::std::string&, const ::Ice::Context*, ::IceInternal::InvocationObserver&);
virtual ::std::string recherche(const ::std::string&, const ::std::string&, const ::Ice::Context*, ::IceInternal::InvocationObserver&);
virtual ::serveur::listetitre rechercheTitre(const ::std::string&, const ::Ice::Context*, ::IceInternal::InvocationObserver&);
virtual ::serveur::listeauteur rechercheAuteur(const ::std::string&, const ::Ice::Context*, ::IceInternal::InvocationObserver&);
virtual void suppression(const ::std::string&, const ::std::string&, const ::Ice::Context*, ::IceInternal::InvocationObserver&);
virtual ::std::string lireMp3(const ::std::string&, const ::std::string&, const ::Ice::Context*, ::IceInternal::InvocationObserver&);
virtual ::std::string lireMp3ParFichier(const ::std::string&, const ::Ice::Context*, ::IceInternal::InvocationObserver&);
virtual bool stopMp3(const ::std::string&, const ::Ice::Context*, ::IceInternal::InvocationObserver&);
};
}
}
namespace serveur
{
class ServeurIceMP3 : virtual public ::Ice::Object
{
public:
typedef ServeurIceMP3Prx ProxyType;
typedef ServeurIceMP3Ptr PointerType;
virtual bool ice_isA(const ::std::string&, const ::Ice::Current& = ::Ice::Current()) const;
virtual ::std::vector< ::std::string> ice_ids(const ::Ice::Current& = ::Ice::Current()) const;
virtual const ::std::string& ice_id(const ::Ice::Current& = ::Ice::Current()) const;
static const ::std::string& ice_staticId();
virtual void ajoutfichier(const ::std::string&, const ::std::string&, const ::std::string&, const ::Ice::Current& = ::Ice::Current()) = 0;
::Ice::DispatchStatus ___ajoutfichier(::IceInternal::Incoming&, const ::Ice::Current&);
virtual ::std::string recherche(const ::std::string&, const ::std::string&, const ::Ice::Current& = ::Ice::Current()) = 0;
::Ice::DispatchStatus ___recherche(::IceInternal::Incoming&, const ::Ice::Current&);
virtual ::serveur::listetitre rechercheTitre(const ::std::string&, const ::Ice::Current& = ::Ice::Current()) = 0;
::Ice::DispatchStatus ___rechercheTitre(::IceInternal::Incoming&, const ::Ice::Current&);
virtual ::serveur::listeauteur rechercheAuteur(const ::std::string&, const ::Ice::Current& = ::Ice::Current()) = 0;
::Ice::DispatchStatus ___rechercheAuteur(::IceInternal::Incoming&, const ::Ice::Current&);
virtual void suppression(const ::std::string&, const ::std::string&, const ::Ice::Current& = ::Ice::Current()) = 0;
::Ice::DispatchStatus ___suppression(::IceInternal::Incoming&, const ::Ice::Current&);
virtual ::std::string lireMp3(const ::std::string&, const ::std::string&, const ::Ice::Current& = ::Ice::Current()) = 0;
::Ice::DispatchStatus ___lireMp3(::IceInternal::Incoming&, const ::Ice::Current&);
virtual ::std::string lireMp3ParFichier(const ::std::string&, const ::Ice::Current& = ::Ice::Current()) = 0;
::Ice::DispatchStatus ___lireMp3ParFichier(::IceInternal::Incoming&, const ::Ice::Current&);
virtual bool stopMp3(const ::std::string&, const ::Ice::Current& = ::Ice::Current()) = 0;
::Ice::DispatchStatus ___stopMp3(::IceInternal::Incoming&, const ::Ice::Current&);
virtual ::Ice::DispatchStatus __dispatch(::IceInternal::Incoming&, const ::Ice::Current&);
protected:
virtual void __writeImpl(::IceInternal::BasicStream*) const;
virtual void __readImpl(::IceInternal::BasicStream*);
#ifdef __SUNPRO_CC
using ::Ice::Object::__writeImpl;
using ::Ice::Object::__readImpl;
#endif
};
inline bool operator==(const ServeurIceMP3& l, const ServeurIceMP3& r)
{
return static_cast<const ::Ice::Object&>(l) == static_cast<const ::Ice::Object&>(r);
}
inline bool operator<(const ServeurIceMP3& l, const ServeurIceMP3& r)
{
return static_cast<const ::Ice::Object&>(l) < static_cast<const ::Ice::Object&>(r);
}
}
namespace serveur
{
template<class T>
class CallbackNC_ServeurIceMP3_ajoutfichier : public Callback_ServeurIceMP3_ajoutfichier_Base, public ::IceInternal::OnewayCallbackNC<T>
{
public:
typedef IceUtil::Handle<T> TPtr;
typedef void (T::*Exception)(const ::Ice::Exception&);
typedef void (T::*Sent)(bool);
typedef void (T::*Response)();
CallbackNC_ServeurIceMP3_ajoutfichier(const TPtr& obj, Response cb, Exception excb, Sent sentcb)
: ::IceInternal::OnewayCallbackNC<T>(obj, cb, excb, sentcb)
{
}
};
template<class T> Callback_ServeurIceMP3_ajoutfichierPtr
newCallback_ServeurIceMP3_ajoutfichier(const IceUtil::Handle<T>& instance, void (T::*cb)(), void (T::*excb)(const ::Ice::Exception&), void (T::*sentcb)(bool) = 0)
{
return new CallbackNC_ServeurIceMP3_ajoutfichier<T>(instance, cb, excb, sentcb);
}
template<class T> Callback_ServeurIceMP3_ajoutfichierPtr
newCallback_ServeurIceMP3_ajoutfichier(const IceUtil::Handle<T>& instance, void (T::*excb)(const ::Ice::Exception&), void (T::*sentcb)(bool) = 0)
{
return new CallbackNC_ServeurIceMP3_ajoutfichier<T>(instance, 0, excb, sentcb);
}
template<class T> Callback_ServeurIceMP3_ajoutfichierPtr
newCallback_ServeurIceMP3_ajoutfichier(T* instance, void (T::*cb)(), void (T::*excb)(const ::Ice::Exception&), void (T::*sentcb)(bool) = 0)
{
return new CallbackNC_ServeurIceMP3_ajoutfichier<T>(instance, cb, excb, sentcb);
}
template<class T> Callback_ServeurIceMP3_ajoutfichierPtr
newCallback_ServeurIceMP3_ajoutfichier(T* instance, void (T::*excb)(const ::Ice::Exception&), void (T::*sentcb)(bool) = 0)
{
return new CallbackNC_ServeurIceMP3_ajoutfichier<T>(instance, 0, excb, sentcb);
}
template<class T, typename CT>
class Callback_ServeurIceMP3_ajoutfichier : public Callback_ServeurIceMP3_ajoutfichier_Base, public ::IceInternal::OnewayCallback<T, CT>
{
public:
typedef IceUtil::Handle<T> TPtr;
typedef void (T::*Exception)(const ::Ice::Exception& , const CT&);
typedef void (T::*Sent)(bool , const CT&);
typedef void (T::*Response)(const CT&);
Callback_ServeurIceMP3_ajoutfichier(const TPtr& obj, Response cb, Exception excb, Sent sentcb)
: ::IceInternal::OnewayCallback<T, CT>(obj, cb, excb, sentcb)
{
}
};
template<class T, typename CT> Callback_ServeurIceMP3_ajoutfichierPtr
newCallback_ServeurIceMP3_ajoutfichier(const IceUtil::Handle<T>& instance, void (T::*cb)(const CT&), void (T::*excb)(const ::Ice::Exception&, const CT&), void (T::*sentcb)(bool, const CT&) = 0)
{
return new Callback_ServeurIceMP3_ajoutfichier<T, CT>(instance, cb, excb, sentcb);
}
template<class T, typename CT> Callback_ServeurIceMP3_ajoutfichierPtr
newCallback_ServeurIceMP3_ajoutfichier(const IceUtil::Handle<T>& instance, void (T::*excb)(const ::Ice::Exception&, const CT&), void (T::*sentcb)(bool, const CT&) = 0)
{
return new Callback_ServeurIceMP3_ajoutfichier<T, CT>(instance, 0, excb, sentcb);
}
template<class T, typename CT> Callback_ServeurIceMP3_ajoutfichierPtr
newCallback_ServeurIceMP3_ajoutfichier(T* instance, void (T::*cb)(const CT&), void (T::*excb)(const ::Ice::Exception&, const CT&), void (T::*sentcb)(bool, const CT&) = 0)
{
return new Callback_ServeurIceMP3_ajoutfichier<T, CT>(instance, cb, excb, sentcb);
}
template<class T, typename CT> Callback_ServeurIceMP3_ajoutfichierPtr
newCallback_ServeurIceMP3_ajoutfichier(T* instance, void (T::*excb)(const ::Ice::Exception&, const CT&), void (T::*sentcb)(bool, const CT&) = 0)
{
return new Callback_ServeurIceMP3_ajoutfichier<T, CT>(instance, 0, excb, sentcb);
}
template<class T>
class CallbackNC_ServeurIceMP3_recherche : public Callback_ServeurIceMP3_recherche_Base, public ::IceInternal::TwowayCallbackNC<T>
{
public:
typedef IceUtil::Handle<T> TPtr;
typedef void (T::*Exception)(const ::Ice::Exception&);
typedef void (T::*Sent)(bool);
typedef void (T::*Response)(const ::std::string&);
CallbackNC_ServeurIceMP3_recherche(const TPtr& obj, Response cb, Exception excb, Sent sentcb)
: ::IceInternal::TwowayCallbackNC<T>(obj, cb != 0, excb, sentcb), response(cb)
{
}
virtual void __completed(const ::Ice::AsyncResultPtr& __result) const
{
::serveur::ServeurIceMP3Prx __proxy = ::serveur::ServeurIceMP3Prx::uncheckedCast(__result->getProxy());
::std::string __ret;
try
{
__ret = __proxy->end_recherche(__result);
}
catch(::Ice::Exception& ex)
{
::IceInternal::CallbackNC<T>::__exception(__result, ex);
return;
}
if(response)
{
(::IceInternal::CallbackNC<T>::callback.get()->*response)(__ret);
}
}
Response response;
};
template<class T> Callback_ServeurIceMP3_recherchePtr
newCallback_ServeurIceMP3_recherche(const IceUtil::Handle<T>& instance, void (T::*cb)(const ::std::string&), void (T::*excb)(const ::Ice::Exception&), void (T::*sentcb)(bool) = 0)
{
return new CallbackNC_ServeurIceMP3_recherche<T>(instance, cb, excb, sentcb);
}
template<class T> Callback_ServeurIceMP3_recherchePtr
newCallback_ServeurIceMP3_recherche(T* instance, void (T::*cb)(const ::std::string&), void (T::*excb)(const ::Ice::Exception&), void (T::*sentcb)(bool) = 0)
{
return new CallbackNC_ServeurIceMP3_recherche<T>(instance, cb, excb, sentcb);
}
template<class T, typename CT>
class Callback_ServeurIceMP3_recherche : public Callback_ServeurIceMP3_recherche_Base, public ::IceInternal::TwowayCallback<T, CT>
{
public:
typedef IceUtil::Handle<T> TPtr;
typedef void (T::*Exception)(const ::Ice::Exception& , const CT&);
typedef void (T::*Sent)(bool , const CT&);
typedef void (T::*Response)(const ::std::string&, const CT&);
Callback_ServeurIceMP3_recherche(const TPtr& obj, Response cb, Exception excb, Sent sentcb)
: ::IceInternal::TwowayCallback<T, CT>(obj, cb != 0, excb, sentcb), response(cb)
{
}
virtual void __completed(const ::Ice::AsyncResultPtr& __result) const
{
::serveur::ServeurIceMP3Prx __proxy = ::serveur::ServeurIceMP3Prx::uncheckedCast(__result->getProxy());
::std::string __ret;
try
{
__ret = __proxy->end_recherche(__result);
}
catch(::Ice::Exception& ex)
{
::IceInternal::Callback<T, CT>::__exception(__result, ex);
return;
}
if(response)
{
(::IceInternal::Callback<T, CT>::callback.get()->*response)(__ret, CT::dynamicCast(__result->getCookie()));
}
}
Response response;
};
template<class T, typename CT> Callback_ServeurIceMP3_recherchePtr
newCallback_ServeurIceMP3_recherche(const IceUtil::Handle<T>& instance, void (T::*cb)(const ::std::string&, const CT&), void (T::*excb)(const ::Ice::Exception&, const CT&), void (T::*sentcb)(bool, const CT&) = 0)
{
return new Callback_ServeurIceMP3_recherche<T, CT>(instance, cb, excb, sentcb);
}
template<class T, typename CT> Callback_ServeurIceMP3_recherchePtr
newCallback_ServeurIceMP3_recherche(T* instance, void (T::*cb)(const ::std::string&, const CT&), void (T::*excb)(const ::Ice::Exception&, const CT&), void (T::*sentcb)(bool, const CT&) = 0)
{
return new Callback_ServeurIceMP3_recherche<T, CT>(instance, cb, excb, sentcb);
}
template<class T>
class CallbackNC_ServeurIceMP3_rechercheTitre : public Callback_ServeurIceMP3_rechercheTitre_Base, public ::IceInternal::TwowayCallbackNC<T>
{
public:
typedef IceUtil::Handle<T> TPtr;
typedef void (T::*Exception)(const ::Ice::Exception&);
typedef void (T::*Sent)(bool);
typedef void (T::*Response)(const ::serveur::listetitre&);
CallbackNC_ServeurIceMP3_rechercheTitre(const TPtr& obj, Response cb, Exception excb, Sent sentcb)
: ::IceInternal::TwowayCallbackNC<T>(obj, cb != 0, excb, sentcb), response(cb)
{
}
virtual void __completed(const ::Ice::AsyncResultPtr& __result) const
{
::serveur::ServeurIceMP3Prx __proxy = ::serveur::ServeurIceMP3Prx::uncheckedCast(__result->getProxy());
::serveur::listetitre __ret;
try
{
__ret = __proxy->end_rechercheTitre(__result);
}
catch(::Ice::Exception& ex)
{
::IceInternal::CallbackNC<T>::__exception(__result, ex);
return;
}
if(response)
{
(::IceInternal::CallbackNC<T>::callback.get()->*response)(__ret);
}
}
Response response;
};
template<class T> Callback_ServeurIceMP3_rechercheTitrePtr
newCallback_ServeurIceMP3_rechercheTitre(const IceUtil::Handle<T>& instance, void (T::*cb)(const ::serveur::listetitre&), void (T::*excb)(const ::Ice::Exception&), void (T::*sentcb)(bool) = 0)
{
return new CallbackNC_ServeurIceMP3_rechercheTitre<T>(instance, cb, excb, sentcb);
}
template<class T> Callback_ServeurIceMP3_rechercheTitrePtr
newCallback_ServeurIceMP3_rechercheTitre(T* instance, void (T::*cb)(const ::serveur::listetitre&), void (T::*excb)(const ::Ice::Exception&), void (T::*sentcb)(bool) = 0)
{
return new CallbackNC_ServeurIceMP3_rechercheTitre<T>(instance, cb, excb, sentcb);
}
template<class T, typename CT>
class Callback_ServeurIceMP3_rechercheTitre : public Callback_ServeurIceMP3_rechercheTitre_Base, public ::IceInternal::TwowayCallback<T, CT>
{
public:
typedef IceUtil::Handle<T> TPtr;
typedef void (T::*Exception)(const ::Ice::Exception& , const CT&);
typedef void (T::*Sent)(bool , const CT&);
typedef void (T::*Response)(const ::serveur::listetitre&, const CT&);
Callback_ServeurIceMP3_rechercheTitre(const TPtr& obj, Response cb, Exception excb, Sent sentcb)
: ::IceInternal::TwowayCallback<T, CT>(obj, cb != 0, excb, sentcb), response(cb)
{
}
virtual void __completed(const ::Ice::AsyncResultPtr& __result) const
{
::serveur::ServeurIceMP3Prx __proxy = ::serveur::ServeurIceMP3Prx::uncheckedCast(__result->getProxy());
::serveur::listetitre __ret;
try
{
__ret = __proxy->end_rechercheTitre(__result);
}
catch(::Ice::Exception& ex)
{
::IceInternal::Callback<T, CT>::__exception(__result, ex);
return;
}
if(response)
{
(::IceInternal::Callback<T, CT>::callback.get()->*response)(__ret, CT::dynamicCast(__result->getCookie()));
}
}
Response response;
};
template<class T, typename CT> Callback_ServeurIceMP3_rechercheTitrePtr
newCallback_ServeurIceMP3_rechercheTitre(const IceUtil::Handle<T>& instance, void (T::*cb)(const ::serveur::listetitre&, const CT&), void (T::*excb)(const ::Ice::Exception&, const CT&), void (T::*sentcb)(bool, const CT&) = 0)
{
return new Callback_ServeurIceMP3_rechercheTitre<T, CT>(instance, cb, excb, sentcb);
}
template<class T, typename CT> Callback_ServeurIceMP3_rechercheTitrePtr
newCallback_ServeurIceMP3_rechercheTitre(T* instance, void (T::*cb)(const ::serveur::listetitre&, const CT&), void (T::*excb)(const ::Ice::Exception&, const CT&), void (T::*sentcb)(bool, const CT&) = 0)
{
return new Callback_ServeurIceMP3_rechercheTitre<T, CT>(instance, cb, excb, sentcb);
}
template<class T>
class CallbackNC_ServeurIceMP3_rechercheAuteur : public Callback_ServeurIceMP3_rechercheAuteur_Base, public ::IceInternal::TwowayCallbackNC<T>
{
public:
typedef IceUtil::Handle<T> TPtr;
typedef void (T::*Exception)(const ::Ice::Exception&);
typedef void (T::*Sent)(bool);
typedef void (T::*Response)(const ::serveur::listeauteur&);
CallbackNC_ServeurIceMP3_rechercheAuteur(const TPtr& obj, Response cb, Exception excb, Sent sentcb)
: ::IceInternal::TwowayCallbackNC<T>(obj, cb != 0, excb, sentcb), response(cb)
{
}
virtual void __completed(const ::Ice::AsyncResultPtr& __result) const
{
::serveur::ServeurIceMP3Prx __proxy = ::serveur::ServeurIceMP3Prx::uncheckedCast(__result->getProxy());
::serveur::listeauteur __ret;
try
{
__ret = __proxy->end_rechercheAuteur(__result);
}
catch(::Ice::Exception& ex)
{
::IceInternal::CallbackNC<T>::__exception(__result, ex);
return;
}
if(response)
{
(::IceInternal::CallbackNC<T>::callback.get()->*response)(__ret);
}
}
Response response;
};
template<class T> Callback_ServeurIceMP3_rechercheAuteurPtr
newCallback_ServeurIceMP3_rechercheAuteur(const IceUtil::Handle<T>& instance, void (T::*cb)(const ::serveur::listeauteur&), void (T::*excb)(const ::Ice::Exception&), void (T::*sentcb)(bool) = 0)
{
return new CallbackNC_ServeurIceMP3_rechercheAuteur<T>(instance, cb, excb, sentcb);
}
template<class T> Callback_ServeurIceMP3_rechercheAuteurPtr
newCallback_ServeurIceMP3_rechercheAuteur(T* instance, void (T::*cb)(const ::serveur::listeauteur&), void (T::*excb)(const ::Ice::Exception&), void (T::*sentcb)(bool) = 0)
{
return new CallbackNC_ServeurIceMP3_rechercheAuteur<T>(instance, cb, excb, sentcb);
}
template<class T, typename CT>
class Callback_ServeurIceMP3_rechercheAuteur : public Callback_ServeurIceMP3_rechercheAuteur_Base, public ::IceInternal::TwowayCallback<T, CT>
{
public:
typedef IceUtil::Handle<T> TPtr;
typedef void (T::*Exception)(const ::Ice::Exception& , const CT&);
typedef void (T::*Sent)(bool , const CT&);
typedef void (T::*Response)(const ::serveur::listeauteur&, const CT&);
Callback_ServeurIceMP3_rechercheAuteur(const TPtr& obj, Response cb, Exception excb, Sent sentcb)
: ::IceInternal::TwowayCallback<T, CT>(obj, cb != 0, excb, sentcb), response(cb)
{
}
virtual void __completed(const ::Ice::AsyncResultPtr& __result) const
{
::serveur::ServeurIceMP3Prx __proxy = ::serveur::ServeurIceMP3Prx::uncheckedCast(__result->getProxy());
::serveur::listeauteur __ret;
try
{
__ret = __proxy->end_rechercheAuteur(__result);
}
catch(::Ice::Exception& ex)
{
::IceInternal::Callback<T, CT>::__exception(__result, ex);
return;
}
if(response)
{
(::IceInternal::Callback<T, CT>::callback.get()->*response)(__ret, CT::dynamicCast(__result->getCookie()));
}
}
Response response;
};
template<class T, typename CT> Callback_ServeurIceMP3_rechercheAuteurPtr
newCallback_ServeurIceMP3_rechercheAuteur(const IceUtil::Handle<T>& instance, void (T::*cb)(const ::serveur::listeauteur&, const CT&), void (T::*excb)(const ::Ice::Exception&, const CT&), void (T::*sentcb)(bool, const CT&) = 0)
{
return new Callback_ServeurIceMP3_rechercheAuteur<T, CT>(instance, cb, excb, sentcb);
}
template<class T, typename CT> Callback_ServeurIceMP3_rechercheAuteurPtr
newCallback_ServeurIceMP3_rechercheAuteur(T* instance, void (T::*cb)(const ::serveur::listeauteur&, const CT&), void (T::*excb)(const ::Ice::Exception&, const CT&), void (T::*sentcb)(bool, const CT&) = 0)
{
return new Callback_ServeurIceMP3_rechercheAuteur<T, CT>(instance, cb, excb, sentcb);
}
template<class T>
class CallbackNC_ServeurIceMP3_suppression : public Callback_ServeurIceMP3_suppression_Base, public ::IceInternal::OnewayCallbackNC<T>
{
public:
typedef IceUtil::Handle<T> TPtr;
typedef void (T::*Exception)(const ::Ice::Exception&);
typedef void (T::*Sent)(bool);
typedef void (T::*Response)();
CallbackNC_ServeurIceMP3_suppression(const TPtr& obj, Response cb, Exception excb, Sent sentcb)
: ::IceInternal::OnewayCallbackNC<T>(obj, cb, excb, sentcb)
{
}
};
template<class T> Callback_ServeurIceMP3_suppressionPtr
newCallback_ServeurIceMP3_suppression(const IceUtil::Handle<T>& instance, void (T::*cb)(), void (T::*excb)(const ::Ice::Exception&), void (T::*sentcb)(bool) = 0)
{
return new CallbackNC_ServeurIceMP3_suppression<T>(instance, cb, excb, sentcb);
}
template<class T> Callback_ServeurIceMP3_suppressionPtr
newCallback_ServeurIceMP3_suppression(const IceUtil::Handle<T>& instance, void (T::*excb)(const ::Ice::Exception&), void (T::*sentcb)(bool) = 0)
{
return new CallbackNC_ServeurIceMP3_suppression<T>(instance, 0, excb, sentcb);
}
template<class T> Callback_ServeurIceMP3_suppressionPtr
newCallback_ServeurIceMP3_suppression(T* instance, void (T::*cb)(), void (T::*excb)(const ::Ice::Exception&), void (T::*sentcb)(bool) = 0)
{
return new CallbackNC_ServeurIceMP3_suppression<T>(instance, cb, excb, sentcb);
}
template<class T> Callback_ServeurIceMP3_suppressionPtr
newCallback_ServeurIceMP3_suppression(T* instance, void (T::*excb)(const ::Ice::Exception&), void (T::*sentcb)(bool) = 0)
{
return new CallbackNC_ServeurIceMP3_suppression<T>(instance, 0, excb, sentcb);
}
template<class T, typename CT>
class Callback_ServeurIceMP3_suppression : public Callback_ServeurIceMP3_suppression_Base, public ::IceInternal::OnewayCallback<T, CT>
{
public:
typedef IceUtil::Handle<T> TPtr;
typedef void (T::*Exception)(const ::Ice::Exception& , const CT&);
typedef void (T::*Sent)(bool , const CT&);
typedef void (T::*Response)(const CT&);
Callback_ServeurIceMP3_suppression(const TPtr& obj, Response cb, Exception excb, Sent sentcb)
: ::IceInternal::OnewayCallback<T, CT>(obj, cb, excb, sentcb)
{
}
};
template<class T, typename CT> Callback_ServeurIceMP3_suppressionPtr
newCallback_ServeurIceMP3_suppression(const IceUtil::Handle<T>& instance, void (T::*cb)(const CT&), void (T::*excb)(const ::Ice::Exception&, const CT&), void (T::*sentcb)(bool, const CT&) = 0)
{
return new Callback_ServeurIceMP3_suppression<T, CT>(instance, cb, excb, sentcb);
}
template<class T, typename CT> Callback_ServeurIceMP3_suppressionPtr
newCallback_ServeurIceMP3_suppression(const IceUtil::Handle<T>& instance, void (T::*excb)(const ::Ice::Exception&, const CT&), void (T::*sentcb)(bool, const CT&) = 0)
{
return new Callback_ServeurIceMP3_suppression<T, CT>(instance, 0, excb, sentcb);
}
template<class T, typename CT> Callback_ServeurIceMP3_suppressionPtr
newCallback_ServeurIceMP3_suppression(T* instance, void (T::*cb)(const CT&), void (T::*excb)(const ::Ice::Exception&, const CT&), void (T::*sentcb)(bool, const CT&) = 0)
{
return new Callback_ServeurIceMP3_suppression<T, CT>(instance, cb, excb, sentcb);
}
template<class T, typename CT> Callback_ServeurIceMP3_suppressionPtr
newCallback_ServeurIceMP3_suppression(T* instance, void (T::*excb)(const ::Ice::Exception&, const CT&), void (T::*sentcb)(bool, const CT&) = 0)
{
return new Callback_ServeurIceMP3_suppression<T, CT>(instance, 0, excb, sentcb);
}
template<class T>
class CallbackNC_ServeurIceMP3_lireMp3 : public Callback_ServeurIceMP3_lireMp3_Base, public ::IceInternal::TwowayCallbackNC<T>
{
public:
typedef IceUtil::Handle<T> TPtr;
typedef void (T::*Exception)(const ::Ice::Exception&);
typedef void (T::*Sent)(bool);
typedef void (T::*Response)(const ::std::string&);
CallbackNC_ServeurIceMP3_lireMp3(const TPtr& obj, Response cb, Exception excb, Sent sentcb)
: ::IceInternal::TwowayCallbackNC<T>(obj, cb != 0, excb, sentcb), response(cb)
{
}
virtual void __completed(const ::Ice::AsyncResultPtr& __result) const
{
::serveur::ServeurIceMP3Prx __proxy = ::serveur::ServeurIceMP3Prx::uncheckedCast(__result->getProxy());
::std::string __ret;
try
{
__ret = __proxy->end_lireMp3(__result);
}
catch(::Ice::Exception& ex)
{
::IceInternal::CallbackNC<T>::__exception(__result, ex);
return;
}
if(response)
{
(::IceInternal::CallbackNC<T>::callback.get()->*response)(__ret);
}
}
Response response;
};
template<class T> Callback_ServeurIceMP3_lireMp3Ptr
newCallback_ServeurIceMP3_lireMp3(const IceUtil::Handle<T>& instance, void (T::*cb)(const ::std::string&), void (T::*excb)(const ::Ice::Exception&), void (T::*sentcb)(bool) = 0)
{
return new CallbackNC_ServeurIceMP3_lireMp3<T>(instance, cb, excb, sentcb);
}
template<class T> Callback_ServeurIceMP3_lireMp3Ptr
newCallback_ServeurIceMP3_lireMp3(T* instance, void (T::*cb)(const ::std::string&), void (T::*excb)(const ::Ice::Exception&), void (T::*sentcb)(bool) = 0)
{
return new CallbackNC_ServeurIceMP3_lireMp3<T>(instance, cb, excb, sentcb);
}
template<class T, typename CT>
class Callback_ServeurIceMP3_lireMp3 : public Callback_ServeurIceMP3_lireMp3_Base, public ::IceInternal::TwowayCallback<T, CT>
{
public:
typedef IceUtil::Handle<T> TPtr;
typedef void (T::*Exception)(const ::Ice::Exception& , const CT&);
typedef void (T::*Sent)(bool , const CT&);
typedef void (T::*Response)(const ::std::string&, const CT&);
Callback_ServeurIceMP3_lireMp3(const TPtr& obj, Response cb, Exception excb, Sent sentcb)
: ::IceInternal::TwowayCallback<T, CT>(obj, cb != 0, excb, sentcb), response(cb)
{
}
virtual void __completed(const ::Ice::AsyncResultPtr& __result) const
{
::serveur::ServeurIceMP3Prx __proxy = ::serveur::ServeurIceMP3Prx::uncheckedCast(__result->getProxy());
::std::string __ret;
try
{
__ret = __proxy->end_lireMp3(__result);
}
catch(::Ice::Exception& ex)
{
::IceInternal::Callback<T, CT>::__exception(__result, ex);
return;
}
if(response)
{
(::IceInternal::Callback<T, CT>::callback.get()->*response)(__ret, CT::dynamicCast(__result->getCookie()));
}
}
Response response;
};
template<class T, typename CT> Callback_ServeurIceMP3_lireMp3Ptr
newCallback_ServeurIceMP3_lireMp3(const IceUtil::Handle<T>& instance, void (T::*cb)(const ::std::string&, const CT&), void (T::*excb)(const ::Ice::Exception&, const CT&), void (T::*sentcb)(bool, const CT&) = 0)
{
return new Callback_ServeurIceMP3_lireMp3<T, CT>(instance, cb, excb, sentcb);
}
template<class T, typename CT> Callback_ServeurIceMP3_lireMp3Ptr
newCallback_ServeurIceMP3_lireMp3(T* instance, void (T::*cb)(const ::std::string&, const CT&), void (T::*excb)(const ::Ice::Exception&, const CT&), void (T::*sentcb)(bool, const CT&) = 0)
{
return new Callback_ServeurIceMP3_lireMp3<T, CT>(instance, cb, excb, sentcb);
}
template<class T>
class CallbackNC_ServeurIceMP3_lireMp3ParFichier : public Callback_ServeurIceMP3_lireMp3ParFichier_Base, public ::IceInternal::TwowayCallbackNC<T>
{
public:
typedef IceUtil::Handle<T> TPtr;
typedef void (T::*Exception)(const ::Ice::Exception&);
typedef void (T::*Sent)(bool);
typedef void (T::*Response)(const ::std::string&);
CallbackNC_ServeurIceMP3_lireMp3ParFichier(const TPtr& obj, Response cb, Exception excb, Sent sentcb)
: ::IceInternal::TwowayCallbackNC<T>(obj, cb != 0, excb, sentcb), response(cb)
{
}
virtual void __completed(const ::Ice::AsyncResultPtr& __result) const
{
::serveur::ServeurIceMP3Prx __proxy = ::serveur::ServeurIceMP3Prx::uncheckedCast(__result->getProxy());
::std::string __ret;
try
{
__ret = __proxy->end_lireMp3ParFichier(__result);
}
catch(::Ice::Exception& ex)
{
::IceInternal::CallbackNC<T>::__exception(__result, ex);
return;
}
if(response)
{
(::IceInternal::CallbackNC<T>::callback.get()->*response)(__ret);
}
}
Response response;
};
template<class T> Callback_ServeurIceMP3_lireMp3ParFichierPtr
newCallback_ServeurIceMP3_lireMp3ParFichier(const IceUtil::Handle<T>& instance, void (T::*cb)(const ::std::string&), void (T::*excb)(const ::Ice::Exception&), void (T::*sentcb)(bool) = 0)
{
return new CallbackNC_ServeurIceMP3_lireMp3ParFichier<T>(instance, cb, excb, sentcb);
}
template<class T> Callback_ServeurIceMP3_lireMp3ParFichierPtr
newCallback_ServeurIceMP3_lireMp3ParFichier(T* instance, void (T::*cb)(const ::std::string&), void (T::*excb)(const ::Ice::Exception&), void (T::*sentcb)(bool) = 0)
{
return new CallbackNC_ServeurIceMP3_lireMp3ParFichier<T>(instance, cb, excb, sentcb);
}
template<class T, typename CT>
class Callback_ServeurIceMP3_lireMp3ParFichier : public Callback_ServeurIceMP3_lireMp3ParFichier_Base, public ::IceInternal::TwowayCallback<T, CT>
{
public:
typedef IceUtil::Handle<T> TPtr;
typedef void (T::*Exception)(const ::Ice::Exception& , const CT&);
typedef void (T::*Sent)(bool , const CT&);
typedef void (T::*Response)(const ::std::string&, const CT&);
Callback_ServeurIceMP3_lireMp3ParFichier(const TPtr& obj, Response cb, Exception excb, Sent sentcb)
: ::IceInternal::TwowayCallback<T, CT>(obj, cb != 0, excb, sentcb), response(cb)
{
}
virtual void __completed(const ::Ice::AsyncResultPtr& __result) const
{
::serveur::ServeurIceMP3Prx __proxy = ::serveur::ServeurIceMP3Prx::uncheckedCast(__result->getProxy());
::std::string __ret;
try
{
__ret = __proxy->end_lireMp3ParFichier(__result);
}
catch(::Ice::Exception& ex)
{
::IceInternal::Callback<T, CT>::__exception(__result, ex);
return;
}
if(response)
{
(::IceInternal::Callback<T, CT>::callback.get()->*response)(__ret, CT::dynamicCast(__result->getCookie()));
}
}
Response response;
};
template<class T, typename CT> Callback_ServeurIceMP3_lireMp3ParFichierPtr
newCallback_ServeurIceMP3_lireMp3ParFichier(const IceUtil::Handle<T>& instance, void (T::*cb)(const ::std::string&, const CT&), void (T::*excb)(const ::Ice::Exception&, const CT&), void (T::*sentcb)(bool, const CT&) = 0)
{
return new Callback_ServeurIceMP3_lireMp3ParFichier<T, CT>(instance, cb, excb, sentcb);
}
template<class T, typename CT> Callback_ServeurIceMP3_lireMp3ParFichierPtr
newCallback_ServeurIceMP3_lireMp3ParFichier(T* instance, void (T::*cb)(const ::std::string&, const CT&), void (T::*excb)(const ::Ice::Exception&, const CT&), void (T::*sentcb)(bool, const CT&) = 0)
{
return new Callback_ServeurIceMP3_lireMp3ParFichier<T, CT>(instance, cb, excb, sentcb);
}
template<class T>
class CallbackNC_ServeurIceMP3_stopMp3 : public Callback_ServeurIceMP3_stopMp3_Base, public ::IceInternal::TwowayCallbackNC<T>
{
public:
typedef IceUtil::Handle<T> TPtr;
typedef void (T::*Exception)(const ::Ice::Exception&);
typedef void (T::*Sent)(bool);
typedef void (T::*Response)(bool);
CallbackNC_ServeurIceMP3_stopMp3(const TPtr& obj, Response cb, Exception excb, Sent sentcb)
: ::IceInternal::TwowayCallbackNC<T>(obj, cb != 0, excb, sentcb), response(cb)
{
}
virtual void __completed(const ::Ice::AsyncResultPtr& __result) const
{
::serveur::ServeurIceMP3Prx __proxy = ::serveur::ServeurIceMP3Prx::uncheckedCast(__result->getProxy());
bool __ret;
try
{
__ret = __proxy->end_stopMp3(__result);
}
catch(::Ice::Exception& ex)
{
::IceInternal::CallbackNC<T>::__exception(__result, ex);
return;
}
if(response)
{
(::IceInternal::CallbackNC<T>::callback.get()->*response)(__ret);
}
}
Response response;
};
template<class T> Callback_ServeurIceMP3_stopMp3Ptr
newCallback_ServeurIceMP3_stopMp3(const IceUtil::Handle<T>& instance, void (T::*cb)(bool), void (T::*excb)(const ::Ice::Exception&), void (T::*sentcb)(bool) = 0)
{
return new CallbackNC_ServeurIceMP3_stopMp3<T>(instance, cb, excb, sentcb);
}
template<class T> Callback_ServeurIceMP3_stopMp3Ptr
newCallback_ServeurIceMP3_stopMp3(T* instance, void (T::*cb)(bool), void (T::*excb)(const ::Ice::Exception&), void (T::*sentcb)(bool) = 0)
{
return new CallbackNC_ServeurIceMP3_stopMp3<T>(instance, cb, excb, sentcb);
}
template<class T, typename CT>
class Callback_ServeurIceMP3_stopMp3 : public Callback_ServeurIceMP3_stopMp3_Base, public ::IceInternal::TwowayCallback<T, CT>
{
public:
typedef IceUtil::Handle<T> TPtr;
typedef void (T::*Exception)(const ::Ice::Exception& , const CT&);
typedef void (T::*Sent)(bool , const CT&);
typedef void (T::*Response)(bool, const CT&);
Callback_ServeurIceMP3_stopMp3(const TPtr& obj, Response cb, Exception excb, Sent sentcb)
: ::IceInternal::TwowayCallback<T, CT>(obj, cb != 0, excb, sentcb), response(cb)
{
}
virtual void __completed(const ::Ice::AsyncResultPtr& __result) const
{
::serveur::ServeurIceMP3Prx __proxy = ::serveur::ServeurIceMP3Prx::uncheckedCast(__result->getProxy());
bool __ret;
try
{
__ret = __proxy->end_stopMp3(__result);
}
catch(::Ice::Exception& ex)
{
::IceInternal::Callback<T, CT>::__exception(__result, ex);
return;
}
if(response)
{
(::IceInternal::Callback<T, CT>::callback.get()->*response)(__ret, CT::dynamicCast(__result->getCookie()));
}
}
Response response;
};
template<class T, typename CT> Callback_ServeurIceMP3_stopMp3Ptr
newCallback_ServeurIceMP3_stopMp3(const IceUtil::Handle<T>& instance, void (T::*cb)(bool, const CT&), void (T::*excb)(const ::Ice::Exception&, const CT&), void (T::*sentcb)(bool, const CT&) = 0)
{
return new Callback_ServeurIceMP3_stopMp3<T, CT>(instance, cb, excb, sentcb);
}
template<class T, typename CT> Callback_ServeurIceMP3_stopMp3Ptr
newCallback_ServeurIceMP3_stopMp3(T* instance, void (T::*cb)(bool, const CT&), void (T::*excb)(const ::Ice::Exception&, const CT&), void (T::*sentcb)(bool, const CT&) = 0)
{
return new Callback_ServeurIceMP3_stopMp3<T, CT>(instance, cb, excb, sentcb);
}
}
#endif
| [
"maxime.manos@gmail.com"
] | maxime.manos@gmail.com |
d9178347f1121bdd46d6b43b1817691b84ac603f | 61c16ab5057ae8a24af5d5b8a6c09c2a593031eb | /fd/src/search/pdbs/canonical_pdbs_heuristic.cc | 49df129e610e5834d96cfc3419168d4ef3f25eff | [] | no_license | YihuaLiang95/honors | 2a6204b88243cc601d22d8d16353d0b900560c96 | f051cbec4499864cc45929fffb3d132c304bce41 | refs/heads/master | 2020-04-27T23:04:48.323697 | 2018-05-05T07:47:39 | 2018-05-05T07:47:39 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 10,670 | cc | #include "canonical_pdbs_heuristic.h"
#include "dominance_pruner.h"
#include "max_cliques.h"
#include "pdb_heuristic.h"
#include "util.h"
#include "../globals.h"
#include "../operator.h"
#include "../option_parser.h"
#include "../plugin.h"
#include "../state.h"
#include "../timer.h"
#include "../utilities.h"
#include <cassert>
#include <cstdlib>
#include <vector>
using namespace std;
CanonicalPDBsHeuristic::CanonicalPDBsHeuristic(const Options &opts)
: Heuristic(opts) {
const vector<vector<int> > &pattern_collection(opts.get_list<vector<int> >("patterns"));
Timer timer;
size = 0;
pattern_databases.reserve(pattern_collection.size());
for (size_t i = 0; i < pattern_collection.size(); ++i)
_add_pattern(pattern_collection[i]);
compute_additive_vars();
compute_max_cliques();
cout << "PDB collection construction time: " << timer << endl;
}
CanonicalPDBsHeuristic::~CanonicalPDBsHeuristic() {
for (size_t i = 0; i < pattern_databases.size(); ++i) {
delete pattern_databases[i];
}
}
void CanonicalPDBsHeuristic::_add_pattern(const vector<int> &pattern) {
Options opts;
opts.set<int>("cost_type", cost_type);
opts.set<vector<int> >("pattern", pattern);
pattern_databases.push_back(new PDBHeuristic(opts, false));
size += pattern_databases.back()->get_size();
}
bool CanonicalPDBsHeuristic::are_patterns_additive(const vector<int> &patt1,
const vector<int> &patt2) const {
for (size_t i = 0; i < patt1.size(); ++i) {
for (size_t j = 0; j < patt2.size(); ++j) {
if (!are_additive[patt1[i]][patt2[j]]) {
return false;
}
}
}
return true;
}
void CanonicalPDBsHeuristic::compute_max_cliques() {
// initialize compatibility graph
max_cliques.clear();
vector<vector<int> > cgraph;
cgraph.resize(pattern_databases.size());
for (size_t i = 0; i < pattern_databases.size(); ++i) {
for (size_t j = i + 1; j < pattern_databases.size(); ++j) {
if (are_patterns_additive(pattern_databases[i]->get_pattern(),
pattern_databases[j]->get_pattern())) {
// if the two patterns are additive there is an edge in the compatibility graph
cgraph[i].push_back(j);
cgraph[j].push_back(i);
}
}
}
vector<vector<int> > cgraph_max_cliques;
::compute_max_cliques(cgraph, cgraph_max_cliques);
max_cliques.reserve(cgraph_max_cliques.size());
for (size_t i = 0; i < cgraph_max_cliques.size(); ++i) {
vector<PDBHeuristic *> clique;
clique.reserve(cgraph_max_cliques[i].size());
for (size_t j = 0; j < cgraph_max_cliques[i].size(); ++j) {
clique.push_back(pattern_databases[cgraph_max_cliques[i][j]]);
}
max_cliques.push_back(clique);
}
}
void CanonicalPDBsHeuristic::compute_additive_vars() {
assert(are_additive.empty());
int num_vars = g_variable_domain.size();
are_additive.resize(num_vars, vector<bool>(num_vars, true));
for (size_t k = 0; k < g_operators.size(); ++k) {
const Operator &o = g_operators[k];
const vector<PrePost> effects = o.get_pre_post();
for (size_t e1 = 0; e1 < effects.size(); ++e1) {
for (size_t e2 = 0; e2 < effects.size(); ++e2) {
are_additive[effects[e1].var][effects[e2].var] = false;
}
}
}
}
void CanonicalPDBsHeuristic::dominance_pruning() {
Timer timer;
int num_patterns = pattern_databases.size();
int num_cliques = max_cliques.size();
DominancePruner(pattern_databases, max_cliques).prune();
// Adjust size.
size = 0;
for (size_t i = 0; i < pattern_databases.size(); ++i) {
size += pattern_databases[i]->get_size();
}
cout << "Pruned " << num_cliques - max_cliques.size() <<
" of " << num_cliques << " cliques" << endl;
cout << "Pruned " << num_patterns - pattern_databases.size() <<
" of " << num_patterns << " PDBs" << endl;
cout << "Dominance pruning took " << timer << endl;
}
void CanonicalPDBsHeuristic::initialize() {
}
int CanonicalPDBsHeuristic::compute_heuristic(const State &state) {
int max_h = 0;
assert(!max_cliques.empty());
// if we have an empty collection, then max_cliques = { \emptyset }
for (size_t i = 0; i < pattern_databases.size(); ++i) {
pattern_databases[i]->evaluate(state);
if (pattern_databases[i]->is_dead_end())
return DEAD_END;
}
for (size_t i = 0; i < max_cliques.size(); ++i) {
const vector<PDBHeuristic *> &clique = max_cliques[i];
int clique_h = 0;
for (size_t j = 0; j < clique.size(); ++j) {
clique_h += clique[j]->get_heuristic();
}
max_h = max(max_h, clique_h);
}
return max_h;
}
void CanonicalPDBsHeuristic::add_pattern(const vector<int> &pattern) {
_add_pattern(pattern);
compute_max_cliques();
}
void CanonicalPDBsHeuristic::get_max_additive_subsets(
const vector<int> &new_pattern, vector<vector<PDBHeuristic *> > &max_additive_subsets) {
/*
We compute additive pattern sets S with the property that we could
add the new pattern P to S and still have an additive pattern set.
Ideally, we would like to return all *maximal* sets S with this
property (w.r.t. set inclusion), but we don't currently
guarantee this. (What we guarantee is that all maximal such sets
are *included* in the result, but the result could contain
duplicates or sets that are subsets of other sets in the
result.)
We currently implement this as follows:
* Consider all maximal additive subsets of the current collection.
* For each additive subset S, take the subset S' that contains
those patterns that are additive with the new pattern P.
* Include the subset S' in the result.
As an optimization, we actually only include S' in the result if
it is non-empty. However, this is wrong if *all* subsets we get
are empty, so we correct for this case at the end.
This may include dominated elements and duplicates in the result.
To avoid this, we could instead use the following algorithm:
* Let N (= neighbours) be the set of patterns in our current
collection that are additive with the new pattern P.
* Let G_N be the compatibility graph of the current collection
restricted to set N (i.e. drop all non-neighbours and their
incident edges.)
* Return the maximal cliques of G_N.
One nice thing about this alternative algorithm is that we could
also use it to incrementally compute the new set of maximal additive
pattern sets after adding the new pattern P:
G_N_cliques = max_cliques(G_N) // as above
new_max_cliques = (old_max_cliques \setminus G_N_cliques) \union
{ clique \union {P} | clique in G_N_cliques}
That is, the new set of maximal cliques is exactly the set of
those "old" cliques that we cannot extend by P
(old_max_cliques \setminus G_N_cliques) and all
"new" cliques including P.
*/
for (size_t i = 0; i < max_cliques.size(); ++i) {
// take all patterns which are additive to new_pattern
vector<PDBHeuristic *> subset;
subset.reserve(max_cliques[i].size());
for (size_t j = 0; j < max_cliques[i].size(); ++j) {
if (are_patterns_additive(new_pattern, max_cliques[i][j]->get_pattern())) {
subset.push_back(max_cliques[i][j]);
}
}
if (!subset.empty()) {
max_additive_subsets.push_back(subset);
}
}
if (max_additive_subsets.empty()) {
// If nothing was additive with the new variable, then
// the only additive subset is the empty set.
max_additive_subsets.push_back(vector<PDBHeuristic *>());
}
}
void CanonicalPDBsHeuristic::evaluate_dead_end(const State &state) {
int evaluator_value = 0;
for (size_t i = 0; i < pattern_databases.size(); ++i) {
pattern_databases[i]->evaluate(state);
if (pattern_databases[i]->is_dead_end()) {
evaluator_value = DEAD_END;
break;
}
}
set_evaluator_value(evaluator_value);
}
void CanonicalPDBsHeuristic::dump_cgraph(const vector<vector<int> > &cgraph) const {
// print compatibility graph
cout << "Compatibility graph" << endl;
for (size_t i = 0; i < cgraph.size(); ++i) {
cout << i << " adjacent to: ";
cout << cgraph[i] << endl;
}
}
void CanonicalPDBsHeuristic::dump_cliques() const {
// print maximal cliques
assert(!max_cliques.empty());
cout << max_cliques.size() << " maximal clique(s)" << endl;
cout << "Maximal cliques are (";
for (size_t i = 0; i < max_cliques.size(); ++i) {
cout << "[";
for (size_t j = 0; j < max_cliques[i].size(); ++j) {
vector<int> pattern = max_cliques[i][j]->get_pattern();
cout << "{ ";
for (size_t k = 0; k < pattern.size(); ++k) {
cout << pattern[k] << " ";
}
cout << "}";
}
cout << "]";
}
cout << ")" << endl;
}
void CanonicalPDBsHeuristic::dump() const {
for (size_t i = 0; i < pattern_databases.size(); ++i) {
cout << pattern_databases[i]->get_pattern() << endl;
}
}
static Heuristic *_parse(OptionParser &parser) {
parser.document_synopsis("Canonical PDB",
"The canonical pattern database heuristic is calculated as follows. "
"For a given pattern collection C, the value of the canonical heuristic "
"function is the maximum over all maximal additive subsets A in C, where "
"the value for one subset S in A is the sum of the heuristic values for "
"all patterns in S for a given state.");
parser.document_language_support("action costs", "supported");
parser.document_language_support("conditional effects", "not supported");
parser.document_language_support("axioms", "not supported");
parser.document_property("admissible", "yes");
parser.document_property("consistent", "yes");
parser.document_property("safe", "yes");
parser.document_property("preferred operators", "no");
Heuristic::add_options_to_parser(parser);
Options opts;
parse_patterns(parser, opts);
if (parser.dry_run())
return 0;
return new CanonicalPDBsHeuristic(opts);
}
static Plugin<Heuristic> _plugin("cpdbs", _parse);
| [
"u6487831@anu.edu.au"
] | u6487831@anu.edu.au |
35dd53701199f8b678212d57c172b64edbfa654c | 4462d31838cc56cfbac3e705c7ca1650c68ccecf | /Assignments/bin/a1/p735A.cpp | d09c3feb6f277abf01d2fcaf0d3b3be3cfc27222 | [] | no_license | WilliamLemens/Competitive | ad94c49addbe08f531d6528d127dbfdbfca27654 | 0fb20b65fa1698288272811a68bf4fe600062bf9 | refs/heads/master | 2021-09-19T18:56:20.400676 | 2018-07-30T23:41:45 | 2018-07-30T23:41:45 | 120,822,384 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 876 | cpp | #include <stdio.h>
#include <iostream>
int main() {
int len, leap;
std::cin >> len;
std::cin >> leap;
char board[len];
std::cin >> board;
int g = 0, t = 0, i = 0, found = 0;
while (i < len && found < 2) {
if (board[i] == 'G') {
g = i;
found++;
} else if (board[i] == 'T') {
t = i;
found++;
}
i++;
}
// Just a guick check to see if it's even possible without obstructions
if (t%leap != g%leap) {
std::cout << "NO" << std::endl;
return 0;
}
// Actual logic
if (t > g) {
g += leap;
while (g != t) {
if (board[g] != '.') {
std::cout << "NO" << std::endl;
return 0;
}
g += leap;
}
} else {
g -= leap;
while (g != t) {
if (board[g] != '.') {
std::cout << "NO" << std::endl;
return 0;
}
g -= leap;
}
}
std::cout << "YES" << std::endl;
}
| [
"william.lemens@gmail.com"
] | william.lemens@gmail.com |
a135172edc7f4c59f7585eb11871c2f3e70126e1 | c10025e21323f2b6719a6431cac74d4dd16c35cc | /engine/src/rendering/transform.cpp | 195983d3d4717b1981dd8cef75e6700d8299dac2 | [] | no_license | rockz-lab/3D_rendering | 259a53500601a17dd3890c06a635cb14c3cc859d | 3ea49f04a6a4ee2014364ebb9d3ca727c801e454 | refs/heads/main | 2023-02-19T22:36:42.507469 | 2021-01-24T15:18:59 | 2021-01-24T15:18:59 | 310,270,434 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 461 | cpp | #include "transform.h"
Transform::Transform()
{
this->pos = glm::vec3(0.0, 0.0, 0.0);
this->rpy = glm::vec3(0.0, 0.0, 0.0);
this->scale = glm::vec3(1.0, 1.0, 1.0);
}
Transform::Transform(glm::vec3 pos, glm::vec3 rpy)
{
this->pos = pos;
this->rpy = rpy;
this->scale = glm::vec3(1.0, 1.0, 1.0);
}
Transform::Transform(glm::vec3 pos, glm::vec3 rpy, glm::vec3 scale)
{
this->pos = pos;
this->rpy = rpy;
this->scale = scale;
} | [
"uzdpx@student.kit.edu"
] | uzdpx@student.kit.edu |
25c5a7ee0bfa0cf27cd9d05178de770a807b4f90 | ce241347f9cb284b837d152e61187f081e3d01a9 | /Background.hpp | 0a775f7d22cfc4faf3e7f0dfc12c9ddf0ebc678b | [] | no_license | etienneFontaine35/Guillaume_VS_EMSE | 2875085402f62455c35b1d7dfa78a186c7650110 | ff1fe2c38493c798e84eb45c3fb0a75cb2423889 | refs/heads/master | 2022-07-19T20:55:58.713881 | 2020-05-16T17:35:06 | 2020-05-16T17:35:06 | 170,454,604 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,795 | hpp | #include <SFML/Graphics.hpp>
#include <string>
#include <vector>
#include <iostream>
#include <ctime>
#include "Objet_Volant.hpp"
#include "Tools.hpp"
class Background
{
public :
Background(std::string textureFondPremier_file, std::string textureFondDeuxieme_file, std::string textureParticuleBack_file, std::string textureParticuleFront_file, sf::RenderWindow& fenetre, int const dimension[]);
void apparaitreFront(int const dimension[]);
void apparaitreBack(int const dimension[]);
void disparaitreFront(int const dimension[]);
void disparaitreBack(int const dimension[]);
void scrolling(int const dimension[]);
void afficher();
void mettreAJour(int const dimension[]);
private :
sf::Texture m_textureFondPremier;
sf::Sprite m_spriteFondPremier;
sf::Texture m_textureFondDeuxieme;
sf::Sprite m_spriteFondDeuxieme;
sf::Texture m_textureParticuleBack;
sf::Sprite m_spriteParticuleBack;
sf::Texture m_textureParticuleFront;
sf::Sprite m_spriteParticuleFront;
std::vector<ObjVolant> m_particulesFrontEnCours;
std::vector<ObjVolant> m_particulesBackEnCours;
ObjVolant m_premierFond;
ObjVolant m_deuxiemeFond;
sf::RenderWindow& m_fenetre;
};
class Opening
{
public :
Opening(std::string fichierImage, Inputs& inputs, Hud& hud, int tempsAffichage, int tempsApparition);
Opening(std::string fichierImage, Inputs& inputs, Hud& hud, int tempsAffichage);
void executer(sf::RenderWindow& fenetre);
void executer(sf::RenderWindow& fenetre, std::string texte, int tailleTexte, int const dimension[]);
void setTempsAffichage(int temps);
private :
Hud& m_texte;
Inputs& m_inputs;
int m_tempsAffichage;
int m_tempsApparition;
sf::Texture m_imageTexture;
sf::Sprite m_imageSprite;
sf::Clock m_timerAffichage;
};
| [
"etienne.fontaine35@gmail.com"
] | etienne.fontaine35@gmail.com |
78d9d0ac7503e501e498ce0de47c8f6b1514114f | 31ac07ecd9225639bee0d08d00f037bd511e9552 | /externals/OCCTLib/inc/Vrml_ShapeHints.hxx | fd43a3a8802e7a37b1fa8d3a0f60efc039f46a0d | [] | no_license | litao1009/SimpleRoom | 4520e0034e4f90b81b922657b27f201842e68e8e | 287de738c10b86ff8f61b15e3b8afdfedbcb2211 | refs/heads/master | 2021-01-20T19:56:39.507899 | 2016-07-29T08:01:57 | 2016-07-29T08:01:57 | 64,462,604 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,849 | hxx | // This file is generated by WOK (CPPExt).
// Please do not edit this file; modify original file instead.
// The copyright and license terms as defined for the original file apply to
// this header file considered to be the "object code" form of the original source.
#ifndef _Vrml_ShapeHints_HeaderFile
#define _Vrml_ShapeHints_HeaderFile
#ifndef _Standard_HeaderFile
#include <Standard.hxx>
#endif
#ifndef _Standard_DefineAlloc_HeaderFile
#include <Standard_DefineAlloc.hxx>
#endif
#ifndef _Standard_Macro_HeaderFile
#include <Standard_Macro.hxx>
#endif
#ifndef _Vrml_VertexOrdering_HeaderFile
#include <Vrml_VertexOrdering.hxx>
#endif
#ifndef _Vrml_ShapeType_HeaderFile
#include <Vrml_ShapeType.hxx>
#endif
#ifndef _Vrml_FaceType_HeaderFile
#include <Vrml_FaceType.hxx>
#endif
#ifndef _Standard_Real_HeaderFile
#include <Standard_Real.hxx>
#endif
#ifndef _Standard_OStream_HeaderFile
#include <Standard_OStream.hxx>
#endif
//! defines a ShapeHints node of VRML specifying properties of geometry and its appearance. <br>
//! The ShapeHints node indicates that IndexedFaceSets are solid, contain ordered vertices, or <br>
//! contain convex faces. <br>
//! These hints allow VRML implementations to optimize certain rendering features. <br>
//! Optimizations that may be performed include enabling back-face culling and disabling <br>
//! two-sided lighting. For example, if an object is solid and has ordered vertices, an <br>
//! implementation may turn on backface culling and turn off two-sided lighting. To ensure <br>
//! that an IndexedFaceSet can be viewed from either direction, set shapeType to be <br>
//! UNKNOWN_SHAPE_TYPE. <br>
//! If you know that your shapes are closed and will alwsys be viewed from the outside, set <br>
//! vertexOrdering to be either CLOCKWISE or COUNTERCLOCKWISE (depending on <br>
//! how you built your object), and set shapeType to be SOLID. Placing this near the top of <br>
//! your VRML file will allow the scene to be rendered much faster. <br>
//! The ShapeHints node also affects how default normals are generated. When an <br>
//! IndexedFaceSet has to generate default normals, it uses the creaseAngle field to determine <br>
//! which edges should be smoothly shaded and which ones should have a sharp crease. The <br>
//! crease angle is the angle between surface normals on adjacent polygons. For example, a <br>
//! crease angle of .5 radians (the default value) means that an edge between two adjacent <br>
//! polygonal faces will be smooth shaded if the normals to the two faces form an angle that is <br>
//! less than .5 radians (about 30 degrees). Otherwise, it will be faceted. <br>
class Vrml_ShapeHints {
public:
DEFINE_STANDARD_ALLOC
Standard_EXPORT Vrml_ShapeHints(const Vrml_VertexOrdering aVertexOrdering = Vrml_UNKNOWN_ORDERING,const Vrml_ShapeType aShapeType = Vrml_UNKNOWN_SHAPE_TYPE,const Vrml_FaceType aFaceType = Vrml_CONVEX,const Standard_Real aAngle = 0.5);
Standard_EXPORT void SetVertexOrdering(const Vrml_VertexOrdering aVertexOrdering) ;
Standard_EXPORT Vrml_VertexOrdering VertexOrdering() const;
Standard_EXPORT void SetShapeType(const Vrml_ShapeType aShapeType) ;
Standard_EXPORT Vrml_ShapeType ShapeType() const;
Standard_EXPORT void SetFaceType(const Vrml_FaceType aFaceType) ;
Standard_EXPORT Vrml_FaceType FaceType() const;
Standard_EXPORT void SetAngle(const Standard_Real aAngle) ;
Standard_EXPORT Standard_Real Angle() const;
Standard_EXPORT Standard_OStream& Print(Standard_OStream& anOStream) const;
protected:
private:
Vrml_VertexOrdering myVertexOrdering;
Vrml_ShapeType myShapeType;
Vrml_FaceType myFaceType;
Standard_Real myAngle;
};
// other Inline functions and methods (like "C++: function call" methods)
#endif
| [
"litao1009@gmail.com"
] | litao1009@gmail.com |
4aa835a070c04f59e3f0de2f75881a982f607da7 | b0a6e931ab45abc968b4f4f171545229bc5abdb4 | /d5/ex05/RobotomyRequestForm.hpp | e2029baefc80ff1e4dbe4db0ac954709999af2f6 | [] | no_license | interstates21/cpp-piscine | 57c7cc1d7d0e2a8feb8b56513c409c00f54ea80a | a0289d3d3f09e66156f144f1a76224d0e64cb328 | refs/heads/master | 2022-01-14T14:04:34.708473 | 2019-07-13T13:11:52 | 2019-07-13T13:11:52 | 193,234,766 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 462 | hpp | #ifndef ROBOTOMY_HPP
#define ROBOTOMY_HPP
#include <iostream>
#include "Form.hpp"
class RobotomyRequestForm : public Form
{
private:
std::string _target;
RobotomyRequestForm();
public:
RobotomyRequestForm(std::string &);
virtual ~RobotomyRequestForm();
RobotomyRequestForm(RobotomyRequestForm &);
RobotomyRequestForm &operator=(RobotomyRequestForm const &);
virtual void execute(Bureaucrat const &executor) const;
};
#endif
| [
"okupin@e1r7p5.unit.ua"
] | okupin@e1r7p5.unit.ua |
878eef755e78f3fd401ad0397c8f687a4b1513ea | 9fad4848e43f4487730185e4f50e05a044f865ab | /src/components/scheduler/child/idle_helper_unittest.cc | 37a6e1b2f303cebe17368d396b09471b7d88783e | [
"BSD-3-Clause"
] | permissive | dummas2008/chromium | d1b30da64f0630823cb97f58ec82825998dbb93e | 82d2e84ce3ed8a00dc26c948219192c3229dfdaa | refs/heads/master | 2020-12-31T07:18:45.026190 | 2016-04-14T03:17:45 | 2016-04-14T03:17:45 | 56,194,439 | 4 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 41,926 | cc | // Copyright 2015 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 "components/scheduler/child/idle_helper.h"
#include <utility>
#include "base/callback.h"
#include "base/macros.h"
#include "base/test/simple_test_tick_clock.h"
#include "cc/test/ordered_simple_task_runner.h"
#include "components/scheduler/base/real_time_domain.h"
#include "components/scheduler/base/task_queue.h"
#include "components/scheduler/base/task_queue_manager.h"
#include "components/scheduler/base/test_time_source.h"
#include "components/scheduler/child/scheduler_helper.h"
#include "components/scheduler/child/scheduler_tqm_delegate_for_test.h"
#include "components/scheduler/child/scheduler_tqm_delegate_impl.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
using testing::_;
using testing::AnyNumber;
using testing::AtLeast;
using testing::Exactly;
using testing::Invoke;
using testing::Return;
namespace scheduler {
namespace {
void AppendToVectorTestTask(std::vector<std::string>* vector,
std::string value) {
vector->push_back(value);
}
void AppendToVectorIdleTestTask(std::vector<std::string>* vector,
std::string value,
base::TimeTicks deadline) {
AppendToVectorTestTask(vector, value);
}
void NullTask() {
}
void NullIdleTask(base::TimeTicks deadline) {
}
void AppendToVectorReentrantTask(base::SingleThreadTaskRunner* task_runner,
std::vector<int>* vector,
int* reentrant_count,
int max_reentrant_count) {
vector->push_back((*reentrant_count)++);
if (*reentrant_count < max_reentrant_count) {
task_runner->PostTask(
FROM_HERE,
base::Bind(AppendToVectorReentrantTask, base::Unretained(task_runner),
vector, reentrant_count, max_reentrant_count));
}
}
void IdleTestTask(int* run_count,
base::TimeTicks* deadline_out,
base::TimeTicks deadline) {
(*run_count)++;
*deadline_out = deadline;
}
int max_idle_task_reposts = 2;
void RepostingIdleTestTask(SingleThreadIdleTaskRunner* idle_task_runner,
int* run_count,
base::TimeTicks* deadline_out,
base::TimeTicks deadline) {
if ((*run_count + 1) < max_idle_task_reposts) {
idle_task_runner->PostIdleTask(
FROM_HERE,
base::Bind(&RepostingIdleTestTask, base::Unretained(idle_task_runner),
run_count, deadline_out));
}
*deadline_out = deadline;
(*run_count)++;
}
void RepostingUpdateClockIdleTestTask(
SingleThreadIdleTaskRunner* idle_task_runner,
int* run_count,
base::SimpleTestTickClock* clock,
base::TimeDelta advance_time,
std::vector<base::TimeTicks>* deadlines,
base::TimeTicks deadline) {
if ((*run_count + 1) < max_idle_task_reposts) {
idle_task_runner->PostIdleTask(
FROM_HERE, base::Bind(&RepostingUpdateClockIdleTestTask,
base::Unretained(idle_task_runner), run_count,
clock, advance_time, deadlines));
}
deadlines->push_back(deadline);
(*run_count)++;
clock->Advance(advance_time);
}
void RepeatingTask(base::SingleThreadTaskRunner* task_runner,
int num_repeats,
base::TimeDelta delay) {
if (num_repeats > 1) {
task_runner->PostDelayedTask(
FROM_HERE, base::Bind(&RepeatingTask, base::Unretained(task_runner),
num_repeats - 1, delay),
delay);
}
}
void UpdateClockIdleTestTask(base::SimpleTestTickClock* clock,
int* run_count,
base::TimeTicks set_time,
base::TimeTicks deadline) {
clock->Advance(set_time - clock->NowTicks());
(*run_count)++;
}
void UpdateClockToDeadlineIdleTestTask(base::SimpleTestTickClock* clock,
int* run_count,
base::TimeTicks deadline) {
UpdateClockIdleTestTask(clock, run_count, deadline, deadline);
}
void EndIdlePeriodIdleTask(IdleHelper* idle_helper, base::TimeTicks deadline) {
idle_helper->EndIdlePeriod();
}
scoped_refptr<SchedulerTqmDelegate> CreateTaskRunnerDelegate(
base::MessageLoop* message_loop,
scoped_refptr<cc::OrderedSimpleTaskRunner> mock_task_runner,
scoped_ptr<TestTimeSource> test_time_source) {
if (message_loop)
return SchedulerTqmDelegateImpl::Create(message_loop,
std::move(test_time_source));
return SchedulerTqmDelegateForTest::Create(mock_task_runner,
std::move(test_time_source));
}
}; // namespace
class IdleHelperForTest : public IdleHelper, public IdleHelper::Delegate {
public:
explicit IdleHelperForTest(
SchedulerHelper* scheduler_helper,
base::TimeDelta required_quiescence_duration_before_long_idle_period)
: IdleHelper(scheduler_helper,
this,
"test.idle",
TRACE_DISABLED_BY_DEFAULT("test.idle"),
"TestSchedulerIdlePeriod",
required_quiescence_duration_before_long_idle_period) {}
~IdleHelperForTest() override {}
// SchedulerHelperDelegate implementation:
MOCK_METHOD2(CanEnterLongIdlePeriod,
bool(base::TimeTicks now,
base::TimeDelta* next_long_idle_period_delay_out));
MOCK_METHOD0(IsNotQuiescent, void());
MOCK_METHOD0(OnIdlePeriodStarted, void());
MOCK_METHOD0(OnIdlePeriodEnded, void());
};
class BaseIdleHelperTest : public testing::Test {
public:
BaseIdleHelperTest(
base::MessageLoop* message_loop,
base::TimeDelta required_quiescence_duration_before_long_idle_period)
: clock_(new base::SimpleTestTickClock()),
mock_task_runner_(
message_loop
? nullptr
: new cc::OrderedSimpleTaskRunner(clock_.get(), false)),
message_loop_(message_loop),
main_task_runner_(CreateTaskRunnerDelegate(
message_loop,
mock_task_runner_,
make_scoped_ptr(new TestTimeSource(clock_.get())))),
scheduler_helper_(
new SchedulerHelper(main_task_runner_,
"test.idle",
TRACE_DISABLED_BY_DEFAULT("test.idle"),
TRACE_DISABLED_BY_DEFAULT("test.idle.debug"))),
idle_helper_(new IdleHelperForTest(
scheduler_helper_.get(),
required_quiescence_duration_before_long_idle_period)),
default_task_runner_(scheduler_helper_->DefaultTaskRunner()),
idle_task_runner_(idle_helper_->IdleTaskRunner()) {
clock_->Advance(base::TimeDelta::FromMicroseconds(5000));
}
~BaseIdleHelperTest() override {}
void SetUp() override {
EXPECT_CALL(*idle_helper_, OnIdlePeriodStarted()).Times(AnyNumber());
EXPECT_CALL(*idle_helper_, OnIdlePeriodEnded()).Times(AnyNumber());
EXPECT_CALL(*idle_helper_, CanEnterLongIdlePeriod(_, _))
.Times(AnyNumber())
.WillRepeatedly(Return(true));
}
void TearDown() override {
DCHECK(!mock_task_runner_.get() || !message_loop_.get());
if (mock_task_runner_.get()) {
// Check that all tests stop posting tasks.
mock_task_runner_->SetAutoAdvanceNowToPendingTasks(true);
while (mock_task_runner_->RunUntilIdle()) {
}
} else {
message_loop_->RunUntilIdle();
}
}
void RunUntilIdle() {
// Only one of mock_task_runner_ or message_loop_ should be set.
DCHECK(!mock_task_runner_.get() || !message_loop_.get());
if (mock_task_runner_.get())
mock_task_runner_->RunUntilIdle();
else
message_loop_->RunUntilIdle();
}
template <typename E>
static void CallForEachEnumValue(E first,
E last,
const char* (*function)(E)) {
for (E val = first; val < last;
val = static_cast<E>(static_cast<int>(val) + 1)) {
(*function)(val);
}
}
static void CheckAllTaskQueueIdToString() {
CallForEachEnumValue<IdleHelper::IdlePeriodState>(
IdleHelper::IdlePeriodState::FIRST_IDLE_PERIOD_STATE,
IdleHelper::IdlePeriodState::IDLE_PERIOD_STATE_COUNT,
&IdleHelper::IdlePeriodStateToString);
}
bool IsInIdlePeriod() const {
return idle_helper_->IsInIdlePeriod(
idle_helper_->SchedulerIdlePeriodState());
}
protected:
static base::TimeDelta maximum_idle_period_duration() {
return base::TimeDelta::FromMilliseconds(
IdleHelper::kMaximumIdlePeriodMillis);
}
static base::TimeDelta retry_enable_long_idle_period_delay() {
return base::TimeDelta::FromMilliseconds(
IdleHelper::kRetryEnableLongIdlePeriodDelayMillis);
}
static base::TimeDelta minimum_idle_period_duration() {
return base::TimeDelta::FromMilliseconds(
IdleHelper::kMinimumIdlePeriodDurationMillis);
}
base::TimeTicks CurrentIdleTaskDeadline() {
return idle_helper_->CurrentIdleTaskDeadline();
}
void CheckIdlePeriodStateIs(const char* expected) {
EXPECT_STREQ(expected, IdleHelper::IdlePeriodStateToString(
idle_helper_->SchedulerIdlePeriodState()));
}
scoped_ptr<base::SimpleTestTickClock> clock_;
// Only one of mock_task_runner_ or message_loop_ will be set.
scoped_refptr<cc::OrderedSimpleTaskRunner> mock_task_runner_;
scoped_ptr<base::MessageLoop> message_loop_;
scoped_refptr<SchedulerTqmDelegate> main_task_runner_;
scoped_ptr<SchedulerHelper> scheduler_helper_;
scoped_ptr<IdleHelperForTest> idle_helper_;
scoped_refptr<base::SingleThreadTaskRunner> default_task_runner_;
scoped_refptr<SingleThreadIdleTaskRunner> idle_task_runner_;
DISALLOW_COPY_AND_ASSIGN(BaseIdleHelperTest);
};
class IdleHelperTest : public BaseIdleHelperTest {
public:
IdleHelperTest() : BaseIdleHelperTest(nullptr, base::TimeDelta()) {}
~IdleHelperTest() override {}
TaskQueueManager* task_queue_manager() const {
return scheduler_helper_->GetTaskQueueManagerForTesting();
}
private:
DISALLOW_COPY_AND_ASSIGN(IdleHelperTest);
};
TEST_F(IdleHelperTest, TestPostIdleTask) {
int run_count = 0;
base::TimeTicks expected_deadline =
clock_->NowTicks() + base::TimeDelta::FromMilliseconds(2300);
base::TimeTicks deadline_in_task;
clock_->Advance(base::TimeDelta::FromMilliseconds(100));
idle_task_runner_->PostIdleTask(
FROM_HERE, base::Bind(&IdleTestTask, &run_count, &deadline_in_task));
RunUntilIdle();
EXPECT_EQ(0, run_count);
idle_helper_->StartIdlePeriod(
IdleHelper::IdlePeriodState::IN_SHORT_IDLE_PERIOD, clock_->NowTicks(),
expected_deadline);
RunUntilIdle();
EXPECT_EQ(1, run_count);
EXPECT_EQ(expected_deadline, deadline_in_task);
}
TEST_F(IdleHelperTest, TestPostIdleTask_EndIdlePeriod) {
int run_count = 0;
base::TimeTicks deadline_in_task;
clock_->Advance(base::TimeDelta::FromMilliseconds(100));
idle_task_runner_->PostIdleTask(
FROM_HERE, base::Bind(&IdleTestTask, &run_count, &deadline_in_task));
RunUntilIdle();
EXPECT_EQ(0, run_count);
idle_helper_->StartIdlePeriod(
IdleHelper::IdlePeriodState::IN_SHORT_IDLE_PERIOD, clock_->NowTicks(),
clock_->NowTicks() + base::TimeDelta::FromMilliseconds(10));
idle_helper_->EndIdlePeriod();
RunUntilIdle();
EXPECT_EQ(0, run_count);
}
TEST_F(IdleHelperTest, TestRepostingIdleTask) {
base::TimeTicks actual_deadline;
int run_count = 0;
max_idle_task_reposts = 2;
idle_task_runner_->PostIdleTask(
FROM_HERE,
base::Bind(&RepostingIdleTestTask, base::RetainedRef(idle_task_runner_),
&run_count, &actual_deadline));
idle_helper_->StartIdlePeriod(
IdleHelper::IdlePeriodState::IN_SHORT_IDLE_PERIOD, clock_->NowTicks(),
clock_->NowTicks() + base::TimeDelta::FromMilliseconds(10));
RunUntilIdle();
EXPECT_EQ(1, run_count);
// Reposted tasks shouldn't run until next idle period.
RunUntilIdle();
EXPECT_EQ(1, run_count);
idle_helper_->StartIdlePeriod(
IdleHelper::IdlePeriodState::IN_SHORT_IDLE_PERIOD, clock_->NowTicks(),
clock_->NowTicks() + base::TimeDelta::FromMilliseconds(10));
RunUntilIdle();
EXPECT_EQ(2, run_count);
}
TEST_F(IdleHelperTest, TestIdleTaskExceedsDeadline) {
int run_count = 0;
// Post two UpdateClockToDeadlineIdleTestTask tasks.
idle_task_runner_->PostIdleTask(
FROM_HERE,
base::Bind(&UpdateClockToDeadlineIdleTestTask, clock_.get(), &run_count));
idle_task_runner_->PostIdleTask(
FROM_HERE,
base::Bind(&UpdateClockToDeadlineIdleTestTask, clock_.get(), &run_count));
idle_helper_->StartIdlePeriod(
IdleHelper::IdlePeriodState::IN_SHORT_IDLE_PERIOD, clock_->NowTicks(),
clock_->NowTicks() + base::TimeDelta::FromMilliseconds(10));
RunUntilIdle();
// Only the first idle task should execute since it's used up the deadline.
EXPECT_EQ(1, run_count);
idle_helper_->EndIdlePeriod();
idle_helper_->StartIdlePeriod(
IdleHelper::IdlePeriodState::IN_SHORT_IDLE_PERIOD, clock_->NowTicks(),
clock_->NowTicks() + base::TimeDelta::FromMilliseconds(10));
RunUntilIdle();
// Second task should be run on the next idle period.
EXPECT_EQ(2, run_count);
}
TEST_F(IdleHelperTest, TestPostIdleTaskAfterWakeup) {
base::TimeTicks deadline_in_task;
int run_count = 0;
idle_task_runner_->PostIdleTaskAfterWakeup(
FROM_HERE, base::Bind(&IdleTestTask, &run_count, &deadline_in_task));
idle_helper_->StartIdlePeriod(
IdleHelper::IdlePeriodState::IN_SHORT_IDLE_PERIOD, clock_->NowTicks(),
clock_->NowTicks() + base::TimeDelta::FromMilliseconds(10));
RunUntilIdle();
// Shouldn't run yet as no other task woke up the scheduler.
EXPECT_EQ(0, run_count);
// Must start a new idle period before idle task runs.
idle_task_runner_->PostIdleTaskAfterWakeup(
FROM_HERE, base::Bind(&IdleTestTask, &run_count, &deadline_in_task));
idle_helper_->StartIdlePeriod(
IdleHelper::IdlePeriodState::IN_SHORT_IDLE_PERIOD, clock_->NowTicks(),
clock_->NowTicks() + base::TimeDelta::FromMilliseconds(10));
RunUntilIdle();
// Another after wakeup idle task shouldn't wake the scheduler.
EXPECT_EQ(0, run_count);
default_task_runner_->PostTask(FROM_HERE, base::Bind(&NullTask));
RunUntilIdle();
idle_helper_->StartIdlePeriod(
IdleHelper::IdlePeriodState::IN_SHORT_IDLE_PERIOD, clock_->NowTicks(),
clock_->NowTicks() + base::TimeDelta::FromMilliseconds(10));
RunUntilIdle();
// Execution of default task queue task should trigger execution of idle task.
EXPECT_EQ(2, run_count);
}
TEST_F(IdleHelperTest, TestPostIdleTaskAfterWakeupWhileAwake) {
base::TimeTicks deadline_in_task;
int run_count = 0;
idle_task_runner_->PostIdleTaskAfterWakeup(
FROM_HERE, base::Bind(&IdleTestTask, &run_count, &deadline_in_task));
default_task_runner_->PostTask(FROM_HERE, base::Bind(&NullTask));
RunUntilIdle();
// Must start a new idle period before idle task runs.
idle_helper_->StartIdlePeriod(
IdleHelper::IdlePeriodState::IN_SHORT_IDLE_PERIOD, clock_->NowTicks(),
clock_->NowTicks() + base::TimeDelta::FromMilliseconds(10));
RunUntilIdle();
// Should run as the scheduler was already awakened by the normal task.
EXPECT_EQ(1, run_count);
}
TEST_F(IdleHelperTest, TestPostIdleTaskWakesAfterWakeupIdleTask) {
base::TimeTicks deadline_in_task;
int run_count = 0;
idle_task_runner_->PostIdleTaskAfterWakeup(
FROM_HERE, base::Bind(&IdleTestTask, &run_count, &deadline_in_task));
idle_task_runner_->PostIdleTask(
FROM_HERE, base::Bind(&IdleTestTask, &run_count, &deadline_in_task));
idle_helper_->StartIdlePeriod(
IdleHelper::IdlePeriodState::IN_SHORT_IDLE_PERIOD, clock_->NowTicks(),
clock_->NowTicks() + base::TimeDelta::FromMilliseconds(10));
RunUntilIdle();
// Must start a new idle period before after-wakeup idle task runs.
idle_helper_->StartIdlePeriod(
IdleHelper::IdlePeriodState::IN_SHORT_IDLE_PERIOD, clock_->NowTicks(),
clock_->NowTicks() + base::TimeDelta::FromMilliseconds(10));
RunUntilIdle();
// Normal idle task should wake up after-wakeup idle task.
EXPECT_EQ(2, run_count);
}
class IdleHelperTestWithIdlePeriodObserver : public BaseIdleHelperTest {
public:
IdleHelperTestWithIdlePeriodObserver()
: BaseIdleHelperTest(nullptr, base::TimeDelta()) {}
~IdleHelperTestWithIdlePeriodObserver() override {}
void SetUp() override {
// Don't set expectations on IdleHelper::Delegate.
}
TaskQueueManager* task_queue_manager() const {
return scheduler_helper_->GetTaskQueueManagerForTesting();
}
void ExpectIdlePeriodStartsButNeverEnds() {
EXPECT_CALL(*idle_helper_, OnIdlePeriodStarted()).Times(1);
EXPECT_CALL(*idle_helper_, OnIdlePeriodEnded()).Times(0);
}
void ExpectIdlePeriodStartsAndEnds(const testing::Cardinality& cardinality) {
EXPECT_CALL(*idle_helper_, OnIdlePeriodStarted()).Times(cardinality);
EXPECT_CALL(*idle_helper_, OnIdlePeriodEnded()).Times(cardinality);
}
private:
DISALLOW_COPY_AND_ASSIGN(IdleHelperTestWithIdlePeriodObserver);
};
TEST_F(IdleHelperTestWithIdlePeriodObserver, TestEnterButNotExitIdlePeriod) {
ExpectIdlePeriodStartsButNeverEnds();
idle_helper_->StartIdlePeriod(
IdleHelper::IdlePeriodState::IN_SHORT_IDLE_PERIOD, clock_->NowTicks(),
clock_->NowTicks() + base::TimeDelta::FromMilliseconds(10));
}
TEST_F(IdleHelperTestWithIdlePeriodObserver, TestEnterAndExitIdlePeriod) {
BaseIdleHelperTest* fixture = this;
ON_CALL(*idle_helper_, OnIdlePeriodStarted())
.WillByDefault(
Invoke([fixture]() { EXPECT_TRUE(fixture->IsInIdlePeriod()); }));
ON_CALL(*idle_helper_, OnIdlePeriodEnded())
.WillByDefault(
Invoke([fixture]() { EXPECT_FALSE(fixture->IsInIdlePeriod()); }));
ExpectIdlePeriodStartsAndEnds(Exactly(1));
idle_helper_->StartIdlePeriod(
IdleHelper::IdlePeriodState::IN_SHORT_IDLE_PERIOD, clock_->NowTicks(),
clock_->NowTicks() + base::TimeDelta::FromMilliseconds(10));
idle_helper_->EndIdlePeriod();
}
class IdleHelperWithMessageLoopTest : public BaseIdleHelperTest {
public:
IdleHelperWithMessageLoopTest()
: BaseIdleHelperTest(new base::MessageLoop(), base::TimeDelta()) {}
~IdleHelperWithMessageLoopTest() override {}
void PostFromNestedRunloop(std::vector<
std::pair<SingleThreadIdleTaskRunner::IdleTask, bool>>* tasks) {
base::MessageLoop::ScopedNestableTaskAllower allow(message_loop_.get());
for (std::pair<SingleThreadIdleTaskRunner::IdleTask, bool>& pair : *tasks) {
if (pair.second) {
idle_task_runner_->PostIdleTask(FROM_HERE, pair.first);
} else {
idle_task_runner_->PostNonNestableIdleTask(FROM_HERE, pair.first);
}
}
idle_helper_->StartIdlePeriod(
IdleHelper::IdlePeriodState::IN_SHORT_IDLE_PERIOD, clock_->NowTicks(),
clock_->NowTicks() + base::TimeDelta::FromMilliseconds(10));
message_loop_->RunUntilIdle();
}
void SetUp() override {
EXPECT_CALL(*idle_helper_, OnIdlePeriodStarted()).Times(AnyNumber());
EXPECT_CALL(*idle_helper_, OnIdlePeriodEnded()).Times(AnyNumber());
}
private:
DISALLOW_COPY_AND_ASSIGN(IdleHelperWithMessageLoopTest);
};
TEST_F(IdleHelperWithMessageLoopTest,
NonNestableIdleTaskDoesntExecuteInNestedLoop) {
std::vector<std::string> order;
idle_task_runner_->PostIdleTask(
FROM_HERE,
base::Bind(&AppendToVectorIdleTestTask, &order, std::string("1")));
idle_task_runner_->PostIdleTask(
FROM_HERE,
base::Bind(&AppendToVectorIdleTestTask, &order, std::string("2")));
std::vector<std::pair<SingleThreadIdleTaskRunner::IdleTask, bool>>
tasks_to_post_from_nested_loop;
tasks_to_post_from_nested_loop.push_back(std::make_pair(
base::Bind(&AppendToVectorIdleTestTask, &order, std::string("3")),
false));
tasks_to_post_from_nested_loop.push_back(std::make_pair(
base::Bind(&AppendToVectorIdleTestTask, &order, std::string("4")), true));
tasks_to_post_from_nested_loop.push_back(std::make_pair(
base::Bind(&AppendToVectorIdleTestTask, &order, std::string("5")), true));
default_task_runner_->PostTask(
FROM_HERE,
base::Bind(&IdleHelperWithMessageLoopTest::PostFromNestedRunloop,
base::Unretained(this),
base::Unretained(&tasks_to_post_from_nested_loop)));
idle_helper_->StartIdlePeriod(
IdleHelper::IdlePeriodState::IN_SHORT_IDLE_PERIOD, clock_->NowTicks(),
clock_->NowTicks() + base::TimeDelta::FromMilliseconds(10));
RunUntilIdle();
// Note we expect task 3 to run last because it's non-nestable.
EXPECT_THAT(order, testing::ElementsAre(std::string("1"), std::string("2"),
std::string("4"), std::string("5"),
std::string("3")));
}
TEST_F(IdleHelperTestWithIdlePeriodObserver, TestLongIdlePeriod) {
base::TimeTicks expected_deadline =
clock_->NowTicks() + maximum_idle_period_duration();
base::TimeTicks deadline_in_task;
int run_count = 0;
idle_task_runner_->PostIdleTask(
FROM_HERE, base::Bind(&IdleTestTask, &run_count, &deadline_in_task));
EXPECT_CALL(*idle_helper_, CanEnterLongIdlePeriod(_, _))
.Times(1)
.WillRepeatedly(Return(true));
ExpectIdlePeriodStartsButNeverEnds();
RunUntilIdle();
EXPECT_EQ(0, run_count); // Shouldn't run yet as no idle period.
idle_helper_->EnableLongIdlePeriod();
RunUntilIdle();
EXPECT_EQ(1, run_count); // Should have run in a long idle time.
EXPECT_EQ(expected_deadline, deadline_in_task);
}
TEST_F(IdleHelperTest, TestLongIdlePeriodWithPendingDelayedTask) {
base::TimeDelta pending_task_delay = base::TimeDelta::FromMilliseconds(30);
base::TimeTicks expected_deadline = clock_->NowTicks() + pending_task_delay;
base::TimeTicks deadline_in_task;
int run_count = 0;
idle_task_runner_->PostIdleTask(
FROM_HERE, base::Bind(&IdleTestTask, &run_count, &deadline_in_task));
default_task_runner_->PostDelayedTask(FROM_HERE, base::Bind(&NullTask),
pending_task_delay);
idle_helper_->EnableLongIdlePeriod();
RunUntilIdle();
EXPECT_EQ(1, run_count); // Should have run in a long idle time.
EXPECT_EQ(expected_deadline, deadline_in_task);
}
TEST_F(IdleHelperTest, TestLongIdlePeriodWithLatePendingDelayedTask) {
base::TimeDelta pending_task_delay = base::TimeDelta::FromMilliseconds(10);
base::TimeTicks deadline_in_task;
int run_count = 0;
default_task_runner_->PostDelayedTask(FROM_HERE, base::Bind(&NullTask),
pending_task_delay);
// Advance clock until after delayed task was meant to be run.
clock_->Advance(base::TimeDelta::FromMilliseconds(20));
// Post an idle task and then EnableLongIdlePeriod. Since there is a late
// pending delayed task this shouldn't actually start an idle period.
idle_task_runner_->PostIdleTask(
FROM_HERE, base::Bind(&IdleTestTask, &run_count, &deadline_in_task));
idle_helper_->EnableLongIdlePeriod();
RunUntilIdle();
EXPECT_EQ(0, run_count);
// After the delayed task has been run we should trigger an idle period.
clock_->Advance(maximum_idle_period_duration());
RunUntilIdle();
EXPECT_EQ(1, run_count);
}
TEST_F(IdleHelperTestWithIdlePeriodObserver, TestLongIdlePeriodRepeating) {
mock_task_runner_->SetAutoAdvanceNowToPendingTasks(true);
std::vector<base::TimeTicks> actual_deadlines;
int run_count = 0;
EXPECT_CALL(*idle_helper_, CanEnterLongIdlePeriod(_, _))
.Times(4)
.WillRepeatedly(Return(true));
ExpectIdlePeriodStartsAndEnds(AtLeast(2));
max_idle_task_reposts = 3;
base::TimeTicks clock_before(clock_->NowTicks());
base::TimeDelta idle_task_runtime(base::TimeDelta::FromMilliseconds(10));
idle_task_runner_->PostIdleTask(
FROM_HERE,
base::Bind(&RepostingUpdateClockIdleTestTask,
base::RetainedRef(idle_task_runner_), &run_count, clock_.get(),
idle_task_runtime, &actual_deadlines));
// Check each idle task runs in their own idle period.
idle_helper_->EnableLongIdlePeriod();
RunUntilIdle();
EXPECT_EQ(3, run_count);
EXPECT_THAT(
actual_deadlines,
testing::ElementsAre(
clock_before + maximum_idle_period_duration(),
clock_before + idle_task_runtime + maximum_idle_period_duration(),
clock_before + (2 * idle_task_runtime) +
maximum_idle_period_duration()));
max_idle_task_reposts = 5;
idle_task_runner_->PostIdleTask(
FROM_HERE,
base::Bind(&RepostingUpdateClockIdleTestTask,
base::RetainedRef(idle_task_runner_), &run_count, clock_.get(),
idle_task_runtime, &actual_deadlines));
idle_task_runner_->PostIdleTask(
FROM_HERE,
base::Bind(&EndIdlePeriodIdleTask, base::Unretained(idle_helper_.get())));
// Ensure that reposting tasks stop after EndIdlePeriod is called.
RunUntilIdle();
EXPECT_EQ(4, run_count);
}
TEST_F(IdleHelperTest, TestLongIdlePeriodDoesNotWakeScheduler) {
base::TimeTicks deadline_in_task;
int run_count = 0;
// Start a long idle period and get the time it should end.
idle_helper_->EnableLongIdlePeriod();
// The scheduler should not run the enable_next_long_idle_period task if
// there are no idle tasks and no other task woke up the scheduler, thus
// the idle period deadline shouldn't update at the end of the current long
// idle period.
base::TimeTicks idle_period_deadline = CurrentIdleTaskDeadline();
clock_->Advance(maximum_idle_period_duration());
RunUntilIdle();
base::TimeTicks new_idle_period_deadline = CurrentIdleTaskDeadline();
EXPECT_EQ(idle_period_deadline, new_idle_period_deadline);
// Posting a after-wakeup idle task also shouldn't wake the scheduler or
// initiate the next long idle period.
idle_task_runner_->PostIdleTaskAfterWakeup(
FROM_HERE, base::Bind(&IdleTestTask, &run_count, &deadline_in_task));
RunUntilIdle();
new_idle_period_deadline = CurrentIdleTaskDeadline();
EXPECT_EQ(idle_period_deadline, new_idle_period_deadline);
EXPECT_EQ(0, run_count);
// Running a normal task should initiate a new long idle period though.
default_task_runner_->PostTask(FROM_HERE, base::Bind(&NullTask));
RunUntilIdle();
new_idle_period_deadline = CurrentIdleTaskDeadline();
EXPECT_EQ(idle_period_deadline + maximum_idle_period_duration(),
new_idle_period_deadline);
EXPECT_EQ(1, run_count);
}
TEST_F(IdleHelperTestWithIdlePeriodObserver,
TestLongIdlePeriodWhenNotCanEnterLongIdlePeriod) {
base::TimeDelta delay = base::TimeDelta::FromMilliseconds(1000);
base::TimeDelta halfDelay = base::TimeDelta::FromMilliseconds(500);
base::TimeTicks delayOver = clock_->NowTicks() + delay;
base::TimeTicks deadline_in_task;
int run_count = 0;
ON_CALL(*idle_helper_, CanEnterLongIdlePeriod(_, _))
.WillByDefault(Invoke(
[delay, delayOver](base::TimeTicks now,
base::TimeDelta* next_long_idle_period_delay_out) {
if (now >= delayOver)
return true;
*next_long_idle_period_delay_out = delay;
return false;
}));
EXPECT_CALL(*idle_helper_, CanEnterLongIdlePeriod(_, _)).Times(2);
EXPECT_CALL(*idle_helper_, OnIdlePeriodStarted()).Times(AnyNumber());
idle_task_runner_->PostIdleTask(
FROM_HERE, base::Bind(&IdleTestTask, &run_count, &deadline_in_task));
// Make sure Idle tasks don't run until the delay has occurred.
idle_helper_->EnableLongIdlePeriod();
RunUntilIdle();
EXPECT_EQ(0, run_count);
clock_->Advance(halfDelay);
RunUntilIdle();
EXPECT_EQ(0, run_count);
// Delay is finished, idle task should run.
clock_->Advance(halfDelay);
RunUntilIdle();
EXPECT_EQ(1, run_count);
}
TEST_F(IdleHelperTest, TestLongIdlePeriodImmediatelyRestartsIfMaxDeadline) {
std::vector<base::TimeTicks> actual_deadlines;
int run_count = 0;
base::TimeTicks clock_before(clock_->NowTicks());
base::TimeDelta idle_task_runtime(base::TimeDelta::FromMilliseconds(10));
// The second idle period should happen immediately after the first the
// they have max deadlines.
max_idle_task_reposts = 2;
idle_task_runner_->PostIdleTask(
FROM_HERE,
base::Bind(&RepostingUpdateClockIdleTestTask,
base::RetainedRef(idle_task_runner_), &run_count, clock_.get(),
idle_task_runtime, &actual_deadlines));
idle_helper_->EnableLongIdlePeriod();
RunUntilIdle();
EXPECT_EQ(2, run_count);
EXPECT_THAT(
actual_deadlines,
testing::ElementsAre(
clock_before + maximum_idle_period_duration(),
clock_before + idle_task_runtime + maximum_idle_period_duration()));
}
TEST_F(IdleHelperTest, TestLongIdlePeriodRestartWaitsIfNotMaxDeadline) {
base::TimeTicks actual_deadline;
int run_count = 0;
base::TimeDelta pending_task_delay(base::TimeDelta::FromMilliseconds(20));
base::TimeDelta idle_task_duration(base::TimeDelta::FromMilliseconds(10));
base::TimeTicks expected_deadline(clock_->NowTicks() + pending_task_delay +
maximum_idle_period_duration() +
retry_enable_long_idle_period_delay());
// Post delayed task to ensure idle period doesn't have a max deadline.
default_task_runner_->PostDelayedTask(FROM_HERE, base::Bind(&NullTask),
pending_task_delay);
max_idle_task_reposts = 2;
idle_task_runner_->PostIdleTask(
FROM_HERE,
base::Bind(&RepostingIdleTestTask, base::RetainedRef(idle_task_runner_),
&run_count, &actual_deadline));
idle_helper_->EnableLongIdlePeriod();
RunUntilIdle();
EXPECT_EQ(1, run_count);
clock_->Advance(idle_task_duration);
// Next idle period shouldn't happen until the pending task has been run.
RunUntilIdle();
EXPECT_EQ(1, run_count);
// Once the pending task is run the new idle period should start.
clock_->Advance(pending_task_delay - idle_task_duration);
// Since the idle period tried to start before the pending task ran we have to
// wait for the idle helper to retry starting the long idle period.
clock_->Advance(retry_enable_long_idle_period_delay());
RunUntilIdle();
EXPECT_EQ(2, run_count);
EXPECT_EQ(expected_deadline, actual_deadline);
}
TEST_F(IdleHelperTest, TestLongIdlePeriodPaused) {
mock_task_runner_->SetAutoAdvanceNowToPendingTasks(true);
std::vector<base::TimeTicks> actual_deadlines;
int run_count = 0;
// If there are no idle tasks posted we should start in the paused state.
idle_helper_->EnableLongIdlePeriod();
CheckIdlePeriodStateIs("in_long_idle_period_paused");
// There shouldn't be any delayed tasks posted by the idle helper when paused.
base::TimeTicks next_pending_delayed_task;
EXPECT_FALSE(scheduler_helper_->real_time_domain()->NextScheduledRunTime(
&next_pending_delayed_task));
// Posting a task should transition us to the an active state.
max_idle_task_reposts = 2;
base::TimeTicks clock_before(clock_->NowTicks());
base::TimeDelta idle_task_runtime(base::TimeDelta::FromMilliseconds(10));
idle_task_runner_->PostIdleTask(
FROM_HERE,
base::Bind(&RepostingUpdateClockIdleTestTask,
base::RetainedRef(idle_task_runner_), &run_count, clock_.get(),
idle_task_runtime, &actual_deadlines));
RunUntilIdle();
EXPECT_EQ(2, run_count);
EXPECT_THAT(
actual_deadlines,
testing::ElementsAre(
clock_before + maximum_idle_period_duration(),
clock_before + idle_task_runtime + maximum_idle_period_duration()));
// Once all task have been run we should go back to the paused state.
CheckIdlePeriodStateIs("in_long_idle_period_paused");
EXPECT_FALSE(scheduler_helper_->real_time_domain()->NextScheduledRunTime(
&next_pending_delayed_task));
idle_helper_->EndIdlePeriod();
CheckIdlePeriodStateIs("not_in_idle_period");
}
TEST_F(IdleHelperTest, TestLongIdlePeriodWhenShutdown) {
base::TimeTicks deadline_in_task;
int run_count = 0;
idle_task_runner_->PostIdleTask(
FROM_HERE, base::Bind(&IdleTestTask, &run_count, &deadline_in_task));
scheduler_helper_->Shutdown();
// We shouldn't be able to enter a long idle period when shutdown
idle_helper_->EnableLongIdlePeriod();
RunUntilIdle();
CheckIdlePeriodStateIs("not_in_idle_period");
EXPECT_EQ(0, run_count);
}
void TestCanExceedIdleDeadlineIfRequiredTask(IdleHelperForTest* idle_helper,
bool* can_exceed_idle_deadline_out,
int* run_count,
base::TimeTicks deadline) {
*can_exceed_idle_deadline_out =
idle_helper->CanExceedIdleDeadlineIfRequired();
(*run_count)++;
}
TEST_F(IdleHelperTest, CanExceedIdleDeadlineIfRequired) {
int run_count = 0;
bool can_exceed_idle_deadline = false;
// Should return false if not in an idle period.
EXPECT_FALSE(idle_helper_->CanExceedIdleDeadlineIfRequired());
// Should return false for short idle periods.
idle_task_runner_->PostIdleTask(
FROM_HERE,
base::Bind(&TestCanExceedIdleDeadlineIfRequiredTask, idle_helper_.get(),
&can_exceed_idle_deadline, &run_count));
idle_helper_->StartIdlePeriod(
IdleHelper::IdlePeriodState::IN_SHORT_IDLE_PERIOD, clock_->NowTicks(),
clock_->NowTicks() + base::TimeDelta::FromMilliseconds(10));
RunUntilIdle();
EXPECT_EQ(1, run_count);
EXPECT_FALSE(can_exceed_idle_deadline);
// Should return false for a long idle period which is shortened due to a
// pending delayed task.
default_task_runner_->PostDelayedTask(FROM_HERE, base::Bind(&NullTask),
base::TimeDelta::FromMilliseconds(10));
idle_task_runner_->PostIdleTask(
FROM_HERE,
base::Bind(&TestCanExceedIdleDeadlineIfRequiredTask, idle_helper_.get(),
&can_exceed_idle_deadline, &run_count));
idle_helper_->EnableLongIdlePeriod();
RunUntilIdle();
EXPECT_EQ(2, run_count);
EXPECT_FALSE(can_exceed_idle_deadline);
// Next long idle period will be for the maximum time, so
// CanExceedIdleDeadlineIfRequired should return true.
clock_->Advance(maximum_idle_period_duration());
idle_task_runner_->PostIdleTask(
FROM_HERE,
base::Bind(&TestCanExceedIdleDeadlineIfRequiredTask, idle_helper_.get(),
&can_exceed_idle_deadline, &run_count));
RunUntilIdle();
EXPECT_EQ(3, run_count);
EXPECT_TRUE(can_exceed_idle_deadline);
}
class IdleHelperWithQuiescencePeriodTest : public BaseIdleHelperTest {
public:
enum {
kQuiescenceDelayMs = 100,
kLongIdlePeriodMs = 50,
};
IdleHelperWithQuiescencePeriodTest()
: BaseIdleHelperTest(
nullptr,
base::TimeDelta::FromMilliseconds(kQuiescenceDelayMs)) {}
~IdleHelperWithQuiescencePeriodTest() override {}
void SetUp() override {
EXPECT_CALL(*idle_helper_, OnIdlePeriodStarted()).Times(AnyNumber());
EXPECT_CALL(*idle_helper_, OnIdlePeriodEnded()).Times(AnyNumber());
EXPECT_CALL(*idle_helper_, CanEnterLongIdlePeriod(_, _))
.Times(AnyNumber())
.WillRepeatedly(Return(true));
EXPECT_CALL(*idle_helper_, IsNotQuiescent()).Times(AnyNumber());
}
void MakeNonQuiescent() {
// Run an arbitrary task so we're deemed to be not quiescent.
default_task_runner_->PostTask(FROM_HERE, base::Bind(NullTask));
RunUntilIdle();
}
private:
DISALLOW_COPY_AND_ASSIGN(IdleHelperWithQuiescencePeriodTest);
};
class IdleHelperWithQuiescencePeriodTestWithIdlePeriodObserver :
public IdleHelperWithQuiescencePeriodTest {
public:
IdleHelperWithQuiescencePeriodTestWithIdlePeriodObserver()
: IdleHelperWithQuiescencePeriodTest() {}
~IdleHelperWithQuiescencePeriodTestWithIdlePeriodObserver() override {}
void SetUp() override {
// Don't set expectations on IdleHelper::Delegate.
}
private:
DISALLOW_COPY_AND_ASSIGN(
IdleHelperWithQuiescencePeriodTestWithIdlePeriodObserver);
};
TEST_F(IdleHelperWithQuiescencePeriodTest,
LongIdlePeriodStartsImmediatelyIfQuiescent) {
base::TimeTicks actual_deadline;
int run_count = 0;
max_idle_task_reposts = 1;
idle_task_runner_->PostIdleTask(
FROM_HERE,
base::Bind(&RepostingIdleTestTask, base::RetainedRef(idle_task_runner_),
&run_count, &actual_deadline));
idle_helper_->EnableLongIdlePeriod();
RunUntilIdle();
EXPECT_EQ(1, run_count);
}
TEST_F(IdleHelperWithQuiescencePeriodTestWithIdlePeriodObserver,
LongIdlePeriodDoesNotStartsImmediatelyIfBusy) {
MakeNonQuiescent();
EXPECT_CALL(*idle_helper_, OnIdlePeriodStarted()).Times(0);
EXPECT_CALL(*idle_helper_, OnIdlePeriodEnded()).Times(0);
EXPECT_CALL(*idle_helper_, CanEnterLongIdlePeriod(_, _)).Times(0);
EXPECT_CALL(*idle_helper_, IsNotQuiescent()).Times(AtLeast(1));
base::TimeTicks actual_deadline;
int run_count = 0;
max_idle_task_reposts = 1;
idle_task_runner_->PostIdleTask(
FROM_HERE,
base::Bind(&RepostingIdleTestTask, base::RetainedRef(idle_task_runner_),
&run_count, &actual_deadline));
idle_helper_->EnableLongIdlePeriod();
RunUntilIdle();
EXPECT_EQ(0, run_count);
scheduler_helper_->Shutdown();
}
TEST_F(IdleHelperWithQuiescencePeriodTest,
LongIdlePeriodStartsAfterQuiescence) {
MakeNonQuiescent();
mock_task_runner_->SetAutoAdvanceNowToPendingTasks(true);
// Run a repeating task so we're deemed to be busy for the next 400ms.
default_task_runner_->PostTask(
FROM_HERE,
base::Bind(&RepeatingTask, base::Unretained(default_task_runner_.get()),
10, base::TimeDelta::FromMilliseconds(40)));
int run_count = 0;
// In this scenario EnableLongIdlePeriod deems us not to be quiescent 5x in
// a row.
base::TimeTicks expected_deadline =
clock_->NowTicks() + base::TimeDelta::FromMilliseconds(
5 * kQuiescenceDelayMs + kLongIdlePeriodMs);
base::TimeTicks deadline_in_task;
idle_task_runner_->PostIdleTask(
FROM_HERE, base::Bind(&IdleTestTask, &run_count, &deadline_in_task));
idle_helper_->EnableLongIdlePeriod();
RunUntilIdle();
EXPECT_EQ(1, run_count);
EXPECT_EQ(expected_deadline, deadline_in_task);
}
TEST_F(IdleHelperWithQuiescencePeriodTest,
QuescienceCheckedForAfterLongIdlePeriodEnds) {
mock_task_runner_->SetAutoAdvanceNowToPendingTasks(true);
idle_task_runner_->PostIdleTask(FROM_HERE, base::Bind(&NullIdleTask));
idle_helper_->EnableLongIdlePeriod();
RunUntilIdle();
// Post a normal task to make the scheduler non-quiescent.
default_task_runner_->PostTask(FROM_HERE, base::Bind(&NullTask));
RunUntilIdle();
// Post an idle task. The idle task won't run initially because the system is
// not judged to be quiescent, but should be run after the quiescence delay.
int run_count = 0;
base::TimeTicks deadline_in_task;
base::TimeTicks expected_deadline =
clock_->NowTicks() +
base::TimeDelta::FromMilliseconds(kQuiescenceDelayMs + kLongIdlePeriodMs);
idle_task_runner_->PostIdleTask(
FROM_HERE, base::Bind(&IdleTestTask, &run_count, &deadline_in_task));
idle_helper_->EnableLongIdlePeriod();
RunUntilIdle();
EXPECT_EQ(1, run_count);
EXPECT_EQ(expected_deadline, deadline_in_task);
}
TEST_F(IdleHelperTest, NoShortIdlePeriodWhenDeadlineTooClose) {
int run_count = 0;
base::TimeTicks deadline_in_task;
idle_task_runner_->PostIdleTask(
FROM_HERE, base::Bind(&IdleTestTask, &run_count, &deadline_in_task));
base::TimeDelta half_a_ms(base::TimeDelta::FromMicroseconds(50));
base::TimeTicks less_than_min_deadline(
clock_->NowTicks() + minimum_idle_period_duration() - half_a_ms);
base::TimeTicks more_than_min_deadline(
clock_->NowTicks() + minimum_idle_period_duration() + half_a_ms);
idle_helper_->StartIdlePeriod(
IdleHelper::IdlePeriodState::IN_SHORT_IDLE_PERIOD, clock_->NowTicks(),
less_than_min_deadline);
RunUntilIdle();
EXPECT_EQ(0, run_count);
idle_helper_->StartIdlePeriod(
IdleHelper::IdlePeriodState::IN_SHORT_IDLE_PERIOD, clock_->NowTicks(),
more_than_min_deadline);
RunUntilIdle();
EXPECT_EQ(1, run_count);
}
TEST_F(IdleHelperTest, NoLongIdlePeriodWhenDeadlineTooClose) {
int run_count = 0;
base::TimeTicks deadline_in_task;
base::TimeDelta half_a_ms(base::TimeDelta::FromMicroseconds(50));
base::TimeDelta less_than_min_deadline_duration(
minimum_idle_period_duration() - half_a_ms);
base::TimeDelta more_than_min_deadline_duration(
minimum_idle_period_duration() + half_a_ms);
idle_task_runner_->PostIdleTask(
FROM_HERE, base::Bind(&IdleTestTask, &run_count, &deadline_in_task));
default_task_runner_->PostDelayedTask(FROM_HERE, base::Bind(&NullTask),
less_than_min_deadline_duration);
idle_helper_->EnableLongIdlePeriod();
RunUntilIdle();
EXPECT_EQ(0, run_count);
idle_helper_->EndIdlePeriod();
clock_->Advance(maximum_idle_period_duration());
RunUntilIdle();
EXPECT_EQ(0, run_count);
default_task_runner_->PostDelayedTask(FROM_HERE, base::Bind(&NullTask),
more_than_min_deadline_duration);
idle_helper_->EnableLongIdlePeriod();
RunUntilIdle();
EXPECT_EQ(1, run_count);
}
} // namespace scheduler
| [
"dummas@163.com"
] | dummas@163.com |
e4feaa4ffb7b57a442880f7f992fe8c6f2e84aa5 | a4ca1e0cde964fca9dc35aa808f8e348a2e70278 | /Perf/Perf.h | ec15dec5b7e0ef328209fb61bbd270d8b26f1eb0 | [] | no_license | tigranmt/perf | 174c8c40bf5b363c593b6b486f2c79eec5fefdcc | e47880397902b253c10995bbdb6c0d63d5a41f88 | refs/heads/master | 2021-09-05T19:21:13.809348 | 2018-01-30T14:07:20 | 2018-01-30T14:07:20 | 119,469,921 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,374 | h |
#pragma once
#include <iostream>
#include <chrono>
#include <vector>
#include <memory>
#include "Sys.h"
using namespace std;
namespace Perf
{
/*
* Sample performance data struct.
* This structure is reported back to the caller of the test
*/
struct PerfData
{
double _milliseconds;
unsigned long _workingSet;
unsigned long _workingSetPeak;
string _hardwareInfo;
string _testName;
};
/*
* Run confioguraiton
*/
struct RunConfiguration
{
bool reportMemoryData;
bool reportHardwareInfo;
RunConfiguration() : reportMemoryData(true), reportHardwareInfo(true) {}
};
/*
* Base class for reporter: a type responsible for visualizing,
* reporting recovered performance information.
*/
class Reporter
{
public:
void virtual ReportData(const Perf::PerfData&) {};
};
/*
* Built-in type for reporting performance data in formatted output on console
*/
class ConsoleReporter : public Reporter
{
void ReportData(const Perf::PerfData& _perfData)
{
cout << _perfData._testName.c_str() << "==>" << endl;
cout << "\t Runtime: \t " << _perfData._milliseconds << " ms" << endl;
if (_perfData._workingSet > 0)
cout << "\t Working set: \t " << ((float)_perfData._workingSet)/1024.0f << " Kb" << endl;
if (_perfData._workingSetPeak > 0)
cout << "\t Working set peak: " << ((float)_perfData._workingSetPeak)/1024.0f << " Kb" << endl;
cout << endl;
}
};
class BasePerf
{
private:
PerfData _pd;
protected:
unique_ptr<Reporter> _reporter;
RunConfiguration _configuration;
string _test_name;
BasePerf()
{
_reporter = unique_ptr<Perf::Reporter>(new Perf::ConsoleReporter());
}
const PerfData& Data() const { return _pd; }
//Allows to inject user-specified reporter
void AssignReporter(Perf::Reporter* reporter) { _reporter = unique_ptr<Perf::Reporter>(reporter); }
virtual void RunTestBody() = 0;
public:
void Run()
{
//retrieve perf data _before_ user test invokation
auto start = chrono::steady_clock::now();
unsigned long prev_workingSet = 0, prev_workingSetPeak = 0;
if (_configuration.reportMemoryData)
{
prev_workingSet = System::Info::GetProcessWorkingSet();
prev_workingSetPeak = System::Info::GetProcessWorkingSetPeak();
}
RunTestBody();
//retrieve perf data _after_ user test invokation
auto end = chrono::steady_clock::now();
if (_configuration.reportMemoryData)
{
auto cur_workingSet = System::Info::GetProcessWorkingSet();
auto cur_workingSetPeak = System::Info::GetProcessWorkingSetPeak();
_pd._workingSet = (cur_workingSet == prev_workingSet)? cur_workingSet : cur_workingSet - prev_workingSet;
_pd._workingSetPeak = (cur_workingSetPeak == prev_workingSetPeak) ? cur_workingSetPeak : cur_workingSetPeak - prev_workingSetPeak;
}
_pd._milliseconds = chrono::duration <double, milli>(end - start).count();
_pd._testName = _test_name;
//reportm collected information
_reporter->ReportData(_pd);
}
};
/*
* Factory for constructing (code-generation) of a specified test cases
*/
class Factory
{
private:
vector<unique_ptr<BasePerf>> tests;
static Factory _runner;
public:
Factory() = default;
bool Add(BasePerf* perf)
{
tests.push_back(move(unique_ptr<BasePerf>(perf)));
return true;
}
static bool Register(BasePerf* perf)
{
return _runner.Add(perf);
}
const vector<unique_ptr<BasePerf>>& Tests() const { return tests;}
static void RunAllTest()
{
for (const auto& t : _runner.Tests())
t->Run();
}
};
/*
* Set of macrosses for generating classes from the name of the Ficture and Name of the test
*/
#define TYPE_FROM(perf_case, perf_test) perf_case##_##perf_test##_perf
#define PERF(perf_case, perf_test) PERF__(perf_case, perf_test, Perf::BasePerf)
#define PERF__(perf_case, perf_test, base_class) \
class TYPE_FROM(perf_case, perf_test) : public base_class \
{ \
protected:\
void RunTestBody() override; \
static bool registered_sucessfully;\
\
TYPE_FROM(perf_case, perf_test)() { _test_name = " " #perf_case "." #perf_test " "; } \
\
};\
\
bool TYPE_FROM(perf_case, perf_test)::registered_sucessfully = \
::Perf::Factory::Register(new TYPE_FROM(perf_case, perf_test)());\
\
void TYPE_FROM(perf_case, perf_test)::RunTestBody()
}
| [
"tigranmt@gmail.com"
] | tigranmt@gmail.com |
3dddad1ce8268ef4168e9ad2de451be5e6cf147e | e4a5154dfbe141e5f92f45b8b476eb738ea2e20b | /EasyEngine/easy_engine.hpp | 445f1bd4b4c9def22fd9ae5bc4bbcbd4c9862fc6 | [] | no_license | Abyabyabyabyabya/EasyEngine | dde8203e4b9173a30542b7dce4fb42f6d16aba54 | 8ebc01d1da1bb0ee65a6d4f95ac60be918362e0d | refs/heads/master | 2022-12-27T21:15:39.027935 | 2020-10-13T13:55:24 | 2020-10-13T13:55:24 | 281,957,655 | 0 | 0 | null | null | null | null | SHIFT_JIS | C++ | false | false | 1,452 | hpp | ///
/// \file easy_engine.hpp
/// \brief エンジンクラス定義ヘッダ
///
/// \author 板場
///
/// \par 履歴
/// - 2020/8/19
/// - ヘッダ追加
/// - EasyEngine 定義
///
#ifndef INCLUDED_EGEG_EASY_ENGINE_HEADER_
#define INCLUDED_EGEG_EASY_ENGINE_HEADER_
#include <memory>
#include "noncopyable.hpp"
#include "result.hpp"
#include "window_manager.hpp"
#include "time.hpp"
#include "update_manager.hpp"
#include "input_manager.hpp"
#include "graphic_manager.hpp"
namespace easy_engine {
/******************************************************************************
EasyEngine
******************************************************************************/
///
/// \brief エンジン本体
///
/// サブシステムのルートでもあります。
///
class EasyEngine final : t_lib::Noncopyable<EasyEngine> {
public :
static void run();
static WindowManager& window() noexcept;
static const Clock& clock() noexcept;
static UpdateManager<EasyEngine>& updator() noexcept;
static i_lib::InputManager& input() noexcept;
static g_lib::GraphicManager& graphics() noexcept;
private :
EasyEngine() = default;
static t_lib::DetailedResult<bool, const char*> startUp();
static void shutDown() noexcept;
struct Impl;
static std::unique_ptr<Impl> impl_;
};
} // namespace easy_engine
#endif // !INCLUDED_EGEG_EASY_ENGINE_HEADER_
// EOF
| [
"harutch.222@gmail.com"
] | harutch.222@gmail.com |
f796d00083b1fcaa1e907c9e28867f57ff6b1393 | 8f0b66089ab6acff5007a34432074030f66a79fe | /testcpu/testcpu.cpp | 57674cea66f9ccfe795d395930ce2495afc8db52 | [] | no_license | Kobey1/dprofiler | 378cfd9425799734d73ea8210918e36aeeedef10 | 97cd909aa22a42f7a30d1edc7932d02e33a10f52 | refs/heads/master | 2021-01-15T12:11:14.846024 | 2015-01-11T12:51:04 | 2015-01-11T12:51:04 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 160 | cpp | // testcpu.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
int _tmain(int argc, _TCHAR* argv[])
{
return 0;
}
| [
"lan.john@gmail.com"
] | lan.john@gmail.com |
235ee2768f859ee7c2e9e293fe5f7c73e9e3d662 | 5456502f97627278cbd6e16d002d50f1de3da7bb | /content/browser/pepper_flash_settings_helper_impl.h | d5e077ed579b4bf732f308b31e11310f91541631 | [
"BSD-3-Clause"
] | permissive | TrellixVulnTeam/Chromium_7C66 | 72d108a413909eb3bd36c73a6c2f98de1573b6e5 | c8649ab2a0f5a747369ed50351209a42f59672ee | refs/heads/master | 2023-03-16T12:51:40.231959 | 2017-12-20T10:38:26 | 2017-12-20T10:38:26 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,569 | h | // 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.
#ifndef CONTENT_BROWSER_PEPPER_FLASH_SETTINGS_HELPER_IMPL_H_
#define CONTENT_BROWSER_PEPPER_FLASH_SETTINGS_HELPER_IMPL_H_
#include "base/compiler_specific.h"
#include "base/macros.h"
#include "content/browser/ppapi_plugin_process_host.h"
#include "content/public/browser/pepper_flash_settings_helper.h"
namespace content {
class CONTENT_EXPORT PepperFlashSettingsHelperImpl
: public PepperFlashSettingsHelper,
NON_EXPORTED_BASE(public PpapiPluginProcessHost::BrokerClient) {
public:
PepperFlashSettingsHelperImpl();
// PepperFlashSettingsHelper implementation.
void OpenChannelToBroker(const base::FilePath& path,
const OpenChannelCallback& callback) override;
// PpapiPluginProcessHost::BrokerClient implementation.
void GetPpapiChannelInfo(base::ProcessHandle* renderer_handle,
int* renderer_id) override;
void OnPpapiChannelOpened(const IPC::ChannelHandle& channel_handle,
base::ProcessId plugin_pid,
int plugin_child_id) override;
bool Incognito() override;
protected:
~PepperFlashSettingsHelperImpl() override;
private:
OpenChannelCallback callback_;
DISALLOW_COPY_AND_ASSIGN(PepperFlashSettingsHelperImpl);
};
} // namespace content
#endif // CONTENT_BROWSER_PEPPER_FLASH_SETTINGS_HELPER_IMPL_H_
| [
"lixiaodonglove7@aliyun.com"
] | lixiaodonglove7@aliyun.com |
f8f2debc1924456a097b4ed72fe25dc18399b060 | f9aff82f3f9cc76b7fad4198fa1b193bf6e48f58 | /src/car_autopilot/src/path_planner.cpp | 2fa27e1f3ec27721478d385497fced90f3c703e6 | [
"MIT"
] | permissive | byu-magicc/mocap_car | c93126f9112edbe9ddf460a53afebc0b81f22fea | cd23dfd891c1d38641910aeb9d3058146d9c53f4 | refs/heads/master | 2020-04-04T11:28:56.223346 | 2018-11-07T23:57:05 | 2018-11-07T23:57:05 | 155,892,424 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,112 | cpp | #include <ros/ros.h>
#include <car_autopilot/Waypoint.h>
#define num_waypoints 4
int main(int argc, char **argv)
{
ros::init(argc, argv, "simple_path_planner");
ros::NodeHandle nh_;
ros::NodeHandle nh_ns_("~");
ros::Publisher waypointPublisher = nh_.advertise<car_autopilot::Waypoint>("waypoint_path", 10);
// float u = 1.5;
// float pn1 = -230.0;
// float pe1 = -100.0;
// float wps[3*num_waypoints] =
// {
// pn1 - 10, pe1, u,
// pn1, pe1, u,
// pn1, pe1 + 10, u,
// pn1 - 10, pe1 + 10, u,
// };
std::vector<double> wps;
nh_ns_.getParam("waypoint_list",wps);
// for (int i(0); i < num_waypoints; i++)
for (int i(0); i < wps.size()/3; i++)
{
ros::Duration(0.5).sleep();
car_autopilot::Waypoint new_waypoint;
new_waypoint.w[0] = wps[i*3 + 0];
new_waypoint.w[1] = wps[i*3 + 1];
new_waypoint.u_d = wps[i*3 + 2];
if (i == 0)
new_waypoint.set_current = true;
else
new_waypoint.set_current = false;
new_waypoint.clear_wp_list = false;
waypointPublisher.publish(new_waypoint);
}
ros::Duration(1.5).sleep();
return 0;
}
| [
"craig.bidstrup@gmail.com"
] | craig.bidstrup@gmail.com |
67f5e45146192c3a3e60d87ff119596adb1b1e79 | fb81d60eaea26c8feed34cdf8bcb302e6246caad | /PARTICLE MEAN/4-particleMean_v2/Constants.cc | 529156bef58d7a8306f54179e88599a28aaaeaa0 | [] | no_license | auroraleso/Cpp-course | e03ff719c7b6dc8ee56f1dde9b5a0521231edc94 | dce1cd39da03c22e595f513379aa0b7e14228c1e | refs/heads/main | 2023-03-27T07:14:24.730861 | 2021-03-25T17:41:00 | 2021-03-25T17:41:00 | 345,602,280 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 83 | cc | #include "Constants.h"
Constants::Constants(){
}
Constants::~Constants(){
} | [
"auroraleso@Aurora-PC.localdomain"
] | auroraleso@Aurora-PC.localdomain |
276b660c5cc2ff1e9dc4353b1c9a625829e3ccce | 34fb2c48d29b4aac014571cbb0d4232896380742 | /数据结构/数据结构实验课文件/EXP4/代码3.24/20354047/task3.cpp | 60561b1787f281368a03f53a2d223a4e253631a4 | [] | no_license | dkhonker/sysu | 2aca46818fc9bf77ededa0d8922859c3cabbd1e7 | ef3b8d0f6d5bb03b408081c932716dbd37ad0a22 | refs/heads/master | 2023-06-17T01:09:03.174593 | 2021-07-14T04:27:07 | 2021-07-14T04:27:07 | 382,212,051 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 318 | cpp | #include <stdio.h>
#include <stdlib.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main()
{
char str[20000],str1[20000];
int pos,len,i,a=0;
scanf("%d%d",&pos,&len);
scanf("%s",str);
for(i=0;a<len;a++,i++,pos++)
str1[i]=str[pos-1];
puts(str1);
}
| [
"2373591933@qq.com"
] | 2373591933@qq.com |
7c442c09675ca591b2b73614fcfff70951570ad3 | 1d3b8ff00aac39e12c76a6b35d169237f4af0bdc | /temp.cpp | 7dd20cb80e0d6542ceb87b63d4f36504db1a6607 | [] | no_license | JUCSERahull337/jahangirnagar-university | b1c3b40b5e6d615c1eb248b7b7333de88e7c665c | beecc8069e30ebeb4b24ce0a5b783587ffd9cab3 | refs/heads/master | 2020-04-08T05:05:15.900427 | 2019-05-25T05:06:22 | 2019-05-25T05:06:22 | 159,045,355 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 371 | cpp | #include<iostream>
using namespace std;
template<class A>
A abs(A n)
{
return (n<0)?-n:n;
}
int main()
{
int I=5;
int j=-6;
long k=700022;
double g=.9926687;
char c='rahulFAIZA';
cout<<"\nabs("<< I <<")="<< abs(I);
cout<<"\nabs("<< c <<")="<< abs(c);
cout<<"\nabs("<< j <<")="<< abs(j);
cout<<"\nabs("<< k <<")="<< abs(k);
cout<<"\nabs("<< g <<")="<< abs(g);
return 0;
}
| [
"noreply@github.com"
] | JUCSERahull337.noreply@github.com |
beec2c6c60e2fa4832d80645b2dc370c592c26d9 | f6bad0a9093bb94b490ea068fab8c7798fe21b93 | /win/win_roscpp/include/geometry_msgs/Accel.h | 997b95b027cbe197ef1e6a58f0b778481ca08662 | [
"MIT",
"Apache-2.0",
"BSD-3-Clause"
] | permissive | warehouse-picking-automation-challenges/team_pfn | 8b5ebb7e106359980abea28dc00784772208ead9 | 2f76524b067d816d8407f6c4fae4e6d33939c024 | refs/heads/master | 2021-06-07T02:21:33.432335 | 2016-08-17T03:12:15 | 2016-08-17T03:12:15 | 66,588,155 | 5 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 5,493 | h | // Generated by gencpp from file geometry_msgs/Accel.msg
// DO NOT EDIT!
#ifndef GEOMETRY_MSGS_MESSAGE_ACCEL_H
#define GEOMETRY_MSGS_MESSAGE_ACCEL_H
#include <string>
#include <vector>
#include <map>
#include <ros/types.h>
#include <ros/serialization.h>
#include <ros/builtin_message_traits.h>
#include <ros/message_operations.h>
#include <geometry_msgs/Vector3.h>
#include <geometry_msgs/Vector3.h>
namespace geometry_msgs
{
template <class ContainerAllocator>
struct Accel_
{
typedef Accel_<ContainerAllocator> Type;
Accel_()
: linear()
, angular() {
}
Accel_(const ContainerAllocator& _alloc)
: linear(_alloc)
, angular(_alloc) {
}
typedef ::geometry_msgs::Vector3_<ContainerAllocator> _linear_type;
_linear_type linear;
typedef ::geometry_msgs::Vector3_<ContainerAllocator> _angular_type;
_angular_type angular;
typedef boost::shared_ptr< ::geometry_msgs::Accel_<ContainerAllocator> > Ptr;
typedef boost::shared_ptr< ::geometry_msgs::Accel_<ContainerAllocator> const> ConstPtr;
}; // struct Accel_
typedef ::geometry_msgs::Accel_<std::allocator<void> > Accel;
typedef boost::shared_ptr< ::geometry_msgs::Accel > AccelPtr;
typedef boost::shared_ptr< ::geometry_msgs::Accel const> AccelConstPtr;
// constants requiring out of line definition
template<typename ContainerAllocator>
std::ostream& operator<<(std::ostream& s, const ::geometry_msgs::Accel_<ContainerAllocator> & v)
{
ros::message_operations::Printer< ::geometry_msgs::Accel_<ContainerAllocator> >::stream(s, "", v);
return s;
}
} // namespace geometry_msgs
namespace ros
{
namespace message_traits
{
// BOOLTRAITS {'IsFixedSize': True, 'IsMessage': True, 'HasHeader': False}
// {'std_msgs': ['/opt/ros/indigo/share/std_msgs/cmake/../msg'], 'geometry_msgs': ['/tmp/binarydeb/ros-indigo-geometry-msgs-1.11.8/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< ::geometry_msgs::Accel_<ContainerAllocator> >
: TrueType
{ };
template <class ContainerAllocator>
struct IsFixedSize< ::geometry_msgs::Accel_<ContainerAllocator> const>
: TrueType
{ };
template <class ContainerAllocator>
struct IsMessage< ::geometry_msgs::Accel_<ContainerAllocator> >
: TrueType
{ };
template <class ContainerAllocator>
struct IsMessage< ::geometry_msgs::Accel_<ContainerAllocator> const>
: TrueType
{ };
template <class ContainerAllocator>
struct HasHeader< ::geometry_msgs::Accel_<ContainerAllocator> >
: FalseType
{ };
template <class ContainerAllocator>
struct HasHeader< ::geometry_msgs::Accel_<ContainerAllocator> const>
: FalseType
{ };
template<class ContainerAllocator>
struct MD5Sum< ::geometry_msgs::Accel_<ContainerAllocator> >
{
static const char* value()
{
return "9f195f881246fdfa2798d1d3eebca84a";
}
static const char* value(const ::geometry_msgs::Accel_<ContainerAllocator>&) { return value(); }
static const uint64_t static_value1 = 0x9f195f881246fdfaULL;
static const uint64_t static_value2 = 0x2798d1d3eebca84aULL;
};
template<class ContainerAllocator>
struct DataType< ::geometry_msgs::Accel_<ContainerAllocator> >
{
static const char* value()
{
return "geometry_msgs/Accel";
}
static const char* value(const ::geometry_msgs::Accel_<ContainerAllocator>&) { return value(); }
};
template<class ContainerAllocator>
struct Definition< ::geometry_msgs::Accel_<ContainerAllocator> >
{
static const char* value()
{
return "# This expresses acceleration in free space broken into its linear and angular parts.\n\
Vector3 linear\n\
Vector3 angular\n\
\n\
================================================================================\n\
MSG: geometry_msgs/Vector3\n\
# This represents a vector in free space. \n\
\n\
float64 x\n\
float64 y\n\
float64 z\n\
";
}
static const char* value(const ::geometry_msgs::Accel_<ContainerAllocator>&) { return value(); }
};
} // namespace message_traits
} // namespace ros
namespace ros
{
namespace serialization
{
template<class ContainerAllocator> struct Serializer< ::geometry_msgs::Accel_<ContainerAllocator> >
{
template<typename Stream, typename T> inline static void allInOne(Stream& stream, T m)
{
stream.next(m.linear);
stream.next(m.angular);
}
ROS_DECLARE_ALLINONE_SERIALIZER;
}; // struct Accel_
} // namespace serialization
} // namespace ros
namespace ros
{
namespace message_operations
{
template<class ContainerAllocator>
struct Printer< ::geometry_msgs::Accel_<ContainerAllocator> >
{
template<typename Stream> static void stream(Stream& s, const std::string& indent, const ::geometry_msgs::Accel_<ContainerAllocator>& v)
{
s << indent << "linear: ";
s << std::endl;
Printer< ::geometry_msgs::Vector3_<ContainerAllocator> >::stream(s, indent + " ", v.linear);
s << indent << "angular: ";
s << std::endl;
Printer< ::geometry_msgs::Vector3_<ContainerAllocator> >::stream(s, indent + " ", v.angular);
}
};
} // namespace message_operations
} // namespace ros
#endif // GEOMETRY_MSGS_MESSAGE_ACCEL_H
| [
"tgp@preferred.jp"
] | tgp@preferred.jp |
e340228d87411614563bf3c76d4c1192751a91c3 | f252f75a66ff3ff35b6eaa5a4a28248eb54840ee | /external/opencore/fileformats/mp4/parser/include/itunesmetadataatom.h | f899a639a94a67e9df15973a260386962e60665a | [
"MIT",
"LicenseRef-scancode-other-permissive",
"Artistic-2.0",
"LicenseRef-scancode-philippe-de-muyter",
"Apache-2.0",
"LicenseRef-scancode-mpeg-iso",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | abgoyal-archive/OT_4010A | 201b246c6f685cf35632c9a1e1bf2b38011ff196 | 300ee9f800824658acfeb9447f46419b8c6e0d1c | refs/heads/master | 2022-04-12T23:17:32.814816 | 2015-02-06T12:15:20 | 2015-02-06T12:15:20 | 30,410,715 | 0 | 1 | null | 2020-03-07T00:35:22 | 2015-02-06T12:14:16 | C | UTF-8 | C++ | false | false | 1,291 | h |
#ifndef ITUNESMETADATAATOM_H_INCLUDED
#define ITUNESMETADATAATOM_H_INCLUDED
typedef Oscl_Vector<OSCL_StackString<128>, OsclMemAllocator> OSCL_StackStringVector;
/** Shared pointer of a key-value pair */
typedef OsclSharedPtr<PvmiKvp> PvmiKvpSharedPtr;
/** Vector of shared pointer of a key-value pair */
typedef Oscl_Vector<PvmiKvpSharedPtr, OsclMemAllocator> PvmiKvpSharedPtrVector;
#include "atom.h"
#include "itunesilstmetadataatom.h"
class ITunesMetaDataAtom: public Atom
{
public:
ITunesMetaDataAtom(MP4_FF_FILE *fp, uint32 size, uint32 type);
virtual ~ITunesMetaDataAtom();
OSCL_wHeapString<OsclMemAllocator> getmdirapplData()
{
return _mdirapplData;
}
PVMFStatus getMetaDataValues(OSCL_StackStringVector* aRequiredKeys,
PvmiKvpSharedPtrVector& aMetaDataKVPVector);
ITunesILstMetaDataAtom* getITunesILstMetaDataAtom()
{
return _pITunesILstMetaDataAtom;
}
private:
// Whether this file is an M4A file or not. (By using "hdlr" tag)
OSCL_wHeapString<OsclMemAllocator> _mdirapplData;
// User ilst Data
ITunesILstMetaDataAtom* _pITunesILstMetaDataAtom;
};
#endif // ITUNESMETADATAATOM_H_INCLUDED
| [
"abgoyal@gmail.com"
] | abgoyal@gmail.com |
4bed644c9f8049476ecd28299b87a62aaf197da6 | 0aa31d232a6949dfbe7fd25365578d2788440d95 | /src/qt/optionsmodel.h | 67d949993f09709b745146be16d72081cb615759 | [
"MIT"
] | permissive | QuarterCoin/QuarterCoin-Wallet | 55382d234b9605822d64b2a857e1e57bff5022b3 | bf6bf8ec8a2907e1fa29305df389e0ae7156e544 | refs/heads/master | 2020-09-09T05:03:29.646947 | 2019-11-15T02:03:58 | 2019-11-15T02:03:58 | 221,355,759 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,910 | h | // Copyright (c) 2011-2018 The Bitcoin Core developers
// Copyright (c) 2017 The Raven Core developers
// Copyright (c) 2018 The Quartercoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef QTC_QT_OPTIONSMODEL_H
#define QTC_QT_OPTIONSMODEL_H
#include "amount.h"
#include <QAbstractListModel>
QT_BEGIN_NAMESPACE
class QNetworkProxy;
QT_END_NAMESPACE
/** Interface from Qt to configuration data structure for Quartercoin client.
To Qt, the options are presented as a list with the different options
laid out vertically.
This can be changed to a tree once the settings become sufficiently
complex.
*/
class OptionsModel : public QAbstractListModel
{
Q_OBJECT
public:
explicit OptionsModel(QObject *parent = 0, bool resetSettings = false);
enum OptionID {
StartAtStartup, // bool
HideTrayIcon, // bool
MinimizeToTray, // bool
MapPortUPnP, // bool
MinimizeOnClose, // bool
ProxyUse, // bool
ProxyIP, // QString
ProxyPort, // int
ProxyUseTor, // bool
ProxyIPTor, // QString
ProxyPortTor, // int
DisplayUnit, // QuartercoinUnits::Unit
ThirdPartyTxUrls, // QString
Language, // QString
CoinControlFeatures, // bool
ThreadsScriptVerif, // int
DatabaseCache, // int
SpendZeroConfChange, // bool
Listen, // bool
CustomFeeFeatures, // bool
DarkModeEnabled, // bool
OptionIDRowCount,
};
void Init(bool resetSettings = false);
void Reset();
int rowCount(const QModelIndex & parent = QModelIndex()) const;
QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const;
bool setData(const QModelIndex & index, const QVariant & value, int role = Qt::EditRole);
/** Updates current unit in memory, settings and emits displayUnitChanged(newUnit) signal */
void setDisplayUnit(const QVariant &value);
/* Explicit getters */
bool getHideTrayIcon() const { return fHideTrayIcon; }
bool getMinimizeToTray() const { return fMinimizeToTray; }
bool getMinimizeOnClose() const { return fMinimizeOnClose; }
int getDisplayUnit() const { return nDisplayUnit; }
QString getThirdPartyTxUrls() const { return strThirdPartyTxUrls; }
bool getProxySettings(QNetworkProxy& proxy) const;
bool getCoinControlFeatures() const { return fCoinControlFeatures; }
bool getCustomFeeFeatures() const { return fCustomFeeFeatures; }
bool getDarkModeEnabled() const { return fDarkModeEnabled; }
const QString& getOverriddenByCommandLine() { return strOverriddenByCommandLine; }
/* Restart flag helper */
void setRestartRequired(bool fRequired);
bool isRestartRequired() const;
private:
/* Qt-only settings */
bool fHideTrayIcon;
bool fMinimizeToTray;
bool fMinimizeOnClose;
QString language;
int nDisplayUnit;
QString strThirdPartyTxUrls;
bool fCoinControlFeatures;
/** QTC START*/
bool fCustomFeeFeatures;
bool fDarkModeEnabled;
/** QTC END*/
/* settings that were overridden by command-line */
QString strOverriddenByCommandLine;
// Add option to list of GUI options overridden through command line/config file
void addOverriddenOption(const std::string &option);
// Check settings version and upgrade default values if required
void checkAndMigrate();
Q_SIGNALS:
void displayUnitChanged(int unit);
void coinControlFeaturesChanged(bool);
void customFeeFeaturesChanged(bool);
void hideTrayIconChanged(bool);
};
#endif // QTC_QT_OPTIONSMODEL_H
| [
"splnty@live.com"
] | splnty@live.com |
69dd40133a8f39f6f4626a7b1b6428729a014480 | 9406d73feabf3b56443934f6059b20c815f7d4af | /test/a32/test-simulator-cond-rd-rn-operand-rm-ror-amount-a32.cc | eeb53e0d66b1d2e39771041ce667fa23afb2d59a | [] | no_license | multi-os-engine-community/vixl | 42b4b80092a01180cf4aa1160da988f1e9c7e628 | 811fe15831f77f7465809503791f85fed76e44c2 | refs/heads/master | 2021-01-20T23:38:00.004361 | 2016-08-08T15:18:52 | 2016-08-09T10:28:29 | 101,847,618 | 0 | 0 | null | 2017-08-30T06:48:55 | 2017-08-30T06:48:55 | null | UTF-8 | C++ | false | false | 73,266 | cc | // Copyright 2016, ARM Limited
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
// * Neither the name of ARM Limited nor the names of its contributors may be
// used to endorse or promote products derived from this software without
// specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// -----------------------------------------------------------------------------
// This file is auto generated from the
// test/a32/config/template-simulator-a32.cc.in template file using
// tools/generate_tests.py.
//
// PLEASE DO NOT EDIT.
// -----------------------------------------------------------------------------
#include "test-runner.h"
#include "test-utils.h"
#include "test-utils-a32.h"
#include "a32/assembler-a32.h"
#include "a32/macro-assembler-a32.h"
#include "a32/disasm-a32.h"
#define __ masm.
#define BUF_SIZE (4096)
#ifdef VIXL_INCLUDE_SIMULATOR
// Run tests with the simulator.
#define SETUP() MacroAssembler masm(BUF_SIZE)
#define START() masm.GetBuffer().Reset()
#define END() \
__ Hlt(0); \
__ FinalizeCode();
// TODO: Run the tests in the simulator.
#define RUN()
#define TEARDOWN()
#else // ifdef VIXL_INCLUDE_SIMULATOR.
#define SETUP() MacroAssembler masm(BUF_SIZE);
#define START() \
masm.GetBuffer().Reset(); \
__ Push(r4); \
__ Push(r5); \
__ Push(r6); \
__ Push(r7); \
__ Push(r8); \
__ Push(r9); \
__ Push(r10); \
__ Push(r11); \
__ Push(r12); \
__ Push(lr)
#define END() \
__ Pop(lr); \
__ Pop(r12); \
__ Pop(r11); \
__ Pop(r10); \
__ Pop(r9); \
__ Pop(r8); \
__ Pop(r7); \
__ Pop(r6); \
__ Pop(r5); \
__ Pop(r4); \
__ Bx(lr); \
__ FinalizeCode();
// Copy the generated code into a memory area garanteed to be executable before
// executing it.
#define RUN() \
{ \
ExecutableMemory code(masm.GetBuffer().GetCursorOffset()); \
code.Write(masm.GetBuffer().GetOffsetAddress<byte*>(0), \
masm.GetBuffer().GetCursorOffset()); \
int pcs_offset = masm.IsT32() ? 1 : 0; \
code.Execute(pcs_offset); \
}
#define TEARDOWN()
#endif // ifdef VIXL_INCLUDE_SIMULATOR
namespace vixl {
namespace aarch32 {
// List of instruction encodings:
#define FOREACH_INSTRUCTION(M) \
M(Sxtab) \
M(Sxtab16) \
M(Sxtah) \
M(Uxtab) \
M(Uxtab16) \
M(Uxtah)
// Values to be passed to the assembler to produce the instruction under test.
struct Operands {
Condition cond;
Register rd;
Register rn;
Register rm;
ShiftType ror;
uint32_t amount;
};
// Input data to feed to the instruction.
struct Inputs {
uint32_t apsr;
uint32_t rd;
uint32_t rn;
uint32_t rm;
};
// This structure contains all input data needed to test one specific encoding.
// It used to generate a loop over an instruction.
struct TestLoopData {
// The `operands` fields represents the values to pass to the assembler to
// produce the instruction.
Operands operands;
// Description of the operands, used for error reporting.
const char* operands_description;
// Unique identifier, used for generating traces.
const char* identifier;
// Array of values to be fed to the instruction.
size_t input_size;
const Inputs* inputs;
};
static const Inputs kCondition[] = {
{NFlag, 0xabababab, 0xabababab, 0xabababab},
{ZFlag, 0xabababab, 0xabababab, 0xabababab},
{CFlag, 0xabababab, 0xabababab, 0xabababab},
{VFlag, 0xabababab, 0xabababab, 0xabababab},
{NZFlag, 0xabababab, 0xabababab, 0xabababab},
{NCFlag, 0xabababab, 0xabababab, 0xabababab},
{NVFlag, 0xabababab, 0xabababab, 0xabababab},
{ZCFlag, 0xabababab, 0xabababab, 0xabababab},
{ZVFlag, 0xabababab, 0xabababab, 0xabababab},
{CVFlag, 0xabababab, 0xabababab, 0xabababab},
{NZCFlag, 0xabababab, 0xabababab, 0xabababab},
{NZVFlag, 0xabababab, 0xabababab, 0xabababab},
{NCVFlag, 0xabababab, 0xabababab, 0xabababab},
{ZCVFlag, 0xabababab, 0xabababab, 0xabababab},
{NZCVFlag, 0xabababab, 0xabababab, 0xabababab}};
static const Inputs kRdIsRn[] = {{NoFlag, 0xffffff83, 0xffffff83, 0xffff8002},
{NoFlag, 0x0000007e, 0x0000007e, 0x7fffffff},
{NoFlag, 0x0000007d, 0x0000007d, 0xffffffe0},
{NoFlag, 0x7fffffff, 0x7fffffff, 0x00000002},
{NoFlag, 0xffff8002, 0xffff8002, 0xfffffffd},
{NoFlag, 0xffffffe0, 0xffffffe0, 0x00007fff},
{NoFlag, 0xffff8000, 0xffff8000, 0xffffff83},
{NoFlag, 0xffff8002, 0xffff8002, 0x80000001},
{NoFlag, 0x00007ffd, 0x00007ffd, 0xffff8003},
{NoFlag, 0x00007fff, 0x00007fff, 0xffffffff},
{NoFlag, 0x00000000, 0x00000000, 0xffffff80},
{NoFlag, 0xffff8001, 0xffff8001, 0x33333333},
{NoFlag, 0xffffff80, 0xffffff80, 0x0000007e},
{NoFlag, 0x0000007e, 0x0000007e, 0x7ffffffd},
{NoFlag, 0xffffff80, 0xffffff80, 0xfffffffd},
{NoFlag, 0x00000020, 0x00000020, 0xffff8002},
{NoFlag, 0xffffff80, 0xffffff80, 0xfffffffe},
{NoFlag, 0x00000002, 0x00000002, 0x00000000},
{NoFlag, 0x0000007e, 0x0000007e, 0x00000001},
{NoFlag, 0x00000002, 0x00000002, 0x0000007f},
{NoFlag, 0x80000000, 0x80000000, 0x80000000},
{NoFlag, 0x7fffffff, 0x7fffffff, 0xffffff80},
{NoFlag, 0x00000001, 0x00000001, 0xfffffffe},
{NoFlag, 0x33333333, 0x33333333, 0x0000007d},
{NoFlag, 0x00000001, 0x00000001, 0x7ffffffe},
{NoFlag, 0x00007ffe, 0x00007ffe, 0x7fffffff},
{NoFlag, 0x80000000, 0x80000000, 0xffffff83},
{NoFlag, 0x00000000, 0x00000000, 0x7ffffffe},
{NoFlag, 0x00000000, 0x00000000, 0x0000007f},
{NoFlag, 0x7fffffff, 0x7fffffff, 0xcccccccc},
{NoFlag, 0xffffff82, 0xffffff82, 0x00000002},
{NoFlag, 0x7ffffffd, 0x7ffffffd, 0xaaaaaaaa},
{NoFlag, 0xcccccccc, 0xcccccccc, 0xffff8001},
{NoFlag, 0xfffffffe, 0xfffffffe, 0xffff8001},
{NoFlag, 0x7fffffff, 0x7fffffff, 0x00000020},
{NoFlag, 0xffffffe0, 0xffffffe0, 0x00007ffe},
{NoFlag, 0x80000001, 0x80000001, 0xffff8000},
{NoFlag, 0xffffff82, 0xffffff82, 0x0000007d},
{NoFlag, 0x0000007e, 0x0000007e, 0x7ffffffe},
{NoFlag, 0x00007ffd, 0x00007ffd, 0xffffff80},
{NoFlag, 0x0000007d, 0x0000007d, 0x0000007e},
{NoFlag, 0xffff8002, 0xffff8002, 0x7fffffff},
{NoFlag, 0xffffffe0, 0xffffffe0, 0x0000007f},
{NoFlag, 0x00007ffe, 0x00007ffe, 0xffffff81},
{NoFlag, 0x80000000, 0x80000000, 0x0000007e},
{NoFlag, 0xffffffff, 0xffffffff, 0xaaaaaaaa},
{NoFlag, 0xfffffffe, 0xfffffffe, 0x00000020},
{NoFlag, 0xffffff82, 0xffffff82, 0xffff8003},
{NoFlag, 0x7ffffffd, 0x7ffffffd, 0xffff8002},
{NoFlag, 0x7ffffffe, 0x7ffffffe, 0x00000000},
{NoFlag, 0xfffffffd, 0xfffffffd, 0xffffffe0},
{NoFlag, 0xffff8000, 0xffff8000, 0xffff8002},
{NoFlag, 0xffffff82, 0xffffff82, 0x7ffffffd},
{NoFlag, 0xcccccccc, 0xcccccccc, 0x80000000},
{NoFlag, 0x80000001, 0x80000001, 0x33333333},
{NoFlag, 0x00000001, 0x00000001, 0x00000002},
{NoFlag, 0x55555555, 0x55555555, 0x0000007f},
{NoFlag, 0xffffffff, 0xffffffff, 0xfffffffd},
{NoFlag, 0xffffff80, 0xffffff80, 0x80000000},
{NoFlag, 0x00000000, 0x00000000, 0x00000020},
{NoFlag, 0xfffffffe, 0xfffffffe, 0xffff8003},
{NoFlag, 0xffff8001, 0xffff8001, 0xffff8000},
{NoFlag, 0x55555555, 0x55555555, 0x55555555},
{NoFlag, 0x00007fff, 0x00007fff, 0xffff8000},
{NoFlag, 0x7fffffff, 0x7fffffff, 0xffffffe0},
{NoFlag, 0x00000001, 0x00000001, 0x55555555},
{NoFlag, 0x33333333, 0x33333333, 0x7ffffffe},
{NoFlag, 0x80000000, 0x80000000, 0xffffffe0},
{NoFlag, 0xffffff83, 0xffffff83, 0x0000007d},
{NoFlag, 0xffff8003, 0xffff8003, 0x00000002},
{NoFlag, 0x7ffffffe, 0x7ffffffe, 0xffffff81},
{NoFlag, 0xfffffffe, 0xfffffffe, 0xffffff80},
{NoFlag, 0x00007ffe, 0x00007ffe, 0xffff8002},
{NoFlag, 0x80000001, 0x80000001, 0xfffffffe},
{NoFlag, 0x7ffffffd, 0x7ffffffd, 0xfffffffd},
{NoFlag, 0x7ffffffd, 0x7ffffffd, 0xfffffffe},
{NoFlag, 0x7ffffffe, 0x7ffffffe, 0xffffff83},
{NoFlag, 0xfffffffd, 0xfffffffd, 0x00007ffe},
{NoFlag, 0x7fffffff, 0x7fffffff, 0x80000000},
{NoFlag, 0xffffff82, 0xffffff82, 0x7fffffff},
{NoFlag, 0xffffffe0, 0xffffffe0, 0xffffff83},
{NoFlag, 0xffff8000, 0xffff8000, 0xffff8000},
{NoFlag, 0x00000001, 0x00000001, 0x7fffffff},
{NoFlag, 0xfffffffe, 0xfffffffe, 0xffffffff},
{NoFlag, 0xffffff82, 0xffffff82, 0xffffffff},
{NoFlag, 0xffffffff, 0xffffffff, 0xfffffffe},
{NoFlag, 0xaaaaaaaa, 0xaaaaaaaa, 0x0000007d},
{NoFlag, 0xffff8001, 0xffff8001, 0xfffffffe},
{NoFlag, 0x00007ffe, 0x00007ffe, 0x0000007d},
{NoFlag, 0xffffff82, 0xffffff82, 0xfffffffe},
{NoFlag, 0x00000000, 0x00000000, 0x00007ffd},
{NoFlag, 0xaaaaaaaa, 0xaaaaaaaa, 0xffff8002},
{NoFlag, 0x0000007f, 0x0000007f, 0xffffff82},
{NoFlag, 0x00007fff, 0x00007fff, 0x33333333},
{NoFlag, 0xfffffffd, 0xfffffffd, 0x80000000},
{NoFlag, 0x00000000, 0x00000000, 0xfffffffd},
{NoFlag, 0x0000007d, 0x0000007d, 0x0000007f},
{NoFlag, 0xfffffffd, 0xfffffffd, 0x0000007e},
{NoFlag, 0xffffffe0, 0xffffffe0, 0x55555555},
{NoFlag, 0xffffffff, 0xffffffff, 0x80000000},
{NoFlag, 0xffffffe0, 0xffffffe0, 0x0000007e},
{NoFlag, 0xffffff81, 0xffffff81, 0x00007ffd},
{NoFlag, 0x00000020, 0x00000020, 0xffff8001},
{NoFlag, 0x00007fff, 0x00007fff, 0xffffff83},
{NoFlag, 0x33333333, 0x33333333, 0x00000000},
{NoFlag, 0xffff8000, 0xffff8000, 0xffffff82},
{NoFlag, 0xffff8001, 0xffff8001, 0x0000007e},
{NoFlag, 0xffffff80, 0xffffff80, 0x00000001},
{NoFlag, 0x80000000, 0x80000000, 0xcccccccc},
{NoFlag, 0x00000002, 0x00000002, 0x00007ffd},
{NoFlag, 0x7ffffffe, 0x7ffffffe, 0x80000001},
{NoFlag, 0x00000020, 0x00000020, 0x00007ffe},
{NoFlag, 0xffff8000, 0xffff8000, 0xfffffffd},
{NoFlag, 0x7fffffff, 0x7fffffff, 0xffff8001},
{NoFlag, 0x00000000, 0x00000000, 0xffffff83},
{NoFlag, 0x0000007f, 0x0000007f, 0x00000020},
{NoFlag, 0x80000001, 0x80000001, 0xffff8003},
{NoFlag, 0xffff8001, 0xffff8001, 0x0000007f},
{NoFlag, 0x0000007f, 0x0000007f, 0x80000001},
{NoFlag, 0x00000002, 0x00000002, 0x7ffffffe},
{NoFlag, 0xffffff82, 0xffffff82, 0xffffff83},
{NoFlag, 0x00007ffd, 0x00007ffd, 0x7fffffff},
{NoFlag, 0x7ffffffe, 0x7ffffffe, 0xfffffffe},
{NoFlag, 0xffffff82, 0xffffff82, 0xffff8000},
{NoFlag, 0xfffffffe, 0xfffffffe, 0xffff8000},
{NoFlag, 0xffff8002, 0xffff8002, 0xffffff81},
{NoFlag, 0x33333333, 0x33333333, 0x7fffffff},
{NoFlag, 0x80000001, 0x80000001, 0x00007fff},
{NoFlag, 0xffff8002, 0xffff8002, 0xcccccccc},
{NoFlag, 0xffffffff, 0xffffffff, 0x00000002},
{NoFlag, 0x33333333, 0x33333333, 0xffffff81},
{NoFlag, 0xfffffffd, 0xfffffffd, 0xffffff80},
{NoFlag, 0x55555555, 0x55555555, 0xaaaaaaaa},
{NoFlag, 0x33333333, 0x33333333, 0xffffff82},
{NoFlag, 0xffffff80, 0xffffff80, 0xaaaaaaaa},
{NoFlag, 0x0000007e, 0x0000007e, 0x00000020},
{NoFlag, 0xffffff83, 0xffffff83, 0x00007ffd},
{NoFlag, 0xffffff82, 0xffffff82, 0xaaaaaaaa},
{NoFlag, 0xffff8003, 0xffff8003, 0xffffffff},
{NoFlag, 0xaaaaaaaa, 0xaaaaaaaa, 0xfffffffe},
{NoFlag, 0xaaaaaaaa, 0xaaaaaaaa, 0x00000000},
{NoFlag, 0xaaaaaaaa, 0xaaaaaaaa, 0x0000007f},
{NoFlag, 0x0000007f, 0x0000007f, 0x0000007d},
{NoFlag, 0xfffffffd, 0xfffffffd, 0x55555555},
{NoFlag, 0xffffffff, 0xffffffff, 0x00000020},
{NoFlag, 0x00007ffe, 0x00007ffe, 0xffffff83},
{NoFlag, 0x7fffffff, 0x7fffffff, 0x55555555},
{NoFlag, 0x55555555, 0x55555555, 0xcccccccc},
{NoFlag, 0xffffffe0, 0xffffffe0, 0xffff8003},
{NoFlag, 0x7ffffffe, 0x7ffffffe, 0x00007ffe},
{NoFlag, 0x00007ffd, 0x00007ffd, 0xffff8002},
{NoFlag, 0x00007ffd, 0x00007ffd, 0x00000001},
{NoFlag, 0x00000000, 0x00000000, 0x00007ffe},
{NoFlag, 0xffffff80, 0xffffff80, 0x00000020},
{NoFlag, 0xffff8000, 0xffff8000, 0x0000007d},
{NoFlag, 0xffff8003, 0xffff8003, 0x00000000},
{NoFlag, 0x0000007e, 0x0000007e, 0x80000000},
{NoFlag, 0xfffffffd, 0xfffffffd, 0x00000000},
{NoFlag, 0xffffff80, 0xffffff80, 0xffffffff},
{NoFlag, 0xcccccccc, 0xcccccccc, 0x0000007f},
{NoFlag, 0x7ffffffd, 0x7ffffffd, 0x00000000},
{NoFlag, 0x00007fff, 0x00007fff, 0x00000000},
{NoFlag, 0x0000007f, 0x0000007f, 0x00000001},
{NoFlag, 0xffffffff, 0xffffffff, 0xffffff82},
{NoFlag, 0x00007ffe, 0x00007ffe, 0x00007ffd},
{NoFlag, 0xaaaaaaaa, 0xaaaaaaaa, 0x33333333},
{NoFlag, 0xffffff82, 0xffffff82, 0x55555555},
{NoFlag, 0xffff8003, 0xffff8003, 0x0000007e},
{NoFlag, 0xffffff83, 0xffffff83, 0x00000002},
{NoFlag, 0xffffff82, 0xffffff82, 0x33333333},
{NoFlag, 0x55555555, 0x55555555, 0xffffffff},
{NoFlag, 0xaaaaaaaa, 0xaaaaaaaa, 0x80000001},
{NoFlag, 0xffffff83, 0xffffff83, 0xffffffe0},
{NoFlag, 0x00000001, 0x00000001, 0xffffffe0},
{NoFlag, 0x33333333, 0x33333333, 0x33333333},
{NoFlag, 0x55555555, 0x55555555, 0x00000001},
{NoFlag, 0xffffff83, 0xffffff83, 0x00007fff},
{NoFlag, 0x00000002, 0x00000002, 0xfffffffd},
{NoFlag, 0xffffffe0, 0xffffffe0, 0xffff8002},
{NoFlag, 0x80000000, 0x80000000, 0x00007ffd},
{NoFlag, 0xffffff83, 0xffffff83, 0xfffffffe},
{NoFlag, 0x80000001, 0x80000001, 0xffffffff},
{NoFlag, 0xffff8003, 0xffff8003, 0x00000020},
{NoFlag, 0xffffff82, 0xffffff82, 0xcccccccc},
{NoFlag, 0x00000020, 0x00000020, 0x7fffffff},
{NoFlag, 0xffffff80, 0xffffff80, 0x55555555},
{NoFlag, 0x00000001, 0x00000001, 0x00000020},
{NoFlag, 0xffff8001, 0xffff8001, 0x00007fff},
{NoFlag, 0x00000020, 0x00000020, 0xaaaaaaaa},
{NoFlag, 0x55555555, 0x55555555, 0x7fffffff},
{NoFlag, 0xfffffffe, 0xfffffffe, 0x7fffffff},
{NoFlag, 0x00007fff, 0x00007fff, 0x55555555},
{NoFlag, 0x55555555, 0x55555555, 0x0000007d},
{NoFlag, 0xcccccccc, 0xcccccccc, 0x7ffffffe},
{NoFlag, 0xffff8002, 0xffff8002, 0x00007ffe},
{NoFlag, 0xfffffffe, 0xfffffffe, 0xffffff81},
{NoFlag, 0xffffff81, 0xffffff81, 0x0000007d},
{NoFlag, 0x00000020, 0x00000020, 0x0000007e},
{NoFlag, 0xffffffff, 0xffffffff, 0x00007ffe},
{NoFlag, 0xffff8002, 0xffff8002, 0x0000007e}};
static const Inputs kRdIsRm[] = {{NoFlag, 0x55555555, 0x7ffffffe, 0x55555555},
{NoFlag, 0xfffffffe, 0x00000001, 0xfffffffe},
{NoFlag, 0xffffff82, 0xffffff82, 0xffffff82},
{NoFlag, 0xffff8000, 0xffff8003, 0xffff8000},
{NoFlag, 0x00000001, 0x00000000, 0x00000001},
{NoFlag, 0xffffff81, 0x00007fff, 0xffffff81},
{NoFlag, 0x0000007d, 0xffff8002, 0x0000007d},
{NoFlag, 0x80000000, 0xffff8000, 0x80000000},
{NoFlag, 0xffffff80, 0x00000020, 0xffffff80},
{NoFlag, 0x55555555, 0xffffff81, 0x55555555},
{NoFlag, 0x00007ffd, 0xffffff82, 0x00007ffd},
{NoFlag, 0x55555555, 0x00007fff, 0x55555555},
{NoFlag, 0x7ffffffd, 0xffff8000, 0x7ffffffd},
{NoFlag, 0xffffffff, 0xffffff83, 0xffffffff},
{NoFlag, 0x00000000, 0xffffffff, 0x00000000},
{NoFlag, 0xffff8002, 0x33333333, 0xffff8002},
{NoFlag, 0x00007ffd, 0xaaaaaaaa, 0x00007ffd},
{NoFlag, 0x55555555, 0xffff8000, 0x55555555},
{NoFlag, 0x80000001, 0xffffffff, 0x80000001},
{NoFlag, 0x0000007d, 0xffffff83, 0x0000007d},
{NoFlag, 0x0000007e, 0xffffff82, 0x0000007e},
{NoFlag, 0xcccccccc, 0x0000007d, 0xcccccccc},
{NoFlag, 0xffff8002, 0xffffffff, 0xffff8002},
{NoFlag, 0xffffff81, 0x0000007f, 0xffffff81},
{NoFlag, 0xffff8000, 0xffffff83, 0xffff8000},
{NoFlag, 0xffffffff, 0xffffffe0, 0xffffffff},
{NoFlag, 0xfffffffd, 0x80000001, 0xfffffffd},
{NoFlag, 0x55555555, 0x80000000, 0x55555555},
{NoFlag, 0xffff8000, 0x0000007d, 0xffff8000},
{NoFlag, 0xaaaaaaaa, 0xffff8003, 0xaaaaaaaa},
{NoFlag, 0x00000001, 0x00007ffd, 0x00000001},
{NoFlag, 0x0000007e, 0x7ffffffe, 0x0000007e},
{NoFlag, 0x00000020, 0x00007ffd, 0x00000020},
{NoFlag, 0xffffff81, 0x7ffffffd, 0xffffff81},
{NoFlag, 0xffffff83, 0x0000007f, 0xffffff83},
{NoFlag, 0x00000001, 0x0000007e, 0x00000001},
{NoFlag, 0xffffff82, 0xfffffffd, 0xffffff82},
{NoFlag, 0xffff8003, 0x7ffffffe, 0xffff8003},
{NoFlag, 0x00000002, 0x00000002, 0x00000002},
{NoFlag, 0xffffff83, 0xffff8001, 0xffffff83},
{NoFlag, 0xffff8002, 0xfffffffe, 0xffff8002},
{NoFlag, 0xffffff80, 0xffffff81, 0xffffff80},
{NoFlag, 0x7fffffff, 0xffffff81, 0x7fffffff},
{NoFlag, 0x00000020, 0xffffff81, 0x00000020},
{NoFlag, 0x0000007f, 0xffffffff, 0x0000007f},
{NoFlag, 0x0000007d, 0xcccccccc, 0x0000007d},
{NoFlag, 0x00007fff, 0x55555555, 0x00007fff},
{NoFlag, 0xffff8003, 0x00007ffd, 0xffff8003},
{NoFlag, 0x80000001, 0x80000001, 0x80000001},
{NoFlag, 0xffffffff, 0xfffffffd, 0xffffffff},
{NoFlag, 0xffff8000, 0xfffffffe, 0xffff8000},
{NoFlag, 0xcccccccc, 0x0000007f, 0xcccccccc},
{NoFlag, 0x00000001, 0x00000002, 0x00000001},
{NoFlag, 0xffffff82, 0xffffff81, 0xffffff82},
{NoFlag, 0xfffffffd, 0x00007ffd, 0xfffffffd},
{NoFlag, 0x80000001, 0x33333333, 0x80000001},
{NoFlag, 0xffffff82, 0xffff8002, 0xffffff82},
{NoFlag, 0xffff8003, 0xfffffffd, 0xffff8003},
{NoFlag, 0xffffff81, 0x00000020, 0xffffff81},
{NoFlag, 0xffff8001, 0xffff8003, 0xffff8001},
{NoFlag, 0x00000001, 0x80000001, 0x00000001},
{NoFlag, 0xfffffffd, 0x00000002, 0xfffffffd},
{NoFlag, 0xffff8003, 0x7ffffffd, 0xffff8003},
{NoFlag, 0x0000007e, 0xaaaaaaaa, 0x0000007e},
{NoFlag, 0x7ffffffe, 0x7fffffff, 0x7ffffffe},
{NoFlag, 0x00007ffd, 0x00007ffe, 0x00007ffd},
{NoFlag, 0x00007fff, 0x80000001, 0x00007fff},
{NoFlag, 0x00007fff, 0xfffffffe, 0x00007fff},
{NoFlag, 0x00000001, 0xffffff80, 0x00000001},
{NoFlag, 0x55555555, 0xcccccccc, 0x55555555},
{NoFlag, 0x7ffffffd, 0xffffffe0, 0x7ffffffd},
{NoFlag, 0xffffff81, 0xfffffffe, 0xffffff81},
{NoFlag, 0xffffff82, 0x00007ffe, 0xffffff82},
{NoFlag, 0xffffff82, 0x80000001, 0xffffff82},
{NoFlag, 0x0000007f, 0xffff8001, 0x0000007f},
{NoFlag, 0x7ffffffd, 0xffffff83, 0x7ffffffd},
{NoFlag, 0xffffff82, 0xcccccccc, 0xffffff82},
{NoFlag, 0x00000020, 0xffffff83, 0x00000020},
{NoFlag, 0x00007ffe, 0x80000000, 0x00007ffe},
{NoFlag, 0x0000007f, 0xffff8000, 0x0000007f},
{NoFlag, 0xffffff82, 0x33333333, 0xffffff82},
{NoFlag, 0x7ffffffd, 0x7ffffffd, 0x7ffffffd},
{NoFlag, 0xffffff80, 0xffff8001, 0xffffff80},
{NoFlag, 0x00000002, 0xaaaaaaaa, 0x00000002},
{NoFlag, 0xffffffff, 0x7fffffff, 0xffffffff},
{NoFlag, 0xfffffffd, 0xfffffffe, 0xfffffffd},
{NoFlag, 0x00000020, 0x00000001, 0x00000020},
{NoFlag, 0x55555555, 0x00000001, 0x55555555},
{NoFlag, 0x55555555, 0xffffff80, 0x55555555},
{NoFlag, 0xffffffff, 0x00007fff, 0xffffffff},
{NoFlag, 0x00000020, 0xaaaaaaaa, 0x00000020},
{NoFlag, 0x00000002, 0x00007ffe, 0x00000002},
{NoFlag, 0x00000001, 0xcccccccc, 0x00000001},
{NoFlag, 0xffff8001, 0x00000000, 0xffff8001},
{NoFlag, 0x00000001, 0xffff8000, 0x00000001},
{NoFlag, 0xffffffe0, 0x00007fff, 0xffffffe0},
{NoFlag, 0xfffffffe, 0x00007fff, 0xfffffffe},
{NoFlag, 0xffffff83, 0x00000001, 0xffffff83},
{NoFlag, 0x00007fff, 0xffff8002, 0x00007fff},
{NoFlag, 0x7ffffffd, 0x7ffffffe, 0x7ffffffd},
{NoFlag, 0x80000001, 0xaaaaaaaa, 0x80000001},
{NoFlag, 0x80000001, 0xcccccccc, 0x80000001},
{NoFlag, 0x00007ffe, 0xffffffe0, 0x00007ffe},
{NoFlag, 0x00007ffe, 0xfffffffd, 0x00007ffe},
{NoFlag, 0x55555555, 0xaaaaaaaa, 0x55555555},
{NoFlag, 0xffffffe0, 0x00000001, 0xffffffe0},
{NoFlag, 0x0000007e, 0x00007fff, 0x0000007e},
{NoFlag, 0xfffffffe, 0xfffffffd, 0xfffffffe},
{NoFlag, 0x33333333, 0x0000007d, 0x33333333},
{NoFlag, 0xffffff81, 0x7fffffff, 0xffffff81},
{NoFlag, 0x0000007e, 0x0000007d, 0x0000007e},
{NoFlag, 0x00000001, 0xffffff81, 0x00000001},
{NoFlag, 0x80000000, 0x00000002, 0x80000000},
{NoFlag, 0x0000007d, 0xffff8003, 0x0000007d},
{NoFlag, 0x7ffffffe, 0x00007ffd, 0x7ffffffe},
{NoFlag, 0x7ffffffe, 0xaaaaaaaa, 0x7ffffffe},
{NoFlag, 0x00000000, 0xffff8000, 0x00000000},
{NoFlag, 0x33333333, 0x00000002, 0x33333333},
{NoFlag, 0xffffff81, 0xffffff83, 0xffffff81},
{NoFlag, 0x7ffffffe, 0x00007ffe, 0x7ffffffe},
{NoFlag, 0x80000000, 0x0000007d, 0x80000000},
{NoFlag, 0x00000020, 0x00000002, 0x00000020},
{NoFlag, 0x33333333, 0x80000001, 0x33333333},
{NoFlag, 0xffffff83, 0x00007ffd, 0xffffff83},
{NoFlag, 0x00007ffd, 0xffffff83, 0x00007ffd},
{NoFlag, 0xffff8001, 0x80000000, 0xffff8001},
{NoFlag, 0x00000000, 0x80000000, 0x00000000},
{NoFlag, 0xffffffe0, 0xffffffff, 0xffffffe0},
{NoFlag, 0x80000000, 0xffffff83, 0x80000000},
{NoFlag, 0x00000020, 0xffffff80, 0x00000020},
{NoFlag, 0x7ffffffd, 0xffff8001, 0x7ffffffd},
{NoFlag, 0x80000001, 0xffff8003, 0x80000001},
{NoFlag, 0x00007ffe, 0x7fffffff, 0x00007ffe},
{NoFlag, 0x7fffffff, 0x00000002, 0x7fffffff},
{NoFlag, 0xffffff83, 0xffff8003, 0xffffff83},
{NoFlag, 0xaaaaaaaa, 0xcccccccc, 0xaaaaaaaa},
{NoFlag, 0x0000007f, 0xffffff80, 0x0000007f},
{NoFlag, 0x80000001, 0x00007ffd, 0x80000001},
{NoFlag, 0xffff8000, 0x80000001, 0xffff8000},
{NoFlag, 0x00007fff, 0x00007ffd, 0x00007fff},
{NoFlag, 0x0000007e, 0x0000007f, 0x0000007e},
{NoFlag, 0x00000002, 0x0000007d, 0x00000002},
{NoFlag, 0x80000001, 0x7fffffff, 0x80000001},
{NoFlag, 0x0000007e, 0xffffff81, 0x0000007e},
{NoFlag, 0x7ffffffe, 0xffff8001, 0x7ffffffe},
{NoFlag, 0x7fffffff, 0x80000001, 0x7fffffff},
{NoFlag, 0x7ffffffd, 0x0000007f, 0x7ffffffd},
{NoFlag, 0xffffff81, 0xffffff81, 0xffffff81},
{NoFlag, 0x00000001, 0xfffffffd, 0x00000001},
{NoFlag, 0x00000001, 0xffffffff, 0x00000001},
{NoFlag, 0x7ffffffd, 0x55555555, 0x7ffffffd},
{NoFlag, 0x55555555, 0x0000007f, 0x55555555},
{NoFlag, 0x55555555, 0xffff8003, 0x55555555},
{NoFlag, 0xaaaaaaaa, 0x00007ffd, 0xaaaaaaaa},
{NoFlag, 0x0000007e, 0x33333333, 0x0000007e},
{NoFlag, 0xfffffffe, 0x80000001, 0xfffffffe},
{NoFlag, 0xfffffffe, 0xffff8000, 0xfffffffe},
{NoFlag, 0xffffffe0, 0xffffff81, 0xffffffe0},
{NoFlag, 0x7fffffff, 0x0000007f, 0x7fffffff},
{NoFlag, 0xffff8003, 0x0000007f, 0xffff8003},
{NoFlag, 0xffffff82, 0x00007ffd, 0xffffff82},
{NoFlag, 0x33333333, 0xffffffff, 0x33333333},
{NoFlag, 0xffffffe0, 0xcccccccc, 0xffffffe0},
{NoFlag, 0xffffff83, 0x7ffffffd, 0xffffff83},
{NoFlag, 0x0000007e, 0xcccccccc, 0x0000007e},
{NoFlag, 0x00000002, 0xfffffffd, 0x00000002},
{NoFlag, 0x00007fff, 0xcccccccc, 0x00007fff},
{NoFlag, 0x7fffffff, 0x00007fff, 0x7fffffff},
{NoFlag, 0xffffffe0, 0x33333333, 0xffffffe0},
{NoFlag, 0x0000007f, 0x0000007d, 0x0000007f},
{NoFlag, 0x0000007f, 0xffffffe0, 0x0000007f},
{NoFlag, 0x00007fff, 0xffff8000, 0x00007fff},
{NoFlag, 0x7fffffff, 0xffffffff, 0x7fffffff},
{NoFlag, 0xffff8000, 0x7ffffffd, 0xffff8000},
{NoFlag, 0xcccccccc, 0x0000007e, 0xcccccccc},
{NoFlag, 0x33333333, 0xffff8003, 0x33333333},
{NoFlag, 0x55555555, 0x00000002, 0x55555555},
{NoFlag, 0x00000001, 0x00000001, 0x00000001},
{NoFlag, 0xaaaaaaaa, 0x33333333, 0xaaaaaaaa},
{NoFlag, 0x7ffffffd, 0x00000001, 0x7ffffffd},
{NoFlag, 0xffffff82, 0xffff8000, 0xffffff82},
{NoFlag, 0x0000007d, 0x55555555, 0x0000007d},
{NoFlag, 0xffff8000, 0x7ffffffe, 0xffff8000},
{NoFlag, 0x7fffffff, 0xffffffe0, 0x7fffffff},
{NoFlag, 0x7fffffff, 0xffff8003, 0x7fffffff},
{NoFlag, 0xffffff82, 0xaaaaaaaa, 0xffffff82},
{NoFlag, 0xfffffffd, 0xffffff80, 0xfffffffd},
{NoFlag, 0x7ffffffd, 0x80000001, 0x7ffffffd},
{NoFlag, 0x00000000, 0x00007ffd, 0x00000000},
{NoFlag, 0xffffffff, 0xffffff80, 0xffffffff},
{NoFlag, 0xffffff80, 0xcccccccc, 0xffffff80},
{NoFlag, 0x00007ffe, 0x55555555, 0x00007ffe},
{NoFlag, 0xffff8000, 0xffff8000, 0xffff8000},
{NoFlag, 0xffffffff, 0xffff8000, 0xffffffff},
{NoFlag, 0x80000001, 0x0000007d, 0x80000001},
{NoFlag, 0xffffffe0, 0xffff8002, 0xffffffe0},
{NoFlag, 0xfffffffe, 0xffffffe0, 0xfffffffe},
{NoFlag, 0x80000000, 0xffff8003, 0x80000000},
{NoFlag, 0x80000001, 0xffffff81, 0x80000001},
{NoFlag, 0xffffffe0, 0x00007ffe, 0xffffffe0}};
static const Inputs kRdIsNotRnIsNotRm[] = {
{NoFlag, 0x0000007e, 0x0000007e, 0x0000007d},
{NoFlag, 0x55555555, 0x00000002, 0xffff8002},
{NoFlag, 0xffffffe0, 0x80000001, 0x00000000},
{NoFlag, 0x55555555, 0xffffff83, 0x00000002},
{NoFlag, 0xffffffe0, 0xffffffe0, 0x00000002},
{NoFlag, 0x00000000, 0x80000001, 0xffffff82},
{NoFlag, 0x80000001, 0x00007fff, 0x0000007f},
{NoFlag, 0xffffff80, 0x0000007d, 0x7ffffffe},
{NoFlag, 0xaaaaaaaa, 0x00000020, 0xffff8002},
{NoFlag, 0x33333333, 0x55555555, 0x00000001},
{NoFlag, 0x7ffffffe, 0x33333333, 0x00000000},
{NoFlag, 0x80000000, 0x7ffffffd, 0x55555555},
{NoFlag, 0xcccccccc, 0xffff8001, 0x7ffffffe},
{NoFlag, 0x00000020, 0xffffff83, 0xffff8003},
{NoFlag, 0x00007fff, 0xffffffe0, 0xffffff81},
{NoFlag, 0xffff8000, 0xffff8001, 0x0000007e},
{NoFlag, 0x33333333, 0x0000007e, 0x00000020},
{NoFlag, 0x0000007f, 0xfffffffd, 0xaaaaaaaa},
{NoFlag, 0xffffff83, 0xffffff82, 0x7ffffffd},
{NoFlag, 0x0000007e, 0xcccccccc, 0x7fffffff},
{NoFlag, 0xffff8001, 0x80000001, 0xffffffff},
{NoFlag, 0xffffff81, 0x00000020, 0x7ffffffe},
{NoFlag, 0xffffff83, 0xffffff81, 0xffffffe0},
{NoFlag, 0xffffffe0, 0xffffff81, 0xfffffffd},
{NoFlag, 0x80000001, 0xffffffff, 0xffffffff},
{NoFlag, 0x7ffffffe, 0xffff8000, 0xcccccccc},
{NoFlag, 0xffffff80, 0x00007ffe, 0xffffff82},
{NoFlag, 0x0000007e, 0x0000007d, 0xffff8003},
{NoFlag, 0xffff8002, 0xffffff81, 0x0000007e},
{NoFlag, 0x00007fff, 0x7ffffffd, 0xfffffffe},
{NoFlag, 0x00007ffe, 0x80000001, 0xffffff81},
{NoFlag, 0xffffff81, 0x00007ffd, 0xfffffffd},
{NoFlag, 0x00000020, 0x7fffffff, 0xffff8003},
{NoFlag, 0x0000007e, 0x0000007d, 0x33333333},
{NoFlag, 0xcccccccc, 0xffff8000, 0x00007ffe},
{NoFlag, 0x00007fff, 0xffff8000, 0x00000020},
{NoFlag, 0x00007ffd, 0x00007fff, 0xffffffe0},
{NoFlag, 0x7ffffffd, 0x00000000, 0x00007ffe},
{NoFlag, 0xffffff82, 0x33333333, 0x00000001},
{NoFlag, 0x7ffffffe, 0xffffff80, 0x00000020},
{NoFlag, 0x00007fff, 0xffffff83, 0x00007ffd},
{NoFlag, 0xffff8001, 0xffffffff, 0x80000001},
{NoFlag, 0x00000002, 0xffffff81, 0xcccccccc},
{NoFlag, 0x55555555, 0x0000007f, 0xffff8001},
{NoFlag, 0x80000000, 0x00000020, 0x80000000},
{NoFlag, 0xffffff83, 0x00007fff, 0xffffff80},
{NoFlag, 0x33333333, 0x7ffffffe, 0x7ffffffd},
{NoFlag, 0xffffff80, 0xffffffff, 0x00000001},
{NoFlag, 0x00007ffd, 0x7ffffffd, 0xffffff83},
{NoFlag, 0x33333333, 0xffff8001, 0xffffffe0},
{NoFlag, 0xffff8001, 0xffffff80, 0x00007ffd},
{NoFlag, 0xffffffe0, 0x00007fff, 0x00007ffe},
{NoFlag, 0x0000007d, 0x00000000, 0xffff8000},
{NoFlag, 0x7ffffffe, 0xaaaaaaaa, 0x7ffffffe},
{NoFlag, 0x0000007e, 0x00007ffd, 0xffffffe0},
{NoFlag, 0xfffffffd, 0xffffffe0, 0xffffff83},
{NoFlag, 0x00000001, 0xffffffe0, 0x7ffffffd},
{NoFlag, 0xfffffffd, 0xffff8002, 0x80000000},
{NoFlag, 0x00000020, 0xffffffff, 0x80000000},
{NoFlag, 0x00000001, 0x80000001, 0xffff8003},
{NoFlag, 0xffff8003, 0xaaaaaaaa, 0xffffff81},
{NoFlag, 0x0000007f, 0xfffffffd, 0xffffffe0},
{NoFlag, 0x00007ffe, 0xffffff80, 0x00007ffe},
{NoFlag, 0xffff8002, 0xffff8003, 0xffffffff},
{NoFlag, 0x7ffffffe, 0xffffff82, 0xffff8000},
{NoFlag, 0xffff8000, 0x00000002, 0x80000000},
{NoFlag, 0xffffff80, 0xffffff82, 0xffffff81},
{NoFlag, 0x00000000, 0xcccccccc, 0x00007ffd},
{NoFlag, 0x55555555, 0x00007ffe, 0x7fffffff},
{NoFlag, 0x00000002, 0xffffff81, 0xaaaaaaaa},
{NoFlag, 0x00007ffd, 0x0000007e, 0x00000002},
{NoFlag, 0xffffff83, 0x0000007e, 0xffffff80},
{NoFlag, 0xcccccccc, 0x00007ffe, 0xaaaaaaaa},
{NoFlag, 0x7ffffffe, 0x55555555, 0xffff8003},
{NoFlag, 0xfffffffd, 0x00000001, 0xffffff80},
{NoFlag, 0x00007ffd, 0x55555555, 0x80000001},
{NoFlag, 0x0000007f, 0x00000000, 0x0000007e},
{NoFlag, 0x7fffffff, 0xaaaaaaaa, 0x00000000},
{NoFlag, 0x7ffffffd, 0xffffff81, 0xcccccccc},
{NoFlag, 0xffffffe0, 0xcccccccc, 0xfffffffd},
{NoFlag, 0x00000002, 0xffff8000, 0x7ffffffd},
{NoFlag, 0xffffffe0, 0xffff8000, 0x80000001},
{NoFlag, 0x7ffffffd, 0xffff8003, 0xffff8001},
{NoFlag, 0x33333333, 0x00007ffd, 0x80000000},
{NoFlag, 0x7ffffffd, 0x00007fff, 0xcccccccc},
{NoFlag, 0xffffffff, 0xffffff80, 0x00007ffe},
{NoFlag, 0xffffff83, 0x7ffffffd, 0xaaaaaaaa},
{NoFlag, 0xfffffffd, 0xffff8003, 0x0000007f},
{NoFlag, 0xfffffffe, 0xfffffffe, 0xfffffffd},
{NoFlag, 0x00007fff, 0xfffffffe, 0x55555555},
{NoFlag, 0x7ffffffd, 0xfffffffe, 0xfffffffe},
{NoFlag, 0xfffffffe, 0xffffffff, 0x00007fff},
{NoFlag, 0x7ffffffd, 0x0000007e, 0x00007ffd},
{NoFlag, 0x7ffffffd, 0xffffffe0, 0x00000002},
{NoFlag, 0xffffffff, 0x00007ffd, 0xffffff81},
{NoFlag, 0xffff8001, 0x00000020, 0xfffffffd},
{NoFlag, 0x00007fff, 0x0000007d, 0xffffff83},
{NoFlag, 0x00000002, 0x55555555, 0x7ffffffe},
{NoFlag, 0x00007fff, 0x00007ffe, 0x00000002},
{NoFlag, 0x80000001, 0x7fffffff, 0x00007ffd},
{NoFlag, 0x0000007f, 0xffffffff, 0x00000001},
{NoFlag, 0xffff8001, 0x33333333, 0xffffff83},
{NoFlag, 0x00007fff, 0xcccccccc, 0x33333333},
{NoFlag, 0x33333333, 0xffffff80, 0x00000001},
{NoFlag, 0x00007fff, 0xcccccccc, 0x00007ffd},
{NoFlag, 0xffff8002, 0xfffffffd, 0x7ffffffe},
{NoFlag, 0x00007ffe, 0x7ffffffe, 0xffffff83},
{NoFlag, 0xffffffe0, 0x0000007f, 0xffff8001},
{NoFlag, 0x80000000, 0x00007fff, 0xffffff80},
{NoFlag, 0x7fffffff, 0x00007fff, 0x7ffffffe},
{NoFlag, 0xffff8002, 0x55555555, 0xffff8001},
{NoFlag, 0xffffff80, 0x00000000, 0xffffff80},
{NoFlag, 0x00007ffd, 0x00007fff, 0x00000002},
{NoFlag, 0x00000000, 0x55555555, 0xffff8003},
{NoFlag, 0x0000007f, 0xffff8003, 0x00000020},
{NoFlag, 0x00000000, 0xffff8002, 0x7fffffff},
{NoFlag, 0x00007fff, 0x55555555, 0x00000000},
{NoFlag, 0x7fffffff, 0x00007ffe, 0xffffff81},
{NoFlag, 0x0000007e, 0x80000001, 0x00007ffe},
{NoFlag, 0x7ffffffd, 0xaaaaaaaa, 0x00000020},
{NoFlag, 0xfffffffd, 0xfffffffe, 0x00000002},
{NoFlag, 0xffffff80, 0xffff8000, 0xffff8002},
{NoFlag, 0x0000007d, 0x00007fff, 0xaaaaaaaa},
{NoFlag, 0xfffffffd, 0xffffff80, 0x00007ffd},
{NoFlag, 0xffffff82, 0x80000000, 0xffffff80},
{NoFlag, 0xffffffe0, 0x55555555, 0xfffffffd},
{NoFlag, 0xffffffff, 0xffffffff, 0x00007ffd},
{NoFlag, 0x0000007e, 0xfffffffe, 0xffffff80},
{NoFlag, 0xffff8000, 0xffffff82, 0xffff8002},
{NoFlag, 0xaaaaaaaa, 0x7ffffffe, 0xffff8000},
{NoFlag, 0x55555555, 0xffff8003, 0xffffff80},
{NoFlag, 0x7ffffffe, 0x00000020, 0xffffffe0},
{NoFlag, 0x00000001, 0xffff8001, 0xffffffe0},
{NoFlag, 0xcccccccc, 0xffff8000, 0xffff8002},
{NoFlag, 0x80000000, 0x00000002, 0x7ffffffe},
{NoFlag, 0x00000002, 0x0000007f, 0xffffff81},
{NoFlag, 0xffffffff, 0x00000001, 0x7fffffff},
{NoFlag, 0xffffff83, 0x00000000, 0x33333333},
{NoFlag, 0xffff8000, 0xffffff83, 0xcccccccc},
{NoFlag, 0x80000000, 0x00000020, 0x00007ffd},
{NoFlag, 0xffffff81, 0xcccccccc, 0x00000000},
{NoFlag, 0xffffffff, 0xffff8000, 0x00007fff},
{NoFlag, 0xffff8003, 0xcccccccc, 0x00007ffe},
{NoFlag, 0xffffffff, 0xfffffffd, 0x7ffffffe},
{NoFlag, 0xffff8003, 0xaaaaaaaa, 0x55555555},
{NoFlag, 0x00000000, 0xaaaaaaaa, 0xffffff81},
{NoFlag, 0x0000007f, 0xfffffffe, 0xffff8000},
{NoFlag, 0x00000001, 0xffffffe0, 0xfffffffd},
{NoFlag, 0x33333333, 0x33333333, 0xfffffffd},
{NoFlag, 0xffffff82, 0xffff8002, 0x80000001},
{NoFlag, 0x55555555, 0xffffff83, 0xffffff83},
{NoFlag, 0xffffff83, 0xffff8002, 0x00000020},
{NoFlag, 0x0000007d, 0x7fffffff, 0x0000007f},
{NoFlag, 0x00000000, 0xcccccccc, 0xffff8000},
{NoFlag, 0x00000002, 0x7ffffffe, 0x00007fff},
{NoFlag, 0xffffff82, 0x7ffffffd, 0x7ffffffd},
{NoFlag, 0xaaaaaaaa, 0xfffffffd, 0xffff8002},
{NoFlag, 0xfffffffd, 0x00000002, 0x7fffffff},
{NoFlag, 0xfffffffe, 0xfffffffe, 0x00000020},
{NoFlag, 0x80000001, 0x0000007e, 0x00007ffe},
{NoFlag, 0x00007ffd, 0x00007ffd, 0xfffffffd},
{NoFlag, 0xffff8000, 0x0000007f, 0x00000002},
{NoFlag, 0x7ffffffd, 0x80000000, 0x7ffffffd},
{NoFlag, 0x0000007d, 0x00007fff, 0x80000001},
{NoFlag, 0xffffffff, 0x80000000, 0xaaaaaaaa},
{NoFlag, 0x00000000, 0xaaaaaaaa, 0xffff8001},
{NoFlag, 0xaaaaaaaa, 0xffffffe0, 0xffff8003},
{NoFlag, 0xffffff82, 0xffffffff, 0x00007ffd},
{NoFlag, 0x00000001, 0xffffff81, 0x00000001},
{NoFlag, 0x7fffffff, 0xaaaaaaaa, 0x80000001},
{NoFlag, 0x7fffffff, 0xffff8000, 0xffff8000},
{NoFlag, 0xaaaaaaaa, 0x00007ffd, 0xaaaaaaaa},
{NoFlag, 0x0000007f, 0x7ffffffe, 0x80000000},
{NoFlag, 0x00007ffd, 0x00007ffe, 0xffffff81},
{NoFlag, 0x0000007d, 0x0000007d, 0xffff8002},
{NoFlag, 0x80000001, 0x00000002, 0xffffff81},
{NoFlag, 0xffff8000, 0xfffffffd, 0x7ffffffd},
{NoFlag, 0xfffffffe, 0x00000020, 0xffffff80},
{NoFlag, 0x00000020, 0x7fffffff, 0xffffffe0},
{NoFlag, 0xffff8002, 0xffff8002, 0x0000007f},
{NoFlag, 0xffff8003, 0x7fffffff, 0xffff8002},
{NoFlag, 0x00000020, 0xfffffffd, 0x00000020},
{NoFlag, 0x7ffffffd, 0xffffffe0, 0x0000007e},
{NoFlag, 0x00000020, 0x00000020, 0x7ffffffe},
{NoFlag, 0xfffffffe, 0x0000007f, 0xffff8000},
{NoFlag, 0x80000001, 0x80000001, 0x0000007d},
{NoFlag, 0x55555555, 0x0000007f, 0x00007ffd},
{NoFlag, 0x55555555, 0xffffffe0, 0xffffff82},
{NoFlag, 0xffff8001, 0x0000007e, 0xffff8002},
{NoFlag, 0xffffffe0, 0x55555555, 0x0000007f},
{NoFlag, 0xffff8000, 0x7fffffff, 0x7ffffffe},
{NoFlag, 0xffffffff, 0xfffffffe, 0xffffff80},
{NoFlag, 0xffff8001, 0xffff8002, 0x33333333},
{NoFlag, 0x7ffffffd, 0xfffffffd, 0xaaaaaaaa},
{NoFlag, 0xaaaaaaaa, 0xfffffffd, 0x00000020},
{NoFlag, 0x0000007f, 0x00007ffe, 0x55555555},
{NoFlag, 0x00000020, 0x00000020, 0x00000002},
{NoFlag, 0x80000001, 0xffff8002, 0xfffffffe},
{NoFlag, 0x7fffffff, 0x80000001, 0xffff8002},
{NoFlag, 0x00000020, 0x0000007e, 0x33333333}};
static const Inputs kRotations[] = {
{NoFlag, 0xabababab, 0xabababab, 0x00000000},
{NoFlag, 0xabababab, 0xabababab, 0x00000001},
{NoFlag, 0xabababab, 0xabababab, 0x00000002},
{NoFlag, 0xabababab, 0xabababab, 0x00000020},
{NoFlag, 0xabababab, 0xabababab, 0x0000007d},
{NoFlag, 0xabababab, 0xabababab, 0x0000007e},
{NoFlag, 0xabababab, 0xabababab, 0x0000007f},
{NoFlag, 0xabababab, 0xabababab, 0x00007ffd},
{NoFlag, 0xabababab, 0xabababab, 0x00007ffe},
{NoFlag, 0xabababab, 0xabababab, 0x00007fff},
{NoFlag, 0xabababab, 0xabababab, 0x33333333},
{NoFlag, 0xabababab, 0xabababab, 0x55555555},
{NoFlag, 0xabababab, 0xabababab, 0x7ffffffd},
{NoFlag, 0xabababab, 0xabababab, 0x7ffffffe},
{NoFlag, 0xabababab, 0xabababab, 0x7fffffff},
{NoFlag, 0xabababab, 0xabababab, 0x80000000},
{NoFlag, 0xabababab, 0xabababab, 0x80000001},
{NoFlag, 0xabababab, 0xabababab, 0xaaaaaaaa},
{NoFlag, 0xabababab, 0xabababab, 0xcccccccc},
{NoFlag, 0xabababab, 0xabababab, 0xffff8000},
{NoFlag, 0xabababab, 0xabababab, 0xffff8001},
{NoFlag, 0xabababab, 0xabababab, 0xffff8002},
{NoFlag, 0xabababab, 0xabababab, 0xffff8003},
{NoFlag, 0xabababab, 0xabababab, 0xffffff80},
{NoFlag, 0xabababab, 0xabababab, 0xffffff81},
{NoFlag, 0xabababab, 0xabababab, 0xffffff82},
{NoFlag, 0xabababab, 0xabababab, 0xffffff83},
{NoFlag, 0xabababab, 0xabababab, 0xffffffe0},
{NoFlag, 0xabababab, 0xabababab, 0xfffffffd},
{NoFlag, 0xabababab, 0xabababab, 0xfffffffe},
{NoFlag, 0xabababab, 0xabababab, 0xffffffff}};
// A loop will be generated for each element of this array.
static const TestLoopData kTests[] = {{{eq, r0, r0, r0, ROR, 0},
"eq r0 r0 r0 ROR 0",
"Condition_eq_r0_r0_r0_ROR_0",
ARRAY_SIZE(kCondition),
kCondition},
{{ne, r0, r0, r0, ROR, 0},
"ne r0 r0 r0 ROR 0",
"Condition_ne_r0_r0_r0_ROR_0",
ARRAY_SIZE(kCondition),
kCondition},
{{cs, r0, r0, r0, ROR, 0},
"cs r0 r0 r0 ROR 0",
"Condition_cs_r0_r0_r0_ROR_0",
ARRAY_SIZE(kCondition),
kCondition},
{{cc, r0, r0, r0, ROR, 0},
"cc r0 r0 r0 ROR 0",
"Condition_cc_r0_r0_r0_ROR_0",
ARRAY_SIZE(kCondition),
kCondition},
{{mi, r0, r0, r0, ROR, 0},
"mi r0 r0 r0 ROR 0",
"Condition_mi_r0_r0_r0_ROR_0",
ARRAY_SIZE(kCondition),
kCondition},
{{pl, r0, r0, r0, ROR, 0},
"pl r0 r0 r0 ROR 0",
"Condition_pl_r0_r0_r0_ROR_0",
ARRAY_SIZE(kCondition),
kCondition},
{{vs, r0, r0, r0, ROR, 0},
"vs r0 r0 r0 ROR 0",
"Condition_vs_r0_r0_r0_ROR_0",
ARRAY_SIZE(kCondition),
kCondition},
{{vc, r0, r0, r0, ROR, 0},
"vc r0 r0 r0 ROR 0",
"Condition_vc_r0_r0_r0_ROR_0",
ARRAY_SIZE(kCondition),
kCondition},
{{hi, r0, r0, r0, ROR, 0},
"hi r0 r0 r0 ROR 0",
"Condition_hi_r0_r0_r0_ROR_0",
ARRAY_SIZE(kCondition),
kCondition},
{{ls, r0, r0, r0, ROR, 0},
"ls r0 r0 r0 ROR 0",
"Condition_ls_r0_r0_r0_ROR_0",
ARRAY_SIZE(kCondition),
kCondition},
{{ge, r0, r0, r0, ROR, 0},
"ge r0 r0 r0 ROR 0",
"Condition_ge_r0_r0_r0_ROR_0",
ARRAY_SIZE(kCondition),
kCondition},
{{lt, r0, r0, r0, ROR, 0},
"lt r0 r0 r0 ROR 0",
"Condition_lt_r0_r0_r0_ROR_0",
ARRAY_SIZE(kCondition),
kCondition},
{{gt, r0, r0, r0, ROR, 0},
"gt r0 r0 r0 ROR 0",
"Condition_gt_r0_r0_r0_ROR_0",
ARRAY_SIZE(kCondition),
kCondition},
{{le, r0, r0, r0, ROR, 0},
"le r0 r0 r0 ROR 0",
"Condition_le_r0_r0_r0_ROR_0",
ARRAY_SIZE(kCondition),
kCondition},
{{al, r0, r0, r0, ROR, 0},
"al r0 r0 r0 ROR 0",
"Condition_al_r0_r0_r0_ROR_0",
ARRAY_SIZE(kCondition),
kCondition},
{{al, r3, r3, r4, ROR, 0},
"al r3 r3 r4 ROR 0",
"RdIsRn_al_r3_r3_r4_ROR_0",
ARRAY_SIZE(kRdIsRn),
kRdIsRn},
{{al, r2, r2, r12, ROR, 0},
"al r2 r2 r12 ROR 0",
"RdIsRn_al_r2_r2_r12_ROR_0",
ARRAY_SIZE(kRdIsRn),
kRdIsRn},
{{al, r8, r8, r5, ROR, 0},
"al r8 r8 r5 ROR 0",
"RdIsRn_al_r8_r8_r5_ROR_0",
ARRAY_SIZE(kRdIsRn),
kRdIsRn},
{{al, r14, r14, r0, ROR, 0},
"al r14 r14 r0 ROR 0",
"RdIsRn_al_r14_r14_r0_ROR_0",
ARRAY_SIZE(kRdIsRn),
kRdIsRn},
{{al, r11, r11, r10, ROR, 0},
"al r11 r11 r10 ROR 0",
"RdIsRn_al_r11_r11_r10_ROR_0",
ARRAY_SIZE(kRdIsRn),
kRdIsRn},
{{al, r12, r12, r10, ROR, 0},
"al r12 r12 r10 ROR 0",
"RdIsRn_al_r12_r12_r10_ROR_0",
ARRAY_SIZE(kRdIsRn),
kRdIsRn},
{{al, r4, r4, r8, ROR, 0},
"al r4 r4 r8 ROR 0",
"RdIsRn_al_r4_r4_r8_ROR_0",
ARRAY_SIZE(kRdIsRn),
kRdIsRn},
{{al, r5, r5, r14, ROR, 0},
"al r5 r5 r14 ROR 0",
"RdIsRn_al_r5_r5_r14_ROR_0",
ARRAY_SIZE(kRdIsRn),
kRdIsRn},
{{al, r0, r0, r6, ROR, 0},
"al r0 r0 r6 ROR 0",
"RdIsRn_al_r0_r0_r6_ROR_0",
ARRAY_SIZE(kRdIsRn),
kRdIsRn},
{{al, r12, r12, r1, ROR, 0},
"al r12 r12 r1 ROR 0",
"RdIsRn_al_r12_r12_r1_ROR_0",
ARRAY_SIZE(kRdIsRn),
kRdIsRn},
{{al, r6, r11, r6, ROR, 0},
"al r6 r11 r6 ROR 0",
"RdIsRm_al_r6_r11_r6_ROR_0",
ARRAY_SIZE(kRdIsRm),
kRdIsRm},
{{al, r11, r9, r11, ROR, 0},
"al r11 r9 r11 ROR 0",
"RdIsRm_al_r11_r9_r11_ROR_0",
ARRAY_SIZE(kRdIsRm),
kRdIsRm},
{{al, r0, r8, r0, ROR, 0},
"al r0 r8 r0 ROR 0",
"RdIsRm_al_r0_r8_r0_ROR_0",
ARRAY_SIZE(kRdIsRm),
kRdIsRm},
{{al, r2, r11, r2, ROR, 0},
"al r2 r11 r2 ROR 0",
"RdIsRm_al_r2_r11_r2_ROR_0",
ARRAY_SIZE(kRdIsRm),
kRdIsRm},
{{al, r9, r4, r9, ROR, 0},
"al r9 r4 r9 ROR 0",
"RdIsRm_al_r9_r4_r9_ROR_0",
ARRAY_SIZE(kRdIsRm),
kRdIsRm},
{{al, r14, r10, r14, ROR, 0},
"al r14 r10 r14 ROR 0",
"RdIsRm_al_r14_r10_r14_ROR_0",
ARRAY_SIZE(kRdIsRm),
kRdIsRm},
{{al, r7, r0, r7, ROR, 0},
"al r7 r0 r7 ROR 0",
"RdIsRm_al_r7_r0_r7_ROR_0",
ARRAY_SIZE(kRdIsRm),
kRdIsRm},
{{al, r4, r9, r4, ROR, 0},
"al r4 r9 r4 ROR 0",
"RdIsRm_al_r4_r9_r4_ROR_0",
ARRAY_SIZE(kRdIsRm),
kRdIsRm},
{{al, r6, r10, r6, ROR, 0},
"al r6 r10 r6 ROR 0",
"RdIsRm_al_r6_r10_r6_ROR_0",
ARRAY_SIZE(kRdIsRm),
kRdIsRm},
{{al, r7, r6, r7, ROR, 0},
"al r7 r6 r7 ROR 0",
"RdIsRm_al_r7_r6_r7_ROR_0",
ARRAY_SIZE(kRdIsRm),
kRdIsRm},
{{al, r3, r9, r10, ROR, 0},
"al r3 r9 r10 ROR 0",
"RdIsNotRnIsNotRm_al_r3_r9_r10_ROR_0",
ARRAY_SIZE(kRdIsNotRnIsNotRm),
kRdIsNotRnIsNotRm},
{{al, r7, r12, r5, ROR, 0},
"al r7 r12 r5 ROR 0",
"RdIsNotRnIsNotRm_al_r7_r12_r5_ROR_0",
ARRAY_SIZE(kRdIsNotRnIsNotRm),
kRdIsNotRnIsNotRm},
{{al, r8, r5, r6, ROR, 0},
"al r8 r5 r6 ROR 0",
"RdIsNotRnIsNotRm_al_r8_r5_r6_ROR_0",
ARRAY_SIZE(kRdIsNotRnIsNotRm),
kRdIsNotRnIsNotRm},
{{al, r0, r6, r0, ROR, 0},
"al r0 r6 r0 ROR 0",
"RdIsNotRnIsNotRm_al_r0_r6_r0_ROR_0",
ARRAY_SIZE(kRdIsNotRnIsNotRm),
kRdIsNotRnIsNotRm},
{{al, r11, r7, r8, ROR, 0},
"al r11 r7 r8 ROR 0",
"RdIsNotRnIsNotRm_al_r11_r7_r8_ROR_0",
ARRAY_SIZE(kRdIsNotRnIsNotRm),
kRdIsNotRnIsNotRm},
{{al, r12, r2, r3, ROR, 0},
"al r12 r2 r3 ROR 0",
"RdIsNotRnIsNotRm_al_r12_r2_r3_ROR_0",
ARRAY_SIZE(kRdIsNotRnIsNotRm),
kRdIsNotRnIsNotRm},
{{al, r7, r4, r10, ROR, 0},
"al r7 r4 r10 ROR 0",
"RdIsNotRnIsNotRm_al_r7_r4_r10_ROR_0",
ARRAY_SIZE(kRdIsNotRnIsNotRm),
kRdIsNotRnIsNotRm},
{{al, r9, r6, r1, ROR, 0},
"al r9 r6 r1 ROR 0",
"RdIsNotRnIsNotRm_al_r9_r6_r1_ROR_0",
ARRAY_SIZE(kRdIsNotRnIsNotRm),
kRdIsNotRnIsNotRm},
{{al, r10, r14, r3, ROR, 0},
"al r10 r14 r3 ROR 0",
"RdIsNotRnIsNotRm_al_r10_r14_r3_ROR_0",
ARRAY_SIZE(kRdIsNotRnIsNotRm),
kRdIsNotRnIsNotRm},
{{al, r14, r3, r6, ROR, 0},
"al r14 r3 r6 ROR 0",
"RdIsNotRnIsNotRm_al_r14_r3_r6_ROR_0",
ARRAY_SIZE(kRdIsNotRnIsNotRm),
kRdIsNotRnIsNotRm},
{{al, r0, r1, r2, ROR, 0},
"al r0 r1 r2 ROR 0",
"Rotations_al_r0_r1_r2_ROR_0",
ARRAY_SIZE(kRotations),
kRotations},
{{al, r0, r1, r2, ROR, 8},
"al r0 r1 r2 ROR 8",
"Rotations_al_r0_r1_r2_ROR_8",
ARRAY_SIZE(kRotations),
kRotations},
{{al, r0, r1, r2, ROR, 16},
"al r0 r1 r2 ROR 16",
"Rotations_al_r0_r1_r2_ROR_16",
ARRAY_SIZE(kRotations),
kRotations},
{{al, r0, r1, r2, ROR, 24},
"al r0 r1 r2 ROR 24",
"Rotations_al_r0_r1_r2_ROR_24",
ARRAY_SIZE(kRotations),
kRotations}};
// We record all inputs to the instructions as outputs. This way, we also check
// that what shouldn't change didn't change.
struct TestResult {
size_t output_size;
const Inputs* outputs;
};
// These headers each contain an array of `TestResult` with the reference output
// values. The reference arrays are names `kReference{mnemonic}`.
#include "a32/traces/simulator-cond-rd-rn-operand-rm-ror-amount-a32-sxtab.h"
#include "a32/traces/simulator-cond-rd-rn-operand-rm-ror-amount-a32-sxtab16.h"
#include "a32/traces/simulator-cond-rd-rn-operand-rm-ror-amount-a32-sxtah.h"
#include "a32/traces/simulator-cond-rd-rn-operand-rm-ror-amount-a32-uxtab.h"
#include "a32/traces/simulator-cond-rd-rn-operand-rm-ror-amount-a32-uxtab16.h"
#include "a32/traces/simulator-cond-rd-rn-operand-rm-ror-amount-a32-uxtah.h"
// The maximum number of errors to report in detail for each test.
static const unsigned kErrorReportLimit = 8;
typedef void (MacroAssembler::*Fn)(Condition cond, Register rd, Register rn,
const Operand& op);
static void TestHelper(Fn instruction, const char* mnemonic,
const TestResult reference[]) {
SETUP();
masm.SetT32(false);
START();
// Data to compare to `reference`.
TestResult* results[ARRAY_SIZE(kTests)];
// Test cases for memory bound instructions may allocate a buffer and save its
// address in this array.
byte* scratch_memory_buffers[ARRAY_SIZE(kTests)];
// Generate a loop for each element in `kTests`. Each loop tests one specific
// instruction.
for (unsigned i = 0; i < ARRAY_SIZE(kTests); i++) {
// Allocate results on the heap for this test.
results[i] = new TestResult;
results[i]->outputs = new Inputs[kTests[i].input_size];
results[i]->output_size = kTests[i].input_size;
uintptr_t input_address = reinterpret_cast<uintptr_t>(kTests[i].inputs);
uintptr_t result_address = reinterpret_cast<uintptr_t>(results[i]->outputs);
scratch_memory_buffers[i] = NULL;
Label loop;
UseScratchRegisterScope scratch_registers(&masm);
// Include all registers from r0 ro r12.
scratch_registers.Include(RegisterList(0x1fff));
// Values to pass to the macro-assembler.
Condition cond = kTests[i].operands.cond;
Register rd = kTests[i].operands.rd;
Register rn = kTests[i].operands.rn;
Register rm = kTests[i].operands.rm;
ShiftType ror = kTests[i].operands.ror;
uint32_t amount = kTests[i].operands.amount;
Operand op(rm, ror, amount);
scratch_registers.Exclude(rd);
scratch_registers.Exclude(rn);
scratch_registers.Exclude(rm);
// Allocate reserved registers for our own use.
Register input_ptr = scratch_registers.Acquire();
Register input_end = scratch_registers.Acquire();
Register result_ptr = scratch_registers.Acquire();
// Initialize `input_ptr` to the first element and `input_end` the address
// after the array.
__ Mov(input_ptr, input_address);
__ Add(input_end, input_ptr,
sizeof(kTests[i].inputs[0]) * kTests[i].input_size);
__ Mov(result_ptr, result_address);
__ Bind(&loop);
{
UseScratchRegisterScope temp_registers(&masm);
Register nzcv_bits = temp_registers.Acquire();
Register saved_q_bit = temp_registers.Acquire();
// Save the `Q` bit flag.
__ Mrs(saved_q_bit, APSR);
__ And(saved_q_bit, saved_q_bit, QFlag);
// Set the `NZCV` and `Q` flags together.
__ Ldr(nzcv_bits, MemOperand(input_ptr, offsetof(Inputs, apsr)));
__ Orr(nzcv_bits, nzcv_bits, saved_q_bit);
__ Msr(APSR_nzcvq, nzcv_bits);
}
__ Ldr(rd, MemOperand(input_ptr, offsetof(Inputs, rd)));
__ Ldr(rn, MemOperand(input_ptr, offsetof(Inputs, rn)));
__ Ldr(rm, MemOperand(input_ptr, offsetof(Inputs, rm)));
(masm.*instruction)(cond, rd, rn, op);
{
UseScratchRegisterScope temp_registers(&masm);
Register nzcv_bits = temp_registers.Acquire();
__ Mrs(nzcv_bits, APSR);
// Only record the NZCV bits.
__ And(nzcv_bits, nzcv_bits, NZCVFlag);
__ Str(nzcv_bits, MemOperand(result_ptr, offsetof(Inputs, apsr)));
}
__ Str(rd, MemOperand(result_ptr, offsetof(Inputs, rd)));
__ Str(rn, MemOperand(result_ptr, offsetof(Inputs, rn)));
__ Str(rm, MemOperand(result_ptr, offsetof(Inputs, rm)));
// Advance the result pointer.
__ Add(result_ptr, result_ptr, sizeof(kTests[i].inputs[0]));
// Loop back until `input_ptr` is lower than `input_base`.
__ Add(input_ptr, input_ptr, sizeof(kTests[i].inputs[0]));
__ Cmp(input_ptr, input_end);
__ B(ne, &loop);
}
END();
RUN();
if (Test::generate_test_trace()) {
// Print the results.
for (size_t i = 0; i < ARRAY_SIZE(kTests); i++) {
printf("static const Inputs kOutputs_%s_%s[] = {\n", mnemonic,
kTests[i].identifier);
for (size_t j = 0; j < results[i]->output_size; j++) {
printf(" { ");
printf("0x%08" PRIx32, results[i]->outputs[j].apsr);
printf(", ");
printf("0x%08" PRIx32, results[i]->outputs[j].rd);
printf(", ");
printf("0x%08" PRIx32, results[i]->outputs[j].rn);
printf(", ");
printf("0x%08" PRIx32, results[i]->outputs[j].rm);
printf(" },\n");
}
printf("};\n");
}
printf("static const TestResult kReference%s[] = {\n", mnemonic);
for (size_t i = 0; i < ARRAY_SIZE(kTests); i++) {
printf(" {\n");
printf(" ARRAY_SIZE(kOutputs_%s_%s),\n", mnemonic,
kTests[i].identifier);
printf(" kOutputs_%s_%s,\n", mnemonic, kTests[i].identifier);
printf(" },\n");
}
printf("};\n");
} else {
// Check the results.
unsigned total_error_count = 0;
for (size_t i = 0; i < ARRAY_SIZE(kTests); i++) {
bool instruction_has_errors = false;
for (size_t j = 0; j < kTests[i].input_size; j++) {
uint32_t apsr = results[i]->outputs[j].apsr;
uint32_t rd = results[i]->outputs[j].rd;
uint32_t rn = results[i]->outputs[j].rn;
uint32_t rm = results[i]->outputs[j].rm;
uint32_t apsr_input = kTests[i].inputs[j].apsr;
uint32_t rd_input = kTests[i].inputs[j].rd;
uint32_t rn_input = kTests[i].inputs[j].rn;
uint32_t rm_input = kTests[i].inputs[j].rm;
uint32_t apsr_ref = reference[i].outputs[j].apsr;
uint32_t rd_ref = reference[i].outputs[j].rd;
uint32_t rn_ref = reference[i].outputs[j].rn;
uint32_t rm_ref = reference[i].outputs[j].rm;
if (((apsr != apsr_ref) || (rd != rd_ref) || (rn != rn_ref) ||
(rm != rm_ref)) &&
(++total_error_count <= kErrorReportLimit)) {
// Print the instruction once even if it triggered multiple failures.
if (!instruction_has_errors) {
printf("Error(s) when testing \"%s %s\":\n", mnemonic,
kTests[i].operands_description);
instruction_has_errors = true;
}
// Print subsequent errors.
printf(" Input: ");
printf("0x%08" PRIx32, apsr_input);
printf(", ");
printf("0x%08" PRIx32, rd_input);
printf(", ");
printf("0x%08" PRIx32, rn_input);
printf(", ");
printf("0x%08" PRIx32, rm_input);
printf("\n");
printf(" Expected: ");
printf("0x%08" PRIx32, apsr_ref);
printf(", ");
printf("0x%08" PRIx32, rd_ref);
printf(", ");
printf("0x%08" PRIx32, rn_ref);
printf(", ");
printf("0x%08" PRIx32, rm_ref);
printf("\n");
printf(" Found: ");
printf("0x%08" PRIx32, apsr);
printf(", ");
printf("0x%08" PRIx32, rd);
printf(", ");
printf("0x%08" PRIx32, rn);
printf(", ");
printf("0x%08" PRIx32, rm);
printf("\n\n");
}
}
}
if (total_error_count > kErrorReportLimit) {
printf("%u other errors follow.\n",
total_error_count - kErrorReportLimit);
}
// TODO: Do this check for the simulator too when it is ready.
#ifndef VIXL_INCLUDE_SIMULATOR
VIXL_CHECK(total_error_count == 0);
#endif
}
for (size_t i = 0; i < ARRAY_SIZE(kTests); i++) {
delete[] results[i]->outputs;
delete results[i];
delete scratch_memory_buffers[i];
}
TEARDOWN();
}
// Instantiate tests for each instruction in the list.
#define TEST(mnemonic) \
static void Test_##mnemonic() { \
TestHelper(&MacroAssembler::mnemonic, #mnemonic, kReference##mnemonic); \
} \
static Test test_##mnemonic( \
"AARCH32_SIMULATOR_COND_RD_RN_OPERAND_RM_ROR_AMOUNT_A32_" #mnemonic, \
&Test_##mnemonic);
FOREACH_INSTRUCTION(TEST)
#undef TEST
} // aarch32
} // vixl
| [
"scott.wakeling@linaro.org"
] | scott.wakeling@linaro.org |
155a42151fbe420b53e37dd8ab837c276b71e1c9 | a8fd0d2f3ea31f0cb0701530fc383f0df568fa3e | /StudentManagement_new_2/stout/tests/os/process_tests.cpp | 0db52618f02df9569d3bd814903028c4056880b0 | [
"Apache-2.0"
] | permissive | Held0n/StudentManagement | 4f74cf845905d4e267796a692f489e1b628bf81d | dae301e8254fff3b21e26f3e3f7934a11ba7d618 | refs/heads/master | 2020-04-01T19:59:04.334975 | 2018-10-31T02:15:48 | 2018-10-31T02:15:48 | 153,582,164 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 8,419 | cpp | // 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
#ifdef __WINDOWS__
#include <process.h>
#endif // __WINDOWS__
#include <set>
#include <gtest/gtest.h>
#include <stout/os.hpp>
#ifndef __WINDOWS__
#include <stout/os/fork.hpp>
#endif // __WINDOWS__
#include <stout/os/pstree.hpp>
#include <stout/tests/utils.hpp>
class ProcessTest : public TemporaryDirectoryTest {};
/home/heldon/CLionProjects/StudentManagement_new_2/stout/tests/os/process_tests.cpp
#ifndef __WINDOWS__
using os::Exec;
using os::Fork;
#endif // __WINDOWS__
using os::Process;
using os::ProcessTree;
using std::list;
using std::set;
using std::string;
const unsigned int init_pid =
#ifdef __WINDOWS__
0;
#else
1;
#endif // __WINDOWS__
#ifdef __WINDOWS__
int getppid()
{
const int pid = getpid();
HANDLE h = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
std::shared_ptr<void> sh(h, CloseHandle);
PROCESSENTRY32 pe = { 0 };
pe.dwSize = sizeof(PROCESSENTRY32);
if (Process32First(h, &pe)) {
do {
if (pe.th32ProcessID == pid) {
return pe.th32ParentProcessID;
}
} while (Process32Next(h, &pe));
}
return -1;
}
#endif // __WINDOWS__
TEST_F(ProcessTest, Process)
{
const Result<Process> process = os::process(getpid());
ASSERT_SOME(process);
EXPECT_EQ(getpid(), process.get().pid);
EXPECT_EQ(getppid(), process.get().parent);
ASSERT_SOME(process.get().session);
#ifndef __WINDOWS__
// NOTE: `getsid` does not have a meaningful interpretation on Windows.
EXPECT_EQ(getsid(getpid()), process.get().session.get());
#endif // __WINDOWS__
ASSERT_SOME(process.get().rss);
EXPECT_GT(process.get().rss.get(), 0);
// NOTE: On Linux /proc is a bit slow to update the CPU times,
// hence we allow 0 in this test.
ASSERT_SOME(process.get().utime);
EXPECT_GE(process.get().utime.get(), Nanoseconds(0));
ASSERT_SOME(process.get().stime);
EXPECT_GE(process.get().stime.get(), Nanoseconds(0));
EXPECT_FALSE(process.get().command.empty());
// Assert invalid PID returns `None`.
Result<Process> invalid_process = os::process(-1);
EXPECT_NONE(invalid_process);
// Assert init.
Result<Process> init_process = os::process(init_pid);
#ifdef __WINDOWS__
// NOTE: On Windows, inspecting other processes usually requires privileges.
// So we expect it to error out instead of succeed, unlike the POSIX version.
EXPECT_ERROR(init_process);
#elif __FreeBSD__
// In a FreeBSD jail, we wont find an init process.
if (!isJailed()) {
EXPECT_SOME(init_process);
} else {
EXPECT_NONE(init_process);
}
#else
EXPECT_SOME(init_process);
#endif // __WINDOWS__
}
TEST_F(ProcessTest, Processes)
{
const Try<list<Process>> processes = os::processes();
ASSERT_SOME(processes);
ASSERT_GT(processes.get().size(), 2u);
// Look for ourselves in the table.
bool found = false;
foreach (const Process& process, processes.get()) {
if (process.pid == getpid()) {
found = true;
EXPECT_EQ(getpid(), process.pid);
EXPECT_EQ(getppid(), process.parent);
ASSERT_SOME(process.session);
#ifndef __WINDOWS__
// NOTE: `getsid` does not have a meaningful interpretation on Windows.
EXPECT_EQ(getsid(getpid()), process.session.get());
#endif // __WINDOWS__
ASSERT_SOME(process.rss);
EXPECT_GT(process.rss.get(), 0);
// NOTE: On linux /proc is a bit slow to update the cpu times,
// hence we allow 0 in this test.
ASSERT_SOME(process.utime);
EXPECT_GE(process.utime.get(), Nanoseconds(0));
ASSERT_SOME(process.stime);
EXPECT_GE(process.stime.get(), Nanoseconds(0));
EXPECT_FALSE(process.command.empty());
break;
}
}
EXPECT_TRUE(found);
}
TEST_F(ProcessTest, Pids)
{
Try<set<pid_t>> pids = os::pids();
ASSERT_SOME(pids);
EXPECT_NE(0u, pids.get().size());
EXPECT_EQ(1u, pids.get().count(getpid()));
// In a FreeBSD jail, pid 1 may not exist.
#ifdef __FreeBSD__
if (!isJailed()) {
#endif
EXPECT_EQ(1u, pids.get().count(init_pid));
#ifdef __FreeBSD__
}
#endif
#ifndef __WINDOWS__
// NOTE: `getpgid` does not have a meaningful interpretation on Windows.
pids = os::pids(getpgid(0), None());
EXPECT_SOME(pids);
EXPECT_GE(pids.get().size(), 1u);
EXPECT_EQ(1u, pids.get().count(getpid()));
// NOTE: This test is not meaningful on Windows because process IDs are
// expected to be non-negative.
EXPECT_ERROR(os::pids(-1, None()));
// NOTE: `getsid` does not have a meaningful interpretation on Windows.
pids = os::pids(None(), getsid(0));
EXPECT_SOME(pids);
EXPECT_GE(pids.get().size(), 1u);
EXPECT_EQ(1u, pids.get().count(getpid()));
// NOTE: This test is not meaningful on Windows because process IDs are
// expected to be non-negative.
EXPECT_ERROR(os::pids(None(), -1));
#endif // __WINDOWS__
}
#ifdef __WINDOWS__
TEST_F(ProcessTest, Pstree)
{
Try<ProcessTree> tree = os::pstree(getpid());
ASSERT_SOME(tree);
// Windows spawns `conhost.exe` if we're running from VS, so the count of
// children could be 0 or 1.
const size_t total_children = tree.get().children.size();
EXPECT_TRUE(0u == total_children ||
1u == total_children) << stringify(tree.get());
const bool conhost_spawned = total_children == 1;
// Windows has no `sleep` command, so we fake it with `ping`.
const string command = "ping 127.0.0.1 -n 2";
STARTUPINFO si;
PROCESS_INFORMATION pi;
ZeroMemory(&si, sizeof(si));
si.cb = sizeof(si);
ZeroMemory(&pi, sizeof(pi));
// Create new process that "sleeps".
BOOL created = CreateProcess(
nullptr, // No module name (use command line).
(LPSTR)command.c_str(),
nullptr, // Process handle not inheritable.
nullptr, // Thread handle not inheritable.
FALSE, // Set handle inheritance to FALSE.
0, // No creation flags.
nullptr, // Use parent's environment block.
nullptr, // Use parent's starting directory.
&si,
&pi);
ASSERT_TRUE(created == TRUE);
Try<ProcessTree> tree_after_spawn = os::pstree(getpid());
ASSERT_SOME(tree_after_spawn);
// Windows spawns conhost.exe if we're running from VS, so the count of
// children could be 0 or 1.
const size_t children_after_span = tree_after_spawn.get().children.size();
EXPECT_TRUE((!conhost_spawned && 1u == children_after_span) ||
(conhost_spawned && 2u == children_after_span)
) << stringify(tree_after_spawn.get());
WaitForSingleObject(pi.hProcess, INFINITE);
}
#else
TEST_F(ProcessTest, Pstree)
{
Try<ProcessTree> tree = os::pstree(getpid());
ASSERT_SOME(tree);
EXPECT_EQ(0u, tree.get().children.size()) << stringify(tree.get());
tree =
Fork(None(), // Child.
Fork(Exec(SLEEP_COMMAND(10))), // Grandchild.
Exec(SLEEP_COMMAND(10)))();
ASSERT_SOME(tree);
// Depending on whether or not the shell has fork/exec'ed,
// we could have 1 or 2 direct children. That is, some shells
// might simply exec the command above (i.e., 'sleep 10') while
// others might fork/exec the command, keeping around a 'sh -c'
// process as well.
ASSERT_LE(1u, tree.get().children.size());
ASSERT_GE(2u, tree.get().children.size());
pid_t child = tree.get().process.pid;
pid_t grandchild = tree.get().children.front().process.pid;
// Now check pstree again.
tree = os::pstree(child);
ASSERT_SOME(tree);
EXPECT_EQ(child, tree.get().process.pid);
ASSERT_LE(1u, tree.get().children.size());
ASSERT_GE(2u, tree.get().children.size());
// Cleanup by killing the descendant processes.
EXPECT_EQ(0, kill(grandchild, SIGKILL));
EXPECT_EQ(0, kill(child, SIGKILL));
// We have to reap the child for running the tests in repetition.
ASSERT_EQ(child, waitpid(child, nullptr, 0));
}
#endif // __WINDOWS__
| [
"764165887@qq.com"
] | 764165887@qq.com |
ed9faaef668b3021c2a07b135ac8b63649678646 | 3f271ccffa54ff199927fb8f8e3e466ae965cbbb | /Task2/Task2A_PThreads.cpp | a2e2bb47627e291926c8c413abd160fb9b7fc791 | [] | no_license | johhov/MultithreadedAssignments | 9544e6f7c9d087fdb1360cd8de6f56b0a28505e9 | 2c0f938fc4c7077c410227bfc624b509a86f5115 | refs/heads/master | 2020-05-29T18:01:08.650968 | 2014-12-05T21:48:53 | 2014-12-05T21:48:53 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,453 | cpp | //Task 2A Multithreaded Programming 2014
//Johannes Hovland - 101028
#include <ctime>
#include <chrono>
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
const int ITERATIONS = 10000000;
const int THREADS = 4;
int partialResults[THREADS];
void *monteCarloPICalculation(void *thrNum){
double x, y;
int threadNumber = (intptr_t)thrNum;
for (int i = 0; i < ITERATIONS/THREADS; i++) {
x = (double)rand() / (double)RAND_MAX; // Random number between 0 and 1
y = (double)rand() / (double)RAND_MAX;
if (((x*x) + (y*y)) <= 1.0) {
partialResults[threadNumber]++;
}
}
pthread_exit(NULL);
}
int main (int argc, char* argv[]) {
pthread_t threadPool[THREADS];
auto startTime = std::chrono::high_resolution_clock::now();
for (int i = 0; i < THREADS; i++) {
pthread_create(&threadPool[i], NULL, &monteCarloPICalculation, (void*)(intptr_t)i);
}
for (int i = 0; i < THREADS; i++) {
pthread_join(threadPool[i], NULL);
}
int in = 0;
for (int i = 0; i < THREADS; i++) {
in += partialResults[i];
}
double pi = (4.0*in)/ITERATIONS;
auto endTime = std::chrono::high_resolution_clock::now();
auto duration = endTime-startTime;
auto msDuration = std::chrono::duration_cast<std::chrono::milliseconds>(duration).count();
printf("Monte Carlo aproximation of PI given %d calculations is: %f.\n", ITERATIONS, pi);
printf("The calculations took %lu milliseconds using %d pThreads.\n", msDuration, THREADS);
return 0;
} | [
"johannes.hovland@gmail.com"
] | johannes.hovland@gmail.com |
03c0a18e44906670e304706866c929bf901a59a1 | d73c7cf85e0e22f9169b8c1fb038ec4c84108412 | /src/cpu/instructions/arithmetic/subad8.hpp | eacdadc1fac24272b9de816f10904ed6ea32d1a8 | [] | no_license | Briensturm/gbcpp | a1b2b43bde9b0ad85fb23c3f7205f7d4b3597879 | df995d059f9f39f24d559ff702d55813f6159234 | refs/heads/main | 2023-02-15T14:59:56.611649 | 2021-01-05T14:18:46 | 2021-01-05T17:07:42 | 321,745,323 | 1 | 0 | null | 2021-01-05T09:47:07 | 2020-12-15T17:49:38 | C++ | UTF-8 | C++ | false | false | 1,058 | hpp | #pragma once
#include "instruction.hpp"
class SUBAD8 : public Instruction
{
public:
int GetInstructionLength() { return 2; }
void ExecuteCycle(CpuStatePtr& cpuState, RamPtr& mainMemory)
{
switch (_remainingCycles)
{
case 2:
_subData = mainMemory->ReadByte(cpuState->ProgramCounter++);
break;
case 1:
{
auto oldValue = cpuState->Registers->A;
cpuState->Registers->A -= _subData;
cpuState->Registers->SubtractionFlag = true;
cpuState->Registers->ZeroFlag = cpuState->Registers->A == 0;
cpuState->Registers->HalfCarryFlag = ((oldValue & 0xF) - (_subData & 0xF)) < 0;
cpuState->Registers->CarryFlag = _subData > oldValue;
break;
}
}
Instruction::ExecuteCycle(cpuState, mainMemory);
}
private:
byte _subData;
};
| [
"64007916+Briensturm@users.noreply.github.com"
] | 64007916+Briensturm@users.noreply.github.com |
37036cf87adb0dd1ebabfcaf4450dfc21b036150 | 7e206171aff10918b71adf2ed7c85d68558d6b39 | /examples/ME/W_4j/P0_Sigma_sm_uxcx_mumvmxuuxcxdx_W_4j.h | c38fcae346d840c95a06071a20f4e2f5e9b8c7fc | [] | no_license | matt-komm/momenta | 934d62f407abcce25e7c813c0ae9002d308f09cf | c52c63fad5ab38dc54e71636f3182d5fbcd308bc | refs/heads/master | 2021-01-01T05:31:11.499532 | 2014-04-01T20:01:29 | 2014-04-01T20:01:29 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,941 | h | //==========================================================================
// This file has been automatically generated for C++ Standalone by
// MadGraph 5 v. 2.0.0.beta3, 2013-02-14
// By the MadGraph Development Team
// Please visit us at https://launchpad.net/madgraph5
//==========================================================================
#ifndef MG5_Sigma_sm_uxcx_mumvmxuuxcxdx_H
#define MG5_Sigma_sm_uxcx_mumvmxuuxcxdx_H
#include <complex>
#include <vector>
#include "Parameters_sm.h"
using namespace std;
//==========================================================================
// A class for calculating the matrix elements for
// Process: u~ c~ > w- u u~ c~ d~ WEIGHTED=6
// * Decay: w- > mu- vm~ WEIGHTED=2
// Process: u~ s~ > w- u u~ s~ d~ WEIGHTED=6
// * Decay: w- > mu- vm~ WEIGHTED=2
// Process: c~ d~ > w- c c~ d~ s~ WEIGHTED=6
// * Decay: w- > mu- vm~ WEIGHTED=2
//--------------------------------------------------------------------------
class P0_Sigma_sm_uxcx_mumvmxuuxcxdx_W_4j
{
public:
// Constructor.
P0_Sigma_sm_uxcx_mumvmxuuxcxdx_W_4j() {}
// Initialize process.
virtual void initProc(string param_card_name);
// Calculate flavour-independent parts of cross section.
virtual void sigmaKin();
// Evaluate sigmaHat(sHat).
virtual double sigmaHat();
// Info on the subprocess.
virtual string name() const {return "u~ c~ > mu- vm~ u u~ c~ d~ (sm)";}
virtual int code() const {return 0;}
const vector<double> & getMasses() const {return mME;}
// Get and set momenta for matrix element evaluation
vector < double * > getMomenta(){return p;}
void setMomenta(vector < double * > & momenta){p = momenta;}
void setInitial(int inid1, int inid2){id1 = inid1; id2 = inid2;}
// Get matrix element vector
const double * getMatrixElements() const {return matrix_element;}
// Constants for array limits
static const int ninitial = 2;
static const int nexternal = 8;
static const int nprocesses = 2;
private:
// Private functions to calculate the matrix element for all subprocesses
// Calculate wavefunctions
void calculate_wavefunctions(const int perm[], const int hel[]);
static const int nwavefuncs = 37;
std::complex<double> w[nwavefuncs][18];
static const int namplitudes = 32;
std::complex<double> amp[namplitudes];
double matrix_uxcx_wmuuxcxdx_wm_mumvmx();
// Store the matrix element value from sigmaKin
double matrix_element[nprocesses];
// Color flows, used when selecting color
double * jamp2[nprocesses];
// Pointer to the model parameters
Parameters_sm * pars;
// vector with external particle masses
vector<double> mME;
// vector with momenta (to be changed each event)
vector < double * > p;
// Initial particle ids
int id1, id2;
};
#endif // MG5_Sigma_sm_uxcx_mumvmxuuxcxdx_H
| [
"Matthias.Komm@cern.ch"
] | Matthias.Komm@cern.ch |
9dedbdd1f0682e609e4e6c8421dd7960bb0792ff | 5456502f97627278cbd6e16d002d50f1de3da7bb | /ios/chrome/browser/browser_state/browser_state_info_cache_observer.h | 81ea6ec067a1644a74a9d36d6f87f05cc8d693ed | [
"BSD-3-Clause"
] | permissive | TrellixVulnTeam/Chromium_7C66 | 72d108a413909eb3bd36c73a6c2f98de1573b6e5 | c8649ab2a0f5a747369ed50351209a42f59672ee | refs/heads/master | 2023-03-16T12:51:40.231959 | 2017-12-20T10:38:26 | 2017-12-20T10:38:26 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,023 | h | // Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef IOS_CHROME_BROWSER_BROWSER_STATE_BROWSER_STATE_INFO_CACHE_OBSERVER_H_
#define IOS_CHROME_BROWSER_BROWSER_STATE_BROWSER_STATE_INFO_CACHE_OBSERVER_H_
#include "base/macros.h"
#include "base/strings/string16.h"
namespace base {
class FilePath;
}
// Observes changes in BrowserStateInfoCache.
class BrowserStateInfoCacheObserver {
public:
BrowserStateInfoCacheObserver() {}
virtual ~BrowserStateInfoCacheObserver() {}
// Called when a BrowserState has been added.
virtual void OnBrowserStateAdded(const base::FilePath& path) = 0;
// Called when a BrowserState has been removed.
virtual void OnBrowserStateWasRemoved(const base::FilePath& path) = 0;
private:
DISALLOW_COPY_AND_ASSIGN(BrowserStateInfoCacheObserver);
};
#endif // IOS_CHROME_BROWSER_BROWSER_STATE_BROWSER_STATE_INFO_CACHE_OBSERVER_H_
| [
"lixiaodonglove7@aliyun.com"
] | lixiaodonglove7@aliyun.com |
21ae0dbdb7bde310621cc71ae2191ff850bcfdcf | 04b1803adb6653ecb7cb827c4f4aa616afacf629 | /third_party/blink/renderer/core/animation/keyframe_effect_model_test.cc | 832f4f375367035dd7e638430b7f6fa2bc37b4d5 | [
"BSD-3-Clause",
"LGPL-2.0-only",
"BSD-2-Clause",
"LGPL-2.1-only",
"LGPL-2.0-or-later",
"GPL-1.0-or-later",
"MIT",
"Apache-2.0",
"LicenseRef-scancode-warranty-disclaimer",
"GPL-2.0-only",
"LicenseRef-scancode-other-copyleft"
] | permissive | Samsung/Castanets | 240d9338e097b75b3f669604315b06f7cf129d64 | 4896f732fc747dfdcfcbac3d442f2d2d42df264a | refs/heads/castanets_76_dev | 2023-08-31T09:01:04.744346 | 2021-07-30T04:56:25 | 2021-08-11T05:45:21 | 125,484,161 | 58 | 49 | BSD-3-Clause | 2022-10-16T19:31:26 | 2018-03-16T08:07:37 | null | UTF-8 | C++ | false | false | 35,390 | cc | /*
* Copyright (C) 2013 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "third_party/blink/renderer/core/animation/keyframe_effect_model.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/renderer/core/animation/animation_test_helper.h"
#include "third_party/blink/renderer/core/animation/css_default_interpolation_type.h"
#include "third_party/blink/renderer/core/animation/invalidatable_interpolation.h"
#include "third_party/blink/renderer/core/animation/string_keyframe.h"
#include "third_party/blink/renderer/core/css/css_primitive_value.h"
#include "third_party/blink/renderer/core/css/property_descriptor.h"
#include "third_party/blink/renderer/core/css/property_registration.h"
#include "third_party/blink/renderer/core/css/property_registry.h"
#include "third_party/blink/renderer/core/css/resolver/style_resolver.h"
#include "third_party/blink/renderer/core/dom/element.h"
#include "third_party/blink/renderer/core/style/computed_style.h"
#include "third_party/blink/renderer/core/testing/page_test_base.h"
#include "third_party/blink/renderer/platform/heap/heap.h"
#include "third_party/blink/renderer/platform/testing/runtime_enabled_features_test_helpers.h"
namespace blink {
class AnimationKeyframeEffectModel : public PageTestBase {
protected:
void SetUp() override {
PageTestBase::SetUp(IntSize());
element = GetDocument().CreateElementForBinding("foo");
}
void ExpectLengthValue(double expected_value,
Interpolation* interpolation_value) {
ActiveInterpolations interpolations;
interpolations.push_back(interpolation_value);
EnsureInterpolatedValueCached(interpolations, GetDocument(), element);
const TypedInterpolationValue* typed_value =
ToInvalidatableInterpolation(interpolation_value)
->GetCachedValueForTesting();
// Length values are stored as a list of values; here we assume pixels.
EXPECT_TRUE(typed_value->GetInterpolableValue().IsList());
const InterpolableList* list =
ToInterpolableList(&typed_value->GetInterpolableValue());
EXPECT_FLOAT_EQ(expected_value,
ToInterpolableNumber(list->Get(0))->Value());
}
void ExpectNonInterpolableValue(const String& expected_value,
Interpolation* interpolation_value) {
ActiveInterpolations interpolations;
interpolations.push_back(interpolation_value);
EnsureInterpolatedValueCached(interpolations, GetDocument(), element);
const TypedInterpolationValue* typed_value =
ToInvalidatableInterpolation(interpolation_value)
->GetCachedValueForTesting();
const NonInterpolableValue* non_interpolable_value =
typed_value->GetNonInterpolableValue();
ASSERT_TRUE(IsCSSDefaultNonInterpolableValue(non_interpolable_value));
const CSSValue* css_value =
ToCSSDefaultNonInterpolableValue(non_interpolable_value)->CssValue();
EXPECT_EQ(expected_value, css_value->CssText());
}
Persistent<Element> element;
};
const AnimationTimeDelta kDuration = AnimationTimeDelta::FromSecondsD(1);
StringKeyframeVector KeyframesAtZeroAndOne(CSSPropertyID property,
const String& zero_value,
const String& one_value) {
StringKeyframeVector keyframes(2);
keyframes[0] = MakeGarbageCollected<StringKeyframe>();
keyframes[0]->SetOffset(0.0);
keyframes[0]->SetCSSPropertyValue(
property, zero_value, SecureContextMode::kInsecureContext, nullptr);
keyframes[1] = MakeGarbageCollected<StringKeyframe>();
keyframes[1]->SetOffset(1.0);
keyframes[1]->SetCSSPropertyValue(
property, one_value, SecureContextMode::kInsecureContext, nullptr);
return keyframes;
}
StringKeyframeVector KeyframesAtZeroAndOne(
AtomicString property_name,
const PropertyRegistry* property_registry,
const String& zero_value,
const String& one_value) {
StringKeyframeVector keyframes(2);
keyframes[0] = MakeGarbageCollected<StringKeyframe>();
keyframes[0]->SetOffset(0.0);
keyframes[0]->SetCSSPropertyValue(
property_name, property_registry, zero_value,
SecureContextMode::kInsecureContext, nullptr);
keyframes[1] = MakeGarbageCollected<StringKeyframe>();
keyframes[1]->SetOffset(1.0);
keyframes[1]->SetCSSPropertyValue(property_name, property_registry, one_value,
SecureContextMode::kInsecureContext,
nullptr);
return keyframes;
}
void ExpectProperty(CSSPropertyID property,
Interpolation* interpolation_value) {
InvalidatableInterpolation* interpolation =
ToInvalidatableInterpolation(interpolation_value);
const PropertyHandle& property_handle = interpolation->GetProperty();
ASSERT_TRUE(property_handle.IsCSSProperty());
ASSERT_EQ(property, property_handle.GetCSSProperty().PropertyID());
}
Interpolation* FindValue(HeapVector<Member<Interpolation>>& values,
CSSPropertyID id) {
for (auto& value : values) {
const PropertyHandle& property =
ToInvalidatableInterpolation(value)->GetProperty();
if (property.IsCSSProperty() &&
property.GetCSSProperty().PropertyID() == id)
return value;
}
return nullptr;
}
TEST_F(AnimationKeyframeEffectModel, BasicOperation) {
StringKeyframeVector keyframes =
KeyframesAtZeroAndOne(CSSPropertyID::kFontFamily, "serif", "cursive");
auto* effect = MakeGarbageCollected<StringKeyframeEffectModel>(keyframes);
HeapVector<Member<Interpolation>> values;
effect->Sample(0, 0.6, kDuration, values);
ASSERT_EQ(1UL, values.size());
ExpectProperty(CSSPropertyID::kFontFamily, values.at(0));
ExpectNonInterpolableValue("cursive", values.at(0));
}
TEST_F(AnimationKeyframeEffectModel, CompositeReplaceNonInterpolable) {
StringKeyframeVector keyframes =
KeyframesAtZeroAndOne(CSSPropertyID::kFontFamily, "serif", "cursive");
keyframes[0]->SetComposite(EffectModel::kCompositeReplace);
keyframes[1]->SetComposite(EffectModel::kCompositeReplace);
auto* effect = MakeGarbageCollected<StringKeyframeEffectModel>(keyframes);
HeapVector<Member<Interpolation>> values;
effect->Sample(0, 0.6, kDuration, values);
ExpectNonInterpolableValue("cursive", values.at(0));
}
TEST_F(AnimationKeyframeEffectModel, CompositeReplace) {
StringKeyframeVector keyframes =
KeyframesAtZeroAndOne(CSSPropertyID::kLeft, "3px", "5px");
keyframes[0]->SetComposite(EffectModel::kCompositeReplace);
keyframes[1]->SetComposite(EffectModel::kCompositeReplace);
auto* effect = MakeGarbageCollected<StringKeyframeEffectModel>(keyframes);
HeapVector<Member<Interpolation>> values;
effect->Sample(0, 0.6, kDuration, values);
ExpectLengthValue(3.0 * 0.4 + 5.0 * 0.6, values.at(0));
}
// FIXME: Re-enable this test once compositing of CompositeAdd is supported.
TEST_F(AnimationKeyframeEffectModel, DISABLED_CompositeAdd) {
StringKeyframeVector keyframes =
KeyframesAtZeroAndOne(CSSPropertyID::kLeft, "3px", "5px");
keyframes[0]->SetComposite(EffectModel::kCompositeAdd);
keyframes[1]->SetComposite(EffectModel::kCompositeAdd);
auto* effect = MakeGarbageCollected<StringKeyframeEffectModel>(keyframes);
HeapVector<Member<Interpolation>> values;
effect->Sample(0, 0.6, kDuration, values);
ExpectLengthValue((7.0 + 3.0) * 0.4 + (7.0 + 5.0) * 0.6, values.at(0));
}
TEST_F(AnimationKeyframeEffectModel, CompositeEaseIn) {
StringKeyframeVector keyframes =
KeyframesAtZeroAndOne(CSSPropertyID::kLeft, "3px", "5px");
keyframes[0]->SetComposite(EffectModel::kCompositeReplace);
keyframes[0]->SetEasing(CubicBezierTimingFunction::Preset(
CubicBezierTimingFunction::EaseType::EASE_IN));
keyframes[1]->SetComposite(EffectModel::kCompositeReplace);
auto* effect = MakeGarbageCollected<StringKeyframeEffectModel>(keyframes);
HeapVector<Member<Interpolation>> values;
effect->Sample(0, 0.6, kDuration, values);
ExpectLengthValue(3.8579516, values.at(0));
effect->Sample(0, 0.6, kDuration * 100, values);
ExpectLengthValue(3.8582394, values.at(0));
}
TEST_F(AnimationKeyframeEffectModel, CompositeCubicBezier) {
StringKeyframeVector keyframes =
KeyframesAtZeroAndOne(CSSPropertyID::kLeft, "3px", "5px");
keyframes[0]->SetComposite(EffectModel::kCompositeReplace);
keyframes[0]->SetEasing(CubicBezierTimingFunction::Create(0.42, 0, 0.58, 1));
keyframes[1]->SetComposite(EffectModel::kCompositeReplace);
auto* effect = MakeGarbageCollected<StringKeyframeEffectModel>(keyframes);
HeapVector<Member<Interpolation>> values;
effect->Sample(0, 0.6, kDuration, values);
ExpectLengthValue(4.3363357, values.at(0));
effect->Sample(0, 0.6, kDuration * 1000, values);
ExpectLengthValue(4.3362322, values.at(0));
}
TEST_F(AnimationKeyframeEffectModel, ExtrapolateReplaceNonInterpolable) {
StringKeyframeVector keyframes =
KeyframesAtZeroAndOne(CSSPropertyID::kFontFamily, "serif", "cursive");
keyframes[0]->SetComposite(EffectModel::kCompositeReplace);
keyframes[1]->SetComposite(EffectModel::kCompositeReplace);
auto* effect = MakeGarbageCollected<StringKeyframeEffectModel>(keyframes);
HeapVector<Member<Interpolation>> values;
effect->Sample(0, 1.6, kDuration, values);
ExpectNonInterpolableValue("cursive", values.at(0));
}
TEST_F(AnimationKeyframeEffectModel, ExtrapolateReplace) {
StringKeyframeVector keyframes =
KeyframesAtZeroAndOne(CSSPropertyID::kLeft, "3px", "5px");
auto* effect = MakeGarbageCollected<StringKeyframeEffectModel>(keyframes);
keyframes[0]->SetComposite(EffectModel::kCompositeReplace);
keyframes[1]->SetComposite(EffectModel::kCompositeReplace);
HeapVector<Member<Interpolation>> values;
effect->Sample(0, 1.6, kDuration, values);
ExpectLengthValue(3.0 * -0.6 + 5.0 * 1.6, values.at(0));
}
// FIXME: Re-enable this test once compositing of CompositeAdd is supported.
TEST_F(AnimationKeyframeEffectModel, DISABLED_ExtrapolateAdd) {
StringKeyframeVector keyframes =
KeyframesAtZeroAndOne(CSSPropertyID::kLeft, "3px", "5px");
keyframes[0]->SetComposite(EffectModel::kCompositeAdd);
keyframes[1]->SetComposite(EffectModel::kCompositeAdd);
auto* effect = MakeGarbageCollected<StringKeyframeEffectModel>(keyframes);
HeapVector<Member<Interpolation>> values;
effect->Sample(0, 1.6, kDuration, values);
ExpectLengthValue((7.0 + 3.0) * -0.6 + (7.0 + 5.0) * 1.6, values.at(0));
}
TEST_F(AnimationKeyframeEffectModel, ZeroKeyframes) {
auto* effect =
MakeGarbageCollected<StringKeyframeEffectModel>(StringKeyframeVector());
HeapVector<Member<Interpolation>> values;
effect->Sample(0, 0.5, kDuration, values);
EXPECT_TRUE(values.IsEmpty());
}
// FIXME: Re-enable this test once compositing of CompositeAdd is supported.
TEST_F(AnimationKeyframeEffectModel, DISABLED_SingleKeyframeAtOffsetZero) {
StringKeyframeVector keyframes(1);
keyframes[0] = MakeGarbageCollected<StringKeyframe>();
keyframes[0]->SetOffset(0.0);
keyframes[0]->SetCSSPropertyValue(CSSPropertyID::kFontFamily, "serif",
SecureContextMode::kInsecureContext,
nullptr);
auto* effect = MakeGarbageCollected<StringKeyframeEffectModel>(keyframes);
HeapVector<Member<Interpolation>> values;
effect->Sample(0, 0.6, kDuration, values);
ExpectNonInterpolableValue("serif", values.at(0));
}
// FIXME: Re-enable this test once compositing of CompositeAdd is supported.
TEST_F(AnimationKeyframeEffectModel, DISABLED_SingleKeyframeAtOffsetOne) {
StringKeyframeVector keyframes(1);
keyframes[0] = MakeGarbageCollected<StringKeyframe>();
keyframes[0]->SetOffset(1.0);
keyframes[0]->SetCSSPropertyValue(CSSPropertyID::kLeft, "5px",
SecureContextMode::kInsecureContext,
nullptr);
auto* effect = MakeGarbageCollected<StringKeyframeEffectModel>(keyframes);
HeapVector<Member<Interpolation>> values;
effect->Sample(0, 0.6, kDuration, values);
ExpectLengthValue(7.0 * 0.4 + 5.0 * 0.6, values.at(0));
}
TEST_F(AnimationKeyframeEffectModel, MoreThanTwoKeyframes) {
StringKeyframeVector keyframes(3);
keyframes[0] = MakeGarbageCollected<StringKeyframe>();
keyframes[0]->SetOffset(0.0);
keyframes[0]->SetCSSPropertyValue(CSSPropertyID::kFontFamily, "serif",
SecureContextMode::kInsecureContext,
nullptr);
keyframes[1] = MakeGarbageCollected<StringKeyframe>();
keyframes[1]->SetOffset(0.5);
keyframes[1]->SetCSSPropertyValue(CSSPropertyID::kFontFamily, "sans-serif",
SecureContextMode::kInsecureContext,
nullptr);
keyframes[2] = MakeGarbageCollected<StringKeyframe>();
keyframes[2]->SetOffset(1.0);
keyframes[2]->SetCSSPropertyValue(CSSPropertyID::kFontFamily, "cursive",
SecureContextMode::kInsecureContext,
nullptr);
auto* effect = MakeGarbageCollected<StringKeyframeEffectModel>(keyframes);
HeapVector<Member<Interpolation>> values;
effect->Sample(0, 0.3, kDuration, values);
ExpectNonInterpolableValue("sans-serif", values.at(0));
effect->Sample(0, 0.8, kDuration, values);
ExpectNonInterpolableValue("cursive", values.at(0));
}
TEST_F(AnimationKeyframeEffectModel, EndKeyframeOffsetsUnspecified) {
StringKeyframeVector keyframes(3);
keyframes[0] = MakeGarbageCollected<StringKeyframe>();
keyframes[0]->SetCSSPropertyValue(CSSPropertyID::kFontFamily, "serif",
SecureContextMode::kInsecureContext,
nullptr);
keyframes[1] = MakeGarbageCollected<StringKeyframe>();
keyframes[1]->SetOffset(0.5);
keyframes[1]->SetCSSPropertyValue(CSSPropertyID::kFontFamily, "cursive",
SecureContextMode::kInsecureContext,
nullptr);
keyframes[2] = MakeGarbageCollected<StringKeyframe>();
keyframes[2]->SetCSSPropertyValue(CSSPropertyID::kFontFamily, "serif",
SecureContextMode::kInsecureContext,
nullptr);
auto* effect = MakeGarbageCollected<StringKeyframeEffectModel>(keyframes);
HeapVector<Member<Interpolation>> values;
effect->Sample(0, 0.1, kDuration, values);
ExpectNonInterpolableValue("serif", values.at(0));
effect->Sample(0, 0.6, kDuration, values);
ExpectNonInterpolableValue("cursive", values.at(0));
effect->Sample(0, 0.9, kDuration, values);
ExpectNonInterpolableValue("serif", values.at(0));
}
TEST_F(AnimationKeyframeEffectModel, SampleOnKeyframe) {
StringKeyframeVector keyframes(3);
keyframes[0] = MakeGarbageCollected<StringKeyframe>();
keyframes[0]->SetOffset(0.0);
keyframes[0]->SetCSSPropertyValue(CSSPropertyID::kFontFamily, "serif",
SecureContextMode::kInsecureContext,
nullptr);
keyframes[1] = MakeGarbageCollected<StringKeyframe>();
keyframes[1]->SetOffset(0.5);
keyframes[1]->SetCSSPropertyValue(CSSPropertyID::kFontFamily, "cursive",
SecureContextMode::kInsecureContext,
nullptr);
keyframes[2] = MakeGarbageCollected<StringKeyframe>();
keyframes[2]->SetOffset(1.0);
keyframes[2]->SetCSSPropertyValue(CSSPropertyID::kFontFamily, "serif",
SecureContextMode::kInsecureContext,
nullptr);
auto* effect = MakeGarbageCollected<StringKeyframeEffectModel>(keyframes);
HeapVector<Member<Interpolation>> values;
effect->Sample(0, 0.0, kDuration, values);
ExpectNonInterpolableValue("serif", values.at(0));
effect->Sample(0, 0.5, kDuration, values);
ExpectNonInterpolableValue("cursive", values.at(0));
effect->Sample(0, 1.0, kDuration, values);
ExpectNonInterpolableValue("serif", values.at(0));
}
TEST_F(AnimationKeyframeEffectModel, MultipleKeyframesWithSameOffset) {
StringKeyframeVector keyframes(9);
keyframes[0] = MakeGarbageCollected<StringKeyframe>();
keyframes[0]->SetOffset(0.0);
keyframes[0]->SetCSSPropertyValue(CSSPropertyID::kFontFamily, "serif",
SecureContextMode::kInsecureContext,
nullptr);
keyframes[1] = MakeGarbageCollected<StringKeyframe>();
keyframes[1]->SetOffset(0.1);
keyframes[1]->SetCSSPropertyValue(CSSPropertyID::kFontFamily, "sans-serif",
SecureContextMode::kInsecureContext,
nullptr);
keyframes[2] = MakeGarbageCollected<StringKeyframe>();
keyframes[2]->SetOffset(0.1);
keyframes[2]->SetCSSPropertyValue(CSSPropertyID::kFontFamily, "monospace",
SecureContextMode::kInsecureContext,
nullptr);
keyframes[3] = MakeGarbageCollected<StringKeyframe>();
keyframes[3]->SetOffset(0.5);
keyframes[3]->SetCSSPropertyValue(CSSPropertyID::kFontFamily, "cursive",
SecureContextMode::kInsecureContext,
nullptr);
keyframes[4] = MakeGarbageCollected<StringKeyframe>();
keyframes[4]->SetOffset(0.5);
keyframes[4]->SetCSSPropertyValue(CSSPropertyID::kFontFamily, "fantasy",
SecureContextMode::kInsecureContext,
nullptr);
keyframes[5] = MakeGarbageCollected<StringKeyframe>();
keyframes[5]->SetOffset(0.5);
keyframes[5]->SetCSSPropertyValue(CSSPropertyID::kFontFamily, "system-ui",
SecureContextMode::kInsecureContext,
nullptr);
keyframes[6] = MakeGarbageCollected<StringKeyframe>();
keyframes[6]->SetOffset(0.9);
keyframes[6]->SetCSSPropertyValue(CSSPropertyID::kFontFamily, "serif",
SecureContextMode::kInsecureContext,
nullptr);
keyframes[7] = MakeGarbageCollected<StringKeyframe>();
keyframes[7]->SetOffset(0.9);
keyframes[7]->SetCSSPropertyValue(CSSPropertyID::kFontFamily, "sans-serif",
SecureContextMode::kInsecureContext,
nullptr);
keyframes[8] = MakeGarbageCollected<StringKeyframe>();
keyframes[8]->SetOffset(1.0);
keyframes[8]->SetCSSPropertyValue(CSSPropertyID::kFontFamily, "monospace",
SecureContextMode::kInsecureContext,
nullptr);
auto* effect = MakeGarbageCollected<StringKeyframeEffectModel>(keyframes);
HeapVector<Member<Interpolation>> values;
effect->Sample(0, 0.0, kDuration, values);
ExpectNonInterpolableValue("serif", values.at(0));
effect->Sample(0, 0.2, kDuration, values);
ExpectNonInterpolableValue("monospace", values.at(0));
effect->Sample(0, 0.4, kDuration, values);
ExpectNonInterpolableValue("cursive", values.at(0));
effect->Sample(0, 0.5, kDuration, values);
ExpectNonInterpolableValue("system-ui", values.at(0));
effect->Sample(0, 0.6, kDuration, values);
ExpectNonInterpolableValue("system-ui", values.at(0));
effect->Sample(0, 0.8, kDuration, values);
ExpectNonInterpolableValue("serif", values.at(0));
effect->Sample(0, 1.0, kDuration, values);
ExpectNonInterpolableValue("monospace", values.at(0));
}
// FIXME: Re-enable this test once compositing of CompositeAdd is supported.
TEST_F(AnimationKeyframeEffectModel, DISABLED_PerKeyframeComposite) {
StringKeyframeVector keyframes(2);
keyframes[0] = MakeGarbageCollected<StringKeyframe>();
keyframes[0]->SetOffset(0.0);
keyframes[0]->SetCSSPropertyValue(CSSPropertyID::kLeft, "3px",
SecureContextMode::kInsecureContext,
nullptr);
keyframes[1] = MakeGarbageCollected<StringKeyframe>();
keyframes[1]->SetOffset(1.0);
keyframes[1]->SetCSSPropertyValue(CSSPropertyID::kLeft, "5px",
SecureContextMode::kInsecureContext,
nullptr);
keyframes[1]->SetComposite(EffectModel::kCompositeAdd);
auto* effect = MakeGarbageCollected<StringKeyframeEffectModel>(keyframes);
HeapVector<Member<Interpolation>> values;
effect->Sample(0, 0.6, kDuration, values);
ExpectLengthValue(3.0 * 0.4 + (7.0 + 5.0) * 0.6, values.at(0));
}
TEST_F(AnimationKeyframeEffectModel, MultipleProperties) {
StringKeyframeVector keyframes(2);
keyframes[0] = MakeGarbageCollected<StringKeyframe>();
keyframes[0]->SetOffset(0.0);
keyframes[0]->SetCSSPropertyValue(CSSPropertyID::kFontFamily, "serif",
SecureContextMode::kInsecureContext,
nullptr);
keyframes[0]->SetCSSPropertyValue(CSSPropertyID::kFontStyle, "normal",
SecureContextMode::kInsecureContext,
nullptr);
keyframes[1] = MakeGarbageCollected<StringKeyframe>();
keyframes[1]->SetOffset(1.0);
keyframes[1]->SetCSSPropertyValue(CSSPropertyID::kFontFamily, "cursive",
SecureContextMode::kInsecureContext,
nullptr);
keyframes[1]->SetCSSPropertyValue(CSSPropertyID::kFontStyle, "oblique",
SecureContextMode::kInsecureContext,
nullptr);
auto* effect = MakeGarbageCollected<StringKeyframeEffectModel>(keyframes);
HeapVector<Member<Interpolation>> values;
effect->Sample(0, 0.6, kDuration, values);
EXPECT_EQ(2UL, values.size());
Interpolation* left_value = FindValue(values, CSSPropertyID::kFontFamily);
ASSERT_TRUE(left_value);
ExpectNonInterpolableValue("cursive", left_value);
Interpolation* right_value = FindValue(values, CSSPropertyID::kFontStyle);
ASSERT_TRUE(right_value);
ExpectNonInterpolableValue("oblique", right_value);
}
// FIXME: Re-enable this test once compositing of CompositeAdd is supported.
TEST_F(AnimationKeyframeEffectModel, DISABLED_RecompositeCompositableValue) {
StringKeyframeVector keyframes =
KeyframesAtZeroAndOne(CSSPropertyID::kLeft, "3px", "5px");
keyframes[0]->SetComposite(EffectModel::kCompositeAdd);
keyframes[1]->SetComposite(EffectModel::kCompositeAdd);
auto* effect = MakeGarbageCollected<StringKeyframeEffectModel>(keyframes);
HeapVector<Member<Interpolation>> values;
effect->Sample(0, 0.6, kDuration, values);
ExpectLengthValue((7.0 + 3.0) * 0.4 + (7.0 + 5.0) * 0.6, values.at(0));
ExpectLengthValue((9.0 + 3.0) * 0.4 + (9.0 + 5.0) * 0.6, values.at(1));
}
TEST_F(AnimationKeyframeEffectModel, MultipleIterations) {
StringKeyframeVector keyframes =
KeyframesAtZeroAndOne(CSSPropertyID::kLeft, "1px", "3px");
auto* effect = MakeGarbageCollected<StringKeyframeEffectModel>(keyframes);
HeapVector<Member<Interpolation>> values;
effect->Sample(0, 0.5, kDuration, values);
ExpectLengthValue(2.0, values.at(0));
effect->Sample(1, 0.5, kDuration, values);
ExpectLengthValue(2.0, values.at(0));
effect->Sample(2, 0.5, kDuration, values);
ExpectLengthValue(2.0, values.at(0));
}
// FIXME: Re-enable this test once compositing of CompositeAdd is supported.
TEST_F(AnimationKeyframeEffectModel, DISABLED_DependsOnUnderlyingValue) {
StringKeyframeVector keyframes(3);
keyframes[0] = MakeGarbageCollected<StringKeyframe>();
keyframes[0]->SetOffset(0.0);
keyframes[0]->SetCSSPropertyValue(CSSPropertyID::kLeft, "1px",
SecureContextMode::kInsecureContext,
nullptr);
keyframes[0]->SetComposite(EffectModel::kCompositeAdd);
keyframes[1] = MakeGarbageCollected<StringKeyframe>();
keyframes[1]->SetOffset(0.5);
keyframes[1]->SetCSSPropertyValue(CSSPropertyID::kLeft, "1px",
SecureContextMode::kInsecureContext,
nullptr);
keyframes[2] = MakeGarbageCollected<StringKeyframe>();
keyframes[2]->SetOffset(1.0);
keyframes[2]->SetCSSPropertyValue(CSSPropertyID::kLeft, "1px",
SecureContextMode::kInsecureContext,
nullptr);
auto* effect = MakeGarbageCollected<StringKeyframeEffectModel>(keyframes);
HeapVector<Member<Interpolation>> values;
effect->Sample(0, 0, kDuration, values);
EXPECT_TRUE(values.at(0));
effect->Sample(0, 0.1, kDuration, values);
EXPECT_TRUE(values.at(0));
effect->Sample(0, 0.25, kDuration, values);
EXPECT_TRUE(values.at(0));
effect->Sample(0, 0.4, kDuration, values);
EXPECT_TRUE(values.at(0));
effect->Sample(0, 0.5, kDuration, values);
EXPECT_FALSE(values.at(0));
effect->Sample(0, 0.6, kDuration, values);
EXPECT_FALSE(values.at(0));
effect->Sample(0, 0.75, kDuration, values);
EXPECT_FALSE(values.at(0));
effect->Sample(0, 0.8, kDuration, values);
EXPECT_FALSE(values.at(0));
effect->Sample(0, 1, kDuration, values);
EXPECT_FALSE(values.at(0));
}
TEST_F(AnimationKeyframeEffectModel, AddSyntheticKeyframes) {
StringKeyframeVector keyframes(1);
keyframes[0] = MakeGarbageCollected<StringKeyframe>();
keyframes[0]->SetOffset(0.5);
keyframes[0]->SetCSSPropertyValue(CSSPropertyID::kLeft, "4px",
SecureContextMode::kInsecureContext,
nullptr);
auto* effect = MakeGarbageCollected<StringKeyframeEffectModel>(keyframes);
const StringPropertySpecificKeyframeVector& property_specific_keyframes =
effect->GetPropertySpecificKeyframes(
PropertyHandle(GetCSSPropertyLeft()));
EXPECT_EQ(3U, property_specific_keyframes.size());
EXPECT_DOUBLE_EQ(0.0, property_specific_keyframes[0]->Offset());
EXPECT_DOUBLE_EQ(0.5, property_specific_keyframes[1]->Offset());
EXPECT_DOUBLE_EQ(1.0, property_specific_keyframes[2]->Offset());
}
TEST_F(AnimationKeyframeEffectModel, ToKeyframeEffectModel) {
StringKeyframeVector keyframes(0);
auto* effect = MakeGarbageCollected<StringKeyframeEffectModel>(keyframes);
EffectModel* base_effect = effect;
EXPECT_TRUE(ToStringKeyframeEffectModel(base_effect));
}
TEST_F(AnimationKeyframeEffectModel, CompositorSnapshotUpdateBasic) {
StringKeyframeVector keyframes =
KeyframesAtZeroAndOne(CSSPropertyID::kOpacity, "0", "1");
auto* effect = MakeGarbageCollected<StringKeyframeEffectModel>(keyframes);
auto style = GetDocument().EnsureStyleResolver().StyleForElement(element);
const CompositorKeyframeValue* value;
// Compositor keyframe value should be empty before snapshot
value = effect
->GetPropertySpecificKeyframes(
PropertyHandle(GetCSSPropertyOpacity()))[0]
->GetCompositorKeyframeValue();
EXPECT_FALSE(value);
// Snapshot should update first time after construction
EXPECT_TRUE(effect->SnapshotAllCompositorKeyframesIfNecessary(
*element, *style, nullptr));
// Snapshot should not update on second call
EXPECT_FALSE(effect->SnapshotAllCompositorKeyframesIfNecessary(
*element, *style, nullptr));
// Snapshot should update after an explicit invalidation
effect->InvalidateCompositorKeyframesSnapshot();
EXPECT_TRUE(effect->SnapshotAllCompositorKeyframesIfNecessary(
*element, *style, nullptr));
// Compositor keyframe value should be available after snapshot
value = effect
->GetPropertySpecificKeyframes(
PropertyHandle(GetCSSPropertyOpacity()))[0]
->GetCompositorKeyframeValue();
EXPECT_TRUE(value);
EXPECT_TRUE(value->IsDouble());
}
TEST_F(AnimationKeyframeEffectModel,
CompositorSnapshotUpdateAfterKeyframeChange) {
StringKeyframeVector opacity_keyframes =
KeyframesAtZeroAndOne(CSSPropertyID::kOpacity, "0", "1");
auto* effect =
MakeGarbageCollected<StringKeyframeEffectModel>(opacity_keyframes);
auto style = GetDocument().EnsureStyleResolver().StyleForElement(element);
EXPECT_TRUE(effect->SnapshotAllCompositorKeyframesIfNecessary(
*element, *style, nullptr));
const CompositorKeyframeValue* value;
value = effect
->GetPropertySpecificKeyframes(
PropertyHandle(GetCSSPropertyOpacity()))[0]
->GetCompositorKeyframeValue();
EXPECT_TRUE(value);
EXPECT_TRUE(value->IsDouble());
StringKeyframeVector filter_keyframes =
KeyframesAtZeroAndOne(CSSPropertyID::kFilter, "blur(1px)", "blur(10px)");
effect->SetFrames(filter_keyframes);
// Snapshot should update after changing keyframes
EXPECT_TRUE(effect->SnapshotAllCompositorKeyframesIfNecessary(
*element, *style, nullptr));
value = effect
->GetPropertySpecificKeyframes(
PropertyHandle(GetCSSPropertyFilter()))[0]
->GetCompositorKeyframeValue();
EXPECT_TRUE(value);
EXPECT_TRUE(value->IsFilterOperations());
}
TEST_F(AnimationKeyframeEffectModel, CompositorSnapshotUpdateCustomProperty) {
ScopedOffMainThreadCSSPaintForTest off_main_thread_css_paint(true);
DummyExceptionStateForTesting exception_state;
PropertyDescriptor* property_descriptor = PropertyDescriptor::Create();
property_descriptor->setName("--foo");
property_descriptor->setSyntax("<number>");
property_descriptor->setInitialValue("0");
property_descriptor->setInherits(false);
PropertyRegistration::registerProperty(&GetDocument(), property_descriptor,
exception_state);
EXPECT_FALSE(exception_state.HadException());
StringKeyframeVector keyframes = KeyframesAtZeroAndOne(
AtomicString("--foo"), GetDocument().GetPropertyRegistry(), "0", "100");
element->style()->setProperty(&GetDocument(), "--foo", "0", g_empty_string,
exception_state);
EXPECT_FALSE(exception_state.HadException());
auto* effect = MakeGarbageCollected<StringKeyframeEffectModel>(keyframes);
auto style = GetDocument().EnsureStyleResolver().StyleForElement(element);
const CompositorKeyframeValue* value;
// Snapshot should update first time after construction
EXPECT_TRUE(effect->SnapshotAllCompositorKeyframesIfNecessary(
*element, *style, nullptr));
// Compositor keyframe value available after snapshot
value = effect
->GetPropertySpecificKeyframes(
PropertyHandle(AtomicString("--foo")))[0]
->GetCompositorKeyframeValue();
EXPECT_TRUE(value);
EXPECT_TRUE(value->IsDouble());
}
} // namespace blink
namespace blink {
class KeyframeEffectModelTest : public testing::Test {
public:
static Vector<double> GetComputedOffsets(const KeyframeVector& keyframes) {
return KeyframeEffectModelBase::GetComputedOffsets(keyframes);
}
};
TEST_F(KeyframeEffectModelTest, EvenlyDistributed1) {
KeyframeVector keyframes(5);
keyframes[0] = MakeGarbageCollected<StringKeyframe>();
keyframes[0]->SetOffset(0.125);
keyframes[1] = MakeGarbageCollected<StringKeyframe>();
keyframes[2] = MakeGarbageCollected<StringKeyframe>();
keyframes[3] = MakeGarbageCollected<StringKeyframe>();
keyframes[4] = MakeGarbageCollected<StringKeyframe>();
keyframes[4]->SetOffset(0.625);
const Vector<double> result = GetComputedOffsets(keyframes);
EXPECT_EQ(5U, result.size());
EXPECT_DOUBLE_EQ(0.125, result[0]);
EXPECT_DOUBLE_EQ(0.25, result[1]);
EXPECT_DOUBLE_EQ(0.375, result[2]);
EXPECT_DOUBLE_EQ(0.5, result[3]);
EXPECT_DOUBLE_EQ(0.625, result[4]);
}
TEST_F(KeyframeEffectModelTest, EvenlyDistributed2) {
KeyframeVector keyframes(6);
keyframes[0] = MakeGarbageCollected<StringKeyframe>();
keyframes[1] = MakeGarbageCollected<StringKeyframe>();
keyframes[2] = MakeGarbageCollected<StringKeyframe>();
keyframes[3] = MakeGarbageCollected<StringKeyframe>();
keyframes[3]->SetOffset(0.75);
keyframes[4] = MakeGarbageCollected<StringKeyframe>();
keyframes[5] = MakeGarbageCollected<StringKeyframe>();
const Vector<double> result = GetComputedOffsets(keyframes);
EXPECT_EQ(6U, result.size());
EXPECT_DOUBLE_EQ(0.0, result[0]);
EXPECT_DOUBLE_EQ(0.25, result[1]);
EXPECT_DOUBLE_EQ(0.5, result[2]);
EXPECT_DOUBLE_EQ(0.75, result[3]);
EXPECT_DOUBLE_EQ(0.875, result[4]);
EXPECT_DOUBLE_EQ(1.0, result[5]);
}
TEST_F(KeyframeEffectModelTest, EvenlyDistributed3) {
KeyframeVector keyframes(12);
keyframes[0] = MakeGarbageCollected<StringKeyframe>();
keyframes[0]->SetOffset(0);
keyframes[1] = MakeGarbageCollected<StringKeyframe>();
keyframes[2] = MakeGarbageCollected<StringKeyframe>();
keyframes[3] = MakeGarbageCollected<StringKeyframe>();
keyframes[4] = MakeGarbageCollected<StringKeyframe>();
keyframes[4]->SetOffset(0.5);
keyframes[5] = MakeGarbageCollected<StringKeyframe>();
keyframes[6] = MakeGarbageCollected<StringKeyframe>();
keyframes[7] = MakeGarbageCollected<StringKeyframe>();
keyframes[7]->SetOffset(0.8);
keyframes[8] = MakeGarbageCollected<StringKeyframe>();
keyframes[9] = MakeGarbageCollected<StringKeyframe>();
keyframes[10] = MakeGarbageCollected<StringKeyframe>();
keyframes[11] = MakeGarbageCollected<StringKeyframe>();
const Vector<double> result = GetComputedOffsets(keyframes);
EXPECT_EQ(12U, result.size());
EXPECT_DOUBLE_EQ(0.0, result[0]);
EXPECT_DOUBLE_EQ(0.125, result[1]);
EXPECT_DOUBLE_EQ(0.25, result[2]);
EXPECT_DOUBLE_EQ(0.375, result[3]);
EXPECT_DOUBLE_EQ(0.5, result[4]);
EXPECT_DOUBLE_EQ(0.6, result[5]);
EXPECT_DOUBLE_EQ(0.7, result[6]);
EXPECT_DOUBLE_EQ(0.8, result[7]);
EXPECT_DOUBLE_EQ(0.85, result[8]);
EXPECT_DOUBLE_EQ(0.9, result[9]);
EXPECT_DOUBLE_EQ(0.95, result[10]);
EXPECT_DOUBLE_EQ(1.0, result[11]);
}
} // namespace blink
| [
"sunny.nam@samsung.com"
] | sunny.nam@samsung.com |
8d1ecdc81f8b03429632f5c0c08abbc779451a3d | 3ff1fe3888e34cd3576d91319bf0f08ca955940f | /cls/include/tencentcloud/cls/v20201016/model/HistogramInfo.h | f042aace4bc1b0da4d3050de913b8f2d7d5309ff | [
"Apache-2.0"
] | permissive | TencentCloud/tencentcloud-sdk-cpp | 9f5df8220eaaf72f7eaee07b2ede94f89313651f | 42a76b812b81d1b52ec6a217fafc8faa135e06ca | refs/heads/master | 2023-08-30T03:22:45.269556 | 2023-08-30T00:45:39 | 2023-08-30T00:45:39 | 188,991,963 | 55 | 37 | Apache-2.0 | 2023-08-17T03:13:20 | 2019-05-28T08:56:08 | C++ | UTF-8 | C++ | false | false | 3,738 | h | /*
* Copyright (c) 2017-2019 THL A29 Limited, a Tencent company. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef TENCENTCLOUD_CLS_V20201016_MODEL_HISTOGRAMINFO_H_
#define TENCENTCLOUD_CLS_V20201016_MODEL_HISTOGRAMINFO_H_
#include <string>
#include <vector>
#include <map>
#include <tencentcloud/core/utils/rapidjson/document.h>
#include <tencentcloud/core/utils/rapidjson/writer.h>
#include <tencentcloud/core/utils/rapidjson/stringbuffer.h>
#include <tencentcloud/core/AbstractModel.h>
namespace TencentCloud
{
namespace Cls
{
namespace V20201016
{
namespace Model
{
/**
* 直方图详细信息
*/
class HistogramInfo : public AbstractModel
{
public:
HistogramInfo();
~HistogramInfo() = default;
void ToJsonObject(rapidjson::Value &value, rapidjson::Document::AllocatorType& allocator) const;
CoreInternalOutcome Deserialize(const rapidjson::Value &value);
/**
* 获取统计周期内的日志条数
* @return Count 统计周期内的日志条数
*
*/
int64_t GetCount() const;
/**
* 设置统计周期内的日志条数
* @param _count 统计周期内的日志条数
*
*/
void SetCount(const int64_t& _count);
/**
* 判断参数 Count 是否已赋值
* @return Count 是否已赋值
*
*/
bool CountHasBeenSet() const;
/**
* 获取按 period 取整后的 unix timestamp: 单位毫秒
* @return BTime 按 period 取整后的 unix timestamp: 单位毫秒
*
*/
int64_t GetBTime() const;
/**
* 设置按 period 取整后的 unix timestamp: 单位毫秒
* @param _bTime 按 period 取整后的 unix timestamp: 单位毫秒
*
*/
void SetBTime(const int64_t& _bTime);
/**
* 判断参数 BTime 是否已赋值
* @return BTime 是否已赋值
*
*/
bool BTimeHasBeenSet() const;
private:
/**
* 统计周期内的日志条数
*/
int64_t m_count;
bool m_countHasBeenSet;
/**
* 按 period 取整后的 unix timestamp: 单位毫秒
*/
int64_t m_bTime;
bool m_bTimeHasBeenSet;
};
}
}
}
}
#endif // !TENCENTCLOUD_CLS_V20201016_MODEL_HISTOGRAMINFO_H_
| [
"tencentcloudapi@tencent.com"
] | tencentcloudapi@tencent.com |
acf537493bfbf19d66f884446d18dd0237763d1f | 47d7c25fa563a6b8f615b9718a8d2154235b8119 | /CSIS 252/Brekke's Files/inheritance/rectangleType.h | 7dc01c267ac1bac338270cc6f3b6e1ce838df079 | [] | no_license | meyerpa/CPlusPlus | aefcbd20671da909b04e68aabc5f70911590903d | 46f7b8465a6fa1929be5c88985ed38ea9ac335ce | refs/heads/master | 2021-06-04T10:25:11.551812 | 2018-02-23T21:50:01 | 2018-02-23T21:50:01 | 57,323,448 | 0 | 0 | null | 2016-04-28T18:23:24 | 2016-04-28T18:05:37 | C++ | UTF-8 | C++ | false | false | 1,318 | h | #ifndef _RECTANGLETYPE_H_
#define _RECTANGLETYPE_H_
class rectangleType
{
public:
void setDimension(double l, double w);
//Function to set the length and width of the rectangle.
//Postcondition: length = l; width = w;
double getLength() const;
//Function to return the length of the rectangle.
//Postcondition: The value of length is returned.
double getWidth() const;
//Function to return the width of the rectangle.
//Postcondition: The value of width is returned.
double area() const;
//Function to return the area of the rectangle.
//Postcondition: The area of the rectangle is
// calculated and returned.
double perimeter() const;
//Function to return the perimeter of the rectangle.
//Postcondition: The perimeter of the rectangle is
// calculated and returned.
void print() const;
//Function to output the length and width of
//the rectangle.
// rectangleType();
//default constructor
//Postcondition: length = 0; width = 0;
rectangleType(double l, double w);
//constructor with parameters
//Postcondition: length = l; width = w;
private:
double length;
double width;
};
#endif
| [
"meyerpa@mnstate.edu"
] | meyerpa@mnstate.edu |
49eca508e33e89312fac9dad4a4a15d805bc2460 | 0a7c429c78853d865ff19f2a75f26690b8e61b9c | /Legacy/SAL/Interfaces/IBuilder.h | d97bf684760b8696ca005721be8a38c114d0e854 | [] | no_license | perryiv/cadkit | 2a896c569b1b66ea995000773f3e392c0936c5c0 | 723db8ac4802dd8d83ca23f058b3e8ba9e603f1a | refs/heads/master | 2020-04-06T07:43:30.169164 | 2018-11-13T03:58:57 | 2018-11-13T03:58:57 | 157,283,008 | 2 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 1,041 | h |
///////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2002, Perry L. Miller IV
// All rights reserved.
// BSD License: http://www.opensource.org/licenses/bsd-license.html
//
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
//
// Interface for a component that builds a scene.
//
///////////////////////////////////////////////////////////////////////////////
#ifndef _SAL_INTERFACE_BUILDER_H_
#define _SAL_INTERFACE_BUILDER_H_
#include "Usul/Interfaces/IUnknown.h"
namespace SAL {
namespace Interfaces {
struct INode;
struct IBuilder : public Usul::Interfaces::IUnknown
{
/// Smart-pointer definitions.
USUL_DECLARE_QUERY_POINTERS ( IBuilder );
/// Id for this interface.
enum { IID = 1282381398 };
// Build the scene.
virtual INode * buildScene() const = 0;
};
}; // namespace Interfaces
}; // namespace SAL
#endif // _SAL_INTERFACE_BUILDER_H_
| [
"pep4@73d323f7-f32a-0410-a0ec-c7cf9bc3a937"
] | pep4@73d323f7-f32a-0410-a0ec-c7cf9bc3a937 |
85720b3af0ca2b3f998827c156d451a7f2317ac2 | 7f583eade8a277b27364b0e6ec900fb48bb07b02 | /Queue-master/src/cppQueue.cpp | 2f58ce524c8c38e1469321d4131a264faf1d4c33 | [
"BSD-3-Clause",
"MIT"
] | permissive | tcafiero/IoTWArduinoLibraries | 727c4ef7f5cfb456c8d2831303fee7e50a0c2ebc | 6cdfc5a14cdefdee8635e3c4296dcea25dfe5840 | refs/heads/master | 2020-03-23T14:56:16.074734 | 2018-09-17T17:02:49 | 2018-09-17T17:02:49 | 141,709,263 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,988 | cpp | /*!\file cppQueue.cpp
** \author SMFSW
** \version 1.5
** \date 2018/03/14
** \copyright BSD 3-Clause License (c) 2017-2018, SMFSW
** \brief Queue handling library (designed on Arduino)
** \details Queue handling library (designed on Arduino)
** This library was designed for Arduino, yet may be compiled without change with gcc for other purporses/targets
**/
extern "C"
{
#include <string.h>
#include <stdlib.h>
}
#include "cppQueue.h"
#define INC_IDX(ctr, end, start) if (ctr < (end-1)) { ctr++; } \
else { ctr = start; } //!< Increments buffer index \b ctr rolling back to \b start when limit \b end is reached
#define DEC_IDX(ctr, end, start) if (ctr > (start)) { ctr--; } \
else { ctr = end-1; } //!< Decrements buffer index \b ctr rolling back to \b end when limit \b start is reached
Queue::Queue(const uint16_t size_rec, const uint16_t nb_recs, const QueueType type, const bool overwrite)
{
rec_nb = nb_recs;
rec_sz = size_rec;
impl = type;
ovw = overwrite;
init = 0;
if (queue) { free(queue); } // Free existing data (if any)
queue = (uint8_t *) malloc(nb_recs * size_rec);
if (queue == NULL) { return; } // Return here if Queue not allocated
init = QUEUE_INITIALIZED;
flush();
}
Queue::~Queue()
{
if (init == QUEUE_INITIALIZED) free(queue);
}
void Queue::flush(void)
{
in = 0;
out = 0;
cnt = 0;
}
bool Queue::push(const void * record)
{
if ((!ovw) && isFull()) { return false; }
uint8_t * pStart = queue + (rec_sz * in);
memcpy(pStart, record, rec_sz);
INC_IDX(in, rec_nb, 0);
if (!isFull()) { cnt++; } // Increase records count
else if (ovw) // Queue is full and overwrite is allowed
{
if (impl == FIFO) { INC_IDX(out, rec_nb, 0); } // as oldest record is overwritten, increment out
//else if (impl == LIFO) {} // Nothing to do in this case
}
return true;
}
bool Queue::pop(void * record)
{
uint8_t * pStart;
if (isEmpty()) { return false; } // No more records
if (impl == FIFO)
{
pStart = queue + (rec_sz * out);
INC_IDX(out, rec_nb, 0);
}
else if (impl == LIFO)
{
DEC_IDX(in, rec_nb, 0);
pStart = queue + (rec_sz * in);
}
else { return false; }
memcpy(record, pStart, rec_sz);
cnt--; // Decrease records count
return true;
}
bool Queue::peek(void * record)
{
uint8_t * pStart;
if (isEmpty()) { return false; } // No more records
if (impl == FIFO)
{
pStart = queue + (rec_sz * out);
// No change on out var as it's just a peek
}
else if (impl == LIFO)
{
uint16_t rec = in; // Temporary var for peek (no change on in with DEC_IDX)
DEC_IDX(rec, rec_nb, 0);
pStart = queue + (rec_sz * rec);
}
else { return false; }
memcpy(record, pStart, rec_sz);
return true;
}
bool Queue::drop(void)
{
if (isEmpty()) { return false; } // No more records
if (impl == FIFO) { INC_IDX(out, rec_nb, 0); }
else if (impl == LIFO) { DEC_IDX(in, rec_nb, 0); }
else { return false; }
cnt--; // Decrease records count
return true;
}
| [
"tcafiero@hotmail.com"
] | tcafiero@hotmail.com |
e0b578bbe6c8b1ff7c14d6f83a6f9d179dc5b411 | b1e5f089be9b6086db51f31015674ad1a0b61b09 | /unit-tests/test_compression.cc | f74a07fc1858c49332b538fd9cc29265fc9c6a0e | [
"Zlib",
"LicenseRef-scancode-public-domain",
"BSD-2-Clause",
"BSD-3-Clause"
] | permissive | tdiazcu/kingdb | 87532a54843c2ae401ad4e9b8b07980b6bf413bc | 50be18b6b65c028e9495c96c56d603e863822bd6 | refs/heads/master | 2021-01-17T06:30:18.059043 | 2015-04-10T21:45:34 | 2015-04-10T21:45:34 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,991 | cc | #include "algorithm/compressor.h"
#include "algorithm/lz4.h"
char* MakeValue(const std::string& key, int size_value) {
int size_key = key.size();
char *str = new char[size_value+1];
str[size_value] = '\0';
int i = 0;
for (i = 0; i < size_value / size_key; i++) {
memcpy(str + i*size_key, key.c_str(), size_key);
}
if (size_value % size_key != 0) {
memcpy(str + i*size_key, key.c_str(), size_value % size_key);
}
return str;
}
int VerifyValue(const std::string& key, int size_value, const char* value) {
int size_key = key.size();
int i = 0;
bool error = false;
for (i = 0; i < size_value / size_key; i++) {
if (memcmp(value + i*size_key, key.c_str(), size_key)) {
std::string value2(value + i*size_key, size_key);
printf("diff i:%d size:%d key:[%s], value:[%s]\n", i, size_key, key.c_str(), value2.c_str());
error = true;
}
}
if (size_value % size_key != 0) {
if (memcmp(value + i*size_key, key.c_str(), size_value % size_key)) {
std::string value2(value, size_value % size_key);
printf("diff remainder size:%d key:[%s], value:[%s]\n", size_value % size_key, key.c_str(), value2.c_str());
error = true;
}
}
if (error) return -1;
return 0;
}
int main() {
kdb::CompressorLZ4 lz4;
char* raw = nullptr;
char *compressed = nullptr;
uint64_t size_value = 442837;
uint64_t size_compressed = 0;
uint64_t size_chunk = 64*1024;
uint64_t offset_chunk_compressed = 0;
uint64_t SIZE_BUFFER = 1024*1024;
std::string key("0x10c095000-0");
raw = MakeValue(key, size_value);
lz4.ResetThreadLocalStorage();
compressed = new char[SIZE_BUFFER];
auto num_chunks = size_value / size_chunk;
char *comp;
if (size_value % size_chunk) num_chunks += 1;
for(auto chunk = 0; chunk < num_chunks; chunk++) {
uint64_t size_chunk_current = 0;
size_chunk_current = size_chunk;
if (chunk == num_chunks - 1) {
size_chunk_current = size_value % size_chunk;
}
fprintf(stderr, "step:%d size:%" PRIu64 "\n", chunk, size_chunk_current);
offset_chunk_compressed = lz4.size_compressed();
kdb::Status s = lz4.Compress(raw + chunk * size_chunk,
size_chunk_current,
&comp,
&size_compressed);
if (!s.IsOK()) {
fprintf(stderr, "%s\n", s.ToString().c_str());
exit(-1);
}
fprintf(stderr, "step %d - %p size_compressed:%" PRIu64 " offset:%" PRIu64 "\n", chunk, comp, size_compressed, offset_chunk_compressed);
memcpy(compressed + offset_chunk_compressed, comp, size_compressed);
fprintf(stderr, "step %d - size_compressed:%" PRIu64 "\n", chunk, size_compressed);
}
size_compressed = lz4.size_compressed();
fprintf(stderr, "--- stream compressed data (size:%" PRIu64 "):\n", size_compressed);
for (auto i = 0; i < size_compressed; i++) {
fprintf(stderr, "%c", compressed[i]);
}
fprintf(stderr, "\n--- done\n");
char *uncompressed;
uint64_t size_out;
uint64_t size_out_total = 0;
char *frame;
uint64_t size_frame;
int step = 0;
char *uncompressed_full = new char[1024*1024];
while(true) {
kdb::Status s1 = lz4.Uncompress(compressed,
size_compressed,
&uncompressed,
&size_out,
&frame,
&size_frame);
fprintf(stderr, "stream uncompressed step: %d size:%" PRIu64 "\n", step, size_out);
if (!s1.IsOK()) {
fprintf(stderr, "%s\n", s1.ToString().c_str());
break;
}
memcpy(uncompressed_full + size_out_total, uncompressed, size_out);
size_out_total += size_out;
step += 1;
}
fprintf(stderr, "stream uncompressed size: %" PRIu64 "\n", size_out_total);
int ret = VerifyValue(key, size_value, uncompressed_full);
if (ret == 0) {
fprintf(stderr, "Verify(): ok\n");
}
return 0;
}
| [
"emmanuel.goossaert@gmail.com"
] | emmanuel.goossaert@gmail.com |
b5bf3bf1e81598646ee21732bf57f365e423ab88 | 26df6604faf41197c9ced34c3df13839be6e74d4 | /src/org/apache/poi/ss/formula/WorkbookEvaluatorProvider.hpp | 49e733e2d21db0ae0ad59c0acf0d8aa1d5669f14 | [
"Apache-2.0"
] | permissive | pebble2015/cpoi | 58b4b1e38a7769b13ccfb2973270d15d490de07f | 6dcc0c5e13e3e722b4ef9fd0baffbf62bf71ead6 | refs/heads/master | 2021-07-09T09:02:41.986901 | 2017-10-08T12:12:56 | 2017-10-08T12:12:56 | 105,988,119 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 400 | hpp | // Generated from /POI/java/org/apache/poi/ss/formula/WorkbookEvaluatorProvider.java
#pragma once
#include <org/apache/poi/ss/formula/fwd-POI.hpp>
#include <java/lang/Object.hpp>
struct poi::ss::formula::WorkbookEvaluatorProvider
: public virtual ::java::lang::Object
{
virtual WorkbookEvaluator* _getWorkbookEvaluator() = 0;
// Generated
static ::java::lang::Class *class_();
};
| [
"zhang.chen.yu@outlook.com"
] | zhang.chen.yu@outlook.com |
951b8cdc8c9a42c5a5ba7993fba3f0b49f772fcb | 958b35b8188909abfb5c5fc466fd4fb461735a21 | /chapter4/4-3.cpp | afc35ab8295d34677faf1466245d86e42817dfea | [] | no_license | 1303575952/Teach-Yourself-Cpp-in-One-Hour-a-Day | af89f85fd26e2d0d639fcc879ccbee67bd6aa072 | 7324b5d2032b8fc127e506359f7c05b96a0c9884 | refs/heads/master | 2020-05-16T23:12:27.812340 | 2019-04-28T08:21:42 | 2019-04-28T08:21:42 | 183,356,020 | 5 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 677 | cpp | #include <iostream>
using namespace std;
int main() {
int threeRowsThreeColumns[3][3] =
{{-501, 205, 2011},
{989, 101, 206},
{303, 456, 596}};
cout << "Row 0: " << threeRowsThreeColumns[0][0] << " "
<< threeRowsThreeColumns[0][1] << " "
<< threeRowsThreeColumns[0][2] << endl;
cout << "Row 1: " << threeRowsThreeColumns[1][0] << " "
<< threeRowsThreeColumns[1][1] << " "
<< threeRowsThreeColumns[1][2] << endl;
cout << "Row 2: " << threeRowsThreeColumns[2][0] << " "
<< threeRowsThreeColumns[2][1] << " "
<< threeRowsThreeColumns[2][2] << endl;
return 0;
} | [
"1303575952@qq.com"
] | 1303575952@qq.com |
e31ffc933237ee41a933149c40b83a4945ba3b04 | 63926f6bc3dd5b3573d4e22c7d5ac0bc1a5e253c | /Plugins/GeoGlue/Source/VoxelExtension/Private/GRDReader.cpp | 95da2c2f704fe112add349005e9a1cd9bf4d1a7d | [] | no_license | chaiyuntian/MPlugins | 8c024cf3cb815614aa4c5eaf7d6d1e0f5af9eb6b | 9050f15e0ac92657dbf63b403d873e87485892d2 | refs/heads/main | 2023-01-10T23:07:38.428583 | 2020-11-10T04:02:52 | 2020-11-10T04:02:52 | 309,244,097 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,617 | cpp | // Fill out your copyright notice in the Description page of Project Settings.
#include "GRDReader.h"
DEFINE_LOG_CATEGORY_STATIC(LogGRDReader, Log, All);
// space and return
static void JumpOverWhiteSpace(const uint8*& BufferPos)
{
while (*BufferPos)
{
if (*BufferPos == 13 && *(BufferPos + 1) == 10)
{
BufferPos += 2;
continue;
}
else if (*BufferPos <= ' ')
{
// Skip tab, space and invisible characters
++BufferPos;
continue;
}
break;
}
}
static void GetLineContent(const uint8*& BufferPos, char Line[256], bool bStopOnWhitespace)
{
JumpOverWhiteSpace(BufferPos);
char* LinePtr = Line;
uint32 i;
for (i = 0; i < 255; ++i)
{
if (*BufferPos == 0)
{
break;
}
else if (*BufferPos == '\r' && *(BufferPos + 1) == '\n')
{
BufferPos += 2;
break;
}
else if (*BufferPos == '\n')
{
++BufferPos;
break;
}
else if (bStopOnWhitespace && (*BufferPos <= ' '))
{
// tab, space, invisible characters
++BufferPos;
break;
}
*LinePtr++ = *BufferPos++;
}
Line[i] = 0;
}
// @return success
static bool GetFloat(const uint8*& BufferPos, float& ret)
{
char Line[256];
GetLineContent(BufferPos, Line, true);
ret = FCStringAnsi::Atof(Line);
return true;
}
static bool GetInt(const uint8*& BufferPos, int32& ret)
{
char Line[256];
GetLineContent(BufferPos, Line, true);
ret = FCStringAnsi::Atoi(Line);
return true;
}
#define PARSE_FLOAT(x) float x; if(!GetFloat(BufferPos, x)){ UE_LOG(LogGRDReader, Warning, TEXT("Value parsing error: Error reading GRD file float value!")) return false;}
#define PARSE_INT(x) int32 x; if(!GetInt(BufferPos, x)){ UE_LOG(LogGRDReader, Warning, TEXT("Value parsing error: Error reading GRD file int value!")) return false;}
bool FGRDReader::Load(FString FilePath, TArray<float>& ValuArray, FGRDHeaderInfo& HeaderInfo)
{
TArray<uint8> Bytes;
if (!FFileHelper::LoadFileToArray(Bytes, *FilePath, FILEREAD_Silent))
{
UE_LOG(LogGRDReader, Warning, TEXT("Error reading GRD file"));
return false;
}
const uint8* BufferPos = Bytes.GetData();
char Line1[256];
GetLineContent(BufferPos, Line1, false);
// Check the first line
if (FCStringAnsi::Stricmp(Line1, "DSAA") != 0)
{
UE_LOG(LogGRDReader, Warning, TEXT("GRD File Format Error: the first line should be DSAA!"));
return false;
}
PARSE_INT(GridsX);
PARSE_INT(GridsY);
PARSE_FLOAT(XMin); PARSE_FLOAT(XMax);
PARSE_FLOAT(YMin); PARSE_FLOAT(YMax);
PARSE_FLOAT(ZMin); PARSE_FLOAT(ZMax);
HeaderInfo.GridsX = GridsX;
HeaderInfo.GridsY = GridsY;
HeaderInfo.XRange = FGridValueRange(XMin,XMax);
HeaderInfo.YRange = FGridValueRange(YMin, YMax);
HeaderInfo.ZRange = FGridValueRange(ZMin, ZMax);
ValuArray.Empty(GridsX * GridsY);
for (uint32 y = 0; y < (uint32)GridsY; ++y)
{
for (uint32 x = 0; x < (uint32)GridsX; ++x)
{
PARSE_FLOAT(Value);
ValuArray.Add(Value);
}
}
return true;
}
void FGRDReader::ResampleData(const TArray<float>& SourceData, uint32 SrcWidth, uint32 SrcHeight, TArray<float>& DstData, uint32 DstWidth, uint32 DstHeight)
{
DstData.Empty(DstWidth * DstHeight);
DstData.AddUninitialized(DstWidth * DstHeight);
const float* SrcData = SourceData.GetData();
const float DestToSrcScaleX = (float)SrcWidth / (float)DstWidth;
const float DestToSrcScaleY = (float)SrcHeight / (float)DstHeight;
for (uint32 Y = 0; Y < (uint32)DstHeight; ++Y)
{
const float SrcY = (float)Y * DestToSrcScaleY;
for (uint32 X = 0; X < (uint32)DstWidth; ++X)
{
const int32 Index = X + DstWidth * Y;
const float SrcX = (float)X * DestToSrcScaleX;
DstData[Index] = SampleGrid(SrcData, SrcWidth, SrcHeight, SrcX, SrcY);
}
}
}
float FGRDReader::SampleGrid(const float* HeightValues, int Width, int Height, float X, float Y)
{
const int64 TexelX0 = FMath::FloorToInt(X);
const int64 TexelY0 = FMath::FloorToInt(Y);
const int64 TexelX1 = FMath::Min<int64>(TexelX0 + 1, Width - 1);
const int64 TexelY1 = FMath::Min<int64>(TexelY0 + 1, Height - 1);
checkSlow(TexelX0 >= 0 && TexelX0 < Width);
checkSlow(TexelY0 >= 0 && TexelY0 < Height);
const float FracX1 = FMath::Frac(X);
const float FracY1 = FMath::Frac(Y);
const float FracX0 = 1.0f - FracX1;
const float FracY0 = 1.0f - FracY1;
const float Value00 = HeightValues[TexelY0 * Width + TexelX0];
const float Value01 = HeightValues[TexelY1 * Width + TexelX0];
const float Value10 = HeightValues[TexelY0 * Width + TexelX1];
const float Value11 = HeightValues[TexelY1 * Width + TexelX1];
return
Value00 * (FracX0 * FracY0) +
Value01 * (FracX0 * FracY1) +
Value10 * (FracX1 * FracY0) +
Value11 * (FracX1 * FracY1);
} | [
"tianyunchai@126.com"
] | tianyunchai@126.com |
5abdb50948be3d16a33c166288a4b16fcd214e2a | bc047c426fc1e2f619173a26cff72394b2a223b2 | /esp015/test2.0 esp8266/Blink/Blink.ino | 6eef7b91ca699677d707b6ccdda52bca7fc74933 | [] | no_license | MathieuAuclair/ArduinoTest | 4587375d8191e12afaa811c046d7ca2f65f85548 | ee6592768f398d5d189742d4293fec5fdb66d511 | refs/heads/master | 2021-04-30T18:14:44.087896 | 2017-05-29T23:31:04 | 2017-05-29T23:31:04 | 80,334,724 | 1 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 1,179 | ino | // Basic serial communication with ESP8266
// Uses serial monitor for communication with ESP8266
//
// Pins
// Arduino pin 2 (RX) to ESP8266 TX
// Arduino pin 3 to voltage divider then to ESP8266 RX
// Connect GND from the Arduiono to GND on the ESP8266
// Pull ESP8266 CH_PD HIGH
//
// When a command is entered in to the serial monitor on the computer
// the Arduino will relay it to the ESP8266
//
#include <SoftwareSerial.h>
SoftwareSerial ESPserial(2, 3); // RX | TX
void setup()
{
Serial.begin(115200); // communication with the host computer
//while (!Serial) { ; }
// Start the software serial for communication with the ESP8266
ESPserial.begin(115200);
Serial.println("");
Serial.println("Remember to to set Both NL & CR in the serial monitor.");
Serial.println("Ready");
Serial.println("");
}
void loop()
{
// listen for communication from the ESP8266 and then write it to the serial monitor
if ( ESPserial.available() ) { Serial.write( ESPserial.read() ); }
// listen for user input and send it to the ESP8266
if ( Serial.available() ) { ESPserial.write( Serial.read() ); }
}
| [
"mathiass12@hotmail.com"
] | mathiass12@hotmail.com |
41e251dcc5b960e442cb4a2bcbbb9dae040c3702 | 7be056d7722b46f165d332558df22a05573471c7 | /ProyectoSDL/game.h | afdb56556ef24ca88ebd382b68a231de6e5f5531 | [] | no_license | ElizabethSly/EscapeRoom | 21081d04e9a1bd0f1ff2a2161fdc3a44d6ea1061 | 203d1ffbeeaa2677cc204f8dfb80f2cafbb2406d | refs/heads/master | 2020-09-14T23:36:03.371691 | 2019-11-22T01:12:42 | 2019-11-22T01:12:42 | 223,295,099 | 0 | 0 | null | null | null | null | ISO-8859-2 | C++ | false | false | 5,032 | h | #ifndef GAME_H_INCLUDED
#define GAME_H_INCLUDED
#include <SDL.h>
#include <SDL_image.h>
#include <stdio.h>
#include <string>
#include <iostream>
#include "mouse.h"
#include "Textura.h"
#include "puzzle.h"
#include "Room.h"
class Game{
public:
Game();
void init(const char* title, int xpos, int ypos, int width, int height, bool fullscreen);
void handleEvents();
void update();
void render();
void clean();
SDL_Texture* loadTexture( std::string path );
bool loadMedia();
bool running(){return isRunning;}
private:
Room* room1 = new Room(2);
int roomActual;
int vistaActual;
bool isRunning;
SDL_Window *window;
SDL_Renderer *renderer;
string passPC1="";
bool PC1=false;
};
Game::Game(){
roomActual = 1;
vistaActual = 1;
}
void Game::init(const char* title, int xpos, int ypos, int width, int height, bool fullscreen){
int flags=0;
if(fullscreen){
flags=SDL_WINDOW_FULLSCREEN;
}
if(SDL_Init(SDL_INIT_EVERYTHING)==0){
std::cout<<"Subsystems Initialized"<<std::endl;
window=SDL_CreateWindow(title,xpos,ypos,width,height,flags);
if(window){
std::cout<<"window created"<<std::endl;
}
renderer=SDL_CreateRenderer(window,-1,0);
if(renderer){
SDL_SetRenderDrawColor(renderer,255,255,255,255);
std::cout<<"renderer created!"<<std::endl;
}
//Initialize PNG loading
int imgFlags = IMG_INIT_PNG;
if( !( IMG_Init( imgFlags ) & imgFlags ) ){
printf( "SDL_image no inicializó! SDL_image Error: %s\n", IMG_GetError() );
}
if(!loadMedia()){
printf("Error al cargar la Media");
}
isRunning=true;
}else{isRunning=false;}
}
void Game::handleEvents(){
int x, y;
SDL_Event event;
SDL_PollEvent(&event);
switch(event.type){
case SDL_QUIT:
isRunning=false;
break;
case SDL_MOUSEBUTTONDOWN:
SDL_GetMouseState( &x, &y );
room1->handleEvent(x, y);
break;
//mostrar coordenadas
/*case SDL_MOUSEMOTION:
SDL_GetMouseState( &x, &y );
system("cls");
std::cout << "x = " << x <<std::endl;
std::cout << "y = " << y <<std::endl;
break;*/
//para puzzles que necesitan texto
case SDL_TEXTINPUT:
SDL_StartTextInput();
switch(roomActual){
case 2:
if(PC1==false){
if(event.type==SDL_TEXTINPUT || event.type==SDL_KEYDOWN){
if(event.type==SDL_KEYDOWN && event.key.keysym.sym==SDLK_BACKSPACE && passPC1.length()>0){
passPC1=passPC1.substr(0,passPC1.length()-1);
}
else if(event.type==SDL_TEXTINPUT){
passPC1+=event.text.text;
std::cout<<passPC1<<std::endl;
}
}
//passPC1+=event.text.text;
PC1=puzzlePC1(passPC1);
cout<<PC1;
}
}
default:
break;
SDL_StopTextInput();
}
}
void Game::update(){
}
void Game::render(){
SDL_SetRenderDrawColor( renderer, 0xFF, 0xFF, 0xFF, 0xFF );
SDL_RenderClear( renderer );
room1->render(renderer);
SDL_RenderPresent(renderer);
}
void Game::clean(){
SDL_DestroyWindow(window);
SDL_DestroyRenderer(renderer);
SDL_Quit();
std::cout<<"Game Cleaned"<<std::endl;
}
bool Game::loadMedia(){
//Loading success flag
bool success = true;
if(!room1->paredes[0].loadFromFile("Room1.png", renderer)){
printf( "Failed to load room1 texture!\n" );
success = false;
}
if(!room1->paredes[1].loadFromFile("Room2.png", renderer)){
printf( "Failed to load room2 texture!\n" );
success = false;
}
if(!room1->paredes[2].loadFromFile("Room3.png", renderer)){
printf( "Failed to load room3 texture!\n" );
success = false;
}
if(!room1->paredes[3].loadFromFile("Room4.png", renderer)){
printf( "Failed to load room4 texture!\n" );
success = false;
}
if(!room1->vistas[0].imagen.loadFromFile("Vista1.png", renderer)){
printf( "Failed to load Vista1 texture!\n" );
success = false;
}else{
room1->vistas[0].pared = 1;
SDL_Rect cuadro={230,357,70,70};
room1->vistas[0].zona = cuadro;
}
if(!room1->vistas[1].imagen.loadFromFile("Vista2.png", renderer)){
printf( "Failed to load Vista2 texture!\n" );
success = false;
}else{
room1->vistas[1].pared = 1;
SDL_Rect cuadro={415,280,65,50};
room1->vistas[1].zona = cuadro;
}
return success;
}
#endif // GAME_H_INCLUDED
| [
"noreply@github.com"
] | ElizabethSly.noreply@github.com |
355ee9b07a02683373fe53f59f9cbc4bc88835a1 | 3e2711b2bb02bf80cb2f4443cc08eaa3f09c8c2f | /codevs1082_zkw_0.cpp | fbfb8570adaa098bcee6423cf84aabb6c0b1206d | [] | no_license | liangsheng/new | 2a13f9efd84c2f2d922ac578d41528a71df6e1f4 | 3c5f46c214b4fbf66719f1dc0bed82196214f620 | refs/heads/master | 2021-01-18T22:34:38.451489 | 2016-06-13T09:26:43 | 2016-06-13T09:26:43 | 35,537,393 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,473 | cpp | #include <bits/stdc++.h>
#define file_r(x) freopen(x, "r", stdin)
#define file_w(x) freopen(x, "w", stdout)
#define rep(i, n) for (int i = 0; i < n; i++)
#define FOR(i, n, m) for (int i = n; i <= m; i++)
#define repe(i, u) for (int i = head[u]; ~i; i = nxt[i])
#define FORD(i, n, m) for (int i = n; i >= m; i--)
#define repit(i, c) for (__typeof__((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define pause cout << " press ant key to continue...", cin >> chh
#define pb push_back
#define mp make_pair
#define ins insert
#define X first
#define Y second
#define be begin
#define nb rbegin
#define er erase
#define SZ(c) c.size()
#define ins insert
#define sc(n) cout << #n << "= " << n, system("pause")
#define sc2(n, m) cout << #n << "= " << n << " " << #m << "= " << m, system("pause")
#define sc3(n, m, k) cout << #n << "= " << n << " " << #m << "= " << m << " " << #k << "= " << k, system("pause")
#define sc4(n, m, k, b) cout << #n << "= " << n << " " << #m << "= " << m << " " << #k << "= " << k << " " << #b << "= " << b, system("pause")
using namespace std;
int chh;
typedef long long LL;
const int N = 200005, M = 262144;
int n, m;
LL a[M * 2 + 1], b[M * 2 + 1];
void init() {
memset(a, 0, sizeof(a));
memset(b, 0, sizeof(b));
}
void add(LL a[], int x, LL y) {
for (a[x += M] += y, x >>= 1; x; x >>= 1) {
a[x] = a[x << 1] + a[x << 1 | 1];
}
}
LL gao(LL a[], int s, int t) {
LL ans = 0;
for (s = s + M - 1, t = t + M + 1; s ^ t ^ 1; s >>= 1, t >>= 1) {
if (~s & 1) ans += a[s ^ 1];
if (t & 1) ans += a[t ^ 1];
}
return ans;
}
int h[N];
int main() {
int f, l, r, x;
LL al, ar;
while (~scanf("%d", &n)) {
init();
FOR (i, 1, n) scanf("%d", &h[i]);
h[0] = 0;
FOR (i, 1, n) {
add(a, i, h[i] - h[i - 1]);
add(b, i, (LL) i * (h[i] - h[i - 1]));
}
scanf("%d", &m);
while (m--) {
scanf("%d", &f);
if (f == 1) {
scanf("%d %d %d", &l, &r, &x);
add(a, l, x), add(a, r + 1, -x);
add(b, l, x * l), add(b, r + 1, (r + 1) * (-x));
} else {
scanf("%d %d", &l, &r);
ar = (r + 1) * gao(a, 1, r) - gao(b, 1, r);
if (l == 1) al = 0;
else al = l * gao(a, 1, l - 1) - gao(b, 1, l - 1);
printf("%lld\n", ar - al);
}
}
}
return 0;
}
| [
"904491908@qq.com"
] | 904491908@qq.com |
973e7e7b9b342e7b3b6980eadebaabefdecc65f8 | 794312de5e5e928080e75730ef56f6fff7baf918 | /snake.h | 46994497f95b3b9604b51f90c75fc5d552bb2656 | [] | no_license | ampaul5653/Snake-Game | d67190e531d623c4111ac354cd826a3698184325 | d283b065e78f44e6ea9ad5175e172f5328542d29 | refs/heads/master | 2023-01-08T14:32:38.957168 | 2020-11-08T01:23:58 | 2020-11-08T01:23:58 | 310,962,151 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,438 | h | /*---------------------------------------------------------
file: snake.h
by: Adam Paul
org: COP 2001, Spring 2020
for: Header file for a snake class object
---------------------------------------------------------*/
#pragma once
#include "block.h"
#include "snakedefs.h"
class Snake {
private:
Block head; //root of the snake body
Block* tail; //pointer to last block in body
Block prevTail; // for erasing and appending
Block speed; // travelling velocity in the x/y axis
int size; // number of body blocks in snake
Direction current; // curent direction snake is traveling
Direction next; // direction player has input
public:
//-------------------------------------------
// Constructors
//-------------------------------------------
Snake();
Snake(int startColumn, int startRow);
//-------------------------------------------
// Accessors
//-------------------------------------------
Block* getHead();
Block* getTail();
Block* getPrevTail();
int getSize();
Direction getCurrentDirection();
Direction getNextDirection();
//-------------------------------------------
// Methods
//-------------------------------------------
void setDirections(int input);
void turn();
void move();
bool isMoving();
void grow();
void collisions();
bool intersects(Block other, bool withHead);
}; // end class Snake | [
"adammpaul4@gmail.com"
] | adammpaul4@gmail.com |
2879611e1e15c17c1b77a8b264988832cde8db0d | 2d7930d9fbea2f8492b47f2b4a4bfca501f1add7 | /TwoChoice/States.cpp | 5ac5089cb8356aebf7975c52a2af377e1980380c | [] | no_license | danieldkato/ArduFSM | e5963351af58b6f07d76be813caceb4cb9dc10b0 | fd5418c857b1852e09805e497fb92d29e80e6f4b | refs/heads/master | 2022-02-03T09:11:33.102805 | 2021-10-07T01:21:37 | 2021-10-07T01:21:37 | 52,998,161 | 0 | 0 | null | 2016-03-02T21:36:05 | 2016-03-02T21:36:05 | null | UTF-8 | C++ | false | false | 18,602 | cpp | /* Implementation file for declaring protocol-specific states.
This implements a two-alternative choice task with two lick ports.
Defines the following:
* param_abbrevs, which defines the shorthand for the trial parameters
* param_values, which define the defaults for those parameters
* results_abbrevs, results_values, default_results_values
* implements the state functions and state objects
*/
#include "States.h"
#include "Arduino.h"
#include "hwconstants.h"
#ifndef __HWCONSTANTS_H_USE_STEPPER_DRIVER
#include "Stepper.h"
#endif
#ifndef __HWCONSTANTS_H_USE_IR_DETECTOR
#include "mpr121.h"
#endif
#ifdef __HWCONSTANTS_H_USE_IR_DETECTOR
#include "ir_detector.h"
#endif
// include this one just to get __TRIAL_SPEAK_YES
#include "chat.h"
//#define EXTRA_180DEG_ROT
extern STATE_TYPE next_state;
// These should go into some kind of Protocol.h or something
char* param_abbrevs[N_TRIAL_PARAMS] = {
"STPPOS", "MRT", "RWSD", "SRVPOS", "ITI",
"2PSTP", "SRVFAR", "SRVTT", "RWIN", "IRI",
"RD_L", "RD_R", "SRVST", "PSW", "TOE",
"TO", "STPSPD", "STPFR", "STPIP", "ISRND",
"TOUT", "RELT", "STPHAL", "HALPOS", "DIRDEL",
"OPTO",
};
long param_values[N_TRIAL_PARAMS] = {
1, 1, 1, 1, 3000,
0, 1900, 4500, 45000, 500,
40, 40, 1000, 1, 1,
6000, 20, 50, 50, 0,
6, 3, 0, 50, 0,
0,
};
// Whether to report on each trial
// Currently, manually match this up with Python-side
// Later, maybe make this settable by Python, and default to all True
// Similarly, find out which are required on each trial, and error if they're
// not set. Currently all that are required_ET are also reported_ET.
bool param_report_ET[N_TRIAL_PARAMS] = {
1, 0, 1, 1, 0,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
0, 0, 0, 0, 1,
0, 0, 0, 0, 1,
1,
};
char* results_abbrevs[N_TRIAL_RESULTS] = {"RESP", "OUTC"};
long results_values[N_TRIAL_RESULTS] = {0, 0};
long default_results_values[N_TRIAL_RESULTS] = {0, 0};
// Global, persistent variable to remember where the stepper is
long sticky_stepper_position = 0;
//// State definitions
#ifndef __HWCONSTANTS_H_USE_STEPPER_DRIVER
extern Stepper* stimStepper;
#endif
//// StateResponseWindow
void StateResponseWindow::update(uint16_t touched)
{
my_touched = touched;
}
void StateResponseWindow::loop()
{
int current_response;
bool licking_l;
bool licking_r;
unsigned long time = millis();
// get the licking state
// overridden in FakeResponseWindow
set_licking_variables(licking_l, licking_r);
// Turn off laser if we've been in the state for long enough
if ((time - (timer - duration)) > 3000) {
digitalWrite(__HWCONSTANTS_H_OPTO, 1);
}
// transition if max rewards reached
if (my_rewards_this_trial >= param_values[tpidx_MRT])
{
next_state = INTER_TRIAL_INTERVAL;
flag_stop = 1;
return;
}
// Do nothing if both or neither are being licked.
// Otherwise, assign current_response.
if (!licking_l && !licking_r)
return;
else if (licking_l && licking_r)
return;
else if (licking_l && !licking_r)
current_response = LEFT;
else if (!licking_l && licking_r)
current_response = RIGHT;
else
Serial.println("ERR this should never happen");
// Only assign result if this is the first response
if (results_values[tridx_RESPONSE] == 0)
results_values[tridx_RESPONSE] = current_response;
// Move to reward state, or error if TOE is set, or otherwise stay
if ((current_response == LEFT) && (param_values[tpidx_REWSIDE] == LEFT))
{ // Hit on left
next_state = REWARD_L;
my_rewards_this_trial++;
results_values[tridx_OUTCOME] = OUTCOME_HIT;
}
else if ((current_response == RIGHT) && (param_values[tpidx_REWSIDE] == RIGHT))
{ // Hit on right
next_state = REWARD_R;
my_rewards_this_trial++;
results_values[tridx_OUTCOME] = OUTCOME_HIT;
}
else if (param_values[tpidx_TERMINATE_ON_ERR] == __TRIAL_SPEAK_NO)
{ // Error made, TOE is false
// Decide how to deal with this non-TOE case
}
else
{ // Error made, TOE is true
next_state = ERROR;
// The type of error depends on whether it's gonogo or 2AFC
if (param_values[tpidx_REWSIDE] == NOGO) {
// Response should have been nogo, so he made a false positive or a spoil
if (current_response == RIGHT) {
// Licked when he shouldn't have done anything
results_values[tridx_OUTCOME] = OUTCOME_ERROR;
} else {
// Licked the wrong pipe
results_values[tridx_OUTCOME] = OUTCOME_SPOIL;
}
} else {
// 2AFC task, so it's an error for licking the wrong way
results_values[tridx_OUTCOME] = OUTCOME_ERROR;
}
}
}
void StateResponseWindow::s_finish()
{
// Turn off laser, if it was on
digitalWrite(__HWCONSTANTS_H_OPTO, 1);
// If response is still not set, mark as a nogo response
if (results_values[tridx_RESPONSE] == 0)
{
// The response was nogo
results_values[tridx_RESPONSE] = NOGO;
// Outcome depends on what he was supposed to do
if (param_values[tpidx_REWSIDE] == NOGO) {
// Correctly did nothing on a NOGO trial
results_values[tridx_OUTCOME] = OUTCOME_HIT;
} else {
// If this is a 2AFC task, then this is a spoil.
// If this is a gonogo task, then this is a miss.
// No way to tell which is which right now, so just call it a spoil
// regardless.
results_values[tridx_OUTCOME] = OUTCOME_SPOIL;
}
// In any case the trial is over
next_state = INTER_TRIAL_INTERVAL;
}
}
void StateResponseWindow::set_licking_variables(bool &licking_l, bool &licking_r)
{ /* Gets the current licking status from the touched variable for each port */
licking_l = (get_touched_channel(my_touched, 0) == 1);
licking_r = (get_touched_channel(my_touched, 1) == 1);
}
//// StateFakeResponsewindow
// Differs only in that it randomly fakes a response
void StateFakeResponseWindow::set_licking_variables(bool &licking_l, bool &licking_r)
{ /* Fakes a response by randomly choosing lick status for each */
licking_l = (random(0, 10000) < 3);
licking_r = (random(0, 10000) < 3);
}
//// Interrotation pause
void StateInterRotationPause::s_finish()
{
next_state = ROTATE_STEPPER2;
}
//// StateErrorTimeout
void StateErrorTimeout::s_finish()
{
next_state = INTER_TRIAL_INTERVAL;
}
void StateErrorTimeout::s_setup()
{
// Turn off laser, if it was on
digitalWrite(__HWCONSTANTS_H_OPTO, 1);
my_linServo.write(param_values[tpidx_SRV_FAR]);
}
//// Wait for servo move
void StateWaitForServoMove::update(Servo linServo)
{
// Actually this belongs in the constructor.
my_linServo = linServo;
}
void StateWaitForServoMove::s_setup()
{
my_linServo.write(param_values[tpidx_SRVPOS]);
//~ next_state = ROTATE_STEPPER1;
}
void StateWaitForServoMove::loop()
{
unsigned long time = millis();
// First set opto
if (
(param_values[tpidx_OPTO] == __TRIAL_SPEAK_YES) &&
((time - timer) > -2000)) {
digitalWrite(__HWCONSTANTS_H_OPTO, 0);
}
// Now set direct delivery
if ((param_values[tpidx_DIRECT_DELIVERY] == __TRIAL_SPEAK_NO) ||
(direct_delivery_delivered == 1)) {
return;
}
if ((time - timer) > -500) {
if (param_values[tpidx_REWSIDE] == LEFT) {
Serial.print(time);
Serial.println(" EV DDR_L");
digitalWrite(L_REWARD_VALVE, HIGH);
delay(param_values[tpidx_REWARD_DUR_L]);
digitalWrite(L_REWARD_VALVE, LOW);
}
else if (param_values[tpidx_REWSIDE] == RIGHT) {
Serial.print(time);
Serial.println(" EV DDR_R");
digitalWrite(R_REWARD_VALVE, HIGH);
delay(param_values[tpidx_REWARD_DUR_R]);
digitalWrite(R_REWARD_VALVE, LOW);
}
direct_delivery_delivered = 1;
}
}
void StateWaitForServoMove::s_finish()
{
next_state = RESPONSE_WINDOW;
}
//// Inter-trial interval
void StateInterTrialInterval::s_setup()
{
// Turn off laser, if it was on
digitalWrite(__HWCONSTANTS_H_OPTO, 1);
// First-time code: Report results
for(int i=0; i < N_TRIAL_RESULTS; i++)
{
Serial.print(time_of_last_call);
Serial.print(" TRLR ");
Serial.print(results_abbrevs[i]);
Serial.print(" ");
Serial.println(results_values[i]);
}
}
void StateInterTrialInterval::s_finish()
{
next_state = WAIT_TO_START_TRIAL;
}
//// Non-class states
int state_rotate_stepper1(STATE_TYPE& next_state)
{ /* Start rotating the stepper motor.
The first rotation is always the same amount.
The second rotation later achieves the final position.
The house light is also turned off now.
*/
//~ digitalWrite(__HWCONSTANTS_H_HOUSE_LIGHT, LOW);
rotate(param_values[tpidx_STEP_FIRST_ROTATION]);
// Rotate randomly +180 or -180 to confuse the subject
// This should be its own state but let's keep it simple for now
// Could get this as a trial param
int steps = random(0, 2);
// convert to steps, +100 or -100
steps = steps * 200 - 100;
// rotate
#ifdef EXTRA_180DEG_ROT
delay(50); // between 1st and intermediate
rotate(steps);
#endif
next_state = INTER_ROTATION_PAUSE;
return 0;
}
int state_rotate_stepper2(STATE_TYPE& next_state)
{ /* The second rotation goes to the final position */
// Calculate how much more we need to rotate
long remaining_rotation = param_values[tpidx_STPPOS] -
sticky_stepper_position;
int step_size = 1;
int actual_steps = remaining_rotation;
digitalWrite(__HWCONSTANTS_H_HOUSE_LIGHT, LOW);
// Take a shorter negative rotation, if available
// For instance, to go from 0 to 150, it's better to go -50
if (remaining_rotation > 100)
remaining_rotation -= 200;
// convoluted way to determine step_size
if (remaining_rotation < 0)
step_size = -1;
// Perform the rotation
if (param_values[tpidx_STP_HALL] == __TRIAL_SPEAK_YES)
{
// Rotate to sensor if available, otherwise regular rotation
if (param_values[tpidx_STPPOS] == param_values[tpidx_STP_POSITIVE_STPPOS])
actual_steps = rotate_to_sensor(step_size, 1, param_values[tpidx_STPPOS], 1);
else if (param_values[tpidx_STPPOS] ==
((param_values[tpidx_STP_POSITIVE_STPPOS] + 100) % 200))
actual_steps = rotate_to_sensor(step_size, 0, param_values[tpidx_STPPOS], 1);
else if (param_values[tpidx_STPPOS] == 199) {
// Rotate to negative reading on second sensor
actual_steps = rotate_to_sensor(step_size, 0, param_values[tpidx_STPPOS], 2);
} else if (param_values[tpidx_STPPOS] == 100) {
// Rotate to positive reading on second sensor
actual_steps = rotate_to_sensor(step_size, 1, param_values[tpidx_STPPOS], 2);
} else {
// no sensor available
rotate(remaining_rotation);
}
if (actual_steps != remaining_rotation)
{
Serial.print(millis());
Serial.print(" DBG STPERR ");
Serial.println(actual_steps - remaining_rotation);
}
}
else
{
// This is the old rotation function
rotate(remaining_rotation);
}
next_state = MOVE_SERVO;
return 0;
}
int rotate_to_sensor(int step_size, bool positive_peak, long set_position,
int hall_sensor_id)
{ /* Rotate to a position where the Hall effect sensor detects a peak.
step_size : typically 1 or -1, the number of steps to use between checks
positive_peak : whether to stop when a positive or negative peak detected
set_position : will set "sticky_stepper_position" to this afterwards
hall_sensor_id : 1 or 2, depending on which hall sensor to read
*/
bool keep_going = 1;
int sensor;
int prev_sensor = sensor;
int actual_steps = 0;
#ifdef __HWCONSTANTS_H_USE_STEPPER_DRIVER
long nondirectional_steps = 0;
#endif
// Keep track of the previous values
int sensor_history[__HWCONSTANTS_H_SENSOR_HISTORY_SZ] = {0};
int sensor_history_idx = 0;
if (hall_sensor_id == 1) {
sensor = analogRead(__HWCONSTANTS_H_HALL1);
} else if (hall_sensor_id == 2) {
sensor = analogRead(__HWCONSTANTS_H_HALL2);
}
// Store in circular buffer
sensor_history[sensor_history_idx] = sensor;
sensor_history_idx = (sensor_history_idx + 1) %
__HWCONSTANTS_H_SENSOR_HISTORY_SZ;
#ifndef __HWCONSTANTS_H_USE_STEPPER_DRIVER
digitalWrite(TWOPIN_ENABLE_STEPPER, HIGH);
delay(__HWCONSTANTS_H_STP_POST_ENABLE_DELAY);
#endif
#ifdef __HWCONSTANTS_H_USE_STEPPER_DRIVER
#ifdef __HWCONSTANTS_H_INVERT_STEPPER_DIRECTION
// Step forwards or backwards
if (step_size < 0) {
nondirectional_steps = -step_size * __HWCONSTANTS_H_MICROSTEP;
digitalWrite(__HWCONSTANTS_H_STEP_DIR, HIGH);
} else {
nondirectional_steps = step_size * __HWCONSTANTS_H_MICROSTEP;
digitalWrite(__HWCONSTANTS_H_STEP_DIR, LOW);
}
#endif
#ifndef __HWCONSTANTS_H_INVERT_STEPPER_DIRECTION
// Step forwards or backwards
if (step_size < 0) {
nondirectional_steps = -step_size * __HWCONSTANTS_H_MICROSTEP;
digitalWrite(__HWCONSTANTS_H_STEP_DIR, LOW);
} else {
nondirectional_steps = step_size * __HWCONSTANTS_H_MICROSTEP;
digitalWrite(__HWCONSTANTS_H_STEP_DIR, HIGH);
}
#endif
#endif
// iterate till target found
while (keep_going)
{
// Rotate the correct number of steps
#ifdef __HWCONSTANTS_H_USE_STEPPER_DRIVER
for (int i=0; i<nondirectional_steps; i++) {
rotate_one_step();
}
#endif
#ifndef __HWCONSTANTS_H_USE_STEPPER_DRIVER
stimStepper->step(step_size);
#endif
actual_steps += step_size;
// update sensor and store previous value
prev_sensor = sensor;
if (hall_sensor_id == 1) {
sensor = analogRead(__HWCONSTANTS_H_HALL1);
} else if (hall_sensor_id == 2) {
sensor = analogRead(__HWCONSTANTS_H_HALL2);
}
// Store in circular buffer
sensor_history[sensor_history_idx] = sensor;
sensor_history_idx = (sensor_history_idx + 1) %
__HWCONSTANTS_H_SENSOR_HISTORY_SZ;
// test if peak found
if (positive_peak && (prev_sensor > (512 + __HWCONSTANTS_H_HALL_THRESH)) && ((sensor - prev_sensor) < -2))
{
// Positive peak: sensor is high, but decreasing
keep_going = 0;
}
else if (!positive_peak && (prev_sensor < (512 - __HWCONSTANTS_H_HALL_THRESH)) && ((sensor - prev_sensor) > 2))
{
// Negative peak: sensor is low, but increasing
keep_going = 0;
}
// Quit if >400 steps have been taken
if (abs(actual_steps) > 400) {
Serial.print(millis());
Serial.println(" DBG STEPS400");
keep_going = 0;
}
}
// Dump the circular buffer
Serial.print(millis());
Serial.print(" SENH ");
for (int i=0; i<__HWCONSTANTS_H_SENSOR_HISTORY_SZ; i++) {
Serial.print(sensor_history[
(sensor_history_idx + i + 1) % __HWCONSTANTS_H_SENSOR_HISTORY_SZ]);
Serial.print(" ");
}
Serial.println("");
// Undo the last step to reach peak exactly
#ifdef __HWCONSTANTS_H_USE_STEPPER_DRIVER
#ifdef __HWCONSTANTS_H_INVERT_STEPPER_DIRECTION
// Step forwards or backwards
if (step_size < 0) {
digitalWrite(__HWCONSTANTS_H_STEP_DIR, LOW);
} else {
digitalWrite(__HWCONSTANTS_H_STEP_DIR, HIGH);
}
#endif
#ifndef __HWCONSTANTS_H_INVERT_STEPPER_DIRECTION
// Step forwards or backwards
if (step_size < 0) {
digitalWrite(__HWCONSTANTS_H_STEP_DIR, HIGH);
} else {
digitalWrite(__HWCONSTANTS_H_STEP_DIR, LOW);
}
#endif
rotate_one_step();
#endif
// Disable H-bridge to prevent overheating
#ifndef __HWCONSTANTS_H_USE_STEPPER_DRIVER
digitalWrite(TWOPIN_ENABLE_STEPPER, LOW);
#endif
// update to specified position
sticky_stepper_position = set_position;
return actual_steps;
}
int rotate(long n_steps)
{ /* Low-level rotation function
I think positive n_steps means CCW and negative n_steps means CW. It does
on L2, at least.
*/
#ifdef __HWCONSTANTS_H_USE_STEPPER_DRIVER
// This incorporates microstepping and will always be positive
long nondirectional_steps = 0;
#ifdef __HWCONSTANTS_H_INVERT_STEPPER_DIRECTION
// Step forwards or backwards
if (n_steps < 0) {
nondirectional_steps = -n_steps * __HWCONSTANTS_H_MICROSTEP;
digitalWrite(__HWCONSTANTS_H_STEP_DIR, HIGH);
} else {
nondirectional_steps = n_steps * __HWCONSTANTS_H_MICROSTEP;
digitalWrite(__HWCONSTANTS_H_STEP_DIR, LOW);
}
#endif
#ifndef __HWCONSTANTS_H_INVERT_STEPPER_DIRECTION
// Step forwards or backwards
if (n_steps < 0) {
nondirectional_steps = -n_steps * __HWCONSTANTS_H_MICROSTEP;
digitalWrite(__HWCONSTANTS_H_STEP_DIR, LOW);
} else {
nondirectional_steps = n_steps * __HWCONSTANTS_H_MICROSTEP;
digitalWrite(__HWCONSTANTS_H_STEP_DIR, HIGH);
}
#endif
// Rotate the correct number of steps
for (int i=0; i<nondirectional_steps; i++) {
rotate_one_step();
}
#endif
#ifndef __HWCONSTANTS_H_USE_STEPPER_DRIVER
// Enable the stepper according to the type of setup
digitalWrite(TWOPIN_ENABLE_STEPPER, HIGH);
// Sometimes the stepper spins like crazy without a delay here
delay(__HWCONSTANTS_H_STP_POST_ENABLE_DELAY);
// BLOCKING CALL //
// Replace this with more iterations of smaller steps
stimStepper->step(n_steps);
// Disable H-bridge to prevent overheating
delay(__HWCONSTANTS_H_STP_POST_ENABLE_DELAY);
digitalWrite(TWOPIN_ENABLE_STEPPER, LOW);
#endif
// update sticky_stepper_position
sticky_stepper_position = sticky_stepper_position + n_steps;
// keep it in the range [0, 200)
sticky_stepper_position = (sticky_stepper_position + 200) % 200;
return 0;
}
#ifdef __HWCONSTANTS_H_USE_STEPPER_DRIVER
void rotate_one_step()
{ // Pulse the step pin, then delay the specified number of microseconds
digitalWrite(__HWCONSTANTS_H_STEP_PIN, HIGH);
delayMicroseconds(__HWCONSTANTS_H_STEP_HALFDELAY_US /
__HWCONSTANTS_H_MICROSTEP);
digitalWrite(__HWCONSTANTS_H_STEP_PIN, LOW);
delayMicroseconds(__HWCONSTANTS_H_STEP_HALFDELAY_US /
__HWCONSTANTS_H_MICROSTEP);
}
#endif
//// Post-reward state
void StatePostRewardPause::s_finish()
{
next_state = RESPONSE_WINDOW;
}
// The reward states use delay because they need to be millisecond-precise
int state_reward_l(STATE_TYPE& next_state)
{
digitalWrite(L_REWARD_VALVE, HIGH);
delay(param_values[tpidx_REWARD_DUR_L]);
digitalWrite(L_REWARD_VALVE, LOW);
next_state = POST_REWARD_PAUSE;
return 0;
}
int state_reward_r(STATE_TYPE& next_state)
{
digitalWrite(R_REWARD_VALVE, HIGH);
delay(param_values[tpidx_REWARD_DUR_R]);
digitalWrite(R_REWARD_VALVE, LOW);
next_state = POST_REWARD_PAUSE;
return 0;
}
| [
"xrodgers@gmail.com"
] | xrodgers@gmail.com |
dcef0cd68b0c765e0e142e4b7d6c655b2f8725cc | c636136096c92ddb07ce97d3960bf0289d70b57a | /Medusa/MedusaCore/Core/Geometry/Graph/GraphEdge.cpp | 0915a185d893973bb01edc789cfca44e9b3fe5ac | [
"MIT"
] | permissive | johndpope/Medusa | 6a5a08e0c3f216dcab3b23db2f7bcf4d05845bce | 22aa6719a001330fea51a6822fec01150eb8aabc | refs/heads/master | 2020-12-30T20:51:14.718429 | 2015-12-15T12:31:22 | 2015-12-15T12:31:22 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 406 | cpp | // Copyright (c) 2015 fjz13. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
#include "MedusaCorePreCompiled.h"
#include "GraphEdge.h"
MEDUSA_BEGIN;
GraphEdge::GraphEdge(GraphNode* from, GraphNode* to, float weight/*=1.f*/)
:mIndex(0),
mFrom(from),
mTo(to),
mWeight(weight)
{
}
GraphEdge::~GraphEdge()
{
}
MEDUSA_END; | [
"fjz13@live.cn"
] | fjz13@live.cn |
131ca57f219b18a2da74d01f83637ba0c55d0845 | d1540cf8b109d22cd67b7e48908b19f02308d1d1 | /Tugas 9/PreprocessorIncludeFile.cpp | d2f04b59c1fd93a9ae5acdee3bc82c0324967a52 | [] | no_license | Plebs13Slayer/Algoritma-Dan-Pemrograman-2 | fdffd37999706e5dd5193b46ec8da6cff5427e31 | 553d2c6bd3d5ed0f50ac6de93b3f1838664ecfe5 | refs/heads/master | 2021-02-25T05:16:46.307249 | 2020-07-17T13:34:04 | 2020-07-17T13:34:04 | 245,448,672 | 0 | 4 | null | null | null | null | UTF-8 | C++ | false | false | 159 | cpp | #include <iostream>
using namespace std;
#include "process.h"
int main(){
ADD(10, 15);
MULTIPLY(10, 15);
cout<<"Proses Telah Selesai";
}
| [
"noreply@github.com"
] | Plebs13Slayer.noreply@github.com |
08ac3a9914f79d201e47266fbc36e89ec966b69a | 6146923541cd6c16b7d565957251668147767cfd | /system/setFieldsDict | 8777b3cd94478e0425c7e21b42999aafdb8013e7 | [] | no_license | OmarMahfoze17/CCP-WSI | 46f1006e8007ffca1f5a5f5c26cd3a10f5f1ce77 | 0a3c14c3a90d71a402d84e593ca5a893be644a9c | refs/heads/master | 2023-08-03T06:02:46.878919 | 2021-09-17T16:29:05 | 2021-09-17T16:29:05 | 403,786,826 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 922 | /*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 8
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "system";
object setFieldsDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
defaultFieldValues
(
volScalarFieldValue alpha.water 0
);
regions
(
boxToCell
{
box (-.1 0 -1) (.1 .008 1);
fieldValues
(
volScalarFieldValue alpha.water 1
);
}
);
// ************************************************************************* //
| [
"omar-ahmed.mahfoze@stfc.ac.uk"
] | omar-ahmed.mahfoze@stfc.ac.uk | |
6e463a20c9c4af785e7d70cc6bb5d3e87a0a2232 | 66e7e96aeee14bf491e02b369b4cea910f627717 | /CMVS/CMVS_CN_PATCH/dllmain.cpp | 13022418257d056064948d97ba116c1f2a8fef3e | [] | no_license | jszhtian/Fragment | 58416e703596898d57a3de5ec4644b8ee88d7482 | 5f62905e50274bc0ae9f9464eedb1f1d4604e254 | refs/heads/master | 2022-09-28T10:49:53.847423 | 2022-09-17T12:47:23 | 2022-09-17T12:47:23 | 75,670,679 | 48 | 5 | null | null | null | null | UTF-8 | C++ | false | false | 8,182 | cpp | // dllmain.cpp : 定义 DLL 应用程序的入口点。
#include "framework.h"
#include "TransText.h"
DWORD str_off = 0;
CHAR CopyStr[0x1000] = { 0 };
CHAR* FileName = nullptr;
TransText transtext;
wchar_t wout[0x100];
bool isAllAscii(string s)
{
for (unsigned char ch : s)
{
if (ch >> 7) // whether the first bit is 1
{
return false;
}
}
return true;
}
//char trans[] = "友達だと思っていたやつが親に言われて態度を変え、面倒くさいと距離を置き、あげくには教師にまで特別扱いされれば誰だってトラ";
void __stdcall ProcessPushStr(UINT str, UINT off)
{
str_off = off;
if (strlen((char*)(str + off)) == 0)
return;
if (isAllAscii((char*)(str + off)))
return;
//cout << "0x" << hex << off << "|"<< strlen((char*)(str + off)) << "|" << wtoc(ctow((char*)(str + off), 932), 936) << endl;
#if(0)
//TODO: Add Func Map
str_off = off;
cout << "0x" << hex << off << "|" << wtoc(ctow((char*)(str + off), 932), 936) << endl;
///*
if (off == 0x980)
{
lstrcpyA(CopyStr, "- 心1 -");
str_off = (UINT)CopyStr - str;
}
else if (off == 0x8E4)
{
lstrcpyA(CopyStr, "中文测试123ABCabc");
str_off = (UINT)CopyStr - str;
}
else if (off == 0x8F3)
{
lstrcpyA(CopyStr, "中文测试");
str_off = (UINT)CopyStr - str;
}
else if (off == 0x16C)
{
lstrcpyA(CopyStr, "库洛的时钟");
str_off = (UINT)CopyStr - str;
}
// */
#endif
#if(0)
if (off == 0x980)
{
lstrcpyA(CopyStr, "- 心1 -");
str_off = (UINT)CopyStr - str;
}
else if (off == 0x8E4)
{
lstrcpyA(CopyStr, "中文测试123ABCabc");
str_off = (UINT)CopyStr - str;
}
else if (off == 0x8F3)
{
lstrcpyA(CopyStr, "中文测试");
str_off = (UINT)CopyStr - str;
}
else if (off == 0x16C)
{
lstrcpyA(CopyStr, "库洛的时钟");
str_off = (UINT)CopyStr - str;
}
else
{
strcpy(CopyStr, trans);
str_off = (UINT)CopyStr - str;
}
#endif
#if(1)
auto newText = transtext.Query((char*)(str + off), off);
if (newText.length() != 0)
{
if (newText.length() > 0x78)
{
cout << "OOM: 0x" << hex << off << " | " << wtoc(ctow((char*)(str + off), 932), 936) << endl;
}
else
{
lstrcpyA(CopyStr, newText.c_str());
str_off = (UINT)CopyStr - str;
//cout << "Replace: 0x" << hex << off << " | " << wtoc(ctow((char*)(str + off), 932), 936) << endl;
}
}
else
{
cout << "Skip 0x" << hex << str_off << " | " << wtoc(ctow((char*)(str + off), 932), 936) << endl;
}
#endif
return;
}
PVOID HookAddr_pPorcessPushStr = (PVOID)0x458282;
PVOID JmpOut_pPorcessPushStr = (PVOID)0x458289;
__declspec(naked)void ASM_ProcessPushStr()
{
__asm
{
mov ecx, dword ptr ds : [esi + edx * 4 + 0x3AFC] ;
pushad;
pushfd;
push eax;
push ecx;
call ProcessPushStr;
popfd;
popad;
mov eax, str_off;
jmp JmpOut_pPorcessPushStr
}
}
PVOID HookAddr_pPorcessPushStr2 = (PVOID)0x45E570;
PVOID JmpOut_pPorcessPushStr2 = (PVOID)0x45E577;
__declspec(naked)void ASM_ProcessPushStr2()
{
__asm
{
mov eax, dword ptr ds : [ecx + eax * 4 + 0x3AFC] ;
pushad;
pushfd;
push edx;
push eax;
call ProcessPushStr;
popfd;
popad;
mov edx, str_off;
jmp JmpOut_pPorcessPushStr2
}
}
PBYTE NTAPI LoadImageRedirect(LPCSTR lpFileName, LPBYTE Buffer)
{
//TODO: FileIO
PBYTE ImageBuffer;
SIZE_T Size;
ImageBuffer = NULL;
Size = 0;
static wchar_t fnmbuffer[256];
memset(fnmbuffer, 0, sizeof(wchar_t) * 256);
static wchar_t filePath[256];
memset(filePath, 0, sizeof(wchar_t) * 256);
if (lpFileName)
{
size_t nu = strlen(lpFileName);
size_t n = (size_t)MultiByteToWideChar(CP_ACP, 0, lpFileName, int(nu), NULL, 0);
memset(fnmbuffer, 0, sizeof(wchar_t) * 256);
MultiByteToWideChar(CP_ACP, 0, lpFileName, int(nu), fnmbuffer, int(n));
}
wcscpy(filePath, L"project\\");
wcscat(filePath, fnmbuffer);
wcscat(filePath, L".bmp");
HANDLE pFile = CreateFile(filePath, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (pFile == INVALID_HANDLE_VALUE)
{
cout << "SKIP_IMG:" << lpFileName << endl;
return Buffer;
}
auto fileSize = GetFileSize(pFile, NULL);
ImageBuffer = new BYTE[fileSize];
ReadFile(pFile, ImageBuffer, fileSize, &Size, NULL);
memcpy(Buffer, ImageBuffer + 0x36, Size - 0x36);
CloseHandle(pFile);
delete[] ImageBuffer;
cout << "REPLACE_IMG:" << lpFileName << endl;
return Buffer;
}
LPVOID DetouredLoadImage_Start = (LPVOID)0x0050BE46;
__declspec(naked) VOID DetouredLoadImage()
{
__asm
{
mov eax, dword ptr[esp + 0x15C]
pushad
push ebx
push eax
call LoadImageRedirect
popad
; original code here
pop edi
pop esi
pop ebp
mov eax, ebx
pop ebx
add esp, 0x48
retn 0xC
}
}
void InlinePatch()
{
DetourTransactionBegin();
DetourAttach(&HookAddr_pPorcessPushStr, ASM_ProcessPushStr);
DetourAttach(&HookAddr_pPorcessPushStr2, ASM_ProcessPushStr2);
DetourAttach(&DetouredLoadImage_Start, DetouredLoadImage);
if (DetourTransactionCommit() != NOERROR)
{
MessageBox(NULL, L"Patch hook error", L"Patch", MB_OK | MB_ICONERROR);
ExitProcess(-1);
}
}
PVOID g_pOldCreateFontA = CreateFontA;
typedef HFONT (WINAPI* PfuncCreateFontA)(int nHeight,
int nWidth,
int nEscapement,
int nOrientation,
int fnWeight,
DWORD fdwltalic,
DWORD fdwUnderline,
DWORD fdwStrikeOut,
DWORD fdwCharSet,
DWORD fdwOutputPrecision,
DWORD fdwClipPrecision,
DWORD fdwQuality,
DWORD fdwPitchAndFamily,
LPCTSTR lpszFace);
HFONT WINAPI HookCreateFontA(int nHeight,
int nWidth,
int nEscapement,
int nOrientation,
int fnWeight,
DWORD fdwltalic,
DWORD fdwUnderline,
DWORD fdwStrikeOut,
DWORD fdwCharSet,
DWORD fdwOutputPrecision,
DWORD fdwClipPrecision,
DWORD fdwQuality,
DWORD fdwPitchAndFamily,
LPCTSTR lpszFace)
{
return CreateFontW(nHeight,
nWidth,
nEscapement,
nOrientation,
fnWeight,
fdwltalic,
fdwUnderline,
fdwStrikeOut,
GB2312_CHARSET,
fdwOutputPrecision,
fdwClipPrecision,
fdwQuality,
fdwPitchAndFamily,
L"SimHei");
}
PVOID g_pOldSetWindowTextA = SetWindowTextA;
typedef bool (WINAPI* PfuncSetWindowTextA)(HWND hWnd, LPCSTR lpString);
bool WINAPI HookSetWindowTextA(HWND hw, LPCSTR lpString)
{
//cout << lpString << endl;
for (int i = 0; i < lstrlenA(lpString);)
{
UINT c1 = lpString[i] & 0xFF;
if (c1 == 0x81 && (UINT)lpString[i + 1] == 0x40)
{
memcpy((void*)(lpString + i), "\xA1\xA1", 2);
i += 2;
}
else
i++;
}
return ((PfuncSetWindowTextA)g_pOldSetWindowTextA)(hw, lpString);
}
void Init()
{
DetourTransactionBegin();
DetourAttach(&g_pOldCreateFontA, HookCreateFontA);
DetourAttach(&g_pOldSetWindowTextA, HookSetWindowTextA);
DetourTransactionCommit();
}
BOOL APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
make_console();
InlinePatch();
Init();
transtext.LoadFromFile();
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
extern "C" __declspec(dllexport) void dummy(void) {
return;
}
| [
"jszhtian@hotmail.com"
] | jszhtian@hotmail.com |
cf3d672edc41aee1e64c97c1c6856dcd849f8a15 | 617a25be1df450b4eea55c12440315268adde10d | /MyFieldWidget.h | fefd9fafeecabaa1adcfd082683b8cc0a2014801 | [] | no_license | ZhangMingdong/TrendDetectionVis | 34250407efd675bd8ca8fe4e64a7ab7b8152740c | 9a0aa01b2023250d1b0f3a42f525e33ba501957b | refs/heads/master | 2021-08-29T16:16:12.815141 | 2017-12-13T05:51:44 | 2017-12-13T05:51:44 | 111,173,115 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 816 | h | #pragma once
#include "def.h"
#include "ContourGenerator.h"
#include "EnsembleIntersections.h"
#include "GLFont.h"
#include "MyGLWidget.h"
#include "Field2D.h"
#include<vector>
#include<unordered_map>
class MeteModel;
class MyFieldWidget : public MyGLWidget
{
Q_OBJECT
public:
MyFieldWidget(QWidget *parent = 0);
~MyFieldWidget();
protected:
MeteModel* _pModelE = NULL;
int _nCurrentGroup = 0;
public:
void SetModelE(MeteModel* pModelE);
protected:
// paint the content
virtual void paint();
virtual void init();
protected:
virtual void mouseDoubleClickEvent(QMouseEvent *event);
//================2dField================
FIELD2D::Field2D* _pField = NULL;
int _nGridWidth=0;
int _nGridHeight=0;
int _nEns=0;
// generate sequences for trend detection -- ensembles
void generateField();
};
| [
"zhangmingdong0408@gmail.com"
] | zhangmingdong0408@gmail.com |
14c1001ee14a348d2de96127e009ee027027471a | d5f97a6069977aced6cd9736bf26afe2709b359f | /C++/Algorithm/Dynamic programming/6_count_all_palindrom_substring.cpp | c4a065bfca6fbaf507ac30921227b0b084d56b62 | [] | no_license | aayushrai/Data_Structure_And_Algorithm | 3bd159256f2a996e298b66c4f9bcd681d19bf056 | 99ee16acf2a5546b0dec56f25eeb23c9476861b9 | refs/heads/master | 2023-07-13T02:54:05.907882 | 2021-08-23T11:19:25 | 2021-08-23T11:19:25 | 203,412,716 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,017 | cpp |
// memoization (top down approach)
// create all the possible substring
// example aba -> a,ab,aba,b,ba,a
// for each string each string is palindrom or not, if palindrom then increament the counter
// the function which checking string ispalindrom we apply memoization in that
// abba -> check for a__a , -> then we check for _bb_
// bb is already checked before for palindrom so we use memoization for that to save time
// #include<iostream>
// #include<bits/stdc++.h>
// using namespace std;
// vector<vector<int>> dp;
// int isPalindrom(int i,int j,string S,int N){
// if(i>j)
// return 1;
// if(dp[i][j]!=-1)
// return dp[i][j];
// if(S[i]==S[j])
// return dp[i][j] = isPalindrom(i+1,j-1,S,N);
// return dp[i][j]=0;
// }
// int CountAllPalindromSubstring(string S, int N)
// {
// dp.resize(N,vector<int>(N,-1));
// int count = 0;
// for(int i=0;i<N;i++){
// for(int j=i;j<N;j++){
// cout << i << " " << j << endl;
// if(isPalindrom(i,j,S,N)){
// count++;
// }
// }
// }
// return count;
// }
// int main(){
// string s = "abaab";
// cout << CountAllPalindromSubstring(s,s.length());
// return 0;
// }
//--------------------------------------------------------------------------------------------------------------------------------------------------
// tabulation (bottom up approach)
// a b c b
// a T F F F
// b x T F T
// c x x T F
// b x x x T
//
// row 0 col 0 say start from a and end at a
// row 0 col 1 say start from a and end at b
// row 1 col 1 say start from b and end at b
// 5 palindrom a,b,c,d,bcb (all the T is table is palindrom)
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
vector<vector<bool>> dp;
int CountAllPalindromSubstring(string S, int N)
{
dp.resize(N,vector<bool>(N,false));
int count = 0;
for(int col=0;col<N;col++){
for(int start=0,end=col;start<N,end<N;start++,end++){
// length 1 palindrom
if(start==end){
dp[start][end] = true;
count++;
}
// length 2 palindrom
else if(col == 1){
if(S[start] == S[end]){
dp[start][end] = true;
count++;
}
else{
dp[start][end] = false;
}
}
// length greater then 2
else if(S[start] == S[end]){
dp[start][end] = dp[start+1][end-1];
if(dp[start][end]){
count++;
}
}
else if(S[start] != S[end]){
dp[start][end] = false;
}
}
}
return count;
}
int main(){
string s = "abbaeae";
cout << CountAllPalindromSubstring(s,s.length());
return 0;
}
| [
"www.aayushrai@gmail.com"
] | www.aayushrai@gmail.com |
d4f198d4e28f907e476b92e736382c50b73a813b | 6d4453247bc38b8bd3b8f73c4e3cd2a6d6f2d790 | /ceng242 - Programming Languages/242-3/pokemon.h | 09eaab2dc4b5dea507ab5946de7fdcc1b6e8143e | [] | no_license | ArthurDayne24/metu-ceng-hws | eff99539b150f7485478dfe2cab712f6f7630a2c | 8b3f22237305610230786803cc1277a836aef2b5 | refs/heads/master | 2020-12-09T21:20:01.845857 | 2019-05-05T17:45:12 | 2019-05-05T17:45:12 | 233,419,683 | 2 | 0 | null | 2020-01-12T16:08:42 | 2020-01-12T16:08:41 | null | UTF-8 | C++ | false | false | 701 | h | #ifndef POKEMON_H
#define POKEMON_H
#include <string>
using namespace std;
class Pokemon
{
private:
string name;
string type;
int numberOfExperiences;
int evolutionBound;
friend bool decide(const Pokemon & pk1, const Pokemon & pk2);
public:
mutable int t_ref_cnt; //stores how many trainers have this pokemon
Pokemon(const string &, const string &, int);
Pokemon(const Pokemon &);
~Pokemon();
const string & getName() const;
bool operator>>(const Pokemon &);
friend Pokemon operator&(Pokemon &, Pokemon &);
Pokemon& operator=(const Pokemon &);
};
#endif
| [
"onur.tirtir@ceng.metu.edu.tr"
] | onur.tirtir@ceng.metu.edu.tr |
7ada1ebe8636f9d0a55f827b35795629595e5d2e | 2f046ba12c84472c0369f7274a9c45fa0718b48f | /lib-network/src/linux/networktcp.cpp | 012b138cfe42aff41df0fed028c11d7a815f7aa9 | [
"MIT"
] | permissive | Kamal-Sonani/GD32207C-EVAL-board-DMX512-RDM | 3beaf3390f78925d0465ad56f6e400cda842a6f8 | 354ba04c02aa99c47138232c01b5f12ba74a54ab | refs/heads/main | 2023-09-03T14:26:12.402763 | 2021-11-09T11:06:34 | 2021-11-09T11:06:34 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,008 | cpp | /*
* network.cpp
*
* Should move to lib-network
*
*/
#include <stdio.h>
#include <string.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <poll.h>
#include <cassert>
#include "network.h"
#define MAX_PORTS_ALLOWED 2
#define MAX_SEGMENT_LENGTH 1400
static uint16_t s_ports_allowed[MAX_PORTS_ALLOWED];
static struct pollfd pollfds[MAX_PORTS_ALLOWED][2];
static uint8_t s_ReadBuffer[MAX_SEGMENT_LENGTH];
int32_t Network::TcpBegin(uint16_t nLocalPort) {
int32_t i;
for (i = 0; i < MAX_PORTS_ALLOWED; i++) {
if (s_ports_allowed[i] == nLocalPort) {
perror("TcpBegin: connection already exists");
return -2;
}
if (s_ports_allowed[i] == 0) {
break;
}
}
if (i == MAX_PORTS_ALLOWED) {
perror("TcpBegin: too many connections");
return -1;
}
s_ports_allowed[i] = nLocalPort;
memset(&pollfds[i], 0, sizeof(pollfds));
int serverfd = socket(AF_INET, SOCK_STREAM, 0);
if (serverfd == -1) {
perror("Could not create socket");
return -1;
}
int flag = 1;
if (-1 == setsockopt(serverfd, SOL_SOCKET, SO_REUSEADDR, &flag, sizeof(flag))) {
perror("setsockopt fail");
}
struct sockaddr_in server;
server.sin_family = AF_INET;
server.sin_addr.s_addr = INADDR_ANY;
server.sin_port = htons(nLocalPort);
if (bind(serverfd, (struct sockaddr*) &server, sizeof(server)) < 0) {
perror("bind failed");
return -2;
}
listen(serverfd, 0);
pollfds[i][0].fd = serverfd;
pollfds[i][0].events = POLLIN | POLLPRI;
printf("Network::TcpBegin -> i=%d\n", i);
return i;
}
int32_t Network::TcpEnd(const int32_t nHandle) {
assert(nHandle < MAX_PORTS_ALLOWED);
close(pollfds[nHandle][0].fd);
close(pollfds[nHandle][1].fd);
return -1;
}
uint16_t Network::TcpRead(const int32_t nHandle, const uint8_t **ppBuffer) {
assert(nHandle < MAX_PORTS_ALLOWED);
const int poll_result = poll(pollfds[nHandle], 2, 0);
if (poll_result <= 0) {
return poll_result;
}
if (pollfds[nHandle][0].revents & POLLIN) {
struct sockaddr_in client;
int c = sizeof(struct sockaddr_in);
const int clientfd = accept(pollfds[nHandle][0].fd, (struct sockaddr*) &client, (socklen_t*) &c);
if (clientfd < 0) {
perror("accept failed");
return clientfd;
}
pollfds[nHandle][1].fd = clientfd;
pollfds[nHandle][1].events = POLLIN | POLLPRI;
}
if ((pollfds[nHandle][1].fd > 0) && (pollfds[nHandle][1].revents & POLLIN)) {
const int bytes = read(pollfds[nHandle][1].fd, s_ReadBuffer, MAX_SEGMENT_LENGTH);
if (bytes <= 0) {
perror("read failed");
pollfds[nHandle][1].fd = 0;
pollfds[nHandle][1].events = 0;
pollfds[nHandle][1].revents = 0;
} else {
*ppBuffer = reinterpret_cast<uint8_t*>(&s_ReadBuffer);
return static_cast<uint16_t>(bytes);
}
}
return 0;
}
void Network::TcpWrite(const int32_t nHandle, const uint8_t *pBuffer, uint16_t nLength) {
assert(nHandle < MAX_PORTS_ALLOWED);
const int c = write(pollfds[nHandle][1].fd, pBuffer, nLength);
if (c < 0) {
perror("write");
}
}
| [
"arjan.van.vught@gmail.com"
] | arjan.van.vught@gmail.com |
a477968d480527c30e8d3bba77cdf534e1b6110e | 9e491b20094318b48571c0750dee875b09c69c86 | /Задание_4/Задание_4.cpp | 643ffad975685c7a92a81ea46d47376125fe8d66 | [] | no_license | Maxytrewq312/Lab_Rab5 | 72fd066ab5c4ea26df3e88065e70e6be4e74663e | 51fb0a362dc0a9cbc9abb6414225e75cf65ef4f6 | refs/heads/master | 2023-01-03T22:36:34.937239 | 2020-10-27T14:00:17 | 2020-10-27T14:00:17 | 307,718,249 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 465 | cpp | // Задание_4.cpp : Этот файл содержит функцию "main". Здесь начинается и заканчивается выполнение программы.
//
#include <iostream>
using namespace std;
int main()
{
setlocale(0, "");
double const PI = 3.141592653589793;
double R;
cout << "Введите радиус: ";
cin >> R;
double S = PI * (R * R);
cout << "Площадь круга равна: " << S;
return 0;
}
| [
"Максим@DESKTOP-TSPOI6V"
] | Максим@DESKTOP-TSPOI6V |
a5f6a470878fa209cf4f6f09678f12dc4b6aa7ef | 753cf6d6998732a371fafc0223e5717fa9f35a21 | /src/model/include/room.h | 3fe0b8948de17ca742d1ce1e9d2f06c2f5afb9e3 | [] | no_license | eeng321/Adventure2016 | ae2470450c8637072d3f8530d67bfdf8a35e5107 | 3a2257163e4934a960757bfb5541385f9bead3c8 | refs/heads/master | 2020-04-29T00:50:20.926124 | 2019-03-17T08:47:26 | 2019-03-17T08:47:26 | 175,710,013 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,860 | h | //room.h
#ifndef ROOM_H
#define ROOM_H
#include <string>
#include <vector>
#include <memory>
#include "door.h"
#include "id.h"
#include "extendedDescription.h"
class RoomModel;
class Room {
private:
std::string area;
roomId id;
std::string name;
std::vector<std::string> mainDescription;
std::vector<extendedDescription> extendedDescriptions;
std::vector<Door> doors;
std::vector<npcId> npcList;
std::vector<std::string> playerList;
std::vector<itemId> itemList;
bool navigable;
public:
Room();
Room(const std::string& areaIn,
const roomId& idIn,
const std::string& nameIn,
const std::vector<std::string>& descriptionIn,
const std::vector<extendedDescription>& extendedDescriptionsIn,
const std::vector<Door>& doorsIn,
const std::vector<npcId>& npcListIn,
const std::vector<std::string>& playerListIn,
const std::vector<itemId>& itemListIn,
bool navigabilityIn);
Room(const std::string& areaIn,
const roomId& idIn,
const std::string& nameIn,
const std::vector<std::string>& descriptionIn,
const std::vector<extendedDescription>& extendedDescriptionsIn,
const std::vector<Door>& doorsIn);
void build(const std::string& areaIn,
const roomId& idIn,
const std::string& nameIn,
const std::vector<std::string>& descriptionIn,
const std::vector<extendedDescription>& extendedDescriptionIn,
const std::vector<Door>& doorsIn,
const std::vector<npcId>& npcListIn,
const std::vector<std::string>& playerListIn,
const std::vector<itemId>& itemListIn,
bool navigabilityIn);
void build(const std::string& areaIn,
const roomId& idIn,
const std::string& nameIn,
const std::vector<std::string>& descriptionIn,
const std::vector<extendedDescription>& extendedDescriptionIn,
const std::vector<Door>& doorsIn,
bool navigabilityIn);
void setModel(const RoomModel& model);
RoomModel getModel() const;
std::string getArea() const;
std::vector<std::string> getDescription() const;
roomId getId() const;
std::string getName() const;
std::vector<extendedDescription> getExtendedDescriptions() const;
std::vector<std::string> getExtendedDescriptionByKey(std::string key) const;
std::vector<Door> getDoors() const;
std::vector<npcId> getNpcList() const;
std::vector<std::string> getPlayerList() const;
std::vector<itemId> getItemList() const;
/* Navigation management */
void makeUnnavigable();
void makeNavigable();
bool isNavigable() const;
/* Player Management */
void addPlayer(std::string player);
void removePlayer(std::string player);
roomId getRoomInDirection(Direction d) const;
Door getDoor(Direction d) const;
/* NPC management */
void addNpc(npcId npc);
void removeNpc(npcId npc);
/* Object management */
void addItem(itemId item);
void removeItem(itemId item);
};//Room class
#endif | [
"bha33@sfu.ca"
] | bha33@sfu.ca |
739e64683f118c3c5d625fdfbe2fb6a62b66ea93 | 93deb00f6967a21639a97d788932fa8b9386802d | /ThayXuan/[VuAnhHuy][FM].cpp | 9d70941ca48ae31e2ae23763daea33834d90ecba | [] | no_license | yakuza-h/cpp | 54f07d4e3a44ec1eb3ac34f778bc224d1f12c2ab | 48e09ac64b1ea8ed3051fa8e7b776d8ba8505b90 | refs/heads/master | 2022-03-29T14:27:11.608876 | 2020-02-03T05:48:56 | 2020-02-03T05:48:56 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 414 | cpp | #include <bits/stdc++.h>
using namespace std;
long long n,m,a[1000001],ans;
int main () {
freopen ("FM.INP","r",stdin);
freopen ("FM.OUT","w",stdout);
cin >> n >> m;
for (int i = 1; i <= n; i ++) cin >> a[i];
ans = 0;
sort(a+1,a+1+n);
for (int i = 1; i <= n; i ++) {
long long j = upper_bound(a+1,a+1+n,m-a[i])-a;
j --;
ans += j;
if (j >= i) ans --;
}
ans /= 2;
cout << ans;
}
| [
"vuanhhuyhl@gmail.com"
] | vuanhhuyhl@gmail.com |
b478f2b0005fc6c7a7354243a4b5cf13ff2a5b07 | e046dd9c2921c03b097104d74890795f54565f1d | /Course.h | 07478c5480309f9fa5c120eb26f8092435139aaf | [] | no_license | SakshamSharma1/Timetable-automation-using-genetic-algorithm | c8e21c7ba0e8ecbee73f7da7d0f8628d8d2e4303 | 8ed8f783d91e956b08f1170198a1e628491e1736 | refs/heads/master | 2020-05-21T06:37:16.750521 | 2019-05-10T08:30:13 | 2019-05-10T08:30:13 | 185,949,066 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 276 | h | #include <string>
using namespace std;
class Course
{
private:
int _id;
string _name;
public:
Course(int id, const string& name);
inline int GetId() const { return _id; }
inline const string& GetName() const { return _name; }
};
| [
"noreply@github.com"
] | SakshamSharma1.noreply@github.com |
63b9704678560e92832b277f5c248fd82cd2deeb | 8d8467edb812bf829602db4dcc39ff4085268ef5 | /include/motion_primitive_library/primitive/poly_solver.h | dcc8ccd0d90c6e2a51559b2391775201c6c47782 | [
"Apache-2.0"
] | permissive | SiChiTong/motion_primitive_library | e3648f49507001770954714d390bad07f52e7b7c | 12a5a59132b714956018d271747010e88476b583 | refs/heads/master | 2021-05-02T15:14:31.565963 | 2018-02-07T23:50:31 | 2018-02-07T23:50:31 | 120,692,418 | 3 | 1 | null | 2018-02-08T01:07:30 | 2018-02-08T01:07:30 | null | UTF-8 | C++ | false | false | 1,349 | h | /**
* @file poly_solver.h
* @brief Trajectory generator back-end
*/
#ifndef POLY_SOLVER_H
#define POLY_SOLVER_H
#include <stdio.h>
#include <iostream>
#include <memory>
#include <Eigen/Core>
#include <Eigen/StdVector>
#include <Eigen/LU>
#include <motion_primitive_library/primitive/poly_traj.h>
/**
* @brief Trajectory generator back-end class
*
* Given intermediate waypoints and associated time allocation, generate the n-th order polynomials
*/
class PolySolver {
public:
/**
* @brief Simple constructor
* @param smooth_derivative_order The max derivative we want continuous
* @param minimize_derivative The derivative to minimize
*/
PolySolver(unsigned int smooth_derivative_order,
unsigned int minimize_derivative);
/**
* @brief Solve the trajector as defined in constructor
* @param waypoints Intermediate waypoints that the trajectory pass through
* @param dts Time allocation for each segment
*
* Note that the element in dts is the time for that segment
*/
bool solve(const std::vector<Waypoint>& waypoints,
const std::vector<decimal_t> &dts);
///Get the solved trajectory
std::shared_ptr<PolyTraj> getTrajectory();
private:
unsigned int N_;
unsigned int R_;
bool debug_;
std::shared_ptr<PolyTraj> ptraj_;
};
#endif
| [
"lskwdlskwd@gmail.com"
] | lskwdlskwd@gmail.com |
4de45d5bdc8ad90f309a2ce5312aa2edf19755f3 | d7e7dfa5fcd6365350d2457453ffec6bdaa9e795 | /src/mqttthread.hpp | b9b47a4f32782e4a2463265b561a4e0e24cd2aab | [] | no_license | hairymnstr/mqttalk | 31a43804d39a3554e40a7b329b84758641edfbcf | fde27514e82344b167bc6d351f21760556ec483d | refs/heads/master | 2021-01-18T20:30:18.470607 | 2019-10-20T15:35:48 | 2019-10-20T15:35:48 | 30,833,616 | 0 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 617 | hpp | #include <QObject>
#include <QString>
#ifndef MQTTTHREAD_H_
#define MQTTTHREAD_H_
class MQTTThread : public QObject {
Q_OBJECT
public:
virtual ~MQTTThread();
void onConnect(struct mosquitto *mosq, int result);
void onMessage(struct mosquitto *mosq, const struct mosquitto_message *message);
void onSubscribe(struct mosquitto *mosq, int mid, int qos_count, const int *granted_qos);
public slots:
void startUp(QString hostname, int port, QString username);
void stop();
signals:
void messageReceived(struct mosquitto_message *message);
private:
bool stopThread;
};
#endif /* ifndef MQTTTHREAD_H_ */
| [
"nathan@nathandumont.com"
] | nathan@nathandumont.com |
1083bc37ffcf6b77457c1b6125bf0d8d19292f11 | c8bb140f3bce3ca44eb31d8a7ba99a5151e2a51e | /Mattrix/src/CalculationUtil/src/Expression.cpp | ade2103cd671ec641c22961c6a576cb9d09c40de | [] | no_license | MHokinson38/Mattrix | 6f8114cf7bfc98b0949640e0d9748f9960b27aec | 5f6a5371acd99063b110bd20fcc6e26d3fa98b81 | refs/heads/master | 2020-12-21T18:11:11.823123 | 2020-01-27T15:39:55 | 2020-01-27T15:39:55 | 236,517,788 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,641 | cpp | //
// Expression.cpp
// Mattrix
//
// Created by Matthew Hokinson on 11/30/19.
//
//Libraries
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <exception>
//My Files
#include <CalculationUtil/interface/Operations/Operation.h>
#include <CalculationUtil/interface/Operations/OperationType.h>
#include <CalculationUtil/interface/Operations/ArithmeticOperation.h>
#include <CalculationUtil/interface/Operations/FunctionalOperation.h>
#include <CalculationUtil/interface/Expression.h>
#include <MatrixUtil/interface/Matrix.h>
#include <MatrixUtil/interface/Exceptions/InvalidSyntaxException.h>
#include <RandomUtils/interface/CoolUtilities.h>
//==================
// Constructors
//==================
CalculationUtil::Expression::Expression(const std::string & input) {
setInputLine(input);
}
//==================
// Setup
//==================
void CalculationUtil::Expression::setInputLine(const std::string &input) {
reset();
inputLine = input;
RandomUtils::removeWhiteSpace(inputLine);
RandomUtils::removeExcessParentheses(inputLine); //Takes off parentheses in from and back in needed
getBaseOperation();
parseInputLine();
}
void CalculationUtil::Expression::reset() {
internalExpressions.clear();
operations.clear();
}
//==================
// Evaluation
//==================
MatrixUtil::Matrix CalculationUtil::Expression::evaluate() {
if(isBase) {
return baseMatrix; //This is the "base case for recursion"
}
else if(baseOperation.isFunctional()) {
//If the base operation is functional, there should only be two internal expressions
// The base, and the exponent
if(internalExpressions.size() > 2) {
throw MatrixUtil::InvalidSyntaxException("Invalid Syntax");
}
MatrixUtil::Matrix base = internalExpressions[0].evaluate();
Operation* opToPerform = baseOperation.isTranspose() ?
new FunctionalOperation(baseOperation, base) :
new FunctionalOperation(baseOperation, base,
internalExpressions[1].evaluate().getScalarValue());
return opToPerform->perform();
}
else {
MatrixUtil::Matrix currentResult = internalExpressions[0].evaluate();
for(int i = 0; i < internalExpressions.size() - 1; ++i) {
Operation* opToPerform = new ArithmeticOperation(operations[i],
currentResult,
internalExpressions[i+1].evaluate());
currentResult = opToPerform->perform();
}
return currentResult;
}
}
//==================
// Parsing
//==================
void CalculationUtil::Expression::getBaseOperation() {
int numOpenParentheses = 0;
bool hasParenthese = false;
OperationType lowestOp(OperationType::OpType::empty);
for(int i = 0; i < inputLine.size(); ++i) {
if(inputLine[i] == INVERSE_CHARACTER && i == 0) {
continue; //This is a minus sign, not subtraction (i.e. -5)
}
if(inputLine[i] == OPENING_PARENTHESE) {
hasParenthese = true;
numOpenParentheses++;
}
else if(inputLine[i] == CLOSING_PARENTHESE) {
numOpenParentheses--;
}
else if(OperationType::isOperationCharacter(inputLine[i]) && numOpenParentheses == 0) {
if(OperationType::getPemdasFromChar(inputLine[i]) < lowestOp.getHierarchyLevel()) {
if(OperationType(inputLine[i]).getOperation() == OperationType::OpType::subtract &&
OperationType(inputLine[i-1]).getOperation() == OperationType::OpType::exponent) {
continue;
}
else if(OperationType(inputLine[i]).getOperation() == OperationType::OpType::transpose &&
i == 0) {
continue;
}
lowestOp = OperationType(inputLine[i]);
}
// Going to use try to avoid putting in extra bounds check and will catch out of bounds
if(lowestOp.isExponent()) {
try {
if(inputLine[i+1] == TRANSPOSE_CHARACTER) {
lowestOp = OperationType(OperationType::OpType::transpose);
}
}
catch(const std::out_of_range & excp) {
continue; //Do nothing, just thought this would be cooler than manual bounds check
}
}
}
}
//Do Parentheses Syntax Check
if(numOpenParentheses != 0) {
throw MatrixUtil::InvalidSyntaxException("Invalid Parentheses!");
}
isBase = lowestOp.isNull() && !hasParenthese;
baseOperation = lowestOp;
}
void CalculationUtil::Expression::parseInputLine() {
std::string newPartialExp = "";
if(isBase) {
baseMatrix = MatrixUtil::Matrix(inputLine);
}
else {
std::string currentInternalExp = "";
int numOpenParentheses = 0;
for(int i = 0; i < inputLine.size(); ++i) {
if(inputLine[i] == OPENING_PARENTHESE) {
numOpenParentheses++;
}
else if(inputLine[i] == CLOSING_PARENTHESE) {
numOpenParentheses--;
}
else if(OperationType::isOperationCharacter(inputLine[i]) &&
OperationType(inputLine[i]).getHierarchyLevel() == baseOperation.getHierarchyLevel() &&
numOpenParentheses == 0) {
internalExpressions.push_back(Expression(currentInternalExp));
operations.push_back(OperationType(inputLine[i]));
currentInternalExp = "";
if(baseOperation.isTranspose()) {break;} //We are going to ignore the T
continue;
}
currentInternalExp += inputLine[i];
if(i == (inputLine.size() - 1)) {
internalExpressions.push_back(Expression(currentInternalExp));
}
}
}
}
//==================
// Stream overloads
//==================
std::istream& CalculationUtil::operator>>(std::istream& is, Expression & exp) {
std::string inputLine = "";
char currentChar;
while(is.get(currentChar)) {inputLine += currentChar;}
exp = Expression(inputLine);
return is;
}
| [
"matthew@hokinson.com"
] | matthew@hokinson.com |
13c680de8f3cff1e42ebe539300b80771791881a | d158de2ad6ce474eaf425ddb3d16a768a62d01d9 | /devc_v2/datastructues/knap_sack_using_profit_weight_ration.cpp | 4898d441e38224c29b1159adca23d42080395f3f | [] | no_license | VijayNandakumarkumar/CodingPractise | 4cc3eb91590890788a0e18bbcb77375c0c4b51a5 | 32cc3601dc2a3d55ccdbafb2d3673ec330f1fd16 | refs/heads/master | 2022-10-07T23:21:42.951250 | 2022-10-05T17:32:32 | 2022-10-05T17:32:32 | 215,368,848 | 1 | 1 | null | 2020-12-08T20:48:17 | 2019-10-15T18:27:22 | C++ | UTF-8 | C++ | false | false | 1,027 | cpp | /*
Coded by following algo of abul dahir.
*/
#include<bits/stdc++.h>
using namespace std;
typedef pair<int, int> ipair;
int knap_sack_wpr(vector<pair<double, ipair> > &wp, int W) {
int max_profit = INT_MIN;
do {
int w = 0, i = 0, p=0;
for(int i=0;i<(int)wp.size() && w<=W;i++){
if ((w + wp[i].second.first) <= W) {
cout<<"weight = "<<w<<" profit = "<<p<<"\n";
w += wp[i].second.first;
p += wp[i].second.second;
}
}
max_profit = max(max_profit, p);
cout<<"profit = "<<p<<"max_profit = "<<max_profit<<"\n";
}while(next_permutation(wp.begin(), wp.end()));
return max_profit;
}
int main(){
vector<int> vt{60, 100, 120};
vector<int> wt{10, 20, 30};
vector<pair<double, ipair> > wp;
for (int i = 0;i<(int)wt.size();i++) {
double wpr = vt[i]/wt[i];
wp.push_back({wpr, {wt[i], vt[i]}});
}
int W = 50;
sort(wp.begin(), wp.end());
cout<<knap_sack_wpr(wp, W);
return 0;
}
| [
"vijay.nandakumar30@gmail.com"
] | vijay.nandakumar30@gmail.com |
ab6a96b74dd7b79c1432f03e3f1345c5ecd472aa | 59c707d69af282d71c47f8614567acd8e6754428 | /inf2/try_3/task_02/source.cpp | 7fb7b31cf4e801cf968deff4457301860e9e0545 | [] | no_license | RiKate/ONTI-2018-19 | 698361cc3e003a4f5c356dcafd1b7426b34e0cec | 381f1b40a72e2ffabdcc664df8fd5eb0ee8300f3 | refs/heads/master | 2020-04-16T05:07:43.594551 | 2019-01-12T09:24:44 | 2019-01-12T09:24:44 | 165,293,802 | 0 | 0 | null | 2019-01-11T18:53:14 | 2019-01-11T18:53:14 | null | UTF-8 | C++ | false | false | 334 | cpp | #include <iostream>
#include <cmath>
#define EPS 1e-9
using namespace std;
int main() {
double d, r;
cin >> d >> r;
double sine = d / 2 / r;
if (sine > 1)
cout << -1;
else {
double angle = asin(sine);
cout << (long long) floor(M_PI / angle + EPS);
}
return 0;
} | [
"noreply@github.com"
] | RiKate.noreply@github.com |
6fc8ea5e1481c1a1b38b4ac7dfbcb36235dffcbb | 794c6ad094d50dab94c0878702b5212ad0eee849 | /public_library/src/old/runtime_error.cpp | 9798f12a2901a32ddd2bc79466d9fa35cf1a8395 | [] | no_license | boris-r-v/mpkpen-2.0 | fdf9ce2a0ca96de66334a1b4e0645beb48b5f669 | 27bf9273f3916c607436df41fa156049e4b0c786 | refs/heads/master | 2021-06-03T23:54:06.728757 | 2021-05-17T12:30:51 | 2021-05-17T12:30:51 | 123,535,481 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 145 | cpp | #include <runtime_error.h>
namespace mp = MpkPen::Public;
mp::RuntimeError::RuntimeError( std::string const& _s): std::runtime_error( _s )
{
}
| [
"borisrozhkin@gmail.com"
] | borisrozhkin@gmail.com |
d4cf72816ab5c64693c3d7d20ce08bc54e643509 | c6548434e67401d1178b507d536689636752eec9 | /SeamCarving/seamcarving.cpp | 0431d4e177b7f7e7be7782ff167f1d9ffdd45a7b | [] | no_license | wnom/Seam-Carver | 9d21a45dad81136c656c6e9423b28507f13764f6 | 8aa1260b383a23090ba08476868ac27e24db276d | refs/heads/main | 2023-08-12T04:11:08.023505 | 2021-09-15T23:43:36 | 2021-09-15T23:43:36 | 406,943,754 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,201 | cpp | #include <iostream>
#include <string>
#include <sstream>
#include <fstream>
#include <cmath>
#include "functions.h"
using namespace std;
int main() {
string filename;
int width = 0;
int height = 0;
int originalWidth = 0;
//int originalHeight = 0;
int targetWidth = 0;
int targetHeight = 0;
cout << "Input filename: ";
cin >> filename;
// add error checking for width, height, targetWidth, and targetHeight
cout << "Input width and height: ";
cin >> width;
if(!cin.good()){//check if input is int
cout << "Error: width is a non-integer value" << endl;
return -1;
}
cin >> height;
if(!cin.good()){//check if input is an int
cout << "Error: height is a non-integer value" << endl;
return -1;
}
if(width <= 0){
cout << "Error: width must be greater than 0. You entered " << width << endl;
return -1;
}
if(height <= 0){
cout << "Error: height must be greater than 0. You entered " << height << endl;
return -1;
}
cout << "Input target width and height: ";
cin >> targetWidth;
if(!cin.good()){
cout << "Error: target width is a non-integer value" << endl;
return -1;
}
if(targetWidth <= 0){
cout << "Error: target width must be greater than 0. You entered " << targetWidth << endl;
return -1;
}
if(targetWidth > width){
cout << "Error: target width must be less than width, " << targetWidth <<
" is greater than " << width << endl;
return -1;
}
cin >> targetHeight;
if(!cin.good()){
cout << "Error: target height is a non-integer value" << endl;
return -1;
}
if(targetHeight <= 0){
cout << "Error: target height must be greater than 0. You entered " << targetHeight << endl;
return -1;
}
if(targetHeight > height){
cout << "Error: target height must be less than height, " << targetHeight <<
" is greater than " << height << endl;
return -1;
}
// save originalWidth since width will change with carving
originalWidth = width;
// save originalHeight since height will change with carving
//originalHeight = height;
Pixel** image = createImage(width, height);
if (image != nullptr) { // new returns nullptr if it fails to allocate array
if (loadImage(filename, image, width, height)) {
// uncomment for part 2
while ((width - targetWidth > 0) || (height - targetHeight > 0)) {
if (width - targetWidth > 0) {
int* verticalSeam = findMinVerticalSeam(image, width, height);
removeVerticalSeam(image, width, height, verticalSeam);
deleteSeam(verticalSeam);
width--;
}
// this is for the extra credit
if (height - targetHeight > 0) {
int* horizontalSeam = findMinHorizontalSeam(image, width, height);
removeHorizontalSeam(image, width, height, horizontalSeam);
deleteSeam(horizontalSeam);
height--;
}
}
stringstream ss;
ss << "carved" << width << "X" << height << "." << filename;
outputImage(ss.str().c_str(), image, width, height);
}
}
// call last to remove the memory from the heap
deleteImage(image, originalWidth);
} | [
"noreply@github.com"
] | wnom.noreply@github.com |
eab22b6f5664d5cc25930f1a54b6f6d005924707 | 8947812c9c0be1f0bb6c30d1bb225d4d6aafb488 | /02_Library/Include/XMCocos2D-v3/network/HttpResponse.h | 874d89299c33671ff3263711829f93a72b034122 | [
"MIT"
] | permissive | alissastanderwick/OpenKODE-Framework | cbb298974e7464d736a21b760c22721281b9c7ec | d4382d781da7f488a0e7667362a89e8e389468dd | refs/heads/master | 2021-10-25T01:33:37.821493 | 2016-07-12T01:29:35 | 2016-07-12T01:29:35 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,329 | h | /* -----------------------------------------------------------------------------------
*
* File HttpResponse.h
* Ported By Young-Hwan Mun
* Contact xmsoft77@gmail.com
*
* -----------------------------------------------------------------------------------
*
* Copyright (c) 2010-2014 XMSoft
* Copyright (c) 2010-2012 cocos2d-x.org
*
* http://www.cocos2d-x.org
*
* -----------------------------------------------------------------------------------
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* --------------------------------------------------------------------------------- */
#ifndef __HttpResponse_h__
#define __HttpResponse_h__
#include "network/HttpRequest.h"
namespace network {
/**
* @brief defines the object which users will receive at onHttpCompleted(sender, HttpResponse) callback
* Please refer to samples/TestCpp/Classes/ExtensionTest/NetworkTest/HttpClientTest.cpp as a sample
* @since v2.0.2
*/
class HttpResponse : public cocos2d::Object
{
public :
/**
* Constructor, it's used by HttpClient internal, users don't need to create HttpResponse manually
* @param request the corresponding HttpRequest which leads to this response
*/
HttpResponse ( HttpRequest* pRequest )
{
m_pHttpRequest = pRequest;
if ( m_pHttpRequest )
{
m_pHttpRequest->retain ( );
}
m_bSucceed = false;
m_aResponseData.clear ( );
m_aErrorBuffer.clear ( );
}
/**
* Destructor, it will be called in HttpClient internal,
* users don't need to desturct HttpResponse object manully
*/
virtual ~HttpResponse ( KDvoid )
{
if ( m_pHttpRequest )
{
m_pHttpRequest->release ( );
}
}
/** Override autorelease method to prevent developers from calling it */
cocos2d::Object* autorelease ( KDvoid )
{
CCASSERT ( false, "HttpResponse is used between network thread and ui thread therefore, autorelease is forbidden here" );
return KD_NULL;
}
// getters, will be called by users
/**
* Get the corresponding HttpRequest object which leads to this response
* There's no paired setter for it, coz it's already setted in class constructor
*/
inline HttpRequest* getHttpRequest ( KDvoid )
{
return m_pHttpRequest;
}
/**
* To see if the http reqeust is returned successfully,
* Althrough users can judge if (http return code = 200), we want an easier way
* If this getter returns false, you can call getResponseCode and getErrorBuffer to find more details
*/
inline KDbool isSucceed ( KDvoid )
{
return m_bSucceed;
};
/** Get the http response raw data */
inline std::vector<KDchar>* getResponseData ( KDvoid )
{
return &m_aResponseData;
}
/** get the Rawheader **/
inline std::vector<KDchar>* getResponseHeader ( KDvoid )
{
return &m_aResponseHeader;
}
/** Get the http response errorCode
* I know that you want to see http 200 :)
*/
inline KDint getResponseCode ( KDvoid )
{
return m_nResponseCode;
}
/**
* Get the rror buffer which will tell you more about the reason why http request failed
*/
inline const KDchar* getErrorBuffer ( KDvoid )
{
return m_aErrorBuffer.c_str ( );
}
// setters, will be called by HttpClient
// users should avoid invoking these methods
/**
* Set if the http request is returned successfully,
* Althrough users can judge if (http code == 200), we want a easier way
* This setter is mainly used in HttpClient, users mustn't set it directly
*/
inline KDvoid setSucceed ( KDbool bValue )
{
m_bSucceed = bValue;
};
/**
* Set the http response raw buffer, is used by HttpClient
*/
inline KDvoid setResponseData ( std::vector<KDchar>* pData )
{
m_aResponseData = *pData;
}
/**
* Set the http response Header raw buffer, is used by HttpClient
*/
inline KDvoid setResponseHeader ( std::vector<KDchar>* pData )
{
m_aResponseHeader = *pData;
}
/**
* Set the http response errorCode
*/
inline KDvoid setResponseCode ( KDint nValue )
{
m_nResponseCode = nValue;
}
/**
* Set the error buffer which will tell you more the reason why http request failed
*/
inline KDvoid setErrorBuffer ( const KDchar* pValue )
{
m_aErrorBuffer.clear ( );
m_aErrorBuffer.assign ( pValue );
};
protected :
KDbool initWithRequest ( HttpRequest* pRequest );
// properties
HttpRequest* m_pHttpRequest; /// the corresponding HttpRequest pointer who leads to this response
KDbool m_bSucceed; /// to indecate if the http reqeust is successful simply
std::vector<KDchar> m_aResponseData; /// the returned raw data. You can also dump it as a string
std::vector<KDchar> m_aResponseHeader; /// the returned raw header data. You can also dump it as a string
KDint m_nResponseCode; /// the status code returned from libcurl, e.g. 200, 404
std::string m_aErrorBuffer; /// if _responseCode != 200, please read _errorBuffer to find the reason
};
}
#endif // __HttpResponse_h__
| [
"mcodegeeks@gmail.com"
] | mcodegeeks@gmail.com |
aee4717369544eee556b41e359ebe0c5c19eb42d | 5d6e6beb365e5e52db41394826ccfbc3e51bcfb7 | /libnano2/nanosoft/xmlparser.h | ab3e0a9d24b8305f1ff0df3dec3ed7418206596d | [
"MIT"
] | permissive | zolotov-av/nanosoft | 86d600d60ec74ae5b456a9d5afd7697883ac57ee | 2aebb09d7d8a424d4de9b57d7586dbb72eed9fa0 | refs/heads/master | 2021-03-19T08:37:57.683170 | 2020-05-27T14:34:29 | 2020-05-27T14:39:26 | 97,500,048 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 3,136 | h | #ifndef NANOSOFT_XMLPARSER_H
#define NANOSOFT_XMLPARSER_H
#include <nanosoft/error.h>
#include <nanosoft/xml_types.h>
#include <string.h>
#include <expat.h>
#include <map>
#include <string>
namespace nanosoft
{
/**
* XML парсер
*/
class XMLParser
{
public:
/**
* Конструктор
*/
XMLParser();
/**
* Деструктор
*/
virtual ~XMLParser();
/**
* Парсинг XML
*
* Если включена компрессия, то данные сначала распаковываются
*
* @param data буфер с данными
* @param len длина буфера с данными
* @param isFinal TRUE - последний кусок, FALSE - будет продолжение
* @return TRUE - успешно, FALSE - ошибка парсинга
*/
bool parseXML(const char *data, size_t len, bool isFinal);
/**
* Сбросить парсер, начать парсить новый поток
*/
void resetParser();
protected:
/**
* Обработчик открытия тега
*/
virtual void onStartElement(const std::string &name, const attributes_t &attributes) = 0;
/**
* Обработчик символьных данных
*/
virtual void onCharacterData(const std::string &cdata) = 0;
/**
* Обработчик закрытия тега
*/
virtual void onEndElement(const std::string &name) = 0;
/**
* Обработчик ошибок парсера
*/
virtual void onParseError(const char *message) = 0;
private:
/**
* Парсер expat
*/
XML_Parser parser;
/**
* Признак парсинга
* TRUE - парсер в состоянии обработка куска файла
*/
bool parsing;
/**
* Признак необходимости перенинициализации парсера
* TRUE - парсер должен быть переинициализован перед
* обработкой следующего куска файла
*/
bool resetNeed;
/**
* Инициализация парсера
*/
bool initParser();
/**
* Реальная переинициализация парсера
*/
bool realResetParser();
/**
* Парсинг XML
*
* @param buf буфер с данными
* @param len длина буфера с данными
* @param isFinal TRUE - последний кусок, FALSE - будет продолжение
* @return TRUE - успешно, FALSE - ошибка парсинга
*/
bool realParseXML(const char *buf, size_t len, bool isFinal);
/**
* Обработчик открытия тега
*/
static void startElementCallback(void *user_data, const XML_Char *name, const XML_Char **atts);
/**
* Отработчик символьных данных
*/
static void characterDataCallback(void *user_data, const XML_Char *s, int len);
/**
* Отбработчик закрытия тега
*/
static void endElementCallback(void *user_data, const XML_Char *name);
};
}
#endif // NANOSOFT_XMLPARSER_H
| [
"shade@shamangrad.net"
] | shade@shamangrad.net |
c13d0fdd0fc12ddd2667bf113ab6515fbe7fa5ce | 0f457762985248f4f6f06e29429955b3fd2c969a | /irrlicht/sdk/irr_bullet/BulletFpsCamAnimator.cpp | cb032f3e69ff87eca1975d828ecc7cfaf75b60b1 | [] | no_license | tk8812/ukgtut | f19e14449c7e75a0aca89d194caedb9a6769bb2e | 3146ac405794777e779c2bbb0b735b0acd9a3f1e | refs/heads/master | 2021-01-01T16:55:07.417628 | 2010-11-15T16:02:53 | 2010-11-15T16:02:53 | 37,515,002 | 0 | 0 | null | null | null | null | UHC | C++ | false | false | 13,440 | cpp | //저작권:
//물리 fps 애니메이터
//수정 2008.8.12
//미구현 사항 : 점푸구현
//
//수정 2009.8.6
#pragma warning (disable:4819)
#include "CBulletAnimatorManager.h"
#include "BulletFpsCamAnimator.h"
#include "IVideoDriver.h"
#include "ISceneManager.h"
#include "Keycodes.h"
#include "ICursorControl.h"
#include "ICameraSceneNode.h"
#include "btBulletDynamicsCommon.h"
#include "BulletCollision/Gimpact/btGImpactShape.h"
#include "BulletCollision/Gimpact/btGImpactCollisionAlgorithm.h"
namespace irr
{
namespace scene
{
//! constructor
CBulletFpsCamAnimator::CBulletFpsCamAnimator(gui::ICursorControl* cursorControl,
f32 rotateSpeed, f32 moveSpeed, f32 jumpSpeed,
SKeyMap* keyMapArray, u32 keyMapSize, bool noVerticalMovement)
: CursorControl(cursorControl), MaxVerticalAngle(88.0f),
MoveSpeed(moveSpeed/1000.0f), RotateSpeed(rotateSpeed), JumpSpeed(jumpSpeed),
LastAnimationTime(0), firstUpdate(true), NoVerticalMovement(noVerticalMovement)
{
#ifdef _DEBUG
setDebugName("CCameraSceneNodeAnimatorFPS");
#endif
if (CursorControl)
CursorControl->grab();
allKeysUp();
// create key map
if (!keyMapArray || !keyMapSize)
{
// create default key map
KeyMap.push_back(SCamKeyMap(0, irr::KEY_UP));
KeyMap.push_back(SCamKeyMap(1, irr::KEY_DOWN));
KeyMap.push_back(SCamKeyMap(2, irr::KEY_LEFT));
KeyMap.push_back(SCamKeyMap(3, irr::KEY_RIGHT));
KeyMap.push_back(SCamKeyMap(4, irr::KEY_KEY_J));
}
else
{
// create custom key map
setKeyMap(keyMapArray, keyMapSize);
}
m_LocalPos = irr::core::vector3df(0,0,0);
}
//! destructor
CBulletFpsCamAnimator::~CBulletFpsCamAnimator()
{
if (CursorControl)
CursorControl->drop();
}
//! It is possible to send mouse and key events to the camera. Most cameras
//! may ignore this input, but camera scene nodes which are created for
//! example with scene::ISceneManager::addMayaCameraSceneNode or
//! scene::ISceneManager::addFPSCameraSceneNode, may want to get this input
//! for changing their position, look at target or whatever.
//! 아래의이벤트핸들러가 호출되는 이유는 현재활성화된 카메라노드에 자식으로 붙어있는 애니매이터는
//! 무조건 이밴트핸들러가 호출이된다.
bool CBulletFpsCamAnimator::OnEvent(const SEvent& evt)
{
switch(evt.EventType)
{
case EET_KEY_INPUT_EVENT:
for (u32 i=0; i<KeyMap.size(); ++i)
{
if (KeyMap[i].keycode == evt.KeyInput.Key)
{
CursorKeys[KeyMap[i].action] = evt.KeyInput.PressedDown;
return true;
}
}
break;
case EET_MOUSE_INPUT_EVENT:
if (evt.MouseInput.Event == EMIE_MOUSE_MOVED)
{
CursorPos = CursorControl->getRelativePosition();
return true;
}
break;
default:
break;
}
return false;
}
//------------------------------------------------------------------------------
//! CreateInstance
//! Creates CBulletChracterAnimator or returns NULL
//! CBulletObjectAnimator와 달리 각회전을 제한(서있는상태를 유지하기위해서는 쓰러짐을 제어하기위해서...)
CBulletFpsCamAnimator* CBulletFpsCamAnimator::createInstance(
ISceneManager* pSceneManager,
ISceneNode* pSceneNode,
gui::ICursorControl *CursorControl,
CBulletAnimatorManager* pBulletMgr,
CBulletObjectAnimatorGeometry* pGeom,
CBulletObjectAnimatorParams* pPhysicsParam)
{
//CursorControl = CursorControl;
// get node scaling
core::vector3df scaling = pSceneNode->getScale();
btStridingMeshInterface* triangleMesh = NULL;
// prepare collision shape
btCollisionShape* collisionShape =
CreateBulletCollisionShape(pSceneManager, pGeom, scaling, triangleMesh);
if (collisionShape == NULL)
return NULL;
CBulletFpsCamAnimator* bulletAnimator = new CBulletFpsCamAnimator(CursorControl,100.f,50.f);
bulletAnimator->geometry = *pGeom;
bulletAnimator->physicsParams = *pPhysicsParam;
bulletAnimator->bulletMesh = triangleMesh;
bulletAnimator->collisionShape = collisionShape;
bulletAnimator->sceneNode = pSceneNode;
bulletAnimator->sceneManager = pSceneManager;
bulletAnimator->bulletMgr = pBulletMgr;
bulletAnimator->CursorControl = CursorControl;
bulletAnimator->InitPhysics();
//추가 물리 속성
//쓰러짐 제어를 위해 각회전 제한
bulletAnimator->getRigidBody()->setAngularFactor(0.0f);
bulletAnimator->getRigidBody()->setSleepingThresholds (0.0, 0.0);
return bulletAnimator;
}
void CBulletFpsCamAnimator::animateNode(ISceneNode* node, u32 timeMs)
{
if (node->getType() != ESNT_CAMERA)
return;
ICameraSceneNode* camera = static_cast<ICameraSceneNode*>(node);
if (firstUpdate)
{
if (CursorControl && camera)
{
CursorControl->setPosition(0.5f, 0.5f);
CursorPos = CenterCursor = CursorControl->getRelativePosition();
}
LastAnimationTime = timeMs;
firstUpdate = false;
}
// get time
f32 timeDiff = (f32) ( timeMs - LastAnimationTime );
LastAnimationTime = timeMs;
// update position
core::vector3df pos = camera->getPosition();
// Update rotation
core::vector3df target = (camera->getTarget() - camera->getAbsolutePosition());
core::vector3df relativeRotation = target.getHorizontalAngle();
if (CursorControl)
{
if (CursorPos != CenterCursor)
{
relativeRotation.Y -= (0.5f - CursorPos.X) * RotateSpeed;
relativeRotation.X -= (0.5f - CursorPos.Y) * RotateSpeed;
// X < MaxVerticalAngle or X > 360-MaxVerticalAngle
if (relativeRotation.X > MaxVerticalAngle*2 &&
relativeRotation.X < 360.0f-MaxVerticalAngle)
{
relativeRotation.X = 360.0f-MaxVerticalAngle;
}
else
if (relativeRotation.X > MaxVerticalAngle &&
relativeRotation.X < 360.0f-MaxVerticalAngle)
{
relativeRotation.X = MaxVerticalAngle;
}
// reset cursor position
CursorControl->setPosition(0.5f, 0.5f);
CenterCursor = CursorControl->getRelativePosition();
//ggf::irr_util::DebugOutputFmt(NULL,"test %f \n",relativeRotation.Y);
}
}
// set target
target.set(0,0,100);
core::vector3df movedir = target;
core::matrix4 mat;
mat.setRotationDegrees(core::vector3df(relativeRotation.X, relativeRotation.Y, 0));
mat.transformVect(target);
if (NoVerticalMovement)
{
mat.setRotationDegrees(core::vector3df(0, relativeRotation.Y, 0));
mat.transformVect(movedir);
}
else
{
movedir = target;
}
movedir.normalize();
//if (CursorKeys[0])
//pos += movedir * timeDiff * MoveSpeed;
//if (CursorKeys[1])
//pos -= movedir * timeDiff * MoveSpeed;
// strafing
//core::vector3df strafevect = target;
//strafevect = strafevect.crossProduct(camera->getUpVector());
//if (NoVerticalMovement)
// strafevect.Y = 0.0f;
//strafevect.normalize();
if (CursorKeys[2])
{
//pos += strafevect * timeDiff * MoveSpeed;
//ggf::irr_util::DebugOutputFmt(NULL,"test %f \n",relativeRotation.Y);
}
if (CursorKeys[3])
//pos -= strafevect * timeDiff * MoveSpeed;
// jumping ( need's a gravity , else it's a fly to the World-UpVector )
if (CursorKeys[4])
{
//pos += camera->getUpVector() * timeDiff * JumpSpeed;
}
// write translation
//camera->setPosition(pos);
/////////////////////////gbox/////////////////////////
//gbox patch 08.07.27 rotation bug fix
camera->setRotation(mat.getRotationDegrees());
/////////////////////////gbox/////////////////////////
// write right target
TargetVector = target;
//target += pos;
//camera->setTarget(target);
irr::f32 Speed = 0;// = timeDiff * MoveSpeed;
irr::f32 Strife_Speed = 0;
irr::f32 Angle = relativeRotation.Y;
if (CursorKeys[0])
{
//Speed = timeDiff * MoveSpeed;
Speed = MoveSpeed;
}
if (CursorKeys[1])
{
//Speed = -(timeDiff * MoveSpeed);
Speed = -MoveSpeed;
}
if (CursorKeys[2])
{
Strife_Speed = MoveSpeed;
//Strife_Speed = (timeDiff * MoveSpeed);
}
if (CursorKeys[3])
{
Strife_Speed = -MoveSpeed;
//Strife_Speed = -(timeDiff * MoveSpeed);
}
//전처리 스탭(충돌 처리)
{
btTransform xform;
rigidBody->getMotionState()->getWorldTransform (xform);
btVector3 down = -xform.getBasis()[1]; //Y축 정보
btVector3 forward = xform.getBasis()[2]; //Z축 정보
down.normalize ();
forward.normalize();
forward.setX(-forward.getX()); //오른손좌표계롤 왼손좌표계로...
m_raySource[0] = xform.getOrigin();
m_raySource[1] = xform.getOrigin();
m_rayTarget[0] = m_raySource[0] + down * ((geometry.Capsule.hight * 0.5f) + geometry.Capsule.radius ) * btScalar(1.1);
m_rayTarget[1] = m_raySource[1] + forward * (geometry.Capsule.radius ) * btScalar(1.1);
class ClosestNotMe : public btCollisionWorld::ClosestRayResultCallback
{
public:
ClosestNotMe (btRigidBody* me) : btCollisionWorld::ClosestRayResultCallback(btVector3(0.0, 0.0, 0.0), btVector3(0.0, 0.0, 0.0))
{
m_me = me;
}
virtual btScalar AddSingleResult(btCollisionWorld::LocalRayResult& rayResult,bool normalInWorldSpace)
{
if (rayResult.m_collisionObject == m_me)
return 1.0;
return ClosestRayResultCallback::addSingleResult (rayResult, normalInWorldSpace
);
}
protected:
btRigidBody* m_me;
};
ClosestNotMe rayCallback(rigidBody);
{
btDynamicsWorld* dynamicsWorld = bulletMgr->getBulletWorldByID(bulletWorldID)->getWorld();
int i = 0;
for (i = 0; i < 2; i++)
{
rayCallback.m_closestHitFraction = 1.0;
dynamicsWorld->rayTest (m_raySource[i], m_rayTarget[i], rayCallback);
if (rayCallback.hasHit())
{
m_rayLambda[i] = rayCallback.m_closestHitFraction; //충돌비율값
} else {
m_rayLambda[i] = 1.0; //충돌하지않음
}
}
}
}
//후처리
{
btTransform xform;
rigidBody->getMotionState()->getWorldTransform (xform);
xform.setRotation (btQuaternion (btVector3(0.0, 1.0, 0.0), Angle * irr::core::DEGTORAD));
btVector3 linearVelocity = rigidBody->getLinearVelocity();
if(m_rayLambda[0] < 1.0)
{
linearVelocity.setY(0);
}
btVector3 forwardDir = xform.getBasis()[2];
btVector3 SideDir = xform.getBasis()[0];
//축변환 및 정규화
forwardDir.normalize ();
forwardDir.setX(-forwardDir.getX());
SideDir.normalize();
SideDir.setX(-SideDir.getX());
btVector3 velocity = (forwardDir * Speed);
velocity += (SideDir * Strife_Speed);
irr::core::vector3df fowardvec = irr::core::vector3df(forwardDir.getX(),forwardDir.getY(),forwardDir.getZ());
irr::core::vector3df sidevec = irr::core::vector3df(-SideDir.getX(),SideDir.getY(),SideDir.getZ());
//ggf::irr_util::DebugOutputFmt(NULL,"%f %f, %f, %f\n",Angle,velocity.getX(),velocity.getY(),velocity.getZ());
//ggf::irr_util::DebugOutputFmt(NULL,"%f/%f %f, %f, %f\n",fowardvec.getHorizontalAngle().Y, sidevec.getHorizontalAngle().Y,SideDir.getX(),SideDir.getY(),SideDir.getZ());
velocity.setY(linearVelocity.getY());
rigidBody->setLinearVelocity (velocity);
rigidBody->getMotionState()->setWorldTransform (xform);
rigidBody->setCenterOfMassTransform (xform);
//camera->setTarget(target);
}
//물리엔진 변환적용
if (physicsParams.mass != 0.0f && rigidBody && rigidBody->getMotionState())
{
btTransform xform;
rigidBody->getMotionState()->getWorldTransform (xform);
btVector3 forwardDir = xform.getBasis()[2];
forwardDir.normalize ();
// set pos
btVector3 p = rigidBody->getCenterOfMassPosition();
irr::core::vector3df vforward = irr::core::vector3df(-forwardDir.getX(),forwardDir.getY(),forwardDir.getZ());
irr::core::vector3df eye_pos = core::vector3df(p.getX(), p.getY(), p.getZ()) + m_LocalPos;
sceneNode->setPosition(eye_pos);
camera->setTarget(eye_pos + TargetVector);
}
}
void CBulletFpsCamAnimator::allKeysUp()
{
for (u32 i=0; i<6; ++i)
CursorKeys[i] = false;
}
//! Sets the rotation speed
void CBulletFpsCamAnimator::setRotateSpeed(f32 speed)
{
RotateSpeed = speed;
}
//! Sets the movement speed
void CBulletFpsCamAnimator::setMoveSpeed(f32 speed)
{
MoveSpeed = speed;
}
//! Gets the rotation speed
f32 CBulletFpsCamAnimator::getRotateSpeed() const
{
return RotateSpeed;
}
// Gets the movement speed
f32 CBulletFpsCamAnimator::getMoveSpeed() const
{
return MoveSpeed;
}
//! Sets the keyboard mapping for this animator
void CBulletFpsCamAnimator::setKeyMap(SKeyMap *map, u32 count)
{
// clear the keymap
KeyMap.clear();
// add actions
for (u32 i=0; i<count; ++i)
{
switch(map[i].Action)
{
case EKA_MOVE_FORWARD: KeyMap.push_back(SCamKeyMap(0, map[i].KeyCode));
break;
case EKA_MOVE_BACKWARD: KeyMap.push_back(SCamKeyMap(1, map[i].KeyCode));
break;
case EKA_STRAFE_LEFT: KeyMap.push_back(SCamKeyMap(2, map[i].KeyCode));
break;
case EKA_STRAFE_RIGHT: KeyMap.push_back(SCamKeyMap(3, map[i].KeyCode));
break;
case EKA_JUMP_UP: KeyMap.push_back(SCamKeyMap(4, map[i].KeyCode));
break;
default:
break;
}
}
}
//! Sets whether vertical movement should be allowed.
void CBulletFpsCamAnimator::setVerticalMovement(bool allow)
{
NoVerticalMovement = !allow;
}
} // namespace scene
} // namespace irr
| [
"gbox3d@58f0f68e-7603-11de-abb5-1d1887d8974b"
] | gbox3d@58f0f68e-7603-11de-abb5-1d1887d8974b |
a21e611eb1c322cc234663420ca1d269fc13f72f | 0cda2dcf353c9dbb42e7b820861929948b9942ea | /fileedit/2009/Paintball.cpp | 7c277d96d64130a31d498ef5cc06a536a7564c12 | [] | no_license | naoyat/topcoder | 618853a31fa339ac6aa8e7099ceedcdd1eb67c64 | ec1a691cd0f56359f3de899b03eada9efa01f31d | refs/heads/master | 2020-05-30T23:14:10.356754 | 2010-01-17T04:03:52 | 2010-01-17T04:03:52 | 176,567 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 12,173 | cpp | #line 2 "Paintball.cpp"
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cctype>
#include <algorithm>
#include <string>
#include <vector>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
// BEGIN CUT HERE
#include "cout.h"
// END CUT HERE
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<string> vs;
typedef vector<long long> vll;
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mset(arr,val) memset(arr,val,sizeof(arr))
#define tr(c,i) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define rep(var,n) for(int var=0;var<(n);var++)
#define forr(var,from,to) for(int var=(from);var<=(to);var++)
#define found(s,e) ((s).find(e)!=(s).end())
#define remove_(c,val) (c).erase(remove((c).begin(),(c).end(),(val)),(c).end())
#define lastc(str) (*((str).end()-1))
vector<string> split(string str, int delim=' ')
{
vector<string> result;
const char *s = str.c_str();
if (delim == ' ') {
for (const char *p=s; *p; p++) {
if (*p == delim)
s++;
else
break;
}
if (!*s) return result;
for (const char *p=s; *p; p++) {
if (*p == delim) {
if (s < p) {
string a(s,p-s);
result.push_back(a);
}
s = p + 1;
}
}
if (*s) result.push_back(s);
} else {
for (const char *p=s; *p; p++) {
if (*p == delim) {
string a(s,p-s);
result.push_back(a);
s = p + 1;
if (*s == '\0') result.push_back("");
}
}
if (*s) result.push_back(s);
}
return result;
}
bool GreaterTeam(const pair<string,int>& t1, const pair<string,int>& t2){
if(t1.second > t2.second) return true;
if(t1.second < t2.second) return false;
if(t1.first <= t2.first) return true;
return false;
}
class Paintball {
public:
vector<string> getLeaderboard(vector<string> players, vector<string> messages) {
map<string,int> teams;
map<string,string> player_team;
map<string,int> player_point;
tr(players,it){
vector<string> s=split(*it);
player_team[s[0]] = s[1];
player_point[s[0]] = 0;
teams[s[1]]=0;
}
tr(messages,it){
vector<string> s=split(*it);
string p1=s[0], p2=s[2];
if(p1==p2){
player_point[p1]--;
}else{
string t1=player_team[p1], t2=player_team[p2];
if(t1==t2){
player_point[p1]--;
}else{
player_point[p1]++;
player_point[p2]--;
}
}
}
tr(player_point,it){
string p=it->first;
string t=player_team[p];
teams[t] += player_point[p];
}
vector<pair<string,int> > ts(all(teams));
sort(all(ts),GreaterTeam);
vector<string> res;
tr(ts,it){
stringstream ss;
ss << it->first << " " << it->second;
res.pb(ss.str());
vector<pair<string,int> > ps;
tr(player_team,jt){
if(jt->second == it->first){
ps.pb(make_pair(jt->first,player_point[jt->first]));
}
}
sort(all(ps),GreaterTeam);
tr(ps,jt){
stringstream ss2;
ss2 << " " << jt->first << " " << jt->second;
res.pb(ss2.str());
}
}
return res;
}
};
// BEGIN CUT HERE
#include <time.h>
clock_t start_time;
void timer_clear() { start_time = clock(); }
string timer() { clock_t end_time = clock(); double interval = (double)(end_time - start_time)/CLOCKS_PER_SEC; ostringstream os; os << " (" << interval*1000 << " msec)"; return os.str(); }
template <typename T> string print_array(const vector<T> &V) { ostringstream os; os << "{ "; for (typename vector<T>::const_iterator iter = V.begin(); iter != V.end(); ++iter) os << '\"' << *iter << "\","; os << " }"; return os.str(); }
int verify_case(const vector <string> &Expected, const vector <string> &Received) { if (Expected == Received) cerr << "PASSED" << timer() << endl; else { cerr << "FAILED" << timer() << endl; cerr << "\tExpected: " << print_array(Expected) << endl; cerr << "\tReceived: " << print_array(Received) << endl; } return 0;}
template<int N> struct Case_ {};
char Test_(...);
int Test_(Case_<0>) {
timer_clear();
string players_[] = {"A RED", "B BLUE"};
vector <string> players(players_, players_+sizeof(players_)/sizeof(*players_));
string messages_[] = {"A SPLATTERED B"};
vector <string> messages(messages_, messages_+sizeof(messages_)/sizeof(*messages_));
string RetVal_[] = {"RED 1", " A 1", "BLUE -1", " B -1" };
vector <string> RetVal(RetVal_, RetVal_+sizeof(RetVal_)/sizeof(*RetVal_));
return verify_case(RetVal, Paintball().getLeaderboard(players, messages)); }
int Test_(Case_<1>) {
timer_clear();
string players_[] = {"LISA RED", "BART RED", "HOMER BLUE", "MARGE BLUE", "MAGGIE GREEN"};
vector <string> players(players_, players_+sizeof(players_)/sizeof(*players_));
string messages_[] = {"MAGGIE SPLATTERED HOMER", "MAGGIE SPLATTERED MARGE"};
vector <string> messages(messages_, messages_+sizeof(messages_)/sizeof(*messages_));
string RetVal_[] = {"GREEN 2", " MAGGIE 2", "RED 0", " BART 0", " LISA 0", "BLUE -2", " HOMER -1", " MARGE -1" };
vector <string> RetVal(RetVal_, RetVal_+sizeof(RetVal_)/sizeof(*RetVal_));
return verify_case(RetVal, Paintball().getLeaderboard(players, messages)); }
int Test_(Case_<2>) {
timer_clear();
string players_[] = {"TODD STRIKEFORCE",
"BART OMEGA",
"DATA STRIKEFORCE",
"MILHOUSE OMEGA",
"NELSON DISCOVERYCHANNEL",
"MARTIN DISCOVERYCHANNEL"};
vector <string> players(players_, players_+sizeof(players_)/sizeof(*players_));
string messages_[] = {"BART SPLATTERED MARTIN","TODD SPLATTERED MARTIN"};
vector <string> messages(messages_, messages_+sizeof(messages_)/sizeof(*messages_));
string RetVal_[] = {"OMEGA 1", " BART 1", " MILHOUSE 0", "STRIKEFORCE 1", " TODD 1", " DATA 0", "DISCOVERYCHANNEL -2", " NELSON 0", " MARTIN -2" };
vector <string> RetVal(RetVal_, RetVal_+sizeof(RetVal_)/sizeof(*RetVal_));
return verify_case(RetVal, Paintball().getLeaderboard(players, messages)); }
int Test_(Case_<3>) {
timer_clear();
string players_[] = {"DR COHO", "ST COHO", "PE COHO"};
vector <string> players(players_, players_+sizeof(players_)/sizeof(*players_));
string messages_[] = {"DR SPLATTERED ST",
"ST SPLATTERED PE"};
vector <string> messages(messages_, messages_+sizeof(messages_)/sizeof(*messages_));
string RetVal_[] = {"COHO -2", " PE 0", " DR -1", " ST -1" };
vector <string> RetVal(RetVal_, RetVal_+sizeof(RetVal_)/sizeof(*RetVal_));
return verify_case(RetVal, Paintball().getLeaderboard(players, messages)); }
int Test_(Case_<4>) {
timer_clear();
string players_[] = {"A B", "AA AA", "AAA AAA"};
vector <string> players(players_, players_+sizeof(players_)/sizeof(*players_));
string messages_[] = {"A SPLATTERED AAA", "A SPLATTERED AAA", "A SPLATTERED AAA",
"AA SPLATTERED AAA", "AA SPLATTERED AAA"};
vector <string> messages(messages_, messages_+sizeof(messages_)/sizeof(*messages_));
string RetVal_[] = {"B 3", " A 3", "AA 2", " AA 2", "AAA -5", " AAA -5" };
vector <string> RetVal(RetVal_, RetVal_+sizeof(RetVal_)/sizeof(*RetVal_));
return verify_case(RetVal, Paintball().getLeaderboard(players, messages)); }
template<int N> void Run_() { cerr << "Test Case #" << N << "..." << flush; Test_(Case_<N>()); Run_<sizeof(Test_(Case_<N+1>()))==1 ? -1 : N+1>(); }
template<> void Run_<-1>() {}
int main() { Run_<0>(); }
// END CUT HERE
// BEGIN CUT HERE
/*
// PROBLEM STATEMENT
//
For his birthday, Bart received the brand new video game "Paintball!". In this game, a person plays on teams over the Internet against various competitors, attempting to hit their opponents with paint balls. Each player earns a point each time that they "splatter" an opponent with a paintball, and lose a point for each time they get "splattered". Due to the way that the game is played, it is also possible to accidentally splatter yourself or a teammate. In that case, the shooter loses a point, and the person who was splattered (if not the shooter) does not lose any points. A team's score is simply the sum of the scores of its players.
Although Bart loves the game, he is disappointed that the game does not provide a leaderboard during gameplay. However, it does provide the list of players, formatted as "NAME TEAM" (where NAME is the player's name, and TEAM is his team), and a series of messages, each formatted as "NAME1 SPLATTERED NAME2" (all quotes for clarity), where NAME1 indicates the name of the person who shot the paintball, and NAME2 indicates the name of the person who got splattered. Bart would like to have an updated scoreboard, and that is where you come in.
All teams will receive a rank number from 1 to M (the total number of teams), based on the team scores (with 1 corresponding to the highest score). If multiple teams have the same score, then the team with the name that comes first alphabetically will receive a lower rank number. For each team (in order from 1 to M), its leaderboard entry will be formatted as follows:
The first line will be "TEAM SCORE" (quotes for clarity), where TEAM is the team name, and SCORE is the team score (with no extra leading zeroes).
Let N be the number of players on the team. Assign rank numbers to the N players from 1 to N, giving a lower rank number to a higher score. If multiple players have the same score, assign the player whose name comes first alphabetically to the lower rank number.
From the player with rank 1 to rank N, output a line with 2 spaces, the player's name, a single space, and then the player's score (with no extra leading zeroes).
Thus, if player A from team RED splatters player B from team BLUE (and they are the only players in the game), the leaderboard will be:
RED 1
A 1
BLUE -1
B -1
You are to generate the leaderboard and return it.
DEFINITION
Class:Paintball
Method:getLeaderboard
Parameters:vector <string>, vector <string>
Returns:vector <string>
Method signature:vector <string> getLeaderboard(vector <string> players, vector <string> messages)
NOTES
-A SCORE of 0 should be output as 0, not as -0.
CONSTRAINTS
-players will contain between 1 and 50 elements, inclusive.
-Each element of players will contain between 3 and 50 characters, inclusive.
-Each element of players will be formatted as "NAME TEAM" (quotes for clarity).
-In each element of players, NAME will consist of uppercase characters ('A'-'Z') and will contain at least 1 character.
-There will be no duplicate NAMEs in players.
-In each element of players, TEAM will consist of uppercase characters ('A'-'Z') and will contain at least 1 character.
-messages will contain between 1 and 50 elements, inclusive.
-Each element of messages will contain between 14 and 50 characters, inclusive.
-Each element of messages will be formatted as described in the problem statement.
-In each element of messages, NAME1 and NAME2 will be NAMEs found in players.
EXAMPLES
0)
{"A RED", "B BLUE"}
{"A SPLATTERED B"}
Returns: {"RED 1", " A 1", "BLUE -1", " B -1" }
The example from the statement.
1)
{"LISA RED", "BART RED", "HOMER BLUE", "MARGE BLUE", "MAGGIE GREEN"}
{"MAGGIE SPLATTERED HOMER", "MAGGIE SPLATTERED MARGE"}
Returns: {"GREEN 2", " MAGGIE 2", "RED 0", " BART 0", " LISA 0", "BLUE -2", " HOMER -1", " MARGE -1" }
2)
{"TODD STRIKEFORCE",
"BART OMEGA",
"DATA STRIKEFORCE",
"MILHOUSE OMEGA",
"NELSON DISCOVERYCHANNEL",
"MARTIN DISCOVERYCHANNEL"}
{"BART SPLATTERED MARTIN","TODD SPLATTERED MARTIN"}
Returns: {"OMEGA 1", " BART 1", " MILHOUSE 0", "STRIKEFORCE 1", " TODD 1", " DATA 0", "DISCOVERYCHANNEL -2", " NELSON 0", " MARTIN -2" }
3)
{"DR COHO", "ST COHO", "PE COHO"}
{"DR SPLATTERED ST",
"ST SPLATTERED PE"}
Returns: {"COHO -2", " PE 0", " DR -1", " ST -1" }
Don't shoot your teammates!
4)
{"A B", "AA AA", "AAA AAA"}
{"A SPLATTERED AAA", "A SPLATTERED AAA", "A SPLATTERED AAA",
"AA SPLATTERED AAA", "AA SPLATTERED AAA"}
Returns: {"B 3", " A 3", "AA 2", " AA 2", "AAA -5", " AAA -5" }
*/
// END CUT HERE
| [
"naoya_t@users.sourceforge.jp"
] | naoya_t@users.sourceforge.jp |
d84c474e40602785a42da7cb0e9e1397dae59f74 | 8dc84558f0058d90dfc4955e905dab1b22d12c08 | /content/browser/payments/payment_instrument_icon_fetcher.h | e3c5f8e608d5da488fd5d1e8d3e07bb24e31b5dc | [
"LicenseRef-scancode-unknown-license-reference",
"BSD-3-Clause"
] | permissive | meniossin/src | 42a95cc6c4a9c71d43d62bc4311224ca1fd61e03 | 44f73f7e76119e5ab415d4593ac66485e65d700a | refs/heads/master | 2022-12-16T20:17:03.747113 | 2020-09-03T10:43:12 | 2020-09-03T10:43:12 | 263,710,168 | 1 | 0 | BSD-3-Clause | 2020-05-13T18:20:09 | 2020-05-13T18:20:08 | null | UTF-8 | C++ | false | false | 1,188 | h | // Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CONTENT_BROWSER_PAYMENTS_PAYMENT_INSTRUMENT_ICON_FETCHER_H_
#define CONTENT_BROWSER_PAYMENTS_PAYMENT_INSTRUMENT_ICON_FETCHER_H_
#include <string>
#include <vector>
#include "base/callback_forward.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "third_party/blink/public/common/manifest/manifest.h"
#include "third_party/blink/public/platform/modules/payments/payment_app.mojom.h"
namespace content {
class PaymentInstrumentIconFetcher {
public:
using PaymentInstrumentIconFetcherCallback =
base::OnceCallback<void(const std::string&)>;
// Should be called on IO thread.
static void Start(
const GURL& scope,
std::unique_ptr<std::vector<std::pair<int, int>>> provider_hosts,
const std::vector<blink::Manifest::Icon>& icons,
PaymentInstrumentIconFetcherCallback callback);
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(PaymentInstrumentIconFetcher);
};
} // namespace content
#endif // CONTENT_BROWSER_PAYMENTS_PAYMENT_INSTRUMENT_ICON_FETCHER_H_
| [
"arnaud@geometry.ee"
] | arnaud@geometry.ee |
497a4c8ca495dde0e71d1dd4d9cb4ca260458eb5 | 99df2b728f7786f8df7a4c7c340e28c361d20171 | /src/common.cpp | 47ef40543d36c31dfc03209191ad698c86f6209f | [] | no_license | sunnyss12/text_query | df9e4d3f053c74e93ed1552bf2b8f2a28f310aa3 | f9a4168ca361bdd10cd6d3f54c06474ce17c4280 | refs/heads/master | 2021-01-10T19:01:51.579621 | 2015-08-18T07:28:16 | 2015-08-18T07:28:16 | 37,717,879 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 192 | cpp | #include "common.h"
bool isFileExist(const char* filepath)
{
std::fstream fin;
fin.open(filepath,std::fstream::in);
if(!fin)
return false;
else
return true;
}
| [
"yinjing@localhost.localdomain"
] | yinjing@localhost.localdomain |
51a5139c26f620cdcdde9ed2c7d96acf40b9f343 | c14e92092077be792b4a453a984e5a4b2c4f9e1e | /src/input.cpp | dd02b5149b4bc075971dffc0d3aedc72c2e40970 | [] | no_license | AaHigh/FontDemo | d05463f851d43ef993d68f453d40a14b2f01eada | 8905c0f468d2e486c36a088692f65d59ce4dedda | refs/heads/master | 2021-01-19T20:49:15.951547 | 2018-03-10T01:21:04 | 2018-03-10T01:21:04 | 88,561,660 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 17,198 | cpp | #include "stdafx.h"
U32 gInputMode;
static U32 sLastMovement;
static U32 sPausedAmount;
static bool CALLBACK _terminateAppEnum( HWND hwnd, LPARAM lParam )
{
DWORD dwID;
GetWindowThreadProcessId( hwnd, &dwID );
if( dwID == ( DWORD ) lParam )
{
PostMessage( hwnd, WM_CLOSE, 0, 0 );
}
return TRUE;
}
struct Nugget
{
U64 usec;
U32 msec;
U08 data;
};
const int sNumNuggets = 1024;
static int sNuggetHead;
static int sNuggetTail;
static Nugget sNuggets[sNumNuggets];
static U32 _pc2ms( U64 val ) // NOTE: this function is not yet tested and has not worked yet
{
static F64 pff64;
static U64 pfu64;
if( pff64 == 0.0 ) pff64 = F64(qpf());
if( pfu64 == 0 ) pfu64 = qpf();
static U64 qpc0ms;
if( !qpc0ms )
{
qpc0ms = qpc();
qpc0ms -= U64((F64(rtmsec())/1000.0)*pff64);
}
U64 delta_qpc = val - qpc0ms;
return U32( ( delta_qpc * 1000ULL ) / pfu64 );
}
static void _stuff( U08 data )
{
Nugget &n = sNuggets[sNuggetHead];
n.data = data;
n.usec = rtusec();
n.msec = rtmsec();
sNuggetHead++;
if( sNuggetHead >= sNumNuggets ) sNuggetHead = 0;
if( sNuggetHead == sNuggetTail )
{
printf( "NUGGET FIFO FULL!\n" );
}
}
static bool _grab( U32 *msec, U64 *usec, U08 *data )
{
if( sNuggetHead == sNuggetTail ) return false;
Nugget &n = sNuggets[sNuggetTail];
*msec = n.msec;
*data = n.data;
*usec = n.usec;
sNuggetTail++;
if( sNuggetTail >= sNumNuggets ) sNuggetTail = 0;
return true;
}
void input_init( void )
{
static RAWINPUTDEVICE *devs;
static RAWINPUTDEVICELIST *dList;
U32 numDevices = 0;
int ndevs = 0;
GetRawInputDeviceList( NULL, &numDevices, sizeof( RAWINPUTDEVICELIST ) );
printf( "There are %d raw input devices attached to the system\n", numDevices );
if( !dList ) dList = (RAWINPUTDEVICELIST *) calloc( numDevices, sizeof( RAWINPUTDEVICELIST ) );
if( !devs ) devs = (RAWINPUTDEVICE *) calloc( numDevices, sizeof( RAWINPUTDEVICE ) );
GetRawInputDeviceList( dList, &numDevices, sizeof( RAWINPUTDEVICELIST ) );
if( 1 )
{
int i;
const char *tname[] = { "MOUSE", "KEYBOARD", "HID" };
for( i=0; i<int(numDevices); i++ )
{
printf( "raw input type %s\n", tname[dList[i].dwType] ); // , dList[i].hDevice );
RID_DEVICE_INFO info = {0};
char name[1024] = {0};
U32 di_size = info.cbSize = sizeof( RID_DEVICE_INFO );
GetRawInputDeviceInfo( dList[i].hDevice, RIDI_DEVICEINFO, &info, &di_size );
U32 nm_size = sizeof( name ) - 1;
GetRawInputDeviceInfo( dList[i].hDevice, RIDI_DEVICENAME, name, &nm_size );
printf( "device name: %s\n", name );
if( info.dwType == RIM_TYPEMOUSE )
{
printf( "mouse id:%d numbut:%d srate:%d hashw:%d\n",
info.mouse.dwId,
info.mouse.dwNumberOfButtons,
info.mouse.dwSampleRate,
info.mouse.fHasHorizontalWheel );
static bool mouseregistered;
if( !mouseregistered )
{
// Register for mouse raw input
devs[ndevs].usUsagePage = 1;
devs[ndevs].usUsage = 2;
devs[ndevs].dwFlags = 0;
devs[ndevs].hwndTarget=NULL;
ndevs++;
mouseregistered = true;
}
}
else if( info.dwType == RIM_TYPEHID )
{
if( info.hid.dwVendorId == 0x0801 )
{
printf( "Found MagTek card reader\n" );
}
printf( "HID vid: %08x, pid: %08x, ver: %d usagepage: %d usage: %d\n",
info.hid.dwVendorId, info.hid.dwProductId, info.hid.dwVendorId, info.hid.usUsagePage, info.hid.usUsage );
devs[ndevs].usUsagePage = info.hid.usUsagePage;
devs[ndevs].usUsage = info.hid.usUsage;
devs[ndevs].dwFlags = 0;
devs[ndevs].hwndTarget = NULL;
ndevs++;
}
else if( info.dwType == RIM_TYPEKEYBOARD )
{
printf( "keyboard type: %d subtype: %d mode: %d funckeys: %d indicators: %d totalkeys: %d\n",
info.keyboard.dwType, info.keyboard.dwSubType, info.keyboard.dwKeyboardMode, info.keyboard.dwNumberOfFunctionKeys, info.keyboard.dwNumberOfIndicators, info.keyboard.dwNumberOfKeysTotal );
static bool keyboardregistered;
if( !keyboardregistered )
{
devs[ndevs].usUsagePage = 1;
devs[ndevs].usUsage = 6;
devs[ndevs].dwFlags = 0;
devs[ndevs].hwndTarget = NULL;
ndevs++;
keyboardregistered = true;
}
}
else
{
printf( "Unknown device type\n" );
}
}
}
if( ndevs ) RegisterRawInputDevices( devs, ndevs, sizeof( RAWINPUTDEVICE ) );
RegisterTouchWindow( get_main_window(), TWF_WANTPALM );
}
static void input_remove_callback( const void *_input )
{
PlayerInput *input = ( PlayerInput * ) _input;
if( input ) delete input;
}
Alist inputs( input_remove_callback );
PlayerInput::PlayerInput( U64 _input_id, INPUT_TYPE itype )
{
t = itype;
unused = false;
showcursor = true;
input_id = _input_id;
F32 brpos[3];
brpos[0] = 1920 / 2;
brpos[1] = 0;
x = brpos[0];
y = brpos[1];
memset( irot, 0, sizeof( irot ) );
buttons = 0;
r.top = 0;
r.bottom = get_height();
r.left = 0;
r.right = get_width();
hscroll = 0;
vscroll = 0;
memset( mb, 0, sizeof( mb ) );
inputs += this;
}
PlayerInput::~PlayerInput()
{
}
PlayerInput *PlayerInput::getUnused( U64 new_input_id )
{
int i;
int uidx = -1;
for( i=0; i<inputs; i++ )
{
PlayerInput *pi = ( PlayerInput * ) inputs[i];
if( pi->unused )
{
pi->input_id = new_input_id;
pi->unused = false;
return pi;
}
}
return NULL;
}
PlayerInput *PlayerInput::get( U64 input_id )
{
int i;
int uidx = -1;
for( i=0; i<inputs; i++ )
{
PlayerInput *pi = ( PlayerInput * ) inputs[i];
if( pi->input_id == input_id ) return pi;
}
return NULL;
}
static bool sDisableTransforms = true;
U32
PlayerInput::deliverRawData( U32 ms, int _dx, int _dy, U32 _buttons, bool _showcursor, bool from_network )
{
U32 rval = 0;
bool moved = false;
_dy = (-(_dy));
dx = F32(_dx);
dy = F32(_dy);
buttons = _buttons;
int i;
for( i=0; i<sizeof(mb); i++ )
{
if( buttons & (1<<(i<<1)) ) mb[i] = 1;
else if( buttons & (2<<(i<<1)) ) mb[i] = 0;
}
if( mb[5] )
{
vscroll += ( S32(buttons) >> 16 );
moved = true;
}
if( mb[6] )
{
hscroll += ( S32(buttons) >> 16 );
moved = true;
}
if( dx != 0 || dy != 0 ) moved = true;
F32 tdx = dx;
F32 tdy = dy;
// perform per-player rotations
if( gInputMode == INPUT_MODE_MULTI_MOUSE && !sDisableTransforms )
{
tdx = irot[0][0] * dx + irot[1][0] * dy;
tdy = irot[0][1] * dx + irot[1][1] * dy;
}
dx = tdx;
dy = tdy;
x += dx;
y += dy;
if( x < r.left ) x = F32(r.left);
if( x > r.right ) x = F32(r.right);
if( y < r.top ) y = F32(r.top);
if( y > r.bottom ) y = F32(r.bottom);
F32 tx = x;
F32 ty = y;
return rval;
}
U32
timeSinceLastMovement( void )
{
return msec() - sLastMovement;
}
U32
PlayerInput::deliverTouchData( U32 msec, int abs_x, int abs_y, U32 buttons, bool _showcursor )
{
U32 rval = 0;
static int initted;
static Dinfo di;
if( !initted )
{
di = getDisplayInfo( gCenterScreenIndex );
}
abs_x -= di.rect.left;
abs_y -= di.rect.top;
abs_x = ( abs_x * 1920 ) / get_width();
abs_y = ( abs_y * 1080 ) / get_height();
abs_y = 1080 - abs_y;
dx = abs_x - x;
dy = abs_y - y;
// printf( "deliverTouchData : %08x %08d %.1f %.1f %d %d %u\n", this, msec, x, y, abs_x, abs_y, buttons );
rval = deliverRawData( msec, int(dx), int(-dy), buttons );
showcursor = _showcursor;
return rval;
}
AImage *cursor;
// position from the top left of the tip of the cursor
// positive x to the right positive y down
static F32 _cursor_tip_pos[2] = { 11.0f, 8.0f };
void
PlayerInput::draw( void )
{
int i;
Afont f;
static F32 hw,hh;
glDepthMask( GL_FALSE );
glDisable( GL_DEPTH_TEST );
if( !cursor )
{
cursor = new AImage( file_find( "arrow_cursor.png" ) );
hw = cursor->getWidth() * 0.5f;
hh = cursor->getHeight() * 0.5f;
}
glEnable( GL_TEXTURE_2D );
for( i=0; i<inputs; i++ )
{
PlayerInput *pi = ( PlayerInput * ) inputs[i];
if( !pi->showcursor ) continue;
cursor->bindtex();
glPushMatrix();
glTranslatef( (F32)pi->getX(), (F32)pi->getY(), 0.0f );
if( gInputMode == INPUT_MODE_MULTI_MOUSE && !sDisableTransforms )
{
F32 m[4][4] = {0};
m[0][0] = pi->irot[0][0];
m[0][1] = pi->irot[0][1];
m[1][0] = pi->irot[1][0];
m[1][1] = pi->irot[1][1];
m[2][2] = m[3][3] = 1;
glMultMatrixf( &m[0][0] );
}
glTranslatef( hw-_cursor_tip_pos[0], -hh+_cursor_tip_pos[1], 0.0f );
draw_textured_frame( 0.0f, 0.0f, hw, hh, 0xffffffff );
// f.pos(0,0);
// f.printf( "%08x", pi->getButtons() );
glPopMatrix();
}
}
void PlayerInput::TouchInput( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
if( gInputMode != INPUT_MODE_MULTI_TOUCH && gInputMode != INPUT_MODE_MULTI_TOUCH_MULTI_MOUSE ) return;
int ninputs = (int) wParam;
TOUCHINPUT *input;
input = ( TOUCHINPUT * ) alloca( sizeof( TOUCHINPUT ) * ninputs );
GetTouchInputInfo( (HTOUCHINPUT) lParam, ninputs, input, sizeof( TOUCHINPUT ) );
int i;
for( i=0; i<ninputs; i++ )
{
TOUCHINPUT &in = input[i];
U64 unique_id = in.dwID + 0x60000ULL;
PlayerInput *pi = PlayerInput::get( unique_id );
if( !pi )
{
static int unique_idx;
pi = new PlayerInput( unique_id+unique_idx );
}
U32 buttons = 0;
if( in.dwFlags & TOUCHEVENTF_DOWN ) buttons |= 1;
if( in.dwFlags & TOUCHEVENTF_UP ) buttons |= 2;
// if( in.dwFlags & TOUCHEVENTF_MOVE )
pi->deliverTouchData( msec(), in.x/100, in.y/100, buttons );
// in.cxContact, in.cyContact, in.dwExtraInfo, in.dwFlags, in.dwID, in.dwMask, in.dwTime, in.hSource, in.x, in.y
// printf( "touch input %d: pinput 0x%x %d %d (%02x)\n",i, pi, in.x, in.y, in.dwFlags );
}
CloseTouchInputHandle( (HTOUCHINPUT) lParam );
}
void PlayerInput::RawInput( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
if( gInputMode != INPUT_MODE_MULTI_MOUSE && gInputMode != INPUT_MODE_MULTI_TOUCH_MULTI_MOUSE ) return;
UINT dwSize;
GetRawInputData((HRAWINPUT)lParam, RID_INPUT, NULL, &dwSize,
sizeof(RAWINPUTHEADER));
LPBYTE lpb = ( LPBYTE ) alloca( dwSize );
if (lpb == NULL)
{
return;
}
if (GetRawInputData((HRAWINPUT)lParam, RID_INPUT, lpb, &dwSize,
sizeof(RAWINPUTHEADER)) != dwSize )
OutputDebugString (TEXT("GetRawInputData doesn't return correct size !\n"));
RAWINPUT* raw = (RAWINPUT*)lpb;
if( (raw->header.dwType == RIM_TYPEMOUSE) )
{
UINT di_size,rval;
if( 0 )
{
RID_DEVICE_INFO info;
di_size = sizeof( RID_DEVICE_INFO );
rval = GetRawInputDeviceInfo( raw->header.hDevice, RIDI_DEVICEINFO, &info, &di_size );
printf( "mouse id:%d numbut:%d srate:%d hashw:%d\n",
info.mouse.dwId,
info.mouse.dwNumberOfButtons,
info.mouse.dwSampleRate,
info.mouse.fHasHorizontalWheel );
}
U32 cksum = 0;
{
char name[1024];
name[0] = 0;
di_size = sizeof(name);
rval = GetRawInputDeviceInfo( raw->header.hDevice, RIDI_DEVICENAME, &name[0], &di_size );
cksum = cksum_data( 0, name, strlen( name ) );
// printf( "mouse name:%s nlen:%d cksum:%08x\n", name, di_size, cksum );
}
if( raw->data.mouse.usButtonData )
{
static int a;
a = 3;
}
if( 0 ) printf("Mouse: dv=%x Flg=%08x But=%04x BFlg=%08x BtnDat=%08x RwBut=%08x dx=%04x dy=%04x xtra=%08x\n",
raw->header.hDevice,
raw->data.mouse.usFlags,
raw->data.mouse.ulButtons,
raw->data.mouse.usButtonFlags,
raw->data.mouse.usButtonData,
raw->data.mouse.ulRawButtons,
raw->data.mouse.lLastX,
raw->data.mouse.lLastY,
raw->data.mouse.ulExtraInformation);
U64 input_id = cksum;
U64 player_id = 0; // Player::input_id_to_player_id( cksum );
if( !player_id )
{
static volatile int a;
a = 0;
}
PlayerInput *pi = PlayerInput::get( input_id );
if( !pi )
{
RID_DEVICE_INFO info;
di_size = sizeof( RID_DEVICE_INFO );
rval = GetRawInputDeviceInfo( raw->header.hDevice, RIDI_DEVICEINFO, &info, &di_size );
printf( "mouse id:%d numbut:%d srate:%d hashw:%d\n",
info.mouse.dwId,
info.mouse.dwNumberOfButtons,
info.mouse.dwSampleRate,
info.mouse.fHasHorizontalWheel );
INPUT_TYPE t = INPUT_TYPE_MOUSE;
pi = new PlayerInput( input_id, t );
}
pi->deliverRawData( msec(),
raw->data.mouse.lLastX,
raw->data.mouse.lLastY,
raw->data.mouse.ulButtons );
}
else if( (raw->header.dwType == RIM_TYPEHID) )
{
// printf( "RAW HID input received\n" );
// printf( "data size: %d", raw->data.hid.dwSizeHid );
int i;
for( i=0; i<int(raw->data.hid.dwSizeHid); i++ )
{
// if( !( i&31 ) ) printf( "\n" );
// printf( "%02x ", raw->data.hid.bRawData[i] );
}
// printf( "\n" );
}
else if( (raw->header.dwType == RIM_TYPEKEYBOARD) )
{
static int lastvkey;
static int lastflag;
// printf( "Raw keyboard data received %d %x\n", raw->data.keyboard.Flags, raw->data.keyboard.VKey );
if( 0 )
{
printf(" Kbd: make=%04x Flags:%04x Reserved:%04x ExtraInformation:%08x, msg=%04x VK=%04x \n",
raw->data.keyboard.MakeCode,
raw->data.keyboard.Flags,
raw->data.keyboard.Reserved,
raw->data.keyboard.ExtraInformation,
raw->data.keyboard.Message,
raw->data.keyboard.VKey );
}
lastvkey = raw->data.keyboard.VKey;
lastflag = raw->data.keyboard.Flags;
}
}
static KeyInput *ki;
DWORD WINAPI KeyInput::MyThreadFunction( LPVOID lpParam )
{
if( ki )
{
printf( "Ki already exists\n" );
}
if( !ki ) ki = new KeyInput();
MSG msg;
while( 1 )
{
if(PeekMessage (&msg, NULL, 0, 0, PM_REMOVE) != 0)
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
else
{
#ifdef TWO_WINDOWS
if( GetForegroundWindow() == get_main_window() )
{
printf( "Grabbing focus away from main window to the hidden input window\n" );
SetForegroundWindow( hwnd );
}
else
#endif
Sleep(1);
}
}
return 0;
}
void hidden_window_key_input_init( void )
{
static DWORD threadId;
if( threadId )
{
printf( "Error: Thread already exists\n" );
}
CreateThread(
NULL, // default security attributes
0, // use default stack size
KeyInput::MyThreadFunction, // thread function name
0, // argument to thread function
0, // use default creation flags
&threadId);
}
static LRESULT CALLBACK sMainWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
case WM_MOUSEMOVE:
case WM_LBUTTONDOWN:
case WM_LBUTTONUP:
case WM_MOUSEHWHEEL:
case WM_MOUSEWHEEL:
case WM_LBUTTONDBLCLK:
case WM_MBUTTONDOWN:
case WM_MBUTTONUP:
case WM_MBUTTONDBLCLK:
case WM_RBUTTONDOWN:
case WM_RBUTTONUP:
case WM_RBUTTONDBLCLK:
case WM_TOUCH:
case WM_KEYDOWN:
case WM_KEYUP:
// just forward these messages over to the main window as they aren't time sensitive -- just the raw data is of concern to use the timing
PostMessage( get_main_window(), msg, wParam, lParam );
break;
case WM_INPUT:
PlayerInput::RawInput( hwnd, msg, wParam, lParam );
break;
default:
// printf( "%-6dMSG %4x on win lParam = 0x%08x wParam = %d wnd = %d\n", msec(), msg, lParam, wParam, hwnd );
break;
}
return DefWindowProc(hwnd, msg, wParam, lParam);
}
HWND KeyInput::hwnd;
WNDCLASSEX KeyInput::wcx;
KeyInput::KeyInput()
{
hwnd = 0;
wcx.cbSize = sizeof(wcx);
wcx.style = CS_DBLCLKS;
wcx.lpfnWndProc = sMainWndProc;
wcx.cbClsExtra = 0;
wcx.cbWndExtra = 0;
wcx.hInstance = 0;
wcx.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wcx.hCursor = LoadCursor(NULL, IDC_ARROW);
wcx.hbrBackground = (HBRUSH) (COLOR_WINDOW);
wcx.lpszMenuName = NULL;
wcx.lpszClassName = "A";
wcx.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
if (!RegisterClassEx(&wcx))
{
printf( "Error\n" );
exit(0);
}
#ifdef TWO_WINDOWS
openWindow();
if (!hwnd)
{
printf( "Error\n" );
exit(0);
}
ShowWindow(hwnd,SW_SHOW);
#endif
}
KeyInput::~KeyInput()
{
CloseWindow( hwnd );
hwnd = NULL;
}
void
KeyInput::openWindow( void )
{
if( hwnd )
{
printf( "Error: window already opened\n" );
CloseWindow( hwnd );
hwnd = NULL;
}
hwnd = CreateWindowEx(0, "A", "B",
WS_POPUP | WS_CLIPCHILDREN | WS_CLIPSIBLINGS,
0, 0, 1, 1, HWND_DESKTOP, 0, 0, 0 );
}
void
input_draw( void )
{
draw_in_screen_coord();
}
static int sIndex;
static bool sStartPressed;
static bool sLeftPressed;
static bool sRightPressed;
static bool sUpPressed;
static bool sDownPressed;
static bool sForwardPressed;
static bool sBackPressed;
static bool sBut1Pressed;
static bool sBut2Pressed;
bool input_button_pressed( ButtonEnum b )
{
if( b == BUTT_START ) return sStartPressed;
else if( b == BUTT_MOVE_LEFT ) return sLeftPressed;
else if( b == BUTT_MOVE_RIGHT ) return sRightPressed;
else if( b == BUTT_MOVE_UP ) return sUpPressed;
else if( b == BUTT_MOVE_DOWN ) return sDownPressed;
else if( b == BUTT_MOVE_FORWARD ) return sForwardPressed;
else if( b == BUTT_MOVE_BACKWARD ) return sBackPressed;
else if( b == BUTT_BUTTON1 ) return sBut1Pressed;
else if( b == BUTT_BUTTON2 ) return sBut2Pressed;
return false;
}
void input_button_addevent( ButtonEnum b, bool onoff )
{
}
void input_adjust_for_pause( U32 dtms )
{
sPausedAmount += dtms;
}
void
input_write( FILE *f )
{
}
void
input_reset( void )
{
}
| [
"Aaron_Hightower@comcast.com"
] | Aaron_Hightower@comcast.com |
2021e5b527e027c58cd67c17267d4690659604f8 | 3084462cc596f0d513edd65a9d7dd514a7284cc0 | /DP/11.EggDrop.cpp | 6e95de32fc3c7f4768ebf3fce233b62ff372cd28 | [] | no_license | atlas25git/DSA_Mastery | 8d330f120a040105ff3932701009f289963ec2b3 | 97236ff9ada502af2ee2526c8568d3163e4daa2e | refs/heads/master | 2023-07-07T14:22:43.127799 | 2021-08-04T14:44:49 | 2021-08-04T14:44:49 | 303,709,740 | 5 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,226 | cpp | // Suppose you have N eggs and you want to determine from which floor in a K-floor building you can drop an egg such that it doesn't break. You have to determine the minimum number of attempts you need in order find the critical floor in the worst case while using the best strategy.There are few rules given below.
// An egg that survives a fall can be used again.
// A broken egg must be discarded.
// The effect of a fall is the same for all eggs.
// If the egg doesn't break at a certain floor, it will not break at any floor below.
// If the eggs breaks at a certain floor, it will break at any floor above.
// For more description on this problem see wiki page
// Input:
// The first line of input is T denoting the number of testcases.Then each of the T lines contains two positive integer N and K where 'N' is the number of eggs and 'K' is number of floor in building.
// Output:
// For each test case, print a single line containing one integer the minimum number of attempt you need in order find the critical floor.
// Constraints:
// 1<=T<=30
// 1<=N<=10
// 1<=K<=50
// Example:
// Input:
// 2
// 2 10
// 3 5
// Output:
// 4
// 3
#include <bits/stdc++.h>
using namespace std;
//********************************************RECURSIVE****************************************************************
int flr(int k,int n)
{
//Here notice the fact that we are asked for the min attempts for the worst case
//of finding out the threshold floor.
//Step 2> Base cases:
if(k>1 && n==1)return k;//We aren't considering the case of 0 eggs because just at when the
//egg count is to be reduced by ,the base case will be hit, and would return rem. k
if(k==1 && n>=1) return 1;//if just one floor is left ,then all we need is one trial
if(k==0 && n>=1) return 0;
// if (k == 1 || k == 0)
// return k;
// if (n == 1)
// return k;
//Here we are iteratively try for all the k floors and out of them will choose the min. no of trials required
//for a worst case scenario
//It is like we are dropping from say nth floor, and we iterate all of the k floors to find
//this optimized nth floor
int res=9999;
for(int i=1;i<=k;i++)
{
int sub_res=max(
//1. Egg Breaks
flr(i-1,n-1),
//2. Doesn't Breaks
flr(k-i,n)
);
res=min(res,sub_res);
}
return res +1;
}
//***********************************************************DP******************************************************
int flrdp(int f,int e)
{
//since 2 dimensions are changing in the rec. call, therefore 2 dimension dp table
//we will need f+1, for f values which ranges from 0,f,
//and since e ranges from 1 to e, using e elements could suffice but for the sake of
//using it with index no, not by -1, we do this
int dp[f+1][e+1]; int res;
// **********dp-table**************
// 0 1 2 3 1.Since we are using the egg col index-1 we ill ignore for e=0,
// 0 #|0|0|0 as it is also not defined by our base case.
// 1 #|1|1|1
// 2 #|2| |
// 3 #|3| |
// 4 #|4| |
// 5 #|5| |
for(int i=1;i<=e;i++)
{
dp[0][i]=0;
dp[1][i]=1;
}
for(int i=2;i<=f;i++)
dp[i][1]=i;
for(int i=2;i<=f;i++)
{
for(int j=2;j<=e;j++)
{
dp[i][j]= INT_MAX;
for(int x =1;x<=i;x++)
{
// dp[i][j]= min(dp[i][j],
// 1+max(dp[i-1][j-1],
// dp[i-x][j])
// );
res = 1 + max(
dp[i-1][j-1],
dp[i-x][j]);
if (res < dp[i][j])
dp[i][j] = res;
// res = 1 + max(
// dp[i - 1][x - 1],
// dp[i][j - x]);
// if (res < dp[i][j])
// dp[i][j] = res;
// int r = 1+max(dp[i-1][j-1],
// dp[i-x][j]);
// if(dp[i][j]< r) dp[i][j]=r;
}
}
}
return dp[f][e];
}
int res(int n, int f)
{
int dp[n + 1][f + 1];
int res;
for (int i = 1; i <= n; i++) {
dp[i][1] = 1;
dp[i][0] = 0;
}
for (int j = 1; j <= f; j++)
dp[1][j] = j;
for (int i = 2; i <= n; i++) {
for (int j = 2; j <= f; j++) {
dp[i][j] = INT_MAX;
for (int x = 1; x <= j; x++) {
res = 1 + max(
dp[i - 1][x - 1],
dp[i][j - x]);
if (res < dp[i][j])
dp[i][j] = res;
}
}
}
return dp[n][f];
}
int main() {
freopen("input.txt","r",stdin);
int t;cin>>t;
while(t--){
int n,k;
cin>>n>>k;
cout<<flrdp(k,n)<<"\n";
}
return 1;
} | [
"atlas.sarthak@gmail.com"
] | atlas.sarthak@gmail.com |
1156e205c3905c8a7cdf33add20d444e77db7a1a | dd2d38732611466e18135f11778653731335e881 | /1400LOG/test/main.cpp | 6fa222a8f0fd69662687da8887eb62f6fe7bf950 | [] | no_license | wwlong/tools_study | d4fe05e52fca0ee6a6a7ea6a11ffbd787e79afb6 | 05dbde02b71faadd90e8b753e23b8e8377c97a17 | refs/heads/master | 2021-04-03T08:39:27.776935 | 2018-12-26T05:50:26 | 2018-12-26T05:50:26 | 124,504,077 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 602 | cpp | #include <stdio.h>
#include <string.h>
#include "1400log.h"
int main()
{
const char *logname = "log.txt";
LP_DG_LOG logHandler = log_init(logname);
if(NULL == logHandler) {
printf("logHandler init failed\n");
return -1;
}
log_enable(logHandler);
int count = 0;
while(1) {
char msg[1024];
memset(msg, 0, sizeof(msg));
sprintf(msg, "hello_%d", count ++);
log_save(logHandler, msg);
count ++;
if(count > 100) {
break;
}
}
//清理资源
log_deinit(logHandler);
return 0;
} | [
"wenlongwang@deepglint.com"
] | wenlongwang@deepglint.com |
3128d4a5ce3fc6ea77f2ef0b56c9f0abdba07c24 | ba4c8a718594f43fb2c5a2ec11c066274ec70445 | /openCV/sources/modules/highgui/src/cap_gstreamer.cpp | 769de7fd5f50e87b5154fd2f4fcea221f71fbc69 | [
"BSD-3-Clause"
] | permissive | jayparekhjp/openCV-Facial-Recognition | d7d83e1cd93a878d91e129dd5f754a50fde973a2 | c351d55863bbc40c3225f55152dcd044f778119f | refs/heads/master | 2020-04-02T03:18:43.346991 | 2018-10-20T23:45:42 | 2018-10-20T23:45:42 | 153,957,654 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 54,644 | cpp | /*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// Intel License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2008, 2011, Nils Hasler, all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's 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.
//
// * The name of Intel Corporation may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors "as is" and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation 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.
//
//M*/
/*!
* \file cap_gstreamer.cpp
* \author Nils Hasler <hasler@mpi-inf.mpg.de>
* Max-Planck-Institut Informatik
* \author Dirk Van Haerenborgh <vhdirk@gmail.com>
*
* \brief Use GStreamer to read/write video
*/
#include "precomp.hpp"
#include <unistd.h>
#include <string.h>
#include <gst/gst.h>
#include <gst/gstbuffer.h>
#include <gst/video/video.h>
#include <gst/app/gstappsink.h>
#include <gst/app/gstappsrc.h>
#include <gst/riff/riff-media.h>
#include <gst/pbutils/missing-plugins.h>
#define VERSION_NUM(major, minor, micro) (major * 1000000 + minor * 1000 + micro)
#define FULL_GST_VERSION VERSION_NUM(GST_VERSION_MAJOR, GST_VERSION_MINOR, GST_VERSION_MICRO)
#if FULL_GST_VERSION >= VERSION_NUM(0,10,32)
#include <gst/pbutils/encoding-profile.h>
//#include <gst/base/gsttypefindhelper.h>
#endif
#ifdef NDEBUG
#define CV_WARN(message)
#else
#define CV_WARN(message) fprintf(stderr, "warning: %s (%s:%d)\n", message, __FILE__, __LINE__)
#endif
#if GST_VERSION_MAJOR == 0
#define COLOR_ELEM "ffmpegcolorspace"
#define COLOR_ELEM_NAME "ffmpegcsp"
#elif FULL_GST_VERSION < VERSION_NUM(1,5,0)
#define COLOR_ELEM "videoconvert"
#define COLOR_ELEM_NAME COLOR_ELEM
#else
#define COLOR_ELEM "autovideoconvert"
#define COLOR_ELEM_NAME COLOR_ELEM
#endif
void toFraction(double decimal, double &numerator, double &denominator);
void handleMessage(GstElement * pipeline);
static cv::Mutex gst_initializer_mutex;
/*!
* \brief The gst_initializer class
* Initializes gstreamer once in the whole process
*/
class gst_initializer
{
public:
static void init()
{
gst_initializer_mutex.lock();
static gst_initializer init;
gst_initializer_mutex.unlock();
}
private:
gst_initializer()
{
gst_init(NULL, NULL);
// gst_debug_set_active(1);
// gst_debug_set_colored(1);
// gst_debug_set_default_threshold(GST_LEVEL_INFO);
}
};
/*!
* \brief The CvCapture_GStreamer class
* Use GStreamer to capture video
*/
class CvCapture_GStreamer : public CvCapture
{
public:
CvCapture_GStreamer() { init(); }
virtual ~CvCapture_GStreamer() { close(); }
virtual bool open( int type, const char* filename );
virtual void close();
virtual double getProperty(int);
virtual bool setProperty(int, double);
virtual bool grabFrame();
virtual IplImage* retrieveFrame(int);
protected:
void init();
bool reopen();
bool isPipelinePlaying();
void startPipeline();
void stopPipeline();
void restartPipeline();
void setFilter(const char* prop, int type, int v1, int v2 = 0);
void removeFilter(const char *filter);
static void newPad(GstElement *myelement,
GstPad *pad,
gpointer data);
GstElement* pipeline;
GstElement* uridecodebin;
GstElement* v4l2src;
GstElement* color;
GstElement* sink;
#if GST_VERSION_MAJOR > 0
GstSample* sample;
GstMapInfo* info;
#endif
GstBuffer* buffer;
GstCaps* caps;
IplImage* frame;
gint64 duration;
gint width;
gint height;
double fps;
};
/*!
* \brief CvCapture_GStreamer::init
* inits the class
*/
void CvCapture_GStreamer::init()
{
pipeline = NULL;
uridecodebin = NULL;
v4l2src = NULL;
color = NULL;
sink = NULL;
#if GST_VERSION_MAJOR > 0
sample = NULL;
info = new GstMapInfo;
#endif
buffer = NULL;
caps = NULL;
frame = NULL;
duration = -1;
width = -1;
height = -1;
fps = -1;
}
/*!
* \brief CvCapture_GStreamer::close
* Closes the pipeline and destroys all instances
*/
void CvCapture_GStreamer::close()
{
if (isPipelinePlaying())
this->stopPipeline();
if(pipeline) {
gst_element_set_state(GST_ELEMENT(pipeline), GST_STATE_NULL);
gst_object_unref(GST_OBJECT(pipeline));
pipeline = NULL;
}
duration = -1;
width = -1;
height = -1;
fps = -1;
}
/*!
* \brief CvCapture_GStreamer::grabFrame
* \return
* Grabs a sample from the pipeline, awaiting consumation by retreiveFrame.
* The pipeline is started if it was not running yet
*/
bool CvCapture_GStreamer::grabFrame()
{
if(!pipeline)
return false;
// start the pipeline if it was not in playing state yet
if(!this->isPipelinePlaying())
this->startPipeline();
// bail out if EOS
if(gst_app_sink_is_eos(GST_APP_SINK(sink)))
return false;
#if GST_VERSION_MAJOR == 0
if(buffer)
gst_buffer_unref(buffer);
buffer = gst_app_sink_pull_buffer(GST_APP_SINK(sink));
#else
if(sample)
gst_sample_unref(sample);
sample = gst_app_sink_pull_sample(GST_APP_SINK(sink));
if(!sample)
return false;
buffer = gst_sample_get_buffer(sample);
#endif
if(!buffer)
return false;
return true;
}
/*!
* \brief CvCapture_GStreamer::retrieveFrame
* \return IplImage pointer. [Transfer Full]
* Retreive the previously grabbed buffer, and wrap it in an IPLImage structure
*/
IplImage * CvCapture_GStreamer::retrieveFrame(int)
{
if(!buffer)
return 0;
//construct a frame header if we did not have any yet
if(!frame)
{
#if GST_VERSION_MAJOR == 0
GstCaps* buffer_caps = gst_buffer_get_caps(buffer);
#else
GstCaps* buffer_caps = gst_sample_get_caps(sample);
#endif
// bail out in no caps
assert(gst_caps_get_size(buffer_caps) == 1);
GstStructure* structure = gst_caps_get_structure(buffer_caps, 0);
// bail out if width or height are 0
if(!gst_structure_get_int(structure, "width", &width) ||
!gst_structure_get_int(structure, "height", &height))
{
gst_caps_unref(buffer_caps);
return 0;
}
int depth = 3;
#if GST_VERSION_MAJOR > 0
depth = 0;
const gchar* name = gst_structure_get_name(structure);
const gchar* format = gst_structure_get_string(structure, "format");
if (!name || !format)
return 0;
// we support 3 types of data:
// video/x-raw, format=BGR -> 8bit, 3 channels
// video/x-raw, format=GRAY8 -> 8bit, 1 channel
// video/x-bayer -> 8bit, 1 channel
// bayer data is never decoded, the user is responsible for that
// everything is 8 bit, so we just test the caps for bit depth
if (strcasecmp(name, "video/x-raw") == 0)
{
if (strcasecmp(format, "BGR") == 0) {
depth = 3;
}
else if(strcasecmp(format, "GRAY8") == 0){
depth = 1;
}
}
else if (strcasecmp(name, "video/x-bayer") == 0)
{
depth = 1;
}
#endif
if (depth > 0) {
frame = cvCreateImageHeader(cvSize(width, height), IPL_DEPTH_8U, depth);
} else {
gst_caps_unref(buffer_caps);
return 0;
}
gst_caps_unref(buffer_caps);
}
// gstreamer expects us to handle the memory at this point
// so we can just wrap the raw buffer and be done with it
#if GST_VERSION_MAJOR == 0
frame->imageData = (char *)GST_BUFFER_DATA(buffer);
#else
// the data ptr in GstMapInfo is only valid throughout the mapifo objects life.
// TODO: check if reusing the mapinfo object is ok.
gboolean success = gst_buffer_map(buffer,info, (GstMapFlags)GST_MAP_READ);
if (!success){
//something weird went wrong here. abort. abort.
//fprintf(stderr,"GStreamer: unable to map buffer");
return 0;
}
frame->imageData = (char*)info->data;
gst_buffer_unmap(buffer,info);
#endif
return frame;
}
/*!
* \brief CvCapture_GStreamer::isPipelinePlaying
* \return if the pipeline is currently playing.
*/
bool CvCapture_GStreamer::isPipelinePlaying()
{
GstState current, pending;
GstClockTime timeout = 5*GST_SECOND;
if(!GST_IS_ELEMENT(pipeline)){
return false;
}
GstStateChangeReturn ret = gst_element_get_state(GST_ELEMENT(pipeline),¤t, &pending, timeout);
if (!ret){
//fprintf(stderr, "GStreamer: unable to query pipeline state\n");
return false;
}
return current == GST_STATE_PLAYING;
}
/*!
* \brief CvCapture_GStreamer::startPipeline
* Start the pipeline by setting it to the playing state
*/
void CvCapture_GStreamer::startPipeline()
{
CV_FUNCNAME("icvStartPipeline");
__BEGIN__;
//fprintf(stderr, "relinked, pausing\n");
GstStateChangeReturn status = gst_element_set_state(GST_ELEMENT(pipeline), GST_STATE_PLAYING);
if (status == GST_STATE_CHANGE_ASYNC)
{
// wait for status update
status = gst_element_get_state(pipeline, NULL, NULL, GST_CLOCK_TIME_NONE);
}
if (status == GST_STATE_CHANGE_FAILURE)
{
handleMessage(pipeline);
gst_object_unref(pipeline);
pipeline = NULL;
CV_ERROR(CV_StsError, "GStreamer: unable to start pipeline\n");
return;
}
//printf("state now playing\n");
handleMessage(pipeline);
__END__;
}
/*!
* \brief CvCapture_GStreamer::stopPipeline
* Stop the pipeline by setting it to NULL
*/
void CvCapture_GStreamer::stopPipeline()
{
CV_FUNCNAME("icvStopPipeline");
__BEGIN__;
//fprintf(stderr, "restarting pipeline, going to ready\n");
if(gst_element_set_state(GST_ELEMENT(pipeline), GST_STATE_NULL) ==
GST_STATE_CHANGE_FAILURE) {
CV_ERROR(CV_StsError, "GStreamer: unable to stop pipeline\n");
gst_object_unref(pipeline);
pipeline = NULL;
return;
}
__END__;
}
/*!
* \brief CvCapture_GStreamer::restartPipeline
* Restart the pipeline
*/
void CvCapture_GStreamer::restartPipeline()
{
handleMessage(pipeline);
this->stopPipeline();
this->startPipeline();
}
/*!
* \brief CvCapture_GStreamer::setFilter
* \param prop the property name
* \param type glib property type
* \param v1 the value
* \param v2 second value of property type requires it, else NULL
* Filter the output formats by setting appsink caps properties
*/
void CvCapture_GStreamer::setFilter(const char *prop, int type, int v1, int v2)
{
//printf("GStreamer: setFilter \n");
if(!caps || !( GST_IS_CAPS (caps) ))
{
if(type == G_TYPE_INT)
{
#if GST_VERSION_MAJOR == 0
caps = gst_caps_new_simple("video/x-raw-rgb", prop, type, v1, NULL);
#else
caps = gst_caps_new_simple("video/x-raw","format",G_TYPE_STRING,"BGR", prop, type, v1, NULL);
#endif
}
else
{
#if GST_VERSION_MAJOR == 0
caps = gst_caps_new_simple("video/x-raw-rgb", prop, type, v1, v2, NULL);
#else
caps = gst_caps_new_simple("video/x-raw","format",G_TYPE_STRING,"BGR", prop, type, v1, v2, NULL);
#endif
}
}
else
{
#if GST_VERSION_MAJOR > 0
if (! gst_caps_is_writable(caps))
caps = gst_caps_make_writable (caps);
#endif
if(type == G_TYPE_INT){
gst_caps_set_simple(caps, prop, type, v1, NULL);
}else{
gst_caps_set_simple(caps, prop, type, v1, v2, NULL);
}
}
#if GST_VERSION_MAJOR > 0
caps = gst_caps_fixate(caps);
#endif
gst_app_sink_set_caps(GST_APP_SINK(sink), caps);
//printf("filtering with %s\n", gst_caps_to_string(caps));
}
/*!
* \brief CvCapture_GStreamer::removeFilter
* \param filter filter to remove
* remove the specified filter from the appsink template caps
*/
void CvCapture_GStreamer::removeFilter(const char *filter)
{
if(!caps)
return;
#if GST_VERSION_MAJOR > 0
if (! gst_caps_is_writable(caps))
caps = gst_caps_make_writable (caps);
#endif
GstStructure *s = gst_caps_get_structure(caps, 0);
gst_structure_remove_field(s, filter);
gst_app_sink_set_caps(GST_APP_SINK(sink), caps);
}
/*!
* \brief CvCapture_GStreamer::newPad link dynamic padd
* \param pad
* \param data
* decodebin creates pads based on stream information, which is not known upfront
* on receiving the pad-added signal, we connect it to the colorspace conversion element
*/
void CvCapture_GStreamer::newPad(GstElement * /*elem*/,
GstPad *pad,
gpointer data)
{
GstPad *sinkpad;
GstElement *color = (GstElement *) data;
sinkpad = gst_element_get_static_pad (color, "sink");
if (!sinkpad){
//fprintf(stderr, "Gstreamer: no pad named sink\n");
return;
}
gst_pad_link (pad, sinkpad);
gst_object_unref (sinkpad);
}
/*!
* \brief CvCapture_GStreamer::open Open the given file with gstreamer
* \param type CvCapture type. One of CV_CAP_GSTREAMER_*
* \param filename Filename to open in case of CV_CAP_GSTREAMER_FILE
* \return boolean. Specifies if opening was succesful.
*
* In case of CV_CAP_GSTREAMER_V4L(2), a pipelin is constructed as follows:
* v4l2src ! autoconvert ! appsink
*
*
* The 'filename' parameter is not limited to filesystem paths, and may be one of the following:
*
* - a normal filesystem path:
* e.g. video.avi or /path/to/video.avi or C:\\video.avi
* - an uri:
* e.g. file:///path/to/video.avi or rtsp:///path/to/stream.asf
* - a gstreamer pipeline description:
* e.g. videotestsrc ! videoconvert ! appsink
* the appsink name should be either 'appsink0' (the default) or 'opencvsink'
*
* When dealing with a file, CvCapture_GStreamer will not drop frames if the grabbing interval
* larger than the framerate period. (Unlike the uri or manual pipeline description, which assume
* a live source)
*
* The pipeline will only be started whenever the first frame is grabbed. Setting pipeline properties
* is really slow if we need to restart the pipeline over and over again.
*
* TODO: the 'type' parameter is imo unneeded. for v4l2, filename 'v4l2:///dev/video0' can be used.
* I expect this to be the same for CV_CAP_GSTREAMER_1394. Is anyone actually still using v4l (v1)?
*
*/
bool CvCapture_GStreamer::open( int type, const char* filename )
{
CV_FUNCNAME("cvCaptureFromCAM_GStreamer");
__BEGIN__;
gst_initializer::init();
bool file = false;
bool stream = false;
bool manualpipeline = false;
char *uri = NULL;
uridecodebin = NULL;
GstElementFactory * testfac;
GstStateChangeReturn status;
int cameraID = -1;
if (type == CV_CAP_GSTREAMER_V4L ||
type == CV_CAP_GSTREAMER_V4L2)
{
cameraID = static_cast<int>(reinterpret_cast<intptr_t>(filename));
}
std::stringstream stdstream;
std::string stdfilename;
if (type == CV_CAP_GSTREAMER_V4L)
{
testfac = gst_element_factory_find("v4lsrc");
if (!testfac){
return false;
}
g_object_unref(G_OBJECT(testfac));
stdstream << "v4lsrc device=/dev/video" << cameraID << " ! " << COLOR_ELEM << " ! appsink";
stdfilename = stdstream.str();
filename = stdfilename.c_str();
}
else if (type == CV_CAP_GSTREAMER_V4L2)
{
testfac = gst_element_factory_find("v4l2src");
if (!testfac){
return false;
}
g_object_unref(G_OBJECT(testfac));
stdstream << "v4l2src device=/dev/video" << cameraID << " ! " << COLOR_ELEM << " ! appsink";
stdfilename = stdstream.str();
filename = stdfilename.c_str();
}
// test if we have a valid uri. If so, open it with an uridecodebin
// else, we might have a file or a manual pipeline.
// if gstreamer cannot parse the manual pipeline, we assume we were given and
// ordinary file path.
if(!gst_uri_is_valid(filename))
{
uri = realpath(filename, NULL);
stream = false;
if(uri)
{
uri = g_filename_to_uri(uri, NULL, NULL);
if(uri)
{
file = true;
}
else
{
CV_WARN("GStreamer: Error opening file\n");
close();
return false;
}
}
else
{
GError *err = NULL;
uridecodebin = gst_parse_launch(filename, &err);
if(!uridecodebin)
{
fprintf(stderr, "GStreamer: Error opening bin: %s\n", err->message);
return false;
}
stream = true;
manualpipeline = true;
}
}
else
{
stream = true;
uri = g_strdup(filename);
}
bool element_from_uri = false;
if(!uridecodebin)
{
// At this writing, the v4l2 element (and maybe others too) does not support caps renegotiation.
// This means that we cannot use an uridecodebin when dealing with v4l2, since setting
// capture properties will not work.
// The solution (probably only until gstreamer 1.2) is to make an element from uri when dealing with v4l2.
gchar * protocol = gst_uri_get_protocol(uri);
if (!strcasecmp(protocol , "v4l2"))
{
#if GST_VERSION_MAJOR == 0
uridecodebin = gst_element_make_from_uri(GST_URI_SRC, uri, "src");
#else
uridecodebin = gst_element_make_from_uri(GST_URI_SRC, uri, "src", NULL);
#endif
element_from_uri = true;
}
else
{
uridecodebin = gst_element_factory_make("uridecodebin", NULL);
g_object_set(G_OBJECT(uridecodebin), "uri", uri, NULL);
}
g_free(protocol);
if(!uridecodebin)
{
//fprintf(stderr, "GStreamer: Error opening bin: %s\n", err->message);
close();
return false;
}
}
if (manualpipeline)
{
GstIterator *it = gst_bin_iterate_elements(GST_BIN(uridecodebin));
GstElement *element = NULL;
gboolean done = false;
gchar* name = NULL;
#if GST_VERSION_MAJOR > 0
GValue value = G_VALUE_INIT;
#endif
while (!done)
{
#if GST_VERSION_MAJOR > 0
switch (gst_iterator_next (it, &value))
{
case GST_ITERATOR_OK:
element = GST_ELEMENT (g_value_get_object (&value));
#else
switch (gst_iterator_next (it, (gpointer *)&element))
{
case GST_ITERATOR_OK:
#endif
name = gst_element_get_name(element);
if (name)
{
if (strstr(name, "opencvsink") != NULL || strstr(name, "appsink") != NULL)
{
sink = GST_ELEMENT ( gst_object_ref (element) );
}
else if (strstr(name, COLOR_ELEM_NAME) != NULL)
{
color = GST_ELEMENT ( gst_object_ref (element) );
}
else if (strstr(name, "v4l") != NULL)
{
v4l2src = GST_ELEMENT ( gst_object_ref (element) );
}
g_free(name);
done = sink && color && v4l2src;
}
#if GST_VERSION_MAJOR > 0
g_value_unset (&value);
#endif
break;
case GST_ITERATOR_RESYNC:
gst_iterator_resync (it);
break;
case GST_ITERATOR_ERROR:
case GST_ITERATOR_DONE:
done = TRUE;
break;
}
}
gst_iterator_free (it);
if (!sink)
{
CV_ERROR(CV_StsError, "GStreamer: cannot find appsink in manual pipeline\n");
return false;
}
pipeline = uridecodebin;
}
else
{
pipeline = gst_pipeline_new(NULL);
// videoconvert (in 0.10: ffmpegcolorspace, in 1.x autovideoconvert)
//automatically selects the correct colorspace conversion based on caps.
color = gst_element_factory_make(COLOR_ELEM, NULL);
sink = gst_element_factory_make("appsink", NULL);
gst_bin_add_many(GST_BIN(pipeline), uridecodebin, color, sink, NULL);
if(element_from_uri)
{
if(!gst_element_link(uridecodebin, color))
{
CV_ERROR(CV_StsError, "GStreamer: cannot link color -> sink\n");
gst_object_unref(pipeline);
pipeline = NULL;
return false;
}
}
else
{
g_signal_connect(uridecodebin, "pad-added", G_CALLBACK(newPad), color);
}
if(!gst_element_link(color, sink))
{
CV_ERROR(CV_StsError, "GStreamer: cannot link color -> sink\n");
gst_object_unref(pipeline);
pipeline = NULL;
return false;
}
}
//TODO: is 1 single buffer really high enough?
gst_app_sink_set_max_buffers (GST_APP_SINK(sink), 1);
gst_app_sink_set_drop (GST_APP_SINK(sink), stream);
//do not emit signals: all calls will be synchronous and blocking
gst_app_sink_set_emit_signals (GST_APP_SINK(sink), 0);
#if GST_VERSION_MAJOR == 0
caps = gst_caps_new_simple("video/x-raw-rgb",
"bpp", G_TYPE_INT, 24,
"red_mask", G_TYPE_INT, 0x0000FF,
"green_mask", G_TYPE_INT, 0x00FF00,
"blue_mask", G_TYPE_INT, 0xFF0000,
NULL);
#else
// support 1 and 3 channel 8 bit data, as well as bayer (also 1 channel, 8bit)
caps = gst_caps_from_string("video/x-raw, format=(string){BGR, GRAY8}; video/x-bayer,format=(string){rggb,bggr,grbg,gbrg}");
#endif
gst_app_sink_set_caps(GST_APP_SINK(sink), caps);
gst_caps_unref(caps);
{
status = gst_element_set_state(GST_ELEMENT(pipeline),
file ? GST_STATE_PAUSED : GST_STATE_PLAYING);
if (status == GST_STATE_CHANGE_ASYNC)
{
// wait for status update
status = gst_element_get_state(pipeline, NULL, NULL, GST_CLOCK_TIME_NONE);
}
if (status == GST_STATE_CHANGE_FAILURE)
{
handleMessage(pipeline);
gst_object_unref(pipeline);
pipeline = NULL;
CV_ERROR(CV_StsError, "GStreamer: unable to start pipeline\n");
return false;
}
GstFormat format;
format = GST_FORMAT_DEFAULT;
#if GST_VERSION_MAJOR == 0
if(!gst_element_query_duration(sink, &format, &duration))
#else
if(!gst_element_query_duration(sink, format, &duration))
#endif
{
handleMessage(pipeline);
CV_WARN("GStreamer: unable to query duration of stream");
duration = -1;
}
GstPad* pad = gst_element_get_static_pad(color, "src");
#if GST_VERSION_MAJOR == 0
GstCaps* buffer_caps = gst_pad_get_caps(pad);
#else
GstCaps* buffer_caps = gst_pad_get_current_caps(pad);
#endif
const GstStructure *structure = gst_caps_get_structure (buffer_caps, 0);
if (!gst_structure_get_int (structure, "width", &width))
{
CV_WARN("Cannot query video width\n");
}
if (!gst_structure_get_int (structure, "height", &height))
{
CV_WARN("Cannot query video heigth\n");
}
gint num = 0, denom=1;
if(!gst_structure_get_fraction(structure, "framerate", &num, &denom))
{
CV_WARN("Cannot query video fps\n");
}
fps = (double)num/(double)denom;
// GST_DEBUG_BIN_TO_DOT_FILE(GST_BIN(pipeline), GST_DEBUG_GRAPH_SHOW_ALL, "pipeline")
stopPipeline();
}
__END__;
return true;
}
/*!
* \brief CvCapture_GStreamer::getProperty retreive the requested property from the pipeline
* \param propId requested property
* \return property value
*
* There are two ways the properties can be retreived. For seek-based properties we can query the pipeline.
* For frame-based properties, we use the caps of the lasst receivef sample. This means that some properties
* are not available until a first frame was received
*/
double CvCapture_GStreamer::getProperty( int propId )
{
GstFormat format;
gint64 value;
gboolean status;
#if GST_VERSION_MAJOR == 0
#define FORMAT &format
#else
#define FORMAT format
#endif
if(!pipeline) {
CV_WARN("GStreamer: no pipeline");
return 0;
}
switch(propId) {
case CV_CAP_PROP_POS_MSEC:
format = GST_FORMAT_TIME;
status = gst_element_query_position(sink, FORMAT, &value);
if(!status) {
CV_WARN("GStreamer: unable to query position of stream");
return 0;
}
return value * 1e-6; // nano seconds to milli seconds
case CV_CAP_PROP_POS_FRAMES:
format = GST_FORMAT_DEFAULT;
status = gst_element_query_position(sink, FORMAT, &value);
if(!status) {
CV_WARN("GStreamer: unable to query position of stream");
return 0;
}
return value;
case CV_CAP_PROP_POS_AVI_RATIO:
format = GST_FORMAT_PERCENT;
status = gst_element_query_position(sink, FORMAT, &value);
if(!status) {
CV_WARN("GStreamer: unable to query position of stream");
return 0;
}
return ((double) value) / GST_FORMAT_PERCENT_MAX;
case CV_CAP_PROP_FRAME_WIDTH:
return width;
case CV_CAP_PROP_FRAME_HEIGHT:
return height;
case CV_CAP_PROP_FPS:
return fps;
case CV_CAP_PROP_FOURCC:
break;
case CV_CAP_PROP_FRAME_COUNT:
return duration;
case CV_CAP_PROP_FORMAT:
case CV_CAP_PROP_MODE:
case CV_CAP_PROP_BRIGHTNESS:
case CV_CAP_PROP_CONTRAST:
case CV_CAP_PROP_SATURATION:
case CV_CAP_PROP_HUE:
if (v4l2src)
{
const gchar * propName =
propId == CV_CAP_PROP_BRIGHTNESS ? "brightness" :
propId == CV_CAP_PROP_CONTRAST ? "contrast" :
propId == CV_CAP_PROP_SATURATION ? "saturation" :
propId == CV_CAP_PROP_HUE ? "hue" : NULL;
if (propName)
{
gint32 value32 = 0;
g_object_get(G_OBJECT(v4l2src), propName, &value32, NULL);
return value32;
}
}
case CV_CAP_PROP_GAIN:
case CV_CAP_PROP_CONVERT_RGB:
break;
case CV_CAP_GSTREAMER_QUEUE_LENGTH:
if(!sink) {
CV_WARN("GStreamer: there is no sink yet");
return false;
}
return gst_app_sink_get_max_buffers(GST_APP_SINK(sink));
default:
CV_WARN("GStreamer: unhandled property");
break;
}
#undef FORMAT
return 0;
}
/*!
* \brief CvCapture_GStreamer::setProperty
* \param propId
* \param value
* \return success
* Sets the desired property id with val. If the pipeline is running,
* it is briefly stopped and started again after the property was set
*/
bool CvCapture_GStreamer::setProperty( int propId, double value )
{
GstFormat format;
GstSeekFlags flags;
if(!pipeline) {
CV_WARN("GStreamer: no pipeline");
return false;
}
bool wasPlaying = this->isPipelinePlaying();
if (wasPlaying)
this->stopPipeline();
switch(propId) {
case CV_CAP_PROP_POS_MSEC:
format = GST_FORMAT_TIME;
flags = (GstSeekFlags) (GST_SEEK_FLAG_FLUSH|GST_SEEK_FLAG_ACCURATE);
if(!gst_element_seek_simple(GST_ELEMENT(pipeline), format,
flags, (gint64) (value * GST_MSECOND))) {
CV_WARN("GStreamer: unable to seek");
}
break;
case CV_CAP_PROP_POS_FRAMES:
format = GST_FORMAT_DEFAULT;
flags = (GstSeekFlags) (GST_SEEK_FLAG_FLUSH|GST_SEEK_FLAG_ACCURATE);
if(!gst_element_seek_simple(GST_ELEMENT(pipeline), format,
flags, (gint64) value)) {
CV_WARN("GStreamer: unable to seek");
}
break;
case CV_CAP_PROP_POS_AVI_RATIO:
format = GST_FORMAT_PERCENT;
flags = (GstSeekFlags) (GST_SEEK_FLAG_FLUSH|GST_SEEK_FLAG_ACCURATE);
if(!gst_element_seek_simple(GST_ELEMENT(pipeline), format,
flags, (gint64) (value * GST_FORMAT_PERCENT_MAX))) {
CV_WARN("GStreamer: unable to seek");
}
break;
case CV_CAP_PROP_FRAME_WIDTH:
if(value > 0)
setFilter("width", G_TYPE_INT, (int) value, 0);
else
removeFilter("width");
break;
case CV_CAP_PROP_FRAME_HEIGHT:
if(value > 0)
setFilter("height", G_TYPE_INT, (int) value, 0);
else
removeFilter("height");
break;
case CV_CAP_PROP_FPS:
if(value > 0) {
double num=0, denom = 1;
toFraction(value, num, denom);
setFilter("framerate", GST_TYPE_FRACTION, value, denom);
} else
removeFilter("framerate");
break;
case CV_CAP_PROP_FOURCC:
case CV_CAP_PROP_FRAME_COUNT:
case CV_CAP_PROP_FORMAT:
case CV_CAP_PROP_MODE:
case CV_CAP_PROP_BRIGHTNESS:
case CV_CAP_PROP_CONTRAST:
case CV_CAP_PROP_SATURATION:
case CV_CAP_PROP_HUE:
if (v4l2src)
{
const gchar * propName =
propId == CV_CAP_PROP_BRIGHTNESS ? "brightness" :
propId == CV_CAP_PROP_CONTRAST ? "contrast" :
propId == CV_CAP_PROP_SATURATION ? "saturation" :
propId == CV_CAP_PROP_HUE ? "hue" : NULL;
if (propName)
{
gint32 value32 = cv::saturate_cast<gint32>(value);
g_object_set(G_OBJECT(v4l2src), propName, &value32, NULL);
return true;
}
}
case CV_CAP_PROP_GAIN:
case CV_CAP_PROP_CONVERT_RGB:
break;
case CV_CAP_GSTREAMER_QUEUE_LENGTH:
if(!sink)
break;
gst_app_sink_set_max_buffers(GST_APP_SINK(sink), (guint) value);
break;
default:
CV_WARN("GStreamer: unhandled property");
}
if (wasPlaying)
this->startPipeline();
return false;
}
/*!
* \brief cvCreateCapture_GStreamer
* \param type
* \param filename
* \return
*/
CvCapture* cvCreateCapture_GStreamer(int type, const char* filename )
{
CvCapture_GStreamer* capture = new CvCapture_GStreamer;
if( capture->open( type, filename ))
return capture;
delete capture;
return 0;
}
/*!
* \brief The CvVideoWriter_GStreamer class
* Use Gstreamer to write video
*/
class CvVideoWriter_GStreamer : public CvVideoWriter
{
public:
CvVideoWriter_GStreamer() { init(); }
virtual ~CvVideoWriter_GStreamer() { close(); }
virtual bool open( const char* filename, int fourcc,
double fps, CvSize frameSize, bool isColor );
virtual void close();
virtual bool writeFrame( const IplImage* image );
protected:
void init();
const char* filenameToMimetype(const char* filename);
GstElement* pipeline;
GstElement* source;
GstElement* encodebin;
GstElement* file;
GstBuffer* buffer;
int input_pix_fmt;
int num_frames;
double framerate;
};
/*!
* \brief CvVideoWriter_GStreamer::init
* initialise all variables
*/
void CvVideoWriter_GStreamer::init()
{
pipeline = NULL;
source = NULL;
encodebin = NULL;
file = NULL;
buffer = NULL;
num_frames = 0;
framerate = 0;
}
/*!
* \brief CvVideoWriter_GStreamer::close
* ends the pipeline by sending EOS and destroys the pipeline and all
* elements afterwards
*/
void CvVideoWriter_GStreamer::close()
{
GstStateChangeReturn status;
if (pipeline)
{
handleMessage(pipeline);
if (gst_app_src_end_of_stream(GST_APP_SRC(source)) != GST_FLOW_OK)
{
CV_WARN("Cannot send EOS to GStreamer pipeline\n");
return;
}
//wait for EOS to trickle down the pipeline. This will let all elements finish properly
GstBus* bus = gst_element_get_bus(pipeline);
GstMessage *msg = gst_bus_timed_pop_filtered(bus, GST_CLOCK_TIME_NONE, (GstMessageType)(GST_MESSAGE_ERROR | GST_MESSAGE_EOS));
if (GST_MESSAGE_TYPE(msg) == GST_MESSAGE_ERROR)
{
CV_WARN("Error during VideoWriter finalization\n");
return;
}
if(msg != NULL)
{
gst_message_unref(msg);
g_object_unref(G_OBJECT(bus));
}
status = gst_element_set_state (pipeline, GST_STATE_NULL);
if (status == GST_STATE_CHANGE_ASYNC)
{
// wait for status update
GstState st1;
GstState st2;
status = gst_element_get_state(pipeline, &st1, &st2, GST_CLOCK_TIME_NONE);
}
if (status == GST_STATE_CHANGE_FAILURE)
{
handleMessage (pipeline);
gst_object_unref (GST_OBJECT (pipeline));
pipeline = NULL;
CV_WARN("Unable to stop gstreamer pipeline\n");
return;
}
gst_object_unref (GST_OBJECT (pipeline));
pipeline = NULL;
}
}
/*!
* \brief CvVideoWriter_GStreamer::filenameToMimetype
* \param filename
* \return mimetype
* Resturns a container mime type for a given filename by looking at it's extension
*/
const char* CvVideoWriter_GStreamer::filenameToMimetype(const char *filename)
{
//get extension
const char *ext = strrchr(filename, '.');
if(!ext || ext == filename) return NULL;
ext += 1; //exclude the dot
// return a container mime based on the given extension.
// gstreamer's function returns too much possibilities, which is not useful to us
//return the appropriate mime
if (strncasecmp(ext,"avi", 3) == 0)
return (const char*)"video/x-msvideo";
if (strncasecmp(ext,"mkv", 3) == 0 || strncasecmp(ext,"mk3d",4) == 0 || strncasecmp(ext,"webm",4) == 0 )
return (const char*)"video/x-matroska";
if (strncasecmp(ext,"wmv", 3) == 0)
return (const char*)"video/x-ms-asf";
if (strncasecmp(ext,"mov", 3) == 0)
return (const char*)"video/x-quicktime";
if (strncasecmp(ext,"ogg", 3) == 0 || strncasecmp(ext,"ogv", 3) == 0)
return (const char*)"application/ogg";
if (strncasecmp(ext,"rm", 3) == 0)
return (const char*)"vnd.rn-realmedia";
if (strncasecmp(ext,"swf", 3) == 0)
return (const char*)"application/x-shockwave-flash";
if (strncasecmp(ext,"mp4", 3) == 0)
return (const char*)"video/x-quicktime, variant=(string)iso";
//default to avi
return (const char*)"video/x-msvideo";
}
/*!
* \brief CvVideoWriter_GStreamer::open
* \param filename filename to output to
* \param fourcc desired codec fourcc
* \param fps desired framerate
* \param frameSize the size of the expected frames
* \param is_color color or grayscale
* \return success
*
* We support 2 modes of operation. Either the user enters a filename and a fourcc
* code, or enters a manual pipeline description like in CvVideoCapture_Gstreamer.
* In the latter case, we just push frames on the appsink with appropriate caps.
* In the former case, we try to deduce the correct container from the filename,
* and the correct encoder from the fourcc profile.
*
* If the file extension did was not recognize, an avi container is used
*
*/
bool CvVideoWriter_GStreamer::open( const char * filename, int fourcc,
double fps, CvSize frameSize, bool is_color )
{
CV_FUNCNAME("CvVideoWriter_GStreamer::open");
// check arguments
assert (filename);
assert (fps > 0);
assert (frameSize.width > 0 && frameSize.height > 0);
// init gstreamer
gst_initializer::init();
// init vars
bool manualpipeline = true;
int bufsize = 0;
GError *err = NULL;
const char* mime = NULL;
GstStateChangeReturn stateret;
GstCaps* caps = NULL;
GstCaps* videocaps = NULL;
#if FULL_GST_VERSION >= VERSION_NUM(0,10,32)
GstCaps* containercaps = NULL;
GstEncodingContainerProfile* containerprofile = NULL;
GstEncodingVideoProfile* videoprofile = NULL;
#endif
GstIterator* it = NULL;
gboolean done = FALSE;
GstElement *element = NULL;
gchar* name = NULL;
#if GST_VERSION_MAJOR == 0
GstElement* splitter = NULL;
GstElement* combiner = NULL;
#endif
// we first try to construct a pipeline from the given string.
// if that fails, we assume it is an ordinary filename
__BEGIN__;
encodebin = gst_parse_launch(filename, &err);
manualpipeline = (encodebin != NULL);
if(manualpipeline)
{
#if GST_VERSION_MAJOR == 0
it = gst_bin_iterate_sources(GST_BIN(encodebin));
if(gst_iterator_next(it, (gpointer *)&source) != GST_ITERATOR_OK) {
CV_ERROR(CV_StsError, "GStreamer: cannot find appsink in manual pipeline\n");
return false;
}
#else
it = gst_bin_iterate_sources (GST_BIN(encodebin));
GValue value = G_VALUE_INIT;
while (!done) {
switch (gst_iterator_next (it, &value)) {
case GST_ITERATOR_OK:
element = GST_ELEMENT (g_value_get_object (&value));
name = gst_element_get_name(element);
if (name){
if(strstr(name, "opencvsrc") != NULL || strstr(name, "appsrc") != NULL) {
source = GST_ELEMENT ( gst_object_ref (element) );
done = TRUE;
}
g_free(name);
}
g_value_unset (&value);
break;
case GST_ITERATOR_RESYNC:
gst_iterator_resync (it);
break;
case GST_ITERATOR_ERROR:
case GST_ITERATOR_DONE:
done = TRUE;
break;
}
}
gst_iterator_free (it);
if (!source){
CV_ERROR(CV_StsError, "GStreamer: cannot find appsrc in manual pipeline\n");
return false;
}
#endif
pipeline = encodebin;
}
else
{
pipeline = gst_pipeline_new (NULL);
// we just got a filename and a fourcc code.
// first, try to guess the container from the filename
//encodebin = gst_element_factory_make("encodebin", NULL);
//proxy old non existing fourcc ids. These were used in previous opencv versions,
//but do not even exist in gstreamer any more
if (fourcc == CV_FOURCC('M','P','1','V')) fourcc = CV_FOURCC('M', 'P', 'G' ,'1');
if (fourcc == CV_FOURCC('M','P','2','V')) fourcc = CV_FOURCC('M', 'P', 'G' ,'2');
if (fourcc == CV_FOURCC('D','R','A','C')) fourcc = CV_FOURCC('d', 'r', 'a' ,'c');
//create encoder caps from fourcc
videocaps = gst_riff_create_video_caps(fourcc, NULL, NULL, NULL, NULL, NULL);
if (!videocaps){
CV_ERROR( CV_StsUnsupportedFormat, "Gstreamer Opencv backend does not support this codec.");
}
//create container caps from file extension
mime = filenameToMimetype(filename);
if (!mime) {
CV_ERROR( CV_StsUnsupportedFormat, "Gstreamer Opencv backend does not support this file type.");
}
#if FULL_GST_VERSION >= VERSION_NUM(0,10,32)
containercaps = gst_caps_from_string(mime);
//create encodebin profile
containerprofile = gst_encoding_container_profile_new("container", "container", containercaps, NULL);
videoprofile = gst_encoding_video_profile_new(videocaps, NULL, NULL, 1);
gst_encoding_container_profile_add_profile(containerprofile, (GstEncodingProfile *) videoprofile);
#endif
//create pipeline elements
encodebin = gst_element_factory_make("encodebin", NULL);
#if FULL_GST_VERSION >= VERSION_NUM(0,10,32)
g_object_set(G_OBJECT(encodebin), "profile", containerprofile, NULL);
#endif
source = gst_element_factory_make("appsrc", NULL);
file = gst_element_factory_make("filesink", NULL);
g_object_set(G_OBJECT(file), "location", filename, NULL);
}
if (is_color)
{
input_pix_fmt = GST_VIDEO_FORMAT_BGR;
bufsize = frameSize.width * frameSize.height * 3;
#if GST_VERSION_MAJOR == 0
caps = gst_video_format_new_caps(GST_VIDEO_FORMAT_BGR,
frameSize.width,
frameSize.height,
int(fps), 1,
1, 1);
#else
caps = gst_caps_new_simple("video/x-raw",
"format", G_TYPE_STRING, "BGR",
"width", G_TYPE_INT, frameSize.width,
"height", G_TYPE_INT, frameSize.height,
"framerate", GST_TYPE_FRACTION, int(fps), 1,
NULL);
caps = gst_caps_fixate(caps);
#endif
}
else
{
#if FULL_GST_VERSION >= VERSION_NUM(0,10,29)
input_pix_fmt = GST_VIDEO_FORMAT_GRAY8;
bufsize = frameSize.width * frameSize.height;
#if GST_VERSION_MAJOR == 0
caps = gst_video_format_new_caps(GST_VIDEO_FORMAT_GRAY8,
frameSize.width,
frameSize.height,
int(fps), 1,
1, 1);
#else
caps = gst_caps_new_simple("video/x-raw",
"format", G_TYPE_STRING, "GRAY8",
"width", G_TYPE_INT, frameSize.width,
"height", G_TYPE_INT, frameSize.height,
"framerate", GST_TYPE_FRACTION, int(fps), 1,
NULL);
caps = gst_caps_fixate(caps);
#endif
#else
CV_Assert(!"Gstreamer 0.10.29 or newer is required for grayscale input");
#endif
}
gst_app_src_set_caps(GST_APP_SRC(source), caps);
gst_app_src_set_stream_type(GST_APP_SRC(source), GST_APP_STREAM_TYPE_STREAM);
gst_app_src_set_size (GST_APP_SRC(source), -1);
g_object_set(G_OBJECT(source), "format", GST_FORMAT_TIME, NULL);
g_object_set(G_OBJECT(source), "block", 1, NULL);
g_object_set(G_OBJECT(source), "is-live", 0, NULL);
if(!manualpipeline)
{
g_object_set(G_OBJECT(file), "buffer-size", bufsize, NULL);
gst_bin_add_many(GST_BIN(pipeline), source, encodebin, file, NULL);
if(!gst_element_link_many(source, encodebin, file, NULL)) {
CV_ERROR(CV_StsError, "GStreamer: cannot link elements\n");
}
}
#if GST_VERSION_MAJOR == 0
// HACK: remove streamsplitter and streamcombiner from
// encodebin pipeline to prevent early EOF event handling
// We always fetch BGR or gray-scale frames, so combiner->spliter
// endge in graph is useless.
it = gst_bin_iterate_recurse (GST_BIN(encodebin));
while (!done) {
switch (gst_iterator_next (it, (void**)&element)) {
case GST_ITERATOR_OK:
name = gst_element_get_name(element);
if (strstr(name, "streamsplitter"))
splitter = element;
else if (strstr(name, "streamcombiner"))
combiner = element;
break;
case GST_ITERATOR_RESYNC:
gst_iterator_resync (it);
break;
case GST_ITERATOR_ERROR:
done = true;
break;
case GST_ITERATOR_DONE:
done = true;
break;
}
}
gst_iterator_free (it);
if (splitter && combiner)
{
gst_element_unlink(splitter, combiner);
GstPad* src = gst_element_get_pad(combiner, "src");
GstPad* sink = gst_element_get_pad(combiner, "encodingsink");
GstPad* srcPeer = gst_pad_get_peer(src);
GstPad* sinkPeer = gst_pad_get_peer(sink);
gst_pad_unlink(sinkPeer, sink);
gst_pad_unlink(src, srcPeer);
gst_pad_link(sinkPeer, srcPeer);
src = gst_element_get_pad(splitter, "encodingsrc");
sink = gst_element_get_pad(splitter, "sink");
srcPeer = gst_pad_get_peer(src);
sinkPeer = gst_pad_get_peer(sink);
gst_pad_unlink(sinkPeer, sink);
gst_pad_unlink(src, srcPeer);
gst_pad_link(sinkPeer, srcPeer);
}
#endif
stateret = gst_element_set_state(GST_ELEMENT(pipeline), GST_STATE_PLAYING);
if(stateret == GST_STATE_CHANGE_FAILURE) {
handleMessage(pipeline);
CV_ERROR(CV_StsError, "GStreamer: cannot put pipeline to play\n");
}
framerate = fps;
num_frames = 0;
handleMessage(pipeline);
__END__;
return true;
}
/*!
* \brief CvVideoWriter_GStreamer::writeFrame
* \param image
* \return
* Pushes the given frame on the pipeline.
* The timestamp for the buffer is generated from the framerate set in open
* and ensures a smooth video
*/
bool CvVideoWriter_GStreamer::writeFrame( const IplImage * image )
{
CV_FUNCNAME("CvVideoWriter_GStreamer::writerFrame");
GstClockTime duration, timestamp;
GstFlowReturn ret;
int size;
__BEGIN__;
handleMessage(pipeline);
if (input_pix_fmt == GST_VIDEO_FORMAT_BGR) {
if (image->nChannels != 3 || image->depth != IPL_DEPTH_8U) {
CV_ERROR(CV_StsUnsupportedFormat, "cvWriteFrame() needs images with depth = IPL_DEPTH_8U and nChannels = 3.");
}
}
#if FULL_GST_VERSION >= VERSION_NUM(0,10,29)
else if (input_pix_fmt == GST_VIDEO_FORMAT_GRAY8) {
if (image->nChannels != 1 || image->depth != IPL_DEPTH_8U) {
CV_ERROR(CV_StsUnsupportedFormat, "cvWriteFrame() needs images with depth = IPL_DEPTH_8U and nChannels = 1.");
}
}
#endif
else {
CV_ERROR(CV_StsUnsupportedFormat, "cvWriteFrame() needs BGR or grayscale images\n");
return false;
}
size = image->imageSize;
duration = ((double)1/framerate) * GST_SECOND;
timestamp = num_frames * duration;
//gst_app_src_push_buffer takes ownership of the buffer, so we need to supply it a copy
#if GST_VERSION_MAJOR == 0
buffer = gst_buffer_try_new_and_alloc (size);
if (!buffer)
{
CV_ERROR(CV_StsBadSize, "Cannot create GStreamer buffer");
}
memcpy(GST_BUFFER_DATA (buffer), (guint8*)image->imageData, size);
GST_BUFFER_DURATION(buffer) = duration;
GST_BUFFER_TIMESTAMP(buffer) = timestamp;
#else
buffer = gst_buffer_new_allocate (NULL, size, NULL);
GstMapInfo info;
gst_buffer_map(buffer, &info, (GstMapFlags)GST_MAP_READ);
memcpy(info.data, (guint8*)image->imageData, size);
gst_buffer_unmap(buffer, &info);
GST_BUFFER_DURATION(buffer) = duration;
GST_BUFFER_PTS(buffer) = timestamp;
GST_BUFFER_DTS(buffer) = timestamp;
#endif
//set the current number in the frame
GST_BUFFER_OFFSET(buffer) = num_frames;
ret = gst_app_src_push_buffer(GST_APP_SRC(source), buffer);
if (ret != GST_FLOW_OK) {
CV_WARN("Error pushing buffer to GStreamer pipeline");
return false;
}
//GST_DEBUG_BIN_TO_DOT_FILE(GST_BIN(pipeline), GST_DEBUG_GRAPH_SHOW_ALL, "pipeline");
++num_frames;
__END__;
return true;
}
/*!
* \brief cvCreateVideoWriter_GStreamer
* \param filename
* \param fourcc
* \param fps
* \param frameSize
* \param isColor
* \return
* Constructor
*/
CvVideoWriter* cvCreateVideoWriter_GStreamer(const char* filename, int fourcc, double fps,
CvSize frameSize, int isColor )
{
CvVideoWriter_GStreamer* wrt = new CvVideoWriter_GStreamer;
if( wrt->open(filename, fourcc, fps,frameSize, isColor))
return wrt;
delete wrt;
return 0;
}
// utility functions
/*!
* \brief toFraction
* \param decimal
* \param numerator
* \param denominator
* Split a floating point value into numerator and denominator
*/
void toFraction(double decimal, double &numerator, double &denominator)
{
double dummy;
double whole;
decimal = modf (decimal, &whole);
for (denominator = 1; denominator<=100; denominator++){
if (modf(denominator * decimal, &dummy) < 0.001f)
break;
}
numerator = denominator * decimal;
}
/*!
* \brief handleMessage
* Handles gstreamer bus messages. Mainly for debugging purposes and ensuring clean shutdown on error
*/
void handleMessage(GstElement * pipeline)
{
CV_FUNCNAME("handlemessage");
GError *err = NULL;
gchar *debug = NULL;
GstBus* bus = NULL;
GstStreamStatusType tp;
GstElement * elem = NULL;
GstMessage* msg = NULL;
__BEGIN__;
bus = gst_element_get_bus(pipeline);
while(gst_bus_have_pending(bus)) {
msg = gst_bus_pop(bus);
//printf("Got %s message\n", GST_MESSAGE_TYPE_NAME(msg));
if(gst_is_missing_plugin_message(msg))
{
CV_ERROR(CV_StsError, "GStreamer: your gstreamer installation is missing a required plugin\n");
}
else
{
switch (GST_MESSAGE_TYPE (msg)) {
case GST_MESSAGE_STATE_CHANGED:
GstState oldstate, newstate, pendstate;
gst_message_parse_state_changed(msg, &oldstate, &newstate, &pendstate);
//fprintf(stderr, "state changed from %s to %s (pending: %s)\n", gst_element_state_get_name(oldstate),
// gst_element_state_get_name(newstate), gst_element_state_get_name(pendstate));
break;
case GST_MESSAGE_ERROR:
gst_message_parse_error(msg, &err, &debug);
fprintf(stderr, "GStreamer Plugin: Embedded video playback halted; module %s reported: %s\n",
gst_element_get_name(GST_MESSAGE_SRC (msg)), err->message);
g_error_free(err);
g_free(debug);
gst_element_set_state(GST_ELEMENT(pipeline), GST_STATE_NULL);
break;
case GST_MESSAGE_EOS:
//fprintf(stderr, "reached the end of the stream.");
break;
case GST_MESSAGE_STREAM_STATUS:
gst_message_parse_stream_status(msg,&tp,&elem);
//fprintf(stderr, "stream status: elem %s, %i\n", GST_ELEMENT_NAME(elem), tp);
break;
default:
//fprintf(stderr, "unhandled message %s\n",GST_MESSAGE_TYPE_NAME(msg));
break;
}
}
gst_message_unref(msg);
}
gst_object_unref(GST_OBJECT(bus));
__END__
}
| [
"thatindiangeek@gmail.com"
] | thatindiangeek@gmail.com |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.