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
905 values
visit_date
timestamp[us]date
2015-08-09 11:21:18
2023-09-06 10:45:07
revision_date
timestamp[us]date
1997-09-14 05:04:47
2023-09-17 19:19:19
committer_date
timestamp[us]date
1997-09-14 05:04:47
2023-09-06 06:22:19
github_id
int64
3.89k
681M
star_events_count
int64
0
209k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
22 values
gha_event_created_at
timestamp[us]date
2012-06-07 00:51:45
2023-09-14 21:58:39
gha_created_at
timestamp[us]date
2008-03-27 23:40:48
2023-08-21 23:17:38
gha_language
stringclasses
141 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
115 values
content
stringlengths
3
10.4M
authors
listlengths
1
1
author_id
stringlengths
0
158
1a93f3ee6e4d0c94f9d53fb2bf4955baeb66f1be
1fe10ee5e34cd76067c720ef4b4a054f6107b286
/mobile/common/favorites/special_folder_impl.h
c1c66c75dce542f9213984dbade95a486300ec1c
[ "BSD-2-Clause" ]
permissive
bopopescu/ofa
9f001c4f36b07fa27347ade37337422fd6719dcc
84e319101d4a1200657337dcdf9ed3857fc59e03
refs/heads/master
2021-06-14T08:53:05.865737
2017-04-03T12:50:44
2017-04-03T12:50:44
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,023
h
// -*- Mode: c++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- // // Copyright (C) 2015 Opera Software ASA. All rights reserved. // // This file is an original work developed by Opera Software ASA #ifndef MOBILE_COMMON_FAVORITES_SPECIAL_FOLDER_IMPL_H_ #define MOBILE_COMMON_FAVORITES_SPECIAL_FOLDER_IMPL_H_ #include <string> #include "mobile/common/favorites/folder_impl.h" namespace mobile { class SpecialFolderImpl : public FolderImpl { public: SpecialFolderImpl(FavoritesImpl* favorites, int64_t parent, int64_t id, int32_t special_id, const base::string16& title, const std::string& guid); const bookmarks::BookmarkNode* data() const override; void Remove() override; int32_t GetSpecialId() const override; protected: const int32_t special_; private: DISALLOW_COPY_AND_ASSIGN(SpecialFolderImpl); }; } // namespace mobile #endif // MOBILE_COMMON_FAVORITES_NODE_FOLDER_IMPL_H_
[ "jimmym@opera.com" ]
jimmym@opera.com
35480db6980f4d8b72b3209c97d84ed8001afc32
e006d064ad3568a1dda9291a7421cbcaa48d6405
/Vivado_Projects/Recovery/Latest3_post250_WoHeater/Latest3_post250_WoHeater.srcs/sources_1/bd/design_1/ip/design_1_xbar_0/sim/design_1_xbar_0_sc.cpp
4074b57d09d36e1f3315f69a640f61dab61a21d2
[]
no_license
Pavithran-P/Reliability_Sensors
a6b480718defaf989c4e158be3cfc965c2e55722
f4c2cebaa2857e0353801d3953d5922fa3cc2e8c
refs/heads/main
2023-06-14T11:15:51.571454
2021-07-03T17:55:02
2021-07-03T17:55:02
361,855,091
0
0
null
null
null
null
UTF-8
C++
false
false
7,778
cpp
// (c) Copyright 1995-2021 Xilinx, Inc. All rights reserved. // // This file contains confidential and proprietary information // of Xilinx, Inc. and is protected under U.S. and // international copyright and other intellectual property // laws. // // DISCLAIMER // This disclaimer is not a license and does not grant any // rights to the materials distributed herewith. Except as // otherwise provided in a valid license issued to you by // Xilinx, and to the maximum extent permitted by applicable // law: (1) THESE MATERIALS ARE MADE AVAILABLE "AS IS" AND // WITH ALL FAULTS, AND XILINX HEREBY DISCLAIMS ALL WARRANTIES // AND CONDITIONS, EXPRESS, IMPLIED, OR STATUTORY, INCLUDING // BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, NON- // INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE; and // (2) Xilinx shall not be liable (whether in contract or tort, // including negligence, or under any other theory of // liability) for any loss or damage of any kind or nature // related to, arising under or in connection with these // materials, including for any direct, or any indirect, // special, incidental, or consequential loss or damage // (including loss of data, profits, goodwill, or any type of // loss or damage suffered as a result of any action brought // by a third party) even if such damage or loss was // reasonably foreseeable or Xilinx had been advised of the // possibility of the same. // // CRITICAL APPLICATIONS // Xilinx products are not designed or intended to be fail- // safe, or for use in any application requiring fail-safe // performance, such as life-support or safety devices or // systems, Class III medical devices, nuclear facilities, // applications related to the deployment of airbags, or any // other applications that could lead to death, personal // injury, or severe property or environmental damage // (individually and collectively, "Critical // Applications"). Customer assumes the sole risk and // liability of any use of Xilinx products in Critical // Applications, subject only to applicable laws and // regulations governing limitations on product liability. // // THIS COPYRIGHT NOTICE AND DISCLAIMER MUST BE RETAINED AS // PART OF THIS FILE AT ALL TIMES. // // DO NOT MODIFY THIS FILE. #include "design_1_xbar_0_sc.h" #include "axi_crossbar.h" #include <map> #include <string> design_1_xbar_0_sc::design_1_xbar_0_sc(const sc_core::sc_module_name& nm) : sc_core::sc_module(nm), mp_impl(NULL) { // configure connectivity manager xsc::utils::xsc_sim_manager::addInstance("design_1_xbar_0", this); // initialize module xsc::common_cpp::properties model_param_props; model_param_props.addLong("C_NUM_SLAVE_SLOTS", "1"); model_param_props.addLong("C_NUM_MASTER_SLOTS", "3"); model_param_props.addLong("C_AXI_ID_WIDTH", "1"); model_param_props.addLong("C_AXI_ADDR_WIDTH", "32"); model_param_props.addLong("C_AXI_DATA_WIDTH", "32"); model_param_props.addLong("C_AXI_PROTOCOL", "2"); model_param_props.addLong("C_NUM_ADDR_RANGES", "7"); model_param_props.addLong("C_AXI_SUPPORTS_USER_SIGNALS", "0"); model_param_props.addLong("C_AXI_AWUSER_WIDTH", "1"); model_param_props.addLong("C_AXI_ARUSER_WIDTH", "1"); model_param_props.addLong("C_AXI_WUSER_WIDTH", "1"); model_param_props.addLong("C_AXI_RUSER_WIDTH", "1"); model_param_props.addLong("C_AXI_BUSER_WIDTH", "1"); model_param_props.addLong("C_R_REGISTER", "1"); model_param_props.addLong("C_CONNECTIVITY_MODE", "0"); model_param_props.addString("C_FAMILY", "zynq"); model_param_props.addBitString("C_M_AXI_BASE_ADDR", "111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111110000000000000000000000000000000001000011110100010000000000000000000000000000000000000000000000000100001111010000000000000000000000000000000000000000000000000000010000111100111100000000000000000000000000000000000000000000000001000011110011010000000000000000000000000000000000000000000000000100001111001100000000000000000000000000000000000000000000000000010000111100101100000000000000000000000000000000000000000000000001000011110010100000000000000000000000000000000000000000000000000100001111001001000000000000000000000000000000000000000000000000010000111100100000000000000000000000000000000000000000000000000001000011110001110000000000000000000000000000000000000000000000000100001111000110000000000000000000000000000000000000000000000000010000111100010100000000000000000000000000000000000000000000000001000011110001000000000000000000000000000000000000000000000000000100001111000011000000000000000000000000000000000000000000000000010000111100001000000000000000000000000000000000000000000000000001000011110000010000000000000000", 1344); model_param_props.addBitString("C_M_AXI_ADDR_WIDTH", "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000100000000000000000000000000000001000000000000000000000000000000010000000000000000000000000000000100000000000000000000000000000001000000000000000000000000000000010000000000000000000000000000000100000000000000000000000000000001000000000000000000000000000000010000000000000000000000000000000100000000000000000000000000000001000000000000000000000000000000010000000000000000000000000000000100000000000000000000000000000001000000000000000000000000000000010000", 672); model_param_props.addBitString("C_S_AXI_BASE_ID", "00000000000000000000000000000000", 32); model_param_props.addBitString("C_S_AXI_THREAD_ID_WIDTH", "00000000000000000000000000000000", 32); model_param_props.addBitString("C_M_AXI_WRITE_CONNECTIVITY", "000000000000000000000000000000010000000000000000000000000000000100000000000000000000000000000001", 96); model_param_props.addBitString("C_M_AXI_READ_CONNECTIVITY", "000000000000000000000000000000010000000000000000000000000000000100000000000000000000000000000001", 96); model_param_props.addBitString("C_S_AXI_SINGLE_THREAD", "00000000000000000000000000000001", 32); model_param_props.addBitString("C_S_AXI_WRITE_ACCEPTANCE", "00000000000000000000000000000001", 32); model_param_props.addBitString("C_S_AXI_READ_ACCEPTANCE", "00000000000000000000000000000001", 32); model_param_props.addBitString("C_M_AXI_WRITE_ISSUING", "000000000000000000000000000000010000000000000000000000000000000100000000000000000000000000000001", 96); model_param_props.addBitString("C_M_AXI_READ_ISSUING", "000000000000000000000000000000010000000000000000000000000000000100000000000000000000000000000001", 96); model_param_props.addBitString("C_S_AXI_ARB_PRIORITY", "00000000000000000000000000000000", 32); model_param_props.addBitString("C_M_AXI_SECURE", "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", 96); mp_impl = new axi_crossbar("inst", model_param_props); // initialize sockets target_0_rd_socket = mp_impl->target_0_rd_socket; target_0_wr_socket = mp_impl->target_0_wr_socket; initiator_0_rd_socket = mp_impl->initiator_0_rd_socket; initiator_0_wr_socket = mp_impl->initiator_0_wr_socket; initiator_1_rd_socket = mp_impl->initiator_1_rd_socket; initiator_1_wr_socket = mp_impl->initiator_1_wr_socket; initiator_2_rd_socket = mp_impl->initiator_2_rd_socket; initiator_2_wr_socket = mp_impl->initiator_2_wr_socket; } design_1_xbar_0_sc::~design_1_xbar_0_sc() { xsc::utils::xsc_sim_manager::clean(); delete mp_impl; }
[ "pavithran.palanichamy@gmail.com" ]
pavithran.palanichamy@gmail.com
5b59d4cacc65a58b41f6c87399ff5d937be371e1
745f5ca4aab736a051342cce970a7232fe65aeca
/GLAC/GLAC/GLAData.cpp
dea93ff5720dd9f30b700ede661773d2a2037961
[]
no_license
kiddove/nikki
cdf7bd3d83458090a979cf067bd05be9459221a1
dfbe1db92159f4a80b32318a870b3c522a89ec8f
refs/heads/master
2021-01-21T04:31:59.582089
2016-06-28T19:14:27
2016-06-28T19:14:27
13,760,340
0
1
null
null
null
null
UTF-8
C++
false
false
59,779
cpp
#include "StdAfx.h" #include "GLAData.h" GLAData::GLAData(void) { int i1 = sizeof(GLA14); int i2 = sizeof(GLA01_MAIN); int i3 = sizeof(GLA01_LONG); int i4 = sizeof(GLA01_SHORT); ASSERT(i1 == 10000); ASSERT(i2 == 4660); ASSERT(i3 == 4660); ASSERT(i4 == 4660); } GLAData::~GLAData(void) { if (m_LogFile.m_hFile != INVALID_HANDLE_VALUE) m_LogFile.Close(); } bool GLAData::Init() { // Get Current Directory TCHAR szPath[MAX_PATH_LEN]={0}; GetModuleFileName(NULL, szPath, MAX_PATH_LEN); (_tcsrchr(szPath, _T('\\')))[1] = 0; CString strPath(szPath); strPath += CONFIG_FILE_NAME; m_strIniFilePath = strPath; try { if (!m_LogFile.Open(_T("./Log.txt"), CFile::modeCreate | CFile::modeReadWrite | CFile::shareDenyNone | CFile::modeNoTruncate)) { DWORD dwError = ::GetLastError(); TRACE(_T("open log file failed.(Error:%d)\n"), dwError); } //int iLen = m_LogFile.GetLength(); m_LogFile.Seek(0, CFile::end); } catch(CFileException* e) { TCHAR szError[MAX_PATH_LEN]; e->GetErrorMessage(szError, MAX_PATH_LEN); TRACE(_T("CFileException catched when open log file. [%s]\n"), szError); } m_bBigEndian = IsBigEndian(); TCHAR szPath14[MAX_PATH_LEN]={0}; GetPrivateProfileString(_T("GLA14"), _T("FilePath"), _T(""), szPath14, sizeof(szPath14), strPath); m_strData14FileDir.Format(_T("%s"), szPath14); //m_bufSize_GLA14 = GetPrivateProfileInt(_T("GLA14"), _T("BufferSize"), 0, strPath); memset(szPath14, 0, MAX_PATH_LEN); GetPrivateProfileString(_T("GLA01"), _T("FilePath"), _T(""), szPath14, sizeof(szPath14), strPath); m_strData01FileDir.Format(_T("%s"), szPath14); if (m_strData14FileDir.IsEmpty()) { //TRACE(_T("read config file path failed.(GLA14)\n")); WriteLog("read config file path failed.(GLA14)"); return false; } if (m_strData01FileDir.IsEmpty()) { //TRACE(_T("read config file path failed.(GLA01)\n")); WriteLog("read config file path failed.(GLA01)"); return false; } m_strData01FileDir += _T("*.*"); m_strData14FileDir += _T("*.*"); m_iLatMin = GetPrivateProfileInt(_T("Latitude"), _T("Min"), 0, strPath); m_iLatMax = GetPrivateProfileInt(_T("Latitude"), _T("Max"), 0, strPath); m_iLonMin = GetPrivateProfileInt(_T("Longitude"), _T("Min"), 0, strPath); m_iLonMax = GetPrivateProfileInt(_T("Longitude"), _T("Max"), 0, strPath); return true; } bool GLAData::IsInvalid(CString& strFile, int& stLen) { CFile f; try { if (f.Open(strFile, CFile::modeRead)) { int ilen = (int)f.GetLength(); f.Close(); int isize = sizeof(stLen); if (ilen % isize != 0) { //TRACE(_T("Invalid File length!\n")); CString strErr; strErr.Format(_T("Invalid File length! [%s]"), strFile); WriteLog(strErr); return false; } else return true; } else { DWORD dwError = ::GetLastError(); //TRACE(_T("IsInvalid --- open file failed.(Error:%d, path:%s)\n"), dwError, strFile); CString strErr; strErr.Format(_T("IsInvalid --- open file failed.(Error:%d, path:%s)\n"), dwError, strFile); WriteLog(strErr); } return false; } catch(CFileException* e) { TCHAR szError[MAX_PATH_LEN]; e->GetErrorMessage(szError, MAX_PATH_LEN); //TRACE(_T("CFileException catched. [%s]\n"), szError); CString strErr; strErr.Format(_T("CFileException catched. [%s]\n"), szError); WriteLog(strErr); return false; } return true; } void GLAData::GetLength(CString& strFile, int& headLen, int& stLen) { headLen = 0; stLen = 0; int RecNum = 0; CStdioFile stdf; try { if (stdf.Open(strFile, CFile::modeRead)) { CString strRecl, strNumhead; stdf.ReadString(strRecl); stdf.ReadString(strNumhead); stdf.Close(); strRecl.Trim(); if (strRecl.Find(_T("Recl")) == 0) { int po1 = strRecl.Find(_T('=')); int po2 = strRecl.Find(_T(';')); CString sRecl = strRecl.Mid(po1 + 1, po2 - po1 - 1); stLen = atoi(sRecl); } if (strNumhead.Find(_T("Numhead")) == 0) { int po1 = strNumhead.Find(_T('=')); int po2 = strNumhead.Find(_T(';')); CString sNum = strNumhead.Mid(po1 + 1, po2 - po1 - 1); RecNum = atoi(sNum); headLen = RecNum * stLen; } } else { DWORD dwError = ::GetLastError(); TRACE(_T("open file failed.(Error:%d, path:%s)\n"), dwError, strFile); } } catch(CFileException* e) { TCHAR szError[MAX_PATH_LEN]; e->GetErrorMessage(szError, MAX_PATH_LEN); TRACE(_T("CFileException catched. [%s]\n"), szError); } } void GLAData::ReadGLA01() { m_indexMin = INT_MAX; m_indexMax = INT_MIN; // output file try { CString strOutput; strOutput.Format(_T("./DataFile01_%s.txt"), m_strMark); if (!m_DataFile01.Open(strOutput, CFile::modeCreate | CFile::modeReadWrite | CFile::shareDenyNone)) { DWORD dwError = ::GetLastError(); CString strErr; strErr.Format(_T("open OutputData01 file failed.(Error:%d)"), dwError); WriteLog(strErr); } } catch(CFileException* e) { TCHAR szError[MAX_PATH_LEN]; e->GetErrorMessage(szError, MAX_PATH_LEN); CString strErr; strErr.Format(_T("CFileException catched when open OutputData01 file. [%s]"), szError); WriteLog(strErr); } CFileFind ff; BOOL bFind = ff.FindFile(m_strData01FileDir); int iCount = 0; while (bFind) { bFind = ff.FindNextFile(); if (!ff.IsDirectory() && !ff.IsDots()) { CString strFile; strFile = ff.GetFilePath(); CString strName = ff.GetFileName(); int iPos = strName.Find(_T('_')); CString strTemp = strName.Left(iPos); if (strTemp.CompareNoCase(_T("GLA01")) == 0) { iPos = strName.Find(_T('_'), iPos + 1); int iPos2 = strName.Find(_T('_'), iPos+1); CString strMark = strName.Mid(iPos + 1, iPos2 - iPos - 1); if (m_strMark.CompareNoCase(strMark) == 0) { int it = 0; int iHeader = 0, istLen = 0; GetLength(strFile, iHeader, istLen); if (!this->IsInvalid(strFile, istLen)) return; if (m_bBigEndian) { CFile f; try { if (f.Open(strFile, CFile::modeRead)) { m_iCount01 = 0; int ilen = (int)f.GetLength(); int iCount =(ilen - iHeader) / istLen; char* pBuffer = new char[istLen]; f.Seek(iHeader, CFile::begin); for (int i = 0; i < iCount; i++) { memset(pBuffer, 0, istLen); f.Read(pBuffer, istLen); TraversalData01_Big(pBuffer); } delete pBuffer; f.Close(); CString strInfo; strInfo.Format(_T("\ntotal %d record in file : %s, max : %d, min : %d\n\n\n"), m_iCount01, strFile, m_indexMax, m_indexMin); m_DataFile01.WriteString(strInfo); } else { DWORD dwError = ::GetLastError(); TRACE(_T("ReadGLA01 --- open file failed.(Error:%d, path:%s)\n"), dwError, strFile); } } catch(CFileException* e) { TCHAR szError[MAX_PATH_LEN]; e->GetErrorMessage(szError, MAX_PATH_LEN); TRACE(_T("CFileException catched. [%s]\n"), szError); } } else { CFile f; try { if (f.Open(strFile, CFile::modeRead)) { m_iCount01 = 0; int ilen = (int)f.GetLength(); char* pBuffer = new char[istLen]; int iCount =(ilen - iHeader) / istLen; f.Seek(iHeader, CFile::begin); for (int i = 0; i < iCount; i++) { memset(pBuffer, 0, istLen); f.Read(pBuffer, istLen); TraversalData01_Little(pBuffer); } delete pBuffer; f.Close(); CString strInfo; strInfo.Format(_T("\ntotal %d record in file : %s, max : %d, min : %d\n\n\n"), m_iCount01, strFile, m_indexMax, m_indexMin); m_DataFile01.WriteString(strInfo); } else { DWORD dwError = ::GetLastError(); TRACE(_T("ReadGLA01 --- open file failed.(Error:%d, path:%s)\n"), dwError, strFile); } } catch(CFileException* e) { TCHAR szError[MAX_PATH_LEN]; e->GetErrorMessage(szError, MAX_PATH_LEN); TRACE(_T("CFileException catched. [%s]\n"), szError); } } } } } } if (m_DataFile01.m_hFile != INVALID_HANDLE_VALUE) m_DataFile01.Close(); return; } // big endian or little endian void GLAData::ReadGLA14() { m_Search_Rec_Index.clear(); // output file try { if (!m_DataFile14.Open("./DataFile14.txt", CFile::modeCreate | CFile::modeReadWrite | CFile::shareDenyNone)) { DWORD dwError = ::GetLastError(); //TRACE(_T("open OutputData14 file failed.(Error:%d)\n"), dwError); CString strErr; strErr.Format(_T("open OutputData14 file failed.(Error:%d)\n"), dwError); WriteLog(strErr); } } catch(CFileException* e) { TCHAR szError[MAX_PATH_LEN]; e->GetErrorMessage(szError, MAX_PATH_LEN); //TRACE(_T("CFileException catched when open OutputData14 file. [%s]\n"), szError); CString strErr; strErr.Format(_T("CFileException catched when open OutputData14 file. [%s]\n"), szError); WriteLog(strErr); } CFileFind ff; BOOL bFind = ff.FindFile(m_strData14FileDir); int iCount = 0; while (bFind) { bFind = ff.FindNextFile(); if (!ff.IsDirectory() && !ff.IsDots()) { CString strFile; strFile = ff.GetFilePath(); // GLA14_633_2123_001_1331_0_01_0001.DAT CString strName = ff.GetFileName(); int iPos = strName.Find(_T('_')); CString strTemp = strName.Left(iPos); if (strTemp.CompareNoCase(_T("GLA14")) == 0) { iPos = strName.Find(_T('_'), iPos + 1); int iPos2 = strName.Find(_T('_'), iPos+1); //iPos2 = strName.Find(_T('_'), iPos2+1); //iPos2 = strName.Find(_T('_'), iPos2+1); // ipos2-1, ipos + 1 m_strMark = strName.Mid(iPos + 1, iPos2 - iPos - 1); int it = 0; int iHeader = 0, istLen = 0; GetLength(strFile, iHeader, istLen); if (!this->IsInvalid(strFile, istLen)) return; if (m_bBigEndian) { CFile f; try { if (f.Open(strFile, CFile::modeRead)) { m_iCount14 = 0; int ilen = (int)f.GetLength(); int iCount =(ilen - iHeader) / istLen; char* pBuffer = new char[istLen]; f.Seek(iHeader, CFile::begin); for (int i = 0; i < iCount; i++) { memset(pBuffer, 0, istLen); f.Read(pBuffer, istLen); TraversalData14_Big(pBuffer); } delete pBuffer; f.Close(); CString strInfo; strInfo.Format(_T("\ntotal %d record in file : %s\n\n\n"), m_iCount14, strFile); m_DataFile14.WriteString(strInfo); } else { DWORD dwError = ::GetLastError(); TRACE(_T("ReadGLA14 --- open file failed.(Error:%d, path:%s)\n"), dwError, strFile); } } catch(CFileException* e) { TCHAR szError[MAX_PATH_LEN]; e->GetErrorMessage(szError, MAX_PATH_LEN); TRACE(_T("CFileException catched. [%s]\n"), szError); } } else { CFile f; try { if (f.Open(strFile, CFile::modeRead)) { m_iCount14 = 0; int ilen = (int)f.GetLength(); int iCount =(ilen - iHeader) / istLen; char* pBuffer = new char[istLen]; f.Seek(iHeader, CFile::begin); for (int i = 0; i < iCount; i++) { memset(pBuffer, 0, istLen); f.Read(pBuffer, istLen); TraversalData14_Little(pBuffer); } delete pBuffer; f.Close(); CString strInfo; strInfo.Format(_T("\ntotal %d record in file : %s\n\n\n"), m_iCount14, strFile); m_DataFile14.WriteString(strInfo); } else { DWORD dwError = ::GetLastError(); TRACE(_T("ReadGLA14 --- open file failed.(Error:%d, path:%s)\n"), dwError, strFile); } } catch(CFileException* e) { TCHAR szError[MAX_PATH_LEN]; e->GetErrorMessage(szError, MAX_PATH_LEN); TRACE(_T("CFileException catched. [%s]\n"), szError); } } ReadGLA01(); } } } if (m_DataFile14.m_hFile != INVALID_HANDLE_VALUE) m_DataFile14.Close(); return; } void GLAData::WriteLog(CString strLog) { COleDateTime dt = COleDateTime::GetCurrentTime(); CString strTime = dt.Format(_T("%Y-%m-%d %H:%M:%S : ")); CString str; str.Format(_T("%s%s\n"), strTime, strLog); m_LogFile.WriteString(str); } void GLAData::TraversalData14_Little(char *pBuffer) { GLA14* pData = (GLA14*)pBuffer; bool bMark = false; for (int i = 0; i < 40; i ++) { if (pData->i_FRir_qaFlag[i] != 15) return; } for (int i = 0; i < 40; i++) { int iLat = htonl(pData->i_lat[i]); int iLon = htonl(pData->i_lon[i]); if (m_iLatMin <= iLat && iLat <= m_iLatMax && m_iLonMin <= iLon && iLon <= m_iLonMax) { bMark = true; } } if (bMark) { if (m_DataFile14.m_hFile != INVALID_HANDLE_VALUE) { CString str; str.Format(_T("Record : %d\n"), m_iCount14); m_DataFile14.WriteString(str); } m_iCount14++; PrintData14_Little(pBuffer); } } void GLAData::PrintData14_Little(char* pBuffer) { if (m_DataFile14.m_hFile == INVALID_HANDLE_VALUE) { WriteLog(_T("Output DataFile14 is invalid!")); return; } GLA14* pData = (GLA14*)pBuffer; CString strOutput; int iCount = 0; //i_rec_ndx strOutput.Format(_T("i_rec_ndx : %d\n"), htonl(pData->i_rec_ndx)); m_DataFile14.WriteString(strOutput); iCount ++; m_Search_Rec_Index.insert(htonl(pData->i_rec_ndx)); return; //i_UTCTime[2]; for (int i = 0; i < 2; i++) { strOutput.Format(_T("i_UTCTime[%.2d] : %d\n"), i, htonl(pData->i_UTCTime[i])); m_DataFile14.WriteString(strOutput); } iCount++; //i_transtime strOutput.Format(_T("i_transtime : %d\n"), htons(pData->i_transtime)); m_DataFile14.WriteString(strOutput); iCount ++; //i_Spare1[2] for (int i = 0; i < 2; i++) { strOutput.Format(_T("i_Spare1[%.2d] : %d\n"), i, pData->i_Spare1[i]); m_DataFile14.WriteString(strOutput); } iCount ++; //i_deltagpstmcor strOutput.Format(_T("i_deltagpstmcor : %d\n"), htonl(pData->i_deltagpstmcor)); m_DataFile14.WriteString(strOutput); iCount ++; //i_dShortTime[39] for (int i = 0; i < 39; i++) { strOutput.Format(_T("i_dShortTime[%.2d] : %d\n"), i, htonl(pData->i_dShortTime[i])); m_DataFile14.WriteString(strOutput); } iCount++; //i_lat[40] for (int i = 0; i < 40; i++) { strOutput.Format(_T("i_lat[%.2d] : %d\n"), i, htonl(pData->i_lat[i])); m_DataFile14.WriteString(strOutput); } iCount++; //i_lon[40] for (int i = 0; i < 40; i++) { strOutput.Format(_T("i_lon[%.2d] : %d\n"), i, htonl(pData->i_lon[i])); m_DataFile14.WriteString(strOutput); } iCount++; //i_elev[40] for (int i = 0; i < 40; i++) { strOutput.Format(_T("i_elev[%.2d] : %d\n"), i, htonl(pData->i_elev[i])); m_DataFile14.WriteString(strOutput); } iCount++; //i_campaign[2] for (int i = 0; i < 2; i++) { strOutput.Format(_T("i_campaign[%.2d] : %d\n"), i, pData->i_campaign[i]); m_DataFile14.WriteString(strOutput); } iCount ++; //i_spare40 strOutput.Format(_T("i_spare40 : %d\n"), htons(pData->i_spare40)); m_DataFile14.WriteString(strOutput); iCount++; //i_cycTrk strOutput.Format(_T("i_cycTrk : %d\n"), htonl(pData->i_cycTrk)); m_DataFile14.WriteString(strOutput); iCount++; //i_localSolarTime strOutput.Format(_T("i_localSolarTime : %d\n"), htonl(pData->i_localSolarTime)); m_DataFile14.WriteString(strOutput); iCount++; //i_spare41[7] for (int i = 0; i < 7; i++) { strOutput.Format(_T("i_spare41[%.2d] : %d\n"), i, htonl(pData->i_spare41[i])); m_DataFile14.WriteString(strOutput); } iCount++; //i_deltaEllip[40] for (int i = 0; i < 40; i++) { strOutput.Format(_T("i_deltaEllip[%.2d] : %d\n"), i, htons(pData->i_deltaEllip[i])); m_DataFile14.WriteString(strOutput); } iCount++; //i_beamCoelv[40] for (int i = 0; i < 40; i++) { strOutput.Format(_T("i_beamCoelv[%.2d] : %d\n"), i, htonl(pData->i_beamCoelv[i])); m_DataFile14.WriteString(strOutput); } iCount++; //i_beamAzimuth[40] for (int i = 0; i < 40; i++) { strOutput.Format(_T("i_beamAzimuth[%.2d] : %d\n"), i, htonl(pData->i_beamAzimuth[i])); m_DataFile14.WriteString(strOutput); } iCount++; //i_d2refTrk[40] for (int i = 0; i < 40; i++) { strOutput.Format(_T("i_d2refTrk[%.2d] : %d\n"), i, htonl(pData->i_d2refTrk[i])); m_DataFile14.WriteString(strOutput); } iCount++; //i_SigBegOff[40] for (int i = 0; i < 40; i++) { strOutput.Format(_T("i_SigBegOff[%.2d] : %d\n"), i, htonl(pData->i_SigBegOff[i])); m_DataFile14.WriteString(strOutput); } iCount++; //i_DEM_hires_src[40] for (int i = 0; i < 40; i++) { strOutput.Format(_T("i_DEM_hires_src[%.2d] : %d\n"), i, pData->i_DEM_hires_src[i]); m_DataFile14.WriteString(strOutput); } iCount ++; //i_DEMhiresArelv[9][40] for (int i = 0; i < 9; i++) { for (int j = 0; j < 40; j++) { strOutput.Format(_T("i_DEMhiresArelv[%.2d][%.2d] : %d\n"), i, j, htons(pData->i_DEMhiresArelv[i][j])); m_DataFile14.WriteString(strOutput); } } iCount++; //i_ElevBiasCorr[40] for (int i = 0; i < 40; i++) { strOutput.Format(_T("i_ElevBiasCorr[%.2d] : %d\n"), i, htons(pData->i_ElevBiasCorr[i])); m_DataFile14.WriteString(strOutput); } iCount++; //i_spare42[4][40] for (int i = 0; i < 4; i++) { for (int j = 0; j < 40; j++) { strOutput.Format(_T("i_spare42[%.2d][%.2d] : %d\n"), i, j, htons(pData->i_spare42[i][j])); m_DataFile14.WriteString(strOutput); } } iCount++; //i_sigmaatt[40] for (int i = 0; i < 40; i++) { strOutput.Format(_T("i_sigmaatt[%.2d] : %d\n"), i, htons(pData->i_sigmaatt[i])); m_DataFile14.WriteString(strOutput); } iCount++; //i_Azimuth strOutput.Format(_T("i_Azimuth : %d\n"), htonl(pData->i_Azimuth)); m_DataFile14.WriteString(strOutput); iCount++; //i_AolAng strOutput.Format(_T("i_AolAng : %d\n"), htonl(pData->i_AolAng)); m_DataFile14.WriteString(strOutput); iCount++; //i_tpintensity_avg strOutput.Format(_T("i_tpintensity_avg : %d\n"), htonl(pData->i_tpintensity_avg)); m_DataFile14.WriteString(strOutput); iCount++; //i_tpazimuth_avg strOutput.Format(_T("i_tpazimuth_avg : %d\n"), htons(pData->i_tpazimuth_avg)); m_DataFile14.WriteString(strOutput); iCount++; //i_tpeccentricity_avg strOutput.Format(_T("i_tpeccentricity_avg : %d\n"), htons(pData->i_tpeccentricity_avg)); m_DataFile14.WriteString(strOutput); iCount++; //i_tpmajoraxis_avg strOutput.Format(_T("i_tpmajoraxis_avg : %d\n"), htons(pData->i_tpmajoraxis_avg)); m_DataFile14.WriteString(strOutput); iCount++; //i_poleTide[2] for (int i = 0; i < 2; i++) { strOutput.Format(_T("i_poleTide[%.2d] : %d\n"), i, pData->i_poleTide[i]); m_DataFile14.WriteString(strOutput); } iCount ++; //i_gdHt[2] for (int i = 0; i < 2; i++) { strOutput.Format(_T("i_gdHt[%.2d] : %d\n"), i, htons(pData->i_gdHt[i])); m_DataFile14.WriteString(strOutput); } iCount++; //i_erElv[2] for (int i = 0; i < 2; i++) { strOutput.Format(_T("i_erElv[%.2d] : %d\n"), i, htons(pData->i_erElv[i])); m_DataFile14.WriteString(strOutput); } iCount++; //i_spElv[4] for (int i = 0; i < 4; i++) { strOutput.Format(_T("i_spElv[%.2d] : %d\n"), i, htons(pData->i_spElv[i])); m_DataFile14.WriteString(strOutput); } iCount++; //i_ldElv[4] for (int i = 0; i < 4; i++) { strOutput.Format(_T("i_ldElv[%.2d] : %d\n"), i, htons(pData->i_ldElv[i])); m_DataFile14.WriteString(strOutput); } iCount++; //i_spare12[2] for (int i = 0; i < 2; i++) { strOutput.Format(_T("i_spare12[%.2d] : %d\n"), i, htons(pData->i_spare12[i])); m_DataFile14.WriteString(strOutput); } iCount++; //i_wTrop[2] for (int i = 0; i < 2; i++) { strOutput.Format(_T("i_wTrop[%.2d] : %d\n"), i, htons(pData->i_wTrop[i])); m_DataFile14.WriteString(strOutput); } iCount++; //i_dTrop[40] for (int i = 0; i < 40; i++) { strOutput.Format(_T("i_dTrop[%.2d] : %d\n"), i, htons(pData->i_dTrop[i])); m_DataFile14.WriteString(strOutput); } iCount++; //i_surfType strOutput.Format(_T("i_surfType : %d\n"), pData->i_surfType); m_DataFile14.WriteString(strOutput); iCount++; //i_spare11[3] for (int i = 0; i < 3; i++) { strOutput.Format(_T("i_spare11[%.2d] : %d\n"), i, pData->i_spare11[i]); m_DataFile14.WriteString(strOutput); } iCount ++; //i_DEM_elv[40] for (int i = 0; i < 40; i++) { strOutput.Format(_T("i_DEM_elv[%.2d] : %d\n"), i, htonl(pData->i_DEM_elv[i])); m_DataFile14.WriteString(strOutput); } iCount++; //i_refRng[40] for (int i = 0; i < 40; i++) { strOutput.Format(_T("i_refRng[%.2d] : %d\n"), i, htonl(pData->i_refRng[i])); m_DataFile14.WriteString(strOutput); } iCount++; //i_spare47[40] for (int i = 0; i < 40; i++) { strOutput.Format(_T("i_spare47[%.2d] : %d\n"), i, htonl(pData->i_spare47[i])); m_DataFile14.WriteString(strOutput); } iCount++; //i_ldRngOff[40] for (int i = 0; i < 40; i++) { strOutput.Format(_T("i_ldRngOff[%.2d] : %d\n"), i, htonl(pData->i_ldRngOff[i])); m_DataFile14.WriteString(strOutput); } iCount++; //i_SigEndOff[40] for (int i = 0; i < 40; i++) { strOutput.Format(_T("i_SigEndOff[%.2d] : %d\n"), i, htonl(pData->i_SigEndOff[i])); m_DataFile14.WriteString(strOutput); } iCount++; //i_gpCntRngOff[6][40] for (int i = 0; i < 6; i++) { for (int j = 0; j < 40; j++) { strOutput.Format(_T("i_gpCntRngOff[%.2d][%.2d] : %d\n"), i, j, htonl(pData->i_gpCntRngOff[i][j])); m_DataFile14.WriteString(strOutput); } } iCount++; //i_reflctUC[40] for (int i = 0; i < 40; i++) { strOutput.Format(_T("i_reflctUC[%.2d] : %d\n"), i, htonl(pData->i_reflctUC[i])); m_DataFile14.WriteString(strOutput); } iCount++; //i_reflCor_atm strOutput.Format(_T("i_reflCor_atm : %d\n"), htonl(pData->i_reflCor_atm)); m_DataFile14.WriteString(strOutput); iCount++; //i_maxSmAmp[40] for (int i = 0; i < 40; i++) { strOutput.Format(_T("i_maxSmAmp[%.2d] : %d\n"), i, htons(pData->i_maxSmAmp[i])); m_DataFile14.WriteString(strOutput); } iCount++; //i_ocElv[40] for (int i = 0; i < 40; i++) { strOutput.Format(_T("i_ocElv[%.2d] : %d\n"), i, htons(pData->i_ocElv[i])); m_DataFile14.WriteString(strOutput); } iCount++; //i_numPk[40] for (int i = 0; i < 40; i++) { strOutput.Format(_T("i_numPk[%.2d] : %d\n"), i, pData->i_numPk[i]); m_DataFile14.WriteString(strOutput); } iCount ++; //i_kurt1[40] for (int i = 0; i < 40; i++) { strOutput.Format(_T("i_kurt1[%.2d] : %d\n"), i, htons(pData->i_kurt1[i])); m_DataFile14.WriteString(strOutput); } iCount++; //i_skew1[40] for (int i = 0; i < 40; i++) { strOutput.Format(_T("i_skew1[%.2d] : %d\n"), i, htons(pData->i_skew1[i])); m_DataFile14.WriteString(strOutput); } iCount++; //i_spare4[160] for (int i = 0; i < 160; i++) { strOutput.Format(_T("i_spare4[%.3d] : %d\n"), i, pData->i_spare4[i]); m_DataFile14.WriteString(strOutput); } iCount ++; //i_Gamp[6][40] for (int i = 0; i < 6; i++) { for (int j = 0; j < 40; j++) { strOutput.Format(_T("i_Gamp[%.2d][%.2d] : %d\n"), i, j, htonl(pData->i_Gamp[i][j])); m_DataFile14.WriteString(strOutput); } } iCount++; //i_Garea[6][40] for (int i = 0; i < 6; i++) { for (int j = 0; j < 40; j++) { strOutput.Format(_T("i_Garea[%.2d][%.2d] : %d\n"), i, j, htonl(pData->i_Garea[i][j])); m_DataFile14.WriteString(strOutput); } } iCount++; //i_gsinma[6][40] for (int i = 0; i < 6; i++) { for (int j = 0; j < 40; j++) { strOutput.Format(_T("i_gsinma[%.2d][%.2d] : %d\n"), i, j, htonl(pData->i_gsinma[i][j])); m_DataFile14.WriteString(strOutput); } } iCount++; //i_nPeaks1[40] for (int i = 0; i < 40; i++) { strOutput.Format(_T("i_nPeaks1[%.2d] : %d\n"), i, pData->i_nPeaks1[i]); m_DataFile14.WriteString(strOutput); } iCount ++; //i_LandVar[40] for (int i = 0; i < 40; i++) { strOutput.Format(_T("i_LandVar[%.2d] : %d\n"), i, htons(pData->i_LandVar[i])); m_DataFile14.WriteString(strOutput); } iCount++; //i_ElvuseFlg[5] for (int i = 0; i < 5; i++) { strOutput.Format(_T("i_ElvuseFlg[%.2d] : %d\n"), i, pData->i_ElvuseFlg[i]); m_DataFile14.WriteString(strOutput); } iCount ++; //i_atm_avail strOutput.Format(_T("i_atm_avail : %d\n"), pData->i_atm_avail); m_DataFile14.WriteString(strOutput); iCount++; //i_spare16[4] for (int i = 0; i < 4; i++) { strOutput.Format(_T("i_spare16[%.2d] : %d\n"), i, pData->i_spare16[i]); m_DataFile14.WriteString(strOutput); } iCount ++; //i_cld1_mswf strOutput.Format(_T("i_cld1_mswf : %d\n"), pData->i_cld1_mswf); m_DataFile14.WriteString(strOutput); iCount++; //i_MRC_af strOutput.Format(_T("i_MRC_af : %d\n"), pData->i_MRC_af); m_DataFile14.WriteString(strOutput); iCount++; //i_spare9[40] for (int i = 0; i < 40; i++) { strOutput.Format(_T("i_spare9[%.2d] : %d\n"), pData->i_spare9[i]); m_DataFile14.WriteString(strOutput); } iCount ++; //i_ElvFlg[40] for (int i = 0; i < 40; i++) { strOutput.Format(_T("i_ElvFlg[%.2d] : %d\n"), i, pData->i_ElvFlg[i]); m_DataFile14.WriteString(strOutput); } iCount ++; //i_rng_UQF[40] for (int i = 0; i < 40; i++) { strOutput.Format(_T("i_rng_UQF[%.2d] : %d\n"), i, htons(pData->i_rng_UQF[i])); m_DataFile14.WriteString(strOutput); } iCount++; //i_spare49[10] for (int i = 0; i < 10; i++) { strOutput.Format(_T("i_spare49[%.2d] : %d\n"), i, pData->i_spare49[i]); m_DataFile14.WriteString(strOutput); } iCount ++; //i_timecorflg strOutput.Format(_T("i_timecorflg : %d\n"), htons(pData->i_timecorflg)); m_DataFile14.WriteString(strOutput); iCount++; //i_APID_AvFlg[8] for (int i = 0; i < 8; i++) { strOutput.Format(_T("i_APID_AvFlg[%.2d] : %d\n"), i, pData->i_APID_AvFlg[i]); m_DataFile14.WriteString(strOutput); } iCount ++; //i_AttFlg2[20] for (int i = 0; i < 20; i++) { strOutput.Format(_T("i_AttFlg2[%.2d] : %d\n"), i, pData->i_AttFlg2[i]); m_DataFile14.WriteString(strOutput); } iCount ++; //i_spare5 strOutput.Format(_T("i_spare5 : %d\n"), pData->i_spare5); m_DataFile14.WriteString(strOutput); iCount++; //i_FrameQF strOutput.Format(_T("i_FrameQF : %d\n"), pData->i_FrameQF); m_DataFile14.WriteString(strOutput); iCount++; //i_OrbFlg[2] for (int i = 0; i < 2; i++) { strOutput.Format(_T("i_OrbFlg[%.2d] : %d\n"), i, pData->i_OrbFlg[i]); m_DataFile14.WriteString(strOutput); } iCount ++; //i_rngCorrFlg[2] for (int i = 0; i < 2; i++) { strOutput.Format(_T("i_rngCorrFlg[%.2d] : %d\n"), i, pData->i_rngCorrFlg[i]); m_DataFile14.WriteString(strOutput); } iCount ++; //i_CorrStatFlg[2] for (int i = 0; i < 2; i++) { strOutput.Format(_T("i_CorrStatFlg[%.2d] : %d\n"), i, pData->i_CorrStatFlg[i]); m_DataFile14.WriteString(strOutput); } iCount ++; //i_spare15[8] for (int i = 0; i < 8; i++) { strOutput.Format(_T("i_spare15[%.2d] : %d\n"), i, pData->i_spare15[i]); m_DataFile14.WriteString(strOutput); } iCount ++; //i_Attflg1 strOutput.Format(_T("i_Attflg1 : %d\n"), htons(pData->i_Attflg1)); m_DataFile14.WriteString(strOutput); iCount++; //i_Spare6[2] for (int i = 0; i < 2; i++) { strOutput.Format(_T("i_Spare6[%.2d] : %d\n"), i, pData->i_Spare6[i]); m_DataFile14.WriteString(strOutput); } iCount ++; //i_spare44[120] for (int i = 0; i < 120; i++) { strOutput.Format(_T("i_spare44[%.3d] : %d\n"), i, pData->i_spare44[i]); m_DataFile14.WriteString(strOutput); } iCount ++; //i_satNdx[40] for (int i = 0; i < 40; i++) { strOutput.Format(_T("i_satNdx[%.2d] : %d\n"), i, pData->i_satNdx[i]); m_DataFile14.WriteString(strOutput); } iCount ++; //i_satElevCorr[40] for (int i = 0; i < 40; i++) { strOutput.Format(_T("i_satElevCorr[%.2d] : %d\n"), i, htons(pData->i_satElevCorr[i])); m_DataFile14.WriteString(strOutput); } iCount++; //i_satCorrFlg[40] for (int i = 0; i < 40; i++) { strOutput.Format(_T("i_satCorrFlg[%.2d] : %d\n"), i, pData->i_satCorrFlg[i]); m_DataFile14.WriteString(strOutput); } iCount ++; //i_satNrgCorr[40] for (int i = 0; i < 40; i++) { strOutput.Format(_T("i_satNrgCorr[%.2d] : %d\n"), i, htons(pData->i_satNrgCorr[i])); m_DataFile14.WriteString(strOutput); } iCount++; //i_spare13[40] for (int i = 0; i < 40; i++) { strOutput.Format(_T("i_spare13[%.2d] : %d\n"), i, htons(pData->i_spare13[i])); m_DataFile14.WriteString(strOutput); } iCount++; //i_gval_rcv[40] for (int i = 0; i < 40; i++) { strOutput.Format(_T("i_gval_rcv[%.2d] : %d\n"), i, htons(pData->i_gval_rcv[i])); m_DataFile14.WriteString(strOutput); } iCount++; //i_RecNrgAll[40] for (int i = 0; i < 40; i++) { strOutput.Format(_T("i_RecNrgAll[%.2d] : %d\n"), i, htons(pData->i_RecNrgAll[i])); m_DataFile14.WriteString(strOutput); } iCount++; //i_FRir_cldtop[40] for (int i = 0; i < 40; i++) { strOutput.Format(_T("i_FRir_cldtop[%.2d] : %d\n"), i, htons(pData->i_FRir_cldtop[i])); m_DataFile14.WriteString(strOutput); } iCount++; //i_FRir_gaFlag[40] for (int i = 0; i < 40; i++) { strOutput.Format(_T("i_FRir_qaFlag[%.2d] : %d\n"), i, pData->i_FRir_qaFlag[i]); m_DataFile14.WriteString(strOutput); } iCount ++; //i_atm_char_flag strOutput.Format(_T("i_atm_char_flag : %d\n"), htons(pData->i_atm_char_flag)); m_DataFile14.WriteString(strOutput); iCount++; //i_atm_char_conf strOutput.Format(_T("i_atm_char_conf : %d\n"), htons(pData->i_atm_char_conf)); m_DataFile14.WriteString(strOutput); iCount++; //i_spare48[36] for (int i = 0; i < 36; i++) { strOutput.Format(_T("i_spare48[%.2d] : %d\n"), i, pData->i_spare48[i]); m_DataFile14.WriteString(strOutput); } iCount ++; //i_FRir_intsig[40] for (int i = 0; i < 40; i++) { strOutput.Format(_T("i_FRir_intsig[%.2d] : %d\n"), i, htons(pData->i_FRir_intsig[i])); m_DataFile14.WriteString(strOutput); } iCount++; //i_spare14[120] for (int i = 0; i < 120; i++) { strOutput.Format(_T("i_spare14[%.3d] : %d\n"), i, pData->i_spare14[i]); m_DataFile14.WriteString(strOutput); } iCount ++; //i_Surface_temp strOutput.Format(_T("i_Surface_temp : %d\n"), htons(pData->i_Surface_temp)); m_DataFile14.WriteString(strOutput); iCount++; //i_Surface_pres strOutput.Format(_T("i_Surface_pres : %d\n"), htons(pData->i_Surface_pres)); m_DataFile14.WriteString(strOutput); iCount++; //i_Surface_relh strOutput.Format(_T("i_Surface_relh : %d\n"), htons(pData->i_Surface_relh)); m_DataFile14.WriteString(strOutput); iCount++; //i_maxRecAmp[40] for (int i = 0; i < 40; i++) { strOutput.Format(_T("i_maxRecAmp[%.2d] : %d\n"), i, htons(pData->i_maxRecAmp[i])); m_DataFile14.WriteString(strOutput); } iCount++; //i_sDevNsOb1[40] for (int i = 0; i < 40; i++) { strOutput.Format(_T("i_sDevNsOb1[%.2d] : %d\n"), i, htons(pData->i_sDevNsOb1[i])); m_DataFile14.WriteString(strOutput); } iCount++; //i_spare8[2] for (int i = 0; i < 2; i++) { strOutput.Format(_T("i_spare8[%.2d] : %d\n"), i, pData->i_spare8[i]); m_DataFile14.WriteString(strOutput); } iCount ++; //i_isRngOff[40] for (int i = 0; i < 40; i++) { strOutput.Format(_T("i_isRngOff[%.2d] : %d\n"), i, htonl(pData->i_isRngOff[i])); m_DataFile14.WriteString(strOutput); } iCount++; //i_pctSAT[40] for (int i = 0; i < 40; i++) { strOutput.Format(_T("i_pctSAT[%.2d] : %d\n"), i, pData->i_pctSAT[i]); m_DataFile14.WriteString(strOutput); } iCount ++; //i_TxNrg[40] for (int i = 0; i < 40; i++) { strOutput.Format(_T("i_TxNrg[%.2d] : %d\n"), i, htons(pData->i_TxNrg[i])); m_DataFile14.WriteString(strOutput); } iCount++; //i_eqElv[2] for (int i = 0; i < 2; i++) { strOutput.Format(_T("i_eqElv[%.2d] : %d\n"), i, htons(pData->i_eqElv[i])); m_DataFile14.WriteString(strOutput); } iCount++; //i_spare7[120] for (int i = 0; i < 120; i++) { strOutput.Format(_T("i_spare7[%.3d] : %d\n"), i, pData->i_spare7[i]); m_DataFile14.WriteString(strOutput); } iCount ++; m_DataFile14.WriteString("\n------------------------------------------------------------\n\n"); ASSERT(iCount == 105); } void GLAData::TraversalData01_Little(char *pBuffer) { // main=1, long=2, or short=3 GLA01_SHORT* pData = (GLA01_SHORT*)pBuffer; short iType = htons(pData->i_gla01_rectype); //if (iType == 3) //{ // short int iIndex = htonl(pData->i_rec_ndx); //TRACE("%d\n", iIndex); m_indexMin = iIndex < m_indexMin ? iIndex : m_indexMin; m_indexMax = iIndex > m_indexMax ? iIndex : m_indexMax; std::set<int>::iterator iter = m_Search_Rec_Index.find(iIndex); if (iter != m_Search_Rec_Index.end()) { if (m_DataFile01.m_hFile != INVALID_HANDLE_VALUE) { CString str; str.Format(_T("Record : %d\n"), m_iCount01); m_DataFile01.WriteString(str); } m_iCount01++; PrintData01_Little(pBuffer); } //} } void GLAData::PrintData01_Little(char* pBuffer) { if (m_DataFile01.m_hFile == INVALID_HANDLE_VALUE) { WriteLog(_T("Output DataFile01 is invalid!")); return; } GLA01_SHORT* pData = (GLA01_SHORT*)pBuffer; CString strOutput; int iCount = 0; //i_rec_ndx strOutput.Format(_T("i_rec_ndx : %d\n"), htonl(pData->i_rec_ndx)); m_DataFile01.WriteString(strOutput); iCount ++; //i_UTCTime[2] for (int i = 0; i < 2; i++) { strOutput.Format(_T("i_UTCTime[%.2d] : %d\n"), i, htonl(pData->i_UTCTime[i])); m_DataFile01.WriteString(strOutput); } iCount++; //i_gla01_rectype strOutput.Format(_T("i_gla01_rectype : %d\n"), htons(pData->i_gla01_rectype)); m_DataFile01.WriteString(strOutput); iCount++; //i_spare1 strOutput.Format(_T("i_spare1 : %d\n"), htons(pData->i_spare1)); m_DataFile01.WriteString(strOutput); iCount++; //i_filtnum[20] for (int i = 0; i < 20; i++) { strOutput.Format(_T("i_filtnum[%.2d] : %d\n"), i, pData->i_filtnum[i]); m_DataFile01.WriteString(strOutput); } iCount ++; //i_shot_ctr[20] for (int i = 0; i < 20; i++) { strOutput.Format(_T("i_shot_ctr[%.2d] : %d\n"), i, htons(pData->i_shot_ctr[i])); m_DataFile01.WriteString(strOutput); } iCount++; //istatflags[20] for (int i = 0; i < 20; i++) { strOutput.Format(_T("istatflags[%.2d] : %d\n"), i, htonl(pData->istatflags[i])); m_DataFile01.WriteString(strOutput); } iCount++; //i_gainSet1064[20] for (int i = 0; i < 20; i++) { strOutput.Format(_T("i_gainSet1064[%.2d] : %d\n"), i, htons(pData->i_gainSet1064[i])); m_DataFile01.WriteString(strOutput); } iCount++; //i_4nsPeakVal[20] for (int i = 0; i < 20; i++) { strOutput.Format(_T("i_4nsPeakVal[%.2d] : %d\n"), i, htons(pData->i_4nsPeakVal[i])); m_DataFile01.WriteString(strOutput); } iCount++; //i_8nsPeakVal[20] for (int i = 0; i < 20; i++) { strOutput.Format(_T("i_8nsPeakVal[%.2d] : %d\n"), i, htons(pData->i_8nsPeakVal[i])); m_DataFile01.WriteString(strOutput); } iCount++; //i_4nsBgMead[20] for (int i = 0; i < 20; i++) { strOutput.Format(_T("i_4nsBgMead[%.2d] : %d\n"), i, (unsigned short)(htons(pData->i_4nsBgMead[i]))); m_DataFile01.WriteString(strOutput); } iCount++; //i_4nsBgSDEV[20] for (int i = 0; i < 20; i++) { strOutput.Format(_T("i_4nsBgSDEV[%.2d] : %d\n"), i, (unsigned short)(htons(pData->i_4nsBgSDEV[i]))); m_DataFile01.WriteString(strOutput); } iCount++; //i_samp_pad[40] for (int i = 0; i < 40; i++) { strOutput.Format(_T("i_samp_pad[%.2d] : %d\n"), i, htons(pData->i_samp_pad[i])); m_DataFile01.WriteString(strOutput); } iCount++; //i_comp_type[20] for (int i = 0; i < 20; i++) { strOutput.Format(_T("i_comp_type[%.2d] : %d\n"), i, pData->i_comp_type[i]); m_DataFile01.WriteString(strOutput); } iCount ++; //i_rng_wf[200][20] for (int i = 0; i < 200; i++) { for (int j = 0; j < 20; j++) { strOutput.Format(_T("i_rng_wf[%.3d][%.2d] : %d\n"), i, j, pData->i_rng_wf[i][j]); m_DataFile14.WriteString(strOutput); } } iCount++; //i_gainStatus[20] for (int i = 0; i < 20; i++) { strOutput.Format(_T("i_gainStatus[%.2d] : %d\n"), i, pData->i_gainStatus[i]); m_DataFile01.WriteString(strOutput); } iCount ++; //i_NumCoinc[20] for (int i = 0; i < 20; i++) { strOutput.Format(_T("i_NumCoinc[%.2d] : %d\n"), i, pData->i_NumCoinc[i]); m_DataFile01.WriteString(strOutput); } iCount ++; //i_rawPkHt[20] for (int i = 0; i < 20; i++) { strOutput.Format(_T("i_rawPkHt[%.2d] : %d\n"), i, pData->i_rawPkHt[i]); m_DataFile01.WriteString(strOutput); } iCount ++; //i_spare2[184] for (int i = 0; i < 184; i++) { strOutput.Format(_T("i_spare2[%.2d] : %d\n"), i, pData->i_spare2[i]); m_DataFile01.WriteString(strOutput); } iCount ++; m_DataFile01.WriteString("\n------------------------------------------------------------\n\n"); ASSERT(iCount == 19); } void GLAData::TraversalData14_Big(char *pBuffer) { GLA14* pData = (GLA14*)pBuffer; bool bMark = false; for (int i = 0; i < 40; i ++) { if (pData->i_FRir_qaFlag[i] != 15) return; } for (int i = 0; i < 40; i++) { int iLat = pData->i_lat[i]; int iLon = pData->i_lon[i]; if (m_iLatMin <= iLat && iLat <= m_iLatMax && m_iLonMin <= iLon && iLon <= m_iLonMax) { bMark = true; } } if (bMark) { if (m_DataFile14.m_hFile != INVALID_HANDLE_VALUE) { CString str; str.Format(_T("Record : %d\n"), m_iCount14); m_DataFile14.WriteString(str); } m_iCount14++; PrintData14_Big(pBuffer); } } void GLAData::PrintData14_Big(char* pBuffer) { if (m_DataFile14.m_hFile == INVALID_HANDLE_VALUE) { WriteLog(_T("Output DataFile14 is invalid!")); return; } GLA14* pData = (GLA14*)pBuffer; CString strOutput; int iCount = 0; //i_rec_ndx strOutput.Format(_T("i_rec_ndx : %d\n"), pData->i_rec_ndx); m_DataFile14.WriteString(strOutput); iCount ++; m_Search_Rec_Index.insert(pData->i_rec_ndx); return; //i_UTCTime[2]; for (int i = 0; i < 2; i++) { strOutput.Format(_T("i_UTCTime[%.2d] : %d\n"), i, pData->i_UTCTime[i]); m_DataFile14.WriteString(strOutput); } iCount++; //i_transtime strOutput.Format(_T("i_transtime : %d\n"), pData->i_transtime); m_DataFile14.WriteString(strOutput); iCount ++; //i_Spare1[2] for (int i = 0; i < 2; i++) { strOutput.Format(_T("i_Spare1[%.2d] : %d\n"), i, pData->i_Spare1[i]); m_DataFile14.WriteString(strOutput); } iCount ++; //i_deltagpstmcor strOutput.Format(_T("i_deltagpstmcor : %d\n"), pData->i_deltagpstmcor); m_DataFile14.WriteString(strOutput); iCount ++; //i_dShortTime[39] for (int i = 0; i < 39; i++) { strOutput.Format(_T("i_dShortTime[%.2d] : %d\n"), i, pData->i_dShortTime[i]); m_DataFile14.WriteString(strOutput); } iCount++; //i_lat[40] for (int i = 0; i < 40; i++) { strOutput.Format(_T("i_lat[%.2d] : %d\n"), i, pData->i_lat[i]); m_DataFile14.WriteString(strOutput); } iCount++; //i_lon[40] for (int i = 0; i < 40; i++) { strOutput.Format(_T("i_lon[%.2d] : %d\n"), i, pData->i_lon[i]); m_DataFile14.WriteString(strOutput); } iCount++; //i_elev[40] for (int i = 0; i < 40; i++) { strOutput.Format(_T("i_elev[%.2d] : %d\n"), i, pData->i_elev[i]); m_DataFile14.WriteString(strOutput); } iCount++; //i_campaign[2] for (int i = 0; i < 2; i++) { strOutput.Format(_T("i_campaign[%.2d] : %d\n"), i, pData->i_campaign[i]); m_DataFile14.WriteString(strOutput); } iCount ++; //i_spare40 strOutput.Format(_T("i_spare40 : %d\n"), pData->i_spare40); m_DataFile14.WriteString(strOutput); iCount++; //i_cycTrk strOutput.Format(_T("i_cycTrk : %d\n"), pData->i_cycTrk); m_DataFile14.WriteString(strOutput); iCount++; //i_localSolarTime strOutput.Format(_T("i_localSolarTime : %d\n"), pData->i_localSolarTime); m_DataFile14.WriteString(strOutput); iCount++; //i_spare41[7] for (int i = 0; i < 7; i++) { strOutput.Format(_T("i_spare41[%.2d] : %d\n"), i, pData->i_spare41[i]); m_DataFile14.WriteString(strOutput); } iCount++; //i_deltaEllip[40] for (int i = 0; i < 40; i++) { strOutput.Format(_T("i_deltaEllip[%.2d] : %d\n"), i, pData->i_deltaEllip[i]); m_DataFile14.WriteString(strOutput); } iCount++; //i_beamCoelv[40] for (int i = 0; i < 40; i++) { strOutput.Format(_T("i_beamCoelv[%.2d] : %d\n"), i, pData->i_beamCoelv[i]); m_DataFile14.WriteString(strOutput); } iCount++; //i_beamAzimuth[40] for (int i = 0; i < 40; i++) { strOutput.Format(_T("i_beamAzimuth[%.2d] : %d\n"), i, pData->i_beamAzimuth[i]); m_DataFile14.WriteString(strOutput); } iCount++; //i_d2refTrk[40] for (int i = 0; i < 40; i++) { strOutput.Format(_T("i_d2refTrk[%.2d] : %d\n"), i, pData->i_d2refTrk[i]); m_DataFile14.WriteString(strOutput); } iCount++; //i_SigBegOff[40] for (int i = 0; i < 40; i++) { strOutput.Format(_T("i_SigBegOff[%.2d] : %d\n"), i, pData->i_SigBegOff[i]); m_DataFile14.WriteString(strOutput); } iCount++; //i_DEM_hires_src[40] for (int i = 0; i < 40; i++) { strOutput.Format(_T("i_DEM_hires_src[%.2d] : %d\n"), i, pData->i_DEM_hires_src[i]); m_DataFile14.WriteString(strOutput); } iCount ++; //i_DEMhiresArelv[9][40] for (int i = 0; i < 9; i++) { for (int j = 0; j < 40; j++) { strOutput.Format(_T("i_DEMhiresArelv[%.2d][%.2d] : %d\n"), i, j, pData->i_DEMhiresArelv[i][j]); m_DataFile14.WriteString(strOutput); } } iCount++; //i_ElevBiasCorr[40] for (int i = 0; i < 40; i++) { strOutput.Format(_T("i_ElevBiasCorr[%.2d] : %d\n"), i, pData->i_ElevBiasCorr[i]); m_DataFile14.WriteString(strOutput); } iCount++; //i_spare42[4][40] for (int i = 0; i < 4; i++) { for (int j = 0; j < 40; j++) { strOutput.Format(_T("i_spare42[%.2d][%.2d] : %d\n"), i, j, pData->i_spare42[i][j]); m_DataFile14.WriteString(strOutput); } } iCount++; //i_sigmaatt[40] for (int i = 0; i < 40; i++) { strOutput.Format(_T("i_sigmaatt[%.2d] : %d\n"), i, pData->i_sigmaatt[i]); m_DataFile14.WriteString(strOutput); } iCount++; //i_Azimuth strOutput.Format(_T("i_Azimuth : %d\n"), pData->i_Azimuth); m_DataFile14.WriteString(strOutput); iCount++; //i_AolAng strOutput.Format(_T("i_AolAng : %d\n"), pData->i_AolAng); m_DataFile14.WriteString(strOutput); iCount++; //i_tpintensity_avg strOutput.Format(_T("i_tpintensity_avg : %d\n"), pData->i_tpintensity_avg); m_DataFile14.WriteString(strOutput); iCount++; //i_tpazimuth_avg strOutput.Format(_T("i_tpazimuth_avg : %d\n"), pData->i_tpazimuth_avg); m_DataFile14.WriteString(strOutput); iCount++; //i_tpeccentricity_avg strOutput.Format(_T("i_tpeccentricity_avg : %d\n"), pData->i_tpeccentricity_avg); m_DataFile14.WriteString(strOutput); iCount++; //i_tpmajoraxis_avg strOutput.Format(_T("i_tpmajoraxis_avg : %d\n"), pData->i_tpmajoraxis_avg); m_DataFile14.WriteString(strOutput); iCount++; //i_poleTide[2] for (int i = 0; i < 2; i++) { strOutput.Format(_T("i_poleTide[%.2d] : %d\n"), i, pData->i_poleTide[i]); m_DataFile14.WriteString(strOutput); } iCount ++; //i_gdHt[2] for (int i = 0; i < 2; i++) { strOutput.Format(_T("i_gdHt[%.2d] : %d\n"), i, pData->i_gdHt[i]); m_DataFile14.WriteString(strOutput); } iCount++; //i_erElv[2] for (int i = 0; i < 2; i++) { strOutput.Format(_T("i_erElv[%.2d] : %d\n"), i, pData->i_erElv[i]); m_DataFile14.WriteString(strOutput); } iCount++; //i_spElv[4] for (int i = 0; i < 4; i++) { strOutput.Format(_T("i_spElv[%.2d] : %d\n"), i, pData->i_spElv[i]); m_DataFile14.WriteString(strOutput); } iCount++; //i_ldElv[4] for (int i = 0; i < 4; i++) { strOutput.Format(_T("i_ldElv[%.2d] : %d\n"), i, pData->i_ldElv[i]); m_DataFile14.WriteString(strOutput); } iCount++; //i_spare12[2] for (int i = 0; i < 2; i++) { strOutput.Format(_T("i_spare12[%.2d] : %d\n"), i, pData->i_spare12[i]); m_DataFile14.WriteString(strOutput); } iCount++; //i_wTrop[2] for (int i = 0; i < 2; i++) { strOutput.Format(_T("i_wTrop[%.2d] : %d\n"), i, pData->i_wTrop[i]); m_DataFile14.WriteString(strOutput); } iCount++; //i_dTrop[40] for (int i = 0; i < 40; i++) { strOutput.Format(_T("i_dTrop[%.2d] : %d\n"), i, pData->i_dTrop[i]); m_DataFile14.WriteString(strOutput); } iCount++; //i_surfType strOutput.Format(_T("i_surfType : %d\n"), pData->i_surfType); m_DataFile14.WriteString(strOutput); iCount++; //i_spare11[3] for (int i = 0; i < 3; i++) { strOutput.Format(_T("i_spare11[%.2d] : %d\n"), i, pData->i_spare11[i]); m_DataFile14.WriteString(strOutput); } iCount ++; //i_DEM_elv[40] for (int i = 0; i < 40; i++) { strOutput.Format(_T("i_DEM_elv[%.2d] : %d\n"), i, pData->i_DEM_elv[i]); m_DataFile14.WriteString(strOutput); } iCount++; //i_refRng[40] for (int i = 0; i < 40; i++) { strOutput.Format(_T("i_refRng[%.2d] : %d\n"), i, pData->i_refRng[i]); m_DataFile14.WriteString(strOutput); } iCount++; //i_spare47[40] for (int i = 0; i < 40; i++) { strOutput.Format(_T("i_spare47[%.2d] : %d\n"), i, pData->i_spare47[i]); m_DataFile14.WriteString(strOutput); } iCount++; //i_ldRngOff[40] for (int i = 0; i < 40; i++) { strOutput.Format(_T("i_ldRngOff[%.2d] : %d\n"), i, pData->i_ldRngOff[i]); m_DataFile14.WriteString(strOutput); } iCount++; //i_SigEndOff[40] for (int i = 0; i < 40; i++) { strOutput.Format(_T("i_SigEndOff[%.2d] : %d\n"), i, pData->i_SigEndOff[i]); m_DataFile14.WriteString(strOutput); } iCount++; //i_gpCntRngOff[6][40] for (int i = 0; i < 6; i++) { for (int j = 0; j < 40; j++) { strOutput.Format(_T("i_gpCntRngOff[%.2d][%.2d] : %d\n"), i, j, pData->i_gpCntRngOff[i][j]); m_DataFile14.WriteString(strOutput); } } iCount++; //i_reflctUC[40] for (int i = 0; i < 40; i++) { strOutput.Format(_T("i_reflctUC[%.2d] : %d\n"), i, pData->i_reflctUC[i]); m_DataFile14.WriteString(strOutput); } iCount++; //i_reflCor_atm strOutput.Format(_T("i_reflCor_atm : %d\n"), pData->i_reflCor_atm); m_DataFile14.WriteString(strOutput); iCount++; //i_maxSmAmp[40] for (int i = 0; i < 40; i++) { strOutput.Format(_T("i_maxSmAmp[%.2d] : %d\n"), i, pData->i_maxSmAmp[i]); m_DataFile14.WriteString(strOutput); } iCount++; //i_ocElv[40] for (int i = 0; i < 40; i++) { strOutput.Format(_T("i_ocElv[%.2d] : %d\n"), i, pData->i_ocElv[i]); m_DataFile14.WriteString(strOutput); } iCount++; //i_numPk[40] for (int i = 0; i < 40; i++) { strOutput.Format(_T("i_numPk[%.2d] : %d\n"), i, pData->i_numPk[i]); m_DataFile14.WriteString(strOutput); } iCount ++; //i_kurt1[40] for (int i = 0; i < 40; i++) { strOutput.Format(_T("i_kurt1[%.2d] : %d\n"), i, pData->i_kurt1[i]); m_DataFile14.WriteString(strOutput); } iCount++; //i_skew1[40] for (int i = 0; i < 40; i++) { strOutput.Format(_T("i_skew1[%.2d] : %d\n"), i, pData->i_skew1[i]); m_DataFile14.WriteString(strOutput); } iCount++; //i_spare4[160] for (int i = 0; i < 160; i++) { strOutput.Format(_T("i_spare4[%.3d] : %d\n"), i, pData->i_spare4[i]); m_DataFile14.WriteString(strOutput); } iCount ++; //i_Gamp[6][40] for (int i = 0; i < 6; i++) { for (int j = 0; j < 40; j++) { strOutput.Format(_T("i_Gamp[%.2d][%.2d] : %d\n"), i, j, pData->i_Gamp[i][j]); m_DataFile14.WriteString(strOutput); } } iCount++; //i_Garea[6][40] for (int i = 0; i < 6; i++) { for (int j = 0; j < 40; j++) { strOutput.Format(_T("i_Garea[%.2d][%.2d] : %d\n"), i, j, pData->i_Garea[i][j]); m_DataFile14.WriteString(strOutput); } } iCount++; //i_gsinma[6][40] for (int i = 0; i < 6; i++) { for (int j = 0; j < 40; j++) { strOutput.Format(_T("i_gsinma[%.2d][%.2d] : %d\n"), i, j, pData->i_gsinma[i][j]); m_DataFile14.WriteString(strOutput); } } iCount++; //i_nPeaks1[40] for (int i = 0; i < 40; i++) { strOutput.Format(_T("i_nPeaks1[%.2d] : %d\n"), i, pData->i_nPeaks1[i]); m_DataFile14.WriteString(strOutput); } iCount ++; //i_LandVar[40] for (int i = 0; i < 40; i++) { strOutput.Format(_T("i_LandVar[%.2d] : %d\n"), i, pData->i_LandVar[i]); m_DataFile14.WriteString(strOutput); } iCount++; //i_ElvuseFlg[5] for (int i = 0; i < 5; i++) { strOutput.Format(_T("i_ElvuseFlg[%.2d] : %d\n"), i, pData->i_ElvuseFlg[i]); m_DataFile14.WriteString(strOutput); } iCount ++; //i_atm_avail strOutput.Format(_T("i_atm_avail : %d\n"), pData->i_atm_avail); m_DataFile14.WriteString(strOutput); iCount++; //i_spare16[4] for (int i = 0; i < 4; i++) { strOutput.Format(_T("i_spare16[%.2d] : %d\n"), i, pData->i_spare16[i]); m_DataFile14.WriteString(strOutput); } iCount ++; //i_cld1_mswf strOutput.Format(_T("i_cld1_mswf : %d\n"), pData->i_cld1_mswf); m_DataFile14.WriteString(strOutput); iCount++; //i_MRC_af strOutput.Format(_T("i_MRC_af : %d\n"), pData->i_MRC_af); m_DataFile14.WriteString(strOutput); iCount++; //i_spare9[40] for (int i = 0; i < 40; i++) { strOutput.Format(_T("i_spare9[%.2d] : %d\n"), pData->i_spare9[i]); m_DataFile14.WriteString(strOutput); } iCount ++; //i_ElvFlg[40] for (int i = 0; i < 40; i++) { strOutput.Format(_T("i_ElvFlg[%.2d] : %d\n"), i, pData->i_ElvFlg[i]); m_DataFile14.WriteString(strOutput); } iCount ++; //i_rng_UQF[40] for (int i = 0; i < 40; i++) { strOutput.Format(_T("i_rng_UQF[%.2d] : %d\n"), i, pData->i_rng_UQF[i]); m_DataFile14.WriteString(strOutput); } iCount++; //i_spare49[10] for (int i = 0; i < 10; i++) { strOutput.Format(_T("i_spare49[%.2d] : %d\n"), i, pData->i_spare49[i]); m_DataFile14.WriteString(strOutput); } iCount ++; //i_timecorflg strOutput.Format(_T("i_timecorflg : %d\n"), pData->i_timecorflg); m_DataFile14.WriteString(strOutput); iCount++; //i_APID_AvFlg[8] for (int i = 0; i < 8; i++) { strOutput.Format(_T("i_APID_AvFlg[%.2d] : %d\n"), i, pData->i_APID_AvFlg[i]); m_DataFile14.WriteString(strOutput); } iCount ++; //i_AttFlg2[20] for (int i = 0; i < 20; i++) { strOutput.Format(_T("i_AttFlg2[%.2d] : %d\n"), i, pData->i_AttFlg2[i]); m_DataFile14.WriteString(strOutput); } iCount ++; //i_spare5 strOutput.Format(_T("i_spare5 : %d\n"), pData->i_spare5); m_DataFile14.WriteString(strOutput); iCount++; //i_FrameQF strOutput.Format(_T("i_FrameQF : %d\n"), pData->i_FrameQF); m_DataFile14.WriteString(strOutput); iCount++; //i_OrbFlg[2] for (int i = 0; i < 2; i++) { strOutput.Format(_T("i_OrbFlg[%.2d] : %d\n"), i, pData->i_OrbFlg[i]); m_DataFile14.WriteString(strOutput); } iCount ++; //i_rngCorrFlg[2] for (int i = 0; i < 2; i++) { strOutput.Format(_T("i_rngCorrFlg[%.2d] : %d\n"), i, pData->i_rngCorrFlg[i]); m_DataFile14.WriteString(strOutput); } iCount ++; //i_CorrStatFlg[2] for (int i = 0; i < 2; i++) { strOutput.Format(_T("i_CorrStatFlg[%.2d] : %d\n"), i, pData->i_CorrStatFlg[i]); m_DataFile14.WriteString(strOutput); } iCount ++; //i_spare15[8] for (int i = 0; i < 8; i++) { strOutput.Format(_T("i_spare15[%.2d] : %d\n"), i, pData->i_spare15[i]); m_DataFile14.WriteString(strOutput); } iCount ++; //i_Attflg1 strOutput.Format(_T("i_Attflg1 : %d\n"), pData->i_Attflg1); m_DataFile14.WriteString(strOutput); iCount++; //i_Spare6[2] for (int i = 0; i < 2; i++) { strOutput.Format(_T("i_Spare6[%.2d] : %d\n"), i, pData->i_Spare6[i]); m_DataFile14.WriteString(strOutput); } iCount ++; //i_spare44[120] for (int i = 0; i < 120; i++) { strOutput.Format(_T("i_spare44[%.3d] : %d\n"), i, pData->i_spare44[i]); m_DataFile14.WriteString(strOutput); } iCount ++; //i_satNdx[40] for (int i = 0; i < 40; i++) { strOutput.Format(_T("i_satNdx[%.2d] : %d\n"), i, pData->i_satNdx[i]); m_DataFile14.WriteString(strOutput); } iCount ++; //i_satElevCorr[40] for (int i = 0; i < 40; i++) { strOutput.Format(_T("i_satElevCorr[%.2d] : %d\n"), i, pData->i_satElevCorr[i]); m_DataFile14.WriteString(strOutput); } iCount++; //i_satCorrFlg[40] for (int i = 0; i < 40; i++) { strOutput.Format(_T("i_satCorrFlg[%.2d] : %d\n"), i, pData->i_satCorrFlg[i]); m_DataFile14.WriteString(strOutput); } iCount ++; //i_satNrgCorr[40] for (int i = 0; i < 40; i++) { strOutput.Format(_T("i_satNrgCorr[%.2d] : %d\n"), i, pData->i_satNrgCorr[i]); m_DataFile14.WriteString(strOutput); } iCount++; //i_spare13[40] for (int i = 0; i < 40; i++) { strOutput.Format(_T("i_spare13[%.2d] : %d\n"), i, pData->i_spare13[i]); m_DataFile14.WriteString(strOutput); } iCount++; //i_gval_rcv[40] for (int i = 0; i < 40; i++) { strOutput.Format(_T("i_gval_rcv[%.2d] : %d\n"), i, pData->i_gval_rcv[i]); m_DataFile14.WriteString(strOutput); } iCount++; //i_RecNrgAll[40] for (int i = 0; i < 40; i++) { strOutput.Format(_T("i_RecNrgAll[%.2d] : %d\n"), i, pData->i_RecNrgAll[i]); m_DataFile14.WriteString(strOutput); } iCount++; //i_FRir_cldtop[40] for (int i = 0; i < 40; i++) { strOutput.Format(_T("i_FRir_cldtop[%.2d] : %d\n"), i, pData->i_FRir_cldtop[i]); m_DataFile14.WriteString(strOutput); } iCount++; //i_FRir_gaFlag[40] for (int i = 0; i < 40; i++) { strOutput.Format(_T("i_FRir_qaFlag[%.2d] : %d\n"), i, pData->i_FRir_qaFlag[i]); m_DataFile14.WriteString(strOutput); } iCount ++; //i_atm_char_flag strOutput.Format(_T("i_atm_char_flag : %d\n"), pData->i_atm_char_flag); m_DataFile14.WriteString(strOutput); iCount++; //i_atm_char_conf strOutput.Format(_T("i_atm_char_conf : %d\n"), pData->i_atm_char_conf); m_DataFile14.WriteString(strOutput); iCount++; //i_spare48[36] for (int i = 0; i < 36; i++) { strOutput.Format(_T("i_spare48[%.2d] : %d\n"), i, pData->i_spare48[i]); m_DataFile14.WriteString(strOutput); } iCount ++; //i_FRir_intsig[40] for (int i = 0; i < 40; i++) { strOutput.Format(_T("i_FRir_intsig[%.2d] : %d\n"), i, pData->i_FRir_intsig[i]); m_DataFile14.WriteString(strOutput); } iCount++; //i_spare14[120] for (int i = 0; i < 120; i++) { strOutput.Format(_T("i_spare14[%.3d] : %d\n"), i, pData->i_spare14[i]); m_DataFile14.WriteString(strOutput); } iCount ++; //i_Surface_temp strOutput.Format(_T("i_Surface_temp : %d\n"), pData->i_Surface_temp); m_DataFile14.WriteString(strOutput); iCount++; //i_Surface_pres strOutput.Format(_T("i_Surface_pres : %d\n"), pData->i_Surface_pres); m_DataFile14.WriteString(strOutput); iCount++; //i_Surface_relh strOutput.Format(_T("i_Surface_relh : %d\n"), pData->i_Surface_relh); m_DataFile14.WriteString(strOutput); iCount++; //i_maxRecAmp[40] for (int i = 0; i < 40; i++) { strOutput.Format(_T("i_maxRecAmp[%.2d] : %d\n"), i, pData->i_maxRecAmp[i]); m_DataFile14.WriteString(strOutput); } iCount++; //i_sDevNsOb1[40] for (int i = 0; i < 40; i++) { strOutput.Format(_T("i_sDevNsOb1[%.2d] : %d\n"), i, pData->i_sDevNsOb1[i]); m_DataFile14.WriteString(strOutput); } iCount++; //i_spare8[2] for (int i = 0; i < 2; i++) { strOutput.Format(_T("i_spare8[%.2d] : %d\n"), i, pData->i_spare8[i]); m_DataFile14.WriteString(strOutput); } iCount ++; //i_isRngOff[40] for (int i = 0; i < 40; i++) { strOutput.Format(_T("i_isRngOff[%.2d] : %d\n"), i, pData->i_isRngOff[i]); m_DataFile14.WriteString(strOutput); } iCount++; //i_pctSAT[40] for (int i = 0; i < 40; i++) { strOutput.Format(_T("i_pctSAT[%.2d] : %d\n"), i, pData->i_pctSAT[i]); m_DataFile14.WriteString(strOutput); } iCount ++; //i_TxNrg[40] for (int i = 0; i < 40; i++) { strOutput.Format(_T("i_TxNrg[%.2d] : %d\n"), i, pData->i_TxNrg[i]); m_DataFile14.WriteString(strOutput); } iCount++; //i_eqElv[2] for (int i = 0; i < 2; i++) { strOutput.Format(_T("i_eqElv[%.2d] : %d\n"), i, pData->i_eqElv[i]); m_DataFile14.WriteString(strOutput); } iCount++; //i_spare7[120] for (int i = 0; i < 120; i++) { strOutput.Format(_T("i_spare7[%.3d] : %d\n"), i, pData->i_spare7[i]); m_DataFile14.WriteString(strOutput); } iCount ++; m_DataFile14.WriteString("\n------------------------------------------------------------\n\n"); ASSERT(iCount == 105); } void GLAData::TraversalData01_Big(char *pBuffer) { // main=1, long=2, or short=3 GLA01_SHORT* pData = (GLA01_SHORT*)pBuffer; short iType = htons(pData->i_gla01_rectype); //if (iType == 3) //{ // short int iIndex = pData->i_rec_ndx; m_indexMin = iIndex < m_indexMin ? iIndex : m_indexMin; m_indexMax = iIndex > m_indexMax ? iIndex : m_indexMax; std::set<int>::iterator iter = m_Search_Rec_Index.find(iIndex); if (iter != m_Search_Rec_Index.end()) { if (m_DataFile01.m_hFile != INVALID_HANDLE_VALUE) { CString str; str.Format(_T("Record : %d\n"), m_iCount01); m_DataFile01.WriteString(str); } m_iCount01++; PrintData01_Big(pBuffer); } //} } void GLAData::PrintData01_Big(char* pBuffer) { if (m_DataFile01.m_hFile == INVALID_HANDLE_VALUE) { WriteLog(_T("Output DataFile01 is invalid!")); return; } GLA01_SHORT* pData = (GLA01_SHORT*)pBuffer; CString strOutput; int iCount = 0; //i_rec_ndx strOutput.Format(_T("i_rec_ndx : %d\n"), pData->i_rec_ndx); m_DataFile01.WriteString(strOutput); iCount ++; //i_UTCTime[2] for (int i = 0; i < 2; i++) { strOutput.Format(_T("i_UTCTime[%.2d] : %d\n"), i, pData->i_UTCTime[i]); m_DataFile01.WriteString(strOutput); } iCount++; //i_gla01_rectype strOutput.Format(_T("i_gla01_rectype : %d\n"), pData->i_gla01_rectype); m_DataFile01.WriteString(strOutput); iCount++; //i_spare1 strOutput.Format(_T("i_spare1 : %d\n"), pData->i_spare1); m_DataFile01.WriteString(strOutput); iCount++; //i_filtnum[20] for (int i = 0; i < 20; i++) { strOutput.Format(_T("i_filtnum[%.2d] : %d\n"), i, pData->i_filtnum[i]); m_DataFile01.WriteString(strOutput); } iCount ++; //i_shot_ctr[20] for (int i = 0; i < 20; i++) { strOutput.Format(_T("i_shot_ctr[%.2d] : %d\n"), i, pData->i_shot_ctr[i]); m_DataFile01.WriteString(strOutput); } iCount++; //istatflags[20] for (int i = 0; i < 20; i++) { strOutput.Format(_T("istatflags[%.2d] : %d\n"), i, pData->istatflags[i]); m_DataFile01.WriteString(strOutput); } iCount++; //i_gainSet1064[20] for (int i = 0; i < 20; i++) { strOutput.Format(_T("i_gainSet1064[%.2d] : %d\n"), i, pData->i_gainSet1064[i]); m_DataFile01.WriteString(strOutput); } iCount++; //i_4nsPeakVal[20] for (int i = 0; i < 20; i++) { strOutput.Format(_T("i_4nsPeakVal[%.2d] : %d\n"), i, pData->i_4nsPeakVal[i]); m_DataFile01.WriteString(strOutput); } iCount++; //i_8nsPeakVal[20] for (int i = 0; i < 20; i++) { strOutput.Format(_T("i_8nsPeakVal[%.2d] : %d\n"), i, pData->i_8nsPeakVal[i]); m_DataFile01.WriteString(strOutput); } iCount++; //i_4nsBgMead[20] for (int i = 0; i < 20; i++) { strOutput.Format(_T("i_4nsBgMead[%.2d] : %d\n"), i, (unsigned short)(pData->i_4nsBgMead[i])); m_DataFile01.WriteString(strOutput); } iCount++; //i_4nsBgSDEV[20] for (int i = 0; i < 20; i++) { strOutput.Format(_T("i_4nsBgSDEV[%.2d] : %d\n"), i, (unsigned short)(pData->i_4nsBgSDEV[i])); m_DataFile01.WriteString(strOutput); } iCount++; //i_samp_pad[40] for (int i = 0; i < 40; i++) { strOutput.Format(_T("i_samp_pad[%.2d] : %d\n"), i, pData->i_samp_pad[i]); m_DataFile01.WriteString(strOutput); } iCount++; //i_comp_type[20] for (int i = 0; i < 20; i++) { strOutput.Format(_T("i_comp_type[%.2d] : %d\n"), i, pData->i_comp_type[i]); m_DataFile01.WriteString(strOutput); } iCount ++; //i_rng_wf[200][20] for (int i = 0; i < 200; i++) { for (int j = 0; j < 20; j++) { strOutput.Format(_T("i_rng_wf[%.3d][%.2d] : %d\n"), i, j, pData->i_rng_wf[i][j]); m_DataFile14.WriteString(strOutput); } } iCount++; //i_gainStatus[20] for (int i = 0; i < 20; i++) { strOutput.Format(_T("i_gainStatus[%.2d] : %d\n"), i, pData->i_gainStatus[i]); m_DataFile01.WriteString(strOutput); } iCount ++; //i_NumCoinc[20] for (int i = 0; i < 20; i++) { strOutput.Format(_T("i_NumCoinc[%.2d] : %d\n"), i, pData->i_NumCoinc[i]); m_DataFile01.WriteString(strOutput); } iCount ++; //i_rawPkHt[20] for (int i = 0; i < 20; i++) { strOutput.Format(_T("i_rawPkHt[%.2d] : %d\n"), i, pData->i_rawPkHt[i]); m_DataFile01.WriteString(strOutput); } iCount ++; //i_spare2[184] for (int i = 0; i < 184; i++) { strOutput.Format(_T("i_spare2[%.2d] : %d\n"), i, pData->i_spare2[i]); m_DataFile01.WriteString(strOutput); } iCount ++; m_DataFile01.WriteString("\n------------------------------------------------------------\n\n"); ASSERT(iCount == 19); }
[ "kiddove@gmail.com" ]
kiddove@gmail.com
761f4f002118af4b4c68a8810add2a7cfdb4ad0f
6532dff708315cc1ae1575ee2d48af71598dc12a
/Project_1/KnowledgeBase.cpp
86beeb0916d6aabf6d340cbf71ee6692ca00202b
[]
no_license
vaibhav345/Intelligent-Systems
a07d369bd76382954387a186b8f9939cba9a07a5
112dc005c53b97b868639cfec4a96d15f672189f
refs/heads/master
2020-12-02T06:18:22.443745
2017-07-17T14:31:19
2017-07-17T14:31:19
96,812,682
0
0
null
null
null
null
UTF-8
C++
false
false
3,757
cpp
// Author: Terry Penner // Date Created: Sept. 1, 2014 // File name: KnowledgeBase.cpp // Purpose: To parse the given knowledge base file // Usage: See Project1-A04367972.cpp #include "KnowledgeBase.h" // Function Prototypes // **************************************************************************** string readVariables(fstream &knowledgeBase, variable_type &variableMap); string readRules(fstream &knowledgeBase, clause_type &clauseVariableList, conclusion_type &conclusionList); // Main functions // **************************************************************************** void readKnowledgeBase(const string &knowledgeBaseFile, conclusion_type &conclusionList, variable_type &variableMap, clause_type &clauseVariableList) { fstream knowledgeBase; knowledgeBase.open(knowledgeBaseFile.c_str()); if (knowledgeBase.is_open()) { string line; getline(knowledgeBase, line); if (line.find(IGNORE_FILE_LINE) != string::npos) { line = readVariables(knowledgeBase, variableMap); } if (line.find(IGNORE_FILE_LINE) != string::npos) { line = readRules(knowledgeBase, clauseVariableList, conclusionList); } } knowledgeBase.close(); } string readVariables(fstream &knowledgeBase, variable_type &variableMap) { string line; while (getline(knowledgeBase, line) && line.find(IGNORE_FILE_LINE) == string::npos) { vector<string> components = split(line, ';'); if (components.size() == 3) { trim(components); variableInfo info; info.isInitialized = false; info.acceptedValues = split(components[1], ','); trim(info.acceptedValues); info.prompt = components[2]; variableMap[components[0]] = info; } } return line; } string readRules(fstream &knowledgeBase, clause_type &clauseVariableList, conclusion_type &conclusionList) { string line; conclusion_type clause; while (getline(knowledgeBase, line) && line.find(IGNORE_FILE_LINE) == string::npos) { vector<string> components = split(line, '='); trim(components); if (components.size() == 2 && components[0][0] == '-') { clauseVariableList.push_back(clause); clause.clear(); pair<string, string> conclusionPair(components[0].substr(1), components[1]); conclusionList.push_back(conclusionPair); } else if (components.size() == 2) { pair<string, string> clausePair(components[0], components[1]); clause.push_back(clausePair); } } return line; } // Support functions // **************************************************************************** void trimRight(string &text, const string &whiteSpace) { int lastPosition = text.find_last_not_of(whiteSpace); text.erase(lastPosition + 1); } void trimLeft(string &text, const string &whiteSpace) { int firstPosition = text.find_first_not_of(whiteSpace); text.erase(0, firstPosition); } void trim(string &text) { const string whiteSpace(" \f\n\r\t\v"); trimRight(text, whiteSpace); trimLeft(text, whiteSpace); } void trim(vector<string> &textList) { for (vector<string>::iterator text = textList.begin(); text != textList.end(); text++) { trim(*text); } } vector<string> &split(const string &text, char deliminator, vector<string> &subSections) { stringstream textStream(text); string item; while (getline(textStream, item, deliminator)) { subSections.push_back(item); } return subSections; } vector<string> split(const string &text, char deliminator) { vector<string> subSections; split(text, deliminator, subSections); return subSections; } bool equalsIgnoreCase(const string &string1, const string &string2) { if (string1.size() != string2.size()) { return false; } for (unsigned int x = 0; x < string1.size(); x++) { if (tolower(string1[x]) != tolower(string2[x])) { return false; } } return true; }
[ "vaibhav.mahant@gmail.com" ]
vaibhav.mahant@gmail.com
dcbf297392ea4c2e788747789b54c5ad1bb62490
dc182283f6eed3b5aaa45c7da61bdc07b41ee161
/chrome/browser/ui/startup/web_app_protocol_handling_startup_utils.cc
2d3a2102d1fb391fcc00cd7ffdd5207ab6290e9e
[ "BSD-3-Clause" ]
permissive
KHJcode/chromium
c2bf1c71363e81aaa9e14de582cd139e46877e0a
61f837c7b6768f2e74501dd614624f44e396f363
refs/heads/master
2023-06-19T07:25:15.090544
2021-07-08T12:38:31
2021-07-08T12:38:31
299,554,207
1
0
BSD-3-Clause
2020-09-29T08:33:13
2020-09-29T08:33:12
null
UTF-8
C++
false
false
8,910
cc
// Copyright 2021 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "chrome/browser/ui/startup/web_app_protocol_handling_startup_utils.h" #include <memory> #include <utility> #include <vector> #include "base/bind.h" #include "base/callback.h" #include "base/check.h" #include "base/command_line.h" #include "base/containers/contains.h" #include "base/files/file_path.h" #include "base/location.h" #include "base/strings/string_util.h" #include "build/build_config.h" #include "chrome/browser/apps/app_service/app_service_proxy.h" #include "chrome/browser/apps/app_service/app_service_proxy_factory.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile_keep_alive_types.h" #include "chrome/browser/profiles/scoped_profile_keep_alive.h" #include "chrome/browser/ui/browser_dialogs.h" #include "chrome/browser/ui/startup/startup_browser_creator.h" #include "chrome/browser/web_applications/components/app_registrar.h" #include "chrome/browser/web_applications/components/app_registry_controller.h" #include "chrome/browser/web_applications/components/os_integration_manager.h" #include "chrome/browser/web_applications/components/web_app_id.h" #include "chrome/browser/web_applications/web_app.h" #include "chrome/browser/web_applications/web_app_provider.h" #include "chrome/browser/web_applications/web_app_registrar.h" #include "chrome/browser/web_applications/web_app_registry_update.h" #include "chrome/common/chrome_switches.h" #include "components/keep_alive_registry/keep_alive_types.h" #include "components/keep_alive_registry/scoped_keep_alive.h" #include "third_party/blink/public/common/custom_handlers/protocol_handler_utils.h" #include "url/gurl.h" namespace { // Tries to launch the web app when the `provider` is ready. `startup_callback` // will run if there is no web app registered for `profile` that can handle // `protocol_url`. If os_integration_manager finds a web app, then check if the // web app has approval from the user to handle `protocol_url`. If the web app // didn't have approval from a previous launch, show the permission dialog to // ask for approval. The permission dialog will then launch the web app if the // user accepts the dialog or close the dialog window if the user cancels it. // If the web app did get permission in the past, the browser will directly // launch the web app with the translated url. The passed in `keep_alive` and // `profile_keep_alives` ensure the profiles and the browser are alive while // `provider` is waiting for the signal for "on_registry_ready()". void OnWebAppSystemReadyMaybeLaunchProtocolHandler( web_app::WebAppProvider* provider, const GURL& protocol_url, const web_app::AppId& app_id, const base::CommandLine& command_line, const base::FilePath& cur_dir, Profile* profile, Profile* last_used_profile, const std::vector<Profile*>& last_opened_profiles, std::unique_ptr<ScopedKeepAlive> keep_alive, const std::vector<std::unique_ptr<ScopedProfileKeepAlive>> profile_keep_alives, web_app::startup::FinalizeWebAppLaunchCallback finalize_callback, web_app::startup::StartupLaunchAfterProtocolCallback startup_callback) { web_app::OsIntegrationManager& os_integration_manager = provider->os_integration_manager(); const std::vector<ProtocolHandler> handlers = os_integration_manager.GetHandlersForProtocol(protocol_url.scheme()); if (!base::Contains(handlers, true, [](const auto& handler) { return handler.web_app_id().has_value(); })) { std::move(startup_callback) .Run(command_line, cur_dir, profile, last_used_profile, last_opened_profiles); return; } auto launch_callback = base::BindOnce( [](const base::CommandLine& command_line, const base::FilePath& cur_dir, Profile* profile, const GURL& protocol_url, const web_app::AppId& app_id, web_app::startup::FinalizeWebAppLaunchCallback callback, bool accepted) { if (accepted) { web_app::WebAppProviderBase* provider = web_app::WebAppProviderBase::GetProviderBase(profile); { web_app::ScopedRegistryUpdate update( provider->registry_controller().AsWebAppSyncBridge()); web_app::WebApp* app_to_update = update->UpdateApp(app_id); std::vector<std::string> protocol_handlers( app_to_update->approved_launch_protocols()); protocol_handlers.push_back(protocol_url.scheme()); app_to_update->SetApprovedLaunchProtocols( std::move(protocol_handlers)); } apps::AppServiceProxyFactory::GetForProfile(profile) ->BrowserAppLauncher() ->LaunchAppWithCallback(app_id, command_line, cur_dir, /*url_handler_launch_url=*/absl::nullopt, protocol_url, std::move(callback)); } // else allow the process to exit without opening a browser. }, command_line, cur_dir, profile, protocol_url, app_id, std::move(finalize_callback)); // Check if we have permission to launch the app directly. web_app::AppRegistrar& registrar = provider->registrar(); if (registrar.IsApprovedLaunchProtocol(app_id, protocol_url.scheme())) { std::move(launch_callback).Run(true); } else { // ShowWebAppProtocolHandlerIntentPicker keeps the `profile` alive through // running of `launch_callback`. chrome::ShowWebAppProtocolHandlerIntentPicker(protocol_url, profile, app_id, std::move(launch_callback)); } } } // namespace namespace web_app { namespace startup { bool MaybeLaunchProtocolHandlerWebApp( const base::CommandLine& command_line, const base::FilePath& cur_dir, Profile* profile, Profile* last_used_profile, const std::vector<Profile*>& last_opened_profiles, FinalizeWebAppLaunchCallback finalize_callback, StartupLaunchAfterProtocolCallback startup_callback) { std::string app_id = command_line.GetSwitchValueASCII(switches::kAppId); // There must be a kAppId switch arg in the command line to launch. if (app_id.empty()) return false; GURL protocol_url; base::CommandLine::StringVector args = command_line.GetArgs(); for (const auto& arg : args) { #if defined(OS_WIN) GURL potential_protocol(base::AsStringPiece16(arg)); #else GURL potential_protocol(arg); #endif // defined(OS_WIN) // protocol_url is checked for validity later with getting the provider and // consulting the os_integration_manager. However because that process has a // wait for "on_registry_ready()", `potential_protocol` checks for // blink::IsValidCustomHandlerScheme() here to avoid loading the // web_app::WebAppProvider with a false positive. bool unused_has_custom_scheme_prefix = false; if (potential_protocol.is_valid() && blink::IsValidCustomHandlerScheme(potential_protocol.scheme(), /*allow_ext_prefix=*/false, unused_has_custom_scheme_prefix)) { protocol_url = std::move(potential_protocol); break; } } if (protocol_url.is_empty()) return false; auto* provider = web_app::WebAppProvider::Get(profile); DCHECK(provider); // Create the keep_alives so the profiles and the browser stays alive as we // wait for the provider() to be ready. auto keep_alive = std::make_unique<ScopedKeepAlive>( KeepAliveOrigin::WEB_APP_PROTOCOL_HANDLER_LAUNCH, KeepAliveRestartOption::DISABLED); std::vector<std::unique_ptr<ScopedProfileKeepAlive>> profile_keep_alives; profile_keep_alives.push_back(std::make_unique<ScopedProfileKeepAlive>( profile, ProfileKeepAliveOrigin::kWebAppProtocolHandlerLaunch)); profile_keep_alives.push_back(std::make_unique<ScopedProfileKeepAlive>( last_used_profile, ProfileKeepAliveOrigin::kWebAppProtocolHandlerLaunch)); for (Profile* last_opened_profile : last_opened_profiles) { profile_keep_alives.push_back(std::make_unique<ScopedProfileKeepAlive>( last_opened_profile, ProfileKeepAliveOrigin::kWebAppProtocolHandlerLaunch)); } provider->on_registry_ready().Post( FROM_HERE, base::BindOnce(OnWebAppSystemReadyMaybeLaunchProtocolHandler, provider, std::move(protocol_url), std::move(app_id), command_line, cur_dir, profile, last_used_profile, last_opened_profiles, std::move(keep_alive), std::move(profile_keep_alives), std::move(finalize_callback), std::move(startup_callback))); return true; } } // namespace startup } // namespace web_app
[ "chromium-scoped@luci-project-accounts.iam.gserviceaccount.com" ]
chromium-scoped@luci-project-accounts.iam.gserviceaccount.com
3bb90a288a0aee4744ed0f56d2ed42e0823033ad
4b3af7f322f3a1ac04b36a1c109795eaf740b895
/leetcode/container_water.cc
29cefcc7f9976ca0be635422a5269b7bd96cfb63
[]
no_license
jnjcc/misc-codes
cad803f32b4164d052fded1591e6cd05238a7509
e0395d78095714c8b53232b6e8bf024e0f446c9b
refs/heads/master
2020-04-01T22:58:31.048077
2015-04-08T12:42:17
2015-04-08T12:42:17
20,638,318
0
0
null
null
null
null
UTF-8
C++
false
false
371
cc
#include "leetcode.h" int MaxArea(const vector<int> &height) { int n = height.size(); int l = 0, r = n - 1; int max_area = -1; while (l < r) { int cur_area = min(height[l], height[r]) * (r - l); if (cur_area > max_area) { max_area = cur_area; } if (height[l] < height[r]) { ++l; } else { --r; } } return max_area; }
[ "jnjcc@live.com" ]
jnjcc@live.com
22cbb1b056d4a15f09a6b57d90429d7c4a3a37e1
9d0c1da53da9e60d4a891d7edb7a02c31c8d26b9
/kaddressbook/addresseeeditorextension.cpp
8e53257c75e5d66b099e5c8a86070d7822a6147d
[]
no_license
serghei/kde3-kdepim
7e6d4a0188c35a2c9c17babd317bfe3c0f1377d2
a1980f1560de118f19f54a5eff5bae87a6aa4784
refs/heads/master
2021-01-17T10:03:14.624954
2018-11-04T21:31:00
2018-11-04T21:31:00
3,688,187
0
0
null
null
null
null
UTF-8
C++
false
false
2,342
cpp
/* This file is part of KAddressBook. Copyright (c) 2005 Tobias Koenig <tokoe@kde.org> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. As a special exception, permission is given to link this program with any edition of Qt, and distribute the resulting executable, without including the source code for Qt in the source distribution. */ #include <qlayout.h> #include <klocale.h> #include "kabprefs.h" #include "addresseeeditorwidget.h" #include "simpleaddresseeeditor.h" #include "addresseeeditorextension.h" AddresseeEditorExtension::AddresseeEditorExtension(KAB::Core *core, QWidget *parent, const char *name) : KAB::ExtensionWidget(core, parent, name) { QVBoxLayout *layout = new QVBoxLayout(this); if(KABPrefs::instance()->editorType() == KABPrefs::SimpleEditor) mAddresseeEditor = new SimpleAddresseeEditor(this); else mAddresseeEditor = new AddresseeEditorWidget(this); layout->addWidget(mAddresseeEditor); } AddresseeEditorExtension::~AddresseeEditorExtension() { } void AddresseeEditorExtension::contactsSelectionChanged() { const KABC::Addressee::List selectedAddressees = selectedContacts(); KABC::Addressee::List addressees; if(mAddresseeEditor->dirty()) { mAddresseeEditor->save(); addressees.append(mAddresseeEditor->addressee()); emit modified(addressees); } mAddresseeEditor->setAddressee(selectedAddressees[ 0 ]); } QString AddresseeEditorExtension::title() const { return i18n("Contact Editor"); } QString AddresseeEditorExtension::identifier() const { return "contact_editor"; } #include "addresseeeditorextension.moc"
[ "serghei.amelian@gmail.com" ]
serghei.amelian@gmail.com
5ed7ca868699a9fb81ede17823ba2c7c7aac7808
823b001df1b6f9451d1d27d9fa82b12f4402113c
/OZMTool/ffsutil.h
01e057bfacbbcf5ddf1c13feb0fe0abae58f8589
[ "BSD-2-Clause" ]
permissive
tmaone/UEFITool
66e0aa3ea366c08bc37ad3ddd1057c19fe3c6421
941c13663a123ea162ba74d0991db4764779cf7e
refs/heads/OZM
2021-04-16T03:55:29.049110
2016-02-19T13:18:02
2016-02-19T13:18:02
249,325,961
0
0
BSD-2-Clause
2020-03-23T03:23:09
2020-03-23T03:21:38
null
UTF-8
C++
false
false
2,104
h
/* ffsutil.h Copyright (c) 2014, tuxuser. All rights reserved. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. */ #ifndef FFSUTIL_H #define FFSUTIL_H #include "../basetypes.h" #include "../ffs.h" #include "../ffsengine.h" class FFSUtil { public: FFSUtil(); ~FFSUtil(); UINT8 insert(QModelIndex & index, QByteArray & object, UINT8 mode); UINT8 replace(QModelIndex & index, QByteArray & object, UINT8 mode); UINT8 extract(QModelIndex & index, QByteArray & extracted, UINT8 mode); UINT8 compress(QByteArray & data, UINT8 algorithm, QByteArray & compressedData); UINT8 decompress(QByteArray & compressed, UINT8 compressionType, QByteArray & decompressedData, UINT8 *algorithm); UINT8 remove(QModelIndex & index); UINT8 reconstructImageFile(QByteArray & out); UINT8 getRootIndex(QModelIndex & result); UINT8 findFileByGUID(const QModelIndex index, const QString guid, QModelIndex & result); UINT8 findSectionByIndex(const QModelIndex index, UINT8 type, QModelIndex & result); UINT8 dumpFileByGUID(QString guid, QByteArray & buf, UINT8 mode); UINT8 dumpSectionByGUID(QString guid, UINT8 type, QByteArray & buf, UINT8 mode); UINT8 getNameByGUID(QString guid, QString & name); UINT8 getLastVolumeIndex(QModelIndex & result); UINT8 getAmiBoardPE32Index(QModelIndex & result); UINT8 getLastSibling(QModelIndex index, QModelIndex &result); UINT8 injectDSDT(QByteArray dsdt); UINT8 injectFile(QByteArray file); UINT8 deleteFilesystemFfs(); UINT8 compressDXE(); UINT8 compressFFS(QByteArray ffs, QByteArray & out); UINT8 runFreeSomeSpace(int aggressivity); UINT8 parseBIOSFile(QByteArray & buf); private: FfsEngine* ffsEngine; }; #endif // FFSUTIL_H
[ "tuxuser360@gmail.com" ]
tuxuser360@gmail.com
66c31f71f94bb86f64aaac013410ca21c4439b76
b2d162fa858e58e28a1c753b191d7b8295c505b2
/Utilities/SimpleImageProcessing/IntensityWindowFilter.cxx
13ad7c6cabd93d3b79de1fc42e2cb4d982e13af8
[]
no_license
XiaoxiaoLiu/SCDS
8c1f64a66dc6daa1458ffc67ba71323183c2397a
594496aff64f5b2f54723e55ab34ba03263f1ef3
refs/heads/master
2016-09-06T09:26:05.561116
2013-06-25T15:26:34
2013-06-25T15:26:34
2,816,144
1
1
null
null
null
null
UTF-8
C++
false
false
1,974
cxx
#include <iostream> #include "itkImageFileReader.h" #include "itkImageFileWriter.h" #include "itkIntensityWindowingImageFilter.h" int main( int argc, char *argv[] ) { if (argc < 6 ) { std::cerr << "Missing Parameters " << std::endl; std::cerr << "Usage: " << argv[0]; std::cerr << " inputImageFileName outputImageFileName input_lowerbound input_upperbound output_lowerbound output_upperbound"<<std::endl; return 1; } const unsigned int Dimension = 3; typedef float PixelType; typedef itk::Image<float, Dimension > InImageType; typedef itk::Image<PixelType,Dimension> OutImageType; typedef itk::ImageFileReader<InImageType> ReaderType; ReaderType::Pointer reader = ReaderType::New(); reader->SetFileName(argv[1]); try { reader->Update(); // reader->GetOutput()->Print(std::cout); } catch (itk::ExceptionObject &ex) { std::cout << ex; return EXIT_FAILURE; } typedef itk::IntensityWindowingImageFilter< InImageType,OutImageType > IntensityWindowingImageFilterType; IntensityWindowingImageFilterType::Pointer windowing = IntensityWindowingImageFilterType::New(); InImageType::PixelType input_lowerBound = atoi(argv[3]); InImageType::PixelType input_upperBound = atoi(argv[4]); OutImageType::PixelType output_lowerBound = atoi(argv[5]); OutImageType::PixelType output_upperBound = atoi(argv[6]); windowing->SetInput(reader->GetOutput()); windowing->SetWindowMinimum(input_lowerBound); windowing->SetWindowMaximum(input_upperBound); windowing->SetOutputMinimum(output_lowerBound); windowing->SetOutputMaximum(output_upperBound); windowing->Update(); typedef itk::ImageFileWriter<OutImageType> imageFileWriterType; imageFileWriterType:: Pointer imageWriter = imageFileWriterType::New(); imageWriter->SetFileName(argv[2]); imageWriter->SetInput(windowing->GetOutput()); try { imageWriter->Update(); } catch (itk::ExceptionObject &e) { std::cerr << e << std::endl; } return 0; }
[ "xiaoxiao.liu@kitware.com" ]
xiaoxiao.liu@kitware.com
259b186613af636dccd058b3249c04d6c8e676f0
adefd0d7f3c7e719e8280d52a685513e58e1fdd7
/Main.cpp
bfbfd74af0eeaa33c652cc717e7fd868b33c8a13
[]
no_license
vaibhav07-creator/Banking-System
582a4a8810194ca336c6dce5aece30bca71fa22d
c33367bdd9cb476ae0854dcc92eb4c3cfd2e6614
refs/heads/master
2023-07-09T15:35:32.713923
2021-08-08T17:46:26
2021-08-08T17:46:26
394,030,983
0
0
null
null
null
null
UTF-8
C++
false
false
8,648
cpp
#include <iostream> #include <fstream> #include <cstdlib> #include <vector> #include <map> #include <string> using namespace std; #define MIN_BALANCE 500 class InsufficientFunds { }; class Account { private: long accountNumber; string firstName; string lastName; float balance; static long NextAccountNumber; public: Account() {} Account(string fname, string lname, float balance); long getAccNo() { return accountNumber; } string getFirstName() { return firstName; } string getLastName() { return lastName; } float getBalance() { return balance; } void Deposit(float amount); void Withdraw(float amount); static void setLastAccountNumber(long accountNumber); static long getLastAccountNumber(); friend ofstream &operator<<(ofstream &ofs, Account &acc); friend ifstream &operator>>(ifstream &ifs, Account &acc); friend ostream &operator<<(ostream &os, Account &acc); }; long Account::NextAccountNumber = 0; class Bank { private: map<long, Account> accounts; public: Bank(); Account OpenAccount(string fname, string lname, float balance); Account BalanceEnquiry(long accountNumber); Account Deposit(long accountNumber, float amount); Account Withdraw(long accountNumber, float amount); void CloseAccount(long accountNumber); void ShowAllAccounts(); ~Bank(); }; int main() { Bank b; Account acc; int choice; string fname, lname; long accountNumber; float balance; float amount; cout << "***Banking System***" << endl; do { cout << "\n\tSelect one option below "; cout << "\n\t1 Open an Account"; cout << "\n\t2 Balance Enquiry"; cout << "\n\t3 Deposit"; cout << "\n\t4 Withdrawal"; cout << "\n\t5 Close an Account"; cout << "\n\t6 Show All Accounts"; cout << "\n\t7 Quit"; cout << "\nEnter your choice: "; cin >> choice; switch (choice) { case 1: cout << "Enter First Name: "; cin >> fname; cout << "Enter Last Name: "; cin >> lname; cout << "Enter initil Balance: "; cin >> balance; acc = b.OpenAccount(fname, lname, balance); cout << endl << "Congradulation Account is Created" << endl; cout << acc; break; case 2: cout << "Enter Account Number:"; cin >> accountNumber; acc = b.BalanceEnquiry(accountNumber); cout << endl << "Your Account Details" << endl; cout << acc; break; case 3: cout << "Enter Account Number:"; cin >> accountNumber; cout << "Enter Balance:"; cin >> amount; acc = b.Deposit(accountNumber, amount); cout << endl << "Amount is Deposited" << endl; cout << acc; break; case 4: cout << "Enter Account Number:"; cin >> accountNumber; cout << "Enter Balance:"; cin >> amount; acc = b.Withdraw(accountNumber, amount); cout << endl << "Amount Withdrawn" << endl; cout << acc; break; case 5: cout << "Enter Account Number:"; cin >> accountNumber; b.CloseAccount(accountNumber); cout << endl << "Account is Closed" << endl; cout << acc; case 6: b.ShowAllAccounts(); break; case 7: break; default: cout << "\nEnter corret choice"; exit(0); } } while (choice != 7); return 0; } Account::Account(string fname, string lname, float balance) { NextAccountNumber++; accountNumber = NextAccountNumber; firstName = fname; lastName = lname; this->balance = balance; } void Account::Deposit(float amount) { balance += amount; } void Account::Withdraw(float amount) { if (balance - amount < MIN_BALANCE) throw InsufficientFunds(); balance -= amount; } void Account::setLastAccountNumber(long accountNumber) { NextAccountNumber = accountNumber; } long Account::getLastAccountNumber() { return NextAccountNumber; } ofstream &operator<<(ofstream &ofs, Account &acc) { ofs << acc.accountNumber << endl; ofs << acc.firstName << endl; ofs << acc.lastName << endl; ofs << acc.balance << endl; return ofs; } ifstream &operator>>(ifstream &ifs, Account &acc) { ifs >> acc.accountNumber; ifs >> acc.firstName; ifs >> acc.lastName; ifs >> acc.balance; return ifs; } ostream &operator<<(ostream &os, Account &acc) { os << "First Name:" << acc.getFirstName() << endl; os << "Last Name:" << acc.getLastName() << endl; os << "Account Number:" << acc.getAccNo() << endl; os << "Balance:" << acc.getBalance() << endl; return os; } Bank::Bank() { Account account; ifstream infile; infile.open("Bank.data"); if (!infile) { //cout<<"Error in Opening! File Not Found!!"<<endl; return; } while(!infile.eof()) { infile>>account; accounts.insert(pair<long,Account>(account.getAccNo(),account)); } Account::setLastAccountNumber(account.getAccNo()); infile.close(); } Account Bank::OpenAccount(string fname,string lname,float balance) { ofstream outfile; Account account(fname,lname,balance); accounts.insert(pair<long,Account>(account.getAccNo(),account)); outfile.open("Bank.data", ios::trunc); map<long,Account>::iterator itr; for(itr=accounts.begin();itr!=accounts.end();itr++) { outfile<<itr->second; } outfile.close(); return account; } Account Bank::BalanceEnquiry(long accountNumber) { map<long,Account>::iterator itr=accounts.find(accountNumber); return itr->second; } Account Bank::Deposit(long accountNumber,float amount) { map<long,Account>::iterator itr=accounts.find(accountNumber); itr->second.Deposit(amount); return itr->second; } Account Bank::Withdraw(long accountNumber,float amount) { map<long,Account>::iterator itr=accounts.find(accountNumber); itr->second.Withdraw(amount); return itr->second; } void Bank::CloseAccount(long accountNumber) { map<long,Account>::iterator itr=accounts.find(accountNumber); cout<<"Account Deleted"<<itr->second; accounts.erase(accountNumber); } void Bank::ShowAllAccounts() { map<long,Account>::iterator itr; for(itr=accounts.begin();itr!=accounts.end();itr++) { cout<<"Account "<<itr->first<<endl<<itr->second<<endl; } } Bank::~Bank() { ofstream outfile; outfile.open("Bank.text", ios::trunc); map<long, Account>::iterator itr; for (itr = accounts.begin(); itr != accounts.end(); itr++) { outfile << itr->second; } outfile.close(); } } Account Bank::OpenAccount(string fname, string lname, float balance) { ofstream outfile; Account account(fname, lname, balance); accounts.insert(pair<long, Account>(account.getAccNo(), account)); outfile.open("Bank.text", ios::trunc); map<long, Account>::iterator itr; for (itr = accounts.begin(); itr != accounts.end(); itr++) { outfile << itr->second; } outfile.close(); return account; } Account Bank::BalanceEnquiry(long accountNumber) { map<long, Account>::iterator itr = accounts.find(accountNumber); return itr->second; } Account Bank::Deposit(long accountNumber, float amount) { map<long, Account>::iterator itr = accounts.find(accountNumber); itr->second.Deposit(amount); return itr->second; } Account Bank::Withdraw(long accountNumber, float amount) { map<long, Account>::iterator itr = accounts.find(accountNumber); itr->second.Withdraw(amount); return itr->second; } void Bank::CloseAccount(long accountNumber) { map<long, Account>::iterator itr = accounts.find(accountNumber); cout << "Account Deleted" << itr->second; accounts.erase(accountNumber); } void Bank::ShowAllAccounts() { map<long, Account>::iterator itr; for (itr = accounts.begin(); itr != accounts.end(); itr++) { cout << "Account " << itr->first << endl << itr->second << endl; } } Bank::~Bank() { ofstream outfile; outfile.open("Bank.data", ios::trunc); map<long, Account>::iterator itr; for (itr = accounts.begin(); itr != accounts.end(); itr++) { outfile << itr->second; } outfile.close(); }
[ "vaibhavrocker2000@gmail.com" ]
vaibhavrocker2000@gmail.com
df7ac43c6e02e062af6062dee89307f1f3c2ad19
9244d9e0932f7703ff69db8ddde23f5e851448de
/C++/Uri_1070.cpp
ad7d83be4212e440bba924b06bccef3e0cf977ac
[]
no_license
waldirmarques/QuestoesUri
a21bba06a82a749f271d01eb55671de88da45709
1052aa7a3358c0539fd1bfb9b8107b8e5810208a
refs/heads/master
2020-04-25T23:06:24.711600
2020-02-15T21:09:13
2020-02-15T21:09:13
173,133,769
0
0
null
null
null
null
UTF-8
C++
false
false
286
cpp
#include <iostream> #define CONDICAO 6 int main() { int entrada; int cont = 0; std::cin >> entrada; while(cont < CONDICAO){ if (entrada % 2 != 0) { std::cout << entrada << std::endl; cont++; } entrada++; } }
[ "waldir.marques@dcx.ufpb.br" ]
waldir.marques@dcx.ufpb.br
0efe7e5a677c9ee94d9627648f5e9325a3e6ebbc
7f3e95e825b894a8d015b5905592757a0040220f
/2015/utils/Atil/Inc/Size.inl
01c6aa7002ce6b7f58ecac24684440a54dc0464f
[ "MIT" ]
permissive
AliClouds/ObjectARXCore
b06e2d4bb59df2b45e56ec76d3abb843c7131009
ce09e150aa7d87675ca15c9416497c0487e3d4d4
refs/heads/master
2021-05-28T05:19:12.593781
2014-05-08T01:23:33
2014-05-08T01:23:33
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,043
inl
////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// // // Copyright 2014 Autodesk, Inc. All rights reserved. // // Use of this software is subject to the terms of the Autodesk license // agreement provided at the time of installation or download, or which // otherwise accompanies this software in either electronic or hard copy form. // ////////////////////////////////////////////////////////////////////////////// #ifndef SIZE_INL #define SIZE_INL // The following are methods of the Size class that have been inlined // for performance reasons and locality. #if __GNUC__ >= 4 #pragma GCC visibility push(default) #endif namespace Atil { /// <summary> /// This method is the inlined implementation of a method in <c>Size</c> <see cref="Size"/>. /// </summary> /// inline Size::Size (Int32 nWidth, Int32 nHeight) : width(nWidth), height(nHeight) { } /// <summary> /// This method is the inlined implementation of a method in <c>Size</c> <see cref="Size"/>. /// </summary> /// inline Size::Size () : width(0), height(0) { } /// <summary> /// This method is the inlined implementation of a method in <c>Size</c> <see cref="Size"/>. /// </summary> /// inline Size::Size (const Size& rhs) : width(rhs.width), height(rhs.height) { } inline Size::~Size () { } /// <summary> /// This method is the inlined implementation of a method in <c>Size</c> <see cref="Size"/>. /// </summary> /// inline bool Size::operator <= (const Size& rhs) const { return width <= rhs.width && height <= rhs.height; } /// <summary> /// This method is the inlined implementation of a method in <c>Size</c> <see cref="Size"/>. /// </summary> /// inline bool Size::operator >= (const Size& rhs) const { return width >= rhs.width && height >= rhs.height; } /// <summary> /// This method is the inlined implementation of a method in <c>Size</c> <see cref="Size"/>. /// </summary> /// inline bool Size::operator == (const Size& rhs) const { return width == rhs.width && height == rhs.height; } /// <summary> /// This method is the inlined implementation of a method in <c>Size</c> <see cref="Size"/>. /// </summary> /// inline bool Size::operator != (const Size& rhs) const { return width != rhs.width || height != rhs.height; } /// <summary> /// This method is the inlined implementation of a method in <c>Size</c> <see cref="Size"/>. /// </summary> /// inline const Size& Size::operator = (const Size& rhs) { width = rhs.width; height = rhs.height; return *this; } /// <summary> /// This method is the inlined implementation of a method in <c>Size</c> <see cref="Size"/>. /// </summary> /// inline const Size& Size::set( Int32 nWidth, Int32 nHeight ) { width = nWidth; height = nHeight; return *this; } /// <summary> /// This method is the inlined implementation of a method in <c>Size</c> <see cref="Size"/>. /// </summary> /// inline const Size& Size::grow (Int32 nWidth, Int32 nHeight) { width += nWidth; height += nHeight; return *this; } /// <summary> /// This method is the inlined implementation of a method in <c>Size</c> <see cref="Size"/>. /// </summary> /// inline const Size& Size::grow (Int32 toEach) { width += toEach; height += toEach; return *this; } /// <summary> /// This method is the inlined implementation of a method in <c>Size</c> <see cref="Size"/>. /// </summary> /// inline const Size& Size::shrink (Int32 byWidth, Int32 byHeight) { width -= byWidth; height -= byHeight; return *this; } /// <summary> /// This method is the inlined implementation of a method in <c>Size</c> <see cref="Size"/>. /// </summary> /// inline const Size& Size::shrink (Int32 eachBy) { width -= eachBy; height -= eachBy; return *this; } } //end of namespace #if __GNUC__ >= 4 #pragma GCC visibility pop #endif #endif
[ "kevinzhwl@gmail.com" ]
kevinzhwl@gmail.com
d1a9dc15a2b3e1701d2b0ca97ce48c3457d4db11
0dfbd0b96651fd0d06fa8b6a0374758bdbaa9c4f
/bitwise_stuff.cpp
4fe467d19dfe0145ed7abb90977343206c4bda67
[]
no_license
rhaas80/rawtobr3
cca7e17417c1b459ef2c5d58175d83c2835834fd
2ea25fc5f4609b3062503b4d154bda6be7658e57
refs/heads/master
2021-10-11T19:33:50.874401
2017-10-16T16:34:14
2017-10-16T16:34:14
null
0
0
null
null
null
null
UTF-8
C++
false
false
632
cpp
#include "rawtobr3.h" bool is_all_zeroes(const void *src, size_t size) { const uint32_t* sp = (const uint32_t*)(src); for(int i = size >> 2; i >= 0; --i) { if (*sp++) return 0; } const uint8_t* sp2 = (uint8_t*)(sp); for(int i = size & 3; i >= 0; --i) { if(*sp2++) return 0; } return 1; } void bitwise_invert(const void* src, void* dst, size_t size) { uint32_t* sp = (uint32_t*)(src); uint32_t* dp = (uint32_t*)(dst); for(int i = size >> 2; i >= 0; --i) { *dp++ = ~*sp++; } uint8_t* sp2 = (uint8_t*)(sp); uint8_t* dp2 = (uint8_t*)(dp); for(int i = size & 3; i >= 0; --i) { *dp2++ = ~*sp2++; } }
[ "k1-801@mail.ru" ]
k1-801@mail.ru
a67d0c3f3f9f830085aa2138f1a569809fda4ad2
438caf29c7ef95a29bf29eaa13ce17eb582ee042
/lab4_1.cpp
5d3b3a521b47fdf3ba41da3a273fc7dbcf982d02
[]
no_license
capgemini-india/group1
77ef069faaf6c2709043f3d7c3ed5a1926badedb
017c811ccbcf2f95931d9d433f13b5e4cda53557
refs/heads/master
2020-03-25T20:25:31.949282
2018-08-10T10:07:11
2018-08-10T10:07:11
null
0
0
null
null
null
null
UTF-8
C++
false
false
656
cpp
#include<iostream> using namespace std; class Employee { long empcode; double salary; char *name; public:Employee(long empcode, double salary, char *str) { this->empcode = empcode; this->salary = salary; this->name = str; } long getEmpcode() { return empcode; } double getsalary() { return salary; } char * getName() { return name; } void displayDetails() { cout << "Employee Code : " << getEmpcode() << "\nSalary : " << getsalary() << "\nName : " << getName(); } ~Employee() { } }; int main() { Employee e(101, 20000, "Rashmi"); e.displayDetails(); return 0; }
[ "yashdeepsingh@hotmail.com" ]
yashdeepsingh@hotmail.com
5a9b59cd945a629a1148240ac8542010c88b5dd3
d52d5fdbcd848334c6b7799cad7b3dfd2f1f33e4
/third_party/folly/folly/executors/IOObjectCache.h
38e95d96b7f7d3bbea300721b0539be589302edc
[ "Apache-2.0" ]
permissive
zhiliaoniu/toolhub
4109c2a488b3679e291ae83cdac92b52c72bc592
39a3810ac67604e8fa621c69f7ca6df1b35576de
refs/heads/master
2022-12-10T23:17:26.541731
2020-07-18T03:33:48
2020-07-18T03:33:48
125,298,974
1
0
null
null
null
null
UTF-8
C++
false
false
2,386
h
/* * Copyright 2017-present Facebook, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #pragma once #include <folly/ThreadLocal.h> #include <folly/executors/GlobalExecutor.h> #include <folly/io/async/EventBase.h> namespace folly { /* * IOObjectCache manages objects of type T that are dependent on an EventBase * provided by the global IOExecutor. * * Provide a factory that creates T objects given an EventBase, and get() will * lazily create T objects based on an EventBase from the global IOExecutor. * These are stored thread locally - for a given pair of event base and calling * thread there will only be one T object created. * * The primary use case is for managing objects that need to do async IO on an * event base (e.g. thrift clients) that can be used outside the IO thread * without much hassle. For instance, you could use this to manage Thrift * clients that are only ever called from within other threads without the * calling thread needing to know anything about the IO threads that the clients * will do their work on. */ template <class T> class IOObjectCache { public: typedef std::function<std::shared_ptr<T>(folly::EventBase*)> TFactory; IOObjectCache() = default; explicit IOObjectCache(TFactory factory) : factory_(std::move(factory)) {} std::shared_ptr<T> get() { CHECK(factory_); auto eb = getIOExecutor()->getEventBase(); CHECK(eb); auto it = cache_->find(eb); if (it == cache_->end()) { auto p = cache_->insert(std::make_pair(eb, factory_(eb))); it = p.first; } return it->second; }; void setFactory(TFactory factory) { factory_ = std::move(factory); } private: folly::ThreadLocal<std::map<folly::EventBase*, std::shared_ptr<T>>> cache_; TFactory factory_; }; } // namespace folly
[ "yangshengzhi1@bigo.sg" ]
yangshengzhi1@bigo.sg
ab0a6d0820c484c2baf336d0b795180ff35fa287
fde6d95afba6e51ddd167cb21147987cb2d03017
/pe/tracker/src/tracker_dll/remote.cpp
7e100cb55bbb619a3f988a6f15819e9569f4e025
[ "Apache-2.0" ]
permissive
mfmans/in-nwu
558d679219223819df801c8ef1eb04bcdd30e208
a7765f4295815034f394b0d48ec92c66f63b4301
refs/heads/master
2016-09-03T07:21:33.136615
2015-02-17T08:07:24
2015-02-17T08:07:24
30,603,981
2
1
null
null
null
null
GB18030
C++
false
false
1,570
cpp
/* $ Tracker w64 (C) 2005-2014 MF $ tracker.dll/remote.cpp # 1312 */ #include "base.h" /* 在目标进程中分配内存空间 */ uintptr_t remote::allocate (HANDLE process, unsigned int size) { return (uintptr_t) VirtualAllocEx (process, NULL, (SIZE_T) size, MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE); } /* 从目标进程内存读取数据 */ bool remote::read (HANDLE process, uintptr_t address, void *buffer, unsigned int size) { // 读取的内存大小 unsigned int read; // 读取内存 if(ReadProcessMemory (process, (LPCVOID) address, (LPVOID) buffer, (SIZE_T) size, (SIZE_T *) & read) == FALSE) { return false; } // 判断是否完全读取 if(size != read) { return false; } return true; } /* 向目标进程内存写入数据 */ bool remote::write (HANDLE process, uintptr_t address, void *buffer, unsigned int size) { // 写入的内存大小 unsigned int written; // 写入到进程内存 if(WriteProcessMemory (process, (LPVOID) address, (LPCVOID) buffer, size, (SIZE_T *) & written) == FALSE) { return false; } // 判断是否完全写入 if(size != written) { return false; } return true; } /* 在目标进程中创建线程 */ HANDLE remote::thread (HANDLE process, uintptr_t address, uint32_t argument) { return CreateRemoteThread ( /* hProcess */ (HANDLE) process, /* lpThreadAttributes */ NULL, /* dwStackSize */ 0, /* lpStartAddress */ (LPTHREAD_START_ROUTINE) address, /* lpParameter */ (LPVOID) argument, /* dwCreationFlags */ 0, /* lpThreadId */ NULL ); }
[ "mfmans@gmail.com" ]
mfmans@gmail.com
1dafd105f4ecdc70c597fca0b7724e649c796140
ae47bfe3f057fffd2592982e7c14a072190515e2
/F4_FOC_Project/STM32F446RE_FOC/SystemLib/Inc/TIMInit.hpp
c324222412cba91230303fb4a49f532f6d5b4135
[]
no_license
marxw3179/PMSM_Control_source
4ecf4f12d0472e0a2f7a133393e03a14e39d925c
600ac632da8c312fba3acf5f3f33827a1b8cb894
refs/heads/master
2022-07-23T16:50:23.997717
2020-05-17T16:27:41
2020-05-17T16:27:41
281,535,794
1
0
null
2020-07-22T00:39:59
2020-07-22T00:39:59
null
UTF-8
C++
false
false
287
hpp
/* * TIMInit.hpp * * Created on: Jul 30, 2019 * Author: watashi */ #ifndef TIMINIT_HPP_ #define TIMINIT_HPP_ #include "STM32SystemPack.h" #include "paramsetting.h" class TIMInit { public: TIMInit(); virtual ~TIMInit(); static void Init(); }; #endif /* TIMINIT_HPP_ */
[ "anmituseries@yahoo.co.jp" ]
anmituseries@yahoo.co.jp
a4b38a38180315292fdfd5f67848fe9d92f69076
dd5356457879b9edf8c982a412e0068f94da697d
/SDK/RoCo_MasterShotgun_WeaponComponent_classes.hpp
698ee0b8cc97011bb263d47a1b6b09062ed53669
[]
no_license
ALEHACKsp/RoCo-SDK
5ee6567294674b6933dcd0acda720f64712ccdbf
3a9e37be3a48bc0a10aa9e4111865c996f3b5680
refs/heads/master
2023-05-14T16:54:49.296847
2021-06-08T20:09:37
2021-06-08T20:09:37
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,335
hpp
#pragma once // Rogue Company (0.60) SDK #ifdef _MSC_VER #pragma pack(push, 0x8) #endif #include "RoCo_MasterShotgun_WeaponComponent_structs.hpp" namespace SDK { //--------------------------------------------------------------------------- //Classes //--------------------------------------------------------------------------- // DynamicClass MasterShotgun_WeaponComponent.MasterShotgun_WeaponComponent_C // 0x0100 (0x1300 - 0x1200) class UMasterShotgun_WeaponComponent_C : public UMaster_WeaponComponent_C { public: unsigned char UnknownData00[0x8]; // 0x1200(0x0008) MISSED OFFSET int Temp_int_Array_Index_Variable; // 0x1208(0x0004) (CPF_ZeroConstructor, CPF_Transient, CPF_DuplicateTransient, CPF_IsPlainOldData, CPF_NoDestructor, CPF_HasGetValueTypeHash, CPF_NativeAccessSpecifierPublic) int Temp_int_Loop_Counter_Variable; // 0x120C(0x0004) (CPF_ZeroConstructor, CPF_Transient, CPF_DuplicateTransient, CPF_IsPlainOldData, CPF_NoDestructor, CPF_HasGetValueTypeHash, CPF_NativeAccessSpecifierPublic) class UKSWeaponAsset_Shotgun* K2Node_DynamicCast_AsKSWeapon_Asset_Shotgun; // 0x1210(0x0008) (CPF_ZeroConstructor, CPF_Transient, CPF_DuplicateTransient, CPF_IsPlainOldData, CPF_NoDestructor, CPF_HasGetValueTypeHash, CPF_NativeAccessSpecifierPublic) bool K2Node_DynamicCast_bSuccess; // 0x1218(0x0001) (CPF_ZeroConstructor, CPF_Transient, CPF_DuplicateTransient, CPF_IsPlainOldData, CPF_NoDestructor, CPF_HasGetValueTypeHash, CPF_NativeAccessSpecifierPublic) unsigned char UnknownData01[0x7]; // 0x1219(0x0007) MISSED OFFSET struct FFullFireRepData K2Node_Event_Fire_Data; // 0x1220(0x0068) (CPF_Transient, CPF_DuplicateTransient, CPF_NativeAccessSpecifierPublic) struct FAimData CallFunc_GenerateShotgunSpreadAimDataV2_OutAim; // 0x1288(0x0050) (CPF_Transient, CPF_DuplicateTransient, CPF_NativeAccessSpecifierPublic) TArray<class AActor*> Temp_object_Variable; // 0x12D8(0x0010) (CPF_ZeroConstructor, CPF_Transient, CPF_DuplicateTransient, CPF_HasGetValueTypeHash, CPF_NativeAccessSpecifierPublic) struct FVector CallFunc_Array_Get_Item; // 0x12E8(0x000C) (CPF_ZeroConstructor, CPF_Transient, CPF_DuplicateTransient, CPF_IsPlainOldData, CPF_NoDestructor, CPF_HasGetValueTypeHash, CPF_NativeAccessSpecifierPublic) unsigned char UnknownData02[0xC]; // 0x12F4(0x000C) MISSED OFFSET static UClass* StaticClass() { static auto ptr = UObject::FindObject<UClass>("DynamicClass MasterShotgun_WeaponComponent.MasterShotgun_WeaponComponent_C"); return ptr; } void ExecuteUbergraph_MasterShotgun_WeaponComponent_1(int bpp__EntryPoint__pf); }; } #ifdef _MSC_VER #pragma pack(pop) #endif
[ "30532128+pubgsdk@users.noreply.github.com" ]
30532128+pubgsdk@users.noreply.github.com
8bbd2037ccf94d21e5eb96c88427ab77e500744b
08fae5bd7f16809b84cf6463693732f2308ab4da
/ETS/DataProvider/DataProvider/Database.h
0a4fad724db855fce616f3f9663787e2810e64c7
[]
no_license
psallandre/IVRM
a7738c31534e1bbff32ded5cfc7330c52b378f19
5a674d10caba23b126e9bcea982dee30eee72ee1
refs/heads/master
2021-01-21T03:22:33.658311
2014-09-24T11:47:10
2014-09-24T11:47:10
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,956
h
#pragma once class CDatabaseImpl { public: typedef CDatabaseImpl* pointer; CDatabaseImpl(): m_ConnectionString(""){ }; long getContractType(long contractId){ try { if (Initialize()) { CStoredProc<CClientRecordset> rs(m_DbConnection, L"usp_ContractType_Get"); /*Set procedure params*/ rs << contractId; /*execute query*/ rs.Open(); if(rs.GetRecordCount()) { rs.MoveFirst(); while(!rs.IsEOF()) { long ContractType = (long)rs[L"iContractType"]; rs.Close(); return ContractType; } }; } } catch (_com_error& err) { LOG4CPLUS_ERROR(ProviderLog, _T("ComError: getContractType(long) ")<<(char*)(err.Description())); ATLASSERT(FALSE); } catch (...) { LOG4CPLUS_ERROR(ProviderLog, _T("Unknown error occured while getContractType(long)")); ATLASSERT(FALSE); }; return -1; }; long getContractType(std::string symbol, bool reload = false){ try{ if (m_contracts.empty() || reload){ if (Initialize()){ m_contracts.clear(); CStoredProc<CClientRecordset> rs(m_DbConnection, L"usp_Contract_Get"); rs.Open(); if (rs.GetRecordCount()){ rs.MoveFirst(); while (!rs.IsEOF()){ std::string bsSymbol = (char*)(_bstr_t(rs[L"vcSymbolName"])); m_contracts[bsSymbol] = static_cast<long>(rs[L"iContractTypeID"]); rs.MoveNext(); } } if ( m_contracts.find(symbol) != m_contracts.end() ){ return m_contracts[symbol]; } } } else{ if ( m_contracts.find(symbol) != m_contracts.end() ){ return m_contracts[symbol]; } return -1; } } catch (_com_error& err) { LOG4CPLUS_ERROR(ProviderLog, _T("ComError: getContractType(std::string) ")<<(char*)(err.Description())); ATLASSERT(FALSE); } catch (...) { LOG4CPLUS_ERROR(ProviderLog, _T("Unknown error occured while getContractType(std::string)")); ATLASSERT(FALSE); }; return -1; }; void setConnectionString(std::string ConnectionString){ m_ConnectionString = ConnectionString; }; bool Initialize(){ try { if(!m_DbConnection.IsOpened()) m_DbConnection.Open(_bstr_t(m_ConnectionString.c_str()), 10, 120, 300, 300); } catch (_com_error& err) { LOG4CPLUS_ERROR(ProviderLog, _T("ComError: CDatabaseImpl::GetContractType() ")<<(char*)(err.Description())); ATLASSERT(FALSE); return false; } catch (...) { LOG4CPLUS_ERROR(ProviderLog, _T("Unknown error occured while CDatabaseImpl::GetContractType()")); ATLASSERT(FALSE); return false; }; return true; }; private: std::string m_ConnectionString; CDBConnection m_DbConnection; std::map<std::string, long> m_contracts; }; class CDataBase { public: static CDatabaseImpl::pointer getInstance(){ if (!m_dbImpl){ m_dbImpl = new CDatabaseImpl(); LOG4CPLUS_INFO(ProviderLog, _T("DB instance created.")); } return m_dbImpl; }; private: static CDatabaseImpl::pointer m_dbImpl; };
[ "alex2172@gmail.com" ]
alex2172@gmail.com
009447ff34ec3aa2f19ec54073277017db01b9b0
1ed1ed934e4175bb20024311a007d60ae784b046
/PHOTOTK/PHOTOTK.cpp
f823925f5bb0bbf2ae2dc6f3261d915c7593a79e
[]
no_license
kkkcoder/Code_in_thptchuyen.ntucoder.net
f568cddc01b641c9a6a3c033a4b48ca59bb6435e
c4c0e19ea56a6560014cbb6e4d7489fb16e8aad7
refs/heads/master
2023-07-16T16:15:39.421817
2021-08-29T15:56:35
2021-08-29T15:56:35
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,347
cpp
// PHOTO // Bất chấp cái nắng gay gắt ở thành phố Tam Kỳ, các bạn học sinh vẫn muốn chụp ảnh lưu niệm // với các thầy cô giáo. Sau khi bàn bạc chiến thuật chụp ảnh, mọi người thống nhất như sau: // 1. Tất cả mọi người sẽ đứng thành một hàng ngang. // 2. Có ba loại người: học sinh nữ, học sinh nam, giáo viên. Ta kí hiệu học sinh nữ bằng số 0, học sinh // nam bằng số 1, giáo viên bằng số 2. // 3. Đứng đầu hàng là một giáo viên (“2”), đứng cuối hàng là một giáo viên (“2”). // 4. Để bức ảnh đẹp, khoảng cách giữa hai giáo viên liên tiếp là 2 (ví dụ “202”) hoặc 3 (ví dụ “2012”). // Như một hệ quả, không có hai giáo viên nào đứng kề nhau (ví dụ “22” là không hợp lệ), và không // có hai giáo viên liên tiếp nào có nhiều hơn 2 học sinh ở giữa (ví dụ “20102” là không hợp lệ). // 5. Nếu khoảng cách giữa hai giáo viên liên tiếp là 2, thì học sinh ở giữa phải là nữ (ví dụ “202”). // 6. Nếu khoảng cách giữa hai giáo viên liên tiếp là 3, thì hai học sinh ở giữa phải có giới tính khác // nhau (ví dụ “2012”, “2102”). // 7. Hai bức ảnh được coi là khác nhau nếu chuỗi tam phân tương ứng là khác nhau. Như một hệ quả, // nếu ta đổi chỗ hai giáo viên (hoặc hai học sinh nam, hoặc hai học sinh nữ) cho nhau thì bức ảnh // được cho là không thay đổi. // Ví dụ: “2021020202”, “210201202012” là các bức ảnh hợp lệ. “0”, “01”, không hợp lệ do vi phạm quy định // số 3. “2020102”, “2202” không hợp lệ do vi phạm quy định số 4. “212”, “201212” không hợp lệ do vi phạm // quy định số 5. “200202”, “211202” không hợp lệ do vi phạm quy định số 6. // Yêu cầu: Cho biết số lượng giáo viên, học sinh nam, học sinh nữ. Đếm số bức ảnh có thể tạo ra. Vì kết // quả có thể rất lớn, in phần dư khi chia kết quả cho 109 + 7. // Dữ liệu // Dữ liệu gồm một dòng duy nhất chứa ba số nguyên dương N0, N1, N2 lần lượt là số học sinh nữ, số học // sinh nam, và số giáo viên (1 ≤ N0, N1, N2 ≤ 106 // ). // Kết quả // In ra phần dư khi chia số lượng bức ảnh có thể tạo được cho 109 + 7. #include <bits/stdc++.h> #define ll long long #define fo(i, a, b) for (int i = a; i <= b; i++) #define nmax 1000005 using namespace std; const int mod = 1e9 + 7; ll n, x = 0, a, b, c, gt[nmax], inv[nmax]; ll mu(ll a, ll b) { if (b == 0) return 1; ll t = mu(a, b / 2); t = (t * t) % mod; if (b % 2 == 1) t = (t * a) % mod; return t; } int main() { gt[0] = 1; fo(i, 1, 1000000) gt[i] = (gt[i - 1] * i) % mod; inv[1000000] = mu(gt[1000000], mod - 2); for (int i = 999999; i >= 0; i--) inv[i] = (inv[i + 1] * (i + 1)) % mod; cin >> a >> b >> c; { if (a + 1 != c || a < b) cout << 0; else { cout << (((gt[a] * inv[b]) % mod * inv[a - b]) % mod * mu(2, b)) % mod; } } }
[ "lam3082004@gmail.com" ]
lam3082004@gmail.com
7d6945a3b9aa8871a87a1deea338e5fb56c1098d
9d7649ca193d5e62b6752ba4098c43eb5a16aa5f
/native/chrome-18.0.1017.0/src/sip/include/CC_CallInfo.h
6e897f5f8a0b6acd1f49889d665d22e96c5c9c14
[]
no_license
yiw2/ikran
6aafe7d2b6ede852bdcffd9fc3ac4613ee9976a8
cc8a3205cdbcb34f7807373db01c7f8b2558a639
refs/heads/master
2020-12-25T17:12:41.280090
2012-03-13T05:42:58
2012-03-13T05:42:58
3,196,837
4
1
null
null
null
null
UTF-8
C++
false
false
10,250
h
/* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * * The contents of this file are subject to the Mozilla Public License Version * 1.1 (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.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License * for the specific language governing rights and limitations under the * License. * * The Original Code is the Cisco Systems SIP Stack. * * The Initial Developer of the Original Code is * Cisco Systems (CSCO). * Portions created by the Initial Developer are Copyright (C) 2002 * the Initial Developer. All Rights Reserved. * * Contributor(s): * Enda Mannion <emannion@cisco.com> * Suhas Nandakumar <snandaku@cisco.com> * Ethan Hugg <ehugg@cisco.com> * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), * in which case the provisions of the GPL or the LGPL are applicable instead * of those above. If you wish to allow use of your version of this file only * under the terms of either the GPL or the LGPL, and not to allow others to * use your version of this file under the terms of the MPL, indicate your * decision by deleting the provisions above and replace them with the notice * and other provisions required by the GPL or the LGPL. If you do not delete * the provisions above, a recipient may use your version of this file under * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ #pragma once #include <set> extern "C" { #include "../src/sipcc/include/ccapi_types.h" } #include "CC_Common.h" #include "CC_CallTypes.h" namespace CSF { class ECC_API CC_CallInfo { protected: CC_CallInfo() { } public: //Base class needs dtor to be declared as virtual virtual ~CC_CallInfo() {}; /** Get the line object associated with this call. @return CC_LinePtr - line ID */ virtual CC_LinePtr getline () = 0; /** get Call state @param [in] handle - call info handle @return call state */ virtual cc_call_state_t getCallState () = 0; /** Get ringer state. @return bool ringer state. */ virtual bool getRingerState() = 0; /** Get call attributes @return cc_call_attr_t. */ virtual cc_call_attr_t getCallAttr() = 0; /** Get the call type @return cc_call_type_t for this call. Supported values inlude: CC_CALL_TYPE_INCOMING, CC_CALL_TYPE_OUTGOING and CC_CALL_TYPE_FORWARDED. */ virtual cc_call_type_t getCallType() = 0; /** Get called party name @return called party name */ virtual std::string getCalledPartyName() = 0; /** Get called party number @return called party number as a string. */ virtual std::string getCalledPartyNumber() = 0; /** Get calling party name @return calling party name */ virtual std::string getCallingPartyName() = 0; /** Get calling party number @return calling party number as a string Note: this is a const reference to a string that's owned by the */ virtual std::string getCallingPartyNumber() = 0; /** Get alternate number @return calling party number as a string. */ virtual std::string getAlternateNumber() = 0; /** This function is used to check if a given capability is supported based on the information in this CC_CallInfo object. @param [in] capability - the capability that is to be checked for availability. @return boolean - returns true if the given capability is available, false otherwise. */ virtual bool hasCapability (CC_CallCapabilityEnum::CC_CallCapability capability) = 0; /** If you need the complete set of capabilities @return cc_return_t - set of Call Capabilities. */ virtual std::set<CC_CallCapabilityEnum::CC_CallCapability> getCapabilitySet() = 0; /** get Original Called party name @param [in] handle - call info handle @return original called party name */ virtual std::string getOriginalCalledPartyName() = 0; /** get Original Called party number @param [in] handle - call info handle @return original called party number */ virtual std::string getOriginalCalledPartyNumber() = 0; /** get last redirecting party name @param [in] handle - call info handle @return last redirecting party name */ virtual std::string getLastRedirectingPartyName() = 0; /** get past redirecting party number @param [in] handle - call info handle @return last redirecting party number */ virtual std::string getLastRedirectingPartyNumber() = 0; /** get placed call party name @param [in] handle - call info handle @return placed party name */ virtual std::string getPlacedCallPartyName() = 0; /** get placed call party number @param [in] handle - call info handle @return placed party number */ virtual std::string getPlacedCallPartyNumber() = 0; /** get call instance number @param [in] handle - call info handle @return */ virtual cc_int32_t getCallInstance() = 0; /** get call status prompt @param [in] handle - call info handle @return call status */ virtual std::string getStatus() = 0; /** get call security // TODO XLS has callagent security and endtoend security on call? @param [in] handle - call info handle @return call security status */ virtual cc_call_security_t getSecurity() = 0; /** get Call Selection Status @param [in] handle - call info handle @return bool - TRUE => selected */ virtual cc_int32_t getSelectionStatus() = 0; /** get GCID @param [in] handle - call info handle @return GCID */ virtual std::string getGCID() = 0; /** get ringer loop count @param handle - call handle @return once Vs continuous */ virtual bool getIsRingOnce() = 0; /** get ringer mode @param handle - call handle @return ringer mode */ virtual int getRingerMode() = 0; /** get onhook reason @param [in] handle - call info handle @return onhook reason */ virtual cc_int32_t getOnhookReason() = 0; /** is Conference Call? @param [in] handle - call info handle @return boolean - is Conference */ virtual bool getIsConference() = 0; /** getStream Statistics @param [in] handle - call info handle @param [in,out] stats - Array to get the stats @param [in,out] count - in len of stats arraysize of stats / out stats copied @return cc_return_t - CC_SUCCESS or CC_FAILURE */ virtual std::set<cc_int32_t> getStreamStatistics() = 0; /** Call selection status @param [in] handle - call info handle @return bool - selection status */ virtual bool isCallSelected() = 0; /** INFO Package for RECEIVED_INFO event @param [in] handle - call info handle @return string - Info package header */ virtual std::string getINFOPack() = 0; /** INFO type for RECEIVED_INFO event @return string - content-type header */ virtual std::string getINFOType() = 0; /** INFO body for RECEIVED_INFO event @return string - INFO body */ virtual std::string getINFOBody() = 0; /** Get the call log reference //TODO NEED TO DO SOMETHING WRAP CALL LOG REF. @return string - INFO body NOTE: Memory associated with the call log is tied to the this would be freed when the callinfo ref is freed. */ virtual cc_calllog_ref_t getCallLogRef() = 0; /** returns the negotiated video direction for this call @return cc_sdp_direction_t - video direction */ virtual cc_sdp_direction_t getVideoDirection() = 0; /** Find out if this call is capable of querying the media state, which includes mute state and video direction @return bool */ virtual bool isMediaStateAvailable() = 0; /** Get the audio mute state if available (check availability with isMediaStateAvailable()) @return bool - the current audio state of the call */ virtual bool isAudioMuted(void) = 0; /** Get the video mute state if available (check availability with isMediaStateAvailable()) @return bool - the current video state of the call */ virtual bool isVideoMuted(void) = 0; /** Get the current call volume level @return int - the current call volume level, or -1 if it cannot be determined */ virtual int getVolume() = 0; }; };
[ "snandaku@cisco.com" ]
snandaku@cisco.com
b3023388e50ed2d74843ff49656974b9b0af4548
d4c13af7eb462b236e82fe248495e5c167e8e7c7
/Car.cpp
c33df1d1298709bf8bbb6ce119a90b86e557fce3
[]
no_license
jderen/F1_Simulator
cd5ad297512d2c7fea22ba327dd051ae70f93737
21192053df86e17046a68aedc5f4bff11082e128
refs/heads/master
2020-05-05T11:48:47.557611
2019-04-07T18:21:21
2019-04-07T18:21:21
180,004,964
0
0
null
null
null
null
UTF-8
C++
false
false
1,569
cpp
// // Created by Kuba on 06.04.2019. // #include "Car.h" #include <thread> #include <iostream> bool Car::runningFlag; Car::Car(int position, int place, int fuel, int lap, bool damaged, int speed ){ this->position=position; this->place=place; this->fuel=fuel; this->lap=lap; this->damaged=damaged; this->speed=speed; } Car::~Car(){ } int Car::getPosition() { return this->position; } int Car::getPlace() { return this->place; } int Car::getFuel() { return this->fuel; } int Car::getLap() { return this->lap; } bool Car::getDamaged() { return this->damaged; } int Car::getSpeed() { return this->speed; } bool Car::getRunningFlag() { return runningFlag; } void Car::setPosition(int position) { this->position=position; } void Car::setPlace(int place) { this->place=place; } void Car::setFuel(int fuel) { this->fuel=fuel; } void Car::setLap(int lap) { this->lap=lap; } void Car::setDamaged(bool damaged) { this->damaged=damaged; } void Car::setSpeed(int speed) { this->speed=speed; } void Car::setRunningFlag(bool flag) { runningFlag=flag; } std::thread Car::moveThread() { return std::thread(&Car::move, this); } void Car::move() { while(runningFlag) { this->position+=this->speed; if(this->position==100){ this->lap+=1; this->position=0; } if(this->lap==5){ this->position=1; std::cout<<"wygrana"; } std::this_thread::sleep_for(std::chrono::milliseconds(500)); } }
[ "kuba35groszy@tlen.pl" ]
kuba35groszy@tlen.pl
e09af4e4b92a70f26fe6a83cb4e55556638b8857
0f1119fe9ccc3073eaf0d235e613b4e31ced9ad9
/MainWindow.cpp
b568f3abbcb1be35712021937880a4572a15da40
[]
no_license
Protew/SELA
951863d69b70b3e05bb5f123d8a1c6e71ad19d4a
80d6b8360b7744b07403c0e644bca91ba60df4bf
refs/heads/master
2020-05-19T12:21:51.640172
2019-05-05T10:31:18
2019-05-05T10:31:18
185,012,267
0
0
null
null
null
null
UTF-8
C++
false
false
1,570
cpp
/* * MainWindow.cpp * Function_2o * * Created by PRoTeW on 29/12/10. * Copyright 2010 __MyCompanyName__. All rights reserved. * */ #include "MainWindow.h" MainWindow :: MainWindow( void ) { initComponents(); setWindowTitle( tr( " SELA ANALYZER " ) ); } void MainWindow :: keyPressEvent( QKeyEvent * event ) { createMatrix(); event->accept(); } //SETS //GETS void MainWindow :: createMatrix( void ) { if( sela_widget != nullptr ) delete sela_widget; sela_widget = new QSela( this, dsb_setter_dimension->value() ); main_layout->update(); upper_layout->addWidget( sela_widget ); connect( btn_output, SIGNAL( clicked() ), sela_widget, SLOT( showOutput() ) ); base_buttons_layout->addWidget( btn_output ); } void MainWindow :: initComponents( void ) { //BUTTONS LAYOUT base_buttons_layout = new QHBoxLayout; // //MATRIX INICIALIZER dsb_setter_dimension = new QSpinBox(); dsb_setter_dimension->setRange( 2, 5000 ); dsb_setter_dimension->setValue( 2 ); dsb_setter_dimension->setSingleStep( 1 ); base_buttons_layout->addWidget( dsb_setter_dimension ); // //BTN CREATE btn_create = new QPushButton("CREATE"); connect( btn_create, SIGNAL( clicked() ), this, SLOT( createMatrix() ) ); base_buttons_layout->addWidget( btn_create ); // //BTN OUTPUT btn_output = new QPushButton("OUTPUT"); // upper_layout = new QHBoxLayout; sela_widget = nullptr; // // //MAIN LAYOUT // main_layout = new QVBoxLayout; main_layout->addLayout( upper_layout ); main_layout->addLayout( base_buttons_layout ); setLayout( main_layout ); }
[ "paulowerdt@gmail.com" ]
paulowerdt@gmail.com
f5449eb4825f40fbffee8b2cae276fca86d4d27f
3d7eb995de16ee58b5aa336295c04e02e3f86d49
/BallZOut/source/support/cocos2d-libs-0.99.5b3/Box2D/Dynamics/b2Body.h
6ba43500d6797b92fa6fcaace44e8687ad17d404
[ "MIT" ]
permissive
alexcurylo/ballzout
11fb97e73c626436f21a6772f3421b9003575029
130b5a3ee472b3556fe6227ed4cd8c227977c19e
refs/heads/master
2021-01-20T20:15:49.544517
2016-06-04T04:10:49
2016-06-04T04:10:49
59,953,344
0
0
null
null
null
null
UTF-8
C++
false
false
21,583
h
/* * Copyright (c) 2006-2009 Erin Catto http://www.gphysics.com * * This software is provided 'as-is', without any express or implied * warranty. In no event will the authors be held liable for any damages * arising from the use of this software. * Permission is granted to anyone to use this software for any purpose, * including commercial applications, and to alter it and redistribute it * freely, subject to the following restrictions: * 1. The origin of this software must not be misrepresented; you must not * claim that you wrote the original software. If you use this software * in a product, an acknowledgment in the product documentation would be * appreciated but is not required. * 2. Altered source versions must be plainly marked as such, and must not be * misrepresented as being the original software. * 3. This notice may not be removed or altered from any source distribution. */ #ifndef B2_BODY_H #define B2_BODY_H #include <Box2D/Common/b2Math.h> #include <Box2D/Collision/Shapes/b2Shape.h> #include <memory> class b2Fixture; class b2Joint; class b2Contact; class b2Controller; class b2World; struct b2FixtureDef; struct b2JointEdge; struct b2ContactEdge; /// The body type. /// static: zero mass, zero velocity, may be manually moved /// kinematic: zero mass, non-zero velocity set by user, moved by solver /// dynamic: positive mass, non-zero velocity determined by forces, moved by solver enum b2BodyType { b2_staticBody = 0, b2_kinematicBody, b2_dynamicBody, }; /// A body definition holds all the data needed to construct a rigid body. /// You can safely re-use body definitions. Shapes are added to a body after construction. struct b2BodyDef { /// This constructor sets the body definition default values. b2BodyDef() : type(b2_staticBody), position(), angle(0.f), linearVelocity(), angularVelocity(0.f), linearDamping(0.f), angularDamping(0.f), allowSleep(true), awake(true), fixedRotation(false), bullet(false), active(true), userData(NULL), inertiaScale(1.f) { //userData = NULL; //position.Set(0.0f, 0.0f); //angle = 0.0f; //linearVelocity.Set(0.0f, 0.0f); //angularVelocity = 0.0f; //linearDamping = 0.0f; //angularDamping = 0.0f; //allowSleep = true; //awake = true; //fixedRotation = false; //bullet = false; //type = b2_staticBody; //active = true; //inertiaScale = 1.0f; } /// The body type: static, kinematic, or dynamic. /// Note: if a dynamic body would have zero mass, the mass is set to one. b2BodyType type; /// The world position of the body. Avoid creating bodies at the origin /// since this can lead to many overlapping shapes. b2Vec2 position; /// The world angle of the body in radians. float32 angle; /// The linear velocity of the body's origin in world co-ordinates. b2Vec2 linearVelocity; /// The angular velocity of the body. float32 angularVelocity; /// Linear damping is use to reduce the linear velocity. The damping parameter /// can be larger than 1.0f but the damping effect becomes sensitive to the /// time step when the damping parameter is large. float32 linearDamping; /// Angular damping is use to reduce the angular velocity. The damping parameter /// can be larger than 1.0f but the damping effect becomes sensitive to the /// time step when the damping parameter is large. float32 angularDamping; /// Set this flag to false if this body should never fall asleep. Note that /// this increases CPU usage. bool allowSleep; /// Is this body initially awake or sleeping? bool awake; /// Should this body be prevented from rotating? Useful for characters. bool fixedRotation; /// Is this a fast moving body that should be prevented from tunneling through /// other moving bodies? Note that all bodies are prevented from tunneling through /// kinematic and static bodies. This setting is only considered on dynamic bodies. /// @warning You should use this flag sparingly since it increases processing time. bool bullet; /// Does this body start out active? bool active; /// Use this to store application specific body data. void* userData; /// Experimental: scales the inertia tensor. float32 inertiaScale; }; /// A rigid body. These are created via b2World::CreateBody. class b2Body { public: /// Creates a fixture and attach it to this body. Use this function if you need /// to set some fixture parameters, like friction. Otherwise you can create the /// fixture directly from a shape. /// If the density is non-zero, this function automatically updates the mass of the body. /// Contacts are not created until the next time step. /// @param def the fixture definition. /// @warning This function is locked during callbacks. b2Fixture* CreateFixture(const b2FixtureDef* def); /// Creates a fixture from a shape and attach it to this body. /// This is a convenience function. Use b2FixtureDef if you need to set parameters /// like friction, restitution, user data, or filtering. /// If the density is non-zero, this function automatically updates the mass of the body. /// @param shape the shape to be cloned. /// @param density the shape density (set to zero for static bodies). /// @warning This function is locked during callbacks. b2Fixture* CreateFixture(const b2Shape* shape, float32 density); /// Destroy a fixture. This removes the fixture from the broad-phase and /// destroys all contacts associated with this fixture. This will /// automatically adjust the mass of the body if the body is dynamic and the /// fixture has positive density. /// All fixtures attached to a body are implicitly destroyed when the body is destroyed. /// @param fixture the fixture to be removed. /// @warning This function is locked during callbacks. void DestroyFixture(b2Fixture* fixture); /// Set the position of the body's origin and rotation. /// This breaks any contacts and wakes the other bodies. /// Manipulating a body's transform may cause non-physical behavior. /// @param position the world position of the body's local origin. /// @param angle the world rotation in radians. void SetTransform(const b2Vec2& position, float32 angle); /// Get the body transform for the body's origin. /// @return the world transform of the body's origin. const b2Transform& GetTransform() const; /// Get the world body origin position. /// @return the world position of the body's origin. const b2Vec2& GetPosition() const; /// Get the angle in radians. /// @return the current world rotation angle in radians. float32 GetAngle() const; /// Get the world position of the center of mass. const b2Vec2& GetWorldCenter() const; /// Get the local position of the center of mass. const b2Vec2& GetLocalCenter() const; /// Set the linear velocity of the center of mass. /// @param v the new linear velocity of the center of mass. void SetLinearVelocity(const b2Vec2& v); /// Get the linear velocity of the center of mass. /// @return the linear velocity of the center of mass. b2Vec2 GetLinearVelocity() const; /// Set the angular velocity. /// @param omega the new angular velocity in radians/second. void SetAngularVelocity(float32 omega); /// Get the angular velocity. /// @return the angular velocity in radians/second. float32 GetAngularVelocity() const; /// Apply a force at a world point. If the force is not /// applied at the center of mass, it will generate a torque and /// affect the angular velocity. This wakes up the body. /// @param force the world force vector, usually in Newtons (N). /// @param point the world position of the point of application. void ApplyForce(const b2Vec2& force, const b2Vec2& point); /// Apply a torque. This affects the angular velocity /// without affecting the linear velocity of the center of mass. /// This wakes up the body. /// @param torque about the z-axis (out of the screen), usually in N-m. void ApplyTorque(float32 torque); /// Apply an impulse at a point. This immediately modifies the velocity. /// It also modifies the angular velocity if the point of application /// is not at the center of mass. This wakes up the body. /// @param impulse the world impulse vector, usually in N-seconds or kg-m/s. /// @param point the world position of the point of application. void ApplyLinearImpulse(const b2Vec2& impulse, const b2Vec2& point); /// Apply an angular impulse. /// @param impulse the angular impulse in units of kg*m*m/s void ApplyAngularImpulse(float32 impulse); /// Get the total mass of the body. /// @return the mass, usually in kilograms (kg). float32 GetMass() const; /// Get the rotational inertia of the body about the local origin. /// @return the rotational inertia, usually in kg-m^2. float32 GetInertia() const; /// Get the mass data of the body. /// @return a struct containing the mass, inertia and center of the body. void GetMassData(b2MassData* data) const; /// Set the mass properties to override the mass properties of the fixtures. /// Note that this changes the center of mass position. /// Note that creating or destroying fixtures can also alter the mass. /// This function has no effect if the body isn't dynamic. /// @param massData the mass properties. void SetMassData(const b2MassData* data); /// This resets the mass properties to the sum of the mass properties of the fixtures. /// This normally does not need to be called unless you called SetMassData to override /// the mass and you later want to reset the mass. void ResetMassData(); /// Get the world coordinates of a point given the local coordinates. /// @param localPoint a point on the body measured relative the the body's origin. /// @return the same point expressed in world coordinates. b2Vec2 GetWorldPoint(const b2Vec2& localPoint) const; /// Get the world coordinates of a vector given the local coordinates. /// @param localVector a vector fixed in the body. /// @return the same vector expressed in world coordinates. b2Vec2 GetWorldVector(const b2Vec2& localVector) const; /// Gets a local point relative to the body's origin given a world point. /// @param a point in world coordinates. /// @return the corresponding local point relative to the body's origin. b2Vec2 GetLocalPoint(const b2Vec2& worldPoint) const; /// Gets a local vector given a world vector. /// @param a vector in world coordinates. /// @return the corresponding local vector. b2Vec2 GetLocalVector(const b2Vec2& worldVector) const; /// Get the world linear velocity of a world point attached to this body. /// @param a point in world coordinates. /// @return the world velocity of a point. b2Vec2 GetLinearVelocityFromWorldPoint(const b2Vec2& worldPoint) const; /// Get the world velocity of a local point. /// @param a point in local coordinates. /// @return the world velocity of a point. b2Vec2 GetLinearVelocityFromLocalPoint(const b2Vec2& localPoint) const; /// Get the linear damping of the body. float32 GetLinearDamping() const; /// Set the linear damping of the body. void SetLinearDamping(float32 linearDamping); /// Get the angular damping of the body. float32 GetAngularDamping() const; /// Set the angular damping of the body. void SetAngularDamping(float32 angularDamping); /// Set the type of this body. This may alter the mass and velocity. void SetType(b2BodyType type); /// Get the type of this body. b2BodyType GetType() const; /// Should this body be treated like a bullet for continuous collision detection? void SetBullet(bool flag); /// Is this body treated like a bullet for continuous collision detection? bool IsBullet() const; /// You can disable sleeping on this body. If you disable sleeping, the /// body will be woken. void SetSleepingAllowed(bool flag); /// Is this body allowed to sleep bool IsSleepingAllowed() const; /// Set the sleep state of the body. A sleeping body has very /// low CPU cost. /// @param flag set to true to put body to sleep, false to wake it. void SetAwake(bool flag); /// Get the sleeping state of this body. /// @return true if the body is sleeping. bool IsAwake() const; /// Set the active state of the body. An inactive body is not /// simulated and cannot be collided with or woken up. /// If you pass a flag of true, all fixtures will be added to the /// broad-phase. /// If you pass a flag of false, all fixtures will be removed from /// the broad-phase and all contacts will be destroyed. /// Fixtures and joints are otherwise unaffected. You may continue /// to create/destroy fixtures and joints on inactive bodies. /// Fixtures on an inactive body are implicitly inactive and will /// not participate in collisions, ray-casts, or queries. /// Joints connected to an inactive body are implicitly inactive. /// An inactive body is still owned by a b2World object and remains /// in the body list. void SetActive(bool flag); /// Get the active state of the body. bool IsActive() const; /// Set this body to have fixed rotation. This causes the mass /// to be reset. void SetFixedRotation(bool flag); /// Does this body have fixed rotation? bool IsFixedRotation() const; /// Get the list of all fixtures attached to this body. b2Fixture* GetFixtureList(); const b2Fixture* GetFixtureList() const; /// Get the list of all joints attached to this body. b2JointEdge* GetJointList(); const b2JointEdge* GetJointList() const; /// Get the list of all contacts attached to this body. /// @warning this list changes during the time step and you may /// miss some collisions if you don't use b2ContactListener. b2ContactEdge* GetContactList(); const b2ContactEdge* GetContactList() const; /// Get the next body in the world's body list. b2Body* GetNext(); const b2Body* GetNext() const; /// Get the user data pointer that was provided in the body definition. void* GetUserData() const; /// Set the user data. Use this to store your application specific data. void SetUserData(void* data); /// Get the parent world of this body. b2World* GetWorld(); const b2World* GetWorld() const; private: friend class b2World; friend class b2Island; friend class b2ContactManager; friend class b2ContactSolver; friend class b2TOISolver; friend class b2DistanceJoint; friend class b2GearJoint; friend class b2LineJoint; friend class b2MouseJoint; friend class b2PrismaticJoint; friend class b2PulleyJoint; friend class b2RevoluteJoint; friend class b2WeldJoint; friend class b2FrictionJoint; // m_flags enum { e_islandFlag = 0x0001, e_awakeFlag = 0x0002, e_autoSleepFlag = 0x0004, e_bulletFlag = 0x0008, e_fixedRotationFlag = 0x0010, e_activeFlag = 0x0020, e_toiFlag = 0x0040, }; b2Body(const b2BodyDef* bd, b2World* world); ~b2Body(); void SynchronizeFixtures(); void SynchronizeTransform(); // This is used to prevent connected bodies from colliding. // It may lie, depending on the collideConnected flag. bool ShouldCollide(const b2Body* other) const; void Advance(float32 t); b2BodyType m_type; uint16 m_flags; int32 m_islandIndex; b2Transform m_xf; // the body origin transform b2Sweep m_sweep; // the swept motion for CCD b2Vec2 m_linearVelocity; float32 m_angularVelocity; b2Vec2 m_force; float32 m_torque; b2World* m_world; b2Body* m_prev; b2Body* m_next; b2Fixture* m_fixtureList; int32 m_fixtureCount; b2JointEdge* m_jointList; b2ContactEdge* m_contactList; float32 m_mass, m_invMass; // Rotational inertia about the center of mass. float32 m_I, m_invI; float32 m_linearDamping; float32 m_angularDamping; float32 m_sleepTime; void* m_userData; private: b2Body(const b2Body& unimplemented); b2Body& operator=(const b2Body& unimplemented); }; inline b2BodyType b2Body::GetType() const { return m_type; } inline const b2Transform& b2Body::GetTransform() const { return m_xf; } inline const b2Vec2& b2Body::GetPosition() const { return m_xf.position; } inline float32 b2Body::GetAngle() const { return m_sweep.a; } inline const b2Vec2& b2Body::GetWorldCenter() const { return m_sweep.c; } inline const b2Vec2& b2Body::GetLocalCenter() const { return m_sweep.localCenter; } inline void b2Body::SetLinearVelocity(const b2Vec2& v) { if (m_type == b2_staticBody) { return; } if (b2Dot(v,v) > 0.0f) { SetAwake(true); } m_linearVelocity = v; } inline b2Vec2 b2Body::GetLinearVelocity() const { return m_linearVelocity; } inline void b2Body::SetAngularVelocity(float32 w) { if (m_type == b2_staticBody) { return; } if (w * w > 0.0f) { SetAwake(true); } m_angularVelocity = w; } inline float32 b2Body::GetAngularVelocity() const { return m_angularVelocity; } inline float32 b2Body::GetMass() const { return m_mass; } inline float32 b2Body::GetInertia() const { return m_I + m_mass * b2Dot(m_sweep.localCenter, m_sweep.localCenter); } inline void b2Body::GetMassData(b2MassData* data) const { data->mass = m_mass; data->I = m_I + m_mass * b2Dot(m_sweep.localCenter, m_sweep.localCenter); data->center = m_sweep.localCenter; } inline b2Vec2 b2Body::GetWorldPoint(const b2Vec2& localPoint) const { return b2Mul(m_xf, localPoint); } inline b2Vec2 b2Body::GetWorldVector(const b2Vec2& localVector) const { return b2Mul(m_xf.R, localVector); } inline b2Vec2 b2Body::GetLocalPoint(const b2Vec2& worldPoint) const { return b2MulT(m_xf, worldPoint); } inline b2Vec2 b2Body::GetLocalVector(const b2Vec2& worldVector) const { return b2MulT(m_xf.R, worldVector); } inline b2Vec2 b2Body::GetLinearVelocityFromWorldPoint(const b2Vec2& worldPoint) const { return m_linearVelocity + b2Cross(m_angularVelocity, worldPoint - m_sweep.c); } inline b2Vec2 b2Body::GetLinearVelocityFromLocalPoint(const b2Vec2& localPoint) const { return GetLinearVelocityFromWorldPoint(GetWorldPoint(localPoint)); } inline float32 b2Body::GetLinearDamping() const { return m_linearDamping; } inline void b2Body::SetLinearDamping(float32 linearDamping) { m_linearDamping = linearDamping; } inline float32 b2Body::GetAngularDamping() const { return m_angularDamping; } inline void b2Body::SetAngularDamping(float32 angularDamping) { m_angularDamping = angularDamping; } inline void b2Body::SetBullet(bool flag) { if (flag) { m_flags |= e_bulletFlag; } else { m_flags &= ~e_bulletFlag; } } inline bool b2Body::IsBullet() const { return (m_flags & e_bulletFlag) == e_bulletFlag; } inline void b2Body::SetAwake(bool flag) { if (flag) { if ((m_flags & e_awakeFlag) == 0) { m_flags |= e_awakeFlag; m_sleepTime = 0.0f; } } else { m_flags &= ~e_awakeFlag; m_sleepTime = 0.0f; m_linearVelocity.SetZero(); m_angularVelocity = 0.0f; m_force.SetZero(); m_torque = 0.0f; } } inline bool b2Body::IsAwake() const { return (m_flags & e_awakeFlag) == e_awakeFlag; } inline bool b2Body::IsActive() const { return (m_flags & e_activeFlag) == e_activeFlag; } inline void b2Body::SetFixedRotation(bool flag) { if (flag) { m_flags |= e_fixedRotationFlag; } else { m_flags &= ~e_fixedRotationFlag; } ResetMassData(); } inline bool b2Body::IsFixedRotation() const { return (m_flags & e_fixedRotationFlag) == e_fixedRotationFlag; } inline void b2Body::SetSleepingAllowed(bool flag) { if (flag) { m_flags |= e_autoSleepFlag; } else { m_flags &= ~e_autoSleepFlag; SetAwake(true); } } inline bool b2Body::IsSleepingAllowed() const { return (m_flags & e_autoSleepFlag) == e_autoSleepFlag; } inline b2Fixture* b2Body::GetFixtureList() { return m_fixtureList; } inline const b2Fixture* b2Body::GetFixtureList() const { return m_fixtureList; } inline b2JointEdge* b2Body::GetJointList() { return m_jointList; } inline const b2JointEdge* b2Body::GetJointList() const { return m_jointList; } inline b2ContactEdge* b2Body::GetContactList() { return m_contactList; } inline const b2ContactEdge* b2Body::GetContactList() const { return m_contactList; } inline b2Body* b2Body::GetNext() { return m_next; } inline const b2Body* b2Body::GetNext() const { return m_next; } inline void b2Body::SetUserData(void* data) { m_userData = data; } inline void* b2Body::GetUserData() const { return m_userData; } inline void b2Body::ApplyForce(const b2Vec2& force, const b2Vec2& point) { if (m_type != b2_dynamicBody) { return; } if (IsAwake() == false) { SetAwake(true); } m_force += force; m_torque += b2Cross(point - m_sweep.c, force); } inline void b2Body::ApplyTorque(float32 torque) { if (m_type != b2_dynamicBody) { return; } if (IsAwake() == false) { SetAwake(true); } m_torque += torque; } inline void b2Body::ApplyLinearImpulse(const b2Vec2& impulse, const b2Vec2& point) { if (m_type != b2_dynamicBody) { return; } if (IsAwake() == false) { SetAwake(true); } m_linearVelocity += m_invMass * impulse; m_angularVelocity += m_invI * b2Cross(point - m_sweep.c, impulse); } inline void b2Body::ApplyAngularImpulse(float32 impulse) { if (m_type != b2_dynamicBody) { return; } if (IsAwake() == false) { SetAwake(true); } m_angularVelocity += m_invI * impulse; } inline void b2Body::SynchronizeTransform() { m_xf.R.Set(m_sweep.a); m_xf.position = m_sweep.c - b2Mul(m_xf.R, m_sweep.localCenter); } inline void b2Body::Advance(float32 t) { // Advance to the new safe time. m_sweep.Advance(t); m_sweep.c = m_sweep.c0; m_sweep.a = m_sweep.a0; SynchronizeTransform(); } inline b2World* b2Body::GetWorld() { return m_world; } inline const b2World* b2Body::GetWorld() const { return m_world; } #endif
[ "alex@alexcurylo.com" ]
alex@alexcurylo.com
df369d7cf4cc71d5ef397d57c3a64669c9b1c7ec
7ba1abd8abaf7b4858c3227e8ab7d21dacc381f5
/FIT/FITsim/AliFITv7.cxx
a80fd5ca7e2a5a55d3692d93f45019749c3da1d8
[]
no_license
ewillsher/AliRoot
099d5221bf89ff82ff28280f7e341837398deaec
1bfa899c6e93b005a87b7cb656e22ee15fc67776
refs/heads/master
2021-01-20T15:23:59.890900
2017-11-05T15:27:27
2017-11-05T15:27:27
90,764,830
0
0
null
2017-05-09T15:55:17
2017-05-09T15:55:16
null
UTF-8
C++
false
false
61,893
cxx
/************************************************************************** * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * * * * Author: The ALICE Off-line Project. * * Contributors are mentioned in the code where appropriate. * * * * Permission to use, copy, modify and distribute this software and its * * documentation strictly for non-commercial purposes is hereby granted * * without fee, provided that the above copyright notice appears in all * * copies and that both the copyright notice and this permission notice * * appear in the supporting documentation. The authors make no claims * * about the suitability of this software for any purpose. It is * * provided "as is" without express or implied warranty. * **************************************************************************/ ///////////////////////////////////////////////////////////////////// // // // FIT detector full geometry version 5 // // //Begin Html /* <img src="gif/AliFITv6Class.gif"> */ //End Html // Alla.Maevskaya@cern.ch ////T0+ optical propreties from Maciej and Noa // V0+ part by Lizardo Valencia Palomo lvalenci@cern.ch // // // // // ////////////////////////////////////////////////////////////////////// #include <Riostream.h> #include <stdlib.h> #include "TGeoCompositeShape.h" #include "TGeoManager.h" #include "TGeoMatrix.h" #include "TGeoVolume.h" #include "TGeoTube.h" #include "TGeoBBox.h" #include "TGeoNode.h" #include "TGeoArb8.h" #include <TGeoGlobalMagField.h> #include <TGraph.h> #include <TLorentzVector.h> #include <TMath.h> #include <TVirtualMC.h> #include <TString.h> #include <TParticle.h> #include "AliLog.h" #include "AliMagF.h" #include "AliRun.h" #include "AliFITHits.h" #include "AliFITv7.h" #include "AliMC.h" #include "AliCDBLocal.h" #include "AliCDBStorage.h" #include "AliCDBManager.h" #include "AliCDBEntry.h" #include "AliTrackReference.h" ClassImp(AliFITv7) using std::cout; using std::endl; //-------------------------------------------------------------------- AliFITv7::AliFITv7(): AliFIT(), fIdSens1(0), fIdSens2(0), fPMTeff(0x0), //V0+ nSectors(16), nRings(5), fSenseless(-1), fV0PlusR0(3.97),//Computed for z = 325 cm from IP fV0PlusR1(7.6),//From V0A fV0PlusR2(13.8),//From V0A fV0PlusR3(22.7),//From V0A fV0PlusR4(41.3),//From V0A fV0PlusR5(72.94),//Computed for z = 325 cm from IP fV0PlusR6(72.6),//Needed to compute fV0PlusnMeters fV0PlusSciWd(2.5),//From V0A fV0PlusFraWd(0.2),//From V0A fV0PlusZposition(+325),//Must be changed to specifications from Corrado (meeting 10/11/176) fV0PlusnMeters(fV0PlusR6*0.01),//From V0A fV0PlusLightYield(93.75),//From V0A fV0PlusLightAttenuation(0.05),//From V0A fV0PlusFibToPhot(0.3)//From V0A { // // Standart constructor for T0 Detector version 0 for (Int_t i = 0; i < nSectors; i++) { for (Int_t j = 0; j < nRings; j++) fIdV0Plus[i][j] = 0; } } //-------------------------------------------------------------------- AliFITv7::AliFITv7(const char *name, const char *title): AliFIT(name,title), fIdSens1(0), fIdSens2(0), fPMTeff(0x0), //V0+ nSectors(16), nRings(5), fSenseless(-1), fV0PlusR0(3.97),//Computed for z = 325 cm from IP fV0PlusR1(7.6),//From V0A fV0PlusR2(13.8),//From V0A fV0PlusR3(22.7),//From V0A fV0PlusR4(41.3),//From V0A fV0PlusR5(72.94),//Computed for z = 325 cm from IP fV0PlusR6(72.6),//Needed to compute fV0PlusnMeters fV0PlusSciWd(2.5),//From V0A fV0PlusFraWd(0.2),//From V0A fV0PlusZposition(+325),//Must be changed to specifications from Corrado (meeting 10/11/176) fV0PlusnMeters(fV0PlusR6*0.01),//From V0A fV0PlusLightYield(93.75),//From V0A fV0PlusLightAttenuation(0.05),//From V0A fV0PlusFibToPhot(0.3)//From V0A { // // Standart constructor for FIT Detector version 0 // fIshunt = 2; // SetPMTeff(); } //_____________________________________________________________________________ AliFITv7::~AliFITv7() { // desctructor } //------------------------------------------------------------------------- void AliFITv7::CreateGeometry() { // // Create the geometry of FIT Detector version 1 full geometry // // begin Html // Int_t *idtmed = fIdtmed->GetArray(); Float_t zdetC = 85; //center of mother volume Float_t zdetA = 333; Int_t idrotm[999]; Double_t x,y,z; // Float_t pstartC[3] = {6., 20 ,5}; // Float_t pstartA[3] = {2.55, 20 ,5}; Float_t pstartC[3] = {20., 20 ,5}; Float_t pstartA[3] = {20, 20 ,5}; Float_t pinstart[3] = {2.95,2.95,4.34}; Float_t pmcp[3] = {2.949, 2.949, 2.8}; //MCP AliMatrix(idrotm[901], 90., 0., 90., 90., 180., 0.); //------------------------------------------------------------------- //------------------------------------------------------------------- //C side Concave Geometry Double_t crad = 82.; //define concave c-side radius here Double_t dP = 3.31735114408; // Work in Progress side length //uniform angle between detector faces== Double_t btta = 2*TMath::ATan(dP/crad); //get noncompensated translation data Double_t grdin[6] = {-3, -2, -1, 1, 2, 3}; Double_t gridpoints[6]; for(Int_t i = 0; i < 6; i++){ gridpoints[i] = crad*TMath::Sin((1 - 1/(2*TMath::Abs(grdin[i])))*grdin[i]*btta); } std::vector<Double_t> xi,yi; for(Int_t j = 5; j >= 0; j--){ for(Int_t i = 0; i < 6; i++){ if(!(((j == 5 || j == 0) && (i == 5 || i == 0)) || ((j == 3 || j == 2) && (i == 3 || i == 2)))) { xi.push_back(gridpoints[i]); yi.push_back(gridpoints[j]); } } } Double_t zi[28]; for(Int_t i = 0; i < 28; i++) { zi[i] = TMath::Sqrt(TMath::Power(crad, 2) - TMath::Power(xi[i], 2) - TMath::Power(yi[i], 2)); } //get rotation data Double_t ac[28], bc[28], gc[28]; for(Int_t i = 0; i < 28; i++) { ac[i] = TMath::ATan(yi[i]/xi[i]) - TMath::Pi()/2 + 2*TMath::Pi(); if(xi[i] < 0){ bc[i] = TMath::ACos(zi[i]/crad); } else { bc[i] = -1 * TMath::ACos(zi[i]/crad); } } Double_t xc2[28], yc2[28], zc2[28]; //compensation based on node position within individual detector geometries //determine compensated radius Double_t rcomp = crad + pstartC[2] / 2.0; // for(Int_t i = 0; i < 28; i++) { //Get compensated translation data xc2[i] = rcomp*TMath::Cos(ac[i] + TMath::Pi()/2)*TMath::Sin(-1*bc[i]); yc2[i] = rcomp*TMath::Sin(ac[i] + TMath::Pi()/2)*TMath::Sin(-1*bc[i]); zc2[i] = rcomp*TMath::Cos(bc[i]); //Convert angles to degrees ac[i]*=180/TMath::Pi(); bc[i]*=180/TMath::Pi(); gc[i] = -1 * ac[i]; } //A Side Float_t xa[24] = {-11.8, -5.9, 0, 5.9, 11.8, -11.8, -5.9, 0, 5.9, 11.8, -12.8, -6.9, 6.9, 12.8, -11.8, -5.9, 0, 5.9, 11.8, -11.8, -5.9, 0, 5.9, 11.8 }; Float_t ya[24] = { 11.9, 11.9, 12.9, 11.9, 11.9, 6.0, 6.0, 7.0, 6.0, 6.0, -0.1, -0.1, 0.1, 0.1, -6.0, -6.0, -7.0, -6.0, -6.0, -11.9, -11.9, -12.9, -11.9, -11.9 }; TGeoVolumeAssembly * stlinA = new TGeoVolumeAssembly("0STL"); // A side mother TGeoVolumeAssembly * stlinC = new TGeoVolumeAssembly("0STR"); // C side mother //FIT interior TVirtualMC::GetMC()->Gsvolu("0INS","BOX",idtmed[kAir],pinstart,3); TGeoVolume *ins = gGeoManager->GetVolume("0INS"); // TGeoTranslation *tr[52]; TString nameTr; //A side Translations for (Int_t itr=0; itr<24; itr++) { nameTr = Form("0TR%i",itr+1); z=-pstartA[2]+pinstart[2]; tr[itr] = new TGeoTranslation(nameTr.Data(),xa[itr],ya[itr], z ); printf(" itr %i A %f %f %f \n",itr, xa[itr], ya[itr], z+zdetA); tr[itr]->RegisterYourself(); stlinA->AddNode(ins,itr,tr[itr]); } TGeoRotation *rot[28]; TString nameRot; TGeoCombiTrans *com[28]; TString nameCom; //C Side Transformations for (Int_t itr=24;itr<52; itr++) { nameTr = Form("0TR%i",itr+1); nameRot = Form("0Rot%i",itr+1); //nameCom = Form("0Com%i",itr+1); rot[itr-24] = new TGeoRotation(nameRot.Data(),ac[itr-24],bc[itr-24],gc[itr-24]); rot[itr-24]->RegisterYourself(); tr[itr] = new TGeoTranslation(nameTr.Data(),xc2[itr-24],yc2[itr-24], (zc2[itr-24]-80.) ); tr[itr]->Print(); tr[itr]->RegisterYourself(); // com[itr-24] = new TGeoCombiTrans(tr[itr],rot[itr-24]); com[itr-24] = new TGeoCombiTrans(xc2[itr-24],yc2[itr-24], (zc2[itr-24]-80),rot[itr-24]); TGeoHMatrix hm = *com[itr-24]; TGeoHMatrix *ph = new TGeoHMatrix(hm); stlinC->AddNode(ins,itr,ph); } TGeoVolume *alice = gGeoManager->GetVolume("ALIC"); alice->AddNode(stlinA,1,new TGeoTranslation(0,0, zdetA ) ); // alice->AddNode(stlinC,1,new TGeoTranslation(0,0, -zdetC ) ); TGeoRotation * rotC = new TGeoRotation( "rotC",90., 0., 90., 90., 180., 0.); alice->AddNode(stlinC,1, new TGeoCombiTrans(0., 0., -zdetC , rotC) ); SetOneMCP(ins); SetVZEROGeo(alice); } //_________________________________________ void AliFITv7::SetOneMCP(TGeoVolume *ins) { cout<<"AliFITv7::SetOneMCP "<<ins<<endl; Double_t x,y,z; Double_t crad = 82.; //define concave c-side radius here Double_t dP = 3.31735114408; // Work in Progress side length Int_t *idtmed = fIdtmed->GetArray(); Float_t pinstart[3] = {2.95,2.95,4.34}; Float_t pmcp[3] = {2.949, 2.949, 2.8}; //MCP Float_t ptop[3] = {1.324, 1.324, 1.};//cherenkov radiator Float_t ptopref[3] = {1.3241, 1.3241, 1.};//cherenkov radiator wrapped with reflection Float_t preg[3] = {1.324, 1.324, 0.005};//photcathode Double_t prfv[3]= {0.0002,1.323, 1.};//vertical refracting layer bettwen radiators and bettwen radiator and not optical Air Double_t prfh[3]= {1.323,0.0002, 1.};//horizontal refracting layer bettwen radiators a Double_t pal[3]= {2.648,2.648, 0.25}; // 5mm Al top on th eeach radiator // Entry window (glass) TVirtualMC::GetMC()->Gsvolu("0TOP","BOX",idtmed[kOpGlass],ptop,3); //glass radiator TGeoVolume *top = gGeoManager->GetVolume("0TOP"); TVirtualMC::GetMC()->Gsvolu("0TRE","BOX",idtmed[kAir],ptopref,3); //air: wrapped radiator TGeoVolume *topref = gGeoManager->GetVolume("0TRE"); TVirtualMC::GetMC()->Gsvolu ("0REG", "BOX", idtmed[kOpGlassCathode], preg, 3); TGeoVolume *cat = gGeoManager->GetVolume("0REG"); TVirtualMC::GetMC()->Gsvolu("0MCP","BOX",idtmed[kGlass],pmcp,3); //glass TGeoVolume *mcp = gGeoManager->GetVolume("0MCP"); TVirtualMC::GetMC()->Gsvolu("0RFV","BOX",idtmed[kOpAir],prfv,3); //optical Air vertical TGeoVolume *rfv = gGeoManager->GetVolume("0RFV"); TVirtualMC::GetMC()->Gsvolu("0RFH","BOX",idtmed[kOpAir],prfh,3); //optical Air horizontal TGeoVolume *rfh = gGeoManager->GetVolume("0RFH"); TVirtualMC::GetMC()->Gsvolu("0PAL","BOX",idtmed[kAl],pal,3); // 5mmAl top on the radiator TGeoVolume *altop = gGeoManager->GetVolume("0PAL"); Double_t thet = TMath::ATan(dP/crad); Double_t rat = TMath::Tan(thet)/2.0; //Al housing definition Double_t mgon[16]; mgon[0] = -45; mgon[1] = 360.0; mgon[2] = 4; mgon[3] = 4; z = -pinstart[2] + 2*pal[2]; mgon[4] = z; mgon[5] = 2*ptop[0] + preg[2]; mgon[6] = dP+rat*z*4/3; z = -pinstart[2] + 2*pal[2] + 2*ptopref[2]; mgon[7] = z; mgon[8] = mgon[5]; mgon[9] = dP+z*rat; mgon[10] = z; mgon[11] = pmcp[0] + preg[2]; mgon[12] = mgon[9]; z = -pinstart[2] + 2*pal[2] + 2*ptopref[2] + 2*preg[2] + 2*pmcp[2]; mgon[13] = z; mgon[14] = mgon[11]; mgon[15] = dP+z*rat*pmcp[2]*9/10; TVirtualMC::GetMC()->Gsvolu("0SUP","PGON",idtmed[kAl], mgon, 16); //Al Housing for Support Structure TGeoVolume *alsup = gGeoManager->GetVolume("0SUP"); //wrapped radiator + reflectiong layers Int_t ntops=0, nrfvs=0, nrfhs=0; Float_t xin=0, yin=0, xinv=0, yinv=0,xinh=0,yinh=0; x=y=z=0; topref->AddNode(top, 1, new TGeoTranslation(0,0,0) ); xinv = -ptop[0] - prfv[0]; topref->AddNode(rfv, 1, new TGeoTranslation(xinv,0,0) ); printf(" GEOGEO refv %f , 0,0 \n",xinv); xinv = ptop[0] + prfv[0]; topref->AddNode(rfv, 2, new TGeoTranslation(xinv,0,0) ); printf(" GEOGEO refv %f , 0,0 \n",xinv); yinv = -ptop[1] - prfh[1]; topref->AddNode(rfh, 1, new TGeoTranslation(0,yinv,0) ); printf(" GEOGEO refh , 0, %f, 0 \n",yinv); yinv = ptop[1] + prfh[1]; topref->AddNode(rfh, 2, new TGeoTranslation(0,yinv,0) ); //container for radiator, cathod for (Int_t ix=0; ix<2; ix++) { xin = - pinstart[0] + 0.3 + (ix+0.5)*2*ptopref[0] ; for (Int_t iy=0; iy<2 ; iy++) { z = - pinstart[2] + 2*pal[2] + ptopref[2]; yin = - pinstart[1] + 0.3 + (iy+0.5)*2*ptopref[1]; ntops++; ins->AddNode(topref, ntops, new TGeoTranslation(xin,yin,z) ); printf(" 0TOP full %i x %f y %f z %f \n", ntops, xin, yin, z); z = -pinstart[2] + 2*pal[2] + 2 * ptopref[2] + preg[2]; ins->AddNode(cat, ntops, new TGeoTranslation(xin, yin, z) ); // cat->Print(); printf(" GEOGEO CATHOD x=%f , y= %f z= %f num %i\n", xin, yin, z, ntops); } } //Al top z=-pinstart[2] + pal[2]; ins->AddNode(altop, 1 , new TGeoTranslation(0,0,z) ); // MCP z=-pinstart[2] + 2*pal[2] + 2*ptopref[2] + 2*preg[2] + pmcp[2]; // z=-pinstart[2] + 2*ptopref[2] + preg[2]; ins->AddNode(mcp, 1 , new TGeoTranslation(0,0,z) ); // Al Housing for Support Structure ins->AddNode(alsup,1); } //_________________________________________ void AliFITv7::SetVZEROGeo(TGeoVolume *alice) { //V0+ cout<<" AliFITv7::SetVZEROGeo "<<alice<<endl; const int kV0PlusColorSci = 5; TGeoMedium *medV0PlusSci = gGeoManager->GetMedium("FIT_V0PlusSci"); Double_t Pi = TMath::Pi(); Double_t Sin22p5 = TMath::Sin(Pi/8.); Double_t Cos22p5 = TMath::Cos(Pi/8.); Double_t v0PlusPts[16]; //Defining the master volume for V0Plus TGeoVolume *v0Plus = new TGeoVolumeAssembly("V0LE"); /// For boolean sustraction for (Int_t i = 0; i < 2; i++) { v0PlusPts[0+8*i] = fV0PlusR0-fV0PlusFraWd/2.-fV0PlusFraWd; v0PlusPts[1+8*i] = -fV0PlusFraWd; v0PlusPts[2+8*i] = fV0PlusR0-fV0PlusFraWd/2.-fV0PlusFraWd; v0PlusPts[3+8*i] = fV0PlusFraWd/2.; v0PlusPts[4+8*i] = fV0PlusR5+fV0PlusFraWd/2.+fV0PlusFraWd; v0PlusPts[5+8*i] = fV0PlusFraWd/2.; v0PlusPts[6+8*i] = fV0PlusR5+fV0PlusFraWd/2.+fV0PlusFraWd; v0PlusPts[7+8*i] = -fV0PlusFraWd; } new TGeoArb8("sV0PlusCha1",fV0PlusSciWd/1.5,v0PlusPts); for (Int_t i = 0; i < 2; i++) { v0PlusPts[0+8*i] = fV0PlusR0*Cos22p5-fV0PlusFraWd; v0PlusPts[1+8*i] = (fV0PlusR0-fV0PlusFraWd)*Sin22p5-fV0PlusFraWd; v0PlusPts[2+8*i] = (fV0PlusR0-fV0PlusFraWd/2.)*Cos22p5-fV0PlusFraWd; v0PlusPts[3+8*i] = (fV0PlusR0-fV0PlusFraWd/2.)*Sin22p5; v0PlusPts[4+8*i] = (fV0PlusR5+fV0PlusFraWd/2.)*Cos22p5+fV0PlusFraWd; v0PlusPts[5+8*i] = (fV0PlusR5+fV0PlusFraWd/2.)*Sin22p5+2.*fV0PlusFraWd; v0PlusPts[6+8*i] = (fV0PlusR5+fV0PlusFraWd)*Cos22p5+fV0PlusFraWd; v0PlusPts[7+8*i] = fV0PlusR5*Sin22p5+fV0PlusFraWd; } new TGeoArb8("sV0PlusCha2", fV0PlusSciWd/2.+2.*fV0PlusFraWd, v0PlusPts); new TGeoCompositeShape("sV0PlusCha","sV0PlusCha1+sV0PlusCha2"); //Sensitive scintillator new TGeoTubeSeg( "sV0PlusR1b", fV0PlusR0+fV0PlusFraWd/2., fV0PlusR1-fV0PlusFraWd/2., fV0PlusSciWd/2., 0, 22.5); new TGeoTubeSeg( "sV0PlusR2b", fV0PlusR1+fV0PlusFraWd/2., fV0PlusR2-fV0PlusFraWd/2., fV0PlusSciWd/2., 0, 22.5); new TGeoTubeSeg( "sV0PlusR3b", fV0PlusR2+fV0PlusFraWd/2., fV0PlusR3-fV0PlusFraWd/2., fV0PlusSciWd/2., 0, 22.5); new TGeoTubeSeg( "sV0PlusR4b", fV0PlusR3+fV0PlusFraWd/2., fV0PlusR4-fV0PlusFraWd/2., fV0PlusSciWd/2., 0, 22.5); new TGeoTubeSeg( "sV0PlusR5b", fV0PlusR4+fV0PlusFraWd/2., fV0PlusR5-fV0PlusFraWd/2., fV0PlusSciWd/2., 0, 22.5); TGeoCompositeShape *sV0PlusR1 = new TGeoCompositeShape("sV0PlusR1","sV0PlusR1b-sV0PlusCha"); TGeoCompositeShape *sV0PlusR2 = new TGeoCompositeShape("sV0PlusR2","sV0PlusR2b-sV0PlusCha"); TGeoCompositeShape *sV0PlusR3 = new TGeoCompositeShape("sV0PlusR3","sV0PlusR3b-sV0PlusCha"); TGeoCompositeShape *sV0PlusR4 = new TGeoCompositeShape("sV0PlusR4","sV0PlusR4b-sV0PlusCha"); TGeoCompositeShape *sV0PlusR5 = new TGeoCompositeShape("sV0PlusR5","sV0PlusR5b-sV0PlusCha"); /// Definition sector 1 TGeoVolume *v0Plus1Sec1 = new TGeoVolume("V0Plus1Sec1",sV0PlusR1,medV0PlusSci); TGeoVolume *v0Plus2Sec1 = new TGeoVolume("V0Plus2Sec1",sV0PlusR2,medV0PlusSci); TGeoVolume *v0Plus3Sec1 = new TGeoVolume("V0Plus3Sec1",sV0PlusR3,medV0PlusSci); TGeoVolume *v0Plus4Sec1 = new TGeoVolume("V0Plus4Sec1",sV0PlusR4,medV0PlusSci); TGeoVolume *v0Plus5Sec1 = new TGeoVolume("V0Plus5Sec1",sV0PlusR5,medV0PlusSci); v0Plus1Sec1->SetLineColor(kV0PlusColorSci); v0Plus2Sec1->SetLineColor(kV0PlusColorSci); v0Plus3Sec1->SetLineColor(kV0PlusColorSci); v0Plus4Sec1->SetLineColor(kV0PlusColorSci); v0Plus5Sec1->SetLineColor(kV0PlusColorSci); TGeoVolume *v0PlusSciSec1 = new TGeoVolumeAssembly("V0PlusSciSec1"); v0PlusSciSec1->AddNode(v0Plus1Sec1,1); v0PlusSciSec1->AddNode(v0Plus2Sec1,1); v0PlusSciSec1->AddNode(v0Plus3Sec1,1); v0PlusSciSec1->AddNode(v0Plus4Sec1,1); v0PlusSciSec1->AddNode(v0Plus5Sec1,1); TGeoVolume *v0PlusSec1 = new TGeoVolumeAssembly("V0PlusSec1"); v0PlusSec1->AddNode(v0PlusSciSec1,1); TGeoRotation *RotSec1 = new TGeoRotation("RotSec1", 90., 0*22.5, 90., 90.+0*22.5, 0., 0.); v0Plus->AddNode(v0PlusSec1,0+1,RotSec1); /// Definition sector 2 TGeoVolume *v0Plus1Sec2 = new TGeoVolume("V0Plus1Sec2",sV0PlusR1,medV0PlusSci); TGeoVolume *v0Plus2Sec2 = new TGeoVolume("V0Plus2Sec2",sV0PlusR2,medV0PlusSci); TGeoVolume *v0Plus3Sec2 = new TGeoVolume("V0Plus3Sec2",sV0PlusR3,medV0PlusSci); TGeoVolume *v0Plus4Sec2 = new TGeoVolume("V0Plus4Sec2",sV0PlusR4,medV0PlusSci); TGeoVolume *v0Plus5Sec2 = new TGeoVolume("V0Plus5Sec2",sV0PlusR5,medV0PlusSci); v0Plus1Sec2->SetLineColor(kV0PlusColorSci); v0Plus2Sec2->SetLineColor(kV0PlusColorSci); v0Plus3Sec2->SetLineColor(kV0PlusColorSci); v0Plus4Sec2->SetLineColor(kV0PlusColorSci); v0Plus5Sec2->SetLineColor(kV0PlusColorSci); TGeoVolume *v0PlusSciSec2 = new TGeoVolumeAssembly("V0PlusSciSec2"); v0PlusSciSec2->AddNode(v0Plus1Sec2,1); v0PlusSciSec2->AddNode(v0Plus2Sec2,1); v0PlusSciSec2->AddNode(v0Plus3Sec2,1); v0PlusSciSec2->AddNode(v0Plus4Sec2,1); v0PlusSciSec2->AddNode(v0Plus5Sec2,1); TGeoVolume *v0PlusSec2 = new TGeoVolumeAssembly("V0PlusSec2"); v0PlusSec2->AddNode(v0PlusSciSec2,1); TGeoRotation *RotSec2 = new TGeoRotation("RotSec2", 90., 1*22.5, 90., 90.+1*22.5, 0., 0.); v0Plus->AddNode(v0PlusSec2,1+1,RotSec2); /// Definition sector 3 TGeoVolume *v0Plus1Sec3 = new TGeoVolume("V0Plus1Sec3",sV0PlusR1,medV0PlusSci); TGeoVolume *v0Plus2Sec3 = new TGeoVolume("V0Plus2Sec3",sV0PlusR2,medV0PlusSci); TGeoVolume *v0Plus3Sec3 = new TGeoVolume("V0Plus3Sec3",sV0PlusR3,medV0PlusSci); TGeoVolume *v0Plus4Sec3 = new TGeoVolume("V0Plus4Sec3",sV0PlusR4,medV0PlusSci); TGeoVolume *v0Plus5Sec3 = new TGeoVolume("V0Plus5Sec3",sV0PlusR5,medV0PlusSci); v0Plus1Sec3->SetLineColor(kV0PlusColorSci); v0Plus2Sec3->SetLineColor(kV0PlusColorSci); v0Plus3Sec3->SetLineColor(kV0PlusColorSci); v0Plus4Sec3->SetLineColor(kV0PlusColorSci); v0Plus5Sec3->SetLineColor(kV0PlusColorSci); TGeoVolume *v0PlusSciSec3 = new TGeoVolumeAssembly("V0PlusSciSec3"); v0PlusSciSec3->AddNode(v0Plus1Sec3,1); v0PlusSciSec3->AddNode(v0Plus2Sec3,1); v0PlusSciSec3->AddNode(v0Plus3Sec3,1); v0PlusSciSec3->AddNode(v0Plus4Sec3,1); v0PlusSciSec3->AddNode(v0Plus5Sec3,1); TGeoVolume *v0PlusSec3 = new TGeoVolumeAssembly("V0PlusSec3"); v0PlusSec3->AddNode(v0PlusSciSec3,1); TGeoRotation *RotSec3 = new TGeoRotation("RotSec3", 90., 2*22.5, 90., 90.+2*22.5, 0., 0.); v0Plus->AddNode(v0PlusSec3,2+1,RotSec3); /// Definition sector 4 TGeoVolume *v0Plus1Sec4 = new TGeoVolume("V0Plus1Sec4",sV0PlusR1,medV0PlusSci); TGeoVolume *v0Plus2Sec4 = new TGeoVolume("V0Plus2Sec4",sV0PlusR2,medV0PlusSci); TGeoVolume *v0Plus3Sec4 = new TGeoVolume("V0Plus3Sec4",sV0PlusR3,medV0PlusSci); TGeoVolume *v0Plus4Sec4 = new TGeoVolume("V0Plus4Sec4",sV0PlusR4,medV0PlusSci); TGeoVolume *v0Plus5Sec4 = new TGeoVolume("V0Plus5Sec4",sV0PlusR5,medV0PlusSci); v0Plus1Sec4->SetLineColor(kV0PlusColorSci); v0Plus2Sec4->SetLineColor(kV0PlusColorSci); v0Plus3Sec4->SetLineColor(kV0PlusColorSci); v0Plus4Sec4->SetLineColor(kV0PlusColorSci); v0Plus5Sec4->SetLineColor(kV0PlusColorSci); TGeoVolume *v0PlusSciSec4 = new TGeoVolumeAssembly("V0PlusSciSec4"); v0PlusSciSec4->AddNode(v0Plus1Sec4,1); v0PlusSciSec4->AddNode(v0Plus2Sec4,1); v0PlusSciSec4->AddNode(v0Plus3Sec4,1); v0PlusSciSec4->AddNode(v0Plus4Sec4,1); v0PlusSciSec4->AddNode(v0Plus5Sec4,1); TGeoVolume *v0PlusSec4 = new TGeoVolumeAssembly("V0PlusSec4"); v0PlusSec4->AddNode(v0PlusSciSec4,1); TGeoRotation *RotSec4 = new TGeoRotation("RotSec4", 90., 3*22.5, 90., 90.+3*22.5, 0., 0.); v0Plus->AddNode(v0PlusSec4,3+1,RotSec4); /// Definition sector 5 TGeoVolume *v0Plus1Sec5 = new TGeoVolume("V0Plus1Sec5",sV0PlusR1,medV0PlusSci); TGeoVolume *v0Plus2Sec5 = new TGeoVolume("V0Plus2Sec5",sV0PlusR2,medV0PlusSci); TGeoVolume *v0Plus3Sec5 = new TGeoVolume("V0Plus3Sec5",sV0PlusR3,medV0PlusSci); TGeoVolume *v0Plus4Sec5 = new TGeoVolume("V0Plus4Sec5",sV0PlusR4,medV0PlusSci); TGeoVolume *v0Plus5Sec5 = new TGeoVolume("V0Plus5Sec5",sV0PlusR5,medV0PlusSci); v0Plus1Sec5->SetLineColor(kV0PlusColorSci); v0Plus2Sec5->SetLineColor(kV0PlusColorSci); v0Plus3Sec5->SetLineColor(kV0PlusColorSci); v0Plus4Sec5->SetLineColor(kV0PlusColorSci); v0Plus5Sec5->SetLineColor(kV0PlusColorSci); TGeoVolume *v0PlusSciSec5 = new TGeoVolumeAssembly("V0PlusSciSec5"); v0PlusSciSec5->AddNode(v0Plus1Sec5,1); v0PlusSciSec5->AddNode(v0Plus2Sec5,1); v0PlusSciSec5->AddNode(v0Plus3Sec5,1); v0PlusSciSec5->AddNode(v0Plus4Sec5,1); v0PlusSciSec5->AddNode(v0Plus5Sec5,1); TGeoVolume *v0PlusSec5 = new TGeoVolumeAssembly("V0PlusSec5"); v0PlusSec5->AddNode(v0PlusSciSec5,1); TGeoRotation *RotSec5 = new TGeoRotation("RotSec5", 90., 4*22.5, 90., 90.+4*22.5, 0., 0.); v0Plus->AddNode(v0PlusSec5,4+1,RotSec5); /// Definition sector 6 TGeoVolume *v0Plus1Sec6 = new TGeoVolume("V0Plus1Sec6",sV0PlusR1,medV0PlusSci); TGeoVolume *v0Plus2Sec6 = new TGeoVolume("V0Plus2Sec6",sV0PlusR2,medV0PlusSci); TGeoVolume *v0Plus3Sec6 = new TGeoVolume("V0Plus3Sec6",sV0PlusR3,medV0PlusSci); TGeoVolume *v0Plus4Sec6 = new TGeoVolume("V0Plus4Sec6",sV0PlusR4,medV0PlusSci); TGeoVolume *v0Plus5Sec6 = new TGeoVolume("V0Plus5Sec6",sV0PlusR5,medV0PlusSci); v0Plus1Sec6->SetLineColor(kV0PlusColorSci); v0Plus2Sec6->SetLineColor(kV0PlusColorSci); v0Plus3Sec6->SetLineColor(kV0PlusColorSci); v0Plus4Sec6->SetLineColor(kV0PlusColorSci); v0Plus5Sec6->SetLineColor(kV0PlusColorSci); TGeoVolume *v0PlusSciSec6 = new TGeoVolumeAssembly("V0PlusSciSec6"); v0PlusSciSec6->AddNode(v0Plus1Sec6,1); v0PlusSciSec6->AddNode(v0Plus2Sec6,1); v0PlusSciSec6->AddNode(v0Plus3Sec6,1); v0PlusSciSec6->AddNode(v0Plus4Sec6,1); v0PlusSciSec6->AddNode(v0Plus5Sec6,1); TGeoVolume *v0PlusSec6 = new TGeoVolumeAssembly("V0PlusSec6"); v0PlusSec6->AddNode(v0PlusSciSec6,1); TGeoRotation *RotSec6 = new TGeoRotation("RotSec6", 90., 5*22.5, 90., 90.+5*22.5, 0., 0.); v0Plus->AddNode(v0PlusSec6,5+1,RotSec6); /// Definition sector 7 TGeoVolume *v0Plus1Sec7 = new TGeoVolume("V0Plus1Sec7",sV0PlusR1,medV0PlusSci); TGeoVolume *v0Plus2Sec7 = new TGeoVolume("V0Plus2Sec7",sV0PlusR2,medV0PlusSci); TGeoVolume *v0Plus3Sec7 = new TGeoVolume("V0Plus3Sec7",sV0PlusR3,medV0PlusSci); TGeoVolume *v0Plus4Sec7 = new TGeoVolume("V0Plus4Sec7",sV0PlusR4,medV0PlusSci); TGeoVolume *v0Plus5Sec7 = new TGeoVolume("V0Plus5Sec7",sV0PlusR5,medV0PlusSci); v0Plus1Sec7->SetLineColor(kV0PlusColorSci); v0Plus2Sec7->SetLineColor(kV0PlusColorSci); v0Plus3Sec7->SetLineColor(kV0PlusColorSci); v0Plus4Sec7->SetLineColor(kV0PlusColorSci); v0Plus5Sec7->SetLineColor(kV0PlusColorSci); TGeoVolume *v0PlusSciSec7 = new TGeoVolumeAssembly("V0PlusSciSec7"); v0PlusSciSec7->AddNode(v0Plus1Sec7,1); v0PlusSciSec7->AddNode(v0Plus2Sec7,1); v0PlusSciSec7->AddNode(v0Plus3Sec7,1); v0PlusSciSec7->AddNode(v0Plus4Sec7,1); v0PlusSciSec7->AddNode(v0Plus5Sec7,1); TGeoVolume *v0PlusSec7 = new TGeoVolumeAssembly("V0PlusSec7"); v0PlusSec7->AddNode(v0PlusSciSec7,1); TGeoRotation *RotSec7 = new TGeoRotation("RotSec7", 90., 6*22.5, 90., 90.+6*22.5, 0., 0.); v0Plus->AddNode(v0PlusSec7,6+1,RotSec7); /// Definition sector 8 TGeoVolume *v0Plus1Sec8 = new TGeoVolume("V0Plus1Sec8",sV0PlusR1,medV0PlusSci); TGeoVolume *v0Plus2Sec8 = new TGeoVolume("V0Plus2Sec8",sV0PlusR2,medV0PlusSci); TGeoVolume *v0Plus3Sec8 = new TGeoVolume("V0Plus3Sec8",sV0PlusR3,medV0PlusSci); TGeoVolume *v0Plus4Sec8 = new TGeoVolume("V0Plus4Sec8",sV0PlusR4,medV0PlusSci); TGeoVolume *v0Plus5Sec8 = new TGeoVolume("V0Plus5Sec8",sV0PlusR5,medV0PlusSci); v0Plus1Sec8->SetLineColor(kV0PlusColorSci); v0Plus2Sec8->SetLineColor(kV0PlusColorSci); v0Plus3Sec8->SetLineColor(kV0PlusColorSci); v0Plus4Sec8->SetLineColor(kV0PlusColorSci); v0Plus5Sec8->SetLineColor(kV0PlusColorSci); TGeoVolume *v0PlusSciSec8 = new TGeoVolumeAssembly("V0PlusSciSec8"); v0PlusSciSec8->AddNode(v0Plus1Sec8,1); v0PlusSciSec8->AddNode(v0Plus2Sec8,1); v0PlusSciSec8->AddNode(v0Plus3Sec8,1); v0PlusSciSec8->AddNode(v0Plus4Sec8,1); v0PlusSciSec8->AddNode(v0Plus5Sec8,1); TGeoVolume *v0PlusSec8 = new TGeoVolumeAssembly("V0PlusSec8"); v0PlusSec8->AddNode(v0PlusSciSec8,1); TGeoRotation *RotSec8 = new TGeoRotation("RotSec8", 90., 7*22.5, 90., 90.+7*22.5, 0., 0.); v0Plus->AddNode(v0PlusSec8,7+1,RotSec8); /// Definition sector 9 TGeoVolume *v0Plus1Sec9 = new TGeoVolume("V0Plus1Sec9",sV0PlusR1,medV0PlusSci); TGeoVolume *v0Plus2Sec9 = new TGeoVolume("V0Plus2Sec9",sV0PlusR2,medV0PlusSci); TGeoVolume *v0Plus3Sec9 = new TGeoVolume("V0Plus3Sec9",sV0PlusR3,medV0PlusSci); TGeoVolume *v0Plus4Sec9 = new TGeoVolume("V0Plus4Sec9",sV0PlusR4,medV0PlusSci); TGeoVolume *v0Plus5Sec9 = new TGeoVolume("V0Plus5Sec9",sV0PlusR5,medV0PlusSci); v0Plus1Sec9->SetLineColor(kV0PlusColorSci); v0Plus2Sec9->SetLineColor(kV0PlusColorSci); v0Plus3Sec9->SetLineColor(kV0PlusColorSci); v0Plus4Sec9->SetLineColor(kV0PlusColorSci); v0Plus5Sec9->SetLineColor(kV0PlusColorSci); TGeoVolume *v0PlusSciSec9 = new TGeoVolumeAssembly("V0PlusSciSec9"); v0PlusSciSec9->AddNode(v0Plus1Sec9,1); v0PlusSciSec9->AddNode(v0Plus2Sec9,1); v0PlusSciSec9->AddNode(v0Plus3Sec9,1); v0PlusSciSec9->AddNode(v0Plus4Sec9,1); v0PlusSciSec9->AddNode(v0Plus5Sec9,1); TGeoVolume *v0PlusSec9 = new TGeoVolumeAssembly("V0PlusSec9"); v0PlusSec9->AddNode(v0PlusSciSec9,1); TGeoRotation *RotSec9 = new TGeoRotation("RotSec9", 90., 8*22.5, 90., 90.+8*22.5, 0., 0.); v0Plus->AddNode(v0PlusSec9,8+1,RotSec9); /// Definition sector 10 TGeoVolume *v0Plus1Sec10 = new TGeoVolume("V0Plus1Sec10",sV0PlusR1,medV0PlusSci); TGeoVolume *v0Plus2Sec10 = new TGeoVolume("V0Plus2Sec10",sV0PlusR2,medV0PlusSci); TGeoVolume *v0Plus3Sec10 = new TGeoVolume("V0Plus3Sec10",sV0PlusR3,medV0PlusSci); TGeoVolume *v0Plus4Sec10 = new TGeoVolume("V0Plus4Sec10",sV0PlusR4,medV0PlusSci); TGeoVolume *v0Plus5Sec10 = new TGeoVolume("V0Plus5Sec10",sV0PlusR5,medV0PlusSci); v0Plus1Sec10->SetLineColor(kV0PlusColorSci); v0Plus2Sec10->SetLineColor(kV0PlusColorSci); v0Plus3Sec10->SetLineColor(kV0PlusColorSci); v0Plus4Sec10->SetLineColor(kV0PlusColorSci); v0Plus5Sec10->SetLineColor(kV0PlusColorSci); TGeoVolume *v0PlusSciSec10 = new TGeoVolumeAssembly("V0PlusSciSec10"); v0PlusSciSec10->AddNode(v0Plus1Sec10,1); v0PlusSciSec10->AddNode(v0Plus2Sec10,1); v0PlusSciSec10->AddNode(v0Plus3Sec10,1); v0PlusSciSec10->AddNode(v0Plus4Sec10,1); v0PlusSciSec10->AddNode(v0Plus5Sec10,1); TGeoVolume *v0PlusSec10 = new TGeoVolumeAssembly("V0PlusSec10"); v0PlusSec10->AddNode(v0PlusSciSec10,1); TGeoRotation *RotSec10 = new TGeoRotation("RotSec10", 90., 9*22.5, 90., 90.+9*22.5, 0., 0.); v0Plus->AddNode(v0PlusSec10,9+1,RotSec10); /// Definition sector 11 TGeoVolume *v0Plus1Sec11 = new TGeoVolume("V0Plus1Sec11",sV0PlusR1,medV0PlusSci); TGeoVolume *v0Plus2Sec11 = new TGeoVolume("V0Plus2Sec11",sV0PlusR2,medV0PlusSci); TGeoVolume *v0Plus3Sec11 = new TGeoVolume("V0Plus3Sec11",sV0PlusR3,medV0PlusSci); TGeoVolume *v0Plus4Sec11 = new TGeoVolume("V0Plus4Sec11",sV0PlusR4,medV0PlusSci); TGeoVolume *v0Plus5Sec11 = new TGeoVolume("V0Plus5Sec11",sV0PlusR5,medV0PlusSci); v0Plus1Sec11->SetLineColor(kV0PlusColorSci); v0Plus2Sec11->SetLineColor(kV0PlusColorSci); v0Plus3Sec11->SetLineColor(kV0PlusColorSci); v0Plus4Sec11->SetLineColor(kV0PlusColorSci); v0Plus5Sec11->SetLineColor(kV0PlusColorSci); TGeoVolume *v0PlusSciSec11 = new TGeoVolumeAssembly("V0PlusSciSec11"); v0PlusSciSec11->AddNode(v0Plus1Sec11,1); v0PlusSciSec11->AddNode(v0Plus2Sec11,1); v0PlusSciSec11->AddNode(v0Plus3Sec11,1); v0PlusSciSec11->AddNode(v0Plus4Sec11,1); v0PlusSciSec11->AddNode(v0Plus5Sec11,1); TGeoVolume *v0PlusSec11 = new TGeoVolumeAssembly("V0PlusSec11"); v0PlusSec11->AddNode(v0PlusSciSec11,1); TGeoRotation *RotSec11 = new TGeoRotation("RotSec11", 90., 10*22.5, 90., 90.+10*22.5, 0., 0.); v0Plus->AddNode(v0PlusSec11,10+1,RotSec11); /// Definition sector 12 TGeoVolume *v0Plus1Sec12 = new TGeoVolume("V0Plus1Sec12",sV0PlusR1,medV0PlusSci); TGeoVolume *v0Plus2Sec12 = new TGeoVolume("V0Plus2Sec12",sV0PlusR2,medV0PlusSci); TGeoVolume *v0Plus3Sec12 = new TGeoVolume("V0Plus3Sec12",sV0PlusR3,medV0PlusSci); TGeoVolume *v0Plus4Sec12 = new TGeoVolume("V0Plus4Sec12",sV0PlusR4,medV0PlusSci); TGeoVolume *v0Plus5Sec12 = new TGeoVolume("V0Plus5Sec12",sV0PlusR5,medV0PlusSci); v0Plus1Sec12->SetLineColor(kV0PlusColorSci); v0Plus2Sec12->SetLineColor(kV0PlusColorSci); v0Plus3Sec12->SetLineColor(kV0PlusColorSci); v0Plus4Sec12->SetLineColor(kV0PlusColorSci); v0Plus5Sec12->SetLineColor(kV0PlusColorSci); TGeoVolume *v0PlusSciSec12 = new TGeoVolumeAssembly("V0PlusSciSec12"); v0PlusSciSec12->AddNode(v0Plus1Sec12,1); v0PlusSciSec12->AddNode(v0Plus2Sec12,1); v0PlusSciSec12->AddNode(v0Plus3Sec12,1); v0PlusSciSec12->AddNode(v0Plus4Sec12,1); v0PlusSciSec12->AddNode(v0Plus5Sec12,1); TGeoVolume *v0PlusSec12 = new TGeoVolumeAssembly("V0PlusSec12"); v0PlusSec12->AddNode(v0PlusSciSec12,1); TGeoRotation *RotSec12 = new TGeoRotation("RotSec12", 90., 11*22.5, 90., 90.+11*22.5, 0., 0.); v0Plus->AddNode(v0PlusSec12,11+1,RotSec12); /// Definition sector 13 TGeoVolume *v0Plus1Sec13 = new TGeoVolume("V0Plus1Sec13",sV0PlusR1,medV0PlusSci); TGeoVolume *v0Plus2Sec13 = new TGeoVolume("V0Plus2Sec13",sV0PlusR2,medV0PlusSci); TGeoVolume *v0Plus3Sec13 = new TGeoVolume("V0Plus3Sec13",sV0PlusR3,medV0PlusSci); TGeoVolume *v0Plus4Sec13 = new TGeoVolume("V0Plus4Sec13",sV0PlusR4,medV0PlusSci); TGeoVolume *v0Plus5Sec13 = new TGeoVolume("V0Plus5Sec13",sV0PlusR5,medV0PlusSci); v0Plus1Sec13->SetLineColor(kV0PlusColorSci); v0Plus2Sec13->SetLineColor(kV0PlusColorSci); v0Plus3Sec13->SetLineColor(kV0PlusColorSci); v0Plus4Sec13->SetLineColor(kV0PlusColorSci); v0Plus5Sec13->SetLineColor(kV0PlusColorSci); TGeoVolume *v0PlusSciSec13 = new TGeoVolumeAssembly("V0PlusSciSec13"); v0PlusSciSec13->AddNode(v0Plus1Sec13,1); v0PlusSciSec13->AddNode(v0Plus2Sec13,1); v0PlusSciSec13->AddNode(v0Plus3Sec13,1); v0PlusSciSec13->AddNode(v0Plus4Sec13,1); v0PlusSciSec13->AddNode(v0Plus5Sec13,1); TGeoVolume *v0PlusSec13 = new TGeoVolumeAssembly("V0PlusSec13"); v0PlusSec13->AddNode(v0PlusSciSec13,1); TGeoRotation *RotSec13 = new TGeoRotation("RotSec13", 90., 12*22.5, 90., 90.+12*22.5, 0., 0.); v0Plus->AddNode(v0PlusSec13,12+1,RotSec13); /// Definition sector 14 TGeoVolume *v0Plus1Sec14 = new TGeoVolume("V0Plus1Sec14",sV0PlusR1,medV0PlusSci); TGeoVolume *v0Plus2Sec14 = new TGeoVolume("V0Plus2Sec14",sV0PlusR2,medV0PlusSci); TGeoVolume *v0Plus3Sec14 = new TGeoVolume("V0Plus3Sec14",sV0PlusR3,medV0PlusSci); TGeoVolume *v0Plus4Sec14 = new TGeoVolume("V0Plus4Sec14",sV0PlusR4,medV0PlusSci); TGeoVolume *v0Plus5Sec14 = new TGeoVolume("V0Plus5Sec14",sV0PlusR5,medV0PlusSci); v0Plus1Sec14->SetLineColor(kV0PlusColorSci); v0Plus2Sec14->SetLineColor(kV0PlusColorSci); v0Plus3Sec14->SetLineColor(kV0PlusColorSci); v0Plus4Sec14->SetLineColor(kV0PlusColorSci); v0Plus5Sec14->SetLineColor(kV0PlusColorSci); TGeoVolume *v0PlusSciSec14 = new TGeoVolumeAssembly("V0PlusSciSec14"); v0PlusSciSec14->AddNode(v0Plus1Sec14,1); v0PlusSciSec14->AddNode(v0Plus2Sec14,1); v0PlusSciSec14->AddNode(v0Plus3Sec14,1); v0PlusSciSec14->AddNode(v0Plus4Sec14,1); v0PlusSciSec14->AddNode(v0Plus5Sec14,1); TGeoVolume *v0PlusSec14 = new TGeoVolumeAssembly("V0PlusSec14"); v0PlusSec14->AddNode(v0PlusSciSec14,1); TGeoRotation *RotSec14 = new TGeoRotation("RotSec14", 90., 13*22.5, 90., 90.+13*22.5, 0., 0.); v0Plus->AddNode(v0PlusSec14,13+1,RotSec14); /// Definition sector 15 TGeoVolume *v0Plus1Sec15 = new TGeoVolume("V0Plus1Sec15",sV0PlusR1,medV0PlusSci); TGeoVolume *v0Plus2Sec15 = new TGeoVolume("V0Plus2Sec15",sV0PlusR2,medV0PlusSci); TGeoVolume *v0Plus3Sec15 = new TGeoVolume("V0Plus3Sec15",sV0PlusR3,medV0PlusSci); TGeoVolume *v0Plus4Sec15 = new TGeoVolume("V0Plus4Sec15",sV0PlusR4,medV0PlusSci); TGeoVolume *v0Plus5Sec15 = new TGeoVolume("V0Plus5Sec15",sV0PlusR5,medV0PlusSci); v0Plus1Sec15->SetLineColor(kV0PlusColorSci); v0Plus2Sec15->SetLineColor(kV0PlusColorSci); v0Plus3Sec15->SetLineColor(kV0PlusColorSci); v0Plus4Sec15->SetLineColor(kV0PlusColorSci); v0Plus5Sec15->SetLineColor(kV0PlusColorSci); TGeoVolume *v0PlusSciSec15 = new TGeoVolumeAssembly("V0PlusSciSec15"); v0PlusSciSec15->AddNode(v0Plus1Sec15,1); v0PlusSciSec15->AddNode(v0Plus2Sec15,1); v0PlusSciSec15->AddNode(v0Plus3Sec15,1); v0PlusSciSec15->AddNode(v0Plus4Sec15,1); v0PlusSciSec15->AddNode(v0Plus5Sec15,1); TGeoVolume *v0PlusSec15 = new TGeoVolumeAssembly("V0PlusSec15"); v0PlusSec15->AddNode(v0PlusSciSec15,1); TGeoRotation *RotSec15 = new TGeoRotation("RotSec15", 90., 14*22.5, 90., 90.+14*22.5, 0., 0.); v0Plus->AddNode(v0PlusSec15,14+1,RotSec15); /// Definition sector 16 TGeoVolume *v0Plus1Sec16 = new TGeoVolume("V0Plus1Sec16",sV0PlusR1,medV0PlusSci); TGeoVolume *v0Plus2Sec16 = new TGeoVolume("V0Plus2Sec16",sV0PlusR2,medV0PlusSci); TGeoVolume *v0Plus3Sec16 = new TGeoVolume("V0Plus3Sec16",sV0PlusR3,medV0PlusSci); TGeoVolume *v0Plus4Sec16 = new TGeoVolume("V0Plus4Sec16",sV0PlusR4,medV0PlusSci); TGeoVolume *v0Plus5Sec16 = new TGeoVolume("V0Plus5Sec16",sV0PlusR5,medV0PlusSci); v0Plus1Sec16->SetLineColor(kV0PlusColorSci); v0Plus2Sec16->SetLineColor(kV0PlusColorSci); v0Plus3Sec16->SetLineColor(kV0PlusColorSci); v0Plus4Sec16->SetLineColor(kV0PlusColorSci); v0Plus5Sec16->SetLineColor(kV0PlusColorSci); TGeoVolume *v0PlusSciSec16 = new TGeoVolumeAssembly("V0PlusSciSec16"); v0PlusSciSec16->AddNode(v0Plus1Sec16,1); v0PlusSciSec16->AddNode(v0Plus2Sec16,1); v0PlusSciSec16->AddNode(v0Plus3Sec16,1); v0PlusSciSec16->AddNode(v0Plus4Sec16,1); v0PlusSciSec16->AddNode(v0Plus5Sec16,1); TGeoVolume *v0PlusSec16 = new TGeoVolumeAssembly("V0PlusSec16"); v0PlusSec16->AddNode(v0PlusSciSec16,1); TGeoRotation *RotSec16 = new TGeoRotation("RotSec16", 90., 15*22.5, 90., 90.+15*22.5, 0., 0.); v0Plus->AddNode(v0PlusSec16,15+1,RotSec16); alice->AddNode(v0Plus,1,new TGeoTranslation(0, 0, fV0PlusZposition)); } //------------------------------------------------------------------------ void AliFITv7::AddAlignableVolumes() const { // // Create entries for alignable volumes associating the symbolic volume // name with the corresponding volume path. Needs to be syncronized with // eventual changes in the geometry. // TString volPath; TString symName, sn; TString vpAalign = "/ALIC_1/0STL_1"; TString vpCalign = "/ALIC_1/0STR_1"; for (Int_t imod=0; imod<2; imod++) { if (imod==0) {volPath = vpCalign; symName="/ALIC_1/0STL"; } if (imod==1) {volPath = vpAalign; symName="/ALIC_1/0STR"; } AliDebug(2,"--------------------------------------------"); AliDebug(2,Form("volPath=%s\n",volPath.Data())); AliDebug(2,Form("symName=%s\n",symName.Data())); AliDebug(2,"--------------------------------------------"); if(!gGeoManager->SetAlignableEntry(symName.Data(),volPath.Data())) AliFatal(Form("Alignable entry %s not created. Volume path %s not valid", symName.Data(),volPath.Data())); } } //------------------------------------------------------------------------ void AliFITv7::CreateMaterials() { Int_t isxfld = ((AliMagF*)TGeoGlobalMagField::Instance()->GetField())->Integ(); Float_t sxmgmx = ((AliMagF*)TGeoGlobalMagField::Instance()->GetField())->Max(); // Float_t a,z,d,radl,absl,buf[1]; // Int_t nbuf; // AIR Float_t aAir[4]={12.0107,14.0067,15.9994,39.948}; Float_t zAir[4]={6.,7.,8.,18.}; Float_t wAir[4]={0.000124,0.755267,0.231781,0.012827}; Float_t dAir = 1.20479E-3; Float_t dAir1 = 1.20479E-11; // Radiator glass SiO2 Float_t aglass[2]={28.0855,15.9994}; Float_t zglass[2]={14.,8.}; Float_t wglass[2]={1.,2.}; Float_t dglass=2.65; // MCP glass SiO2 Float_t dglass_mcp=1.3; //*** Definition Of avaible T0 materials *** AliMixture(1, "Vacuum$", aAir, zAir, dAir1,4,wAir); AliMixture(2, "Air$", aAir, zAir, dAir,4,wAir); AliMixture( 4, "MCP glass $",aglass,zglass,dglass_mcp,-2,wglass); AliMixture( 24, "Radiator Optical glass$",aglass,zglass,dglass,-2,wglass); AliMaterial(11, "Aliminium$", 26.98, 13.0, 2.7, 8.9,999); AliMedium(1, "Air$", 2, 0, isxfld, sxmgmx, 10., .1, 1., .003, .003); AliMedium(3, "Vacuum$", 1, 0, isxfld, sxmgmx, 10., .01, .1, .003, .003); AliMedium(6, "Glass$", 4, 0, isxfld, sxmgmx, 10., .01, .1, .003, .003); AliMedium(7, "OpAir$", 2, 0, isxfld, sxmgmx, 10., .1, 1., .003, .003); AliMedium(15, "Aluminium$", 11, 0, isxfld, sxmgmx, 10., .01, 1., .003, .003); AliMedium(16, "OpticalGlass$", 24, 1, isxfld, sxmgmx, 10., .01, .1, .003, .003); AliMedium(19, "OpticalGlassCathode$", 24, 1, isxfld, sxmgmx, 10., .01, .1, .003, .003); AliMedium(22, "SensAir$", 2, 1, isxfld, sxmgmx, 10., .1, 1., .003, .003); //V0+ // Parameters for simulation scope Int_t FieldType = ((AliMagF*)TGeoGlobalMagField::Instance()->GetField())->Integ(); // Field type Double_t MaxField = ((AliMagF*)TGeoGlobalMagField::Instance()->GetField())->Max(); // Field max. Double_t MaxBending = 10; // Max Angle Double_t MaxStepSize = 0.01; // Max step size Double_t MaxEnergyLoss = 1; // Max Delta E Double_t Precision = 0.003; // Precision Double_t MinStepSize = 0.003; // Minimum step size Int_t Id; Double_t A, Z, RadLength, AbsLength; Float_t Density, as[4], zs[4], ws[4]; // Parameters for V0Plusscintilator: BC404 as[0] = 1.00794; as[1] = 12.011; zs[0] = 1.; zs[1] = 6.; ws[0] = 5.21; ws[1] = 4.74; Density = 1.032; Id = 5; AliMixture(Id, "V0PlusSci", as, zs, Density, -2, ws); AliMedium(Id, "V0PlusSci", Id, 1, FieldType, MaxField, MaxBending, MaxStepSize, MaxEnergyLoss, Precision, MinStepSize); AliDebugClass(1,": ++++++++++++++Medium set++++++++++"); } //------------------------------------------------------------------- void AliFITv7::DefineOpticalProperties() { // Path of the optical properties input file TString optPropPath = "$(ALICE_ROOT)/FIT/sim/quartzOptProperties.txt"; optPropPath = gSystem->ExpandPathName(optPropPath.Data()); // Expand $(ALICE_ROOT) into real system path // Optical properties definition. Int_t *idtmed = fIdtmed->GetArray(); // Prepare pointers for arrays read from the input file Float_t *aPckov=NULL; Double_t *dPckov=NULL; Float_t *aAbsSiO2=NULL; Float_t *rindexSiO2=NULL; Float_t *qeff = NULL; Int_t kNbins=0; ReadOptProperties(optPropPath.Data(), &aPckov, &dPckov, &aAbsSiO2, &rindexSiO2, &qeff, kNbins); // set QE fPMTeff = new TGraph(kNbins,aPckov,qeff); // Prepare pointers for arrays with constant and hardcoded values (independent on wavelength) Float_t *efficAll=NULL; Float_t *rindexAir=NULL; Float_t *absorAir=NULL; Float_t *rindexCathodeNext=NULL; Float_t *absorbCathodeNext=NULL; Double_t *efficMet=NULL; Double_t *aReflMet=NULL; FillOtherOptProperties(&efficAll, &rindexAir, &absorAir, &rindexCathodeNext, &absorbCathodeNext, &efficMet, &aReflMet, kNbins); TVirtualMC::GetMC()->SetCerenkov (idtmed[kOpGlass], kNbins, aPckov, aAbsSiO2, efficAll, rindexSiO2); // TVirtualMC::GetMC()->SetCerenkov (idtmed[kOpGlassCathode], kNbins, aPckov, aAbsSiO2, effCathode, rindexSiO2); TVirtualMC::GetMC()->SetCerenkov (idtmed[kOpGlassCathode], kNbins, aPckov, aAbsSiO2, efficAll, rindexSiO2); // TVirtualMC::GetMC()->SetCerenkov (idtmed[kOpAir], kNbins, aPckov, absorAir ,efficAll, rindexAir); // TVirtualMC::GetMC()->SetCerenkov (idtmed[kOpAirNext], kNbins, aPckov, absorbCathodeNext, efficAll, rindexCathodeNext); //Define a border for radiator optical properties // TODO: Maciek: The following 3 lines just generate warnings and do nothing else - could be deleted TVirtualMC::GetMC()->DefineOpSurface("surfRd", kUnified /*kGlisur*/,kDielectric_metal,kPolished, 0.); TVirtualMC::GetMC()->SetMaterialProperty("surfRd", "EFFICIENCY", kNbins, dPckov, efficMet); TVirtualMC::GetMC()->SetMaterialProperty("surfRd", "REFLECTIVITY", kNbins, dPckov, aReflMet); DeleteOptPropertiesArr(&aPckov, &dPckov, &aAbsSiO2, &rindexSiO2, &efficAll, &rindexAir, &absorAir, &rindexCathodeNext, &absorbCathodeNext, &efficMet, &aReflMet); } //------------------------------------------------------------------- void AliFITv7::Init() { // Initialises version 0 of the Forward Multiplicity Detector // AliFIT::Init(); fIdSens1=TVirtualMC::GetMC()->VolId("0REG"); // fIdSens1=TVirtualMC::GetMC()->VolId("0TOP"); //Defining the sensitive volumes for (Int_t Sec = 0; Sec < nSectors; Sec++) { for (Int_t Ring = 0; Ring < nRings; Ring++) { fIdV0Plus[Sec][Ring] = TVirtualMC::GetMC()->VolId(Form("V0Plus%dSec%d",Ring+1,Sec+1)); } } AliDebug(1,Form("%s: *** FIT version 1 initialized ***\n",ClassName())); } //------------------------------------------------------------------- void AliFITv7::StepManager() { // // Called for every step in the T0 Detector // Int_t id,copy,copy1; static Float_t hits[13]; static Int_t vol[3]; TLorentzVector pos; TLorentzVector mom; // TClonesArray &lhits = *fHits; if(!TVirtualMC::GetMC()->IsTrackAlive()) return; // particle has disappeared id=TVirtualMC::GetMC()->CurrentVolID(copy); // Check the sensetive volume // printf("T0 :::volumes %i %s \n", id, TVirtualMC::GetMC()->CurrentVolName() ); if(id==fIdSens1 ) { if(TVirtualMC::GetMC()->IsTrackEntering()) { TVirtualMC::GetMC()->CurrentVolOffID(1,copy1); vol[1] = copy1; vol[0]=copy; TVirtualMC::GetMC()->TrackPosition(pos); TVirtualMC::GetMC()->TrackMomentum(mom); Float_t Pt = TMath::Sqrt( mom.Px() * mom.Px() + mom.Py() * mom.Py() ); TParticle *Particle = gAlice->GetMCApp()->Particle(gAlice->GetMCApp()->GetCurrentTrackNumber()); hits[0] = pos[0]; hits[1] = pos[1]; hits[2] = pos[2]; if(pos[2]<0) vol[2] = 0; else vol[2] = 1; Float_t etot=TVirtualMC::GetMC()->Etot(); hits[3]=etot; Int_t iPart= TVirtualMC::GetMC()->TrackPid(); Int_t partID=TVirtualMC::GetMC()->IdFromPDG(iPart); hits[4]=partID; Float_t ttime=TVirtualMC::GetMC()->TrackTime(); hits[5]=ttime*1e12; hits[6] = TVirtualMC::GetMC()->TrackCharge(); hits[7] = mom.Px(); hits[8] = mom.Py(); hits[9] = mom.Pz(); hits[10] = fSenseless;//Energy loss is sensless for T0+ hits[11] = fSenseless;//Track length is sensless for T0+ hits[12] = fSenseless;//Photon production for V0+ // printf("T0 :::volumes pmt %i mcp %i vol %i x %f y %f z %f particle %f all \n", vol[0], vol[1], vol[2], hits[0], hits[1], hits[2], hits[4]); if (TVirtualMC::GetMC()->TrackPid() == 50000050) // If particles is photon then ... { if(RegisterPhotoE(hits[3])) { fIshunt = 2; AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber(),vol,hits); // Create a track reference at the exit of photocatode } } //charge particle HITS if ( TVirtualMC::GetMC()->TrackCharge() ) { fIshunt = 0; AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber(),vol,hits); } //charge particle TrackReference if ( TVirtualMC::GetMC()->TrackCharge() ) AddTrackReference(gAlice->GetMCApp()->GetCurrentTrackNumber(), AliTrackReference::kFIT); }// trck entering } //sensitive //V0+ if ( !gMC->TrackCharge() || !gMC->IsTrackAlive() ) return;//Only interested in charged and alive tracks //Check if there is a hit in any of the V0+ sensitive volumes defined in Init Bool_t IsId = kFALSE; for (Int_t i = 0; i < nSectors; i++) { for (Int_t j = 0; j < nRings; j++) { if ( id == fIdV0Plus[i][j] ) { IsId = kTRUE; break; } } } if ( IsId == kTRUE ) //If yes, then perform the following { //Defining V0+ ring numbers using the sensitive volumes Int_t RingNumber; if ( (id == fIdV0Plus[0][0]) || (id == fIdV0Plus[1][0]) || (id == fIdV0Plus[2][0]) || (id == fIdV0Plus[3][0]) || (id == fIdV0Plus[4][0]) || (id == fIdV0Plus[5][0]) || (id == fIdV0Plus[6][0]) || (id == fIdV0Plus[7][0]) || (id == fIdV0Plus[8][0]) || (id == fIdV0Plus[9][0]) || (id == fIdV0Plus[10][0]) || (id == fIdV0Plus[11][0]) || (id == fIdV0Plus[12][0]) || (id == fIdV0Plus[13][0]) || (id == fIdV0Plus[14][0]) || (id == fIdV0Plus[15][0]) ) RingNumber = 1; else if ( (id == fIdV0Plus[0][1]) || (id == fIdV0Plus[1][1]) || (id == fIdV0Plus[2][1]) || (id == fIdV0Plus[3][1]) || (id == fIdV0Plus[4][1]) || (id == fIdV0Plus[5][1]) || (id == fIdV0Plus[6][1]) || (id == fIdV0Plus[7][1]) || (id == fIdV0Plus[8][1]) || (id == fIdV0Plus[9][1]) || (id == fIdV0Plus[10][1]) || (id == fIdV0Plus[11][1]) || (id == fIdV0Plus[12][1]) || (id == fIdV0Plus[13][1]) || (id == fIdV0Plus[14][1]) || (id == fIdV0Plus[15][1]) ) RingNumber = 2; else if ( (id == fIdV0Plus[0][2]) || (id == fIdV0Plus[1][2]) || (id == fIdV0Plus[2][2]) || (id == fIdV0Plus[3][2]) || (id == fIdV0Plus[4][2]) || (id == fIdV0Plus[5][2]) || (id == fIdV0Plus[6][2]) || (id == fIdV0Plus[7][2]) || (id == fIdV0Plus[8][2]) || (id == fIdV0Plus[9][2]) || (id == fIdV0Plus[10][2]) || (id == fIdV0Plus[11][2]) || (id == fIdV0Plus[12][2]) || (id == fIdV0Plus[13][2]) || (id == fIdV0Plus[14][2]) || (id == fIdV0Plus[15][2]) ) RingNumber = 3; else if ( (id == fIdV0Plus[0][3]) || (id == fIdV0Plus[1][3]) || (id == fIdV0Plus[2][3]) || (id == fIdV0Plus[3][3]) || (id == fIdV0Plus[4][3]) || (id == fIdV0Plus[5][3]) || (id == fIdV0Plus[6][3]) || (id == fIdV0Plus[7][3]) || (id == fIdV0Plus[8][3]) || (id == fIdV0Plus[9][3]) || (id == fIdV0Plus[10][3]) || (id == fIdV0Plus[11][3]) || (id == fIdV0Plus[12][3]) || (id == fIdV0Plus[13][3]) || (id == fIdV0Plus[14][3]) || (id == fIdV0Plus[15][3]) ) RingNumber = 4; else if ( (id == fIdV0Plus[0][4]) || (id == fIdV0Plus[1][4]) || (id == fIdV0Plus[2][4]) || (id == fIdV0Plus[3][4]) || (id == fIdV0Plus[4][4]) || (id == fIdV0Plus[5][4]) || (id == fIdV0Plus[6][4]) || (id == fIdV0Plus[7][4]) || (id == fIdV0Plus[8][4]) || (id == fIdV0Plus[9][4]) || (id == fIdV0Plus[10][4]) || (id == fIdV0Plus[11][4]) || (id == fIdV0Plus[12][4]) || (id == fIdV0Plus[13][4]) || (id == fIdV0Plus[14][4]) || (id == fIdV0Plus[15][4]) ) RingNumber = 5; else RingNumber = 0; if ( RingNumber ) { if(TVirtualMC::GetMC()->IsTrackEntering()) { TVirtualMC::GetMC()->TrackPosition(pos); TVirtualMC::GetMC()->TrackMomentum(mom); Float_t Pt = TMath::Sqrt( mom.Px() * mom.Px() + mom.Py() * mom.Py() ); TParticle *Particle = gAlice->GetMCApp()->Particle(gAlice->GetMCApp()->GetCurrentTrackNumber()); hits[0] = pos[0]; hits[1] = pos[1]; hits[2] = pos[2]; Float_t etot=TVirtualMC::GetMC()->Etot(); hits[3]=etot; Int_t iPart= TVirtualMC::GetMC()->TrackPid(); Int_t partID=TVirtualMC::GetMC()->IdFromPDG(iPart); hits[4]=partID; Float_t ttime=TVirtualMC::GetMC()->TrackTime(); hits[5]=ttime*1e12; hits[6] = TVirtualMC::GetMC()->TrackCharge(); hits[7] = mom.Px(); hits[8] = mom.Py(); hits[9] = mom.Pz(); }//Track entering if( gMC->IsTrackExiting() || gMC->IsTrackStop() || gMC->IsTrackDisappeared()) { Float_t Eloss, Tlength; Float_t EnergyDep = TVirtualMC::GetMC()->Edep(); Float_t Step = TVirtualMC::GetMC()->TrackStep();//Energy loss in the current step Int_t nPhotonsInStep = 0; Int_t nPhotons = 0; nPhotonsInStep = Int_t(EnergyDep / (fV0PlusLightYield*1e-9) ); nPhotons = nPhotonsInStep - Int_t((Float_t(nPhotonsInStep) * fV0PlusLightAttenuation * fV0PlusnMeters)); nPhotons = nPhotons - Int_t( Float_t(nPhotons) * fV0PlusFibToPhot); Eloss += EnergyDep; Tlength += Step; hits[10] = Eloss; hits[11] = Tlength; hits[12] = nPhotons; vol[0] = GetCellId(vol); vol[1] = RingNumber; vol[2] = 2; fIshunt = 0; AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber(), vol, hits); AddTrackReference(gAlice->GetMCApp()->GetCurrentTrackNumber(), AliTrackReference::kFIT); Tlength = 0.0; Eloss = 0.0; }//Exiting, stopped or disappeared track }//Ring number } } //------------------------------------------------------------------------ Bool_t AliFITv7::RegisterPhotoE(Double_t energy) { // Float_t hc=197.326960*1.e6; //mev*nm Double_t hc=1.973*1.e-6; //gev*nm Float_t lambda=hc/energy; Float_t eff = fPMTeff->Eval(lambda); Double_t p = gRandom->Rndm(); if (p > eff) return kFALSE; return kTRUE; } //---------------------------------------------------------------------------- //------------------------------------------------------------------------- Int_t AliFITv7::GetCellId(Int_t *vol) { fCellId = 0; if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0Plus1Sec1")) fCellId = 1; if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0Plus1Sec2")) fCellId = 2; if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0Plus1Sec3")) fCellId = 3; if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0Plus1Sec4")) fCellId = 4; if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0Plus1Sec5")) fCellId = 5; if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0Plus1Sec6")) fCellId = 6; if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0Plus1Sec7")) fCellId = 7; if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0Plus1Sec8")) fCellId = 8; if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0Plus1Sec9")) fCellId = 9; if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0Plus1Sec10")) fCellId = 10; if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0Plus1Sec11")) fCellId = 11; if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0Plus1Sec12")) fCellId = 12; if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0Plus1Sec13")) fCellId = 13; if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0Plus1Sec14")) fCellId = 14; if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0Plus1Sec15")) fCellId = 15; if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0Plus1Sec16")) fCellId = 16; if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0Plus2Sec1")) fCellId = 17; if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0Plus2Sec2")) fCellId = 18; if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0Plus2Sec3")) fCellId = 19; if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0Plus2Sec4")) fCellId = 20; if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0Plus2Sec5")) fCellId = 21; if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0Plus2Sec6")) fCellId = 22; if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0Plus2Sec7")) fCellId = 23; if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0Plus2Sec8")) fCellId = 24; if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0Plus2Sec9")) fCellId = 25; if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0Plus2Sec10")) fCellId = 26; if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0Plus2Sec11")) fCellId = 27; if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0Plus2Sec12")) fCellId = 28; if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0Plus2Sec13")) fCellId = 29; if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0Plus2Sec14")) fCellId = 30; if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0Plus2Sec15")) fCellId = 31; if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0Plus2Sec16")) fCellId = 32; if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0Plus3Sec1")) fCellId = 33; if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0Plus3Sec2")) fCellId = 34; if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0Plus3Sec3")) fCellId = 35; if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0Plus3Sec4")) fCellId = 36; if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0Plus3Sec5")) fCellId = 37; if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0Plus3Sec6")) fCellId = 38; if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0Plus3Sec7")) fCellId = 39; if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0Plus3Sec8")) fCellId = 40; if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0Plus3Sec9")) fCellId = 41; if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0Plus3Sec10")) fCellId = 42; if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0Plus3Sec11")) fCellId = 43; if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0Plus3Sec12")) fCellId = 44; if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0Plus3Sec13")) fCellId = 45; if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0Plus3Sec14")) fCellId = 46; if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0Plus3Sec15")) fCellId = 47; if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0Plus3Sec16")) fCellId = 48; if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0Plus4Sec1")) fCellId = 49; if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0Plus4Sec2")) fCellId = 50; if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0Plus4Sec3")) fCellId = 51; if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0Plus4Sec4")) fCellId = 52; if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0Plus4Sec5")) fCellId = 53; if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0Plus4Sec6")) fCellId = 54; if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0Plus4Sec7")) fCellId = 55; if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0Plus4Sec8")) fCellId = 56; if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0Plus4Sec9")) fCellId = 57; if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0Plus4Sec10")) fCellId = 58; if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0Plus4Sec11")) fCellId = 59; if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0Plus4Sec12")) fCellId = 60; if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0Plus4Sec13")) fCellId = 61; if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0Plus4Sec14")) fCellId = 62; if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0Plus4Sec15")) fCellId = 63; if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0Plus4Sec16")) fCellId = 64; if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0Plus5Sec1")) fCellId = 65; if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0Plus5Sec2")) fCellId = 66; if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0Plus5Sec3")) fCellId = 67; if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0Plus5Sec4")) fCellId = 68; if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0Plus5Sec5")) fCellId = 69; if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0Plus5Sec6")) fCellId = 70; if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0Plus5Sec7")) fCellId = 71; if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0Plus5Sec8")) fCellId = 72; if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0Plus5Sec9")) fCellId = 73; if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0Plus5Sec10")) fCellId = 74; if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0Plus5Sec11")) fCellId = 75; if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0Plus5Sec12")) fCellId = 76; if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0Plus5Sec13")) fCellId = 77; if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0Plus5Sec14")) fCellId = 78; if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0Plus5Sec15")) fCellId = 79; if (gMC->CurrentVolID(vol[2]) == gMC->VolId("V0Plus5Sec16")) fCellId = 80; return fCellId; } //----------------------------------------------------------------- Int_t AliFITv7::ReadOptProperties(const std::string filePath, Float_t **e, Double_t **de, Float_t **abs, Float_t **n, Float_t **qe, Int_t &kNbins) const{ std::ifstream infile; infile.open(filePath.c_str()); // Check if file is opened correctly if(infile.fail()==true){ AliFatal(Form("Error opening ascii file: %s", filePath.c_str())); return -1; } std::string comment; // dummy, used just to read 4 first lines and move the cursor to the 5th, otherwise unused if(!getline(infile,comment)){ // first comment line AliFatal(Form("Error opening ascii file (it is probably a folder!): %s", filePath.c_str())); return -2; } getline(infile,comment); // 2nd comment line // Get number of elements required for the array infile >> kNbins; if(kNbins<0 || kNbins>1e4){ AliFatal(Form("Input arraySize out of range 0..1e4: %i. Check input file: %s", kNbins, filePath.c_str())); return -4; } // Allocate memory required for arrays *e = new Float_t[kNbins]; *de = new Double_t[kNbins]; *abs = new Float_t[kNbins]; *n = new Float_t[kNbins]; *qe = new Float_t[kNbins]; getline(infile,comment); // finish 3rd line after the nEntries are read getline(infile,comment); // 4th comment line // read the main body of the file (table of values: energy, absorption length and refractive index) Int_t iLine=0; std::string sLine; getline(infile, sLine); while(!infile.eof()){ if(iLine >= kNbins){ AliFatal(Form("Line number: %i reaches range of declared arraySize: %i. Check input file: %s", iLine, kNbins, filePath.c_str())); return -5; } std::stringstream ssLine(sLine); ssLine >> (*de)[iLine]; (*de)[iLine] *= 1e-9; // Convert eV -> GeV immediately (*e)[iLine] = static_cast<Float_t> ((*de)[iLine]); // same value, different precision ssLine >> (*abs)[iLine]; ssLine >> (*n)[iLine]; ssLine >> (*qe)[iLine]; if(!(ssLine.good() || ssLine.eof())){ // check if there were problems with numbers conversion AliFatal(Form("Error while reading line %i: %s", iLine, ssLine.str().c_str())); return -6; } getline(infile, sLine); iLine++; } if(iLine != kNbins){ AliFatal(Form("Total number of lines %i is different than declared %i. Check input file: %s", iLine, kNbins, filePath.c_str())); return -7; } AliInfo(Form("Optical properties taken from the file: %s. Number of lines read: %i",filePath.c_str(),iLine)); return 0; } void AliFITv7::FillOtherOptProperties(Float_t **efficAll, Float_t **rindexAir, Float_t **absorAir, Float_t **rindexCathodeNext, Float_t **absorbCathodeNext, Double_t **efficMet, Double_t **aReflMet, const Int_t kNbins) const{ // Allocate memory for these arrays according to the required size *efficAll = new Float_t[kNbins]; *rindexAir = new Float_t[kNbins]; *absorAir = new Float_t[kNbins]; *rindexCathodeNext = new Float_t[kNbins]; *absorbCathodeNext = new Float_t[kNbins]; *efficMet = new Double_t[kNbins]; *aReflMet = new Double_t[kNbins]; // Set constant values to the arrays for(Int_t i=0; i<kNbins; i++) { (*efficAll)[i]=1.; (*rindexAir)[i] = 1.; (*absorAir)[i]=0.3; (*rindexCathodeNext)[i]=0; (*absorbCathodeNext)[i]=0; (*efficMet)[i]=0.; (*aReflMet)[i]=1.; } } void AliFITv7::DeleteOptPropertiesArr(Float_t **e, Double_t **de, Float_t **abs, Float_t **n, Float_t **efficAll, Float_t **rindexAir, Float_t **absorAir, Float_t **rindexCathodeNext, Float_t **absorbCathodeNext, Double_t **efficMet, Double_t **aReflMet) const{ delete [] (*e); delete [] (*de); delete [] (*abs); delete [] (*n); delete [] (*efficAll); delete [] (*rindexAir); delete [] (*absorAir); delete [] (*rindexCathodeNext); delete [] (*absorbCathodeNext); delete [] (*efficMet); delete [] (*aReflMet); }
[ "Alla.Maevskaya@cern.ch" ]
Alla.Maevskaya@cern.ch
294305bf47ed1270af5416d2311191dd22825a2c
0acc8e77e1b3ac1e82d6d7ff2f339a28e80cbbd7
/2010-2018/CPP/AceProject/client/src/Engine/GameFrame.cpp
cdcd0838d5e725ff8fcc0259ca28dd98165d9894
[]
no_license
dev4robi/portfolio
5adbf1f384702649ec8e5a167134af5b9da022a9
98e93a2bf51e6430e5d0946098b5b0e0a8841549
refs/heads/master
2020-05-22T07:09:27.956348
2019-05-12T14:18:00
2019-05-12T14:18:00
null
0
0
null
null
null
null
UHC
C++
false
false
5,200
cpp
#include "Engine/GameWidget.h" #include "Engine/GameFrame.h" #include "Game/Object/Skybox.h" #include "Game/Object/Player.h" GameFrame::GameFrame(wstring name) : GameObject() { // 게임 매니저 설정 g_pGameManager->setGameFrame(this); // 위젯이 생성과 동시에 GameFrame의 리스트에 추가되는데, 일부 Frame의 생성자에서 위젯을 생성하므로 여기서 게임 프레임을 선지정 해주어야 한다. if ((pGameManager = g_pGameManager) == NULL) { MessageBox(NULL, TEXT("Fail to construct GameFrame"), TEXT("GameFrame::GameFrame(wstring name) : g_pGameManager is NULL."), (MB_OK | MB_ICONINFORMATION)); return; } // 드로우 매니저 설정 if ((pDrawManager = pGameManager->getDrawManagerPtr()) == NULL) { MessageBox(NULL, TEXT("Fail to construct GameFrame"), TEXT("GameFrame::GameFrame(wstring name) : pDrawManager is NULL."), (MB_OK | MB_ICONINFORMATION)); return; } // 인풋 매니저 설정 if ((pInputManager = pGameManager->getInputManagerPtr()) == NULL) { MessageBox(NULL, TEXT("Fail to construct GameFrame"), TEXT("GameFrame::GameFrame(wstring name) : pInputManager is NULL."), (MB_OK | MB_ICONINFORMATION)); return; } // 리소스 매니저 설정 if ((pResourceManager = pGameManager->getResourceManagerPtr()) == NULL) { MessageBox(NULL, TEXT("Fail to construct GameFrame"), TEXT("GameFrame::GameFrame(wstring name) : pResourceManager is NULL."), (MB_OK | MB_ICONINFORMATION)); return; } // 사운드 매니저 설정 if ((pSoundManager = pGameManager->getSoundManagerPtr()) == NULL) { MessageBox(NULL, TEXT("Fail to construct GameFrame"), TEXT("GameFrame::GameFrame(wstring name) : pSoundManager is NULL."), (MB_OK | MB_ICONINFORMATION)); return; } // 네트워크 매니저 설정 if ((pNetworkManager = pGameManager->getNetworkManagerPtr()) == NULL) { MessageBox(NULL, TEXT("Fail to construct GameFrame"), TEXT("GameFrame::GameFrame(wstring name) : pNetworkManager is NULL."), (MB_OK | MB_ICONINFORMATION)); return; } // 플레이어를 NULL로 설정 pOwnerPlayer = NULL; // 배경 하늘과 지형을 NULL로 설정 pSkybox = NULL; pTerrain = NULL; // 배경 음악을 NULL로 설정 pBackgroundSound = NULL; // 프레임 이름 설정 wsFrameName = name; // 생성 시간 dwCreatedTime = g_pGameManager->getElapsedTime(); } GameFrame::~GameFrame() { // 이펙트 리스트 파괴 GL_Effect *pEffect = NULL; for (list<GL_Effect*>::iterator iterEffect = effectList.begin(); iterEffect != effectList.end();) { pEffect = (*iterEffect); iterEffect = effectList.erase(iterEffect); if (pEffect != NULL) delete pEffect; } pEffect = NULL; // 동적 생성된 위젯 파괴 GameWidget *pWidget = NULL; for (list<GameWidget*>::iterator iterWidget = widgetList.begin(); iterWidget != widgetList.end();) { pWidget = (*iterWidget); iterWidget = widgetList.erase(iterWidget); if (pWidget != NULL) delete pWidget; } pWidget = NULL; // 남은 사운드 파괴 if (pSoundManager != NULL) pSoundManager->destroySoundAll(); // 하늘상자 및 지형 파괴 if (pSkybox != NULL) delete pSkybox; if (pTerrain != NULL) delete pTerrain; // 포인터를 NULL로 pTerrain = NULL; pSkybox = NULL; pGameManager = NULL; pDrawManager = NULL; pInputManager = NULL; pResourceManager = NULL; pOwnerPlayer = NULL; pSoundManager = NULL; pNetworkManager = NULL; } bool GameFrame::getNetworkingUse() { return bUseNetworking; } void GameFrame::setNetworkingUse(bool use) { bUseNetworking = use; } DWORD GameFrame::getCreatedTime() { return dwCreatedTime; } wstring GameFrame::getFrameName() { return wsFrameName; } list<GameWidget*>* GameFrame::getDrawListPtr() { return &drawList; } list<GameWidget*>* GameFrame::getWidgetListPtr() { return &widgetList; } list<GL_Effect*>* GameFrame::getEffectListPtr() { return &effectList; } Skybox* GameFrame::getSkyboxPtr() { return pSkybox; } bool GameFrame::setSkybox(Skybox *skyboxPtr) { pSkybox = skyboxPtr; return true; } Terrain* GameFrame::getTerrainPtr() { return pTerrain; } bool GameFrame::setTerrain(Terrain *terrainPtr) { pTerrain = terrainPtr; return true; } Player* GameFrame::getOwnerPlayerPtr() { return pOwnerPlayer; } bool GameFrame::setBackgroundSound(Sound *pSound) { pBackgroundSound = pSound; return true; } Sound* GameFrame::getBackgroundSoundPtr() { return pBackgroundSound; } GameWidget* GameFrame::findWidget(const ID id) { list<GameWidget*>::iterator iter; for (iter = widgetList.begin(); iter != widgetList.end(); ++iter) { if ((*iter)->getID() == id) { return (*iter); } } return NULL; } bool GameFrame::destoryWidget(GameWidget *widgetPtr) { widgetPtr->destroy(); delete widgetPtr; return true; } bool GameFrame::addWidget(GameWidget *widgetPtr) { widgetList.push_back(widgetPtr); return true; } bool GameFrame::addEffect(GL_Effect *pEffect) { effectList.push_back(pEffect); return true; } bool GameFrame::removeWidget(GameWidget *widgetPtr) { widgetList.remove(widgetPtr); return true; } void GameFrame::updateKey(REAL timeElapsed) { // 가상 함수 } bool GameFrame::updateFrame(REAL timeElapsed) { // 가상 함수 return true; }
[ "dev4robi@gmail.com" ]
dev4robi@gmail.com
980213cd515815184ac5fc505693f29ab87efa19
12dba981b6027e873846850666f6ab1ccc40ab07
/OnDiskIndex.cpp
d612e824fd62f1e16be2b72b5be34be497d3b609
[ "BSD-3-Clause" ]
permissive
chubbymaggie/ursadb
56d0fab5327c9f3ccda430d86fd19b3b2d79c48e
6e16de8b18ad20195e5b6d7bd8cb18330a2d4b7e
refs/heads/master
2020-03-19T21:18:56.432473
2018-05-26T22:23:10
2018-05-26T22:23:10
null
0
0
null
null
null
null
UTF-8
C++
false
false
5,656
cpp
#include "OnDiskIndex.h" #include <algorithm> #include <cstring> #include <fstream> #include <iostream> #include "Query.h" #include "Utils.h" OnDiskIndex::OnDiskIndex(const std::string &fname) : disk_map(fname) { constexpr uint64_t RUN_OFFSET_ARRAY_SIZE = (NUM_TRIGRAMS + 1) * sizeof(uint64_t); if (disk_map.size() < 16 + RUN_OFFSET_ARRAY_SIZE) { throw std::runtime_error("corrupted index, file is too small"); } const uint8_t *data = disk_map.data(); uint32_t magic, version, raw_type, reserved; memcpy(&magic, data + 0, sizeof(uint32_t)); memcpy(&version, data + 4, sizeof(uint32_t)); memcpy(&raw_type, data + 8, sizeof(uint32_t)); memcpy(&reserved, data + 12, sizeof(uint32_t)); if (magic != DB_MAGIC) { throw std::runtime_error("invalid magic, not a catdata"); } if (version != OnDiskIndex::VERSION) { throw std::runtime_error("unsupported version"); } if (!is_valid_index_type(raw_type)) { throw std::runtime_error("invalid index type"); } ntype = static_cast<IndexType>(raw_type); run_offsets = (uint64_t *)&data[disk_map.size() - RUN_OFFSET_ARRAY_SIZE]; } bool OnDiskIndex::internal_expand(QString::const_iterator qit, uint8_t *out, size_t pos, size_t comb_len, const TrigramGenerator &gen, QueryResult &res) const { if (pos >= comb_len) { bool was_generated = false; gen(out, comb_len, [&] (TriGram val) { was_generated = true; res.do_or(query_primitive(val)); }); return was_generated; } auto j = (uint8_t)qit->val(); do { out[pos] = j; bool was_generated = internal_expand(qit + 1, out, pos + 1, comb_len, gen, res); if (!was_generated) { // sequence was not recognized by given index // this may happen for indexes like text4 or wide8 return false; } switch (qit->type()) { case QTokenType::CHAR: return true; case QTokenType::WILDCARD: if (j == 0xFF) { return true; } else { ++j; } break; case QTokenType::LWILDCARD: if (j == (qit->val() | 0xFU)) { return true; } else { ++j; } break; case QTokenType::HWILDCARD: if (j == (qit->val() | 0xF0U)) { return true; } else { j += 0x10; } break; } } while (true); } QueryResult OnDiskIndex::expand_wildcards(const QString &qstr, size_t len, const TrigramGenerator &gen) const { uint8_t out[len]; QueryResult total = QueryResult::everything(); if (qstr.size() < len) { return total; } for (unsigned int i = 0; i <= qstr.size() - len; i++) { QueryResult res = QueryResult::empty(); bool success = internal_expand(qstr.cbegin() + i, out, 0, len, gen, res); if (success) { total.do_and(std::move(res)); } } return total; } QueryResult OnDiskIndex::query_str(const QString &str) const { TrigramGenerator generator = get_generator_for(ntype); size_t input_len = 0; switch (index_type()) { case IndexType::GRAM3: input_len = 3; break; case IndexType::HASH4: input_len = 4; break; case IndexType::TEXT4: input_len = 4; break; case IndexType::WIDE8: input_len = 8; break; } if (input_len == 0) { throw std::runtime_error("unhandled index type"); } return expand_wildcards(str, input_len, generator); } std::vector<FileId> OnDiskIndex::query_primitive(TriGram trigram) const { uint64_t ptr = run_offsets[trigram]; uint64_t next_ptr = run_offsets[trigram + 1]; const uint8_t *data = disk_map.data(); if (ptr > next_ptr || next_ptr > disk_map.size()) { // TODO() - Which index? Which run? throw std::runtime_error("internal error: index is corrupted, invalid run"); } return read_compressed_run(&data[ptr], &data[next_ptr]); } void OnDiskIndex::on_disk_merge( const fs::path &db_base, const std::string &fname, IndexType merge_type, const std::vector<IndexMergeHelper> &indexes, Task *task) { std::ofstream out(db_base / fname, std::ofstream::binary | std::ofstream::out); if (!std::all_of(indexes.begin(), indexes.end(), [merge_type](const IndexMergeHelper &ndx) { return ndx.index->ntype == merge_type; })) { throw std::runtime_error("Unexpected index type during merge"); } uint32_t magic = DB_MAGIC; uint32_t version = OnDiskIndex::VERSION; uint32_t ndx_type = (uint32_t)merge_type; uint32_t reserved = 0; out.write((char *)&magic, 4); out.write((char *)&version, 4); out.write((char *)&ndx_type, 4); out.write((char *)&reserved, 4); std::vector<uint64_t> out_offsets(NUM_TRIGRAMS + 1); std::vector<uint64_t> in_offsets(indexes.size()); for (TriGram trigram = 0; trigram < NUM_TRIGRAMS; trigram++) { out_offsets[trigram] = (uint64_t)out.tellp(); std::vector<FileId> all_ids; FileId baseline = 0; for (const IndexMergeHelper &helper : indexes) { std::vector<FileId> new_ids = helper.index->query_primitive(trigram); for (FileId id : new_ids) { all_ids.push_back(id + baseline); } baseline += helper.file_count; } compress_run(all_ids, out); if (task != nullptr) { task->work_done += 1; } } out_offsets[NUM_TRIGRAMS] = (uint64_t)out.tellp(); out.write((char *)out_offsets.data(), (NUM_TRIGRAMS + 1) * sizeof(uint64_t)); }
[ "michal.leszczynski@cert.pl" ]
michal.leszczynski@cert.pl
106e1863128d883775be051102d62900a6bfd6a6
90d62b5fc8bb764c7238e7db99da3459fa8be4ef
/libs/2DGameSDK/include/2DGameSDK/scene/entity/static/SpriteStaticEntity.h
a46aa20a0d92ff30a03b90c680cee116051d956a
[ "MIT" ]
permissive
markoczy/2DGameSDK
1d57c6a2f77e91f73a4d47cb7ca42f21339d2795
53da378d604ace1d931dfe6ec336241045675667
refs/heads/master
2022-03-29T05:17:41.618959
2020-01-16T18:26:01
2020-01-16T18:26:01
177,466,808
4
0
MIT
2019-12-19T18:05:22
2019-03-24T20:40:44
C++
UTF-8
C++
false
false
1,041
h
#ifndef __SPRITE_STATIC_ENTITY_H__ #define __SPRITE_STATIC_ENTITY_H__ #include <vector> #include <SFML/Graphics.hpp> #include <2DGameSDK/core/Game.h> #include <2DGameSDK/dll/gamesdk_dll.h> #include <2DGameSDK/physics/shape/Shape.h> #include <2DGameSDK/physics/shape/definitions/StaticShapeDefinition.h> #include <2DGameSDK/scene/entity/definitions/StaticEntity.h> namespace game { class GAMESDK_DLL SpriteStaticEntity : public StaticEntity { public: SpriteStaticEntity(int type, Game* game, sf::Texture* texture, std::vector<Shape<StaticShapeDefinition>*> shapes = std::vector<Shape<StaticShapeDefinition>*>(), bool isCollidable = false); ~SpriteStaticEntity(); void SetSize(sf::Vector2f size); void OnRender(sf::RenderTarget* target, sf::RenderStates states = sf::RenderStates::Default); virtual void OnTick(); protected: sf::Sprite mSprite; }; } // namespace game #endif
[ "a.markoczy@gmail.com" ]
a.markoczy@gmail.com
1dc5f1d332aa649b67d87c14d0c36f30f1ae7888
91a882547e393d4c4946a6c2c99186b5f72122dd
/Source/XPSP1/NT/multimedia/directx/dxg/d3d/dx7/fe/lists.hpp
047a45ff3bb5617a7436db734aafcb97db9d7e84
[]
no_license
IAmAnubhavSaini/cryptoAlgorithm-nt5src
94f9b46f101b983954ac6e453d0cf8d02aa76fc7
d9e1cdeec650b9d6d3ce63f9f0abe50dabfaf9e2
refs/heads/master
2023-09-02T10:14:14.795579
2021-11-20T13:47:06
2021-11-20T13:47:06
null
0
0
null
null
null
null
UTF-8
C++
false
false
16,005
hpp
/* Copyright (c) 1997 Microsoft Corporation */ /* See the .C test code at the end of this file for examples of how to use this stuff. */ #ifndef _LISTS_H #define _LISTS_H #define LIST_ROOT(name, type) struct name {type *Root;} #define LIST_MEMBER(type) struct { type **Prev; type *Next;} /* Note! Prev is the ADDRESS of the previous next element ptr */ #define LIST_INSERT_ROOT(root,element,field)\ { if(((element)->field.Next = (root)->Root) != 0)\ (root)->Root->field.Prev = &(element)->field.Next;\ (root)->Root = (element);\ (element)->field.Prev = &(root)->Root;\ } #define LIST_DELETE(element,field)\ {\ if((element)->field.Next)\ (element)->field.Next->field.Prev = (element)->field.Prev;\ if ((element)->field.Prev)\ {\ *(element)->field.Prev = (element)->field.Next;\ (element)->field.Prev = 0;\ }\ (element)->field.Next = 0;\ } #define LIST_INITIALIZE(root)\ {\ (root)->Root = 0;\ } #define LIST_INITIALIZE_MEMBER(element,field)\ { (element)->field.Next = 0;\ (element)->field.Prev = 0;\ } #define LIST_ORPHAN_MEMBER(element,field) (!((element)->field.Prev)) #define LIST_FIRST(root) (root)->Root #define LIST_NEXT(element,field) (element)->field.Next #define TAIL_QUEUE_INITIALIZE(root)\ {\ (root)->First = NULL;\ (root)->Last = &(root)->First;\ } #define TAIL_QUEUE_ROOT(name,type)\ struct name\ { type *First;\ type **Last;\ }/* NOTE! This is the address of the last Next pointer. */ #define TAIL_QUEUE_MEMBER(type)\ struct\ { type *Next;\ type **Prev; /* NOTE! Address of previous Next element ptr */\ } #define TAIL_QUEUE_INSERT_END(root,element,field)\ { (element)->field.Prev = (root)->Last;\ (element)->field.Next = 0;\ *(root)->Last = (element);\ (root)->Last = &(element)->field.Next;\ } #define TAIL_QUEUE_DELETE(root,element,field)\ {\ if (((element)->field.Next) != NULL)\ (element)->field.Next->field.Prev = (element)->field.Prev;\ else\ (root)->Last = (element)->field.Prev;\ *(element)->field.Prev = (element)->field.Next;\ (element)->field.Next = 0;\ (element)->field.Prev = 0;\ } #define TAIL_QUEUE_FIRST(root) (root)->First #define TAIL_QUEUE_NEXT(element,field) (element)->field.Next #define CIRCLE_QUEUE_ROOT(name,type)\ struct name\ { type *Last;\ type *First;\ } #define CIRCLE_QUEUE_MEMBER(type)\ struct\ { type *Prev;\ type *Next;\ } #define CIRCLE_QUEUE_INITIALIZE(root,type)\ { (root)->Last = (type *)(root);\ (root)->First = (type *)(root);\ } #define CIRCLE_QUEUE_INITIALIZE_MEMBER(element,field)\ { (element)->field.Next = (element)->field.Prev = 0;\ } #define CIRCLE_QUEUE_INSERT_END(root,type,element,field)\ { (element)->field.Prev = (root)->Last;\ (element)->field.Next = (type *)(root);\ if((root)->First != (type *)(root))\ (root)->Last->field.Next = (element);\ else\ (root)->First = (element);\ (root)->Last = (element);\ } #define CIRCLE_QUEUE_INSERT_ROOT(root,type,element,field)\ { (element)->field.Prev = (type *)(root);\ (element)->field.Next = (root)->First;\ if ((root)->Last != (void *)(root))\ (root)->First->field.Prev = (element);\ else\ (root)->Last = (element);\ (root)->First = (element);\ } #define CIRCLE_QUEUE_INSERT_PREVIOUS(root,current_element,element,field)\ { (element)->field.Prev = (current_element)->field.Prev;\ (element)->field.Next = (current_element);\ if ((current_element)->field.Prev != (void *)(root))\ (current_element)->field.Prev->field.Next = (element);\ else\ (root)->First = (element);\ (current_element)->field.Prev = (element);\ } #define CIRCLE_QUEUE_DELETE(root,element,field)\ { if((element)->field.Next != (void *)(root))\ (element)->field.Next->field.Prev = (element)->field.Prev;\ else\ (root)->Last = (element)->field.Prev;\ if((element)->field.Prev != (void *)(root))\ (element)->field.Prev->field.Next = (element)->field.Next;\ else\ (root)->First = (element)->field.Next;\ (element)->field.Next = 0;\ (element)->field.Prev = 0;\ } #define CIRCLE_QUEUE_FIRST(root)\ ((root)->First == (void *) (root)? 0: (root)->First) #define CIRCLE_QUEUE_LAST(root)\ ((root)->Last == (void *) (root)? 0: (root)->Last) #define CIRCLE_QUEUE_NEXT(root,element,field)\ ((void *) (element)->field.Next == (void *) (root)? 0: (element)->field.Next) #define CIRCLE_QUEUE_PREVIOUS(root,element,field)\ ((element)->field.Prev == (void *) (root)? 0: (element)->field.Prev) #if 0 /* Test code. Strip it out, put it in a .C (or .CPP) file and compile it as a console app to test this stuff. It should run without any assertion failures. Also, use this as example code. */ #include <stdio.h> #include <stdlib.h> #include <assert.h> #include "lists.hpp" void TestList(void) { struct Foo { int a; LIST_MEMBER(Foo) ListStuff; int b; }; struct Foo MyFoo1, MyFoo2, MyFoo3, *pFoo = 0; LIST_ROOT(sRoot, Foo) MyListRoot; fputs("Testing LIST.\n",stdout); LIST_INITIALIZE(&MyListRoot); LIST_INITIALIZE_MEMBER(&MyFoo1,ListStuff); MyFoo1.a = 0x1A; MyFoo1.b = 0x1B; LIST_INITIALIZE_MEMBER(&MyFoo2,ListStuff); MyFoo2.a = 0x2A; MyFoo2.b = 0x2B; LIST_INITIALIZE_MEMBER(&MyFoo3,ListStuff); MyFoo3.a = 0x3A; MyFoo3.b = 0x3B; assert(LIST_ORPHAN_MEMBER(&MyFoo3,ListStuff)); LIST_INSERT_ROOT(&MyListRoot,&MyFoo3,ListStuff); assert(!LIST_ORPHAN_MEMBER(&MyFoo3,ListStuff)); LIST_INSERT_ROOT(&MyListRoot,&MyFoo2,ListStuff); LIST_INSERT_ROOT(&MyListRoot,&MyFoo1,ListStuff); assert(!LIST_ORPHAN_MEMBER(&MyFoo1,ListStuff)); assert(!LIST_ORPHAN_MEMBER(&MyFoo2,ListStuff)); assert(!LIST_ORPHAN_MEMBER(&MyFoo3,ListStuff)); pFoo = LIST_FIRST(&MyListRoot); assert(pFoo); assert(pFoo->a == 0x1A); assert(pFoo->b == 0x1B); pFoo = LIST_NEXT(pFoo,ListStuff); assert(pFoo); assert(pFoo->a == 0x2A); assert(pFoo->b == 0x2B); pFoo = LIST_NEXT(pFoo,ListStuff); assert(pFoo); assert(pFoo->a == 0x3A); assert(pFoo->b == 0x3B); pFoo = LIST_NEXT(pFoo,ListStuff); assert(pFoo == 0); /* Delete member 2. */ pFoo = LIST_FIRST(&MyListRoot); pFoo = LIST_NEXT(pFoo,ListStuff); LIST_DELETE(pFoo,ListStuff); assert(pFoo->a == 0x2A);/* Make sure we have the right member. */ assert(pFoo->b == 0x2B);/* And the data is intact. */ assert(LIST_NEXT(pFoo,ListStuff) == 0); /* Make sure that there are only members 1 and 3 in the list now. */ pFoo = LIST_FIRST(&MyListRoot); assert(pFoo); assert(pFoo->a == 0x1A); assert(pFoo->b == 0x1B); pFoo = LIST_NEXT(pFoo,ListStuff); assert(pFoo); assert(pFoo->a == 0x3A); assert(pFoo->b == 0x3B); assert(LIST_NEXT(pFoo,ListStuff) == 0); /* Delete member 3. */ pFoo = LIST_FIRST(&MyListRoot); pFoo = LIST_NEXT(pFoo,ListStuff); LIST_DELETE(pFoo,ListStuff); assert(pFoo->a == 0x3A);/* Make sure we have the right member. */ assert(pFoo->b == 0x3B);/* And the data is intact. */ assert(LIST_NEXT(pFoo,ListStuff) == 0); /* Delete member 1. */ pFoo = LIST_FIRST(&MyListRoot); LIST_DELETE(pFoo,ListStuff); assert(pFoo->a == 0x1A);/* Make sure we have the right member. */ assert(pFoo->b == 0x1B);/* And the data is intact. */ assert(LIST_NEXT(pFoo,ListStuff) == 0); assert(LIST_FIRST(&MyListRoot) == 0); LIST_INSERT_ROOT(&MyListRoot,&MyFoo2,ListStuff); LIST_INSERT_ROOT(&MyListRoot,&MyFoo1,ListStuff); /* Delete member 1 while there are other members in the list. */ pFoo = LIST_FIRST(&MyListRoot); LIST_DELETE(pFoo,ListStuff); assert(pFoo->a == 0x1A);/* Make sure we have the right member. */ assert(pFoo->b == 0x1B);/* And the data is intact. */ assert(LIST_NEXT(pFoo,ListStuff) == 0); assert(LIST_FIRST(&MyListRoot) == &MyFoo2); assert(MyFoo1.a == 0x1A); assert(MyFoo1.b == 0x1B); assert(MyFoo2.a == 0x2A); assert(MyFoo2.b == 0x2B); assert(MyFoo3.a == 0x3A); assert(MyFoo3.b == 0x3B); fputs("List passed.\n", stdout); } void TestTailQueue(void) { struct Foo { int a; TAIL_QUEUE_MEMBER(Foo) TQStuff; int b; }; struct Foo MyFoo1, MyFoo2, MyFoo3, *pFoo = 0; TAIL_QUEUE_ROOT(sRoot, Foo) MyTQRoot; fputs("Testing TAIL_QUEUE.\n",stdout); TAIL_QUEUE_INITIALIZE(&MyTQRoot); MyFoo1.a = 0x1A; MyFoo1.b = 0x1B; MyFoo2.a = 0x2A; MyFoo2.b = 0x2B; MyFoo3.a = 0x3A; MyFoo3.b = 0x3B; TAIL_QUEUE_INSERT_END(&MyTQRoot,&MyFoo1,TQStuff); TAIL_QUEUE_INSERT_END(&MyTQRoot,&MyFoo2,TQStuff); TAIL_QUEUE_INSERT_END(&MyTQRoot,&MyFoo3,TQStuff); pFoo = TAIL_QUEUE_FIRST(&MyTQRoot); assert(pFoo); assert(pFoo->a == 0x1A); assert(pFoo->b == 0x1B); pFoo = TAIL_QUEUE_NEXT(pFoo,TQStuff); assert(pFoo); assert(pFoo->a == 0x2A); assert(pFoo->b == 0x2B); pFoo = TAIL_QUEUE_NEXT(pFoo,TQStuff); assert(pFoo); assert(pFoo->a == 0x3A); assert(pFoo->b == 0x3B); pFoo = TAIL_QUEUE_NEXT(pFoo,TQStuff); assert(pFoo == 0); /* Delete member 2. */ pFoo = TAIL_QUEUE_FIRST(&MyTQRoot); pFoo = TAIL_QUEUE_NEXT(pFoo,TQStuff); TAIL_QUEUE_DELETE(&MyTQRoot,pFoo,TQStuff); assert(pFoo->a == 0x2A);/* Make sure we have the right member. */ assert(pFoo->b == 0x2B);/* And the data is intact. */ assert(TAIL_QUEUE_NEXT(pFoo,TQStuff) == 0); /* Make sure that there are only members 1 and 3 in the list now. */ pFoo = TAIL_QUEUE_FIRST(&MyTQRoot); assert(pFoo); assert(pFoo->a == 0x1A); assert(pFoo->b == 0x1B); pFoo = TAIL_QUEUE_NEXT(pFoo,TQStuff); assert(pFoo); assert(pFoo->a == 0x3A); assert(pFoo->b == 0x3B); assert(TAIL_QUEUE_NEXT(pFoo,TQStuff) == 0); /* Delete member 3. */ pFoo = TAIL_QUEUE_FIRST(&MyTQRoot); pFoo = TAIL_QUEUE_NEXT(pFoo,TQStuff); TAIL_QUEUE_DELETE(&MyTQRoot,pFoo,TQStuff); assert(pFoo->a == 0x3A);/* Make sure we have the right member. */ assert(pFoo->b == 0x3B);/* And the data is intact. */ assert(TAIL_QUEUE_NEXT(pFoo,TQStuff) == 0); /* Delete member 1. */ pFoo = TAIL_QUEUE_FIRST(&MyTQRoot); TAIL_QUEUE_DELETE(&MyTQRoot,pFoo,TQStuff); assert(pFoo->a == 0x1A);/* Make sure we have the right member. */ assert(pFoo->b == 0x1B);/* And the data is intact. */ assert(TAIL_QUEUE_NEXT(pFoo,TQStuff) == 0); assert(TAIL_QUEUE_FIRST(&MyTQRoot) == 0); TAIL_QUEUE_INSERT_END(&MyTQRoot,&MyFoo1,TQStuff); TAIL_QUEUE_INSERT_END(&MyTQRoot,&MyFoo2,TQStuff); /* Delete member 1 while there are other members in the list. */ pFoo = TAIL_QUEUE_FIRST(&MyTQRoot); TAIL_QUEUE_DELETE(&MyTQRoot,pFoo,TQStuff); assert(pFoo->a == 0x1A);/* Make sure we have the right member. */ assert(pFoo->b == 0x1B);/* And the data is intact. */ assert(TAIL_QUEUE_NEXT(pFoo,TQStuff) == 0); assert(TAIL_QUEUE_FIRST(&MyTQRoot) == &MyFoo2); assert(MyFoo1.a == 0x1A); assert(MyFoo1.b == 0x1B); assert(MyFoo2.a == 0x2A); assert(MyFoo2.b == 0x2B); assert(MyFoo3.a == 0x3A); assert(MyFoo3.b == 0x3B); fputs("Tail Queue passed.\n", stdout); } void TestCircleQueue(void) { enum {END,ROOT,PREVIOUS,DONE} WhichInsert = END; int i; struct Foo { int a; CIRCLE_QUEUE_MEMBER(Foo) CQStuff; int b; }; struct Foo MyFoo1, MyFoo2, MyFoo3, *pFoo = 0; CIRCLE_QUEUE_ROOT(sRoot, Foo) MyCQRoot; fputs("Testing CIRCLE_QUEUE.\n",stdout); while(WhichInsert != DONE) { CIRCLE_QUEUE_INITIALIZE(&MyCQRoot,Foo); MyFoo1.a = 0x1A; MyFoo1.b = 0x1B; MyFoo2.a = 0x2A; MyFoo2.b = 0x2B; MyFoo3.a = 0x3A; MyFoo3.b = 0x3B; switch(WhichInsert) { case END: CIRCLE_QUEUE_INSERT_END(&MyCQRoot,Foo,&MyFoo1,CQStuff); CIRCLE_QUEUE_INSERT_END(&MyCQRoot,Foo,&MyFoo2,CQStuff); CIRCLE_QUEUE_INSERT_END(&MyCQRoot,Foo,&MyFoo3,CQStuff); WhichInsert = ROOT; break; case ROOT: CIRCLE_QUEUE_INSERT_ROOT(&MyCQRoot,Foo,&MyFoo3,CQStuff); CIRCLE_QUEUE_INSERT_ROOT(&MyCQRoot,Foo,&MyFoo2,CQStuff); CIRCLE_QUEUE_INSERT_ROOT(&MyCQRoot,Foo,&MyFoo1,CQStuff); WhichInsert = PREVIOUS; break; case PREVIOUS: CIRCLE_QUEUE_INSERT_ROOT(&MyCQRoot,Foo,&MyFoo3,CQStuff); CIRCLE_QUEUE_INSERT_PREVIOUS(&MyCQRoot,&MyFoo3,&MyFoo2,CQStuff); CIRCLE_QUEUE_INSERT_PREVIOUS(&MyCQRoot,&MyFoo2,&MyFoo1,CQStuff); WhichInsert = DONE; break; default: assert(0); } pFoo = CIRCLE_QUEUE_FIRST(&MyCQRoot); assert(pFoo); assert(pFoo->a == 0x1A); assert(pFoo->b == 0x1B); pFoo = CIRCLE_QUEUE_NEXT(&MyCQRoot,pFoo,CQStuff); assert(pFoo); assert(pFoo->a == 0x2A); assert(pFoo->b == 0x2B); pFoo = CIRCLE_QUEUE_NEXT(&MyCQRoot,pFoo,CQStuff); assert(pFoo); assert(pFoo->a == 0x3A); assert(pFoo->b == 0x3B); pFoo = CIRCLE_QUEUE_NEXT(&MyCQRoot,pFoo,CQStuff); assert(pFoo == 0); pFoo = CIRCLE_QUEUE_FIRST(&MyCQRoot); assert(CIRCLE_QUEUE_PREVIOUS(&MyCQRoot,pFoo,CQStuff) == 0); pFoo = CIRCLE_QUEUE_LAST(&MyCQRoot); assert(pFoo == &MyFoo3); assert(CIRCLE_QUEUE_PREVIOUS(&MyCQRoot,pFoo,CQStuff) == &MyFoo2); assert(CIRCLE_QUEUE_PREVIOUS(&MyCQRoot,&MyFoo2,CQStuff) == &MyFoo1); /* Delete member 2. */ pFoo = CIRCLE_QUEUE_FIRST(&MyCQRoot); pFoo = CIRCLE_QUEUE_NEXT(&MyCQRoot,pFoo,CQStuff); CIRCLE_QUEUE_DELETE(&MyCQRoot,pFoo,CQStuff); assert(pFoo->a == 0x2A);/* Make sure we have the right member. */ assert(pFoo->b == 0x2B);/* And the data is intact. */ assert(CIRCLE_QUEUE_NEXT(&MyCQRoot,pFoo,CQStuff) == 0); /* Make sure that there are only members 1 and 3 in the list now. */ pFoo = CIRCLE_QUEUE_FIRST(&MyCQRoot); assert(pFoo); assert(pFoo->a == 0x1A); assert(pFoo->b == 0x1B); pFoo = CIRCLE_QUEUE_NEXT(&MyCQRoot,pFoo,CQStuff); assert(pFoo); assert(pFoo->a == 0x3A); assert(pFoo->b == 0x3B); assert(CIRCLE_QUEUE_NEXT(&MyCQRoot,pFoo,CQStuff) == 0); /* Delete member 3. */ pFoo = CIRCLE_QUEUE_FIRST(&MyCQRoot); pFoo = CIRCLE_QUEUE_NEXT(&MyCQRoot,pFoo,CQStuff); CIRCLE_QUEUE_DELETE(&MyCQRoot,pFoo,CQStuff); assert(pFoo->a == 0x3A);/* Make sure we have the right member. */ assert(pFoo->b == 0x3B);/* And the data is intact. */ assert(CIRCLE_QUEUE_NEXT(&MyCQRoot,pFoo,CQStuff) == 0); /* Delete member 1. */ pFoo = CIRCLE_QUEUE_FIRST(&MyCQRoot); CIRCLE_QUEUE_DELETE(&MyCQRoot,pFoo,CQStuff); assert(pFoo->a == 0x1A);/* Make sure we have the right member. */ assert(pFoo->b == 0x1B);/* And the data is intact. */ assert(CIRCLE_QUEUE_NEXT(&MyCQRoot,pFoo,CQStuff) == 0); assert(CIRCLE_QUEUE_FIRST(&MyCQRoot) == 0); CIRCLE_QUEUE_INSERT_END(&MyCQRoot,Foo,&MyFoo1,CQStuff); CIRCLE_QUEUE_INSERT_END(&MyCQRoot,Foo,&MyFoo2,CQStuff); /* Delete member 1 while there are other members in the list. */ pFoo = CIRCLE_QUEUE_FIRST(&MyCQRoot); CIRCLE_QUEUE_DELETE(&MyCQRoot,pFoo,CQStuff); assert(pFoo->a == 0x1A);/* Make sure we have the right member. */ assert(pFoo->b == 0x1B);/* And the data is intact. */ assert(CIRCLE_QUEUE_NEXT(&MyCQRoot,pFoo,CQStuff) == 0); assert(CIRCLE_QUEUE_FIRST(&MyCQRoot) == &MyFoo2); assert(MyFoo1.a == 0x1A); assert(MyFoo1.b == 0x1B); assert(MyFoo2.a == 0x2A); assert(MyFoo2.b == 0x2B); assert(MyFoo3.a == 0x3A); assert(MyFoo3.b == 0x3B); } fputs("Circle Queue passed.\n", stdout); } int main() { TestList(); TestTailQueue(); TestCircleQueue(); fputs("All tests passed.", stdout); return EXIT_SUCCESS; } #endif /* End of test code. */ #endif // !_LISTS_H
[ "support@cryptoalgo.cf" ]
support@cryptoalgo.cf
8cb36a1d24a053d67d281036b05d67ed308844b5
9d8ebc22107885bdf5fcab1191de7d78a14bba8e
/network/dataStruct.h
061416ec0db6be5534bd4affe213890a68b87c25
[]
no_license
Gary016/Network
001d9c7b8a0cb696696d4f558cd8bff2f1b93359
570afa853e0d84e60634f5fa8d74d4aa58387fe6
refs/heads/master
2016-08-12T22:39:22.680903
2016-01-03T17:55:42
2016-01-03T17:55:42
48,955,185
0
0
null
null
null
null
UTF-8
C++
false
false
123
h
#include<vector> using std::vector; class dataStruct { public: vector<double> linksFlow; dataStruct(); ~dataStruct(); };
[ "jun.xie@northwestern.edu" ]
jun.xie@northwestern.edu
35b54d0dbfe9c4bcd27e5be7b1e465f07733f66a
7d558e68292c1b6345e6f0af1f14927a60367718
/Arith_256_W/Arith_256_W.cpp
d098c7e4f9adfb753f64486a9663f5ffb7c0c8e0
[]
no_license
veinyyxy/IDP_OLD2
e8c15c8cc0d0be62ea7c359b46b5285616ba2da1
4dbd439f5d01a78eb10a3da5792d609d0950ae2b
refs/heads/master
2022-12-19T19:19:31.823314
2020-09-28T05:24:17
2020-09-28T05:24:17
299,151,464
0
0
null
null
null
null
GB18030
C++
false
false
5,215
cpp
////////////////////////////////////////////////////////////////////////// // Arith_256_W.cpp // created by ply 20080411 // 256号产品,基本谱宽,W ////////////////////////////////////////////////////////////////////////// #ifndef IARITHMS_LIB #define IARITHMS_LIB #endif #include "Arith_256_W.h" #include "StandardRadarDataX.h" #include "CJulMsGMT.h" #include <fstream> #include "IBase.h" #include "GDef.h" ARITH_256_W::ARITH_256_W() { ; } ARITH_256_W::~ARITH_256_W() { ; } GHRESULT ARITH_256_W::Initialize() { m_pInputList = NULL; m_pOutputList = NULL; return GS_OK; } GHRESULT ARITH_256_W::LoadData(void *pValue,ReadParam* /*ReadParameter*/) { if(pValue == NULL) return GE_INVALIDARG; m_pInputList=(GXList< GenerationData > *)pValue; return GS_OK; } GHRESULT ARITH_256_W::OutPutData(void * pValue) { if(pValue == NULL) return GE_INVALIDARG; m_pOutputList=(GXList< GenerationData > *)pValue; return GS_OK; } GHRESULT ARITH_256_W::Execute() { ofstream logfile; logfile.open("./Log/Arith_256_W.txt",ios::app); gUint16 iJulDay; gInt32 iMilliSecond,iYear,iMonth,iDay,iHour,iMinute,iSecond,iMSecond; CJulMsGMT::GetLocalJulMs(iJulDay, iMilliSecond ); CJulMsGMT::Jul2Greg(iJulDay,iYear,iMonth,iDay); CJulMsGMT::MilliSecond2Time(iMilliSecond,iHour,iMinute,iSecond,iMSecond); logfile<<endl<<iHour<<":"<<iMinute<<":"<<iSecond<<" "<<iYear<<"-"<<iMonth<<"-"<<iDay<<endl; logfile<<"256_W: Started: "<<endl; logfile<<"256_W: Check m_pInputList's Count. "<<endl; if (m_pInputList->GetCount()!=1) { return GE_SHORTOFINDATA; } logfile<<"256_W: Get and Set head Information from StandardRadarData. "<<endl; StandardRadarData* pRadar = &(*(m_pInputList->GetHeadAs<StandardRadarData >())); GRADARDATAHEADER* prdh = pRadar->GetHeadP(); gInt16 ElevationCount = prdh->ElevationCount; m_pOutputList->AddTail(); Product_256_W* ppdt = &(*(m_pOutputList->GetTailAs<Product_256_W>())); GHRESULT ConstrutHand; ConstrutHand = ppdt->ConstructIt(ElevationCount, pRadar->GetElevationHeadP(0)->AzimuthNumber, pRadar->GetElevationHeadP(0)->DopplerGates); if(ConstrutHand != GS_OK) { logfile<<"256_W: Create New Product Failed and Return GE_FAILOFNEWPRODUMEM."<<endl; logfile.close(); return GE_FAILOFNEWPRODUMEM; } RadarInfor * pRadarInfor = ppdt->GetRadarInfor(); memcpy(pRadarInfor->SiteCode, prdh->SiteCode, sizeof(gChar)*8); memcpy(pRadarInfor->RadarType, prdh->RadarType, sizeof(gInt8)* 4); pRadarInfor->Latitude = prdh->RadarLat; pRadarInfor->Longitude = prdh->RadarLon; pRadarInfor->Altitude = prdh->RadarHeight; PDBlock* pdb = ppdt->GetMyPDBlock(); CJulMsGMT::GetLocalJulMs(pdb->GenerationDateOfProduct, pdb->GenerationTimeOfProduct); pdb->ProductDate = prdh->VCPDate; pdb->ProductTime = prdh->VCPTime; CJulMsGMT::Jul2Greg(pdb->ProductDate,iYear,iMonth,iDay); CJulMsGMT::MilliSecond2Time(pdb->ProductTime,iHour,iMinute,iSecond,iMSecond); logfile<<"256_W: VCPDate:"<<iYear<<"-"<<iMonth<<"-"<<iDay<<" VCPTime:"<<iHour<<":"<<iMinute<<":"<<iSecond<<endl; memcpy(pdb->OperationalMode, prdh->OperationMode, sizeof(gInt8)* 2); memcpy(pdb->VCPMode, prdh->VCPMode, sizeof(gInt8) * 4); //pdb->VCP=prdh->VCPMode; pdb->ScaleOfData = 100; pdb->IndexOfTabular = -1; pdb->IndexOfGraphic = -1; logfile<<"256_W: Set RadialData,ElevationHead and SpectrumWidth Data Information in each Elevation.\n"; for (int i=0;i<ElevationCount;i++) { GELEVATIONDATAHEAD* pedh = pRadar->GetElevationHeadP(i); if(pedh->DopplerGates <= 0) { continue; } ppdt->GetMyLayer(i)->HeightOfElevation = pedh->Elevation; ppdt->GetMyLayer(i)->LayerDate=pRadar->GetRadarDataP(i,0)->Date; ppdt->GetMyLayer(i)->LayerTime=pRadar->GetRadarDataP(i,0)->Time; ppdt->GetMyRadial_Head(i)->DistanceOfFirstGate=pRadar->GetElevationHeadP(i)->FirstGateRangeOfDoppler; ppdt->GetMyRadial_Head(i)->LengthOfGate=pRadar->GetHeadP()->DopplerGateSize; ppdt->GetMyRadial_Head(i)->NumberOfGates=pRadar->GetElevationHeadP(i)->DopplerGates; gInt16 DeltaAngel=36000/pRadar->GetElevationHeadP(i)->AzimuthNumber; for (int j=0;j< pedh->AzimuthNumber;j++) { ppdt->GetMyRadial_RadialData(i,j)->AzimuthAngle=pRadar->GetRadarDataP(i,j)->Azimuth; //s这段是根据下一个角读角差距 if (j== pedh->AzimuthNumber-1) { ppdt->GetMyRadial_RadialData(i,j)->DeltaAngle=(pRadar->GetRadarDataP(i,0)->Azimuth+36000-pRadar->GetRadarDataP(i,j)->Azimuth)%36000; } else { ppdt->GetMyRadial_RadialData(i,j)->DeltaAngle=(pRadar->GetRadarDataP(i,j+1)->Azimuth+36000-pRadar->GetRadarDataP(i,j)->Azimuth)%36000; } if (ppdt->GetMyRadial_RadialData(i,j)->DeltaAngle<DeltaAngel||ppdt->GetMyRadial_RadialData(i,j)->DeltaAngle>2*DeltaAngel) { ppdt->GetMyRadial_RadialData(i,j)->DeltaAngle=DeltaAngel; } //e这段是根据下一个角读角差距 for (int k=0;k< pedh->DopplerGates; k++) { ppdt->GetMyRadial_Data(i,j)[k]=pRadar->GetRadarDataW(i,j)[k]; } } } logfile<<"256_W: Finished. "<<endl; logfile.close(); return GS_OK; } GHRESULT ARITH_256_W::UnInitialize() { return GS_OK; } extern "C" DLLEXP_GSYS IArith *Create_arith (void)//用于创建ARITH_256_W接口 { return new(::std::nothrow) ARITH_256_W; }
[ "veiny_yxy@163.com" ]
veiny_yxy@163.com
a19efe22d5b6dbaea822aa470f23c97b89fe86cd
0674c2af89c95020a19e78ef392f42f022d51a8c
/MandelbrotSet/mandelbrot.h
57357777699cf69b94c2f06793362ac40774f598
[]
no_license
chienchi/CppLearning
4f2ba23d1b3f1a59f08bf6583c75b44ec8a95adf
f33471ed1f0773f485c79858ecd2f4cc726558c2
refs/heads/master
2020-05-09T16:23:44.268812
2020-01-24T16:48:41
2020-01-24T16:48:41
181,268,823
0
0
null
null
null
null
UTF-8
C++
false
false
1,202
h
// // Created by osboxes on 8/30/19. // #ifndef LIVECODING_MANDELBROT_H #define LIVECODING_MANDELBROT_H #endif //LIVECODING_MANDELBROT_H #include <complex> using namespace std; complex<float> c; complex<float> k; class mandel_pixel { public: mandel_pixel(int x, int y, int xdim, int ydim, int max_iter) : max_iter(max_iter), iter(0), c(x, y) { // scale y to [-1.2,1.2] and shift -0.5+0i to the center c*= 2.4f / static_cast<float>(ydim); c-= complex<float>(1.2 * xdim / ydim + 0.5, 1.2); //k = complex<float>(-0.6,0.6); k = complex<float>(0.353,0.288); //std::cout << c << " " ; iterate(); } int iterations() const { return iter; } void print(){ if ( this->iterations() == max_iter){ std::cout << "#"; }else{ std::cout << " "; } } private: void iterate() { complex<float> z= c; #pragma omp parallel for default(none) shared(z) for (; iter < max_iter && norm(z) <= 4.0f; iter++) z= z * z + c; //z= z * z + k; }; const int max_iter; int iter; complex<float> c; complex<float> k; };
[ "chienchi@lanl.gov" ]
chienchi@lanl.gov
fc239a1b394e5f15d3be61226b9f22da7fba449d
b7f3699c14d8b8dcb764f44972afa3f341c4cf03
/src/ADE9000.cpp
0adab5eb902fb05ef3651585c7d9687aaf0ecae3
[]
no_license
EmbeddedSystemClass/ade9000
e8096d65bc83ea1b64aea7a25e20a9aa22dcc448
1f1b52ff1d400fbfeff8279acb0f15d0ac721198
refs/heads/master
2021-10-25T16:59:21.528338
2019-04-05T17:08:55
2019-04-05T17:08:55
null
0
0
null
null
null
null
UTF-8
C++
false
false
26,784
cpp
/* ADE9000API.cpp - Library for ADE9000/ADE9078 - Energy and PQ monitoring AFE Date: 3-16-2017 */ /**************************************************************************************************************** Includes ***************************************************************************************************************/ #include <Arduino.h> #include <SPI.h> #include "ADE9000.h" #include "Preferences.h" Preferences preferences; //uncomment next line to get debugging output from this library //#define DEBUGADE ADE9000::ADE9000() { _chipSelect_Pin = 25; m_flipCurr = false; } void ADE9000::loadParams() { preferences.begin("ADE9000", false); /* //I don't know that we want to mess with these. Maybe just have our own conversion factors //Also, the hardware stores these in integer format so maybe store them that way instead. OverVSetpoint = preferences.getFloat("AIGain", 1.0f); OverVSetpoint = preferences.getFloat("BIGain", 1.0f); OverVSetpoint = preferences.getFloat("CIGain", 1.0f); OverVSetpoint = preferences.getFloat("NIGain", 1.0f); OverVSetpoint = preferences.getFloat("AVGain", 1.0f); OverVSetpoint = preferences.getFloat("BVGain", 1.0f); OverVSetpoint = preferences.getFloat("CVGain", 1.0f); OverVSetpoint = preferences.getFloat("APHCal0", 1.0f); OverVSetpoint = preferences.getFloat("BPHCal0", 1.0f); OverVSetpoint = preferences.getFloat("CPHCal0", 1.0f); OverVSetpoint = preferences.getFloat("APGain", 1.0f); OverVSetpoint = preferences.getFloat("BPGain", 1.0f); OverVSetpoint = preferences.getFloat("CPGain", 1.0f); */ m_L1vcal_p = preferences.getFloat("L1VCal", 1.0f); m_L1vcal_n = preferences.getFloat("L1VCalNeg", m_L1vcal_p); m_L2vcal_p = preferences.getFloat("L2VCal", 1.0f); m_L2vcal_n = preferences.getFloat("L2VCalNeg", m_L2vcal_p); m_L1ical_p = preferences.getFloat("L1ICal", 1.0f); m_L1ical_n = preferences.getFloat("L1ICalNeg", m_L1ical_p); m_L2ical_p = preferences.getFloat("L2ICal", 1.0f); m_L2ical_n = preferences.getFloat("L2ICalNeg", m_L2ical_p); m_L1pcal_p = preferences.getFloat("L1PCal", 1.0f); m_L1pcal_n = preferences.getFloat("L1PCalNeg", m_L1pcal_p); m_L2pcal_p = preferences.getFloat("L2PCal", 1.0f); m_L2pcal_n = preferences.getFloat("L2PCalNeg", m_L2pcal_p); KWH = preferences.getFloat("KWH", 1.0f); m_flipCurr = preferences.getInt("FlipCurr", 0); preferences.end(); } void ADE9000::saveParams() { preferences.begin("ADE9000", false); /* preferences.putFloat("AIGain", 1.0f); preferences.putFloat("BIGain", 1.0f); preferences.putFloat("CIGain", 1.0f); preferences.putFloat("NIGain", 1.0f); preferences.putFloat("AVGain", 1.0f); preferences.putFloat("BVGain", 1.0f); preferences.putFloat("CVGain", 1.0f); preferences.putFloat("APHCal0", 1.0f); preferences.putFloat("BPHCal0", 1.0f); preferences.putFloat("CPHCal0", 1.0f); preferences.putFloat("APGain", 1.0f); preferences.putFloat("BPGain", 1.0f); preferences.putFloat("CPGain", 1.0f); */ preferences.putFloat("L1VCal", m_L1vcal_p); preferences.putFloat("L2VCal", m_L2vcal_p); preferences.putFloat("L1ICal", m_L1ical_p); preferences.putFloat("L2ICal", m_L2ical_p); preferences.putFloat("L1PCal", m_L1pcal_p); preferences.putFloat("L2PCal", m_L2pcal_p); preferences.putFloat("L1VCalNeg", m_L1vcal_n); preferences.putFloat("L2VCalNeg", m_L2vcal_n); preferences.putFloat("L1ICalNeg", m_L1ical_n); preferences.putFloat("L2ICalNeg", m_L2ical_n); preferences.putFloat("L1PCalNeg", m_L1pcal_n); preferences.putFloat("L2PCalNeg", m_L2pcal_n); preferences.putFloat("KWH", KWH); preferences.putInt("FlipCurr", m_flipCurr); preferences.end(); } /* Description: Initializes the ADE9000. The initial settings for registers are defined in ADE9000API.h header file Input: Register settings in header files Output: */ void ADE9000::begin(void) { SPI_Write_16(ADDR_PGA_GAIN,ADE9000_PGA_GAIN); SPI_Write_32(ADDR_CONFIG0,ADE9000_CONFIG0); SPI_Write_16(ADDR_CONFIG1,ADE9000_CONFIG1); SPI_Write_16(ADDR_CONFIG2,ADE9000_CONFIG2); SPI_Write_16(ADDR_CONFIG3,ADE9000_CONFIG3); SPI_Write_16(ADDR_ACCMODE,ADE9000_ACCMODE); SPI_Write_16(ADDR_TEMP_CFG,ADE9000_TEMP_CFG); SPI_Write_16(ADDR_ZX_LP_SEL,ADE9000_ZX_LP_SEL); SPI_Write_32(ADDR_MASK0,ADE9000_MASK0); SPI_Write_32(ADDR_MASK1,ADE9000_MASK1); SPI_Write_32(ADDR_EVENT_MASK,ADE9000_EVENT_MASK); SPI_Write_16(ADDR_WFB_CFG,ADE9000_WFB_CFG); SPI_Write_32(ADDR_VLEVEL,ADE9000_VLEVEL); SPI_Write_32(ADDR_DICOEFF,ADE9000_DICOEFF); SPI_Write_16(ADDR_EGY_TIME,ADE9000_EGY_TIME); SPI_Write_16(ADDR_EP_CFG,ADE9000_EP_CFG); //Energy accumulation ON SPI_Write_16(ADDR_RUN,ADE9000_RUN_ON); //DSP ON loadParams(); } void ADE9000::flipCurrentDirection() { m_flipCurr = !m_flipCurr; saveParams(); } //instantaneous current on phase A (rms current) float ADE9000::L1I() { float outVal; int32_t valu = int32_t (SPI_Read_32(ADDR_AIRMS)); //Get rms current for phase A if(SPI_Read_16(ADDR_PHSIGN)&1)valu*=-1; //If bit 0 of sign register value is negative if (m_flipCurr) valu *= -1; if (valu < 0) outVal = valu * m_L1ical_n; //Apply calibration factor else outVal = valu * m_L1ical_p; return outVal; } //instantaneous current on phase B (rms current) float ADE9000::L2I() { float outVal; int32_t valu = int32_t (SPI_Read_32(ADDR_BIRMS)); //Get rms current for phase A if(SPI_Read_16(ADDR_PHSIGN)&4)valu*=-1; //If bit 0 of sign register value is negative if (m_flipCurr) valu *= -1; if (valu < 0) outVal = valu * m_L2ical_n; //Apply calibration factor else outVal = valu * m_L2ical_p; return outVal; } //instantaneous rms voltage on phase A float ADE9000::L1Vrms() { float outVal; bool negCurr = SPI_Read_16(ADDR_PHSIGN)&1; if (m_flipCurr) negCurr = !negCurr; int32_t valu = int32_t (SPI_Read_32(ADDR_AVRMS)); #ifdef DEBUGADE Serial.print("AVRMS "); Serial.println(valu, HEX); #endif if (negCurr) outVal = valu * m_L1vcal_n; else outVal = valu * m_L1vcal_p; return outVal; } //instantaneous rms voltage on phase B float ADE9000::L2Vrms() { float outVal; bool negCurr = SPI_Read_16(ADDR_PHSIGN)&4; if (m_flipCurr) negCurr = !negCurr; int32_t valu = int32_t (SPI_Read_32(ADDR_BVRMS)); #ifdef DEBUGADE Serial.print("BVRMS "); Serial.println(valu, HEX); #endif if (negCurr) outVal = valu * m_L2vcal_n; else outVal = valu * m_L2vcal_p; return outVal; } //instantaneous wattage on phase A float ADE9000::L1Watt() { float outVal; int32_t valu = int32_t (SPI_Read_32(ADDR_AWATT)); #ifdef DEBUGADE Serial.print("AWATT "); Serial.println(valu, HEX); #endif if (m_flipCurr) valu *= -1; if (valu < 0) outVal = valu * m_L1pcal_n; else outVal = valu * m_L1pcal_p; return outVal; } //instantaneous wattage on phase B float ADE9000::L2Watt() { float outVal; int32_t valu = int32_t (SPI_Read_32(ADDR_BWATT)); #ifdef DEBUGADE Serial.print("AWATT "); Serial.println(valu, HEX); #endif if (m_flipCurr) valu *= -1; if (valu < 0) outVal = valu * m_L2pcal_n; else outVal = valu * m_L2pcal_p; return outVal; } //total wattage of A and B together float ADE9000::Watt() { return L1Watt() + L2Watt(); } //instantaneous apparent power in volt amps on phase A float ADE9000::L1VA() { int32_t valu = int32_t (SPI_Read_32(ADDR_AVA)); #ifdef DEBUGADE Serial.print("AVA "); Serial.println(valu, HEX); #endif float outVal = valu * m_L1pcal_p; return outVal; } //instantaneous apparent power in volt amps on phase B float ADE9000::L2VA() { int32_t valu = int32_t (SPI_Read_32(ADDR_BVA)); #ifdef DEBUGADE Serial.print("BVA "); Serial.println(valu, HEX); #endif float outVal = valu * m_L2pcal_p; return outVal; } float ADE9000::L1VAR() { int32_t valu = int32_t (SPI_Read_32(ADDR_AVAR)); #ifdef DEBUGADE Serial.print("AVAR "); Serial.println(valu, HEX); #endif float outVal = valu * m_L1pcal_p; return outVal; } float ADE9000::L2VAR() { int32_t valu = int32_t (SPI_Read_32(ADDR_BVAR)); #ifdef DEBUGADE Serial.print("BVAR "); Serial.println(valu, HEX); #endif float outVal = valu * m_L1pcal_p; return outVal; } //total volt amps of phase A and B together float ADE9000::VA() { return L1VA() + L2VA(); } //line frequency of the system (measured at phase A) float ADE9000::frequency() { //frequency is (8000 * 2^16) / ((valu + 1); uint32_t valu = (SPI_Read_32(ADDR_APERIOD)); #ifdef DEBUGADE Serial.print("APERIOD "); Serial.println(valu, HEX); #endif return 524288000.0 / (valu + 1.0); } //total harmonic distortion, as a percentage (Just A for now and just voltage) float ADE9000::THD() { //%THD on Current Channel A = AITHD × 2 −27 × 100% uint32_t valu = (SPI_Read_32(ADDR_AVTHD)); #ifdef DEBUGADE Serial.print("AVTHD "); Serial.println(valu, HEX); #endif return valu / 1342177.28; } //power factor as a percentage (try Average of A and B power factors?) float ADE9000::PF() { //Power Factor = xPF × 2 −27 * 100 to turn it to percentage int32_t valu = (int32_t)(SPI_Read_32(ADDR_APF)); #ifdef DEBUGADE Serial.print("APF "); Serial.println(valu, HEX); #endif return valu / 1342177.28; } //voltage gain factor to turn reading into actual voltage - Phase A void ADE9000::L1VCal(float calFactor) { m_L1vcal_p = calFactor; m_L1vcal_n = calFactor; } //voltage gain factor to turn reading into actual voltage - Phase A - Positive Current Flow void ADE9000::L1VCalPos(float calFactor) { m_L1vcal_p = calFactor; } //voltage gain factor to turn reading into actual voltage - Phase A - Negative Current Flow void ADE9000::L1VCalNeg(float calFactor) { m_L1vcal_n = calFactor; } //get factor for Phase A float ADE9000::L1VCal() { return m_L1vcal_p; } //get factor for Phase A float ADE9000::L1VCalPos() { return m_L1vcal_p; } //get factor for Phase A float ADE9000::L1VCalNeg() { return m_L1vcal_n; } //voltage gain factor to turn reading into actual voltage - Phase B void ADE9000::L2VCal(float calFactor) { m_L2vcal_p = calFactor; m_L2vcal_n = calFactor; } //voltage gain factor to turn reading into actual voltage - Phase B - Positive Current Flow void ADE9000::L2VCalPos(float calFactor) { m_L2vcal_p = calFactor; } //voltage gain factor to turn reading into actual voltage - Phase B - Negative Current Flow void ADE9000::L2VCalNeg(float calFactor) { m_L2vcal_n = calFactor; } //get factor for Phase B float ADE9000::L2VCal() { return m_L2vcal_p; } //get factor for Phase B float ADE9000::L2VCalPos() { return m_L2vcal_p; } //get factor for Phase B float ADE9000::L2VCalNeg() { return m_L2vcal_n; } //current gain factor to turn reading into actual current - Phase A void ADE9000::L1ICal(float calFactor) { m_L1ical_p = calFactor; m_L1ical_n = calFactor; } //current gain factor to turn reading into actual current - Phase A - Positive Current Flow void ADE9000::L1ICalPos(float calFactor) { m_L1ical_p = calFactor; } //current gain factor to turn reading into actual current - Phase A - Negative Current Flow void ADE9000::L1ICalNeg(float calFactor) { m_L1ical_n = calFactor; } //get factor for Phase A float ADE9000::L1ICal() { return m_L1ical_p; } //get factor for Phase A float ADE9000::L1ICalPos() { return m_L1ical_p; } //get factor for Phase A float ADE9000::L1ICalNeg() { return m_L1ical_n; } //current gain factor to turn reading into actual current - Phase B void ADE9000::L2ICal(float calFactor) { m_L2ical_p = calFactor; m_L2ical_n = calFactor; } //current gain factor to turn reading into actual current - Phase B - Positive Current Flow void ADE9000::L2ICalPos(float calFactor) { m_L2ical_p = calFactor; } //current gain factor to turn reading into actual current - Phase B - Negative Current Flow void ADE9000::L2ICalNeg(float calFactor) { m_L2ical_n = calFactor; } //get factor for Phase B float ADE9000::L2ICal() { return m_L2ical_p; } //get factor for Phase B float ADE9000::L2ICalPos() { return m_L2ical_p; } //get factor for Phase B float ADE9000::L2ICalNeg() { return m_L2ical_n; } //power gain factor to turn reading into actual power - Phase A void ADE9000::L1PCal(float calFactor) { m_L1pcal_p = calFactor; m_L1pcal_n = calFactor; } //power gain factor to turn reading into actual power - Phase A - Positive Current Flow void ADE9000::L1PCalPos(float calFactor) { m_L1pcal_p = calFactor; } //power gain factor to turn reading into actual power - Phase A - Negative Current Flow void ADE9000::L1PCalNeg(float calFactor) { m_L1pcal_n = calFactor; } //get factor for Phase A float ADE9000::L1PCal() { return m_L1pcal_p; } //get factor for Phase A float ADE9000::L1PCalPos() { return m_L1pcal_p; } //get factor for Phase A float ADE9000::L1PCalNeg() { return m_L1pcal_n; } //power gain factor to turn reading into actual power - Phase B void ADE9000::L2PCal(float calFactor) { m_L2pcal_p = calFactor; m_L2pcal_n = calFactor; } //power gain factor to turn reading into actual power - Phase B - Positive Current Flow void ADE9000::L2PCalPos(float calFactor) { m_L2pcal_p = calFactor; } //power gain factor to turn reading into actual power - Phase B - Negative Current Flow void ADE9000::L2PCalNeg(float calFactor) { m_L2pcal_n = calFactor; } //get factor for Phase B float ADE9000::L2PCal() { return m_L2pcal_p; } //get factor for Phase B float ADE9000::L2PCalPos() { return m_L2pcal_p; } //get factor for Phase B float ADE9000::L2PCalNeg() { return m_L2pcal_n; } /* Description: Initializes the arduino SPI port using SPI.h library Input: SPI speed, chip select pin Output:- */ void ADE9000::SPI_Init(uint32_t SPI_speed , uint8_t chipSelect_Pin) { SPI.begin(); //Initiate SPI port SPI.beginTransaction(SPISettings(SPI_speed,MSBFIRST,SPI_MODE0)); //Setup SPI parameters pinMode(chipSelect_Pin, OUTPUT); //Set Chip select pin as output digitalWrite(chipSelect_Pin, HIGH); //Set Chip select pin high _chipSelect_Pin = chipSelect_Pin; } /* Description: Writes 16bit data to a 16 bit register. Input: Register address, data Output:- */ void ADE9000:: SPI_Write_16(uint16_t Address , uint16_t Data ) { uint16_t temp_address; digitalWrite(_chipSelect_Pin, LOW); temp_address = ((Address << 4) & 0xFFF0); //shift address to align with cmd packet SPI.transfer16(temp_address); SPI.transfer16(Data); digitalWrite(_chipSelect_Pin, HIGH); } /* Description: Writes 32bit data to a 32 bit register. Input: Register address, data Output:- */ void ADE9000:: SPI_Write_32(uint16_t Address , uint32_t Data ) { uint16_t temp_address; uint16_t temp_highpacket; uint16_t temp_lowpacket; temp_highpacket= (Data & 0xFFFF0000)>>16; temp_lowpacket= (Data & 0x0000FFFF); digitalWrite(_chipSelect_Pin, LOW); temp_address = ((Address << 4) & 0xFFF0); //shift address to align with cmd packet SPI.transfer16(temp_address); SPI.transfer16(temp_highpacket); SPI.transfer16(temp_lowpacket); digitalWrite(_chipSelect_Pin, HIGH); } /* Description: Reads 16bit data from register. Input: Register address Output: 16 bit data */ uint16_t ADE9000:: SPI_Read_16(uint16_t Address) { uint16_t temp_address; uint16_t returnData; digitalWrite(_chipSelect_Pin, LOW); temp_address = (((Address << 4) & 0xFFF0)+8); SPI.transfer16(temp_address); returnData = SPI.transfer16(0); digitalWrite(_chipSelect_Pin, HIGH); return returnData; } /* Description: Reads 32bit data from register. Input: Register address Output: 32 bit data */ uint32_t ADE9000:: SPI_Read_32(uint16_t Address) { uint16_t temp_address; uint16_t temp_highpacket; uint16_t temp_lowpacket; uint32_t returnData; digitalWrite(_chipSelect_Pin, LOW); temp_address = (((Address << 4) & 0xFFF0)+8); SPI.transfer16(temp_address); temp_highpacket = SPI.transfer16(0); temp_lowpacket = SPI.transfer16(0); digitalWrite(_chipSelect_Pin, HIGH); returnData = temp_highpacket << 16; returnData = returnData + temp_lowpacket; return returnData; } /* Description: Burst reads the content of waveform buffer. This function only works with resampled data. Configure waveform buffer to have Resampled data, and burst enabled (BURST_CHAN=0000 in WFB_CFG Register). Input: The starting address. Use the starting address of a data set. e.g 0x800, 0x804 etc to avoid data going into incorrect arrays. Read_Element_Length is the number of data sets to read. If the starting address is 0x800, the maximum sets to read are 512. Output: Resampled data returned in structure */ void ADE9000:: SPI_Burst_Read_Resampled_Wfb(uint16_t Address, uint16_t Read_Element_Length, ResampledWfbData *ResampledData) { uint16_t temp; uint16_t i; digitalWrite(_chipSelect_Pin, LOW); SPI.transfer16(((Address << 4) & 0xFFF0)+8); //Send the starting address //burst read the data upto Read_Length for(i=0;i<Read_Element_Length;i++) { ResampledData->IA_Resampled[i] = SPI.transfer16(0); ResampledData->VA_Resampled[i] = SPI.transfer16(0); ResampledData->IB_Resampled[i] = SPI.transfer16(0); ResampledData->VB_Resampled[i] = SPI.transfer16(0); ResampledData->IC_Resampled[i] = SPI.transfer16(0); ResampledData->VC_Resampled[i] = SPI.transfer16(0); ResampledData->IN_Resampled[i] = SPI.transfer16(0); } digitalWrite(_chipSelect_Pin, HIGH); } /* Description: Reads the Active power registers AWATT,BWATT and CWATT Input: Structure name Output: Active power codes stored in respective structure */ void ADE9000:: ReadActivePowerRegs(ActivePowerRegs *Data) { Data->ActivePowerReg_A = int32_t (SPI_Read_32(ADDR_AWATT)); Data->ActivePowerReg_B = int32_t (SPI_Read_32(ADDR_BWATT)); Data->ActivePowerReg_C = int32_t (SPI_Read_32(ADDR_CWATT)); } void ADE9000:: ReadReactivePowerRegs(ReactivePowerRegs *Data) { Data->ReactivePowerReg_A = int32_t (SPI_Read_32(ADDR_AVAR)); Data->ReactivePowerReg_B = int32_t (SPI_Read_32(ADDR_BVAR)); Data->ReactivePowerReg_C = int32_t (SPI_Read_32(ADDR_CVAR)); } void ADE9000:: ReadApparentPowerRegs(ApparentPowerRegs *Data) { Data->ApparentPowerReg_A = int32_t (SPI_Read_32(ADDR_AVA)); Data->ApparentPowerReg_B = int32_t (SPI_Read_32(ADDR_BVA)); Data->ApparentPowerReg_C = int32_t (SPI_Read_32(ADDR_CVA)); } void ADE9000:: ReadVoltageRMSRegs(VoltageRMSRegs *Data) { Data->VoltageRMSReg_A = int32_t (SPI_Read_32(ADDR_AVRMS)); Data->VoltageRMSReg_B = int32_t (SPI_Read_32(ADDR_BVRMS)); Data->VoltageRMSReg_C = int32_t (SPI_Read_32(ADDR_CVRMS)); } void ADE9000:: ReadCurrentRMSRegs(CurrentRMSRegs *Data) { Data->CurrentRMSReg_A = int32_t (SPI_Read_32(ADDR_AIRMS)); Data->CurrentRMSReg_B = int32_t (SPI_Read_32(ADDR_BIRMS)); Data->CurrentRMSReg_C = int32_t (SPI_Read_32(ADDR_CIRMS)); Data->CurrentRMSReg_N = int32_t (SPI_Read_32(ADDR_NIRMS)); } void ADE9000:: ReadFundActivePowerRegs(FundActivePowerRegs *Data) { Data->FundActivePowerReg_A = int32_t (SPI_Read_32(ADDR_AFWATT)); Data->FundActivePowerReg_B = int32_t (SPI_Read_32(ADDR_BFWATT)); Data->FundActivePowerReg_C = int32_t (SPI_Read_32(ADDR_CFWATT)); } void ADE9000:: ReadFundReactivePowerRegs(FundReactivePowerRegs *Data) { Data->FundReactivePowerReg_A = int32_t (SPI_Read_32(ADDR_AFVAR)); Data->FundReactivePowerReg_B = int32_t (SPI_Read_32(ADDR_BFVAR)); Data->FundReactivePowerReg_C = int32_t (SPI_Read_32(ADDR_CFVAR)); } void ADE9000:: ReadFundApparentPowerRegs(FundApparentPowerRegs *Data) { Data->FundApparentPowerReg_A = int32_t (SPI_Read_32(ADDR_AFVA)); Data->FundApparentPowerReg_B = int32_t (SPI_Read_32(ADDR_BFVA)); Data->FundApparentPowerReg_C = int32_t (SPI_Read_32(ADDR_CFVA)); } void ADE9000:: ReadFundVoltageRMSRegs(FundVoltageRMSRegs *Data) { Data->FundVoltageRMSReg_A = int32_t (SPI_Read_32(ADDR_AVFRMS)); Data->FundVoltageRMSReg_B = int32_t (SPI_Read_32(ADDR_BVFRMS)); Data->FundVoltageRMSReg_C = int32_t (SPI_Read_32(ADDR_CVFRMS)); } void ADE9000:: ReadFundCurrentRMSRegs(FundCurrentRMSRegs *Data) { Data->FundCurrentRMSReg_A = int32_t (SPI_Read_32(ADDR_AIFRMS)); Data->FundCurrentRMSReg_B = int32_t (SPI_Read_32(ADDR_BIFRMS)); Data->FundCurrentRMSReg_C = int32_t (SPI_Read_32(ADDR_CIFRMS)); } void ADE9000:: ReadHalfVoltageRMSRegs(HalfVoltageRMSRegs *Data) { Data->HalfVoltageRMSReg_A = int32_t (SPI_Read_32(ADDR_AVRMSONE)); Data->HalfVoltageRMSReg_B = int32_t (SPI_Read_32(ADDR_BVRMSONE)); Data->HalfVoltageRMSReg_C = int32_t (SPI_Read_32(ADDR_CVRMSONE)); } void ADE9000:: ReadHalfCurrentRMSRegs(HalfCurrentRMSRegs *Data) { Data->HalfCurrentRMSReg_A = int32_t (SPI_Read_32(ADDR_AIRMSONE)); Data->HalfCurrentRMSReg_B = int32_t (SPI_Read_32(ADDR_BIRMSONE)); Data->HalfCurrentRMSReg_C = int32_t (SPI_Read_32(ADDR_CIRMSONE)); Data->HalfCurrentRMSReg_N = int32_t (SPI_Read_32(ADDR_NIRMSONE)); } void ADE9000:: ReadTen12VoltageRMSRegs(Ten12VoltageRMSRegs *Data) { Data->Ten12VoltageRMSReg_A = int32_t (SPI_Read_32(ADDR_AVRMS1012)); Data->Ten12VoltageRMSReg_B = int32_t (SPI_Read_32(ADDR_BVRMS1012)); Data->Ten12VoltageRMSReg_C = int32_t (SPI_Read_32(ADDR_CVRMS1012)); } void ADE9000:: ReadTen12CurrentRMSRegs(Ten12CurrentRMSRegs *Data) { Data->Ten12CurrentRMSReg_A = int32_t (SPI_Read_32(ADDR_AIRMS1012)); Data->Ten12CurrentRMSReg_B = int32_t (SPI_Read_32(ADDR_BIRMS1012)); Data->Ten12CurrentRMSReg_C = int32_t (SPI_Read_32(ADDR_CIRMS1012)); Data->Ten12CurrentRMSReg_N = int32_t (SPI_Read_32(ADDR_NIRMS1012)); } void ADE9000:: ReadVoltageTHDRegsnValues(VoltageTHDRegs *Data) { uint32_t tempReg; float tempValue; tempReg=int32_t (SPI_Read_32(ADDR_AVTHD)); //Read THD register Data->VoltageTHDReg_A = tempReg; tempValue=(float)tempReg*100/(float)134217728; //Calculate THD in % Data->VoltageTHDValue_A=tempValue; tempReg=int32_t (SPI_Read_32(ADDR_BVTHD)); //Read THD register Data->VoltageTHDReg_B = tempReg; tempValue=(float)tempReg*100/(float)134217728; //Calculate THD in % Data->VoltageTHDValue_B=tempValue; tempReg=int32_t (SPI_Read_32(ADDR_CVTHD)); //Read THD register Data->VoltageTHDReg_C = tempReg; tempValue=(float)tempReg*100/(float)134217728; //Calculate THD in % Data->VoltageTHDValue_C=tempValue; } void ADE9000:: ReadCurrentTHDRegsnValues(CurrentTHDRegs *Data) { uint32_t tempReg; float tempValue; tempReg=int32_t (SPI_Read_32(ADDR_AITHD)); //Read THD register Data->CurrentTHDReg_A = tempReg; tempValue=(float)tempReg*100/(float)134217728; //Calculate THD in % Data->CurrentTHDValue_A=tempValue; tempReg=int32_t (SPI_Read_32(ADDR_BITHD)); //Read THD register Data->CurrentTHDReg_B = tempReg; tempValue=(float)tempReg*100/(float)134217728; //Calculate THD in % Data->CurrentTHDValue_B=tempValue; tempReg=int32_t (SPI_Read_32(ADDR_CITHD)); //Read THD register Data->CurrentTHDReg_C = tempReg; tempValue=(float)tempReg*100/(float)134217728; //Calculate THD in % Data->CurrentTHDValue_C=tempValue; } void ADE9000:: ReadPowerFactorRegsnValues(PowerFactorRegs *Data) { uint32_t tempReg; float tempValue; tempReg=int32_t (SPI_Read_32(ADDR_APF)); //Read PF register Data->PowerFactorReg_A = tempReg; tempValue=(float)tempReg/(float)134217728; //Calculate PF Data->PowerFactorValue_A=tempValue; tempReg=int32_t (SPI_Read_32(ADDR_BPF)); //Read PF register Data->PowerFactorReg_B = tempReg; tempValue=(float)tempReg/(float)134217728; //Calculate PF Data->PowerFactorValue_B=tempValue; tempReg=int32_t (SPI_Read_32(ADDR_CPF)); //Read PF register Data->PowerFactorReg_C = tempReg; tempValue=(float)tempReg/(float)134217728; //Calculate PF Data->PowerFactorValue_C=tempValue; } void ADE9000:: ReadPeriodRegsnValues(PeriodRegs *Data) { uint32_t tempReg; float tempValue; tempReg=int32_t (SPI_Read_32(ADDR_APERIOD)); //Read PERIOD register Data->PeriodReg_A = tempReg; tempValue=(float)(8000*65536)/(float)(tempReg+1); //Calculate Frequency Data->FrequencyValue_A = tempValue; tempReg=int32_t (SPI_Read_32(ADDR_BPERIOD)); //Read PERIOD register Data->PeriodReg_B = tempReg; tempValue=(float)(8000*65536)/(float)(tempReg+1); //Calculate Frequency Data->FrequencyValue_B = tempValue; tempReg=int32_t (SPI_Read_32(ADDR_CPERIOD)); //Read PERIOD register Data->PeriodReg_C = tempReg; tempValue=(float)(8000*65536)/(float)(tempReg+1); //Calculate Frequency Data->FrequencyValue_C = tempValue; } void ADE9000:: ReadAngleRegsnValues(AngleRegs *Data) { uint32_t tempReg; uint16_t temp; float mulConstant; float tempValue; temp=SPI_Read_16(ADDR_ACCMODE); //Read frequency setting register if((temp&0x0100)>=0) { mulConstant=0.02109375; //multiplier constant for 60Hz system } else { mulConstant=0.017578125; //multiplier constant for 50Hz system } tempReg=int16_t (SPI_Read_32(ADDR_ANGL_VA_VB)); //Read ANGLE register Data->AngleReg_VA_VB=tempReg; tempValue=tempReg*mulConstant; //Calculate Angle in degrees Data->AngleValue_VA_VB=tempValue; tempReg=int16_t (SPI_Read_32(ADDR_ANGL_VB_VC)); Data->AngleReg_VB_VC=tempReg; tempValue=tempReg*mulConstant; Data->AngleValue_VB_VC=tempValue; tempReg=int16_t (SPI_Read_32(ADDR_ANGL_VA_VC)); Data->AngleReg_VA_VC=tempReg; tempValue=tempReg*mulConstant; Data->AngleValue_VA_VC=tempValue; tempReg=int16_t (SPI_Read_32(ADDR_ANGL_VA_IA)); Data->AngleReg_VA_IA=tempReg; tempValue=tempReg*mulConstant; Data->AngleValue_VA_IA=tempValue; tempReg=int16_t (SPI_Read_32(ADDR_ANGL_VB_IB)); Data->AngleReg_VB_IB=tempReg; tempValue=tempReg*mulConstant; Data->AngleValue_VB_IB=tempValue; tempReg=int16_t (SPI_Read_32(ADDR_ANGL_VC_IC)); Data->AngleReg_VC_IC=tempReg; tempValue=tempReg*mulConstant; Data->AngleValue_VC_IC=tempValue; tempReg=int16_t (SPI_Read_32(ADDR_ANGL_IA_IB)); Data->AngleReg_IA_IB=tempReg; tempValue=tempReg*mulConstant; Data->AngleValue_IA_IB=tempValue; tempReg=int16_t (SPI_Read_32(ADDR_ANGL_IB_IC)); Data->AngleReg_IB_IC=tempReg; tempValue=tempReg*mulConstant; Data->AngleValue_IB_IC=tempValue; tempReg=int16_t (SPI_Read_32(ADDR_ANGL_IA_IC)); Data->AngleReg_IA_IC=tempReg; tempValue=tempReg*mulConstant; Data->AngleValue_IA_IC=tempValue; } /* Description: Starts a new acquisition cycle. Waits for constant time and returns register value and temperature in Degree Celsius Input: Structure name Output: Register reading and temperature value in Degree Celsius */ void ADE9000:: ReadTempRegnValue(TemperatureRegnValue *Data) { uint32_t trim; uint16_t gain; uint16_t offset; uint16_t tempReg; float tempValue; SPI_Write_16(ADDR_TEMP_CFG,ADE9000_TEMP_CFG);//Start temperature acquisition cycle with settings in defined in ADE9000_TEMP_CFG delay(2); //delay of 2ms. Increase delay if TEMP_TIME is changed trim = SPI_Read_32(ADDR_TEMP_TRIM); gain= (trim & 0xFFFF); //Extract 16 LSB offset= ((trim>>16)&0xFFFF); //Extract 16 MSB tempReg= SPI_Read_16(ADDR_TEMP_RSLT); //Read Temperature result register tempValue= (float)(offset>>5)-((float)tempReg*(float)gain/(float)65536); Data->Temperature_Reg=tempReg; Data->Temperature=tempValue; }
[ "collink@kkmfg.com" ]
collink@kkmfg.com
483b425c208cfec745bf5dfc4b9193f8b8830527
5624a68f4ea5cfc6a24e73631cb9b225d30c0843
/C++/Homework - OOP/Homework-OOP/Building.h
c881db5a735b2eb6316a2e711b4552fd25da0791
[]
no_license
Vutov/SoftUni
815c33cc65a7f2cf1d87c348cb19940b2acf1c17
adccca7d61abc94993ac00ffdd81d75e15e42f7d
refs/heads/master
2020-04-12T01:25:29.612599
2016-12-29T18:29:42
2016-12-29T18:29:42
25,986,065
9
11
null
null
null
null
UTF-8
C++
false
false
653
h
#pragma once #include <string> using namespace std; class Building { private: string _buildingName; int _floors; int _offices; int _employees; int _freeWorkingSeats; bool _hasOnlyOffices; public: Building(); Building(string buildingName, int floors, int offices, int employees, int freeWorkingSeats, bool hasOnlyOffices = true); ~Building(); string getBuildingName(); int getFloors(); int getOffices(); int getEmployees(); int getFreeWorkingSeats(); bool getHasOnlyOffices(); double GetEmployeeFreeSeatCoef(); double Building::GetPeoplePerFloor(); double Building::GetOfficesPerFloor(); double Building::GetPeoplePerOffices(); };
[ "VutovSpas@gmail.com" ]
VutovSpas@gmail.com
73930a7e6b3033e38dfbe6b4423789683a89b88e
c808fee0345c2a31e4147a88aad56dbc99b70405
/09-Proyecciones/main.cpp
88f2bc4aeb518f9cf3fa0dcf74d0076024b9a9f1
[]
no_license
AmauryRamirez/ComputacionGrafica
faf5b13320b8a9e8611613bf338f28318a6122d4
a15014a6ce062f8b2a116ca813ee1bcd4867210b
refs/heads/master
2020-07-06T06:40:09.889703
2018-09-07T06:26:28
2018-09-07T06:26:28
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,272
cpp
#include <GL\glut.h> #include <stdio.h> #include <math.h> bool* keyStates = new bool[256]; void renderPrimitiveQuad() { glBegin(GL_QUADS); glVertex3f(-0.5f, -0.5f, -3.0f); glVertex3f(0.5f, -0.5f, -3.0f); glVertex3f(0.5f, 0.5f, -3.0f); glVertex3f(-0.5f, 0.5f, -3.0f); glEnd(); } void renderPrimitivePoints() { glPointSize(20.0f); glBegin(GL_POINTS); glVertex3f(-0.5f, -0.5f, -3.0f); glVertex3f(0.5f, -0.5f, -3.0f); glVertex3f(0.5f, 0.5f, -3.0f); glVertex3f(-0.5f, 0.5f, -3.0f); glEnd(); } void renderPrimitiveLineLoop() { glBegin(GL_LINE_LOOP); glVertex3f(-0.5f, -0.5f, -3.0f); glVertex3f(0.5f, -0.5f, -3.0f); glVertex3f(0.5f, 0.5f, -3.0f); glVertex3f(-0.5f, 0.5f, -3.0f); glEnd(); } void renderPrimitiveTriangle() { glBegin(GL_TRIANGLES); glVertex3f(-0.5f, -0.5f, -3.0f); glVertex3f(0.5f, -0.5f, -3.0f); glVertex3f(0.0f, 0.5f, -3.0f); glEnd(); } void init(void) { glClearColor (0.0, 0.0, 0.0, 0.0); } void renderQuadradoProyectado() { glBegin(GL_QUADS); glColor3f(1, 1, 1); glVertex3f(-sqrt(2) / 2.0f, -sqrt(2) / 2.0f, -4); glColor3f(1, 0, 0); glVertex3f(sqrt(2) / 2.0f, -sqrt(2) / 2.0f, -4); glColor3f(0, 1, 0); glVertex3f(sqrt(2) / 2.0f, sqrt(2) / 2.0f, -4); glColor3f(0, 0, 1); glVertex3f(-sqrt(2) / 2.0f, sqrt(2) / 2.0f, -4); glEnd(); } void display(void) { glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glClearColor(1.0f, 0.0f, 0.0f, 1.0f); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glColor3f(0.0f, 0.0f, 1.0f); glTranslatef(sqrt(2), 0, -2); glRotatef(-45, 0, 0, 1); glScalef(sqrt(2), sqrt(2), 1.0); renderQuadradoProyectado(); glFlush(); } void idleFunc(void) { glutPostRedisplay(); } void reshape(int width, int height) { glViewport(0, 0, (GLsizei)width, (GLsizei)height); glMatrixMode(GL_PROJECTION); glLoadIdentity(); // gluPerspective(45, (GLfloat)width / (GLfloat)height, 0.01, 100.0); glFrustum(-0.004, 0.004, -0.004, 0.004, 0.01, 10.0); glMatrixMode(GL_MODELVIEW); } void keyboard(unsigned char key, int x, int y) { keyStates[key] = true; switch (key) { case 27: exit(0); break; case 'a': case 'A': printf("Se presiono la tecla A\n"); break; case 'd': case 'D': printf("Se presiono la tecla D\n"); break; case 'w': case 'W': printf("Se presiono la tecla W\n"); break; case 's': case 'S': printf("Se presiono la tecla S\n"); break; } } void keyUp(unsigned char key, int x, int y) { keyStates[key] = false; } void mouseFunc(int button, int state, int x, int y) { printf("Mouse botton %d estado %d x %d y %d\n", button, state, x, y); } void motionFunc(int x, int y) { printf("Mouse Motion func %d, %d\n", x, y); } void passiveMotionFunc(int x, int y) { printf("Passive Mouse motion func %d, %d\n", x, y); } int main(int argc, char** argv) { glutInit(&argc, argv); glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB); glutInitWindowSize (500, 500); glutInitWindowPosition (100, 100); glutCreateWindow ("Teclado"); init(); glutDisplayFunc(display); glutIdleFunc(idleFunc); glutKeyboardFunc(keyboard); glutKeyboardUpFunc(keyUp); glutReshapeFunc(reshape); glutMouseFunc(mouseFunc); glutMotionFunc(motionFunc); glutPassiveMotionFunc(passiveMotionFunc); glutMainLoop(); return 0; }
[ "reymar_44@hotmail.com" ]
reymar_44@hotmail.com
d5d01a685fd46544410a609923fe17004b64026e
15496ef8e55b49b055858d848bb69c4a45779e59
/TPV2/TPV2/game/RenderSystem.h
8bd63e9f54f197b870eac04fc3d81a5c8d879bb3
[]
no_license
madelino22/TPV2P3
72430c5194138e20940e48808efdffae59b90cdf
77372f8a7bf6d1ea80b4c776f01c1706710a5036
refs/heads/main
2023-05-09T11:18:49.377546
2021-05-28T07:48:09
2021-05-28T07:48:09
366,112,803
0
0
null
null
null
null
UTF-8
C++
false
false
701
h
// This file is part of the course TPV2@UCM - Samir Genaim #pragma once #include <SDL_pixels.h> #include "../ecs/System.h" #include <vector> #include "../ecs/Entity.h" #include "../sdlutils/Texture.h" struct Transform; class RenderSystem: public System { protected: const std::vector<Entity*>* entidades; public: RenderSystem(); virtual ~RenderSystem(); void init() override; void update() override; void getEntities(const std::vector<Entity*>* ent) { entidades = ent; } private: void drawScore(); void drawMsgs(); void drawNames(); Texture* naveIzq; Texture* naveDr; Texture* balaTex; SDL_Rect src_; Transform* tr_; Transform *leftFighter; Transform *rightFighter; };
[ "madelino@ucm.es" ]
madelino@ucm.es
c98d2d9cfcfe61d5b7c46a214fa9ea36a61c03c7
297497957c531d81ba286bc91253fbbb78b4d8be
/third_party/libwebrtc/modules/audio_coding/neteq/tools/neteq_event_log_input.cc
994c15c969282f4a6b650292478020ef000286c5
[ "BSD-3-Clause", "LicenseRef-scancode-unknown-license-reference" ]
permissive
marco-c/gecko-dev-comments-removed
7a9dd34045b07e6b22f0c636c0a836b9e639f9d3
61942784fb157763e65608e5a29b3729b0aa66fa
refs/heads/master
2023-08-09T18:55:25.895853
2023-08-01T00:40:39
2023-08-01T00:40:39
211,297,481
0
0
NOASSERTION
2019-09-29T01:27:49
2019-09-27T10:44:24
C++
UTF-8
C++
false
false
1,851
cc
#include "modules/audio_coding/neteq/tools/neteq_event_log_input.h" #include <limits> #include <memory> #include "absl/strings/string_view.h" #include "modules/audio_coding/neteq/tools/rtc_event_log_source.h" #include "rtc_base/checks.h" namespace webrtc { namespace test { NetEqEventLogInput* NetEqEventLogInput::CreateFromFile( absl::string_view file_name, absl::optional<uint32_t> ssrc_filter) { auto event_log_src = RtcEventLogSource::CreateFromFile(file_name, ssrc_filter); if (!event_log_src) { return nullptr; } return new NetEqEventLogInput(std::move(event_log_src)); } NetEqEventLogInput* NetEqEventLogInput::CreateFromString( absl::string_view file_contents, absl::optional<uint32_t> ssrc_filter) { auto event_log_src = RtcEventLogSource::CreateFromString(file_contents, ssrc_filter); if (!event_log_src) { return nullptr; } return new NetEqEventLogInput(std::move(event_log_src)); } absl::optional<int64_t> NetEqEventLogInput::NextOutputEventTime() const { return next_output_event_ms_; } absl::optional<NetEqInput::SetMinimumDelayInfo> NetEqEventLogInput::NextSetMinimumDelayInfo() const { return next_minimum_delay_event_info_; } void NetEqEventLogInput::AdvanceOutputEvent() { next_output_event_ms_ = source_->NextAudioOutputEventMs(); if (*next_output_event_ms_ == std::numeric_limits<int64_t>::max()) { next_output_event_ms_ = absl::nullopt; } } void NetEqEventLogInput::AdvanceSetMinimumDelay() { next_minimum_delay_event_info_ = source_->NextSetMinimumDelayEvent(); } PacketSource* NetEqEventLogInput::source() { return source_.get(); } NetEqEventLogInput::NetEqEventLogInput( std::unique_ptr<RtcEventLogSource> source) : source_(std::move(source)) { LoadNextPacket(); AdvanceOutputEvent(); AdvanceSetMinimumDelay(); } } }
[ "mcastelluccio@mozilla.com" ]
mcastelluccio@mozilla.com
911bc5a50f3c42269c4422fa2d85321af6b98ddf
cbbcfcb52e48025cb6c83fbdbfa28119b90efbd2
/hackerrank/101 hack 41/D.cpp
36868756e32ac723f344c2dbdb703b85149b70a1
[]
no_license
dmehrab06/Time_wasters
c1198b9f2f24e06bfb2199253c74a874696947a8
a158f87fb09d880dd19582dce55861512e951f8a
refs/heads/master
2022-04-02T10:57:05.105651
2019-12-05T20:33:25
2019-12-05T20:33:25
104,850,524
0
1
null
null
null
null
UTF-8
C++
false
false
1,950
cpp
#include <bits/stdc++.h> #define MIN(X,Y) X<Y?X:Y #define MAX(X,Y) X>Y?X:Y #define ISNUM(a) ('0'<=(a) && (a)<='9') #define ISCAP(a) ('A'<=(a) && (a)<='Z') #define ISSML(a) ('a'<=(a) && (a)<='z') #define ISALP(a) (ISCAP(a) || ISSML(a)) #define MXX 100000000000000000 #define MNN -MXX #define VALID(X,Y,N,M) ((X)>=0 && (X)<(N) && (Y)>=0 && (Y)<(M)) #define LLI long long int #define VI vector<int> #define VLLI vector<long long int> #define MII map<int,int> #define SI set<int> #define PB push_back #define MSI map<string,int> #define PII pair<int,int> #define PLLI pair<LLI,LLI> #define PLLII pair< pair<LLI,LLI> , int > #define FREP(i,I,N) for(int (i)=(I);(i)<=(N);(i)++) #define eps 0.0000000001 #define RFREP(i,N,I) for(int (i)=(N);(i)>=(I);(i)--) #define pi acos(-1.0) #define float double #define MAXMOD 100000000 using namespace std; vector<VI>edges; LLI c[200005]; LLI sc[200005]; void dfs(int cur){ sc[cur]=c[cur]; int d=edges[cur].size(); FREP(i,0,(d-1)){ int nxt=edges[cur][i]; dfs(nxt); sc[cur]+=sc[nxt]; } return; } void bfs(){ } vector<PLLII>myp; int main() { int n; cin>>n; VI line; FREP(i,1,(n+3))edges.PB(line); FREP(i,1,n)scanf("%lld",&c[i]); FREP(i,2,n){ int a; scanf("%d",&a); edges[a].PB(i); } dfs(1); FREP(i,1,n){ PLLII meh=make_pair(make_pair(c[i],sc[i]),i); myp.PB(meh); } priority_queue<PLLII, vector<PLLII> > qq; qq.push(myp[0]); LLI total=0; LLI ase=myp[0].second; while(!qq.empty()){ //int cur=qq.second; PLLII oka=qq.top(); qq.pop(); int cur=oka.second; total+=(oka.first.second-oka.first.first)+(ase-oka.first.first); ase-=oka.first.second; int d=edges[cur].size(); FREP(i,0,(d-1)){ int nxt=edges[cur][i]; qq.push(myp[nxt-1]); } } cout<<total<<"\n"; return 0; }
[ "1205112.zm@ugrad.cse.buet.ac.bd" ]
1205112.zm@ugrad.cse.buet.ac.bd
03f54c54277a34f8093f38b0f257cd8636f51867
93396398ced93f13f65909edc35ef6ed660bf891
/examples/Linalg/Linalg4/Example.cpp
8eedbbdfdce90ce24e55f883ee6b6a7226aa2121
[ "Apache-2.0" ]
permissive
cesarriat/mlir
0affb769fe1ed16f6f9ae23312dd086e1682c4e1
78caf457ce48e04f7767fbae240bd93db541e18d
refs/heads/master
2020-05-09T11:28:09.545193
2019-04-16T00:18:32
2019-04-16T00:18:32
181,080,954
0
0
Apache-2.0
2019-04-12T20:43:57
2019-04-12T20:43:57
null
UTF-8
C++
false
false
8,764
cpp
//===- Example.cpp - Our running example ----------------------------------===// // // Copyright 2019 The MLIR Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // 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. // ============================================================================= // RUN: %p/test | FileCheck %s #include "TestHarness.h" #include "linalg1/Common.h" #include "linalg1/Dialect.h" #include "linalg2/Intrinsics.h" #include "linalg3/Ops.h" #include "linalg4/Transforms.h" #include "mlir/IR/OpImplementation.h" using llvm::StringRef; using namespace mlir; using namespace mlir::edsc; using namespace mlir::edsc::intrinsics; using namespace linalg; using namespace linalg::common; using namespace linalg::intrinsics; Function *makeFunctionWithAMatmulOp(Module &module, StringRef name) { MLIRContext *context = module.getContext(); auto dynamic2DMemRefType = floatMemRefType<2>(context); mlir::Function *f = linalg::common::makeFunction( module, name, {dynamic2DMemRefType, dynamic2DMemRefType, dynamic2DMemRefType}, {}); ScopedContext scope(f); // clang-format off ValueHandle M = dim(f->getArgument(0), 0), N = dim(f->getArgument(2), 1), K = dim(f->getArgument(0), 1), rM = range(constant_index(0), M, constant_index(1)), rN = range(constant_index(0), N, constant_index(1)), rK = range(constant_index(0), K, constant_index(1)), vA = view(f->getArgument(0), {rM, rK}), vB = view(f->getArgument(1), {rK, rN}), vC = view(f->getArgument(2), {rM, rN}); matmul(vA, vB, vC); ret(); // clang-format on return f; } TEST_FUNC(matmul_tiled_loops) { MLIRContext context; Module module(&context); mlir::Function *f = makeFunctionWithAMatmulOp(module, "matmul_tiled_loops"); lowerToTiledLoops(f, {8, 9}); PassManager pm; pm.addPass(createLowerLinalgLoadStorePass()); if (succeeded(pm.run(f->getModule()))) cleanupAndPrintFunction(f); // clang-format off // CHECK-LABEL: func @matmul_tiled_loops(%arg0: memref<?x?xf32>, %arg1: memref<?x?xf32>, %arg2: memref<?x?xf32>) { // CHECK: %[[M:.*]] = dim %arg0, 0 : memref<?x?xf32> // CHECK: %[[N:.*]] = dim %arg2, 1 : memref<?x?xf32> // CHECK: %[[K:.*]] = dim %arg0, 1 : memref<?x?xf32> // CHECK: affine.for %i0 = 0 to (d0) -> (d0)(%[[M]]) step 8 { // CHECK: affine.for %i1 = 0 to (d0) -> (d0)(%[[N]]) step 9 { // CHECK: affine.for %i2 = 0 to (d0) -> (d0)(%[[K]]) { // CHECK: affine.for %i3 = max (d0)[s0] -> (s0, d0)(%i0)[%{{.*}}] to min (d0)[s0] -> (s0, d0 + 8)(%i0)[%[[M]]] { // CHECK: affine.for %i4 = max (d0)[s0] -> (s0, d0)(%i1)[%{{.*}}] to min (d0)[s0] -> (s0, d0 + 9)(%i1)[%[[N]]] { // CHECK-NEXT: %{{.*}} = cmpi "eq", %i2, %{{.*}} : index // CHECK-NEXT: %[[I3:.*]] = affine.apply (d0) -> (d0)(%i3) // CHECK-NEXT: %[[I4:.*]] = affine.apply (d0) -> (d0)(%i4) // CHECK-NEXT: %{{.*}} = load %arg2[%[[I3]], %[[I4]]] : memref<?x?xf32> // CHECK-NEXT: %{{.*}} = select %{{.*}}, %{{.*}}, %{{.*}} : f32 // CHECK-NEXT: %[[I2:.*]] = affine.apply (d0) -> (d0)(%i2) // CHECK-NEXT: %{{.*}} = load %arg1[%[[I2]], %[[I4]]] : memref<?x?xf32> // CHECK-NEXT: %{{.*}} = load %arg0[%[[I3]], %[[I2]]] : memref<?x?xf32> // CHECK-NEXT: %{{.*}} = mulf %10, %9 : f32 // CHECK-NEXT: %{{.*}} = addf %7, %11 : f32 // CHECK-NEXT: store %{{.*}}, %arg2[%[[I3]], %[[I4]]] : memref<?x?xf32> // clang-format on } TEST_FUNC(matmul_tiled_views) { MLIRContext context; Module module(&context); mlir::Function *f = makeFunctionWithAMatmulOp(module, "matmul_tiled_views"); FuncBuilder b(f); lowerToTiledViews(f, {b.create<ConstantIndexOp>(f->getLoc(), 8), b.create<ConstantIndexOp>(f->getLoc(), 9)}); composeSliceOps(f); // clang-format off // CHECK-LABEL: func @matmul_tiled_views(%arg0: memref<?x?xf32>, %arg1: memref<?x?xf32>, %arg2: memref<?x?xf32>) { // CHECK: %[[M:.*]] = dim %arg0, 0 : memref<?x?xf32> // CHECK: %[[N:.*]] = dim %arg2, 1 : memref<?x?xf32> // CHECK: %[[K:.*]] = dim %arg0, 1 : memref<?x?xf32> // CHECK: affine.for %i0 = 0 to (d0) -> (d0)(%[[M]]) step 8 { // CHECK-NEXT: affine.for %i1 = 0 to (d0) -> (d0)(%[[N]]) step 9 { // CHECK-NEXT: %[[i0min:.*]] = affine.apply (d0) -> (d0)(%i0) // CHECK-NEXT: %[[i0max:.*]] = affine.apply (d0) -> (d0 + 8)(%i0) // CHECK-NEXT: %[[ri0:.*]] = linalg.range %[[i0min]]:%[[i0max]]:{{.*}} : !linalg.range // CHECK: %[[rK:.*]] = linalg.range %{{.*}}:%{{.*}}:%{{.*}} : !linalg.range // CHECK: %[[vA:.*]] = linalg.view %arg0[%[[ri0]], %[[rK]]] : !linalg<"view<?x?xf32>"> // CHECK: %[[i1min:.*]] = affine.apply (d0) -> (d0)(%i1) // CHECK-NEXT: %[[i1max:.*]] = affine.apply (d0) -> (d0 + 9)(%i1) // CHECK-NEXT: %[[ri1:.*]] = linalg.range %[[i1min]]:%[[i1max]]:%{{.*}} : !linalg.range // CHECK-NEXT: %[[vB:.*]] = linalg.view %arg1[%10, %13] : !linalg<"view<?x?xf32>"> // CHECK-NEXT: %[[vC:.*]] = linalg.view %arg2[%5, %13] : !linalg<"view<?x?xf32>"> // CHECK-NEXT: linalg.matmul(%[[vA]], %[[vB]], %[[vC]]) : !linalg<"view<?x?xf32>"> // clang-format on cleanupAndPrintFunction(f); } TEST_FUNC(matmul_tiled_views_as_loops) { MLIRContext context; Module module(&context); mlir::Function *f = makeFunctionWithAMatmulOp(module, "matmul_tiled_views_as_loops"); FuncBuilder b(f); lowerToTiledViews(f, {b.create<ConstantIndexOp>(f->getLoc(), 8), b.create<ConstantIndexOp>(f->getLoc(), 9)}); composeSliceOps(f); lowerToLoops(f); // This cannot lower below linalg.load and linalg.store due to lost // information related to loop bounds and tiling. There are multiple ways to // attack the problem, the best one is an IR change. // clang-format off // CHECK-LABEL: func @matmul_tiled_views_as_loops(%arg0: memref<?x?xf32>, %arg1: memref<?x?xf32>, %arg2: memref<?x?xf32>) { // CHECK: %[[M:.*]] = dim %arg0, 0 : memref<?x?xf32> // CHECK: %[[N:.*]] = dim %arg2, 1 : memref<?x?xf32> // CHECK: %[[K:.*]] = dim %arg0, 1 : memref<?x?xf32> // CHECK: affine.for %i0 = 0 to (d0) -> (d0)(%[[M]]) step 8 { // CHECK-NEXT: affine.for %i1 = 0 to (d0) -> (d0)(%[[N]]) step 9 { // CHECK-NEXT: %[[i0min:.*]] = affine.apply (d0) -> (d0)(%i0) // CHECK-NEXT: %[[i0max:.*]] = affine.apply (d0) -> (d0 + 8)(%i0) // CHECK-NEXT: %[[ri0:.*]] = linalg.range %[[i0min]]:%[[i0max]]:{{.*}} : !linalg.range // CHECK: %[[rK:.*]] = linalg.range %{{.*}}:%{{.*}}:%{{.*}} : !linalg.range // CHECK: %[[vA:.*]] = linalg.view %arg0[%[[ri0]], %[[rK]]] : !linalg<"view<?x?xf32>"> // CHECK: %[[i1min:.*]] = affine.apply (d0) -> (d0)(%i1) // CHECK-NEXT: %[[i1max:.*]] = affine.apply (d0) -> (d0 + 9)(%i1) // CHECK-NEXT: %[[ri1:.*]] = linalg.range %[[i1min]]:%[[i1max]]:%{{.*}} : !linalg.range // CHECK-NEXT: %[[vB:.*]] = linalg.view %arg1[%10, %13] : !linalg<"view<?x?xf32>"> // CHECK-NEXT: %[[vC:.*]] = linalg.view %arg2[%5, %13] : !linalg<"view<?x?xf32>"> // CHECK-NEXT: affine.for %i2 = (d0) -> (d0)(%i0) to (d0) -> (d0)(%[[i0max]]) { // CHECK-NEXT: affine.for %i3 = (d0) -> (d0)(%i1) to (d0) -> (d0)(%[[i1max]]) { // CHECK-NEXT: affine.for %i4 = 0 to (d0) -> (d0)(%[[K]]) { // CHECK-NEXT: %{{.*}} = cmpi "eq", %i4, %c0 : index // CHECK-NEXT: %{{.*}} = linalg.load %[[vC]][%i2, %i3] : !linalg<"view<?x?xf32>"> // CHECK-NEXT: %{{.*}} = select %{{.*}}, %cst, %{{.*}} : f32 // CHECK-NEXT: %{{.*}} = linalg.load %[[vB]][%i4, %i3] : !linalg<"view<?x?xf32>"> // CHECK-NEXT: %{{.*}} = linalg.load %[[vA]][%i2, %i4] : !linalg<"view<?x?xf32>"> // CHECK-NEXT: %{{.*}} = mulf %{{.*}}, %{{.*}} : f32 // CHECK-NEXT: %{{.*}} = addf %{{.*}}, %{{.*}} : f32 // CHECK-NEXT: linalg.store %{{.*}}, %[[vC]][%i2, %i3] : !linalg<"view<?x?xf32>"> // clang-format on cleanupAndPrintFunction(f); } int main() { mlir::registerDialect<linalg::LinalgDialect>(); RUN_TESTS(); return 0; }
[ "joker.eph@gmail.com" ]
joker.eph@gmail.com
f5a7f9d1951f135dae96391fa832c031c47c2f53
587aaf4e7844a61f1e292009aae587053e6cb6a8
/Sources/Purchase/AskPurchaseMT.h
e322d11973bd97b4bdad00c82576612971765004
[]
no_license
25311753/runshun_2008r2
15cd7eba2bec1661fb3749bc76539d5f2f2ef953
c069f00913eec20acf215da26121df3e3da8d3f1
refs/heads/master
2021-01-10T22:01:46.990290
2014-07-19T16:08:22
2014-07-19T16:08:22
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,474
h
//--------------------------------------------------------------------------- #ifndef AskPurchaseMTH #define AskPurchaseMTH //--------------------------------------------------------------------------- #include <Classes.hpp> #include <Controls.hpp> #include <StdCtrls.hpp> #include <Forms.hpp> #include <ComCtrls.hpp> #include <ExtCtrls.hpp> #include <ADODB.hpp> #include <DB.hpp> #include <DBCtrls.hpp> #include <DBGrids.hpp> #include <Grids.hpp> //--------------------------------------------------------------------------- class TAskPurchaseMTForm : public TForm { __published: // IDE-managed Components TLabel *Label5; TPageControl *ctlPage; TTabSheet *ctlType; TEdit *edtCorp; TEdit *edtID0; TPanel *Panel1; TEdit *edtID1; TLabel *Label6; TEdit *edtSpec; TLabel *Label1; TComboBox *lstCorp; TLabel *Label2; TComboBox *lstLarge; TLabel *Label3; TComboBox *lstMid; TLabel *Label4; TComboBox *lstMin; TListView *lstView; TTabSheet *ctlTree; TTreeView *lstTree; TListView *lstTreeView; TLabel *Label7; TComboBox *lstTreeCorp; TButton *btnToExcel; TButton *btnOK; TButton *btnCancel; TLabel *Label8; TEdit *edtID; TLabel *Label9; TEdit *edtName; TTabSheet *ctlSearch; TLabel *Label10; TEdit *edtSearchText; TLabel *Label11; TListView *lstSearchView; TButton *btnSearch; TTabSheet *ctlPrefix; TLabel *Label12; TLabel *Label13; TEdit *edtPrefixID; TButton *btnPrefixQuery; TListView *lstPrefixView; TLabel *Label14; TComboBox *lstTreatType; TMemo *Memo1; TButton *btnPrintRem; TButton *btnRem2Excel; TLabel *Label15; TEdit *edtUnits; TGroupBox *GroupBox1; TDBImage *DBImage1; TDataSource *DSMnPic; TADOConnection *ADOC1; TADOTable *ADOT1; TLabel *labCorp; TLabel *labID0; TLabel *labID1; TButton *btnDetail; void __fastcall FormShow(TObject *Sender); void __fastcall FormKeyDown(TObject *Sender, WORD &Key, TShiftState Shift); void __fastcall lstCorpClick(TObject *Sender); void __fastcall lstLargeClick(TObject *Sender); void __fastcall edtID0Change(TObject *Sender); void __fastcall edtCorpChange(TObject *Sender); void __fastcall lstMidClick(TObject *Sender); void __fastcall lstMinClick(TObject *Sender); void __fastcall edtID1Change(TObject *Sender); void __fastcall lstViewSelectItem(TObject *Sender, TListItem *Item, bool Selected); void __fastcall btnOKClick(TObject *Sender); void __fastcall btnToExcelClick(TObject *Sender); void __fastcall ctlTreeShow(TObject *Sender); void __fastcall lstTreeClick(TObject *Sender); void __fastcall lstTreeChange(TObject *Sender, TTreeNode *Node); void __fastcall lstTreeViewSelectItem(TObject *Sender, TListItem *Item, bool Selected); void __fastcall lstTreeCorpClick(TObject *Sender); void __fastcall lstSearchViewSelectItem(TObject *Sender, TListItem *Item, bool Selected); void __fastcall btnSearchClick(TObject *Sender); void __fastcall btnPrefixQueryClick(TObject *Sender); void __fastcall lstPrefixViewSelectItem(TObject *Sender, TListItem *Item, bool Selected); void __fastcall lstTreatTypeClick(TObject *Sender); void __fastcall lstViewDblClick(TObject *Sender); void __fastcall lstPrefixViewDblClick(TObject *Sender); void __fastcall lstTreeViewDblClick(TObject *Sender); void __fastcall lstSearchViewDblClick(TObject *Sender); void __fastcall btnRem2ExcelClick(TObject *Sender); void __fastcall btnPrintRemClick(TObject *Sender); void __fastcall btnDetailClick(TObject *Sender); private: // User declarations CStringArray m_lstCorpID; CStringArray m_lstLargID; CStringArray m_lstMidID; CStringArray m_lstMinID; CStringArray m_lstTreeCorpID; char m_cCurCorp; char m_cCurLarge; CString m_szCurMid; CString m_szCurMin; TTreeNode *m_pNode; CStringArray m_lstTreeID; bool m_bTreeInitialed; enum { EN_CLICK_NONE,EN_CLICK_CORP,EN_CLICK_LARGE,EN_CLICK_MID,EN_CLICK_MIN,EN_CLICK_VIEW,EN_CLICK_INIT } m_enClick; void ResetAllUI(); void ResetCorp(); void ResetMiddle(); void ResetMin(); void ResetView(); public: // User declarations AnsiString m_szMaterCode; int m_nTreatType; int m_nAuthor; __fastcall TAskPurchaseMTForm(TComponent* Owner); }; //--------------------------------------------------------------------------- extern PACKAGE TAskPurchaseMTForm *AskPurchaseMTForm; //--------------------------------------------------------------------------- #endif
[ "25311753@qq.com" ]
25311753@qq.com
282e21d9816c567305b79961b073b2be3636ceb8
3f5fbaef67d1adcf9922179aa48fe7ffd6e8c57a
/Plugins/GraphPrinter/Source/GraphPrinter/Private/GraphPrinterCore.h
1d4b9475b2722c2e45de53701cf1e12ca58d9fe6
[ "MIT" ]
permissive
welflau/GraphPrinter
7aa14b271d7bac298abe470ad61dedc3ac600b97
b27d71e6680eb62d96352bec4c9f8d689f8a5fcb
refs/heads/master
2023-02-23T08:28:27.268113
2021-01-12T13:57:21
2021-01-12T13:57:21
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,230
h
// Copyright 2020 Naotsun. All Rights Reserved. #pragma once #include "CoreMinimal.h" #include "GraphPrinterTypes.h" class SWidget; class SGraphEditor; class SNotificationItem; class UTexture; class UTextureRenderTarget2D; struct FImageWriteOptions; enum class EDesiredImageFormat : uint8; /** * Internal processing functions used in this plugin. */ class GRAPHPRINTER_API FGraphPrinterCore { public: // Define notification types so don't need to include "SNotificationList.h". using TCompletionState = int32; static const TCompletionState CS_Pending; static const TCompletionState CS_Success; static const TCompletionState CS_Fail; public: // Show notifications at the bottom right of the editor (When Expire Duration is 0 or less, you need to call the fade process manually.). static TSharedPtr<SNotificationItem> ShowNotification( const FText& NotificationText, TCompletionState CompletionState, float ExpireDuration = 4.f, ENotificationInteraction InteractionType = ENotificationInteraction::None, const FText& InteractionText = FText(), FSimpleDelegate InteractionCallback = nullptr ); // Recursively collect all child widgets of the specified widget. static void CollectAllChildWidgets(TSharedPtr<SWidget> SearchTarget, TArray<TSharedPtr<SWidget>>& OutChildren); // Get SGraphEditor if it's in a child widget. static TSharedPtr<SGraphEditor> FindGraphEditor(TSharedPtr<SWidget> SearchTarget); // Draw the widget on the render target. // Setting the "NumberOfDrawingAttempts" too high can slow down the operation or, in the worst case, cause the engine to crash. static UTextureRenderTarget2D* DrawWidgetToRenderTarget( TSharedPtr<SWidget> WidgetToRender, const FVector2D& DrawSize, bool bUseGamma, TextureFilter Filter ); // Saves the render target in the specified format. static void SaveTextureAsImageFile(UTexture* Texture, const FString& Filename, const FImageWriteOptions& Options); // Calculate the range and view location to use when drawing the graph editor. static bool CalculateGraphDrawSizeAndViewLocation( FVector2D& DrawSize, FVector2D& ViewLocation, TSharedPtr<SGraphEditor> GraphEditor, float Padding ); // Get the title of the graph being edited in the graph editor. static FString GetGraphTitle(TSharedPtr<SGraphEditor> GraphEditor); // Get the extension by the format of the image file. static FString GetImageFileExtension(EDesiredImageFormat ImageFormat); // Open the folder containing the file in Explorer. static void OpenFolderWithExplorer(const FString& FilePath); #ifdef ENABLE_EMBED_NODE_INFO // Writes the information of the node selected in Graph Editor to the png file. static bool ExportGraphToPngFile(const FString& FilePath, TSharedPtr<SGraphEditor> GraphEditor); // Restore the node from the information read from the png file. static bool RestoreGraphFromPngFile(const FString& FilePath, TSharedPtr<SGraphEditor> GraphEditor); // Show the file browser and let the user select a file. static bool OpenFileDialog( TArray<FString>& FilePaths, const FString& DialogTitle = TEXT("Open File Dialog"), const FString& DefaultPath = TEXT(""), const FString& DefaultFile = TEXT(""), const FString& FileTypes = TEXT("All (*)|*.*"), bool bIsMultiple = false ); // Create an FKeyEvent from FUICommandInfo. static bool GetKeyEventFromUICommandInfo(const TSharedPtr<FUICommandInfo>& UICommandInfo, FKeyEvent& OutKeyEvent); #endif }; /** * Cast function for classes that inherit from SWidget. */ namespace CastSlateWidgetPrivate { template<class To, class From> TSharedPtr<To> CastSlateWidget(TSharedPtr<From> FromPtr, const FName& ToClassName) { static_assert(TIsDerivedFrom<From, SWidget>::IsDerived, "This implementation wasn't tested for a filter that isn't a child of SWidget."); static_assert(TIsDerivedFrom<To, SWidget>::IsDerived, "This implementation wasn't tested for a filter that isn't a child of SWidget."); if (FromPtr.IsValid()) { if (FromPtr->GetType() == ToClassName) { return StaticCastSharedPtr<To>(FromPtr); } } return nullptr; } } #define CAST_SLATE_WIDGET(ToClass, FromPtr) CastSlateWidgetPrivate::CastSlateWidget<ToClass>(FromPtr, #ToClass)
[ "51815450+Naotsun19B@users.noreply.github.com" ]
51815450+Naotsun19B@users.noreply.github.com
df887bccf2d655e8f897112fa316aa3a254f4ea1
d27a676805fd6763d835c3dcf84026dd56e77d78
/Public/ResizableLib/ResizableSheet.cpp
825a94aa790ceee59652fe71d254987f919a2864
[ "Artistic-1.0" ]
permissive
leoqingliu/StateGrid
f106affd49745c0d169e99233fdb834421a4257f
0ddb9751ca2f642e34b5466e2cf07c061abf59c9
refs/heads/master
2021-01-19T12:52:49.512389
2017-03-11T07:25:13
2017-03-11T07:25:13
82,368,869
2
6
null
null
null
null
UTF-8
C++
false
false
7,824
cpp
// ResizableSheet.cpp : implementation file // ///////////////////////////////////////////////////////////////////////////// // // Copyright (C) 2000-2001 by Paolo Messina // (http://www.geocities.com/ppescher - ppescher@yahoo.com) // // The contents of this file are subject to the Artistic License (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.opensource.org/licenses/artistic-license.html // // If you find this code useful, credits would be nice! // ///////////////////////////////////////////////////////////////////////////// #include "stdafx.h" #include "ResizableSheet.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CResizableSheet IMPLEMENT_DYNAMIC(CResizableSheet, CPropertySheet) inline void CResizableSheet::Construct() { m_bInitDone = FALSE; m_bEnableSaveRestore = FALSE; m_bSavePage = FALSE; } CResizableSheet::CResizableSheet() { Construct(); } CResizableSheet::CResizableSheet(UINT nIDCaption, CWnd *pParentWnd, UINT iSelectPage) : CPropertySheet(nIDCaption, pParentWnd, iSelectPage) { Construct(); } CResizableSheet::CResizableSheet(LPCTSTR pszCaption, CWnd *pParentWnd, UINT iSelectPage) : CPropertySheet(pszCaption, pParentWnd, iSelectPage) { Construct(); } CResizableSheet::~CResizableSheet() { } BEGIN_MESSAGE_MAP(CResizableSheet, CPropertySheet) //{{AFX_MSG_MAP(CResizableSheet) ON_WM_GETMINMAXINFO() ON_WM_SIZE() ON_WM_DESTROY() ON_WM_CREATE() ON_WM_ERASEBKGND() //}}AFX_MSG_MAP ON_NOTIFY_REFLECT_EX(PSN_SETACTIVE, OnPageChanging) END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CResizableSheet message handlers int CResizableSheet::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CPropertySheet::OnCreate(lpCreateStruct) == -1) return -1; // keep client area CRect rect; GetClientRect(&rect); // set resizable style ModifyStyle(DS_MODALFRAME, WS_POPUP | WS_THICKFRAME); // adjust size to reflect new style ::AdjustWindowRectEx(&rect, GetStyle(), ::IsMenu(GetMenu()->GetSafeHmenu()), GetExStyle()); SetWindowPos(NULL, 0, 0, rect.Width(), rect.Height(), SWP_FRAMECHANGED| SWP_NOMOVE|SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOREPOSITION); if (!InitGrip()) return -1; return 0; } BOOL CResizableSheet::OnInitDialog() { BOOL bResult = CPropertySheet::OnInitDialog(); // set the initial size as the min track size CRect rc; GetWindowRect(&rc); SetMinTrackSize(rc.Size()); // init UpdateGripPos(); PresetLayout(); // prevent flickering GetTabControl()->ModifyStyle(0, WS_CLIPSIBLINGS); m_bInitDone = TRUE; return bResult; } void CResizableSheet::OnDestroy() { if (m_bEnableSaveRestore) { SaveWindowRect(m_sSection, m_bRectOnly); SavePage(); } RemoveAllAnchors(); CPropertySheet::OnDestroy(); } // maps an index to a button ID and vice-versa static UINT _propButtons[] = { IDOK, IDCANCEL, ID_APPLY_NOW, IDHELP, ID_WIZBACK, ID_WIZNEXT, ID_WIZFINISH }; // horizontal line in wizard mode #define ID_WIZLINE ID_WIZFINISH+1 void CResizableSheet::PresetLayout() { if (IsWizard()) // wizard mode { // hide tab control GetTabControl()->ShowWindow(SW_HIDE); AddAnchor(ID_WIZLINE, BOTTOM_LEFT, BOTTOM_RIGHT); } else // tab mode { AddAnchor(AFX_IDC_TAB_CONTROL, TOP_LEFT, BOTTOM_RIGHT); } // add a callback for active page (which can change at run-time) AddAnchorCallback(1); // use *total* parent size to have correct margins CRect rectPage, rectSheet; GetTotalClientRect(&rectSheet); GetActivePage()->GetWindowRect(&rectPage); ScreenToClient(&rectPage); // pre-calculate margins m_sizePageTL = rectPage.TopLeft() - rectSheet.TopLeft(); m_sizePageBR = rectPage.BottomRight() - rectSheet.BottomRight(); // add all possible buttons, if they exist for (int i = 0; i < 7; i++) { if (NULL != GetDlgItem(_propButtons[i])) AddAnchor(_propButtons[i], BOTTOM_RIGHT); } } BOOL CResizableSheet::ArrangeLayoutCallback(LayoutInfo &layout) { if (layout.nCallbackID != 1) // we only added 1 callback return CResizableLayout::ArrangeLayoutCallback(layout); // set layout info for active page layout.hWnd = GetActivePage()->GetSafeHwnd(); // set margins if (IsWizard()) // wizard mode { // use pre-calculated margins layout.sizeMarginTL = m_sizePageTL; layout.sizeMarginBR = m_sizePageBR; } else // tab mode { CRect rectPage, rectSheet; GetTotalClientRect(&rectSheet); CTabCtrl* pTab = GetTabControl(); pTab->GetWindowRect(&rectPage); pTab->AdjustRect(FALSE, &rectPage); ScreenToClient(&rectPage); // use tab control layout.sizeMarginTL = rectPage.TopLeft() - rectSheet.TopLeft(); layout.sizeMarginBR = rectPage.BottomRight() - rectSheet.BottomRight(); } // set anchor types layout.sizeTypeTL = TOP_LEFT; layout.sizeTypeBR = BOTTOM_RIGHT; // use this layout info return TRUE; } void CResizableSheet::OnSize(UINT nType, int cx, int cy) { CWnd::OnSize(nType, cx, cy); if (nType == SIZE_MAXHIDE || nType == SIZE_MAXSHOW) return; // arrangement not needed if (m_bInitDone) { // update size-grip UpdateGripPos(); ArrangeLayout(); } } BOOL CResizableSheet::OnPageChanging(NMHDR* /*pNotifyStruct*/, LRESULT* /*pResult*/) { // update new wizard page // active page changes after this notification PostMessage(WM_SIZE); return FALSE; // continue routing } BOOL CResizableSheet::OnEraseBkgnd(CDC* pDC) { ClipChildren(pDC); return CPropertySheet::OnEraseBkgnd(pDC); } void CResizableSheet::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI) { if (!m_bInitDone) return; MinMaxInfo(lpMMI); } // protected members int CResizableSheet::GetMinWidth() { CWnd* pWnd = NULL; CRect rectWnd, rectSheet; GetTotalClientRect(&rectSheet); int max = 0, min = rectSheet.Width(); // search for leftmost and rightmost button margins for (int i = 0; i < 7; i++) { pWnd = GetDlgItem(_propButtons[i]); // exclude not present or hidden buttons if (pWnd == NULL || !(pWnd->GetStyle() & WS_VISIBLE)) continue; // left position is relative to the right border // of the parent window (negative value) pWnd->GetWindowRect(&rectWnd); ScreenToClient(&rectWnd); int left = rectSheet.right - rectWnd.left; int right = rectSheet.right - rectWnd.right; if (left > max) max = left; if (right < min) min = right; } // sizing border width int border = GetSystemMetrics(SM_CXSIZEFRAME); // compute total width return max + min + 2*border; } // NOTE: this must be called after all the other settings // to have the window and its controls displayed properly void CResizableSheet::EnableSaveRestore(LPCTSTR pszSection, BOOL bRectOnly, BOOL bWithPage) { m_sSection = pszSection; m_bSavePage = bWithPage; m_bEnableSaveRestore = TRUE; m_bRectOnly = bRectOnly; // restore immediately LoadWindowRect(pszSection, bRectOnly); LoadPage(); } // private memebers // used to save/restore active page // either in the registry or a private .INI file // depending on your application settings #define ACTIVEPAGE _T("ActivePage") void CResizableSheet::SavePage() { if (!m_bSavePage) return; // saves active page index, zero (the first) if problems // cannot use GetActivePage, because it always fails CTabCtrl *pTab = GetTabControl(); int page = 0; if (pTab != NULL) page = pTab->GetCurSel(); if (page < 0) page = 0; AfxGetApp()->WriteProfileInt(m_sSection, ACTIVEPAGE, page); } void CResizableSheet::LoadPage() { // restore active page, zero (the first) if not found int page = AfxGetApp()->GetProfileInt(m_sSection, ACTIVEPAGE, 0); if (m_bSavePage) { SetActivePage(page); ArrangeLayout(); // needs refresh } }
[ "leo.qing.liu@gmail.com" ]
leo.qing.liu@gmail.com
d9869b623cdcd0100a47f3b3d4ded5cd503dd90a
55bea1bcfdb4472ae828cbb3c161ee70236fa339
/class_spin_matrix.h
a00646245789df9051a3f2f3a3fcdb26d2afcd11
[]
no_license
gintrona/SpinorClass
edb9b0865dea8d4117bd3f664582509fec5eb241
2047f7acaeffed36772a89e7a68f679608025b83
refs/heads/master
2020-06-04T13:28:36.304898
2015-05-23T07:27:54
2015-05-23T07:27:54
22,616,402
0
0
null
null
null
null
UTF-8
C++
false
false
1,460
h
#ifndef SPIN_MATRIX_COMPLEX #define SPIN_MATRIX_COMPLEX #include"gsl/gsl_matrix.h" #include"class_spinor.h" class spin_matrix_complex{ public: //CONTRUCTORS //WITH PARAMETERS spin_matrix_complex(const int & numRows, const int & numColumns); //por copia spin_matrix_complex(const spin_matrix_complex & anotherMatrix); //destructor ~spin_matrix_complex(); //GETTERS y SETTERS const gsl_complex spin_matrix_complex_get(const int & i ,SPIN spin_i ,const int & j, SPIN spin_j) const; //set the value of the element (i,j) void spin_matrix_complex_set( const int & i , SPIN spin_i, const int & j, SPIN spin_j, const gsl_complex & c_value ); //returns the pointer to the underlying gsl-matrix gsl_matrix_complex * pMatriz() const; //Write and read const int spin_matrix_complex_numSites() const; //write the matrix in a file (ascii with floats) void spin_matrix_complex_fprintf(FILE *) const; //write the matri in a file (binary format) void spin_matrix_complex_fwrite(FILE *) const; //read the file (ascii format with floats) void spin_matrix_complex_fscanf(FILE *) const; //read the file in binary format void spin_matrix_complex_fread(FILE *) const; //OPERATIONS //symmetrize the matrix void spin_matrix_complex_symmetrize(); private: gsl_matrix_complex * pMatrix; unsigned int _numSites; unsigned int dimension; unsigned int numRowsWithSpin; unsigned int numColsWithSpin; }; #endif
[ "gintronati@users.noreply.github.com" ]
gintronati@users.noreply.github.com
3c8a8d6ffcbf08fad93a0aaa3ea2c037b05268fa
6e25c49160136c226fb698da6da570cacdab1156
/codeforces/405A.cpp
b975dafbfdc84a6ec2871b1947f729d3e6c9f242
[]
no_license
amitkvikram/COMPETITIVE-PROGRAMMING
627627447f777192e092289989ebc60a8e67ae60
cfa7ee44884e8739813e4f2779a0eb121bd3aa92
refs/heads/master
2021-10-22T11:07:19.763820
2019-03-10T03:42:43
2019-03-10T03:42:43
103,694,836
1
0
null
null
null
null
UTF-8
C++
false
false
311
cpp
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef std::vector<int> vi; int main(int argc, char const *argv[]) { int n; cin>>n; vi v(n); for(int i =0; i<n; i++){ cin>>v[i]; } sort(v.begin(), v.end()); for(int i =0; i<n; i++){ cout<<v[i]<<' '; } return 0; }
[ "amitkvikram@rediffmail.com" ]
amitkvikram@rediffmail.com
e407d211cbc8b6471cdf8dba4282f536c5ed03db
1c2be2c2fc156baad3e2992d8946342a32280e97
/Main.cpp
2b63812c3bcccbdc318b13500ae51b22d6c15a94
[]
no_license
chicolismo/cesar2
e7506c616848bb4fcdea594486577fd7ee1d9567
e4add0e227e4edc98ff34bdbaa65c709ba73de41
refs/heads/master
2020-05-16T16:16:03.378014
2019-04-26T07:23:47
2019-04-26T07:23:47
183,094,782
0
0
null
null
null
null
UTF-8
C++
false
false
607
cpp
#pragma clang diagnostic push #pragma ide diagnostic ignored "cert-err58-cpp" #pragma ide diagnostic ignored "cppcoreguidelines-pro-type-static-cast-downcast" #ifdef WX_PRECOMP #include <wx/wxprec.h> #else #include <wx/wx.h> #include "MainFrame.h" #endif class Application : public wxApp { public: bool OnInit() override; }; bool Application::OnInit() { wxInitAllImageHandlers(); MainFrame *main_frame = new MainFrame(nullptr, wxID_ANY, wxT("Cesar")); SetTopWindow(main_frame); main_frame->Show(true); return true; } IMPLEMENT_APP(Application) #pragma clang diagnostic pop
[ "carlosfpinheiro@gmail.com" ]
carlosfpinheiro@gmail.com
5b001551daa8471c1b877d320a5756415f6db6ed
341fbbaa6d7e9b8cf5beba68bde5c8c1090cf3ef
/ACM 模板代码/f-有向图的强连通分量/f-有向图的强连通分量/main.cpp
6af87a9a46d8d752848957cd6ee5a2a5a48317e3
[]
no_license
webturing/ACM-1
0ceb79e5439a95315234ae1e8bee93b353305459
7fcf14d1ff2ae42b001139d04bde01378fb4f5c4
refs/heads/master
2020-03-19T17:33:37.098619
2018-06-09T17:07:14
2018-06-09T17:07:14
136,766,339
3
0
null
2018-06-09T23:59:30
2018-06-09T23:59:30
null
UTF-8
C++
false
false
3,945
cpp
// // main.cpp // f-有向图的强连通分量 // // Created by ZYJ on 16/7/17. // Copyright © 2016年 ZYJ. All rights reserved. // #include <iostream> using namespace std; // Tarjan ///* // * Tarjan算法 // * 复杂度O(N+M) // */ //const int MAXN = 20010; // 点数 //const int MAXM = 50010; // 边数 // //struct Edge //{ // int to, next; //}edge[MAXM]; // //int head[MAXN], tot; //int Low[MAXN], DFN[MAXN], Stack[MAXN], Belong[MAXN]; // Belong数组的值是1~scc //int Index, top; //int scc; // 强连通分量的个数 //bool Instack[MAXN]; //int num[MAXN]; // 各个强连通分量包含点的个数,数组编号1~scc // // num数组不一定需要,结合实际情况 //void addedge(int u, int v) //{ // edge[tot].to = v; // edge[tot].next = head[u]; // head[u] = tot++; // return ; //} // //void Tarjan(int u) //{ // int v; // Low[u] = DFN[u] = ++Index; // Stack[top++] = u; // Instack[u] = true; // for (int i = head[u]; i != -1; i = edge[i].next) // { // v = edge[i].to; // if (!DFN[v]) // { // Tarjan(v); // if (Low[u] > Low[v]) // { // Low[u] = Low[v]; // } // } // else if (Instack[v] && Low[u] > DFN[v]) // { // Low[u] = DFN[v]; // } // } // if (Low[u] == DFN[u]) // { // scc++; // do // { // v = Stack[--top]; // Instack[v] = false; // Belong[v] = scc; num[scc]++; // } // while (v != u); // } // return ; //} // //void solve(int N) //{ // memset(DFN, 0, sizeof(DFN)); // memset(Instack, false, sizeof(Instack)); // memset(num, 0, sizeof(num)); // Index = scc = top = 0; // for (int i = 1; i <= N; i++) // { // if (!DFN[i]) // { // Tarjan(i); // } // } // return ; //} // //void init() //{ // tot = 0; // memset(head, -1, sizeof(head)); // return ; //} // Kosaraju /* * 复杂度O(N+M) */ const int MAXN = 20010; const int MAXM = 50010; struct Edge { int to, next; } edge1[MAXM], edge2[MAXM]; // edge1是原图G,edge2是逆图GT int head1[MAXN], head2[MAXN]; bool mark1[MAXN], mark2[MAXN]; int tot1, tot2; int cnt1, cnt2; int st[MAXN]; // 对原图进行dfs,点的结束时间从小到大排序 int Belong[MAXN]; // 每个点属于哪个连通分量(0~cnt2-1) int num; // 中间变量,用来数某个连通分量中点的个数 int setNum[MAXN]; // 强连通分量中点的个数,编号0~cnt2-1 void addedge(int u, int v) { edge1[tot1].to = v; edge1[tot1].next = head1[u]; head1[u] = tot1++; edge2[tot2].to = u; edge2[tot2].next = head2[v]; head2[v] = tot2++; return ; } void DFS1(int u) { mark1[u] = true; for (int i = head1[u]; i != -1; i = edge1[i].next) { if(!mark1[edge1[i].to]) { DFS1(edge1[i].to); } } st[cnt1++] = u; return ; } void DFS2(int u) { mark2[u] = true; num++; Belong[u] = cnt2; for (int i = head2[u]; i != -1; i = edge2[i].next) { if(!mark2[edge2[i].to]) { DFS2(edge2[i].to); } } return ; } void solve(int n) // 点的编号从1开始 { memset(mark1, false, sizeof(mark1)); memset(mark2, false, sizeof(mark2)); cnt1 = cnt2 = 0; for (int i = 1; i <= n; i++) { if (!mark1[i]) { DFS1(i); } } for (int i = cnt1 - 1; i >= 0; i--) { if (!mark2[st[i]]) { num = 0; DFS2(st[i]); setNum[cnt2++] = num; } } return ; } int main(int argc, const char * argv[]) { std::cout << "Hello, World!\n"; return 0; }
[ "1179754741@qq.com" ]
1179754741@qq.com
118e062bfb829c329347e4bb7f25d2d027db2818
cddf0052367e8a53a1dd2a9b93694ffb766a8be9
/asteroids/src/Game.h
2a184a3333baf66b4f689be83ae9956b916bee9f
[ "MIT" ]
permissive
RATIU5/asteroids
fac100eeabca3f42c190d43d5475109d503907af
afddf134d21e1028f6f35f4f1db255851e658cb3
refs/heads/main
2023-06-24T10:37:19.460002
2023-06-20T21:04:38
2023-06-20T21:04:38
292,733,412
0
0
null
null
null
null
UTF-8
C++
false
false
657
h
#pragma once #include <vector> #include "Motion.h" #include "Vector.h" #include "Rocks.h" #include "Ship.h" #include "Bullet.h" #include "Alien.h" #include "UIInteract.h" #define START_ASTEROIDS 5 #define MIN_ASTEROIDS 5 class Game { private: vec2 boundsMin; vec2 boundsMax; std::vector<Rock*> rocks; std::vector<Bullet> bullets; std::vector<Alien> aliens; Ship ship; public: Game(const vec2& tl, const vec2& br); void update(); void handleInput(const Interface& interface); void draw(const Interface& interface); void split(Rock* rock); void restart(); void addRock(const vec2& pos, const vec2& vel); };
[ "jcmemmott20@outlook.com" ]
jcmemmott20@outlook.com
909e4c6d25cb5e223931f20710542bf57a74a6ac
e966d5df4db23e394a5e24cfd387a912e9004be9
/Competitive_Programming/TopCoder/BadNeighbor.cpp
da8a14fd851f02728a784d64dbf9c5314a6748d3
[]
no_license
Tatvam/Data-Structure-And-Algorithms
f90f6a436841620e1209d8b89bd618eec97caede
abe1e2b6ca2a6796bfb25c9af19a13850351c6ff
refs/heads/master
2020-03-12T17:40:29.702916
2018-11-06T06:37:37
2018-11-06T06:37:37
130,742,021
0
0
null
null
null
null
UTF-8
C++
false
false
630
cpp
#include <bits/stdc++.h> using namespace std; class BadNeighbors { public: int maxDonations(vector<int> a){ int n = a.size(); vector<int> dp(1005,0); vector<int> dp1(1005,0); //if 0 index is taken dp[0] = a[0]; for(int i = 1; i <= n-2; i++){ if(i == 1){ dp[1] = max(dp[0],dp[1]); } else dp[i]=max(dp[i-1],dp[i-2]+a[i]); } dp[n-1]=dp[n-2]; // if 0 not taken dp[0] = 0; dp1[1]=a[1]; for(int i = 2; i <= n-1; i++){ dp1[i]=max(dp1[i-1],dp1[i-2]+a[i]); } return max(dp[n-1],dp1[n-1]); } };
[ "td14@iitbbs.ac.in" ]
td14@iitbbs.ac.in
70a3ddd66a1321718b8a99d9f72718b272e1bceb
8f35b4775733b97f4696cf94d65cf71d6af9a86a
/source/Graphics/Window.h
d81e655d427bb10979f70a749a672bbbc5f1cf20
[]
no_license
Fro-Z/Reversi
f1b0c625a98945dc98989478d1592a869c6a4f72
467ddc8e5091d77826f405843a79b6e044c58df7
refs/heads/master
2021-05-15T23:43:47.812966
2017-10-14T16:41:02
2017-10-14T16:41:02
106,934,628
0
0
null
null
null
null
UTF-8
C++
false
false
567
h
#ifndef WINDOW_H_ #define WINDOW_H_ #include <ncurses.h> #include "Drawable.h" /** * Wrapper class for ncurses window */ class Window: public Drawable { public: Window(int posX, int posY, int width, int height); virtual ~Window(); ///Draw window virtual void Draw() override; ///Enable or disable border around window void SetBorder(bool enabled); protected: void DrawBorder(); void RemoveBorder(); const int posX; const int posY; const int width; const int height; bool drawBorder; WINDOW* ncursesWin; //ncurses window }; #endif /* WINDOW_H_ */
[ "fro-z@email.cz" ]
fro-z@email.cz
49c14738d3c57494c41305fc256ea2ffd32518d0
ee819cbb90cc24ea7e285986e055f4005bc7513f
/Data Structure/Trie/Trie01(SuffixContactBook).cpp
8e2611e3ce154faa3f8e91f250b50a7128271fdc
[]
no_license
Imran4424/Hackerrank-Solutions
d6eaec624bfb3e45e3ad1455b54c03baa93ed627
374a8aee2370f68b438a797e02d046938eed397a
refs/heads/master
2021-07-14T16:56:44.572516
2020-07-22T11:14:29
2020-07-22T11:14:29
183,985,195
0
0
null
null
null
null
UTF-8
C++
false
false
7,457
cpp
#include <iostream> #include <stdio.h> using namespace std; const int tSize = 63; /// string merge sort /// compare String int compareString(char *source, char *destination) { int i; for(i = 0; source[i]; i++) { if(source[i] != destination[i]) { return source[i] - destination[i]; } } return source[i] - destination[i]; } /// copy string void copyString(char *dest, char *source) { int i; for(i = 0; source[i]; i++) { dest[i] = source[i]; } dest[i] = '\0'; } void merge(char arr[][12], char left[][12], int leftSize, char right[][12], int rightSize) { int i = 0, j = 0, index = 0; while(i < leftSize && j < rightSize) { if(compareString(left[i], right[j]) <= 0) { copyString(arr[index], left[i++]); } else { copyString(arr[index], right[j++]); } index++; } while(i < leftSize) { copyString(arr[index++], left[i++]); } while(j < rightSize) { copyString(arr[index++], right[j++]); } } void mergeSort(char (*arr)[12], int aSize) { if(aSize < 2) { return; } int mid = aSize / 2; char left[mid][12]; char right[aSize - mid][12]; int index = 0; for(int i = 0; i < mid; i++) { copyString(left[i], arr[index++]); } for(int i = 0; i < aSize - mid; i++) { copyString(right[i], arr[index++]); } mergeSort(left, mid); mergeSort(right, aSize - mid); merge(arr, left, mid, right, aSize - mid); } struct node { bool endMark; int count; node *next[tSize]; node () { endMark = false; count = 0; for(int i = 0; i < tSize; i++) { next[i] = NULL; } } }; node *rootTrie; /// string reverse char* reverseString(char *word, int length) { char *reversed = new char[length + 1]; int i, j; for(i = 0, j = length - 1; i < length && j >= 0; i++, j--) { reversed[i] = word[j]; } reversed[i] = '\0'; return reversed; } /// string length int stringLength(char *word) { int length = 0; for(int i = 0; word[i]; i++) { length++; } return length; } void trieInsert(char *word) { node* travel = rootTrie; int length = stringLength(word); word = reverseString(word, length); for(int i = 0; word[i]; i++) { int letter; if(word[i] >= 'A' && word[i] <= 'Z') { letter = word[i] - 'A'; } else if(word[i] >= 'a' && word[i] <= 'z') { letter = word[i] - 'a' + 26; } else { letter = word[i] - '0' + 52; } if(NULL == travel -> next[letter]) { travel -> next[letter] = new node(); } travel = travel -> next[letter]; } travel -> endMark = true; travel -> count = travel -> count + 1; } int trieSearch(char *word) { node* travel = rootTrie; int length = stringLength(word); word = reverseString(word, length); for(int i = 0; word[i]; i++) { int letter; if(word[i] >= 'A' && word[i] <= 'Z') { letter = word[i] - 'A'; } else if(word[i] >= 'a' && word[i] <= 'z') { letter = word[i] - 'a' + 26; } else { letter = word[i] - '0' + 52; } if(NULL == travel -> next[letter]) { return 0; } travel = travel -> next[letter]; } return travel -> count; } void trieDeleteAll(node* travel) { for (int i = 0; i < tSize; ++i) { if(travel -> next[i]) { trieDeleteAll(travel -> next[i]); } } // dont remove // just reset the node // removing will cause segmentation fault travel -> endMark = false; travel -> count = 0; } void trieDelete(char *word) { node* travel = rootTrie; int length = stringLength(word); word = reverseString(word, length); for(int i = 0; word[i]; i++) { int letter; if(word[i] >= 'A' && word[i] <= 'Z') { letter = word[i] - 'A'; } else if(word[i] >= 'a' && word[i] <= 'z') { letter = word[i] - 'a' + 26; } else { letter = word[i] - '0' + 52; } if(NULL == travel -> next[letter]) { return; } travel = travel -> next[letter]; } /// deletion travel -> endMark = false; travel -> count = 0; } void trieDeleteSuffix(char *word) { node* travel = rootTrie; int length = stringLength(word); word = reverseString(word, length); for(int i = 0; word[i]; i++) { int letter; if(word[i] >= 'A' && word[i] <= 'Z') { letter = word[i] - 'A'; } else if(word[i] >= 'a' && word[i] <= 'z') { letter = word[i] - 'a' + 26; } else { letter = word[i] - '0' + 52; } if(NULL == travel -> next[letter]) { return; } travel = travel -> next[letter]; } trieDeleteAll(travel); } char arrTrie[100][12]; int indexTrie; void triePrintAll(node* travel, char *word, int pos) { if(NULL == travel) { return; } if(travel -> endMark) { word[pos] = '\0'; word = reverseString(word, pos); copyString(arrTrie[indexTrie++], word); } for (int i = 0; i < tSize; ++i) { if(travel -> next[i]) { if(i >= 0 && i <= 25) { word[pos] = i + 'A'; } else if(i >= 26 && i <= 51) { word[pos] = (i + 'a' - 26); } else { word[pos] = i + '0' - 52; } triePrintAll(travel -> next[i], word, pos + 1); } } } void triePrintSuffix(char *word) { node* travel = rootTrie; int length = stringLength(word); word = reverseString(word, length); int i; for(i = 0; word[i]; i++) { int letter; if(word[i] >= 'A' && word[i] <= 'Z') { letter = word[i] - 'A'; } else if(word[i] >= 'a' && word[i] <= 'z') { letter = word[i] - 'a' + 26; } else { letter = word[i] - '0' + 52; } if(NULL == travel -> next[letter]) { return; } travel = travel -> next[letter]; } indexTrie = 0; triePrintAll(travel, word, i); mergeSort(arrTrie, indexTrie); for(int x = 0; x < indexTrie; x++) { printf("%s\n", arrTrie[x]); } } int main() { /* Enter your code here. Read input from STDIN. Print output to STDOUT */ rootTrie = new node(); char word[12]; int command; while(scanf("%d", &command) != EOF) { if(0 == command) { indexTrie = 0; triePrintAll(rootTrie, word, 0); mergeSort(arrTrie, indexTrie); for(int x = 0; x < indexTrie; x++) { printf("%s\n", arrTrie[x]); } } else if (1 == command) { scanf("%s", word); trieInsert(word); } else if (2 == command) { scanf("%s", word); printf("%d\n", trieSearch(word)); } else if (3 == command) { scanf("%s", word); trieDelete(word); } else if(4 == command) { scanf("%s", word); triePrintSuffix(word); } else if(5 == command) { scanf("%s", word); trieDeleteSuffix(word); } } return 0; }
[ "akashganga.programming.534363@gmail.com" ]
akashganga.programming.534363@gmail.com
51395f6a62da4883da24c1db68dae02cff4b9028
f87d3c1fd79f9c4abe65348b415b211997b838e7
/src/FootTrajectoryGeneration/FootTrajectoryGenerationStandard.hh
095e01adeac45eab5897e5434134cfdf92cad5c9
[]
no_license
stack-of-tasks/contact-to-contact-trajectory
5c674a7fb5ffe7f0d0a2357641209fe5249a5244
2b74404d893183af42737df1c95b90dc302a353b
refs/heads/master
2021-05-02T09:05:22.105731
2016-11-04T13:04:02
2016-11-04T13:04:02
72,829,637
1
0
null
null
null
null
UTF-8
C++
false
false
9,340
hh
/* * Copyright 2008, 2009, 2010, * * * Olivier Stasse * * JRL, CNRS/AIST * * This file is part of walkGenJrl. * walkGenJrl 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. * * walkGenJrl is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Lesser Public License for more details. * You should have received a copy of the GNU Lesser General Public License * along with walkGenJrl. If not, see <http://www.gnu.org/licenses/>. * * Research carried out within the scope of the * Joint Japanese-French Robotics Laboratory (JRL) */ /*! \file FootTrajectoryGenerationStandard.h \brief This object generate all the values for the foot trajectories. @ingroup foottrajectorygeneration */ #ifndef _FOOT_TRAJECTORY_GENERATION_STANDARD_H_ #define _FOOT_TRAJECTORY_GENERATION_STANDARD_H_ /* Walking pattern generation related inclusions */ #include <FootTrajectoryGeneration/FootTrajectoryGenerationAbstract.hh> #include <Mathematics/PolynomeFoot.hh> namespace PatternGeneratorJRL { /** @ingroup foottrajectorygeneration This class generates a trajectory for the swinging foot during single support phase. It uses a classical approach relying in polynome of 3rd orders for the position in the orthogonal plan as well as the direction.For the height modification a 4th order polynome is used. Finally a landing and take off phase using an angular value (\f$\omega\f$). */ class FootTrajectoryGenerationStandard : public FootTrajectoryGenerationAbstract { public: /*!\name Constants related to the direction for the generation of the polynomes. @{ */ /*! \brief along the frontal direction */ const static unsigned int X_AXIS = 0; /*! \brief along the left of the robot */ const static unsigned int Y_AXIS = 1; /*! \brief along the vertical axis of the robot. */ const static unsigned int Z_AXIS = 2; /*! \brief Along the direction of the robot*/ const static unsigned int THETA_AXIS = 3; /*! \brief Angle used by the swinging foot for taking off. */ const static unsigned int OMEGA_AXIS = 4; /*! \brief Angle used by the swinging foot for landing */ const static unsigned int OMEGA2_AXIS = 5; /* @} */ /*! Constructor: In order to compute some appropriate strategies, this class needs to extract specific details from the humanoid model. */ FootTrajectoryGenerationStandard(FootSpecifications *aFoot); /*! Default destructor. */ virtual ~FootTrajectoryGenerationStandard(); /*! This method computes the position of the swinging foot during single support phase, and maintain a constant position for the support foot. It uses polynomial of 3rd order for the X-axis, Y-axis, orientation in the X-Z axis, and orientation in the X-Y axis, and finally it uses a 4th order polynome for the Z-axis. @param SupportFootAbsolutePositions: Queue of absolute position for the support foot. This method will set the foot position at index CurrentAbsoluteIndex of the queue. This position is supposed to be constant. @param NoneSupportFootAbsolutePositions: Queue of absolute position for the swinging foot. This method will set the foot position at index NoneSupportFootAbsolutePositions of the queue. @param CurrentAbsoluteIndex: Index in the queues of the foot position to be set. @param IndexInitial: Index in the queues which correspond to the starting point of the current single support phase. @param ModulatedSingleSupportTime: Amount of time where the foot is flat. @param StepType: Type of steps (for book-keeping). @param LeftOrRight: Specify if it is left (1) or right (-1). */ virtual void UpdateFootPosition(deque<FootAbsolutePosition> &SupportFootAbsolutePositions, deque<FootAbsolutePosition> &NoneSupportFootAbsolutePositions, int CurrentAbsoluteIndex, int IndexInitial, double ModulatedSingleSupportTime, int StepType,int LeftOrRight); virtual void UpdateFootPosition(deque<FootAbsolutePosition> &SupportFootAbsolutePositions, deque<FootAbsolutePosition> &NoneSupportFootAbsolutePositions, int StartIndex, int k, double LocalInterpolationStartTime, double ModulatedSingleSupportTime, int StepType, int LeftOrRight); /*! Initialize internal data structures. In this specific case, it is in charge of creating the polynomial structures. */ virtual void InitializeInternalDataStructures(); /*! Free internal data structures. In this specific case, it is in charge of freeing the polynomial data structures. */ virtual void FreeInternalDataStructures(); /*! This method specifies the parameters for each of the polynome used by this object. In this case, as it is used for the 3rd order polynome. The polynome to which those parameters are set is specified with PolynomeIndex. It assumes an initial position and an initial speed set to zero. @param[in] AxisReference: Set to which axis the parameters will be applied. @param[in] TimeInterval: Set the time base of the polynome. @param[in] Position: Set the final position of the polynome at TimeInterval. */ int SetParameters(int AxisReference, double TimeInterval, double Position); /*! This method specifies the parameters for each of the polynome used by this object. In this case, as it is used for the 3rd order polynome. The polynome to which those parameters are set is specified with PolynomeIndex. @param[in] AxisReference: Set to which axis the parameters will be applied. @param[in] TimeInterval: Set the time base of the polynome. @param[in] FinalPosition: Set the final position of the polynome at TimeInterval. @param[in] InitPosition: Initial position when computing the polynome at t=0.0. @param[in] InitSpeed: Initial speed when computing the polynome at t=0.0. */ int SetParametersWithInitPosInitSpeed(int AxisReference, double TimeInterval, double FinalPosition, double InitPosition, double InitSpeed); /*! This method get the parameters for each of the polynome used by this object. In this case, as it is used for the 3rd order polynome. The polynome to which those parameters are set is specified with PolynomeIndex. @param[in] AxisReference: Set to which axis the parameters will be applied. @param[in] TimeInterval: Set the time base of the polynome. @param[in] FinalPosition: Set the final position of the polynome at TimeInterval. @param[in] InitPosition: Initial position when computing the polynome at t=0.0. @param[in] InitSpeed: Initial speed when computing the polynome at t=0.0. */ int GetParametersWithInitPosInitSpeed(int AxisReference, double &TimeInterval, double &FinalPosition, double &InitPosition, double &InitSpeed); /// \brief Set parameters considering initial position, speed, acceleration. /// /// \param[in] PolynomeIndex /// \param[in] TimeInterval /// \param[in] FinalPosition /// \param[in] InitPosition /// \param[in] InitSpeed /// \param[in] InitAcc int SetParameters(int PolynomeIndex, double TimeInterval, double FinalPosition, double InitPosition, double InitSpeed, double InitAcc); /*! Fill an absolute foot position structure for a given time. */ double ComputeAll(FootAbsolutePosition & aFootAbsolutePosition, double Time); /*! Compute the value for a given polynome. */ double Compute(unsigned int PolynomeIndex, double Time); /*! Compute the value for a given polynome's second derivative. */ double ComputeSecDerivative(unsigned int PolynomeIndex, double Time); /*! Compute the absolute foot position from the queue of relative positions. There is not direct dependency with time. */ void ComputingAbsFootPosFromQueueOfRelPos(deque<RelativeFootPosition> &RelativeFootPositions, deque<FootAbsolutePosition> &AbsoluteFootPositions); /*! Methods to compute a set of positions for the feet according to the discrete time given in parameters and the phase of walking. @{ */ /*! @} */ void print(); protected: /*! \brief Polynomes for X and Y axis positions*/ Polynome5 *m_PolynomeX,*m_PolynomeY; /*! \brief Polynome for X-Y orientation */ Polynome3 *m_PolynomeTheta; /*! \brief Polynome for Y-Z orientation */ Polynome3 *m_PolynomeOmega, *m_PolynomeOmega2; /*! \brief Polynome for Z axis position. */ Polynome4 *m_PolynomeZ; /*! \brief Foot dimension. */ double m_FootB, m_FootH, m_FootF; /*! \brief Position of the ankle in the left foot. */ vector3d m_AnklePositionLeft; /*! \brief Position of the ankle in the right foot. */ vector3d m_AnklePositionRight; }; } #endif /* _FOOT_TRAJECTORY_GENERATION_ABSTRACT_H_ */
[ "ostasse@laas.fr" ]
ostasse@laas.fr
e2affb2a64b9d01b638e4aa4d741c25ee24eebaa
9f30c9b456d30f022ddd72993480cee64830523c
/SuperTrace/SuperTrace/src/Camera.cpp
a4f883d46d854ad46ce08fab5fa0f221ac4c1f2f
[]
no_license
leag37/RayTracer
8a3103e68985987f99b5faa106d31b67d6b060ad
b7c76ebe46de1acdc0383cb7f4e8afc743797331
refs/heads/master
2021-01-15T20:57:39.124453
2013-12-12T16:44:30
2013-12-12T16:44:30
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,301
cpp
//************************************************************************************************* // Title: Camera.cpp // Author: Gael Huber // Description: A camera in the world. //************************************************************************************************* #include "Camera.h" #include "STMath.h" namespace SuperTrace { /** Constructor */ Camera::Camera() : _width(0), _height(0), _aspectRatio(0.0f), _fov(0.0f), _position(Vector3()), _forward(Vector3(0.0f, 0.0f, -1.0f)) { } /** Constructor * @param * width The view plane width * @param * height The view plane height * @param * fov The viewing angle for this camera */ Camera::Camera(unsigned int width, unsigned int height, float fov) : _width(width), _height(height), _fov(fov), _position(Vector3()), _forward(Vector3(0.0f, 0.0f, -1.0f)) { _aspectRatio = static_cast<float>(width) / static_cast<float>(height); } /** Set the position of the camera * @param * v The new position */ void Camera::setPosition(const Vector3& v) { _position = v; } /** Get the position of the camera * @return * Vector3 The position vector */ const Vector3& Camera::getPosition() const { return _position; } /** Set the forward direction of the camera * @param * v The new forward direction */ void Camera::setForward(const Vector3& v) { _forward = v; } /** Get the forward for the camera * @return * Vector3 The forward for the camera */ const Vector3& Camera::getForward() const { return _forward; } /** Given a raster position on the screen, return a view ray * @param * x The x raster position * @param * y The y raster position * @return * Ray The ray that goes from the camera's origin through the specified raster position */ Ray Camera::rasterToRay(unsigned int x, unsigned int y) const { // First, remap from raster space to screen space float fX = static_cast<float>(x); float fY = static_cast<float>(y); float fWidth = static_cast<float>(_width); float fHeight = static_cast<float>(_height); // First map fX and fY from raster space to NDC space float sX = (fX + 0.5f) / fWidth; float sY = (fY + 0.5f) / fHeight; // Next, map from NDC to screen space sX = (2.0f * sX) - 1.0f; sY = 1.0f - (2.0f * sY); // Apply aspect ratio to X coordinate sX *= _aspectRatio; // TEST - y aspect ratio // As y deviates from the center line, scale it by a fraction of the inverse aspect ratio //float invAspect = 1.0f / _aspectRatio; //sY *= invAspect; // END TEST // Multiply by field of view sX *= _fov; sY *= _fov; // Now we can get the position of the point in camera space as (sX, sY, -1) Vector3 pCamera = Vector3(sX, sY, -1.0f); Vector3 rayDirection = pCamera - _position; // Build the perspective matrix float f = 1.0f / _fov; float near = 1.0f; float far = 1000.0f; Matrix44 persp = Matrix44( f, 0.0f, 0.0f, 0.0f, 0.0f, f, 0.0f, 0.0f, 0.0f, 0.0f, far/(far-near), 1.0f, 0.0f, 0.0f, -(far*near)/(far-near), 0.0f); rayDirection = Vector3Transform(rayDirection, persp); rayDirection.normalize(); return Ray(_position, rayDirection); } } // Namespace
[ "gael.scott.huber@gmail.com" ]
gael.scott.huber@gmail.com
1bb3a3ce4329afa33d9e9abb8ed9185769115498
24653c0a8be19e46eb95451de1d961ffbcc01341
/software/src/8.1/src/kernel/Vca_VcaOffer.cpp
eab40e42fe76472d761e1f68a27ea51c93f55d86
[ "BSD-3-Clause" ]
permissive
VisionAerie/vision
150e5bfa7eb16116b1e5b4bdb1bb8cee888fbfe5
e40c39e3abc49b0e2c9623204c54b900c4333f29
refs/heads/master
2021-01-19T09:23:34.429209
2019-01-30T17:10:59
2019-01-30T17:10:59
82,104,368
2
1
BSD-3-Clause
2019-01-30T17:11:00
2017-02-15T20:41:27
C++
UTF-8
C++
false
false
9,729
cpp
/***** Vca::VcaOffer Implementation *****/ /************************ ************************ ***** Interfaces ***** ************************ ************************/ /******************** ***** System ***** ********************/ #include "Vk.h" /****************** ***** Self ***** ******************/ #include "Vca_VcaOffer.h" /************************ ***** Supporting ***** ************************/ #include "Vca_CompilerHappyPill.h" #include "Vca_VcaSite.h" /*************************** *************************** ***** ***** ***** Vca::VcaOffer ***** ***** ***** *************************** ***************************/ /************************** ************************** ***** Construction ***** ************************** **************************/ Vca::VcaOffer::VcaOffer ( VcaSite *pSiteObject, Offering const &rOffering ) : m_pIPeer (this), m_pSiteObject (pSiteObject), m_iOffering (rOffering) { aggregate (pSiteObject); // ... provides access to INeedYou and other peer specific interfaces // 'm_pSiteInterface' is 'const' because it is a structural property of this // object; however, initializing it requires that we temporarily the 'const'. traceInfo ("Creating VcaOffer"); pSiteObject->getRole (*const_cast<IPeer2::Reference*>(&m_pSiteInterface)); incrementOfferCount (); } /************************* ************************* ***** Destruction ***** ************************* *************************/ Vca::VcaOffer::~VcaOffer () { traceInfo ("Destroying VcaOffer"); #ifdef TracingVcaMemoryLeaks log("PoolMemoryLeak ~VcaOffer site info:: referenceCount: %u exportCount: %u exportedInterfaceCount: %u instantiatedInterfaceCount: %u referencedInterfaceCount: %u", m_pSiteObject->referenceCount(), m_pSiteObject->exportCount(), m_pSiteObject->exportedInterfaceCount(), m_pSiteObject->instantiatedInterfaceCount(), m_pSiteObject->referencedInterfaceCount() ); #endif } /****************************** ****************************** ***** Offer Management ***** ****************************** ******************************/ void Vca::VcaOffer::incrementOfferCount () { if (m_bOffered.setIfClear ()) m_iOffering.incrementOfferCount (this); } void Vca::VcaOffer::decrementOfferCount () { if (m_bOffered.clearIfSet ()) m_iOffering.decrementOfferCount (this); #ifdef TracingVcaMemoryLeaks log("PoolMemoryLeak VcaOffer::decrementOfferCount referenceCount: %u exportCount: %u exportedInterfaceCount: %u instantiatedInterfaceCount: %u referencedInterfaceCount: %u", referenceCount(), exportCount(), exportedInterfaceCount(), instantiatedInterfaceCount(), referencedInterfaceCount()); #endif } /**************************** **************************** ***** IPeer2 Methods ***** **************************** ****************************/ void Vca::VcaOffer::ReleaseExportEx ( VMessageHolder<IPeer_Ex2> const& rMessage, uuid_t const &rObjectSite, VcaSSID const &rObjectSSID, U32 cExports, U32 cWeakExports, U32 cMessages ) { m_pSiteObject->ReleaseExportEx (rMessage, rObjectSite, rObjectSSID, cExports, cWeakExports, cMessages); } /**************************** **************************** ***** IPeer1 Methods ***** **************************** ****************************/ void Vca::VcaOffer::WeakenExport (IPeer1* pRole, uuid_t const& rPeerUUID, VcaSSID const& rObjectSSID) { m_pSiteInterface->WeakenExport (rPeerUUID, rObjectSSID); } void Vca::VcaOffer::WeakenImport (IPeer1* pRole, uuid_t const& rPeerUUID, VcaSSID const& rObjectSSID) { m_pSiteInterface->WeakenImport (rPeerUUID, rObjectSSID); } void Vca::VcaOffer::GetProcessInfo (IPeer1* pRole, uuid_t const& rPeerUUID, IProcessInfoSink* pInfoSink) { m_pSiteInterface->GetProcessInfo (rPeerUUID, pInfoSink); } /*************************** *************************** ***** IPeer Methods ***** *************************** ***************************/ void Vca::VcaOffer::getRole (IPeer1::Reference &rpRole) { IPeer2::Reference pRoleX; getRole (pRoleX); rpRole.setTo (pRoleX); } void Vca::VcaOffer::getRole (IPeer::Reference &rpRole) { IPeer2::Reference pRoleX; getRole (pRoleX); rpRole.setTo (pRoleX); } void Vca::VcaOffer::SinkInterface (IPeer *pRole, IVUnknown* pUnknown) { m_pSiteInterface->SinkInterface (pUnknown); } void Vca::VcaOffer::ReleaseExport ( VMessageHolder<IPeer_Ex2> const& rMessage, uuid_t const& rObjectSite, VcaSSID const& rObjectSSID, U32 cExports, U32 cMessages ) { m_pSiteObject->ReleaseExport (rMessage, rObjectSite, rObjectSSID, cExports, cMessages); } void Vca::VcaOffer::ReleaseImport ( IPeer *pRole, uuid_t const &rObjectSite, VcaSSID const &rObjectSSID ) { m_pSiteInterface->ReleaseImport (rObjectSite, rObjectSSID); } void Vca::VcaOffer::FakeExportTo ( IPeer* pRole, uuid_t const& rExportPeer, uuid_t const& rObjectSite, VcaSSID const& rObjectSSID ) { m_pSiteInterface->FakeExportTo (rExportPeer, rObjectSite, rObjectSSID); } void Vca::VcaOffer::FakeImportFrom ( IPeer* pRole, uuid_t const& rImportPeer, uuid_t const& rObjectSite, VcaSSID const& rObjectSSID ) { m_pSiteInterface->FakeImportFrom (rImportPeer, rObjectSite, rObjectSSID); } void Vca::VcaOffer::GatherConnectionData ( IPeer* pRole, IConnectionRequest* pRequest, VPeerDataArray const& rForwardData, VPeerDataArray const& rReverseData, uuid_t const& targetPeer, bool bForward ) { m_pSiteInterface->GatherConnectionData ( pRequest, rForwardData, rReverseData, targetPeer, bForward ); } void Vca::VcaOffer::CreateConnection ( IPeer *pRole, VPeerDataArray const &peerDataArray, uuid_t const &targetUUID, uuid_t const &finalUUID ) { m_pSiteInterface->CreateConnection (peerDataArray, targetUUID, finalUUID); } void Vca::VcaOffer::GetLocalInterfaceFor ( IPeer *pRole, VcaSite *pPeer, IVReceiver<IPeer*>* pReceiver ) { m_pSiteInterface->GetLocalInterfaceFor (pPeer, pReceiver); } void Vca::VcaOffer::OnDone (VMessageHolder<IPeer_Ex2> const& rMessage) { m_pSiteObject->OnDone (rMessage); #ifdef TracingVcaMemoryLeaks log("PoolMemoryLeak VcaOffer::OnDone sequence number: %u referenceCount: %u exportCount: %u exportedInterfaceCount: %u instantiatedInterfaceCount: %u referencedInterfaceCount: %u", rMessage.message()->sequenceNumber(), referenceCount(), exportCount(), exportedInterfaceCount(), instantiatedInterfaceCount(), referencedInterfaceCount()); #endif } void Vca::VcaOffer::MakeConnection ( IPeer *pRole, IVReceiver<IConnection*> *pClient, VString const &rDestination ) { m_pSiteInterface->MakeConnection (pClient, rDestination); } void Vca::VcaOffer::GetRootInterface ( IPeer *pRole, VTypeInfo *pInterfaceType, IVReceiver<IVUnknown*>* pInterfaceReceiver ) { m_iOffering.supplyInterface (pInterfaceReceiver, pInterfaceType); } void Vca::VcaOffer::SetRemoteReflectionFor ( IPeer *pRole, uuid_t const &rSiteUUID, IPeer *pReflection ) { m_pSiteInterface->SetRemoteReflectionFor (rSiteUUID, pReflection); } /************************************* ************************************* ***** ***** ***** Vca::VcaOffer::Offering ***** ***** ***** ************************************* *************************************/ /************************** ************************** ***** Construction ***** ************************** **************************/ Vca::VcaOffer::Offering::Offering (VRolePlayer *pObject, Tracker *pTracker) : m_pObject (pObject), m_pTracker (pTracker) { } Vca::VcaOffer::Offering::Offering (VRolePlayer *pObject) : m_pObject (pObject), m_pTracker (new Tracker ()) { } Vca::VcaOffer::Offering::Offering (Tracker *pTracker) : m_pTracker (pTracker) { } Vca::VcaOffer::Offering::Offering (ThisClass const &rOther) : m_pObject (rOther.m_pObject), m_pTracker (rOther.m_pTracker) { } /******************** ******************** ***** Access ***** ******************** ********************/ void Vca::VcaOffer::Offering::supplyInterface (IVReceiver<IVUnknown*>* pInterfaceReceiver, VTypeInfo *pInterfaceType) const { if (m_pObject) m_pObject->supplyInterface (pInterfaceReceiver, pInterfaceType); else if (pInterfaceReceiver) { pInterfaceReceiver->OnError (0, "No Object"); } } /********************************************** ********************************************** ***** ***** ***** Vca::VcaOffer::Offering::Tracker ***** ***** ***** ********************************************** **********************************************/ /************************** ************************** ***** Construction ***** ************************** **************************/ Vca::VcaOffer::Offering::Tracker::Tracker () : m_cOffers (0) { } /************************* ************************* ***** Destruction ***** ************************* *************************/ Vca::VcaOffer::Offering::Tracker::~Tracker () { } /******************** ******************** ***** Update ***** ******************** ********************/ void Vca::VcaOffer::Offering::Tracker::onIncrement (VcaOffer* pOffer) { } void Vca::VcaOffer::Offering::Tracker::onDecrement (VcaOffer* pOffer) { } void Vca::VcaOffer::Offering::Tracker::incrementOfferCount (VcaOffer* pOffer) { m_cOffers++; onIncrement (pOffer); } void Vca::VcaOffer::Offering::Tracker::decrementOfferCount (VcaOffer* pOffer) { m_cOffers--; onDecrement (pOffer); }
[ "tkowalczyk@factset.com" ]
tkowalczyk@factset.com
f37a9eff1249b7cc7d858a08d7de406670e8a466
4c86527bcc10279ed1745a753072b4decf9a5216
/Source/GUAO22/Public/GAObject08.h
97a72a3ab6032da328659d685e4e7cb7d3c82462
[]
no_license
FashGek/GUAO22
b4a901aec23fefe6d817d7583364c07f2233bdb1
1dab7e2175817c38c28d12b61400a78604c294b4
refs/heads/master
2022-02-13T07:19:36.988491
2019-08-18T07:08:37
2019-08-18T07:08:37
null
0
0
null
null
null
null
UTF-8
C++
false
false
461
h
// Fill out your copyright notice in the Description page of Project Settings. #pragma once #include "CoreMinimal.h" #include "UObject/NoExportTypes.h" #include "GAObject08.generated.h" /** * */ UCLASS() class GUAO22_API UGAObject08 : public UObject { GENERATED_BODY() public: UFUNCTION() void OnRep_TestFloatValue() {} UPROPERTY(BlueprintReadOnly, EditAnywhere, ReplicatedUsing = OnRep_TestFloatValue, Category = "Test") float TestFloatValue; };
[ "714896324@qq.com" ]
714896324@qq.com
7b1055dd6e8ac1709fc5a89ab86799d66d7d3865
2d930aadf19b2ad6ea49725099d2f37475cd57f8
/src/policy/fees.h
684e78a44297b327b5b3cc190a2c8fd8a3e0b60a
[ "MIT" ]
permissive
stratton-oakcoin/oakcoin
ea83774c9f6ea64adb8832770e6219ffb31edef6
fe53193a50bd3674211448f1dcc39c6f9f042bb2
refs/heads/master
2021-01-20T13:22:05.877005
2017-05-07T10:09:57
2017-05-07T10:09:57
90,477,972
1
2
null
2017-05-07T10:09:57
2017-05-06T16:58:05
C++
UTF-8
C++
false
false
7,071
h
// Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2016 The Oakcoin Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #ifndef BITCOIN_POLICYESTIMATOR_H #define BITCOIN_POLICYESTIMATOR_H #include "amount.h" #include "uint256.h" #include "random.h" #include "sync.h" #include <map> #include <string> #include <vector> class CAutoFile; class CFeeRate; class CTxMemPoolEntry; class CTxMemPool; class TxConfirmStats; /** \class CBlockPolicyEstimator * The BlockPolicyEstimator is used for estimating the feerate needed * for a transaction to be included in a block within a certain number of * blocks. * * At a high level the algorithm works by grouping transactions into buckets * based on having similar feerates and then tracking how long it * takes transactions in the various buckets to be mined. It operates under * the assumption that in general transactions of higher feerate will be * included in blocks before transactions of lower feerate. So for * example if you wanted to know what feerate you should put on a transaction to * be included in a block within the next 5 blocks, you would start by looking * at the bucket with the highest feerate transactions and verifying that a * sufficiently high percentage of them were confirmed within 5 blocks and * then you would look at the next highest feerate bucket, and so on, stopping at * the last bucket to pass the test. The average feerate of transactions in this * bucket will give you an indication of the lowest feerate you can put on a * transaction and still have a sufficiently high chance of being confirmed * within your desired 5 blocks. * * Here is a brief description of the implementation: * When a transaction enters the mempool, we * track the height of the block chain at entry. Whenever a block comes in, * we count the number of transactions in each bucket and the total amount of feerate * paid in each bucket. Then we calculate how many blocks Y it took each * transaction to be mined and we track an array of counters in each bucket * for how long it to took transactions to get confirmed from 1 to a max of 25 * and we increment all the counters from Y up to 25. This is because for any * number Z>=Y the transaction was successfully mined within Z blocks. We * want to save a history of this information, so at any time we have a * counter of the total number of transactions that happened in a given feerate * bucket and the total number that were confirmed in each number 1-25 blocks * or less for any bucket. We save this history by keeping an exponentially * decaying moving average of each one of these stats. Furthermore we also * keep track of the number unmined (in mempool) transactions in each bucket * and for how many blocks they have been outstanding and use that to increase * the number of transactions we've seen in that feerate bucket when calculating * an estimate for any number of confirmations below the number of blocks * they've been outstanding. */ /** Track confirm delays up to 25 blocks, can't estimate beyond that */ static const unsigned int MAX_BLOCK_CONFIRMS = 25; /** Decay of .998 is a half-life of 346 blocks or about 2.4 days */ static const double DEFAULT_DECAY = .998; /** Require greater than 95% of X feerate transactions to be confirmed within Y blocks for X to be big enough */ static const double MIN_SUCCESS_PCT = .95; /** Require an avg of 1 tx in the combined feerate bucket per block to have stat significance */ static const double SUFFICIENT_FEETXS = 1; // Minimum and Maximum values for tracking feerates // The MIN_BUCKET_FEERATE should just be set to the lowest reasonable feerate we // might ever want to track. Historically this has been 1000 since it was // inheriting DEFAULT_MIN_RELAY_TX_FEE and changing it is disruptive as it // invalidates old estimates files. So leave it at 1000 unless it becomes // necessary to lower it, and then lower it substantially. static constexpr double MIN_BUCKET_FEERATE = 1000; static const double MAX_BUCKET_FEERATE = 1e7; static const double INF_FEERATE = MAX_MONEY; // We have to lump transactions into buckets based on feerate, but we want to be able // to give accurate estimates over a large range of potential feerates // Therefore it makes sense to exponentially space the buckets /** Spacing of FeeRate buckets */ static const double FEE_SPACING = 1.1; /** * We want to be able to estimate feerates that are needed on tx's to be included in * a certain number of blocks. Every time a block is added to the best chain, this class records * stats on the transactions included in that block */ class CBlockPolicyEstimator { public: /** Create new BlockPolicyEstimator and initialize stats tracking classes with default values */ CBlockPolicyEstimator(); ~CBlockPolicyEstimator(); /** Process all the transactions that have been included in a block */ void processBlock(unsigned int nBlockHeight, std::vector<const CTxMemPoolEntry*>& entries); /** Process a transaction accepted to the mempool*/ void processTransaction(const CTxMemPoolEntry& entry, bool validFeeEstimate); /** Remove a transaction from the mempool tracking stats*/ bool removeTx(uint256 hash); /** Return a feerate estimate */ CFeeRate estimateFee(int confTarget) const; /** Estimate feerate needed to get be included in a block within * confTarget blocks. If no answer can be given at confTarget, return an * estimate at the lowest target where one can be given. */ CFeeRate estimateSmartFee(int confTarget, int *answerFoundAtTarget, const CTxMemPool& pool) const; /** Write estimation data to a file */ bool Write(CAutoFile& fileout) const; /** Read estimation data from a file */ bool Read(CAutoFile& filein); private: CFeeRate minTrackedFee; //!< Passed to constructor to avoid dependency on main unsigned int nBestSeenHeight; struct TxStatsInfo { unsigned int blockHeight; unsigned int bucketIndex; TxStatsInfo() : blockHeight(0), bucketIndex(0) {} }; // map of txids to information about that transaction std::map<uint256, TxStatsInfo> mapMemPoolTxs; /** Classes to track historical data on transaction confirmations */ TxConfirmStats* feeStats; unsigned int trackedTxs; unsigned int untrackedTxs; mutable CCriticalSection cs_feeEstimator; /** Process a transaction confirmed in a block*/ bool processBlockTx(unsigned int nBlockHeight, const CTxMemPoolEntry* entry); }; class FeeFilterRounder { public: /** Create new FeeFilterRounder */ FeeFilterRounder(const CFeeRate& minIncrementalFee); /** Quantize a minimum fee for privacy purpose before broadcast **/ CAmount round(CAmount currentMinFee); private: std::set<double> feeset; FastRandomContext insecure_rand; }; #endif /*BITCOIN_POLICYESTIMATOR_H */
[ "s.matthew.english@gmail.com" ]
s.matthew.english@gmail.com
a5fe9d6c70666fa48453d260f766e64a567f434c
aa8bc6f9479d6d02eaa8c432a06bfdc80e21f53e
/RemoteSAMD21G18A_1/setTimeDate.ino
89f58b1e0271c4dcabc43dd4f17aa7b612826845
[]
no_license
XBeeModule/XBee
a2e515106169aea33c311dd564704ceefa1dbcbe
7290ce21d55884dfa365e4787c7cdfbbc8c095f6
refs/heads/master
2020-05-21T15:01:18.010658
2018-05-30T12:56:36
2018-05-30T12:56:42
60,069,011
0
0
null
null
null
null
WINDOWS-1251
C++
false
false
15,586
ino
void drawUpButton(int x, int y) { myGLCD.setColor(64, 64, 128); myGLCD.fillRoundRect(x, y, x+32, y+25); myGLCD.setColor(255, 255, 255); myGLCD.drawRoundRect(x, y, x+32, y+25); myGLCD.setColor(128, 128, 255); for (int i=0; i<15; i++) myGLCD.drawLine(x+6+(i/1.5), y+20-i, x+27-(i/1.5), y+20-i); } void drawDownButton(int x, int y) { myGLCD.setColor(64, 64, 128); myGLCD.fillRoundRect(x, y, x+32, y+25); myGLCD.setColor(255, 255, 255); myGLCD.drawRoundRect(x, y, x+32, y+25); myGLCD.setColor(128, 128, 255); for (int i=0; i<15; i++) myGLCD.drawLine(x+6+(i/1.5), y+5+i, x+27-(i/1.5), y+5+i); } void showDOW(byte dow) { char* str[] = {"MON","TUE","WED","THU","FRI","SAT","SUN"}; myGLCD.setColor(128, 128, 255); myGLCD.setBackColor(0, 0, 0); myGLCD.print(str[dow-1], 16, 167); } int bin_to_bcd(int temp)//decimal to BCD { int a,b,c; a=temp; b=0; if(a>=10) { while(a>=10) { a=a-10; b=b+16; c=a+b; temp=c; } } return temp; } byte validateDate(byte d, byte m, word y) { byte mArr[12] = {31,0,31,30,31,30,31,31,30,31,30,31}; byte od; if (m==2) { if ((y % 4)==0) { if (d==30) od=1; else if (d==0) od=29; else od=d; } else { if (d==29) od=1; else if (d==0) od=28; else od=d; } } else { if (d==0) od=mArr[m-1]; else if (d==(mArr[m-1]+1)) od=1; else od=d; } return od; } byte validateDateForMonth(byte d, byte m, word y) { byte mArr[12] = {31,0,31,30,31,30,31,31,30,31,30,31}; byte od; boolean dc=false; if (m==2) { if ((y % 4)==0) { if (d>29) { d=29; dc=true; } } else { if (d>28) { d=28; dc=true; } } } else { if (d>mArr[m-1]) { d=mArr[m-1]; dc=true; } } if (dc) { if (d<10) { myGLCD.printNumI(0, 82, 140); myGLCD.printNumI(d, 98, 140); } else { myGLCD.printNumI(d, 82, 140); } } return d; } void setClock() { int t_temp_sec, t_temp_min, t_temp_hour, t_temp_dow, t_temp_date, t_temp_mon, t_temp_year; int x, y; int res = 0; boolean ct=false; boolean cd=false; waitForTouchRelease(); myGLCD.clrScr(); myGLCD.setFont(BigFont); myGLCD.setColor(64, 64, 128); myGLCD.fillRoundRect(121, 200, 234, 239); myGLCD.setColor(255, 255, 255); myGLCD.drawRoundRect(121, 200, 234, 239); myGLCD.setBackColor(64, 64, 128); myGLCD.print("Save", 140, 212); myGLCD.setBackColor(0, 0, 0); // Draw Cancel button myGLCD.setColor(64, 64, 128); myGLCD.fillRoundRect(5, 200, 118, 239); myGLCD.setColor(255, 255, 255); myGLCD.drawRoundRect(5, 200, 118, 239); myGLCD.setBackColor(64, 64, 128); myGLCD.print("Cancel", 15, 212); myGLCD.setBackColor(0, 0, 0); // Draw frames myGLCD.setColor(0, 0, 255); myGLCD.drawRoundRect(0, 0, 239, 96); myGLCD.drawRoundRect(0, 100, 239, 196); myGLCD.print("Time:", 5, 40); myGLCD.print(":", 114, 40); myGLCD.print(":", 162, 40); myGLCD.print("Date:", 5, 140); myGLCD.print(".", 114, 140); myGLCD.print(".", 159, 140); // Draw Buttons drawUpButton(82, 10); drawUpButton(130, 10); drawUpButton(178, 10); drawDownButton(82, 61); drawDownButton(130, 61); drawDownButton(178, 61); drawUpButton(82, 110); drawUpButton(130, 110); drawUpButton(184, 110); drawDownButton(82, 161); drawDownButton(130, 161); drawDownButton(184, 161); // Print current time and date myGLCD.setColor(255, 255, 255); //clock_read(); t_temp_date=day; t_temp_mon=month; t_temp_year=year; t_temp_dow=dow; t_temp_hour=hour; t_temp_min=minute; t_temp_sec=second; if (t_temp_date==0) { t_temp_date=1; t_temp_mon=1; t_temp_year=2016; t_temp_dow=5; t_temp_hour=0; t_temp_min=0; t_temp_sec=0; ct=true; cd=true; } if (t_temp_hour<10) { myGLCD.printNumI(0, 82, 40); myGLCD.printNumI(t_temp_hour, 98, 40); } else { myGLCD.printNumI(t_temp_hour, 82, 40); } if (t_temp_min<10) { myGLCD.printNumI(0, 130, 40); myGLCD.printNumI(t_temp_min, 146, 40); } else { myGLCD.printNumI(t_temp_min, 130, 40); } if (t_temp_sec<10) { myGLCD.printNumI(0, 178, 40); myGLCD.printNumI(t_temp_sec, 194, 40); } else { myGLCD.printNumI(t_temp_sec, 178, 40); } if (t_temp_date<10) { myGLCD.printNumI(0, 82, 140); myGLCD.printNumI(t_temp_date, 98, 140); } else { myGLCD.printNumI(t_temp_date, 82, 140); } if (t_temp_mon<10) { myGLCD.printNumI(0, 130, 140); myGLCD.printNumI(t_temp_mon, 146, 140); } else { myGLCD.printNumI(t_temp_mon, 130, 140); } myGLCD.printNumI(t_temp_year, 168, 140); // showDOW(t_temp_dow); while (res==0) { if (myTouch.dataAvailable()) { myTouch.read(); x=myTouch.getX(); y=myTouch.getY(); if ((y>=20) && (y<=45)) // Buttons: Time UP { if ((x>=82+x_delta+6) && (x<=114+x_delta+6)) { buttonWait(82, 10); t_temp_hour+=1; if (t_temp_hour==24) t_temp_hour=0; if (t_temp_hour<10) { myGLCD.printNumI(0, 82, 40); myGLCD.printNumI(t_temp_hour, 98, 40); } else { myGLCD.printNumI(t_temp_hour, 82, 40); } if (ct==false) { ct=true; myGLCD.setColor(64, 64, 128); myGLCD.setFont(SmallFont); myGLCD.print("Changed!", 5, 10); myGLCD.setColor(255, 255, 255); myGLCD.setFont(BigFont); } } else if ((x>=130+x_delta+3) && (x<=162+x_delta+3)) { buttonWait(130, 10); t_temp_min+=1; if (t_temp_min==60) t_temp_min=0; if (t_temp_min<10) { myGLCD.printNumI(0, 130, 40); myGLCD.printNumI(t_temp_min, 146, 40); } else { myGLCD.printNumI(t_temp_min, 130, 40); } if (ct==false) { ct=true; myGLCD.setColor(64, 64, 128); myGLCD.setFont(SmallFont); myGLCD.print("Changed!", 5, 10); myGLCD.setColor(255, 255, 255); myGLCD.setFont(BigFont); } } else if ((x>=178+x_delta) && (x<=210+x_delta)) { buttonWait(178, 10); t_temp_sec+=1; if (t_temp_sec==60) t_temp_sec=0; if (t_temp_sec<10) { myGLCD.printNumI(0, 178, 40); myGLCD.printNumI(t_temp_sec, 194, 40); } else { myGLCD.printNumI(t_temp_sec, 178, 40); } if (ct==false) { ct=true; myGLCD.setColor(64, 64, 128); myGLCD.setFont(SmallFont); myGLCD.print("Changed!", 5, 10); myGLCD.setColor(255, 255, 255); myGLCD.setFont(BigFont); } } } else if ((y>=61+10) && (y<=86+10)) // Buttons: Time DOWN { if ((x>=82+x_delta+6) && (x<=114+x_delta+6)) { buttonWait(82, 61); t_temp_hour-=1; if (t_temp_hour==-1) t_temp_hour=23; if (t_temp_hour<10) { myGLCD.printNumI(0, 82, 40); myGLCD.printNumI(t_temp_hour, 98, 40); } else { myGLCD.printNumI(t_temp_hour, 82, 40); } if (ct==false) { ct=true; myGLCD.setColor(64, 64, 128); myGLCD.setFont(SmallFont); myGLCD.print("Changed!", 5, 10); myGLCD.setColor(255, 255, 255); myGLCD.setFont(BigFont); } } else if ((x>=130+x_delta+3) && (x<=162+x_delta+3)) { buttonWait(130, 61); t_temp_min-=1; if (t_temp_min==-1) t_temp_min=59; if (t_temp_min<10) { myGLCD.printNumI(0, 130, 40); myGLCD.printNumI(t_temp_min, 146, 40); } else { myGLCD.printNumI(t_temp_min, 130, 40); } if (ct==false) { ct=true; myGLCD.setColor(64, 64, 128); myGLCD.setFont(SmallFont); myGLCD.print("Changed!", 5, 10); myGLCD.setColor(255, 255, 255); myGLCD.setFont(BigFont); } } else if ((x>=178+x_delta) && (x<=210+x_delta)) { buttonWait(178, 61); t_temp_sec-=1; if (t_temp_sec==-1) t_temp_sec=59; if (t_temp_sec<10) { myGLCD.printNumI(0, 178, 40); myGLCD.printNumI(t_temp_sec, 194, 40); } else { myGLCD.printNumI(t_temp_sec, 178, 40); } if (ct==false) { ct=true; myGLCD.setColor(64, 64, 128); myGLCD.setFont(SmallFont); myGLCD.print("Changed!", 5, 10); myGLCD.setColor(255, 255, 255); myGLCD.setFont(BigFont); } } } if ((y>=120) && (y<=145)) // Buttons: Date UP { if ((x>=82+x_delta+6) && (x<=114+x_delta+6)) { buttonWait(82, 110); t_temp_date+=1; t_temp_date=validateDate(t_temp_date, t_temp_mon, t_temp_year); if (t_temp_date<10) { myGLCD.printNumI(0, 82, 140); myGLCD.printNumI(t_temp_date, 98, 140); } else { myGLCD.printNumI(t_temp_date, 82, 140); } if (cd==false) { cd=true; myGLCD.setColor(64, 64, 128); myGLCD.setFont(SmallFont); myGLCD.print("Changed!", 5, 110); myGLCD.setColor(255, 255, 255); myGLCD.setFont(BigFont); } } else if ((x>=130+x_delta+3) && (x<=162+x_delta+3)) { buttonWait(130, 110); t_temp_mon+=1; if (t_temp_mon==13) { t_temp_mon=1; } if (t_temp_mon<10) { myGLCD.printNumI(0, 130, 140); myGLCD.printNumI(t_temp_mon, 146, 140); } else { myGLCD.printNumI(t_temp_mon, 130, 140); } t_temp_date=validateDateForMonth(t_temp_date, t_temp_mon, t_temp_year); if (cd==false) { cd=true; myGLCD.setColor(64, 64, 128); myGLCD.setFont(SmallFont); myGLCD.print("Changed!", 5, 110); myGLCD.setColor(255, 255, 255); myGLCD.setFont(BigFont); } } else if ((x>=184+x_delta) && (x<=220+x_delta))// исправить { buttonWait(184, 110); t_temp_year+=1; if (t_temp_year==2100) t_temp_year=2000; myGLCD.printNumI(t_temp_year, 168, 140); t_temp_date=validateDateForMonth(t_temp_date, t_temp_mon, t_temp_year); if (cd==false) { cd=true; myGLCD.setColor(64, 64, 128); myGLCD.setFont(SmallFont); myGLCD.print("Changed!", 5, 110); myGLCD.setColor(255, 255, 255); myGLCD.setFont(BigFont); } } t_temp_dow=calcDOW(t_temp_date, t_temp_mon, t_temp_year); showDOW(t_temp_dow); } else if ((y>=171) && (y<=196)) // Buttons: Date DOWN { if ((x>=82+x_delta+6) && (x<=114+x_delta+6)) { buttonWait(82, 161); t_temp_date-=1; t_temp_date=validateDate(t_temp_date, t_temp_mon, t_temp_year); if (t_temp_date<10) { myGLCD.printNumI(0, 82, 140); myGLCD.printNumI(t_temp_date, 98, 140); } else { myGLCD.printNumI(t_temp_date, 82, 140); } if (cd==false) { cd=true; myGLCD.setColor(64, 64, 128); myGLCD.setFont(SmallFont); myGLCD.print("Changed!", 5, 110); myGLCD.setColor(255, 255, 255); myGLCD.setFont(BigFont); } } else if ((x>=130+x_delta+3) && (x<=162+x_delta+3)) { buttonWait(130, 161); t_temp_mon-=1; if (t_temp_mon==0) t_temp_mon=12; if (t_temp_mon<10) { myGLCD.printNumI(0, 130, 140); myGLCD.printNumI(t_temp_mon, 146, 140); } else { myGLCD.printNumI(t_temp_mon, 130, 140); } t_temp_date=validateDateForMonth(t_temp_date, t_temp_mon, t_temp_year); if (cd==false) { cd=true; myGLCD.setColor(64, 64, 128); myGLCD.setFont(SmallFont); myGLCD.print("Changed!", 5, 110); myGLCD.setColor(255, 255, 255); myGLCD.setFont(BigFont); } } else if ((x>=184+x_delta) && (x<=216+x_delta))// исправить { buttonWait(184, 161); t_temp_year-=1; if (t_temp_year==1999) t_temp_year=2099; myGLCD.printNumI(t_temp_year, 168, 140); t_temp_date=validateDateForMonth(t_temp_date, t_temp_mon, t_temp_year); if (cd==false) { cd=true; myGLCD.setColor(64, 64, 128); myGLCD.setFont(SmallFont); myGLCD.print("Changed!", 5, 110); myGLCD.setColor(255, 255, 255); myGLCD.setFont(BigFont); } } t_temp_dow=calcDOW(t_temp_date, t_temp_mon, t_temp_year); showDOW(t_temp_dow); } else if ((y>=200) && (y<=239)) // Buttons: CANCEL / SAVE { if ((x>=121) && (x<=234)) { res=1; myGLCD.setColor (255, 0, 0); myGLCD.drawRoundRect(121, 200, 234, 239); } else if ((x>=5) && (x<=118)) { res=2; myGLCD.setColor (255, 0, 0); myGLCD.drawRoundRect(5, 200, 118, 239); } } } } waitForTouchRelease(); if (res==1) { if (ct|cd) { t_temp_year = t_temp_year-2000; Wire.beginTransmission(0x68);//DS1307 write the initial time Wire.write(0); Wire.requestFrom(0x68, 7); Wire.write(bin_to_bcd(t_temp_sec)); Wire.write(bin_to_bcd(t_temp_min)); Wire.write(bin_to_bcd(t_temp_hour)); Wire.write(bin_to_bcd(t_temp_dow)); Wire.write(bin_to_bcd(t_temp_date)); Wire.write(bin_to_bcd(t_temp_mon)); Wire.write(bin_to_bcd(t_temp_year)); Wire.endTransmission(); } } }
[ "promavto@ntmp.ru" ]
promavto@ntmp.ru
ebf5d26d7e90fffd49bb2487396f3a155838a4aa
eebe2735ba7f170a0e8a1d617fb338bb495ad443
/example/concept_example.cpp
92a1a2a18794497d45f0af139b63d513ca38c5c0
[]
no_license
EricWF/entity
479b5364b234852565e7fd21e59d5f8cdfe41f92
158b67e4dbca4555b0b5bbe7cc60a99b38872d0c
refs/heads/master
2019-01-19T13:38:34.470490
2014-03-31T01:33:07
2014-03-31T01:33:07
18,272,457
1
0
null
null
null
null
UTF-8
C++
false
false
2,293
cpp
#include "entity.hpp" #include "sample.hpp" #include <algorithm> #include <iostream> #include <vector> using namespace chips; int main() { std::vector<entity> elist = { // 1 hero create_entity(entity_id::hero) // 5 monsters , create_entity(entity_id::monster) , create_entity(entity_id::monster) , create_entity(entity_id::monster) , create_entity(entity_id::monster) , create_entity(entity_id::monster) // 10 walls , create_entity(entity_id::wall) , create_entity(entity_id::wall) , create_entity(entity_id::wall) , create_entity(entity_id::wall) , create_entity(entity_id::wall) , create_entity(entity_id::wall) , create_entity(entity_id::wall) , create_entity(entity_id::wall) , create_entity(entity_id::wall) , create_entity(entity_id::wall) }; // shuffle the vector (so we don't know where everything is) std::random_shuffle(elist.begin(), elist.end()); // count each entity; int hero_count = 0; int monster_count = 0; int wall_count = 0; for (auto & h : IsHero().filter(elist)) { ((void)h); ++hero_count; } for (auto & m : IsMonster().filter(elist)) { ((void)m); ++monster_count; } for (auto & w : IsWall().filter(elist)) { ((void)w); ++wall_count; } std::cout << "There are " << hero_count << " Heros, " << monster_count << " Monsters, and " << wall_count << " walls.\n\n"; // Use a concept to find out hero entity & hero = IsHero().get(elist); // give a one-hit weapon hero << weapon("Doomhammer", 1000); // print the state std::cout << "Found our Hero. This is the hero's state\n"; hero(print_); std::cout << std::endl; std::cout << "Our hero now attacks all the monsters\n"; int mon_count = 0; for (auto & monster : Attackable().filter(elist)) { ++mon_count; hero(attack_, monster); } std::cout << "\n"; std::cout << "Our hero killed " << mon_count << " Monsters!\n"; if (not Attackable().contains(elist)) { std::cout << "There are no more monsters left." << std::endl; } }
[ "eric@efcs.ca" ]
eric@efcs.ca
9f6d2b4a338ff566eb2505cc9e56e21cd35f9e9f
7dd824a1d9224903b685c6768102fbca1d907316
/annual/CJ141A/C-test-gen.cpp
7a99c302db7b274830a3ac8598e83f018510665b
[]
no_license
1ridescent/ACM
c2a50f3619f9480e2bf4a7f690a12eb1574eb6b0
41f7b63655edd257eeab223bbaaf78d50960e789
refs/heads/master
2020-12-24T17:26:32.650345
2015-12-02T01:03:51
2015-12-02T01:03:51
20,510,103
0
0
null
null
null
null
UTF-8
C++
false
false
398
cpp
#include <iostream> #include <algorithm> #include <cstdlib> #include <ctime> #include <vector> #include <map> using namespace std; int main() { srand(time(0)); int N = 1000; vector<int> P(N); for(int k = 0; k < N; k++) P[k] = k; for(int k = 0; k < N; k++) { int p = rand() % N; swap(P[k], P[p]); } cout << N << endl; for(int i = 0; i < N; i++) cout << P[i] << ' '; cout << endl; }
[ "jasonmli02@gmail.com" ]
jasonmli02@gmail.com
cd267956777b969db01a0d62f9474baf074ad8b1
2e5ee79f6a204d9452b9c9d5c1c3577ba15be0e7
/gl_testbench/DDSTextureLoaderLuna.h
6c71f10bfd5301ec578af422eef3ded2ee89c8dc
[]
no_license
Gamewolf3000/3D3-Ass1
38320170069b2e5a41ac108556f4bbd52ec505b5
0e3da0b802b1ba634f96d9def8d6d1dd8cd2ca66
refs/heads/master
2021-01-20T08:16:16.220487
2017-05-03T08:35:29
2017-05-03T08:35:29
90,125,022
0
0
null
null
null
null
UTF-8
C++
false
false
9,145
h
//-------------------------------------------------------------------------------------- // File: DDSTextureLoader.h // // Functions for loading a DDS texture and creating a Direct3D 11 runtime resource for it // // Note these functions are useful as a light-weight runtime loader for DDS files. For // a full-featured DDS file reader, writer, and texture processing pipeline see // the 'Texconv' sample and the 'DirectXTex' library. // // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A // PARTICULAR PURPOSE. // // Copyright (c) Microsoft Corporation. All rights reserved. // // http://go.microsoft.com/fwlink/?LinkId=248926 // http://go.microsoft.com/fwlink/?LinkId=248929 //-------------------------------------------------------------------------------------- #ifdef _MSC_VER #pragma once #endif #include <wrl.h> #include <d3d11_1.h> #include "CD3DX12Helper.h" #pragma warning(push) #pragma warning(disable : 4005) #include <stdint.h> #pragma warning(pop) #if defined(_MSC_VER) && (_MSC_VER<1610) && !defined(_In_reads_) #define _In_reads_(exp) #define _Out_writes_(exp) #define _In_reads_bytes_(exp) #define _In_reads_opt_(exp) #define _Outptr_opt_ #endif #ifndef _Use_decl_annotations_ #define _Use_decl_annotations_ #endif namespace DirectX { enum DDS_ALPHA_MODE { DDS_ALPHA_MODE_UNKNOWN = 0, DDS_ALPHA_MODE_STRAIGHT = 1, DDS_ALPHA_MODE_PREMULTIPLIED = 2, DDS_ALPHA_MODE_OPAQUE = 3, DDS_ALPHA_MODE_CUSTOM = 4, }; // Standard version HRESULT CreateDDSTextureFromMemory( _In_ ID3D11Device* d3dDevice, _In_reads_bytes_(ddsDataSize) const uint8_t* ddsData, _In_ size_t ddsDataSize, _Outptr_opt_ ID3D11Resource** texture, _Outptr_opt_ ID3D11ShaderResourceView** textureView, _In_ size_t maxsize = 0, _Out_opt_ DDS_ALPHA_MODE* alphaMode = nullptr ); HRESULT CreateDDSTextureFromMemory12(_In_ ID3D12Device* device, _In_ ID3D12GraphicsCommandList* cmdList, _In_reads_bytes_(ddsDataSize) const uint8_t* ddsData, _In_ size_t ddsDataSize, _Out_ Microsoft::WRL::ComPtr<ID3D12Resource>& texture, _Out_ Microsoft::WRL::ComPtr<ID3D12Resource>& textureUploadHeap, _In_ size_t maxsize = 0, _Out_opt_ DDS_ALPHA_MODE* alphaMode = nullptr ); HRESULT CreateDDSTextureFromFile( _In_ ID3D11Device* d3dDevice, _In_z_ const wchar_t* szFileName, _Outptr_opt_ ID3D11Resource** texture, _Outptr_opt_ ID3D11ShaderResourceView** textureView, _In_ size_t maxsize = 0, _Out_opt_ DDS_ALPHA_MODE* alphaMode = nullptr ); HRESULT CreateDDSTextureFromFile12(_In_ ID3D12Device* device, _In_ ID3D12GraphicsCommandList* cmdList, _In_z_ const wchar_t* szFileName, _Out_ Microsoft::WRL::ComPtr<ID3D12Resource>& texture, _Out_ Microsoft::WRL::ComPtr<ID3D12Resource>& textureUploadHeap, _In_ size_t maxsize = 0, _Out_opt_ DDS_ALPHA_MODE* alphaMode = nullptr ); // Standard version with optional auto-gen mipmap support HRESULT CreateDDSTextureFromMemory( _In_ ID3D11Device* d3dDevice, _In_opt_ ID3D11DeviceContext* d3dContext, _In_reads_bytes_(ddsDataSize) const uint8_t* ddsData, _In_ size_t ddsDataSize, _Outptr_opt_ ID3D11Resource** texture, _Outptr_opt_ ID3D11ShaderResourceView** textureView, _In_ size_t maxsize = 0, _Out_opt_ DDS_ALPHA_MODE* alphaMode = nullptr ); HRESULT CreateDDSTextureFromFile( _In_ ID3D11Device* d3dDevice, _In_opt_ ID3D11DeviceContext* d3dContext, _In_z_ const wchar_t* szFileName, _Outptr_opt_ ID3D11Resource** texture, _Outptr_opt_ ID3D11ShaderResourceView** textureView, _In_ size_t maxsize = 0, _Out_opt_ DDS_ALPHA_MODE* alphaMode = nullptr ); // Extended version HRESULT CreateDDSTextureFromMemoryEx( _In_ ID3D11Device* d3dDevice, _In_reads_bytes_(ddsDataSize) const uint8_t* ddsData, _In_ size_t ddsDataSize, _In_ size_t maxsize, _In_ D3D11_USAGE usage, _In_ unsigned int bindFlags, _In_ unsigned int cpuAccessFlags, _In_ unsigned int miscFlags, _In_ bool forceSRGB, _Outptr_opt_ ID3D11Resource** texture, _Outptr_opt_ ID3D11ShaderResourceView** textureView, _Out_opt_ DDS_ALPHA_MODE* alphaMode = nullptr ); HRESULT CreateDDSTextureFromFileEx( _In_ ID3D11Device* d3dDevice, _In_z_ const wchar_t* szFileName, _In_ size_t maxsize, _In_ D3D11_USAGE usage, _In_ unsigned int bindFlags, _In_ unsigned int cpuAccessFlags, _In_ unsigned int miscFlags, _In_ bool forceSRGB, _Outptr_opt_ ID3D11Resource** texture, _Outptr_opt_ ID3D11ShaderResourceView** textureView, _Out_opt_ DDS_ALPHA_MODE* alphaMode = nullptr ); // Extended version with optional auto-gen mipmap support HRESULT CreateDDSTextureFromMemoryEx( _In_ ID3D11Device* d3dDevice, _In_opt_ ID3D11DeviceContext* d3dContext, _In_reads_bytes_(ddsDataSize) const uint8_t* ddsData, _In_ size_t ddsDataSize, _In_ size_t maxsize, _In_ D3D11_USAGE usage, _In_ unsigned int bindFlags, _In_ unsigned int cpuAccessFlags, _In_ unsigned int miscFlags, _In_ bool forceSRGB, _Outptr_opt_ ID3D11Resource** texture, _Outptr_opt_ ID3D11ShaderResourceView** textureView, _Out_opt_ DDS_ALPHA_MODE* alphaMode = nullptr ); HRESULT CreateDDSTextureFromFileEx( _In_ ID3D11Device* d3dDevice, _In_opt_ ID3D11DeviceContext* d3dContext, _In_z_ const wchar_t* szFileName, _In_ size_t maxsize, _In_ D3D11_USAGE usage, _In_ unsigned int bindFlags, _In_ unsigned int cpuAccessFlags, _In_ unsigned int miscFlags, _In_ bool forceSRGB, _Outptr_opt_ ID3D11Resource** texture, _Outptr_opt_ ID3D11ShaderResourceView** textureView, _Out_opt_ DDS_ALPHA_MODE* alphaMode = nullptr ); }
[ "andreas.jonasson1993@gmail.com" ]
andreas.jonasson1993@gmail.com
26fd605277fc87044925fc8146d777bf97732b59
f6de0114d28cf8ec9adcc13a12d9eef4fe2cc230
/Diff/diff.cpp
26e35525e7ee1a662c10d44d42d507a71c774918
[]
no_license
ravikanthreddy89/Scratch
643de6e40bfed361c12a12dc80c8ae938e8c2ad5
19ea37e6891f4d1186b63196f45a7d70c287bf6e
refs/heads/master
2020-05-02T17:41:18.389525
2014-06-04T02:52:06
2014-06-04T02:52:06
null
0
0
null
null
null
null
UTF-8
C++
false
false
619
cpp
#include<iostream> #include<vector> using namespace std; int main(int argc, char *argv[]) { int order; cout<<"enter the order of the polynomial"<<endl; cin>>order; vector<int> coeffs; coeffs.resize(order); for (int i = order-1; i >=0; i--) { cout<<"enter the coefficient of "<<order<<"power of x"<<endl; cin>>coeffs[i]; } while(order>=1){ coeffs[order-1]=coeffs[order-1]*order; order=order-1; } cout<<"The derivative of above expression is :"<<endl; for (int i = coeffs.size()-1; i>=0; i--) { cout<<coeffs[i]<<" "; } cout<<endl; return 0; }
[ "ravikanthreddy89@gmail.com" ]
ravikanthreddy89@gmail.com
8a752c7a79413102eac3cbb4b96f771d6e23d6c2
08f4cb007e0fd84e2fa7113d2d3411713cfbc2cb
/src/netbase.h
e861cbe181d0a4d6b33798ae4d5cdc4d455564f4
[ "MIT" ]
permissive
robinadaptor/renish
d2ab48a63ec7efaf6ec92bba82431ab78050a222
7428946594ae8aa06d4bc03640e9b6022163a061
refs/heads/master
2020-07-13T02:27:58.596751
2019-12-17T00:38:16
2019-12-17T00:38:16
145,383,606
0
0
null
null
null
null
UTF-8
C++
false
false
8,132
h
// Copyright (c) 2009-2013 Bitcoin developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #ifndef BITCOIN_NETBASE_H #define BITCOIN_NETBASE_H #if defined(HAVE_CONFIG_H) #include "config/renish-config.h" #endif #include "compat.h" #include "serialize.h" #include <stdint.h> #include <string> #include <vector> extern int nConnectTimeout; extern bool fNameLookup; /** -timeout default */ static const int DEFAULT_CONNECT_TIMEOUT = 5000; //! -dns default static const int DEFAULT_NAME_LOOKUP = true; #ifdef WIN32 // In MSVC, this is defined as a macro, undefine it to prevent a compile and link error #undef SetPort #endif enum Network { NET_UNROUTABLE = 0, NET_IPV4, NET_IPV6, NET_TOR, NET_MAX, }; /** IP address (IPv6, or IPv4 using mapped IPv6 range (::FFFF:0:0/96)) */ class CNetAddr { protected: unsigned char ip[16]; // in network byte order public: CNetAddr(); CNetAddr(const struct in_addr& ipv4Addr); explicit CNetAddr(const char* pszIp, bool fAllowLookup = false); explicit CNetAddr(const std::string& strIp, bool fAllowLookup = false); void Init(); void SetIP(const CNetAddr& ip); /** * Set raw IPv4 or IPv6 address (in network byte order) * @note Only NET_IPV4 and NET_IPV6 are allowed for network. */ void SetRaw(Network network, const uint8_t* data); bool SetSpecial(const std::string& strName); // for Tor addresses bool IsIPv4() const; // IPv4 mapped address (::FFFF:0:0/96, 0.0.0.0/0) bool IsIPv6() const; // IPv6 address (not mapped IPv4, not Tor) bool IsRFC1918() const; // IPv4 private networks (10.0.0.0/8, 192.168.0.0/16, 172.16.0.0/12) bool IsRFC2544() const; // IPv4 inter-network communcations (192.18.0.0/15) bool IsRFC6598() const; // IPv4 ISP-level NAT (100.64.0.0/10) bool IsRFC5737() const; // IPv4 documentation addresses (192.0.2.0/24, 198.51.100.0/24, 203.0.113.0/24) bool IsRFC3849() const; // IPv6 documentation address (2001:0DB8::/32) bool IsRFC3927() const; // IPv4 autoconfig (169.254.0.0/16) bool IsRFC3964() const; // IPv6 6to4 tunnelling (2002::/16) bool IsRFC4193() const; // IPv6 unique local (FC00::/7) bool IsRFC4380() const; // IPv6 Teredo tunnelling (2001::/32) bool IsRFC4843() const; // IPv6 ORCHID (2001:10::/28) bool IsRFC4862() const; // IPv6 autoconfig (FE80::/64) bool IsRFC6052() const; // IPv6 well-known prefix (64:FF9B::/96) bool IsRFC6145() const; // IPv6 IPv4-translated address (::FFFF:0:0:0/96) bool IsTor() const; bool IsLocal() const; bool IsRoutable() const; bool IsValid() const; bool IsMulticast() const; enum Network GetNetwork() const; std::string ToString() const; std::string ToStringIP() const; unsigned int GetByte(int n) const; uint64_t GetHash() const; bool GetInAddr(struct in_addr* pipv4Addr) const; std::vector<unsigned char> GetGroup() const; int GetReachabilityFrom(const CNetAddr* paddrPartner = NULL) const; CNetAddr(const struct in6_addr& pipv6Addr); bool GetIn6Addr(struct in6_addr* pipv6Addr) const; friend bool operator==(const CNetAddr& a, const CNetAddr& b); friend bool operator!=(const CNetAddr& a, const CNetAddr& b); friend bool operator<(const CNetAddr& a, const CNetAddr& b); ADD_SERIALIZE_METHODS; template <typename Stream, typename Operation> inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) { READWRITE(FLATDATA(ip)); } friend class CSubNet; }; class CSubNet { protected: /// Network (base) address CNetAddr network; /// Netmask, in network byte order uint8_t netmask[16]; /// Is this value valid? (only used to signal parse errors) bool valid; public: CSubNet(); explicit CSubNet(const std::string& strSubnet, bool fAllowLookup = false); bool Match(const CNetAddr& addr) const; std::string ToString() const; bool IsValid() const; friend bool operator==(const CSubNet& a, const CSubNet& b); friend bool operator!=(const CSubNet& a, const CSubNet& b); }; /** A combination of a network address (CNetAddr) and a (TCP) port */ class CService : public CNetAddr { protected: unsigned short port; // host order public: CService(); CService(const CNetAddr& ip, unsigned short port); CService(const struct in_addr& ipv4Addr, unsigned short port); CService(const struct sockaddr_in& addr); explicit CService(const char* pszIpPort, int portDefault, bool fAllowLookup = false); explicit CService(const char* pszIpPort, bool fAllowLookup = false); explicit CService(const std::string& strIpPort, int portDefault, bool fAllowLookup = false); explicit CService(const std::string& strIpPort, bool fAllowLookup = false); void Init(); void SetPort(unsigned short portIn); unsigned short GetPort() const; bool GetSockAddr(struct sockaddr* paddr, socklen_t* addrlen) const; bool SetSockAddr(const struct sockaddr* paddr); friend bool operator==(const CService& a, const CService& b); friend bool operator!=(const CService& a, const CService& b); friend bool operator<(const CService& a, const CService& b); std::vector<unsigned char> GetKey() const; std::string ToString() const; std::string ToStringPort() const; std::string ToStringIPPort() const; CService(const struct in6_addr& ipv6Addr, unsigned short port); CService(const struct sockaddr_in6& addr); ADD_SERIALIZE_METHODS; template <typename Stream, typename Operation> inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) { READWRITE(FLATDATA(ip)); unsigned short portN = htons(port); READWRITE(portN); if (ser_action.ForRead()) port = ntohs(portN); } }; class proxyType { public: proxyType(): randomize_credentials(false) {} proxyType(const CService &proxy, bool randomize_credentials=false): proxy(proxy), randomize_credentials(randomize_credentials) {} bool IsValid() const { return proxy.IsValid(); } CService proxy; bool randomize_credentials; }; enum Network ParseNetwork(std::string net); std::string GetNetworkName(enum Network net); void SplitHostPort(std::string in, int& portOut, std::string& hostOut); bool SetProxy(enum Network net, const proxyType &addrProxy); bool GetProxy(enum Network net, proxyType& proxyInfoOut); bool IsProxy(const CNetAddr& addr); bool SetNameProxy(const proxyType &addrProxy); bool HaveNameProxy(); bool LookupHost(const char* pszName, std::vector<CNetAddr>& vIP, unsigned int nMaxSolutions = 0, bool fAllowLookup = true); bool Lookup(const char* pszName, CService& addr, int portDefault = 0, bool fAllowLookup = true); bool Lookup(const char* pszName, std::vector<CService>& vAddr, int portDefault = 0, bool fAllowLookup = true, unsigned int nMaxSolutions = 0); bool LookupNumeric(const char* pszName, CService& addr, int portDefault = 0); bool ConnectSocket(const CService& addr, SOCKET& hSocketRet, int nTimeout, bool* outProxyConnectionFailed = 0); bool ConnectSocketByName(CService& addr, SOCKET& hSocketRet, const char* pszDest, int portDefault, int nTimeout, bool* outProxyConnectionFailed = 0); /** Return readable error string for a network error code */ std::string NetworkErrorString(int err); /** Close socket and set hSocket to INVALID_SOCKET */ bool CloseSocket(SOCKET& hSocket); /** Disable or enable blocking-mode for a socket */ bool SetSocketNonBlocking(SOCKET& hSocket, bool fNonBlocking); /** * Convert milliseconds to a struct timeval for e.g. select. */ struct timeval MillisToTimeval(int64_t nTimeout); #endif // BITCOIN_NETBASE_H
[ "robin.adaptor@gmail.com" ]
robin.adaptor@gmail.com
183a476e48b158aa6a8a1db18fa5c3263af996f6
cba54fda668bdbadbfe04130b17d2f703a53971c
/sr2/src/items/armor/ArmorRef.cpp
0b3447337f895a7a317176c0b9a8f5efdb25fbb1
[]
no_license
Nightwind0/stonering
85af318ad90c6698bc424c86a031481cb6d67ee0
f6c31db3840bfdc3d9a5da7f66aed9186615a2c9
refs/heads/master
2021-01-17T18:45:07.301920
2018-08-29T20:19:56
2018-08-29T20:19:56
65,499,984
0
0
null
null
null
null
UTF-8
C++
false
false
1,843
cpp
#include "ArmorRef.h" #include "ArmorType.h" #include "ArmorClass.h" #include "RuneType.h" #include "ItemManager.h" #include "IApplication.h" using namespace StoneRing; ArmorRef::ArmorRef ( ArmorType *pType, ArmorClass *pClass, ArmorClass *pImbuement, RuneType *pRune ) :m_pArmorType(pType), m_pArmorClass(pClass), m_pImbuement(pImbuement), m_pRuneType(pRune) { } std::string ArmorRef::GetName() const { return m_name; } bool ArmorRef::handle_element(eElement element, Element * pElement) { switch(element) { case EARMORTYPEREF: m_pType = (dynamic_cast<ArmorTypeRef*>(pElement)); m_pArmorType = ItemManager::GetArmorType(*m_pType); break; case EARMORCLASSREF: m_pClass = (dynamic_cast<ArmorClassRef*>(pElement)); m_pArmorClass = ItemManager::GetArmorClass (*m_pClass); break; case EARMORIMBUEMENTREF: m_pImbuement = ItemManager::GetArmorImbuement(* dynamic_cast<ArmorImbuementRef*>(pElement)); break; case ERUNETYPE: m_pRuneType = dynamic_cast<RuneType*>(pElement); break; default: return false; } return true; } void ArmorRef::load_finished() { m_name = Armor::CreateArmorName(m_pArmorType,m_pArmorClass,m_pImbuement,m_pRuneType); } ArmorRef::ArmorRef():m_pArmorType(NULL), m_pArmorClass(NULL), m_pImbuement(NULL), m_pRuneType(NULL) { } ArmorRef::~ArmorRef() { } ArmorType * ArmorRef::GetArmorType() const { return m_pArmorType; } ArmorClass * ArmorRef::GetArmorClass() const { return m_pArmorClass; } ArmorClass * ArmorRef::GetArmorImbuement() const { return m_pImbuement; } RuneType * ArmorRef::GetRuneType() const { return m_pRuneType; }
[ "nightwind@1a319a91-200f-0410-9ca8-f36a151797b4" ]
nightwind@1a319a91-200f-0410-9ca8-f36a151797b4
60fcd0905385a961c260a6e95bde2cdf77220147
a4380ed3e48f9402a34c95580108defe92dfd3ed
/HashTable.cc
04292d1b354087511c3a5f815bcaac9364f530da
[]
no_license
liminglives/BasicAlgorithm
ce67ca6125f8dbb4bbb49214cee0ed0da63fa4af
a51178308ec2203a687b0d87883378959a675cf5
refs/heads/master
2016-09-06T03:19:08.894246
2014-10-22T05:00:36
2014-10-22T05:00:36
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,295
cc
//hash table by separate chaining #include <iostream> #include <stdlib.h> typedef struct ListNode { int data; struct ListNode *next; }List; typedef struct HashTableHead { int size; List **table; }HashTable; HashTable * initilaze(int size) { if (size < 0) return NULL; //todo: calculate the next prime of number size; HashTable *hashtable = (HashTable *)malloc(sizeof(HashTable)); if (hashtable == NULL) return NULL; hashtable->size = size; hashtable->table = (List **)malloc(sizeof(List *)*hashtable->size); if (hashtable->table == NULL) { free(hashtable); return NULL; } //memset(hashtable->table, 0, sizeof(List *)*hashtable->size); for (int i=0; i<hashtable->size; ++i) { hashtable->table[i] = (List *)malloc(sizeof(List)); if (hashtable->table[i] == NULL) std::cout<<"out of space"<<std::endl; else hashtable->table[i]->next = NULL; } return hashtable; } void insert(HashTable *hash, int data) { if (hash == NULL) return; int index = data % hash->size; List *prev = hash->table[index]; List *cur = prev->next; while(cur) { prev = cur; if (cur->data == data) return; cur = cur->next; } prev->next = (List *)malloc(sizeof(List)); prev->next->data = data; prev->next->next = NULL; } List * find(HashTable *hash, int data) { if (hash == NULL) return NULL; int index = data % hash->size; List *tmp = hash->table[index]->next; while(tmp) { if (tmp->data == data) return tmp; tmp = tmp->next; } return NULL; } void printList(List *head) { if (!head) return; List *tmp = head->next; while(tmp) { std::cout<<tmp->data<<" "; tmp = tmp->next; } std::cout<<std::endl; } void printHashTable(HashTable *hash) { if (!hash) return; for (int i=0; i<hash->size; ++i) printList(hash->table[i]); } int main() { int a[10] = {1, 2, 3, 5, 12, 8, 11, 6, 14, 10}; HashTable *hashtable = initilaze(7); for (int i=0; i<10; ++i) insert(hashtable, a[i]); printHashTable(hashtable); return 0; }
[ "liminglives@163.com" ]
liminglives@163.com
669ccf8e04df390e2f21d165b91539ea14d5825d
2f80cd4cf920c80ebee2b8d657ac938372497848
/day01/ex04/ex04.cpp
7a78c745d6776565735726ec3c0ba2bcad2def84
[]
no_license
jDiazPrieto/cpp_piscine
8cfbe80dc9973bcbe40aad127698c7f733fe1788
4d787d271f463898e8d687df71ec752ff38e2c74
refs/heads/master
2021-10-19T00:41:42.323507
2019-02-16T02:47:18
2019-02-16T02:47:18
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,173
cpp
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ex04.cpp :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: jdiaz <marvin@42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/01/23 17:56:44 by jdiaz #+# #+# */ /* Updated: 2019/01/23 18:05:28 by jdiaz ### ########.fr */ /* */ /* ************************************************************************** */ #include <string> #include <iostream> int main(void) { std::string str = "HI THIS IS A BRAIN"; std::string *strPointer = &str; std::string &strRef = str; std::cout << "Pointer: " << *strPointer << std::endl; std::cout << "Reference: " << strRef << std::endl; return (0); }
[ "jdiaz@e1z2r3p36.42.us.org" ]
jdiaz@e1z2r3p36.42.us.org
9953b40d08b1b62412394893b578501c7bab95b6
c26672d8ffd1c145ddce9caa55da3d379bfa6c77
/source/Pages/NcaDumpPage.cpp
1dd9bc80ba2e19e0d64481553b63e2b3fca59c9c
[]
no_license
tiansongyu/SwitchThemesNX_ch
1eddef7ea7b8a1bfcaf0c6916f33db50816cf314
a3d1e9ef612adb3343860035e6b01a636b79da7e
refs/heads/master
2022-11-24T02:40:02.490183
2020-07-25T14:59:29
2020-07-25T14:59:29
282,163,591
0
0
null
null
null
null
UTF-8
C++
false
false
3,400
cpp
#include "NcaDumpPage.hpp" #include "../ViewFunctions.hpp" #include "../fs.hpp" #include "../SwitchTools/hactool.hpp" #include <filesystem> #include "../Platform/Platform.hpp" #include "../SwitchThemesCommon/NXTheme.hpp" using namespace std; NcaDumpPage::NcaDumpPage() : dumpNca("备份默认主题") { Name = "备份默认主题"; guideText = ("要安装.nxtheme文件,首先需要备份默认主题 \n" "每当固件更改时,无论是更新还是降级,都需要这样做.\n" "当提取的版本与您的固件不匹配时,将提示您这样做.\n\n" "通常不需要手动提取,但如果遇到问题,可以在这里尝试这样做."); } void NcaDumpPage::Render(int X, int Y) { Utils::ImGuiSetupPage(this, X, Y); ImGui::PushFont(font30); ImGui::TextWrapped(guideText.c_str()); if (ImGui::Button(dumpNca.c_str())) { PushFunction([]() { if ((gamepad.buttons[GLFW_GAMEPAD_BUTTON_LEFT_BUMPER] && gamepad.buttons[GLFW_GAMEPAD_BUTTON_RIGHT_BUMPER])) { DialogBlocking("输入超级密钥组合,只有主菜单NCA会被丢弃(不会被提取)"); DisplayLoading("提取 NCA中..."); if (fs::DumpHomeMenuNca()) Dialog("主菜单NCA被提取,现在使用注入器来完成设置。\n如果您不是故意这样做的,请忽略此消息."); return; } if (!YesNoPage::Ask( "安装自定义主题之前,你需要首先提取(备份)主菜单,这个过程可能需要几秒钟,不要让你的机器进入睡眠模式,不要按下home键\n" "你想继续吗 ?")) return; fs::RemoveSystemDataDir(); try { if (hactool::ExtractHomeMenu()) Dialog("已完成,默认主题被导出(备份成功),现在可以安装新的nxtheme文件(主题)了!"); } catch (std::runtime_error &err) { DialogBlocking("在备份默认主题时出错: " + string(err.what())); } }); } PAGE_RESET_FOCUS ImGui::PopFont(); Utils::ImGuiCloseWin(); } void NcaDumpPage::Update() { if (Utils::PageLeaveFocusInput()){ Parent->PageLeaveFocus(this); } } void NcaDumpPage::CheckHomeMenuVer() { if (!filesystem::exists(SD_PREFIX "/themes/systemData/ResidentMenu.szs")) { DialogBlocking("安装自定义主题之前,你需要首先备份默认主题,这个过程可能需要几秒钟,不要让你的机器进入睡眠模式,不要按下home键 按A开始"); goto DUMP_HOMEMENU; } if (filesystem::exists(SD_PREFIX "/themes/systemData/ver.cfg")) { FILE *ver = fopen(SD_PREFIX "/themes/systemData/ver.cfg", "r"); if (ver) { char str[50] = {0}; fgets(str,49,ver); fclose(ver); string version(str); if (version != SystemVer) goto ASK_DUMP; else return; } else goto ASK_DUMP; } else if (HOSVer.major >= 7) goto ASK_DUMP; else fs::WriteHomeDumpVer(); return; ASK_DUMP: if (!YesNoPage::Ask("当前固件版本与所提取的主菜单不同,是否要再次提取主菜单?\n如果所提取的主菜单与已安装的主题不匹配,将会出错")) { DialogBlocking("你不会再看到这条消息,在出错的情况下,你可以手动从主菜单的 `备份默认主题`选项中备份默认主题"); fs::WriteHomeDumpVer(); return; } DUMP_HOMEMENU: fs::RemoveSystemDataDir(); try { hactool::ExtractHomeMenu(); } catch (std::runtime_error &err) { DialogBlocking("在备份默认主题时出错: " + string(err.what())); } }
[ "478880214@qq.com" ]
478880214@qq.com
2e9869b1fe26a4ae23dd92aec835591c70cd5aa4
069cde13545969aad751208bbde64aa76d7cd081
/src/Schemes/FvVectorScheme.h
0b033af4f8219d9b41c7f8984c414b53f9ecfe00
[]
no_license
Haider-BA/CAFFE
2be592ca8a520f8bc46488f51e644b6b2a2ac75a
bcf546ff25f94b7e98494ed8e9cb70878ba1954c
refs/heads/master
2021-01-12T12:10:24.368885
2016-01-08T17:49:09
2016-01-08T17:49:09
72,333,374
1
0
null
2016-10-30T06:46:00
2016-10-30T06:46:00
null
UTF-8
C++
false
false
447
h
#ifndef FV_VECTOR_SCHEME_H #define FV_VECTOR_SCHEME_H #include "FvScheme.h" #include "Vector3D.h" #include "Tensor3D.h" class FvVectorScheme : public FvScheme { public: static void computeCellCenteredGradients(GradientEvaluationMethod method, const Field<Vector3D> &field, Field<Tensor3D> &gradField); static void extrapolateInteriorFaces(GradientEvaluationMethod method, Field<Vector3D>& field, Field<Tensor3D>& gradField); }; #endif
[ "roni511@gmail.com" ]
roni511@gmail.com
0f0dc9c851b84c048bc2df74eda1af86d34e37b6
d4fa84dd00d32f2162d24f1940e4337d58859296
/Parametric_EstimationModel.h
6118d1b5d5934e2f9149c2c2512146689ff09a0a
[]
no_license
vakondah/MyBudget
2e702211c09a906b203fc4a5f80f2bb641aab562
50fa6583ce00b3fe617391034ff5783cbb3f6404
refs/heads/master
2023-04-05T19:20:29.293627
2021-04-15T18:32:34
2021-04-15T18:32:34
357,662,910
0
0
null
null
null
null
UTF-8
C++
false
false
775
h
// Aliaksandra Hrechka // CSC 160 // 12/11/2020 //Final Project // Parametric_EstimationModel.h #pragma once #include <string> #include "DocumentEstimationModel.h" using namespace std; class Parametric_EstimationModel : public DocumentEstimationModel { private: string* units; double** patametric_table; double numOfUnits; double total; public: // Getters and setters functions: void setNumberOfUnits(double num) { numOfUnits = num; } double getTotal() const { return total; } int getNumberOfActivities() const { return numOfUnits; } // Member functions: void fillParametric_Table(); void PrintDocument(); // Constructors: Parametric_EstimationModel(); Parametric_EstimationModel(int id, string author, string date, string acc, EstimationType et); };
[ "ahrechka@student.cccs.edu" ]
ahrechka@student.cccs.edu
17d7d959a95c542f176e3adad99752ad9d84f5fe
1e3e6526a92b721d378ae8d36a0709f7b8c541ed
/SimDisk/SimDisk/FileSystem.cpp
ca4f93cd91bb250948d5ceeabf1a8f06dd6962f4
[ "Apache-2.0" ]
permissive
J-CIC/SimDisk
5c73a80537c3170b3e63782c653b2a93327801c8
b4d131b0728402150c81b529254b803b882f98ca
refs/heads/master
2021-03-27T14:28:38.761036
2018-02-26T12:53:20
2018-02-26T12:53:20
118,877,969
1
0
null
null
null
null
GB18030
C++
false
false
43,092
cpp
#include "stdafx.h" #include "FileSystem.h" const string FileSystem::fileName = "disk.bin"; #define INPUT_SIZE 4096 FileSystem::FileSystem() { long int diskSize = 100 * 1024 * 1024 * 1;//磁盘大小,Byte fileDisk.open(fileName, ios::binary | ios::in| ios::out); if (!fileDisk){//文件不存在 fileDisk.open(fileName, ios::out | ios::binary); //生成新超级块的信息,并写入 superBlock sp; sp.init(); s_block = sp; seekAndSave<superBlock>(fileDisk.tellg(), sp); //生成位图 fileDisk.seekg(sp.inodemap_pos, ios::beg); unsigned char * map = new unsigned char[sp.blockSize]; memset(map, 0, sp.blockSize*sizeof(char)); for (int i = 0; i < ceil(sp.inode_num / (8 * 1024)); i++){ fileDisk.write((char *)map, sp.blockSize); } fileDisk.seekg(sp.bitmap_pos, ios::beg); for (int i = 0; i < ceil(sp.block_num / (8 * 1024)); i++){ fileDisk.write((char *)map, sp.blockSize); } fileDisk.seekg(diskSize, ios::beg);//偏移磁盘大小 fileDisk.write("1",1);//写入内容使得文件达到目标大小 fileDisk.close(); fileDisk.open(fileName, ios::binary | ios::in | ios::out); int ret = alloc_inode(272384, root, true);//设置根节点 root.i_size = 0; unsigned short t_mode = 1; t_mode = t_mode << 14; root.i_mode = t_mode + (7 << 8) + (7 << 4) + 7;//设定为文件夹777权限 seekAndSave<iNode>(s_block.inode_table, root); } seekAndGet<superBlock>(0, s_block); seekAndGet<iNode>(s_block.inode_table, root); init_root_dentry();//初始化目录 init_user();//初始化用户 } FileSystem::~FileSystem() { fileDisk.close(); } //初始化用户 int FileSystem::init_user() { //初始化root用户 dentry * temp; if (findDentryWithName("/etc/shadow", temp, 2) != 2){ //shadow文件不存在 User rootUser = User("root", "root", 0);//默认账户 currUser = rootUser; userLists.push_back(rootUser);//加入用户列表 User testUser = User("test", "test", userLists[userLists.size()-1].u_id+1);//测试账户 userLists.push_back(testUser);//加入用户列表 mkdir("/etc"); int id = newfile("/etc/shadow", 10240); save_user(); return 1; } findDentryWithName("/etc/shadow", temp, 2); vector<unsigned int> block_lists;//内容块 readBlockIds(temp->inode, block_lists);//读取内容块 int cnt_per_block = s_block.blockSize / sizeof(User); int block_idx = 0, cnt = 0; int user_count = temp->inode.i_size / sizeof(User); for (int i = 0; i < user_count;i++){ if (cnt >= cnt_per_block){ cnt = 0; block_idx += 1; } unsigned long base_pos = (block_lists[block_idx] - 1) * s_block.blockSize; User *user = new User(); seekAndGet<User>(base_pos + cnt*sizeof(User), *user); userLists.push_back(*user);//推入列表中 cnt++; } return 1; } //保存用户 int FileSystem::save_user() { dentry * temp; if (findDentryWithName("/etc/shadow", temp, 2) != 2){ mkdir("/etc"); int id = newfile("/etc/shadow", 10240); } temp->inode.i_mode = 7 << 8; temp->inode.i_size = userLists.size()*sizeof(User); vector<unsigned int> block_lists;//内容块 readBlockIds(temp->inode, block_lists);//读取内容块 int cnt_per_block = s_block.blockSize / sizeof(User); int block_idx = 0, cnt = 0; for (auto user : userLists){ if (cnt >= cnt_per_block){ cnt = 0; block_idx += 1; } unsigned long base_pos = (block_lists[block_idx] - 1) * s_block.blockSize; seekAndSave<User>(base_pos + cnt*sizeof(User), user); cnt++; } write_inode(temp->inode);//保存iNode return 1; } //服务 int FileSystem::serve(){ srand(time(NULL));//置随机数种子用于生成token HANDLE m_command; //客户端通知服务器 HANDLE m_return; //服务器通知客户端 HANDLE p_mutex; //用于同步客户端的 mutex //设定事件初始化,若没创建事件则创建 m_command = OpenEvent(EVENT_ALL_ACCESS, NULL, L"shell_input"); if (m_command == NULL){ m_command = CreateEvent(NULL, FALSE, FALSE, L"shell_input"); } m_return = OpenEvent(EVENT_ALL_ACCESS, NULL, L"shell_return"); if (m_return == NULL){ m_return = CreateEvent(NULL, FALSE, FALSE, L"shell_return"); } // 创建共享文件句柄 hMapFile = CreateFileMapping( INVALID_HANDLE_VALUE, // 物理文件句柄 NULL, // 默认安全级别 PAGE_READWRITE, // 可读可写 0, // 高位文件大小 INPUT_SIZE, // 低位文件大小 L"ShareMemory" // 共享内存名称 ); usrMapFile = CreateFileMapping( INVALID_HANDLE_VALUE, // 物理文件句柄 NULL, // 默认安全级别 PAGE_READWRITE, // 可读可写 0, // 高位文件大小 INPUT_SIZE, // 低位文件大小 L"usrShareMemory" // 共享内存名称 ); for (;;){ DWORD dw = WaitForSingleObject(m_command, INFINITE);//无限等待 // 映射缓存区视图 , 得到指向共享内存的指针 LPVOID lpBase = MapViewOfFile( hMapFile, // 共享内存的句柄 FILE_MAP_ALL_ACCESS, // 可读写许可 0, 0, INPUT_SIZE ); if (dw == WAIT_TIMEOUT){ break; } // 将共享内存数据拷贝到字符串 char cmd_inital[INPUT_SIZE] = { 0 }; strcpy_s(cmd_inital, (char*)lpBase); string cmd = cmd_inital; stringstream redirect_stream;//设定cout的重定向留 streambuf * backup;//备份 cout.rdbuf(redirect_stream.rdbuf());//重定向 parseCmd(cmd);//处理命令 outputPrompt();//输出提示符 string output;//输出 output = redirect_stream.str();//复制到输出 strcpy_s((char*)lpBase, INPUT_SIZE, output.c_str());//写入共享内存 ResetEvent(m_command);//重置事件 SetEvent(m_return);//通知客户端处理 UnmapViewOfFile(lpBase);// 解除文件映射 } // 关闭内存映射文件对象句柄 CloseHandle(hMapFile); CloseHandle(usrMapFile); return 1; } //检查权限,需要的权限access_type用rwx的整数表示 bool FileSystem::checkAccess(int access_type, iNode node){ bool ret_val = false; if (currUser.u_id == 0){ //管理员 return true; } if (currUser.u_id == node.i_uid){ //属于当前用户的权限 int access = node.i_mode;//所拥有的权限 int mask = (1 << 2) + (1 << 1) + 1; mask = mask << 8;//获取本用户权限的掩码 ret_val = (access_type << 8)&(mask&access); } else if (currUser.g_id == node.i_gid){ //属于当前用户组的权限 int access = node.i_mode;//所拥有的权限 int mask = (1 << 2) + (1 << 1) + 1; mask = mask << 4;//获取本用户权限的掩码 ret_val = (access_type << 4)&(mask&access); } else{ //其他人的权限 int access = node.i_mode;//所拥有的权限 int mask = (1 << 2) + (1 << 1) + 1;//获取本用户权限的掩码 ret_val = access_type&(mask&access); } return ret_val; } //解析命令 int FileSystem::parseCmd(string cmd) { int ret = 0; vector<string>cmd_list; stringstream s(cmd); string total = cmd; s >> cmd; string temp; while (s >> temp){ cmd_list.push_back(temp); } //如果用户执行登录操作,则进行单独判断 if (cmd == "auth"){ int u_id = auth(cmd_list[0], cmd_list[1]); if (u_id == -1){ generate_token(-1);//生成失败空token,并保存至内存中 return ret; } else{ generate_token(u_id);//生成校验token,并保存至内存中 ret = 1; } } else{ //获取本次的shell_user if (get_shell_user() == -1){ cout << "invalid user" << endl; return ret; } //处理命令 if (cmd == "newfile"){ if (cmd_list.size() == 1){ ret = newfile(cmd_list[0]); if (ret == -1){ cout << "file exists !" << endl; } else if (ret == -2){ cout << "name length is not valid" << endl; } else if (ret == -3){ cout << "No enough iNode or blocks" << endl; } } else{ cout << "newfile accept one parameter" << endl; } } else if (cmd == "dir"){ if (cmd_list.size() == 1){ ret = ls(cmd_list[0]); if (ret == 0 || ret == 2){ cout << "No such directory : " << cmd_list[0] << endl; } } else if (cmd_list.size() == 0){ ret = ls(); } else{ cout << "dir accept less than one parameter" << endl; } } else if (cmd == "cd"){ if (cmd_list.size() >= 1){ ret = cd(cmd_list[0]); if (ret == 2 || ret == 0){ cout << "No such directory : " << cmd_list[0] << endl; } } } else if (cmd == "del"){ if (cmd_list.size() == 0){ cout << "del accept at least one parameter" << endl; } else{ for (auto name : cmd_list){ int ret = del(name); if (ret == 0){ cout << "file: " << name << " not found " << endl; } else if (ret == -1){ cout << "file: " << name << " is not file" << endl; } } } } else if (cmd == "md"){ if (cmd_list.size() == 0){ cout << "mkdir accept at least one parameter" << endl; } else{ for (auto name : cmd_list){ ret = mkdir(name); if (ret == -1){ cout << "folder exists !" << endl; } else if (ret == -2){ cout << "name length is not valid" << endl; } else if (ret == -3){ cout << "No enough iNode or blocks" << endl; } } } } else if (cmd == "rd"){ if (cmd_list.size() == 0){ cout << "del accept at least one parameter" << endl; } else{ for (auto name : cmd_list){ ret = rd(name); if (ret == 3){ //非空目录 cout << "the directory is not empty, force delete? " << "Y/N :" << endl; string choice; getline(cin, choice); if (choice == "Y" || choice == "y"){ ret = rd(name, true);//强制删除 } } if (ret == 0 || ret == 2){ cout << "No such folder: " << name << endl; } } } } else if (cmd == "cat"){ if (cmd_list.size() != 1){ cout << "cat accept only one parameter" << endl; } else{ ret = cat(cmd_list[0]); if (ret == 0 || ret == 1){ cout << "No such file: " << cmd_list[0] << endl; } } } else if (cmd == "info"){ s_block.printInfo(); } else if (cmd == "copy"){ if (cmd_list.size() == 2){ ret = copy(cmd_list[0], cmd_list[1]); if (ret == 0){ cout << "No such file: " << cmd_list[0] << endl; } else if (ret == -1){ cout << "file exists !" << endl; } else if (ret == -2){ cout << "name length is not valid" << endl; } else if (ret == -3){ cout << "No enough iNode or blocks" << endl; } } else{ cout << "copy require two parameters" << endl; } } else if (cmd=="chmod"){ stringstream temp(cmd_list[1]); int mode; temp >> mode; ret = chmod(cmd_list[0], mode); if (ret == 0){ cout << "file not exists" << endl; } else if (ret == -1){ cout << "invalid mode" << endl; } } else if (cmd == "exit"){ exit(0);//退出 } else{ if (cmd != "") cout << "unknown command" << endl; } } return ret; } //生成登录的token int FileSystem::generate_token(int uid){ string token = "";//最终保存的token if (uid != -1){ //登录成功才产生token,否则token为空 unsigned long c_time = time(NULL); stringstream buf;//生成流用以转换类型 buf << c_time;//流中输入信息 string time_string; buf >> time_string;//输出到字符 for (int i = 0; i < time_string.length(); i++){ int rand_num = rand() % 26;//26个字母 char character = rand_num + 65 + (rand() % 2) * 32;//随机大小写字母 token += character; token += time_string[i];//插值 } loginUserLists.insert(pair<string, int>(token, uid)); if (uid < userLists.size()){ currUser = userLists[uid]; } } // 映射缓存区视图 , 得到指向共享内存的指针 LPVOID lpBase = MapViewOfFile( usrMapFile, // 共享内存的句柄 FILE_MAP_ALL_ACCESS, // 可读写许可 0, 0, INPUT_SIZE ); strcpy_s((char*)lpBase, INPUT_SIZE, token.c_str());//写入共享内存 return 1; } //获取本次命令的User int FileSystem::get_shell_user(){ char token[INPUT_SIZE] = { 0 }; // 映射缓存区视图 , 得到指向共享内存的指针 LPVOID lpBase = MapViewOfFile( usrMapFile, // 共享内存的句柄 FILE_MAP_ALL_ACCESS, // 可读写许可 0, 0, INPUT_SIZE ); strcpy_s(token, (char*)lpBase);//写入共享内存 string key = token;//token复制 int u_id = -1;//用户id auto item = loginUserLists.find(key);//寻找对应id if (item != loginUserLists.end()){ //找到了登录用户 u_id = item->second; if (u_id < userLists.size()){ currUser = userLists[u_id];//设定当前用户 } else{ return -1;//异常状况,按道理不可能出现,以防万一 } } return u_id; } //输出提示符 void FileSystem::outputPrompt(){ cout << currUser.username << ":" << curr_dentry->getPathName() << "# "; } //申请iNode节点,size单位为Byte int FileSystem::alloc_inode(unsigned long size, iNode &node,bool is_dentry) { unsigned int blocks_needed = ceil((double)size / s_block.blockSize);//需要存储内容的块数 //最大大小超过限制,iNode节点不足时 if (size>s_block.maxBytes || s_block.inode_remain == 0){ return -1; } if (size == 0){ blocks_needed = 10; } fileDisk.seekg(s_block.inodemap_pos, ios::beg);//挪动到位图位置 bool is_end = false; int inode_no = 1;//使用的iNode号码 unsigned char* bytes = new unsigned char[s_block.blockSize];//读取的数组 int block_node_num = s_block.blockSize / sizeof(unsigned int);//每块可存的iNode的id的数目 if (blocks_needed <= 10){ //可以在10个直接块中放下 } else if (blocks_needed <= (10 + block_node_num)){ //加上一个一次间接块 blocks_needed += 1; } else if (blocks_needed <= (10 + block_node_num + block_node_num*block_node_num)){ //加上一个二次间接块 blocks_needed += 2 + block_node_num; } else if (blocks_needed <= (10 + block_node_num + block_node_num*block_node_num + block_node_num*block_node_num*block_node_num)){ //加上一个三次间接块 blocks_needed += 3 + 2 * block_node_num + block_node_num*block_node_num; } if (blocks_needed > s_block.block_remain){ //超过剩余量 return -1; } //寻找空闲的iNode for (int i = 0; i < ceil(s_block.inode_num / (8 * s_block.blockSize)); i++){ if (is_end) break;//遍历完所有位图后退出 fileDisk.read((char *)bytes, s_block.blockSize);//一次读取一块 unsigned char mask = 1; mask = mask << 7; for (int index = 0; index<s_block.blockSize; index++){ if (is_end) break;//遍历完所有位图后退出 unsigned char byte = bytes[index]; for (int j = 0; j < 8; j++){ if (!((byte << j)&mask)){ //若有空位 bytes[index] = byte | (1 << (7-j)); fileDisk.seekg(s_block.inodemap_pos + i*s_block.blockSize, ios::beg); fileDisk.write((char *)bytes, s_block.blockSize);//位图改变整块写回 fileDisk.flush();//写回文件 is_end = true;//结束 break; } inode_no += 1; if (inode_no>s_block.inode_num){ is_end = true; break; } } } } vector<unsigned int> block_list; alloc_blocks(blocks_needed, block_list);//申请磁盘块 node = iNode(inode_no,size,blocks_needed,block_list); node.i_mode = (6<<8)+(6<<4)+4;//664的默认权限 if (is_dentry){ unsigned short mode = 1; mode = mode << 14; node.i_mode = mode + (7 << 8) + (5 << 4) + 5;//设定为文件夹755的默认权限 } node.i_uid = currUser.u_id; node.i_gid = currUser.u_id; write_inode(node); //更新相应的超级块信息 s_block.inode_remain--; s_block.block_remain -= blocks_needed; seekAndSave<superBlock>(0, s_block); return 1; } int FileSystem::alloc_blocks(int num, vector<unsigned int> &list){ fileDisk.seekg(s_block.bitmap_pos, ios::beg);//挪动到位图位置 bool is_end = false; unsigned int block_no = 1;//使用的block号码 unsigned char* bytes = new unsigned char[s_block.blockSize];//读取的数组 //寻找空闲的block for (int i = 0; i < ceil(s_block.block_num / (8 * s_block.blockSize)); i++){ if (is_end) break;//遍历完所有位图后退出 fileDisk.read((char *)bytes, s_block.blockSize);//一次读取一块 bool modify = false;//是否有更改需要写回磁盘 unsigned char mask = 1; mask = mask << 7; for (int index = 0; index<s_block.blockSize; index++){ if (is_end) break;//遍历完所有位图后退出 unsigned char byte = bytes[index]; for (int j = 0; j < 8; j++){ if (block_no < s_block.first_data_block_no){ block_no++; continue; } if (!((byte << j)&mask)){ //若有空位 bytes[index] = byte | (1 << (7 - j)); byte = bytes[index];//更新byte list.push_back(block_no); modify = true; if (num == list.size()){ is_end = true;//结束 break; } } block_no += 1; if (block_no>s_block.block_num){ is_end = true; break; } } } if (modify){ fileDisk.seekg(s_block.bitmap_pos + i*s_block.blockSize, ios::beg); fileDisk.write((char *)bytes, s_block.blockSize);//位图改变整块写回 } } clearBlockContent(list);//清除分配的块中的内容 //排放block int block_per_num = s_block.blockSize / sizeof(unsigned int);//每块可存的block的id的数目 if (list.size() <= 10){ //可以在10个直接块中放下 } else if (list.size() <= (11 + block_per_num)){ //加上一个一次间接块 int cnt = 0, i;//写入次数和写入下标 unsigned int once_no = list[10]; fileDisk.seekg((once_no-1)*s_block.blockSize);//去到正确的偏移位置 for (i = 11; cnt< block_per_num&&i<list.size(); i++, cnt++){ fileDisk.write((char*)&list[i], sizeof(unsigned int)); } list.resize(11); } else if (list.size() <= (12 + 2*block_per_num + block_per_num*block_per_num)){ //加上一个一次间接块 int cnt=0,i;//写入次数和写入下标 unsigned int once_no = list[10]; unsigned int twice_no = list[11]; fileDisk.seekg((once_no - 1)*s_block.blockSize);//去到正确的偏移位置 for (i = 12; cnt <block_per_num ; i++,cnt++){ fileDisk.write((char*)&list[i], sizeof(unsigned int)); } //加上一个二次间接块 vector<unsigned int> once_in_twice;//二次间接块中的一次间接块 fileDisk.seekg((twice_no - 1)*s_block.blockSize);//去到正确的偏移位置 cnt = 0; for (; cnt<block_per_num; i++,cnt++){ once_in_twice.push_back(list[i]); fileDisk.write((char*)&list[i], sizeof(unsigned int)); } //二次间接块的一次间接块 for (auto item : once_in_twice){ fileDisk.seekg((item - 1)*s_block.blockSize);//去到正确的偏移位置 cnt = 0; for (; cnt<block_per_num&&i<list.size(); i++, cnt++){ once_in_twice.push_back(list[i]); fileDisk.write((char*)&list[i], sizeof(unsigned int)); } } list.resize(12); } else if (list.size() <= (13 + 3*block_per_num + 2*block_per_num*block_per_num + block_per_num*block_per_num*block_per_num)){ //加上一个一次间接块 int cnt = 0, i;//写入次数和写入下标 unsigned int once_no = list[10]; unsigned int twice_no = list[11]; unsigned int third_no = list[12]; fileDisk.seekg((once_no - 1)*s_block.blockSize);//去到正确的偏移位置 for (i = 13; cnt <block_per_num; i++, cnt++){ fileDisk.write((char*)&list[i], sizeof(unsigned int)); } //加上一个二次间接块 vector<unsigned int> once_in_twice;//二次间接块中的一次间接块 fileDisk.seekg((twice_no - 1)*s_block.blockSize);//去到正确的偏移位置 cnt = 0; for (; cnt<block_per_num; i++, cnt++){ once_in_twice.push_back(list[i]); fileDisk.write((char*)&list[i], sizeof(unsigned int)); } //二次间接块的一次间接块 for (auto item : once_in_twice){ fileDisk.seekg((item - 1)*s_block.blockSize);//去到正确的偏移位置 cnt = 0; for (; cnt<block_per_num; i++, cnt++){ once_in_twice.push_back(list[i]); fileDisk.write((char*)&list[i], sizeof(unsigned int)); } } //加上一个三次间接块 vector<unsigned int> twice_in_third;//三次间接块中的一次间接块 fileDisk.seekg((third_no - 1)*s_block.blockSize);//去到正确的偏移位置 cnt = 0; for (; cnt<block_per_num; i++, cnt++){ twice_in_third.push_back(list[i]); fileDisk.write((char*)&list[i], sizeof(unsigned int)); } once_in_twice.clear(); for (auto item : twice_in_third){ fileDisk.seekg((item - 1)*s_block.blockSize);//去到正确的偏移位置 cnt = 0; for (; cnt<block_per_num; i++, cnt++){ once_in_twice.push_back(list[i]); fileDisk.write((char*)&list[i], sizeof(unsigned int)); } } for (auto item : once_in_twice){ fileDisk.seekg((item - 1)*s_block.blockSize);//去到正确的偏移位置 cnt = 0; for (; cnt<block_per_num&&i<list.size(); i++, cnt++){ once_in_twice.push_back(list[i]); fileDisk.write((char*)&list[i], sizeof(unsigned int)); } } list.resize(13); } return 1; } int FileSystem::write_inode(iNode &node){ //检查范围 if (node.ino<1 || node.ino>s_block.inode_num){ return -1; } node.i_mtime = time(NULL);//修改时间 node.i_atime = node.i_mtime;//访问时间 seekAndSave<iNode>(s_block.inode_table + (node.ino - 1)*sizeof(iNode), node); return 1; } template<typename T> int FileSystem::seekAndGet(unsigned long pos, T& item){ fileDisk.seekg(pos,ios::beg); fileDisk.read((char*)&item, sizeof(T)); return 1; } template<typename T> int FileSystem::seekAndSave(unsigned long pos, T& item){ fileDisk.seekg(pos, ios::beg); fileDisk.write((char*)&item, sizeof(T)); fileDisk.flush();//写回文件 return 1; } //删除文件后的收回文件对应的节点和块 int FileSystem::withdraw_node(iNode node){ vector<unsigned int> block_list; readBlockIds(node, block_list); destroy_inode(node.ino);//修改inode位图 s_block.inode_remain++;//修改剩余iNode数目 for (auto idx : block_list){ destroy_block(idx);//修改block位图 } s_block.block_remain += block_list.size();//修改剩余block数目 seekAndSave<superBlock>(0, s_block); return 1; } //收回block,即修改位图 int FileSystem::destroy_block(int id) { unsigned int byte_pos = floor(id / 8);//偏移字节 int byte_idx = id % 8;//字节内地址下标 if (byte_idx == 0){ //整除则回退一位 byte_pos--; byte_idx = 8; } char byte=0;//存放内容的位图 unsigned char mask = 255; unsigned char xor_mask = 1; xor_mask = xor_mask << (8 - byte_idx); mask = mask^xor_mask; //读取并置0 fileDisk.seekg(s_block.bitmap_pos + byte_pos); fileDisk.read((char *)&byte, 1); byte = byte & mask; //写回 fileDisk.seekg(s_block.bitmap_pos + byte_pos); fileDisk.write((char *)&byte, 1); fileDisk.flush();//写回文件 vector<unsigned int> list;//清空块内容 list.push_back(id);//清空块内容 clearBlockContent(list);//清空块内容 return 1; } //收回iNode int FileSystem::destroy_inode(int id) { unsigned int byte_pos = floor(id / 8);//偏移字节 int byte_idx = id % 8;//字节内地址下标 if (byte_idx == 0){ //整除则回退一位 byte_pos--; byte_idx = 8; } char byte = 0;//存放内容的位图 unsigned char mask = 255; unsigned char xor_mask = 1; xor_mask = xor_mask << (8 - byte_idx); mask = mask^xor_mask; //读取并置0 fileDisk.seekg(s_block.inodemap_pos + byte_pos); fileDisk.read((char *)&byte, 1); byte = byte & mask; //写回 fileDisk.seekg(s_block.inodemap_pos + byte_pos); fileDisk.write((char *)&byte, 1); fileDisk.flush();//写回文件 return 1; } //批量清理块中的内容 int FileSystem::clearBlockContent(vector<unsigned int> list) { //生成空内容并写入 char bytes[1024]; memset(bytes, 0, 1024); for (auto item : list) { fileDisk.seekg((item-1)*s_block.blockSize, ios::beg); fileDisk.write(bytes, 1024); fileDisk.flush();//写回文件 } return 1; } //初始化根dentry int FileSystem::init_root_dentry() { root_dentry = dentry(); root_dentry.inode = root; root_dentry.fileName = "/"; root_dentry.setParent(&root_dentry); curr_dentry = &root_dentry; vector<unsigned int> blocks_list; iNode p_node = root_dentry.inode; readBlockIds(p_node, blocks_list);//读取内容块列表 InitDentry(root_dentry); for (auto item : root_dentry.child_list){ InitDentry(*item); } return 1; } //读取对应iNode的内容块,不包含间接块 int FileSystem::readBlockIds(iNode inode, vector<unsigned int> &blocks_list) { unsigned int block_num = inode.i_blocks; //十个间接块 for (int i = 0; i < 10; i++){ if (inode.i_zone[i] == 0){ break; } blocks_list.push_back(inode.i_zone[i]); } //一次间接块 if (inode.i_zone[10] != 0){ int pos = (inode.i_zone[10] - 1)*s_block.blockSize; fileDisk.seekg(pos, ios::beg); int loop_times = ceil(s_block.blockSize / sizeof(unsigned int)); for (int i = 0; i < loop_times; i++){ unsigned int blcoks_num = 0; fileDisk.read((char*)&blcoks_num, sizeof(unsigned int)); if (blcoks_num>0){ blocks_list.push_back(blcoks_num); } } } //二次间接块 if (inode.i_zone[11] != 0){ int pos = (inode.i_zone[11] - 1)*s_block.blockSize; fileDisk.seekg(pos, ios::beg); int loop_times = ceil(s_block.blockSize / sizeof(unsigned int));//计算每块能放下的数目 vector<unsigned int> once_list; for (int i = 0; i < loop_times; i++){ unsigned int blcoks_num = 0; fileDisk.read((char*)&blcoks_num, sizeof(unsigned int)); if (blcoks_num>0){ once_list.push_back(blcoks_num);//存入中间缓存列表 } } for (auto item : once_list){ int pos = (item - 1)*s_block.blockSize; fileDisk.seekg(pos, ios::beg); for (int i = 0; i < loop_times; i++){ unsigned int blcoks_num = 0; fileDisk.read((char*)&blcoks_num, sizeof(unsigned int));//计算每块能放下的数目 if (blcoks_num>0){ blocks_list.push_back(blcoks_num);//读出最终的块号 } } } } //三次间接块 if (inode.i_zone[12] != 0){ int pos = (inode.i_zone[11] - 1)*s_block.blockSize; fileDisk.seekg(pos, ios::beg); int loop_times = ceil(s_block.blockSize / sizeof(unsigned int));//计算每块能放下的数目 vector<unsigned int> twice_list, once_list; for (int i = 0; i < loop_times; i++){ unsigned int blcoks_num = 0; fileDisk.read((char*)&blcoks_num, sizeof(unsigned int)); if (blcoks_num>0){ twice_list.push_back(blcoks_num);//存入二次中间缓存列表 } } for (auto item : twice_list){ int pos = (item - 1)*s_block.blockSize; fileDisk.seekg(pos, ios::beg); for (int i = 0; i < loop_times; i++){ unsigned int blcoks_num = 0; fileDisk.read((char*)&blcoks_num, sizeof(unsigned int)); if (blcoks_num>0){ once_list.push_back(blcoks_num);//放入一次缓存表 } } } for (auto item : once_list){ int pos = (item - 1)*s_block.blockSize; fileDisk.seekg(pos, ios::beg); for (int i = 0; i < loop_times; i++){ unsigned int blcoks_num = 0; fileDisk.read((char*)&blcoks_num, sizeof(unsigned int));//计算每块能放下的数目 if (blcoks_num>0){ blocks_list.push_back(blcoks_num);//读出最终的块号 } } } } return 1; } //修改文件权限,mode为10进制的数字 int FileSystem::chmod(string name, int mode){ dentry * temp_dentry; int ret = findDentryWithName(name, temp_dentry); if (ret <= 0){ return ret; } //检查权限 if (!checkAccess(WRITE_ACCESS, temp_dentry->inode)){ cout << "Access Deny" << endl; return ACCESS_DENY; } if (mode <= 0 || mode > 1000){ return -1;//mode无效 } int idx_3 = (mode % 1000) / 100; int idx_2 = (mode % 100) / 10; int idx_1 = mode % 10; if (idx_1 > 7 || idx_2 > 7 || idx_3 > 7){ return -1;//mode无效 } if (temp_dentry->is_dir()){ unsigned short t_mode = 1; t_mode = t_mode << 14; temp_dentry->inode.i_mode = t_mode + (idx_3 << 8) + (idx_2 << 4) + idx_1;//设定为文件夹权限 } else{ temp_dentry->inode.i_mode = (idx_3 << 8) + (idx_2 << 4) + idx_1;//设定为文件权限 } return 1; } //登录认证操作,登录失败返回-1,否则返回对应用户的内存下标 int FileSystem::auth(string username, string pwd) { if (username.length() > 16 || pwd.length() > 32){ //当用户名或密码长度超过最大限制的时候,应该在shell处限制 } char usr_name[17] = { 0 }; char usr_pwd[33] = { 0 }; strcpy_s(usr_name, 16, username.c_str());//复制用户名 strcpy_s(usr_pwd, 16, pwd.c_str());//复制密码 for (int i = 0; i < userLists.size(); i++){ User user = userLists[i]; if (user.auth(usr_name, usr_pwd)){ return i; } } return -1; } //复制文件,可从本机或模拟磁盘中复制 int FileSystem::copy(string from, string to){ string host_cmd = "<host>"; if (from.compare(0, host_cmd.size(), host_cmd)==0){ //以<host>开头的指令 from = from.substr(host_cmd.size()); fstream file_from(from, ios::binary | ios::in | ios::out); if (!file_from){ //文件不存在 return 0; } else{ file_from.seekg(0,ios::end); unsigned long size = file_from.tellg();//文件大小,Byte file_from.seekg(0, ios::beg); if (size > s_block.maxBytes){ file_from.close(); return -2;//超过最大文件大小 } int ret = newfile(to,size); if (ret <0){ file_from.close(); return ret;//申请失败 } iNode des_node; read_inode(ret,des_node);//读取要存放的iNode vector<unsigned int> block_list; readBlockIds(des_node, block_list);//获取写入的块 //声明读取和暂存的块变量并进行初始化 char * content = new char[s_block.blockSize]; memset(content, 0, s_block.blockSize); for (auto block_id : block_list){ unsigned long pos = (block_id - 1)*s_block.blockSize; fileDisk.seekg(pos,ios::beg); file_from.read((char *)content, s_block.blockSize); int real_size = file_from.gcount(); fileDisk.write((char *)content, real_size); } file_from.close(); } } else if (to.compare(0, host_cmd.size(), host_cmd) == 0){ //从模拟系统中复制到本机 to = to.substr(host_cmd.size()); fstream file_to(to, ios::binary | ios::out); dentry *fromDentry; int ret = findDentryWithName(from, fromDentry, FILE_TYPE); if (ret == 0){ //未找到文件 return 0; } //权限检查 if (!checkAccess(READ_ACCESS, fromDentry->inode)){ //无权限 cout << "Access Deny" << endl; return ACCESS_DENY; } //获取读取的内容 vector<unsigned int> read_list; readBlockIds(fromDentry->inode, read_list); //初始化内容块 char * content = new char[s_block.blockSize]; memset(content, 0, s_block.blockSize); //获得文件大小 unsigned long size = fromDentry->inode.i_size; int read_size = 0; for (int i = 0; i < read_list.size(); i++){ //计算一次读取的大小 if (size > s_block.blockSize){ read_size = s_block.blockSize; size -= s_block.blockSize; } else{ read_size = size; size = 0; } unsigned long read_pos = (read_list[i] - 1)*s_block.blockSize; fileDisk.seekg(read_pos, ios::beg); fileDisk.read((char *)content, read_size); file_to.write((char *)content, read_size); } file_to.close(); }else{ //从模拟系统中复制到模拟系统 dentry *fromDentry, *toDentry; int ret = findDentryWithName(from, fromDentry, FILE_TYPE); if (ret == 0){ //未找到文件 return 0; } //判断是否有读权限 if (!checkAccess(READ_ACCESS, fromDentry->inode)){ cout << "Access Deny" << endl; return ACCESS_DENY; } ret = newfile(to, fromDentry->inode.i_size); if (ret < 0){ //iNode数目不足或block数目不足 return ret; } findDentryWithName(to, toDentry, FILE_TYPE); //获取读写的block vector<unsigned int> read_list, write_list; readBlockIds(fromDentry->inode, read_list); readBlockIds(toDentry->inode, write_list); //初始化内容块 char * content = new char[s_block.blockSize]; memset(content, 0, s_block.blockSize); //获得文件大小 unsigned long size = fromDentry->inode.i_size; int read_size = 0; for (int i = 0; i < write_list.size(); i++){ //计算一次读取的大小 if (size > s_block.blockSize){ read_size = s_block.blockSize; size -= s_block.blockSize; } else{ read_size = size; size = 0; } unsigned long read_pos = (read_list[i] - 1)*s_block.blockSize; unsigned long write_pos = (write_list[i] - 1)*s_block.blockSize; fileDisk.seekg(read_pos, ios::beg); fileDisk.read((char *)content, read_size); fileDisk.seekg(write_pos, ios::beg); fileDisk.write((char *)content, read_size); } } return 1; } //创建文件夹,返回值为iNode的id int FileSystem::newfile(string filename,unsigned long size) { vector<string> dir_list; SplitString(filename, dir_list, "/"); dentry *temp_dentry;//暂存的变量 string file_name = ""; //获取创建的文件名字 file_name = dir_list[dir_list.size() - 1]; if (file_name.length() <= 0){ return -2;//文件名长度不合法 } int ret = findDentry(dir_list, temp_dentry, filename[0],FILE_TYPE);//用于判断是否存在 //去掉文件夹名字后的目录字符串 dir_list.resize(dir_list.size() - 1); int ret2 = findDentry(dir_list, temp_dentry, filename[0]);//用于寻找父文件夹 if (ret2 == 0){ return 0; } //判断是否有写权限 if (!checkAccess(WRITE_ACCESS, temp_dentry->inode)){ cout << "Access Deny" << endl; return ACCESS_DENY; } if (ret == FILE_TYPE || ret == FOLDER_TYPE){ //存在文件或文件夹同名 return -1; } iNode file_node; ret = alloc_inode(size, file_node); if (ret == -1){ return -3; } dir s_dir(file_name, file_node.ino);//生成file dentry *created_dentry = new dentry(s_dir.dir_name, file_node);//生成dentry项 created_dentry->setParent(temp_dentry); temp_dentry->addChild(created_dentry);//加入父目录的子项 SaveDentry(*temp_dentry); return file_node.ino; } //创建目录 int FileSystem::mkdir(string filename) { vector<string> dir_list; SplitString(filename,dir_list,"/"); dentry *temp_dentry;//暂存的变量 string folder_name = ""; //获取创建的文件夹名字 folder_name = dir_list[dir_list.size() - 1]; if (folder_name.length() <= 0){ return -2;//文件名长度不合法 } int ret = findDentry(dir_list, temp_dentry, filename[0]);//用于判断是否存在 //去掉文件夹名字后的目录字符串 dir_list.resize(dir_list.size() - 1); int ret2 = findDentry(dir_list, temp_dentry,filename[0]);//用于寻找父文件夹 if (ret2 == 0){ return 0; } //判断是否有写权限 if (!checkAccess(WRITE_ACCESS, temp_dentry->inode)){ cout << "Access Deny" << endl; return ACCESS_DENY; } if (ret == FILE_TYPE || ret == FOLDER_TYPE){ //存在文件夹或文件同名 return -1; } iNode dir_node; ret = alloc_inode(0, dir_node, true); if (ret == -1){//申请失败 return -3; } dir s_dir(folder_name, dir_node.ino);//生成dir dentry *created_dentry = new dentry(s_dir.dir_name, dir_node);//生成dentry项 created_dentry->setParent(temp_dentry); temp_dentry->addChild(created_dentry);//加入父目录的子项 SaveDentry(*temp_dentry); return 1; } //切换目录 int FileSystem::cd(string filename){ dentry *temp; int ret = findDentryWithName(filename, temp); //判断是否有执行权限 if (!checkAccess(EXEC_ACCESS, temp->inode)){ //无权限 cout << "Access Deny" << endl; return ACCESS_DENY; } if (ret == 1){ curr_dentry = temp; } return ret; } //删除目录,返回1表示成功,返回2表示目录不为空,需要确认 int FileSystem::rd(string filename,bool force) { vector<string> dir_list; SplitString(filename, dir_list, "/"); dentry *temp_dentry;//暂存的变量 string folder_name = ""; //获取创建的文件夹名字 folder_name = dir_list[dir_list.size() - 1]; int ret = findDentry(dir_list, temp_dentry, filename[0]);//判断是否存在 if (ret == 0){ //不存在文件 return 0; } else if (ret == 2){ //是文件类型 return 2; } else if (ret == 1){ //判断是否有写权限 if (!checkAccess(WRITE_ACCESS, temp_dentry->inode)){ //无权限 cout << "Access Deny" << endl; return ACCESS_DENY; } //文件夹格式 if (temp_dentry->inode.i_size == 0){ //空目录 dentry *p_dentry = temp_dentry->parent; withdraw_node(temp_dentry->inode);//收回iNode节点 p_dentry->removeChild(temp_dentry);//移除内存内的项 SaveDentry(*(temp_dentry->parent));//保存父目录的信息修改 delete temp_dentry; } else{ if (force){ //非空且强制删除 vector<dentry*> temp = temp_dentry->child_list;//中间缓存,因为删除操作会修改temp_dentry的内容 for (auto item : temp){ if (item->is_dir()){ //强制删除子目录 rd(item->getPathName(), force); } else{ //删除文件 del(item->getPathName()); } } dentry *p_dentry = temp_dentry->parent; withdraw_node(temp_dentry->inode);//收回iNode节点 p_dentry->removeChild(temp_dentry);//移除内存内的项 SaveDentry(*(temp_dentry->parent));//保存父目录的信息修改 return 1; } return 3; } } return 1; } //删除文件 int FileSystem::del(string filename){ vector<string> dir_list; SplitString(filename, dir_list, "/"); dentry *temp_dentry;//暂存的变量 string folder_name = ""; //获取创建的文件夹名字 folder_name = dir_list[dir_list.size() - 1]; int ret = findDentry(dir_list, temp_dentry, filename[0],FILE_TYPE);//判断是否存在 if (ret == 0){ //不存在文件 return 0; } else if (ret == 2){ //是文件类型 //判断是否有写权限 if (!checkAccess(WRITE_ACCESS, temp_dentry->inode)){ //无权限 cout << "Access Deny" << endl; return ACCESS_DENY; } withdraw_node(temp_dentry->inode);//收回iNode节点 temp_dentry->parent->removeChild(temp_dentry);//移除内存内的项 SaveDentry(*temp_dentry->parent);//保存父目录的信息修改 delete temp_dentry; } else if (ret == 1){ //文件夹格式 return -1; } return 1; } //读取文件 int FileSystem::cat(string filename){ dentry *temp; int ret = findDentryWithName(filename, temp, FILE_TYPE); if (ret == 0||ret==1){ return ret; } //判断是否有读权限 if (!checkAccess(READ_ACCESS, temp->inode)){ //无权限 cout << "Access Deny" << endl; return ACCESS_DENY; } readBlockIds(temp->inode, temp->block_list);//读取block char *content = new char[s_block.blockSize]; memset(content, 0, s_block.blockSize); unsigned long size = temp->inode.i_size; int read_size = 0; for (auto block_id : temp->block_list){ if (size > s_block.blockSize){ read_size = s_block.blockSize; size -= s_block.blockSize; } else{ read_size = size; size = 0; } unsigned long pos = (block_id - 1)*s_block.blockSize; fileDisk.seekg(pos, ios::beg); fileDisk.read((char *)content, read_size); int real_size = fileDisk.gcount(); string t(content, content + read_size); cout << t; } return FILE_TYPE; } //展示目录 int FileSystem::ls(string filename){ dentry *temp; if (filename == ""){ curr_dentry->showDentry(this->getUsers()); } else{ int ret = findDentryWithName(filename, temp); if (ret == 0 || ret == 2){ return ret; } temp->showDentry(this->getUsers()); } return 1; } //获取用户列表 vector<string> FileSystem::getUsers() { vector<string> users; for (auto user : userLists){ users.push_back(user.username); } return users; } //通过名字寻找目录项,返回1表示找到文件夹,返回2表示找到文件,0表示未找到,type为1找文件夹,type为2找文件 int FileSystem::findDentryWithName(string name, dentry *&p_dentry, int type) { int ret = 0; vector<string> dir_list; SplitString(name, dir_list, "/"); ret = findDentry(dir_list, p_dentry, name[0], type); return ret; } //通过路径vector寻找目录项,返回1表示找到文件夹,返回2表示找到文件,0表示未找到,type为1找文件夹,type为2找文件 int FileSystem::findDentry(vector<string> list,dentry *&p_dentry,char firstChar,int type) { int ret = 0; p_dentry = curr_dentry; if (firstChar == '/'){ p_dentry = &root_dentry;//从根目录开始 list.erase(list.begin());//若第一个字符是/则split后第一位为空 } if (list.size() == 0){ return 1;//直接当前目录下创建 } for (auto item : list){ ret = 0; if (item == ".."){//父层目录 p_dentry = p_dentry->parent; ret = 1; } else if (item == "."){//当前目录 ret = 1; } else{//遍历寻找目录 for (auto child_dentry : p_dentry->child_list){ if (child_dentry->fileName == item){ //如果名字对上了,还要判断文件类型 if (child_dentry->is_dir()){ p_dentry = child_dentry; if (p_dentry->child_list.size() == 0){ InitDentry(*p_dentry);//初始化自身及子目录 } for (auto item : p_dentry->child_list){ InitDentry(*item); } ret = FOLDER_TYPE;//找到了文件夹 if (item == list[list.size() - 1]){ break;//找到了字符串路径末尾,直接退出 } } else{ p_dentry = child_dentry; ret = FILE_TYPE;//找到了文件夹 //若是路径上的最后一个,则看是不是寻找的文件 if (item == list[list.size() - 1]){ break;//找到了字符串路径末尾,直接退出 } } } } } if (ret == 0){ return ret; } } return ret; } //初始化dentry int FileSystem::InitDentry(dentry & p_dentry){ if (p_dentry.child_list.size() == 0){ readBlockIds(p_dentry.inode, p_dentry.block_list);//保存block_list int dir_num_per_block = s_block.blockSize / sizeof(dir);//每一个块能存放的dir数目 int count = 0, max_dir = floor(p_dentry.inode.i_size / sizeof(dir)); dir t_dir; for (auto b_idx : p_dentry.block_list){ if (count == max_dir){ break; } int base_pos = (b_idx - 1)*s_block.blockSize;//基础偏移地址 for (int i = 0; i < dir_num_per_block&&count<max_dir; i++){ seekAndGet<dir>(base_pos + i*sizeof(dir), t_dir); if (t_dir.ino>0 && t_dir.ino <= s_block.inode_num){ dentry* t_dentry = new dentry(); read_inode(t_dir.ino, t_dentry->inode);//读取iNode t_dentry->fileName = t_dir.dir_name; t_dentry->setParent(&p_dentry); p_dentry.addChild(t_dentry); count++; if (count == max_dir){ break; } } } } } return 1; } //保存dentry int FileSystem::SaveDentry(dentry & p_dentry){ write_inode(p_dentry.inode);//保存iNode int dir_num_per_block = s_block.blockSize / sizeof(dir);//每一个块能存放的dir数目 vector<dir> save_list = p_dentry.getDirList(); int count = 0, max_dir = save_list.size(); for (auto b_idx : p_dentry.block_list){ if (count == max_dir){ break; } int base_pos = (b_idx - 1)*s_block.blockSize;//基础偏移地址 for (int i = 0; i < dir_num_per_block && count<max_dir; i++){ seekAndSave<dir>(base_pos + i*sizeof(dir), save_list[count]); count++; } } return 1; } //读取iNode节点 int FileSystem::read_inode(int ino, iNode &node){ unsigned long pos = s_block.inode_table + (ino-1)*sizeof(iNode); seekAndGet<iNode>(pos, node); return 1; }
[ "791863347@qq.com" ]
791863347@qq.com
96d5aa7bc16d9fb06b10a016ab206d07a444422d
ae793fb81a9b0214b77e01ce8405b688bb370360
/Final LunarDrift/LunarDrift/LunarDrift/game/scenes/game/environment/Mars.h
596bed74c6e84dba5a9a723dcbe408ba04326c93
[]
no_license
venfabio/Lunar-Drift
f2175acfcbe6d55e0055cdd3c9d89283ec082390
ab27817225e92ba505a67206b9f154eef456a8e9
refs/heads/master
2020-08-30T22:41:02.542636
2019-10-30T11:03:25
2019-10-30T11:03:25
218,507,356
0
0
null
null
null
null
UTF-8
C++
false
false
1,231
h
#pragma once #include "../../../../engine/containers/SceneObject.h" #include "../../../../engine/containers/Model.h" #include "../../../../engine/graphics/Texture.h" /** * @brief Spinning textured Mars model, for scene decoration * * @author Fabio * @date 26/05/2016 * @ingroup Game */ class Mars : public SceneObject { public: /** @brief Default constructor */ Mars( Context* context, std::weak_ptr<MetaManager> managers, const glm::vec3& position); /** @brief Default destructor */ ~Mars(); /** * @brief Step the simulation state * @param dt Delta-time since last step call in seconds */ void step(double dt) override; /** * @brief Called before the renderer draws the scene * * This allows the scene objects to do updates that require a * graphics context before the graphical state is drawn * @param context Graphics context */ void predraw(Context* context) override; /** * @brief Draw the object in its current state * @param context Graphics context * @param shaders Shader manager containing shader programs for use */ void draw(Context* context, std::shared_ptr<ShaderManager> shaders) override; private: std::shared_ptr<Model> m_Model; std::unique_ptr<Texture> m_Texture; };
[ "venuti@illogic.xyz" ]
venuti@illogic.xyz
5e4fc3eb1f4e3b054af847ea3f98ad32ab125938
fe184188fbc43685c99c2464fc3fbe785069e7f2
/include/OwDevices.h
8686c7b73b314b213392eb93bfdbfac73b2c8722
[ "MIT" ]
permissive
RaulKatos/HomeCtrlWdt
26f27483b0ebd0107b65b7deeb0c2cbd98a37d02
67d9708ff7e65df8aa939861cca600ba79846bdb
refs/heads/master
2023-01-31T09:41:25.494232
2020-11-21T06:39:04
2020-11-21T06:39:04
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,542
h
#ifndef _OWDEVICES_H #define _OWDEVICES_H #include <OneWireBase.h> #define MAX_BUS 4 #define MAX_SWITCHES 2 * 8 #define MAX_CFG_SIZE 26 union s_adr { uint8_t data; struct { // pio/latch number 0..7 unsigned int latch : 3; unsigned int adr : 5; } sa; }; union d_adr { uint8_t data; struct { unsigned int pio : 1; unsigned int adr : 4; unsigned int type : 1; unsigned int bus : 2; } da; }; class OwDevices { private: public: OwDevices() {;} void begin(OneWireBase *ds); void end() { ; }; void loop(); void adrGen(OneWireBase *ds, byte bus, byte adr[8], uint8_t id); uint8_t ds2408LatchReset(OneWireBase *ds, uint8_t* addr); uint8_t ds2408RegRead(OneWireBase *ds, byte bus, uint8_t* addr, uint8_t* data, bool latch_reset = true); void ds2408Status(OneWireBase *ds, byte bus, byte adr[8], bool latch_reset = true); void toggleDs2413(OneWireBase *ds, byte bus, uint8_t* addr); void ds2408Data(OneWireBase *ds, byte bus, byte adr[8], uint8_t len); uint8_t ds2408PioSet(OneWireBase *ds, byte bus, uint8_t* addr, uint8_t pio); uint8_t ds2408TogglePio(OneWireBase *ds, byte bus, uint8_t* addr, uint8_t pio, uint8_t* data = NULL); void ds2408CfgWrite(OneWireBase *ds, byte bus, byte adr[8], uint8_t* d, uint8_t len); int ds2408CfgRead(OneWireBase *ds, byte bus, byte adr[8], uint8_t* data); float tempRead(OneWireBase *ds, byte busNr, byte addr[8]); void statusPrint(OneWireBase *ds, byte adr[8]); void statusRead(OneWireBase *ds); void search(OneWireBase *ds, byte bus); }; #endif
[ "INgo.Rah@intel.com" ]
INgo.Rah@intel.com
f538a9e2c83ae591417074484d4cfc51a88a9440
91a882547e393d4c4946a6c2c99186b5f72122dd
/Source/XPSP1/NT/inetsrv/iis/svcs/cmp/aspcmp/browser/context.cpp
6726b17c44b55e5931593fb03bbd78851a6a7cc1
[]
no_license
IAmAnubhavSaini/cryptoAlgorithm-nt5src
94f9b46f101b983954ac6e453d0cf8d02aa76fc7
d9e1cdeec650b9d6d3ce63f9f0abe50dabfaf9e2
refs/heads/master
2023-09-02T10:14:14.795579
2021-11-20T13:47:06
2021-11-20T13:47:06
null
0
0
null
null
null
null
UTF-8
C++
false
false
58
cpp
#include "stdafx.h" #include "..\shared\src\context.cpp"
[ "support@cryptoalgo.cf" ]
support@cryptoalgo.cf
e189983c40d2ff1d078a9f217cdb568a9daad8b9
62869fe5152bbe07fbe9f0b61166be32e4f5016c
/3rdparty/CGAL/include/CGAL/Polyhedral_mesh_domain_3.h
988f9d9528f070f1f7c1c36b33f9a4de81337d24
[ "MIT", "LicenseRef-scancode-warranty-disclaimer", "LGPL-3.0-or-later", "LGPL-2.0-or-later", "GPL-1.0-or-later", "LicenseRef-scancode-commercial-license" ]
permissive
daergoth/SubdivisionSandbox
aef65eab0e1ab3dfecb2f9254c36d26c71ecd4fd
d67386980eb978a552e5a98ba1c4b25cf5a9a328
refs/heads/master
2020-03-30T09:19:07.121847
2019-01-08T16:42:53
2019-01-08T16:42:53
151,070,972
0
0
MIT
2018-12-03T11:10:03
2018-10-01T10:26:28
C++
UTF-8
C++
false
false
24,632
h
// Copyright (c) 2009 INRIA Sophia-Antipolis (France). // Copyright (c) 2011 GeometryFactory Sarl (France). // All rights reserved. // // This file is part of CGAL (www.cgal.org). // You can redistribute it and/or modify it under the terms of the GNU // General Public License as published by the Free Software Foundation, // either version 3 of the License, or (at your option) any later version. // // Licensees holding a valid commercial license may use this file in // accordance with the commercial license agreement provided with the software. // // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. // // $URL$ // $Id$ // // // Author(s) : Stéphane Tayeb // //****************************************************************************** // File Description : // //****************************************************************************** #ifndef CGAL_POLYHEDRAL_MESH_DOMAIN_3_H #define CGAL_POLYHEDRAL_MESH_DOMAIN_3_H #include <CGAL/license/Mesh_3.h> #include <CGAL/Polygon_mesh_processing/internal/Side_of_triangle_mesh/Point_inside_vertical_ray_cast.h> #include <CGAL/Mesh_3/global_parameters.h> #include <CGAL/Mesh_3/Robust_intersection_traits_3.h> #include <CGAL/Mesh_3/Triangle_accessor_primitive.h> #include <CGAL/Triangle_accessor_3.h> #include <CGAL/AABB_tree.h> #include <CGAL/AABB_traits.h> #include <sstream> #include <CGAL/Random.h> #include <CGAL/point_generators_3.h> #include <CGAL/Mesh_3/Creator_weighted_point_3.h> #include <CGAL/Mesh_3/Profile_counter.h> #include <boost/optional.hpp> #include <boost/none.hpp> #include <boost/utility/enable_if.hpp> #include <boost/mpl/vector.hpp> #include <boost/mpl/contains.hpp> #include <CGAL/tuple.h> #include <boost/format.hpp> #include <boost/variant.hpp> #include <boost/math/special_functions/round.hpp> #ifdef CGAL_LINKED_WITH_TBB # include <tbb/enumerable_thread_specific.h> #endif // To handle I/O for Surface_patch_index if that is a pair of `int` (the // default) #include <CGAL/internal/Mesh_3/Handle_IO_for_pair_of_int.h> namespace CGAL { namespace Mesh_3 { namespace details { inline double max_length(const Bbox_3& b) { return (std::max)(b.xmax()-b.xmin(), (std::max)(b.ymax()-b.ymin(),b.zmax()-b.zmin()) ); } // ----------------------------------- // Surface_patch_index_generator // To use patch_id enclosed in AABB_primitives or not // ----------------------------------- template < typename Subdomain_index, typename Polyhedron, typename Tag > struct Surface_patch_index_generator { typedef std::pair<Subdomain_index,Subdomain_index> Surface_patch_index; typedef Surface_patch_index type; template < typename Primitive_id > Surface_patch_index operator()(const Primitive_id&) { return Surface_patch_index(0,1); } }; template < typename Subdomain_index, typename Polyhedron > struct Surface_patch_index_generator<Subdomain_index, Polyhedron, CGAL::Tag_true> { typedef typename Polyhedron::Face::Patch_id Surface_patch_index; typedef Surface_patch_index type; template < typename Primitive_id > Surface_patch_index operator()(const Primitive_id& primitive_id) { return primitive_id->patch_id(); } }; // ----------------------------------- // Index_generator // Don't use boost::variant if types are the same type // ----------------------------------- template < typename Subdomain_index, typename Surface_patch_index > struct Index_generator { typedef boost::variant<Subdomain_index,Surface_patch_index> Index; typedef Index type; }; template < typename T > struct Index_generator<T, T> { typedef T Index; typedef Index type; }; // ----------------------------------- // Geometric traits generator // ----------------------------------- template < typename Gt, typename Use_exact_intersection_construction_tag > struct IGT_generator {}; template < typename Gt > struct IGT_generator<Gt,CGAL::Tag_true> { #ifdef CGAL_MESH_3_NEW_ROBUST_INTERSECTION_TRAITS typedef CGAL::Mesh_3::Robust_intersection_traits_3_new<Gt> type; #else // NOT CGAL_MESH_3_NEW_ROBUST_INTERSECTION_TRAITS typedef CGAL::Mesh_3::Robust_intersection_traits_3<Gt> type; #endif // NOT CGAL_MESH_3_NEW_ROBUST_INTERSECTION_TRAITS typedef type Type; }; template < typename Gt > struct IGT_generator<Gt,CGAL::Tag_false> { typedef Gt type; typedef type Type; }; } // end namespace details } // end namespace Mesh_3 /** * @class Polyhedral_mesh_domain_3 * * */ template<class Polyhedron, class IGT_, class TriangleAccessor=Triangle_accessor_3<Polyhedron,IGT_>, class Use_patch_id_tag=Tag_false, class Use_exact_intersection_construction_tag = CGAL::Tag_true> class Polyhedral_mesh_domain_3 { typedef typename Mesh_3::details::IGT_generator< IGT_,Use_exact_intersection_construction_tag>::type IGT; public: /// Geometric object types typedef typename IGT::Point_3 Point_3; typedef typename IGT::Segment_3 Segment_3; typedef typename IGT::Ray_3 Ray_3; typedef typename IGT::Line_3 Line_3; typedef typename IGT::Vector_3 Vector_3; typedef typename IGT::Sphere_3 Sphere_3; //------------------------------------------------------- // Index Types //------------------------------------------------------- /// Type of indexes for cells of the input complex typedef int Subdomain_index; typedef boost::optional<Subdomain_index> Subdomain; /// Type of indexes for surface patch of the input complex typedef Mesh_3::details::Surface_patch_index_generator< Subdomain_index,Polyhedron,Use_patch_id_tag> Surface_patch_index_generator; typedef typename Surface_patch_index_generator::type Surface_patch_index; typedef boost::optional<Surface_patch_index> Surface_patch; /// Type of indexes to characterize the lowest dimensional face of the input /// complex on which a vertex lie typedef typename Mesh_3::details::Index_generator< Subdomain_index, Surface_patch_index>::type Index; typedef CGAL::cpp11::tuple<Point_3,Index,int> Intersection; typedef typename IGT::FT FT; // Kernel_traits compatibility typedef IGT R; public: typedef Mesh_3::Triangle_accessor_primitive< TriangleAccessor, IGT> AABB_primitive; typedef class AABB_traits<IGT,AABB_primitive> AABB_traits; typedef class AABB_tree<AABB_traits> AABB_tree_; typedef typename AABB_tree_::Primitive_id AABB_primitive_id; typedef typename AABB_tree_::Primitive Primitive; typedef typename AABB_traits::Bounding_box Bounding_box; public: /// Default constructor Polyhedral_mesh_domain_3(CGAL::Random* p_rng = NULL) : tree_() , bounding_tree_(&tree_) , p_rng_(p_rng) { } /** * @brief Constructor. Contruction from a polyhedral surface * @param polyhedron the polyhedron describing the polyhedral surface */ Polyhedral_mesh_domain_3(const Polyhedron& p, CGAL::Random* p_rng = NULL) : tree_() , bounding_tree_(&tree_) // the bounding tree is tree_ , p_rng_(p_rng) { this->add_primitives(p); if(!p.is_pure_triangle()) { std::cerr << "Your input polyhedron must be triangulated!\n"; CGAL_error_msg("Your input polyhedron must be triangulated!"); } this->build(); } Polyhedral_mesh_domain_3(const Polyhedron& p, const Polyhedron& bounding_polyhedron, CGAL::Random* p_rng = NULL) : tree_() , bounding_tree_(new AABB_tree_) , p_rng_(p_rng) { this->add_primitives(p); this->add_primitives(bounding_polyhedron); this->add_primitives_to_bounding_tree(bounding_polyhedron); this->build(); } /** * Constructor. * * Constructor from a sequence of polyhedral surfaces, and a bounding * polyhedral surface. * * @param InputPolyhedraPtrIterator must an iterator of a sequence of * pointers to polyhedra * * @param bounding_polyhedron reference to the bounding surface */ template <typename InputPolyhedraPtrIterator> Polyhedral_mesh_domain_3(InputPolyhedraPtrIterator begin, InputPolyhedraPtrIterator end, const Polyhedron& bounding_polyhedron, CGAL::Random* p_rng = NULL) : p_rng_(p_rng) , delete_rng_(false) { if(begin != end) { for(; begin != end; ++begin) { this->add_primitives(**begin); } this->add_primitives(bounding_polyhedron); } this->add_primitives_to_bounding_tree(bounding_polyhedron); this->build(); } /** * Constructor. * * Constructor from a sequence of polyhedral surfaces, without bounding * surface. The domain will always answer false to "is_in_domain" * queries. * * @param InputPolyhedraPtrIterator must an iterator of a sequence of * pointers to polyhedra */ template <typename InputPolyhedraPtrIterator> Polyhedral_mesh_domain_3(InputPolyhedraPtrIterator begin, InputPolyhedraPtrIterator end, CGAL::Random* p_rng = NULL) : p_rng_(p_rng) { if(begin != end) { for(; begin != end; ++begin) { this->add_primitives(**begin); } tree_.build(); } bounding_tree_ = 0; } /// Destructor ~Polyhedral_mesh_domain_3() { if(bounding_tree_ != 0 && bounding_tree_ != &tree_) { delete bounding_tree_; } } void set_surface_only() { bounding_tree_ = 0; } /** * Constructs a set of \ccc{n} points on the surface, and output them to * the output iterator \ccc{pts} whose value type is required to be * \ccc{std::pair<Points_3, Index>}. */ struct Construct_initial_points { Construct_initial_points(const Polyhedral_mesh_domain_3& domain) : r_domain_(domain) {} template<class OutputIterator> OutputIterator operator()(OutputIterator pts, const int n = 8) const; private: const Polyhedral_mesh_domain_3& r_domain_; }; Construct_initial_points construct_initial_points_object() const { return Construct_initial_points(*this); } /** * Returns a bounding box of the domain */ Bbox_3 bbox() const { return tree_.bbox(); } /** * Returns true if point~\ccc{p} is in the domain. If \ccc{p} is in the * domain, the parameter index is set to the index of the subdomain * including $p$. It is set to the default value otherwise. */ struct Is_in_domain { Is_in_domain(const Polyhedral_mesh_domain_3& domain) : r_domain_(domain) {} Subdomain operator()(const Point_3& p) const; private: const Polyhedral_mesh_domain_3& r_domain_; }; Is_in_domain is_in_domain_object() const { return Is_in_domain(*this); } Point_3 project_on_surface(const Point_3& p) const { return tree_.closest_point(p); } /// Allowed query types typedef boost::mpl::vector<Segment_3, Ray_3, Line_3> Allowed_query_types; /** * Returns true is the element \ccc{type} intersect properly any of the * surface patches describing the either the domain boundary or some * subdomain boundary. * \ccc{Type} is either \ccc{Segment_3}, \ccc{Ray_3} or \ccc{Line_3}. * Parameter index is set to the index of the intersected surface patch * if \ccc{true} is returned and to the default \ccc{Surface_patch_index} * value otherwise. */ struct Do_intersect_surface { Do_intersect_surface(const Polyhedral_mesh_domain_3& domain) : r_domain_(domain) {} template <typename Query> typename boost::enable_if<typename boost::mpl::contains<Allowed_query_types, Query>::type, Surface_patch>::type operator()(const Query& q) const { CGAL_MESH_3_PROFILER(std::string("Mesh_3 profiler: ") + std::string(CGAL_PRETTY_FUNCTION)); boost::optional<AABB_primitive_id> primitive_id = r_domain_.tree_.any_intersected_primitive(q); if ( primitive_id ) { r_domain_.cache_primitive(q, *primitive_id); return Surface_patch(r_domain_.make_surface_index(*primitive_id)); } else { return Surface_patch(); } } private: const Polyhedral_mesh_domain_3& r_domain_; }; Do_intersect_surface do_intersect_surface_object() const { return Do_intersect_surface(*this); } /** * Returns a point in the intersection of the primitive \ccc{type} * with some boundary surface. * \ccc{Type1} is either \ccc{Segment_3}, \ccc{Ray_3} or \ccc{Line_3}. * The integer \ccc{dimension} is set to the dimension of the lowest * dimensional face in the input complex containing the returned point, and * \ccc{index} is set to the index to be stored at a mesh vertex lying * on this face. */ struct Construct_intersection { Construct_intersection(const Polyhedral_mesh_domain_3& domain) : r_domain_(domain) {} template <typename Query> typename boost::enable_if<typename boost::mpl::contains<Allowed_query_types, Query>::type, Intersection>::type operator()(const Query& q) const { CGAL_MESH_3_PROFILER(std::string("Mesh_3 profiler: ") + std::string(CGAL_PRETTY_FUNCTION)); typedef typename AABB_tree_::template Intersection_and_primitive_id<Query>::Type Intersection_and_primitive_id; typedef boost::optional<Intersection_and_primitive_id> AABB_intersection; typedef Point_3 Bare_point; AABB_intersection intersection; #ifndef CGAL_MESH_3_NO_LONGER_CALLS_DO_INTERSECT_3 if(r_domain_.query_is_cached(q)) { const AABB_primitive_id primitive_id = r_domain_.cached_primitive_id(); typename cpp11::result_of< typename IGT::Intersect_3(typename Primitive::Datum, Query)>::type o = IGT().intersect_3_object()(Primitive(primitive_id).datum(),q); intersection = o ? Intersection_and_primitive_id(*o, primitive_id) : AABB_intersection(); } else #endif // not CGAL_MESH_3_NO_LONGER_CALLS_DO_INTERSECT_3 { #ifndef CGAL_MESH_3_NO_LONGER_CALLS_DO_INTERSECT_3 CGAL_precondition(r_domain_.do_intersect_surface_object()(q) != boost::none); #endif // NOT CGAL_MESH_3_NO_LONGER_CALLS_DO_INTERSECT_3 intersection = r_domain_.tree_.any_intersection(q); } if ( intersection ) { // Get primitive AABB_primitive_id primitive_id = intersection->second; // intersection may be either a point or a segment #if CGAL_INTERSECTION_VERSION > 1 if ( const Bare_point* p_intersect_pt = boost::get<Bare_point>( &(intersection->first) ) ) #else if ( const Bare_point* p_intersect_pt = object_cast<Bare_point>( &(intersection->first) ) ) #endif { return Intersection(*p_intersect_pt, r_domain_.index_from_surface_patch_index( r_domain_.make_surface_index(primitive_id)), 2); } #if CGAL_INTERSECTION_VERSION > 1 else if ( const Segment_3* p_intersect_seg = boost::get<Segment_3>(&(intersection->first))) #else else if ( const Segment_3* p_intersect_seg = object_cast<Segment_3>(&(intersection->first))) #endif { CGAL_MESH_3_PROFILER("Mesh_3 profiler: Intersection is a segment"); return Intersection(p_intersect_seg->source(), r_domain_.index_from_surface_patch_index( r_domain_.make_surface_index(primitive_id)), 2); } else { #ifndef CGAL_MESH_3_NO_LONGER_CALLS_DO_INTERSECT_3 std::stringstream stream; stream.precision(17); set_pretty_mode(stream); stream << "Mesh_3 error : AABB_tree any_intersection result is " "not a point nor a segment\n"; if(intersection->first.empty()) { stream << "The intersection is empty!"; } else { stream << "The intersection typeinfo name is "; stream << intersection->first.type().name(); } stream << "\nThe query was: "; stream << q << std::endl; stream << "The intersecting primitive in the AABB tree was: " << AABB_primitive(intersection->second).datum() << std::endl; CGAL_error_msg(stream.str().c_str()); #endif // not CGAL_MESH_3_NO_LONGER_CALLS_DO_INTERSECT_3 } } // Should not happen // unless CGAL_MESH_3_NO_LONGER_CALLS_DO_INTERSECT_3 is defined return Intersection(); } private: const Polyhedral_mesh_domain_3& r_domain_; }; Construct_intersection construct_intersection_object() const { return Construct_intersection(*this); } /** * Returns the index to be stored in a vertex lying on the surface identified * by \c index. */ Index index_from_surface_patch_index(const Surface_patch_index& index) const { return Index(index); } /** * Returns the index to be stored in a vertex lying in the subdomain * identified by \c index. */ Index index_from_subdomain_index(const Subdomain_index& index) const { return Index(index); } /** * Returns the \c Surface_patch_index of the surface patch * where lies a vertex with dimension 2 and index \c index. */ Surface_patch_index surface_patch_index(const Index& index) const { return boost::get<Surface_patch_index>(index); } /** * Returns the index of the subdomain containing a vertex * with dimension 3 and index \c index. */ Subdomain_index subdomain_index(const Index& index) const { return boost::get<Subdomain_index>(index); } // ----------------------------------- // Backward Compatibility // ----------------------------------- #ifndef CGAL_MESH_3_NO_DEPRECATED_SURFACE_INDEX typedef Surface_patch_index Surface_index; Index index_from_surface_index(const Surface_index& index) const { return index_from_surface_patch_index(index); } Surface_index surface_index(const Index& index) const { return surface_patch_index(index); } #endif // CGAL_MESH_3_NO_DEPRECATED_SURFACE_INDEX // ----------------------------------- // End backward Compatibility // ----------------------------------- public: Surface_patch_index make_surface_index( const AABB_primitive_id& primitive_id = AABB_primitive_id() ) const { Mesh_3::details::Surface_patch_index_generator<Subdomain_index, Polyhedron, Use_patch_id_tag> generator; return generator(primitive_id); } // Undocumented function, used to implement a sizing field that // computes lfs using this AABB tree. That avoids to rebuild the same // tree. typedef AABB_tree_ AABB_tree; const AABB_tree& aabb_tree() const { return tree_; } const AABB_tree* bounding_aabb_tree_ptr() const { return bounding_tree_; } protected: void add_primitives(const Polyhedron& p) { tree_.insert(TriangleAccessor().triangles_begin(p), TriangleAccessor().triangles_end(p)); } void add_primitives_to_bounding_tree(const Polyhedron& p) { if(bounding_tree_ == &tree_ || bounding_tree_ == 0) { bounding_tree_ = new AABB_tree_; } bounding_tree_->insert(TriangleAccessor().triangles_begin(p), TriangleAccessor().triangles_end(p)); } void build() { tree_.build(); if(bounding_tree_ != &tree_ && bounding_tree_ != 0) { bounding_tree_->build(); } } private: /// The AABB tree: intersection detection and more AABB_tree_ tree_; AABB_tree_* bounding_tree_; // cache queries and intersected primitive typedef typename boost::make_variant_over<Allowed_query_types>::type Cached_query; struct Query_cache { Query_cache() : has_cache(false) {} bool has_cache; Cached_query cached_query; AABB_primitive_id cached_primitive_id; }; #ifdef CGAL_LINKED_WITH_TBB mutable tbb::enumerable_thread_specific<Query_cache> query_cache; #else mutable Query_cache query_cache; #endif //random number generator for Construct_initial_points CGAL::Random* p_rng_; bool delete_rng_; public: template <typename Query> void cache_primitive(const Query& q, const AABB_primitive_id id) const { #ifdef CGAL_LINKED_WITH_TBB Query_cache &qc = query_cache.local(); qc.cached_query = Cached_query(q); qc.has_cache = true; qc.cached_primitive_id = id; #else query_cache.cached_query = Cached_query(q); query_cache.has_cache = true; query_cache.cached_primitive_id = id; #endif } template <typename Query> bool query_is_cached(const Query& q) const { #ifdef CGAL_LINKED_WITH_TBB Query_cache &qc = query_cache.local(); return qc.has_cache && (qc.cached_query == Cached_query(q)); #else return query_cache.has_cache && (query_cache.cached_query == Cached_query(q)); #endif } AABB_primitive_id cached_primitive_id() const { #ifdef CGAL_LINKED_WITH_TBB return query_cache.local().cached_primitive_id; #else return query_cache.cached_primitive_id; #endif } void set_random_generator(CGAL::Random* p_rng) { p_rng_ = p_rng; } private: // Disabled copy constructor & assignment operator typedef Polyhedral_mesh_domain_3 Self; Polyhedral_mesh_domain_3(const Self& src); Self& operator=(const Self& src); }; // end class Polyhedral_mesh_domain_3 template<typename P_, typename IGT_, typename TA, typename Tag, typename E_tag_> template<class OutputIterator> OutputIterator Polyhedral_mesh_domain_3<P_,IGT_,TA,Tag,E_tag_>:: Construct_initial_points::operator()(OutputIterator pts, const int n) const { typename IGT::Construct_ray_3 ray = IGT().construct_ray_3_object(); typename IGT::Construct_vector_3 vector = IGT().construct_vector_3_object(); const Bounding_box bbox = r_domain_.tree_.bbox(); const Point_3 center( FT( (bbox.xmin() + bbox.xmax()) / 2), FT( (bbox.ymin() + bbox.ymax()) / 2), FT( (bbox.zmin() + bbox.zmax()) / 2) ); CGAL::Random& rng = *(r_domain_.p_rng_ != 0 ? r_domain_.p_rng_ : new Random(0)); Random_points_on_sphere_3<Point_3> random_point(1., rng); int i = n; # ifdef CGAL_MESH_3_VERBOSE std::cerr << "construct initial points:" << std::endl; # endif // Point construction by ray shooting from the center of the enclosing bbox while ( i > 0 ) { const Ray_3 ray_shot = ray(center, vector(CGAL::ORIGIN,*random_point)); #ifdef CGAL_MESH_3_NO_LONGER_CALLS_DO_INTERSECT_3 Intersection intersection = r_domain_.construct_intersection_object()(ray_shot); if(CGAL::cpp0x::get<2>(intersection) != 0) { #else if(r_domain_.do_intersect_surface_object()(ray_shot)) { Intersection intersection = r_domain_.construct_intersection_object()(ray_shot); #endif *pts++ = std::make_pair(CGAL::cpp0x::get<0>(intersection), CGAL::cpp0x::get<1>(intersection)); --i; #ifdef CGAL_MESH_3_VERBOSE std::cerr << boost::format("\r \r" "%1%/%2% initial point(s) found...") % (n - i) % n; # endif } ++random_point; } #ifdef CGAL_MESH_3_VERBOSE std::cerr << std::endl; #endif if(r_domain_.p_rng_ == 0) delete &rng; return pts; } template<typename P_, typename IGT_, typename TA, typename Tag, typename E_tag_> typename Polyhedral_mesh_domain_3<P_,IGT_,TA,Tag,E_tag_>::Subdomain Polyhedral_mesh_domain_3<P_,IGT_,TA,Tag,E_tag_>:: Is_in_domain::operator()(const Point_3& p) const { if(r_domain_.bounding_tree_ == 0) return Subdomain(); internal::Point_inside_vertical_ray_cast<IGT_, AABB_tree_> inside_functor; Bounded_side side = inside_functor(p, *(r_domain_.bounding_tree_)); if(side == CGAL::ON_UNBOUNDED_SIDE) { return Subdomain(); } else { return Subdomain(Subdomain_index(1)); } // case ON_BOUNDARY && ON_BOUNDED_SIDE } } // end namespace CGAL #endif // POLYHEDRAL_MESH_TRAITS_3_H_
[ "bodonyiandi94@gmail.com" ]
bodonyiandi94@gmail.com
186a6ad83b906b9fa255c3cb83d6f73a53dece65
6146e33102797407ede06ce2daa56c28fdfa2812
/src/GafferArnold/ArnoldAtmosphere.cpp
2a2028516c54197a481a82096fdbf0479808c6bc
[ "BSD-3-Clause" ]
permissive
GafferHQ/gaffer
e1eb78ba8682bfbb7b17586d6e7b47988c3b7d64
59cab96598c59b90bee6d3fc1806492a5c03b4f1
refs/heads/main
2023-09-01T17:36:45.227956
2023-08-30T09:10:56
2023-08-30T09:10:56
9,043,124
707
144
BSD-3-Clause
2023-09-14T09:05:37
2013-03-27T00:04:53
Python
UTF-8
C++
false
false
2,464
cpp
////////////////////////////////////////////////////////////////////////// // // Copyright (c) 2018, John Haddon. 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 John Haddon nor the names of // any other contributors to this software 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 "GafferArnold/ArnoldAtmosphere.h" using namespace GafferArnold; GAFFER_NODE_DEFINE_TYPE( ArnoldAtmosphere ); ArnoldAtmosphere::ArnoldAtmosphere( const std::string &name ) : GlobalShader( name ) { } ArnoldAtmosphere::~ArnoldAtmosphere() { } bool ArnoldAtmosphere::affectsOptionName( const Gaffer::Plug *input ) const { return false; } void ArnoldAtmosphere::hashOptionName( const Gaffer::Context *context, IECore::MurmurHash &h ) const { // No need to hash anything, because our option name is constant } std::string ArnoldAtmosphere::computeOptionName( const Gaffer::Context *context ) const { return "ai:atmosphere"; }
[ "thehaddonyoof@gmail.com" ]
thehaddonyoof@gmail.com
c62799a45668efed4206acffefe5b97ea94d23a5
5601e1fe63915b6346501a57af2bd87ac18d138c
/dr.cpp
518a270ac827262f129a355cea9253dc9caa3c6f
[]
no_license
Kleshchev/Perceptrons
127e757160393c03f58aca74a31484aa6269af80
6952931108226833705ef825aafc0158362a0e6a
refs/heads/main
2023-07-16T02:28:07.767669
2021-08-20T07:59:35
2021-08-20T07:59:35
392,508,125
0
0
null
null
null
null
UTF-8
C++
false
false
7,891
cpp
#include <iostream> #include <math.h> #include <random> #include <time.h> #include <Windows.h> #include <fstream> #include <vector> #include <string> using std::cout; using std::endl; using std::ifstream; using std::ofstream; using std::string; using std::vector; vector<string> split(const string &str, const string &delim) // сплит строки в вектор { vector<string> tokens; size_t prev = 0, pos = 0; do { pos = str.find(delim, prev); if (pos == string::npos) pos = str.length(); string token = str.substr(prev, pos - prev); if (!token.empty()) tokens.push_back(token); prev = pos + delim.length(); } while (pos < str.length() && prev < str.length()); return tokens; } void ClearScreen() //очистка экрана { HANDLE hStdOut; CONSOLE_SCREEN_BUFFER_INFO csbi; DWORD count; DWORD cellCount; COORD homeCoords = {0, 0}; hStdOut = GetStdHandle(STD_OUTPUT_HANDLE); if (hStdOut == INVALID_HANDLE_VALUE) return; /* Get the number of cells in the current buffer */ if (!GetConsoleScreenBufferInfo(hStdOut, &csbi)) return; cellCount = csbi.dwSize.X * csbi.dwSize.Y; /* Fill the entire buffer with spaces */ if (!FillConsoleOutputCharacter( hStdOut, (TCHAR)' ', cellCount, homeCoords, &count)) return; /* Fill the entire buffer with the current colors and attributes */ if (!FillConsoleOutputAttribute( hStdOut, csbi.wAttributes, cellCount, homeCoords, &count)) return; /* Move the cursor home */ SetConsoleCursorPosition(hStdOut, homeCoords); } int data[4][2] = {{0, 0}, {0, 1}, {1, 0}, {1, 1}}; // входные данные int answers[4] = {1, 0, 0, 1}; //то, что нам необходимо получить float weights1[3]; //веса первого входа float weights2[3]; //веса второго входа float outputweights[3]; //веса внутреннего слоя int itcount = 100; //количество итераций до выхода по ошибке const float eta = 0.05; //скорость обучения const int MAX_RAND = 5; //максимальное значение случайного числа const int MIN_RAND = -5; //минимальное значение случайного числа const int speed = 20; //скорость отображения в косноли(время одной итерации) int Activation(float in) //функция для активации нейрона { if (in < 0) return 0; else return 1; } int main() { srand(time(0)); //сид рандома из времени ifstream iff("weights.txt"); if (iff.is_open()) //чтение весов из файла, если он есть { string line; int i = 0; while (getline(iff, line)) { vector<string> ss = split(line, " "); weights1[i] = stof(ss[0]); weights2[i] = stof(ss[1]); outputweights[i] = stof(ss[2]); i++; if (i > 2) break; } iff.close(); } else //иначе нахождение правильных весов { int epocha = 0; //количество итераций while (true) { for (int i = 0; i < 3; i++) //задание рандомных весов { weights1[i] = rand() % (MAX_RAND - MIN_RAND + 1) + MIN_RAND; weights2[i] = rand() % (MAX_RAND - MIN_RAND + 1) + MIN_RAND; outputweights[i] = rand() % (MAX_RAND - MIN_RAND + 1) + MIN_RAND; } int epochaerror = 0; //ошибка данного набора весов int hidden[3]; //активация скрытого слоя нейронов for (int i = 0; i < itcount; i++) { ClearScreen(); epochaerror = 0; for (int j = 0; j < 4; j++) { float answer = 0; for (int k = 0; k < 3; k++) { hidden[k] = Activation(data[j][0] * weights1[k] + data[j][1] * weights2[k]); //активация скрытого слоя } for (int k = 0; k < 3; k++) { answer += outputweights[k] * hidden[k]; } answer = Activation(answer); //вычисление значения функции float diff = answers[j] - answer; //разница между вычисленным и правильным epochaerror += abs(diff); //обновление суммы ошибок if (epochaerror != 0) //обновление весов по дельта правилу, мне кажется именно здесь ошибка, т.к. веса просто начинают расти по модулю не уменьшая конечную ошибку { for (int k = 0; k < 3; k++) { weights1[k] += eta * diff * data[j][0]; // weights2[k] += eta * diff * data[j][1]; //либо в скрытых, либо во входных нейронах нерправильная зависимость т.к в outputweights[k] += eta * diff * hidden[k]; //конечном итоге на выходе (0,1,1,1) вместо (0,1,1,0) и из-за вхожа (1,1) веса входного слоя просто растут по модулю, //не корректируя выход в правильную сторону } } cout << data[j][0] << " " << data[j][1] << "| " << answer << " > " << answers[j] << endl; } for (int j = 0; j < 3; j++) { cout << weights1[j] << " " << weights2[j] << " " << outputweights[j] << endl; } cout << epochaerror << " - " << epocha * itcount + i << " it" << endl; if (epochaerror == 0) break; Sleep(speed); } if (epochaerror == 0) break; epocha++; } ofstream out("weights.txt"); //запись правильных весов в файл if (out.is_open()) { for (int j = 0; j < 3; j++) { out << weights1[j] << " " << weights2[j] << " " << outputweights[j] << endl; } out.close(); } } //вычисление значения функции уже с правильными весами либо из файла, либо вычисленными при обучении int hidden[3]; for (int i = 0; i < 4; i++) { for (int j = 0; j < 3; j++) { hidden[j] = Activation(data[i][0] * weights1[j] + data[i][1] * weights2[j]); } float answer = 0; for (int j = 0; j < 3; j++) { answer += hidden[j] * outputweights[j]; } answer = Activation(answer); cout << data[i][0] << " " << data[i][1] << "| " << answer << " > " << answers[i] << endl; } system("pause"); }
[ "61725304+Kleshchev@users.noreply.github.com" ]
61725304+Kleshchev@users.noreply.github.com
4ec69579a3978dfe9eb96b39eb13dd2ce9b5e774
3b141c379debc63588586dbceb44442ccfba97eb
/9-Camera_Space/Camera.h
bea230504f574978b171aaa71b9e2691d01e954f
[]
no_license
FabrizioPerria/OpenGL
27fbca335e5b4efe660a93306450f0af2e13896a
a5686f096189290051d80ace9fdaf0394f9785ba
refs/heads/master
2020-12-24T18:32:04.622301
2016-05-24T14:35:36
2016-05-24T14:35:36
55,981,134
0
1
null
null
null
null
UTF-8
C++
false
false
664
h
//wrapper class to interact with the pipeline to handle a camera #include "glew.h" #include "math_3d.h" class Camera { public: Camera(); void setCameraPosition(Vector3f& pos); void changeCameraPosition(Vector3f& direction); void setCameraUpDirection(Vector3f& up); void setCameraTarget(Vector3f& tgt); void changeCameraTarget(Vector3f& tgt); Vector3f getCameraPosition(void) const; Vector3f getCameraUpDirection(void) const; Vector3f getCameraTarget(void) const; float getCameraSpeed(void); private: void update(); Vector3f _position; Vector3f _up; Vector3f _target; float speed; float _angleH; float _angleV; };
[ "fabrizio.perria@gmail.com" ]
fabrizio.perria@gmail.com
5bfbacce6f0b02747dc55c59f2c05157272cf58c
e6eb52b60930d8f65015c70453763af5bae225b2
/test/regression/list1.cpp
f50dfbc05aad6d108463bac58d685f0ea4c491a6
[ "LicenseRef-scancode-stlport-4.5" ]
permissive
OS2World/DEV-UTIL-OPENWATCOM-STLport
dee884c0b96b43a4986ef55c5a0b542022d7c496
bc77a13dff24091d8a4a72c4054bbc8954d52bef
refs/heads/master
2020-04-26T14:21:10.860234
2014-12-29T04:10:16
2014-12-29T04:10:20
null
0
0
null
null
null
null
UTF-8
C++
false
false
631
cpp
// STLport regression testsuite component. // To compile as a separate example, please #define MAIN. #include <iostream> #include <list> #ifdef MAIN #define list1_test main #endif #if !defined (STLPORT) || defined(__STL_USE_NAMESPACES) using namespace std; #endif int list1_test(int, char**) { cout<<"Results of list1_test:"<<endl; int array1 [] = { 9, 16, 36 }; int array2 [] = { 1, 4 }; list<int> l1(array1, array1 + 3); list<int> l2(array2, array2 + 2); list<int>::iterator i1 = l1.begin(); l1.splice(i1, l2); list<int>::iterator i2 = l1.begin(); while(i2 != l1.end()) cout << *i2++ << endl; return 0; }
[ "martin@os2world.com" ]
martin@os2world.com
c39fe5e56977b841ca22fbf7a2e22d9e1fd7242d
7e686617bdbff7e00199c82c1cc7bc243333bd62
/library/dripline_config.cc
d4cdf7f465307d6313649a5ed7815e535fce6e75
[ "Apache-2.0" ]
permissive
driplineorg/dripline-cpp
0c4d1d1c11726ce3abb60238d7f03ad00cb9bf0e
c0ea805a790e91a32623267c3f5b7f03d7630f77
refs/heads/main
2023-04-29T18:35:36.290190
2022-09-22T17:17:49
2022-09-22T17:17:49
143,458,633
2
2
Apache-2.0
2023-04-14T16:47:41
2018-08-03T18:06:16
C++
UTF-8
C++
false
false
3,915
cc
/* * dripline_config.cc * * Created on: Jun 26, 2019 * Author: N.S. Oblath */ #define DRIPLINE_API_EXPORTS #include "dripline_config.hh" #include "application.hh" #include "logger.hh" using scarab::param_node; LOGGER( dlog, "agent_config" ); namespace dripline { dripline_config::dripline_config( const std::string& a_auth_file ) { // default dripline configuration scarab::path t_auth_default_path; #ifdef DRIPLINE_AUTH_FILE //add logic for default auth file if it exists LTRACE( dlog, "Have a default auth path provided at build time: <" << TOSTRING( DRIPLINE_AUTH_FILE ) << ">" ); t_auth_default_path = scarab::expand_path( TOSTRING( DRIPLINE_AUTH_FILE ) ); #endif if( ! a_auth_file.empty() ) { LTRACE( dlog, "Have a default auth path provided at runtime: <" << a_auth_file << ">" ); t_auth_default_path = scarab::expand_path( a_auth_file ); } if ( ! t_auth_default_path.empty() && boost::filesystem::exists( t_auth_default_path ) ) { LDEBUG( dlog, "default auth file found, setting that as initial value: " << t_auth_default_path.string() ); add( "auth-file", t_auth_default_path.string() ); } else { if( t_auth_default_path.empty() ) { LDEBUG( dlog, "No default auth file present; will not be set in dripline_config" ); } else { LDEBUG( dlog, "Default auth path <" << t_auth_default_path.string() << "> does not exist; will not be set in dripline_config" ); } } add( "requests-exchange", "requests" ); add( "alerts-exchange", "alerts" ); add( "max-payload-size", DL_MAX_PAYLOAD_SIZE ); add( "loop-timeout-ms", 1000 ); add( "message-wait-ms", 1000 ); add( "heartbeat-routing-key", "heartbeat" ); add( "heartbeat-interval-s", 60 ); // broker and broker-port can be specified in the config. // however, we don't give default values so that they can be specified in the auth file. // the dripline config will override the auth file if it's given there. //add( "broker-port", 5672 ); //add( "broker", "localhost" ); } dripline_config::~dripline_config() { } void add_dripline_options( scarab::main_app& an_app ) { an_app.add_config_option< std::string >( "-b,--broker", "dripline.broker", "Set the dripline broker address" ); an_app.add_config_option< unsigned >( "-p,--port", "dripline.broker-port", "Set the port for communication with the dripline broker" ); an_app.add_config_option< std::string >( "--auth-file", "dripline.auth-file", "Set the authentication file path" ); an_app.add_config_option< std::string >( "--requests-exchange", "dripline.requests-exchange", "Set the name of the requests exchange" ); an_app.add_config_option< std::string >( "--alerts-exchange", "dripline.alerts-exchange", "Set the name of the alerts exchange" ); an_app.add_config_option< unsigned >( "--max-payload", "dripline.max-payload-size", "Set the maximum payload size (in bytes)" ); an_app.add_config_option< unsigned >( "--loop-timeout-ms" "dripline.loop-timeout-ms", "Set the timeout for thread loops in ms" ); an_app.add_config_option< unsigned >( "--message-wait-ms" "dripline.message-wait-ms", "Set the time to wait for a full multi-part message in ms" ); an_app.add_config_option< std::string >( "--heartbeat-routing-key", "dripline.heartbeat-routing-key", "Set the first token of heartbeat routing keys: [token].[origin]" ); an_app.add_config_option< unsigned >( "--heartbeat-interval-s", "dripline.heartbeat-interval-s", "Set the interval between heartbeats in s" ); return; } } /* namespace dripline */
[ "nsoblath@gmail.com" ]
nsoblath@gmail.com
13961a98550cbe7e186a18fdeb432ef4acc33fea
0eff74b05b60098333ad66cf801bdd93becc9ea4
/second/download/xgboost/xgboost-gumtree/dmlc_xgboost_old_hunk_270.cpp
2209fbb8bf64d61bef4abd16fcb277ffbdf6442b
[]
no_license
niuxu18/logTracker-old
97543445ea7e414ed40bdc681239365d33418975
f2b060f13a0295387fe02187543db124916eb446
refs/heads/master
2021-09-13T21:39:37.686481
2017-12-11T03:36:34
2017-12-11T03:36:34
null
0
0
null
null
null
null
UTF-8
C++
false
false
839
cpp
maxthread = std::max(maxthread / 2, 1); nthread_ = std::min(maxthread, nthread); } virtual ~LibSVMParser() { delete source_; } virtual void BeforeFirst(void) { utils::Assert(at_head_, "cannot call BeforeFirst"); } virtual const LibSVMPage &Value(void) const { return data_[data_ptr_ - 1]; } virtual bool Next(void) { while (true) { while (data_ptr_ < data_end_) { data_ptr_ += 1; if (data_[data_ptr_ - 1].Size() != 0) { return true; } } if (!FillData()) break; data_ptr_ = 0; data_end_ = data_.size(); } return false; } inline size_t bytes_read(void) const { return bytes_read_; } protected: inline bool FillData() { dmlc::InputSplit::Blob chunk; if (!source_->NextChunk(&chunk)) return false; int nthread;
[ "993273596@qq.com" ]
993273596@qq.com
2d434dbf9d3b059825338f8af8ef3258c8a8c253
877fff5bb313ccd23d1d01bf23b1e1f2b13bb85a
/app/src/main/cpp/dir521/dir3871/dir5864/dir6285/dir7553/file7554.cpp
77168a468bff750d44694a00295e1f95cf4ea9c1
[]
no_license
tgeng/HugeProject
829c3bdfb7cbaf57727c41263212d4a67e3eb93d
4488d3b765e8827636ce5e878baacdf388710ef2
refs/heads/master
2022-08-21T16:58:54.161627
2020-05-28T01:54:03
2020-05-28T01:54:03
267,468,475
0
0
null
null
null
null
UTF-8
C++
false
false
111
cpp
#ifndef file7554 #error "macro file7554 must be defined" #endif static const char* file7554String = "file7554";
[ "tgeng@google.com" ]
tgeng@google.com
499318dabae2dccfb78fcc13e3a87d38be94c952
06bd829a0b316ff1a8b54b4fc1bb88c73a4fc68f
/两根指针/100.删除排序数组中的重复数字.cpp
ce640898f31b215af01636ffa8b62b1ccc6d9eaf
[]
no_license
LiuYu0521/lintcode
148e763294f478f50858f8053cacf5478b5c60b4
97c90a2065c6bf6df76c43211af0db2da528b965
refs/heads/master
2021-01-22T21:53:32.924735
2017-08-13T02:51:25
2017-08-13T02:51:25
92,742,383
2
0
null
null
null
null
UTF-8
C++
false
false
515
cpp
class Solution { public: /** * @param A: a list of integers * @return : return an integer */ int removeDuplicates(vector<int> &nums) { // write your code here if(nums.size() == 0 || nums.size() == 1) return nums.size(); int len = 0; for(int i = 1; i < nums.size(); i++) { if(nums[len] != nums[i]) { len++; nums[len] = nums[i]; } } return len + 1; } };
[ "ly819933137@gmail.com" ]
ly819933137@gmail.com
d085db9e112f9ff3efb3cf7838e73ecf4c246940
7c564490c39d6000de61f8e824ccd9589cc8f3d6
/Chapter 5/4.cpp
bba3a9b416f8653713272228e7f49feda7fed16a
[]
no_license
MONA00007/Cpp
ba009acea70d542f0fd980fbae47879e6f16c3c1
eb26fe775afcefce927839cba385e344ad46b8b7
refs/heads/master
2023-01-22T17:40:44.178347
2020-12-10T13:04:50
2020-12-10T13:04:50
295,726,028
0
0
null
null
null
null
UTF-8
C++
false
false
3,781
cpp
#include <iostream> #include <algorithm> #include <cstring> #include <string> #include <cmath> #include <functional> #include <vector> #include <stack> #include <queue> #include <map> #include <set> #define MAX 51 //#define INF 1000000000 using namespace std; //typedef long long int LL; int n, len; char str[MAX]; bool vis[MAX]; bool cmp(int a, int b) { return a > b; } int cal(int v, int w, int x, int y, int z) { return v - w * w + x * x * x - y * y * y * y + z * z * z * z * z; } bool func() { len = strlen(str); sort(str, str + len, cmp); for (int v = 0; v < len; v++) { vis[v] = true; for (int w = 0; w < len; w++) { if (!vis[w]) { vis[w] = true; for (int x = 0; x < len; x++) { if (!vis[x]) { vis[x] = true; for (int y = 0; y < len; y++) { if (!vis[y]) { vis[y] = true; for (int z = 0; z < len; z++) { if (!vis[z]) { vis[z] = true; if (cal(str[v] - '@', str[w] - '@', str[x] - '@', str[y] - '@', str[z] - '@') == n) { printf("%c%c%c%c%c\n", str[v], str[w], str[x], str[y], str[z]); return true; } vis[z] = false; } } vis[y] = false; } } vis[x] = false; } } vis[w] = false; } } vis[v] = false; } return false; } int main(int agrc, char *agrv[]) { while (~scanf("%d", &n) && n) { scanf("%s", str); if (!func()) printf("no solution\n"); } } #include <iostream> #include <string> #include <algorithm> #include <cmath> using namespace std; int array[13]; int first = -1; int aw[5]; void empty() //清空函数 { for (int i = 4; i >= 0; --i) { aw[i] = 0; } first = -1; } void solve(int n, string s1) { for (int i = 0; i < (int)s1.size(); ++i) { array[i] = s1[i] - 'A' + 1; //将字符转成序号 } sort(array, array + s1.size()); do { if (array[4] > first) //剪枝,剪去排头第一个字符小于当前最优字符的所有情况 { if (array[4] - pow(array[3], 2) + pow(array[2], 3) - pow(array[1], 4) + pow(array[0], 5) == n) //条件判断 { if (array[4] > first) { first = array[4]; for (int i = 4; i >= 0; --i) { aw[i] = array[i]; } } } } } while (next_permutation(array, array + s1.size())); //全排列 if (first == -1) { cout << "no solution" << endl; } else { for (int i = 4; i >= 0; --i) { cout << (char)(aw[i] + 'A' - 1); //还原字符并输出 } cout << endl; empty(); //清空,不影响下次结果。 } } int main() { string s1; int n = 0; while (cin >> n && n != 0) { cin >> s1; solve(n, s1); } return 0; }
[ "1175104595@qq.com" ]
1175104595@qq.com
07321e87c3b154c7a05452723a42b6593fa73dbe
9b9b0a2884ad60523293aee6882b70a48c8ab667
/CppDLLDemo/CppDLL/ClassOne.h
0e5f78b0dd7f96a98ac3b5349fb33077efce0eb3
[]
no_license
waterstonemf/CPP
ad83db4fec14c4f4b608fc3f843b67546854f263
cd5d21ec1460d33876f8c3b8105b9d5e1743b7ff
refs/heads/master
2021-01-19T05:20:39.463828
2015-10-13T08:09:04
2015-10-13T08:09:04
41,714,280
0
0
null
null
null
null
UTF-8
C++
false
false
232
h
#pragma once namespace CppDLLDemo { class ClassOne { private: int varone; public: __declspec(dllexport) ClassOne(); __declspec(dllexport) void SetVar(int val); __declspec(dllexport) int GetVar(); //~ClassOne(); }; }
[ "waterstonemf@outlook.com" ]
waterstonemf@outlook.com
b8222872f0d5d5b9d64f12012358592a9bc442a7
6b473926c32cdc373eafe7470ef92fda3e9385b5
/Source/FirstPersonProject/Private/AmmoTypeEnum.cpp
d573f8b9039477c0cb0f31f9e2be421e99dd5972
[]
no_license
RickyCarrera/FirstPersonProject
98b8d9aaddefcd963ed133f290c5af9633649e55
553fec274e3bebe272bca7d3eb03e6f3944c9930
refs/heads/master
2022-11-21T09:09:03.091158
2020-07-28T22:29:07
2020-07-28T22:29:07
278,741,578
0
0
null
null
null
null
UTF-8
C++
false
false
108
cpp
// Fill out your copyright notice in the Description page of Project Settings. #include "AmmoTypeEnum.h"
[ "rickycarrera@csu.fullerton.edu" ]
rickycarrera@csu.fullerton.edu
b0a93bdca38e3a7ad7f4e0910bc99a8b57e95628
645579a92951646f4fadfbebe3e3ff242fd4036b
/lab2/calendar.cpp
08b6dbb29b5aaa6be2fcd5da054eb95c9c320969
[]
no_license
gauravalgo/cprog13
1525fe3926f5286238d6e9ef38db29ed89fd8635
9d2467eb649534a189fdcc4b24e2ae2b5f7f8b05
refs/heads/master
2021-01-16T22:10:15.843378
2014-01-30T14:22:58
2014-01-30T14:22:58
null
0
0
null
null
null
null
UTF-8
C++
false
false
384
cpp
#include "calendar.h" #include <iostream> using namespace lab2; //template<class T> //Calendar<T>::Calendar() : current_date( T() ) { // std::cout << "Calendar()" << std::endl; //} //template<class T> //bool Calendar<T>::add_event(std::string event, int y, int m, int d) { //} //template<class T> //bool Calendar<T>::remove_event(std::string event, int y, int m, int d) { //}
[ "simon.strom@gmail.com" ]
simon.strom@gmail.com
91f4a7b2613b82374323c1b4ac5ed2926c58af8c
b2e0adc80f0e05f580d24eb9642a6144e7e6314d
/main.cpp
b6312230c52c062c874bf066c5ae6a3622df32e5
[]
no_license
nalger2/HelloWorldPersonalGithub
5342110df738470fe7ae2500aad9cfd34c66231d
3ae1debc21e8ffb4ed23da736b0b7fe078bc9e87
refs/heads/master
2020-12-18T14:56:02.299435
2020-01-21T19:57:52
2020-01-21T19:57:52
235,428,138
0
0
null
null
null
null
UTF-8
C++
false
false
100
cpp
#include <iostream> using namespace std; int main(){ cout << "Hello world" << endl; return 0; }
[ "nalger2@zagmail.gonzaga.edu" ]
nalger2@zagmail.gonzaga.edu
2f9a8e7eb27c1bb4c5208177d67ae57c8fc9fb62
097007b435b1bf420a19ce33aabee32f0789f145
/codeforces/692_div2/3.cpp
baf35eb605258f248090c7809c564849c5fe32aa
[]
no_license
Anshit01/Competitive-Programming
71f84a85dde49278f8c3318d00db70616d8ea470
13911ec7f622abc061fea1ccc1f35d34118641f7
refs/heads/master
2023-06-11T12:06:11.722865
2021-06-30T11:51:01
2021-06-30T11:51:01
266,321,296
5
2
null
2020-10-19T09:47:06
2020-05-23T11:21:40
C++
UTF-8
C++
false
false
1,601
cpp
/* *>>>>>Anshit_Bhardwaj<<<<<* */ #include <bits/stdc++.h> #define ll long long //#define int long long #define f(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) #define what_is(x) cerr << #x << " is " << x << endl #define dbg(x) cerr << x << endl #define dbg2(x, y) cerr << x << ' ' << y << endl #define dbg3(x, y, z) cerr << x << ' ' << y << ' ' << z << endl #define inputArray(arr) f(i, 0, arr.size()) cin >> arr[i] #define printArray(arr) f(i, 0, arr.size()) cout << arr[i] << ' '; cout << endl #define mod 1000000007 #define endl '\n' using namespace std; int32_t main(){ ios::sync_with_stdio(0); cin.tie(0); int T; cin >> T; while(T--){ int n; cin >> n; int m; cin >> m; map<int, int> mp; int x, y; f(i, 0, m){ cin >> x >> y; mp[y] = x; } int cnt = 0; while(!mp.empty()){ pair<int, int> cur = *mp.begin(); if(cur.first == cur.second){ mp.erase(cur.first); }else{ int st = cur.first; while(mp.find(cur.second) != mp.end()){ cnt++; mp.erase(cur.first); cur = *mp.find(cur.second); if(cur.second == st){ cnt++; break; } } mp.erase(cur.first); cnt++; } } cout << cnt << endl; } }
[ "bhardwaj.anshit1379@gmail.com" ]
bhardwaj.anshit1379@gmail.com
a18fbb9d51f5fc70760379d22e3cb7bea42d678a
ff7dc642d1ba5b010baad248a1589291ff50f9a6
/src/URI.hpp
73b5252f1768eda8211e0e5a14674cd336f2923e
[ "MIT" ]
permissive
ImagicTheCat/Tsux
25614be7c4e2fe3c4d3e5f99361223722a7df939
f3bcd188a5defeeed947de942d78534ea3ee68d3
refs/heads/master
2021-01-22T02:58:34.249404
2014-09-05T14:29:30
2014-09-05T14:29:30
21,709,179
2
0
null
null
null
null
UTF-8
C++
false
false
613
hpp
/* URI encode/decode functions wrapper * source: http://www.codeguru.com/cpp/cpp/algorithms/strings/article.php/c12759/URI-Encoding-and-Decoding.htm * * Uri encode and decode. * RFC1630, RFC1738, RFC2396 */ #ifndef H_URI #define H_URI #include <iostream> class URI{ public: static std::string encode(const std::string& str); static std::string decode(const std::string& str); //encode a string in a human readable format for uri static std::string slugify(const std::string& str); static const char HEX2DEC[256]; static const char SAFE[256]; private: URI(); }; #endif
[ "imagic@rebirth" ]
imagic@rebirth
54a575b71a272fffb7caf51a13a7c6e6115f6e67
9b30ff25a3ca496a7dbe278816517b31a4f0fe25
/CreekWater/code/mywidgets/gaugeplane.h
8c98467016158f1cd5eac8840df4299da9e9fbd4
[]
no_license
DreamFly2016/creekwater
1bd903cd5ef36a1a1b57d8027b2df107049ad005
3c7a83bc695d9d7750c906be4dcb824d63f8b4eb
refs/heads/master
2022-10-11T18:33:53.471875
2020-06-07T05:51:35
2020-06-07T05:51:35
null
0
0
null
null
null
null
UTF-8
C++
false
false
5,101
h
#ifndef GAUGEPLANE_H #define GAUGEPLANE_H #include <QWidget> #ifdef quc #if (QT_VERSION < QT_VERSION_CHECK(5,7,0)) #include <QtDesigner/QDesignerExportWidget> #else #include <QtUiPlugin/QDesignerExportWidget> #endif class QDESIGNER_WIDGET_EXPORT GaugePlane : public QWidget #else class GaugePlane : public QWidget #endif { Q_OBJECT Q_PROPERTY(QColor borderOutColorStart READ getBorderOutColorStart WRITE setBorderOutColorStart) Q_PROPERTY(QColor borderOutColorEnd READ getBorderOutColorEnd WRITE setBorderOutColorEnd) Q_PROPERTY(QColor borderInColorStart READ getBorderInColorStart WRITE setBorderInColorStart) Q_PROPERTY(QColor borderInColorEnd READ getBorderInColorEnd WRITE setBorderInColorEnd) Q_PROPERTY(QColor bgColor READ getBgColor WRITE setBgColor) Q_PROPERTY(QColor planeColor READ getPlaneColor WRITE setPlaneColor) Q_PROPERTY(QColor glassColor READ getGlassColor WRITE setGlassColor) Q_PROPERTY(QColor scaleColor READ getScaleColor WRITE setScaleColor) Q_PROPERTY(QColor lineColor READ getLineColor WRITE setLineColor) Q_PROPERTY(QColor textColor READ getTextColor WRITE setTextColor) Q_PROPERTY(QColor pointerColor READ getPointerColor WRITE setPointerColor) Q_PROPERTY(QColor handleColor READ getHandleColor WRITE setHandleColor) Q_PROPERTY(int degValue READ getDegValue WRITE setDegValue) Q_PROPERTY(int rollValue READ getRollValue WRITE setRollValue) public: explicit GaugePlane(QWidget *parent = nullptr); protected: void paintEvent(QPaintEvent *); void drawYawBorderOut(QPainter *painter); void drawYawBorderIn(QPainter *painter); void drawYawBg(QPainter *painter); void drawYawScale(QPainter *painter); void drawScaleNum(QPainter *painter); void drawYawPointer(QPainter *painter); void drawBorderOut(QPainter *painter); void drawBorderIn(QPainter *painter); void drawBg(QPainter *painter); void drawPlane(QPainter *painter); void drawGlass(QPainter *painter); void drawScale(QPainter *painter); void drawLine(QPainter *painter); void drawHandle(QPainter *painter); void drawValue(QPainter *painter); private: QColor borderOutColorStart; //外边框渐变开始颜色 QColor borderOutColorEnd; //外边框渐变结束颜色 QColor borderInColorStart; //里边框渐变开始颜色 QColor borderInColorEnd; //里边框渐变结束颜色 QColor bgColor; //背景颜色 QColor planeColor; //姿态仪背景 QColor glassColor; //遮罩层颜色 QColor scaleColor; //刻度尺颜色 QColor lineColor; //线条颜色 QColor textColor; //文字颜色 QColor pointerColor; //指针颜色 QColor handleColor; //手柄颜色 int degValue; //旋转角度 int rollValue; //滚动值 int yawValue; double value; //目标值 int precision; //精确度,小数点后几位 public: QColor getBorderOutColorStart() const; QColor getBorderOutColorEnd() const; QColor getBorderInColorStart() const; QColor getBorderInColorEnd() const; QColor getBgColor() const; QColor getPlaneColor() const; QColor getGlassColor() const; QColor getScaleColor() const; QColor getLineColor() const; QColor getTextColor() const; QColor getPointerColor() const; QColor getHandleColor() const; int getDegValue() const; int getRollValue() const; QSize sizeHint() const; QSize minimumSizeHint() const; public Q_SLOTS: //设置外边框渐变颜色 void setBorderOutColorStart(const QColor &borderOutColorStart); void setBorderOutColorEnd(const QColor &borderOutColorEnd); //设置里边框渐变颜色 void setBorderInColorStart(const QColor &borderInColorStart); void setBorderInColorEnd(const QColor &borderInColorEnd); //设置背景色 void setBgColor(const QColor &bgColor); //设置姿态仪背景 void setPlaneColor(const QColor &planeColor); //设置遮罩层颜色 void setGlassColor(const QColor &glassColor); //设置刻度尺颜色 void setScaleColor(const QColor &scaleColor); //设置线条颜色 void setLineColor(const QColor &lineColor); //设置文字颜色 void setTextColor(const QColor &textColor); //设置指针颜色 void setPointerColor(const QColor &pointerColor); //设置手柄颜色 void setHandleColor(const QColor &handleColor); //设置旋转角度值 void setDegValue(int degValue); //设置前进旋转值 void setRollValue(int rollValue); //设置偏航 void setYawValue(int yawValue); }; #endif // GAUGEPLANE_H
[ "892821534@qq.com" ]
892821534@qq.com
e587be1d4b42696cf4ffdd7e633cd149588c42ce
651b8518618387c84d082ae3c85c4087c14aa1bc
/chromium/patches/patch-base_debug_debugger__posix.cc
88d39ede4f9ed35b449b11e3c2da875083384ed0
[ "BSD-3-Clause" ]
permissive
jcea/pkgsrc-wip
3868cde803d99b2911971fe9592bb70f8162f905
e4e1744528811203f8c31740d09d1f99c2c2617d
refs/heads/master
2021-01-11T15:44:06.159591
2017-01-23T10:12:50
2017-01-23T10:12:50
79,915,472
0
0
null
2017-01-24T13:48:28
2017-01-24T13:48:28
null
UTF-8
C++
false
false
2,005
cc
$NetBSD: patch-base_debug_debugger__posix.cc,v 1.2 2011/05/27 13:23:09 rxg Exp $ --- base/debug/debugger_posix.cc.orig 2011-05-24 08:01:33.000000000 +0000 +++ base/debug/debugger_posix.cc @@ -6,11 +6,18 @@ #include "build/build_config.h" #include <errno.h> +#if !defined(OS_NETBSD) && !defined(OS_DRAGONFLY) #include <execinfo.h> +#endif #include <fcntl.h> #include <stdio.h> #include <stdlib.h> #include <sys/stat.h> +#if defined(OS_OPENBSD) || defined(OS_NETBSD) +#include <sys/param.h> +#elif defined(OS_DRAGONFLY) +#include <sys/kinfo.h> +#endif #if !defined(OS_NACL) #include <sys/sysctl.h> #endif @@ -50,7 +57,7 @@ bool SpawnDebuggerOnProcess(unsigned /* return false; } -#if defined(OS_MACOSX) +#if defined(OS_MACOSX) || defined(OS_BSD) // Based on Apple's recommended method as described in // http://developer.apple.com/qa/qa2004/qa1361.html @@ -71,11 +78,23 @@ bool BeingDebugged() { KERN_PROC, KERN_PROC_PID, getpid() +#if defined(OS_OPENBSD) || defined(OS_NETBSD) || defined(OS_DRAGONFLY) +#if defined(OS_NETBSD) + , sizeof(struct kinfo_proc2), +#else + , sizeof(struct kinfo_proc), +#endif + 400 /* XXX */ +#endif }; // Caution: struct kinfo_proc is marked __APPLE_API_UNSTABLE. The source and // binary interfaces may change. +#if defined(OS_NETBSD) + struct kinfo_proc2 info; +#else struct kinfo_proc info; +#endif size_t info_size = sizeof(info); int sysctl_result = sysctl(mib, arraysize(mib), &info, &info_size, NULL, 0); @@ -88,7 +107,15 @@ bool BeingDebugged() { // This process is being debugged if the P_TRACED flag is set. is_set = true; +#if defined(OS_OPENBSD) || defined(OS_NETBSD) + being_debugged = (info.p_flag & P_TRACED) != 0; +#elif defined(OS_FREEBSD) + being_debugged = (info.ki_flag & P_TRACED) != 0; +#elif defined(OS_DRAGONFLY) + being_debugged = (info.kp_flags & P_TRACED) != 0; +#else being_debugged = (info.kp_proc.p_flag & P_TRACED) != 0; +#endif return being_debugged; }
[ "wiz@NetBSD.org" ]
wiz@NetBSD.org
c81c8deabc0141417e0672b994d4b6c2791faafa
8fe2d7853c375adecd4549de13988aa01c637c09
/configuracion/actions.h
cb4dc2d0a6e4c01d25586273bbd1bf91c65ddf26
[]
no_license
borjabrisson/WxAF
85a5bc6ccc8b440a8e9152a6ed795f705f81b5c0
73fe724ea8331bb8cd9aba17284f0a3d806f772b
refs/heads/master
2020-05-19T12:45:50.960072
2014-01-18T15:56:37
2014-01-18T15:56:37
11,108,041
1
0
null
null
null
null
UTF-8
C++
false
false
512
h
#ifndef ACTION_APP_H_ #define ACTION_APP_H_ #include <map> #include <iostream> #include <string> #include <list> using namespace std; enum Agosal_Base_Action{ ACT_getFilter=1, ACT_setFilter, ACT_onFilter }; enum Agosal_Type_BlockComunicate{ BKCM_Action=21, BKCM_Query, BKCM_Filter }; enum Agosal_Acton_Ctr_TO_View{ C2V_showList=131, C2V_showMsg, C2V_actionOK, C2V_actionDeny }; enum Agosal_Acton_View_TO_Ctr{ V2C_setFilter = 241, V2C_onFilter }; #endif /* ACTION_APP_H_ */
[ "borjabrisson@gmail.com" ]
borjabrisson@gmail.com
05783416dae114ae01fc98e0ec01a30ed9fb31a9
13781d36f3a3ae2684e41f47268b3d5c5767881b
/bwi_tools/include/bwi_tools/point.h
3b58a72c6940f62ded9e26656ab8b3fc6bcb965e
[ "LicenseRef-scancode-public-domain" ]
permissive
utexas-bwi/bwi_common
c1da90b2d3b88e4514ccc088d6a783a22a65b0fa
ae037f3fca15951e29e08644a135aac1a2ca456f
refs/heads/master
2023-07-20T15:05:34.771069
2023-07-13T04:54:47
2023-07-13T04:54:47
14,791,963
17
43
NOASSERTION
2021-07-16T14:30:24
2013-11-29T03:26:28
C++
UTF-8
C++
false
false
264
h
#ifndef BWI_TOOLS_POINT_H #define BWI_TOOLS_POINT_H #include <opencv/cv.h> namespace bwi { typedef cv::Point2f Point2f; inline float getMagnitude(Point2f p) { return cv::norm(p); } } /* bwi */ #endif /* end of include guard: BWI_TOOLS_POINT_H */
[ "piyushk@gmail.com" ]
piyushk@gmail.com
4135091130ded878298331eeb16af755cdb36c2b
87252f880b0348c58a556ab966c6c39b8945e3c5
/8-Path-Sum-III.cpp
d41a34a07e561ad5678900a958c431b86f34bc0b
[]
no_license
lrakla/Leetcode-August-2020-Challenge
8c8430838692a54896977ac6f480472aa06196e4
aad7ed396e032d595bbe996002b39f516977647b
refs/heads/master
2022-12-07T04:46:54.094116
2020-09-03T04:31:58
2020-09-03T04:31:58
285,034,736
0
0
null
null
null
null
UTF-8
C++
false
false
846
cpp
/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode() : val(0), left(nullptr), right(nullptr) {} * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {} * TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {} * }; */ class Solution { int incl_node(TreeNode* node, int sum){ if(node==nullptr) return 0; int res = 0; if(node->val == sum) res++; res +=incl_node(node->left, sum-node->val); res +=incl_node(node->right, sum-node->val); return res; } public: int pathSum(TreeNode* root, int sum) { if(root==nullptr) return 0; return pathSum(root->left, sum) + incl_node(root,sum) + pathSum(root->right, sum); } };
[ "raklalulua@gmail.com" ]
raklalulua@gmail.com
ed654349d8fea67e9378aaeffe3b281f0dd9156e
2c27b0c9931c7d0e40a7000a71391129c56de823
/cpp/Programmers/타겟 넘버/타겟 넘버/main.cpp
9078f079ba1080b6125bac53ee873dc49d7ab9d8
[]
no_license
KaJaeHyeob/Coding_Test
202ff97ef02fed5b8e01ffaf3031627c4ca2d0af
6b25936b41b0494ac008fb0a8d049ccca8a60cca
refs/heads/master
2023-06-09T04:46:45.118266
2021-07-02T06:00:52
2021-07-02T06:00:52
250,206,062
0
0
null
null
null
null
UTF-8
C++
false
false
1,904
cpp
// DFS 사용 // sum 전역변수가 아니라 DFS 함수 인자로 사용하면 훨씬 깔끔함 // 참조, 포인터 연습하기 /* int main(){ int a = 1; int* b = &a; // 포인터 변수 b = a 주소값 cout << "a = " << a << endl; cout << "&a = " << &a << endl; cout << "b = " << b << endl; cout << "*b = " << *b << endl; // 포인터 변수 b 역참조 int& c = a; // 참조 변수 c = a cout << "c = " << c << endl; cout << "c++ = " << c++ << endl; cout << "a = " << a << endl; cout << "c = " << c << endl; } */ /* #include <string> #include <vector> using namespace std; int sum = 0; int res = 0; vector<int> num; int size; int tar; void dfs(int i, int sign){ if(sign == 1){ sum += num[i]; } else{ sum -= num[i]; } if(i == size - 1){ if(sum == tar){ res++; } if(sign == 1){ sum -= num[i]; } else{ sum += num[i]; } return; } dfs(i+1, 1); dfs(i+1, 2); if(sign == 1){ sum -= num[i]; } else{ sum += num[i]; } } int solution(vector<int> numbers, int target) { sum = 0; res = 0; num = numbers; tar = target; size = numbers.size(); dfs(0, 1); dfs(0, 2); return res; } */ #include <string> #include <vector> using namespace std; int total; void DFS(vector<int> &numbers, int &target,int sum,int n) { if(n >= numbers.size()){ if(sum == target) total++; return; } DFS(numbers, target, sum + numbers[n], n+1); DFS(numbers, target, sum - numbers[n], n+1); } int solution(vector<int> numbers, int target) { int answer = 0; DFS(numbers, target, numbers[0] , 1); DFS(numbers, target, -numbers[0], 1); answer = total; return answer; }
[ "lobster0120@naver.com" ]
lobster0120@naver.com
1cbb0234c92027cbab90ce277c46dd6e7863486b
021e8c48a44a56571c07dd9830d8bf86d68507cb
/build/vtk/vtkCarbonRenderWindowInteractor.h
980e286bb495d3c4283bfe833fefdca79b87586f
[ "BSD-3-Clause" ]
permissive
Electrofire/QdevelopVset
c67ae1b30b0115d5c2045e3ca82199394081b733
f88344d0d89beeec46f5dc72c20c0fdd9ef4c0b5
refs/heads/master
2021-01-18T10:44:01.451029
2011-05-01T23:52:15
2011-05-01T23:52:15
null
0
0
null
null
null
null
UTF-8
C++
false
false
6,521
h
/*========================================================================= Program: Visualization Toolkit Module: vtkCarbonRenderWindowInteractor.h Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen All rights reserved. See Copyright.txt or http://www.kitware.com/Copyright.htm for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notice for more information. =========================================================================*/ // .NAME vtkCarbonRenderWindowInteractor - implements Carbon specific functions // required by vtkRenderWindowInteractor. // // .SECTION Description // The interactor interfaces with vtkCarbonWindow // to trap messages from the Carbon window manager and send them to vtk. // #ifndef __vtkCarbonRenderWindowInteractor_h #define __vtkCarbonRenderWindowInteractor_h #include "vtkRenderWindowInteractor.h" #include "vtkTDxConfigure.h" // defines VTK_USE_TDX #ifdef VTK_USE_TDX class vtkTDxMacDevice; #endif // The 10.3.9 SDK (and older probably) have a bug in fp.h (in the Carbon // umbrella framework) which this works around. Without this, there // would be a compile error from the Carbon header if Python wrappings // were enabled. #include <AvailabilityMacros.h> // Needed for MAC_OS_X_VERSION_MAX_ALLOWED #if MAC_OS_X_VERSION_MAX_ALLOWED < 1040 #define scalb scalbn #endif #include <Carbon/Carbon.h> // Carbon and Mac specific class VTK_RENDERING_EXPORT vtkCarbonRenderWindowInteractor : public vtkRenderWindowInteractor { public: // Description: // Construct object so that light follows camera motion. static vtkCarbonRenderWindowInteractor *New(); vtkTypeMacro(vtkCarbonRenderWindowInteractor,vtkRenderWindowInteractor); void PrintSelf(ostream& os, vtkIndent indent); // Description: // Initialize the even handler virtual void Initialize(); // Description: // Enable/Disable interactions. By default interactors are enabled when // initialized. Initialize() must be called prior to enabling/disabling // interaction. These methods are used when a window/widget is being // shared by multiple renderers and interactors. This allows a "modal" // display where one interactor is active when its data is to be displayed // and all other interactors associated with the widget are disabled // when their data is not displayed. virtual void Enable(); virtual void Disable(); // Description: // This will start up the event loop and never return. If you // call this method it will loop processing events until the // application is exited. virtual void Start(); // Description: // By default the interactor installs a MessageProc callback which // intercepts windows messages to the window and controls interactions. // MFC or BCB programs can prevent this and instead directly route any mouse/key // messages into the event bindings by setting InstallMessgeProc to false. vtkSetMacro(InstallMessageProc,int); vtkGetMacro(InstallMessageProc,int); vtkBooleanMacro(InstallMessageProc,int); // Description: // Carbon specific application terminate, calls ClassExitMethod then // calls PostQuitMessage(0) to terminate app. An application can Specify // ExitMethod for alternative behaviour (i.e. suppresion of keyboard exit) void TerminateApp(void); // Description: // Methods to set the default exit method for the class. This method is // only used if no instance level ExitMethod has been defined. It is // provided as a means to control how an interactor is exited given // the various language bindings (tcl, Carbon, etc.). static void SetClassExitMethod(void (*f)(void *), void *arg); static void SetClassExitMethodArgDelete(void (*f)(void *)); // Description: // These methods correspond to the the Exit, User and Pick // callbacks. They allow for the Style to invoke them. virtual void ExitCallback(); // Description: // This method is for internal use only. Track the Carbon mouse deltas // Carbon events that don't provide mouse position directly. void GetLastMouseDelta(int delta[2]) { delta[0] = this->LastMouseDelta[0]; delta[1] = this->LastMouseDelta[1]; }; void SetLastMouseDelta(int deltaX, int deltaY) { this->LastMouseDelta[0] = deltaX; this->LastMouseDelta[1] = deltaY; }; // Description: // This method is for internal use only. This is a state variable used for // Enter/Leave events. If the mouse is dragged outside of the window, // MouseInsideWindow will remain set until the mouse button is released // outside of the window. void SetMouseInsideWindow(int val) { this->MouseInsideWindow = val; }; int GetMouseInsideWindow() { return this->MouseInsideWindow; }; // Description: // This method is for internal use only. This is a state variable used for // Enter/Leave events. It keeps track of whether a mouse button is down. void SetMouseButtonDown(int val) { this->MouseButtonDown = val; }; int GetMouseButtonDown() { return this->MouseButtonDown; }; protected: vtkCarbonRenderWindowInteractor(); ~vtkCarbonRenderWindowInteractor(); EventHandlerUPP ViewProcUPP; EventHandlerUPP WindowProcUPP; int InstallMessageProc; // For generating event info that Carbon doesn't int LastMouseDelta[2]; int LeaveCheckId; int MouseInsideWindow; int MouseButtonDown; //BTX // Description: // Class variables so an exit method can be defined for this class // (used to set different exit methods for various language bindings, // i.e. tcl, java, Carbon) static void (*ClassExitMethod)(void *); static void (*ClassExitMethodArgDelete)(void *); static void *ClassExitMethodArg; //ETX // Description: // Carbon-specific internal timer methods. See the superclass for detailed // documentation. virtual int InternalCreateTimer(int timerId, int timerType, unsigned long duration); virtual int InternalDestroyTimer(int platformTimerId); #ifdef VTK_USE_TDX vtkTDxMacDevice *Device; #endif private: vtkCarbonRenderWindowInteractor(const vtkCarbonRenderWindowInteractor&); // Not implemented. void operator=(const vtkCarbonRenderWindowInteractor&); // Not implemented. }; #endif
[ "ganondorf@ganondorf-VirtualBox.(none)" ]
ganondorf@ganondorf-VirtualBox.(none)
faeb9c2c7f6ebf2492c2a3957e4d18d28bedb847
d51af344066e4da6f97284aa4ce8a5343e41d822
/lightengine/inc/drCamera.h
8a742d00d08bacffd18c836fe0a60c2e7c67c118
[]
no_license
xeroix9794/CrystalSaga2.4
343819810317c346859a9f2c9493f1d713de07f1
249a36b9e6ea12046ec5aa5afab1d77a729e6ee0
refs/heads/master
2023-02-19T15:22:27.447586
2019-10-23T22:41:33
2019-10-23T22:41:33
202,953,390
0
0
null
null
null
null
UTF-8
C++
false
false
902
h
// #pragma once #include "drHeader.h" #include "drMath.h" #include "drFrontAPI.h" #include "drDirectX.h" DR_BEGIN class DR_FRONT_API drCamera { public: static void GetMatrixCameraToView(drMatrix44* mat, const drMatrix44* cam_mat); static void GetMatrixViewToCamera(drMatrix44* mat, const drMatrix44* mat_view); private: drMatrix44 _m; public: float _fov; float _aspect; float _znear; float _zfar; public: drCamera(); int SetPerspectiveFov(float fov, float aspect, float zn, float zf); void SetPosition(drVector3* pos); void SetPosition(drVector3* face, drVector3* up); void SetPosition(drVector3* pos, drVector3* face, drVector3* up); void SetPosition(const drMatrix44* m) { _m = *m; } void Rotate(DWORD axis, float angle); void SetTransform(); drMatrix44* GetMatrix() { return &_m; } void GetMatrixView(drMatrix44* mat); void GetMatrixProj(drMatrix44* mat); }; DR_END
[ "Jaredjay9794@gmail.com" ]
Jaredjay9794@gmail.com
7498120b6665b13df4ff3a70811a51eaa83c5002
bc388f44b90673dfdcf9806e3454541c51ac98cd
/INFO_II/clases/1er cuatrimestre/3_clase_8_4_2020_c++_clases/3 - clases/EjercicioCuenta/cuenta.cpp
e59a89dd754713655a7d3af5271f281b0fcf2d5c
[]
no_license
mgoyret/INFO_UTN
4029cd29b776513b3a5fae2b82e5ab8b4f4dbf1c
12f34389b2b5937cf62fcd6f2af911b7bea89afa
refs/heads/master
2022-12-30T06:57:58.450023
2020-10-27T01:00:38
2020-10-27T01:00:38
213,951,944
0
0
null
null
null
null
UTF-8
C++
false
false
190
cpp
#include "cuenta.h" Cuenta::Cuenta() { saldo = 0; } int Cuenta::ObtenerSaldo() { return saldo; } void Cuenta::CargarSaldo(int valor) { saldo += valor; }
[ "marcosgoyret@gmail.com" ]
marcosgoyret@gmail.com
6d92a16070ba809d1ec682ac6caac1bdcd5ec4dc
c920079b644668fcea120937ec7bec392d2029bd
/B5---Applied-Mathematics/309pollution/includes/Points.hh
58b76630b8ba26d8b7b5081231353047f5b875cc
[]
no_license
Ankirama/Epitech
d23fc8912d19ef657b925496ce0ffcc58dc51d3b
3690ab3ec0c8325edee1802b6b0ce6952e3ae182
refs/heads/master
2021-01-19T08:11:27.374033
2018-01-03T10:06:20
2018-01-03T10:06:20
105,794,978
0
5
null
null
null
null
UTF-8
C++
false
false
524
hh
#ifndef INC_309POLLUTION_POINTS_HH #define INC_309POLLUTION_POINTS_HH #include <iostream> class Points { public: Points() { _poll = 0; _wgt = 1; } ~Points() { } Points(int poll) { _poll = poll; _wgt = 5; } void setPoll(int poll) { _poll = poll; } void setWgt(int wgt) { _wgt = wgt; } int getPoll() { return _poll; } int getWgt() { return _wgt; } private: int _poll; int _wgt; }; std::ostream& operator<<(std::ostream &os, Points &points); #endif //INC_309POLLUTION_POINTS_HH
[ "fabien.martinez@epitech.eu" ]
fabien.martinez@epitech.eu
94d151aff537efa8a039fd120a958b05a7392692
ad5522c6fa2d140295f1413a23c002320f5cb629
/icon_littlecat.h
c8efc8d1ec7f5f1f9ebf2a80c0e160d3497e3255
[]
no_license
ChienChia000/C-plus-plus-Project2
4a2d284ae6ad84f2bceeb7887299dbe0e11e1ad8
1aebb3aecff55a065bb064e609917c7cf4072360
refs/heads/master
2020-08-07T08:56:01.702059
2019-10-15T05:28:37
2019-10-15T05:28:37
213,380,872
0
0
null
null
null
null
UTF-8
C++
false
false
317
h
#ifndef ICON_LITTLECAT_H #define ICON_LITTLECAT_H #include<QGraphicsPixmapItem> #include<QGraphicsItem> #include<QObject> class Icon_littlecat : public QObject, public QGraphicsPixmapItem { Q_OBJECT public: Icon_littlecat(QGraphicsItem* parent=0); void spawn_littlecat(); }; #endif // ICON_LITTLECAT_H
[ "hcc7390@gmail.com" ]
hcc7390@gmail.com
9405c828cdfd3da9a5e0613ff6b584f5f24c9715
c776476e9d06b3779d744641e758ac3a2c15cddc
/examples/litmus/c/run-scripts/tmp_1/MP+dmb.sy+fri-rfi-ctrl-pos-addr.c.cbmc.cpp
dc1b39e6b1bfc547ac5adc082e7b3766316e0c42
[]
no_license
ashutosh0gupta/llvm_bmc
aaac7961c723ba6f7ffd77a39559e0e52432eade
0287c4fb180244e6b3c599a9902507f05c8a7234
refs/heads/master
2023-08-02T17:14:06.178723
2023-07-31T10:46:53
2023-07-31T10:46:53
143,100,825
3
4
null
2023-05-25T05:50:55
2018-08-01T03:47:00
C++
UTF-8
C++
false
false
44,123
cpp
// 0:vars:3 // 3:atom_1_X0_1:1 // 4:atom_1_X3_2:1 // 5:atom_1_X8_0:1 // 6:thr0:1 // 7:thr1:1 #define ADDRSIZE 8 #define NPROC 3 #define NCONTEXT 1 #define ASSUME(stmt) __CPROVER_assume(stmt) #define ASSERT(stmt) __CPROVER_assert(stmt, "error") #define max(a,b) (a>b?a:b) char __get_rng(); char get_rng( char from, char to ) { char ret = __get_rng(); ASSUME(ret >= from && ret <= to); return ret; } char get_rng_th( char from, char to ) { char ret = __get_rng(); ASSUME(ret >= from && ret <= to); return ret; } int main(int argc, char **argv) { // declare arrays for intial value version in contexts int meminit_[ADDRSIZE*NCONTEXT]; #define meminit(x,k) meminit_[(x)*NCONTEXT+k] int coinit_[ADDRSIZE*NCONTEXT]; #define coinit(x,k) coinit_[(x)*NCONTEXT+k] int deltainit_[ADDRSIZE*NCONTEXT]; #define deltainit(x,k) deltainit_[(x)*NCONTEXT+k] // declare arrays for running value version in contexts int mem_[ADDRSIZE*NCONTEXT]; #define mem(x,k) mem_[(x)*NCONTEXT+k] int co_[ADDRSIZE*NCONTEXT]; #define co(x,k) co_[(x)*NCONTEXT+k] int delta_[ADDRSIZE*NCONTEXT]; #define delta(x,k) delta_[(x)*NCONTEXT+k] // declare arrays for local buffer and observed writes int buff_[NPROC*ADDRSIZE]; #define buff(x,k) buff_[(x)*ADDRSIZE+k] int pw_[NPROC*ADDRSIZE]; #define pw(x,k) pw_[(x)*ADDRSIZE+k] // declare arrays for context stamps char cr_[NPROC*ADDRSIZE]; #define cr(x,k) cr_[(x)*ADDRSIZE+k] char iw_[NPROC*ADDRSIZE]; #define iw(x,k) iw_[(x)*ADDRSIZE+k] char cw_[NPROC*ADDRSIZE]; #define cw(x,k) cw_[(x)*ADDRSIZE+k] char cx_[NPROC*ADDRSIZE]; #define cx(x,k) cx_[(x)*ADDRSIZE+k] char is_[NPROC*ADDRSIZE]; #define is(x,k) is_[(x)*ADDRSIZE+k] char cs_[NPROC*ADDRSIZE]; #define cs(x,k) cs_[(x)*ADDRSIZE+k] char crmax_[NPROC*ADDRSIZE]; #define crmax(x,k) crmax_[(x)*ADDRSIZE+k] char sforbid_[ADDRSIZE*NCONTEXT]; #define sforbid(x,k) sforbid_[(x)*NCONTEXT+k] // declare arrays for synchronizations int cl[NPROC]; int cdy[NPROC]; int cds[NPROC]; int cdl[NPROC]; int cisb[NPROC]; int caddr[NPROC]; int cctrl[NPROC]; int cstart[NPROC]; int creturn[NPROC]; // declare arrays for contexts activity int active[NCONTEXT]; int ctx_used[NCONTEXT]; __LOCALS__ buff(0,0) = 0; pw(0,0) = 0; cr(0,0) = 0; iw(0,0) = 0; cw(0,0) = 0; cx(0,0) = 0; is(0,0) = 0; cs(0,0) = 0; crmax(0,0) = 0; buff(0,1) = 0; pw(0,1) = 0; cr(0,1) = 0; iw(0,1) = 0; cw(0,1) = 0; cx(0,1) = 0; is(0,1) = 0; cs(0,1) = 0; crmax(0,1) = 0; buff(0,2) = 0; pw(0,2) = 0; cr(0,2) = 0; iw(0,2) = 0; cw(0,2) = 0; cx(0,2) = 0; is(0,2) = 0; cs(0,2) = 0; crmax(0,2) = 0; buff(0,3) = 0; pw(0,3) = 0; cr(0,3) = 0; iw(0,3) = 0; cw(0,3) = 0; cx(0,3) = 0; is(0,3) = 0; cs(0,3) = 0; crmax(0,3) = 0; buff(0,4) = 0; pw(0,4) = 0; cr(0,4) = 0; iw(0,4) = 0; cw(0,4) = 0; cx(0,4) = 0; is(0,4) = 0; cs(0,4) = 0; crmax(0,4) = 0; buff(0,5) = 0; pw(0,5) = 0; cr(0,5) = 0; iw(0,5) = 0; cw(0,5) = 0; cx(0,5) = 0; is(0,5) = 0; cs(0,5) = 0; crmax(0,5) = 0; buff(0,6) = 0; pw(0,6) = 0; cr(0,6) = 0; iw(0,6) = 0; cw(0,6) = 0; cx(0,6) = 0; is(0,6) = 0; cs(0,6) = 0; crmax(0,6) = 0; buff(0,7) = 0; pw(0,7) = 0; cr(0,7) = 0; iw(0,7) = 0; cw(0,7) = 0; cx(0,7) = 0; is(0,7) = 0; cs(0,7) = 0; crmax(0,7) = 0; cl[0] = 0; cdy[0] = 0; cds[0] = 0; cdl[0] = 0; cisb[0] = 0; caddr[0] = 0; cctrl[0] = 0; cstart[0] = get_rng(0,NCONTEXT-1); creturn[0] = get_rng(0,NCONTEXT-1); buff(1,0) = 0; pw(1,0) = 0; cr(1,0) = 0; iw(1,0) = 0; cw(1,0) = 0; cx(1,0) = 0; is(1,0) = 0; cs(1,0) = 0; crmax(1,0) = 0; buff(1,1) = 0; pw(1,1) = 0; cr(1,1) = 0; iw(1,1) = 0; cw(1,1) = 0; cx(1,1) = 0; is(1,1) = 0; cs(1,1) = 0; crmax(1,1) = 0; buff(1,2) = 0; pw(1,2) = 0; cr(1,2) = 0; iw(1,2) = 0; cw(1,2) = 0; cx(1,2) = 0; is(1,2) = 0; cs(1,2) = 0; crmax(1,2) = 0; buff(1,3) = 0; pw(1,3) = 0; cr(1,3) = 0; iw(1,3) = 0; cw(1,3) = 0; cx(1,3) = 0; is(1,3) = 0; cs(1,3) = 0; crmax(1,3) = 0; buff(1,4) = 0; pw(1,4) = 0; cr(1,4) = 0; iw(1,4) = 0; cw(1,4) = 0; cx(1,4) = 0; is(1,4) = 0; cs(1,4) = 0; crmax(1,4) = 0; buff(1,5) = 0; pw(1,5) = 0; cr(1,5) = 0; iw(1,5) = 0; cw(1,5) = 0; cx(1,5) = 0; is(1,5) = 0; cs(1,5) = 0; crmax(1,5) = 0; buff(1,6) = 0; pw(1,6) = 0; cr(1,6) = 0; iw(1,6) = 0; cw(1,6) = 0; cx(1,6) = 0; is(1,6) = 0; cs(1,6) = 0; crmax(1,6) = 0; buff(1,7) = 0; pw(1,7) = 0; cr(1,7) = 0; iw(1,7) = 0; cw(1,7) = 0; cx(1,7) = 0; is(1,7) = 0; cs(1,7) = 0; crmax(1,7) = 0; cl[1] = 0; cdy[1] = 0; cds[1] = 0; cdl[1] = 0; cisb[1] = 0; caddr[1] = 0; cctrl[1] = 0; cstart[1] = get_rng(0,NCONTEXT-1); creturn[1] = get_rng(0,NCONTEXT-1); buff(2,0) = 0; pw(2,0) = 0; cr(2,0) = 0; iw(2,0) = 0; cw(2,0) = 0; cx(2,0) = 0; is(2,0) = 0; cs(2,0) = 0; crmax(2,0) = 0; buff(2,1) = 0; pw(2,1) = 0; cr(2,1) = 0; iw(2,1) = 0; cw(2,1) = 0; cx(2,1) = 0; is(2,1) = 0; cs(2,1) = 0; crmax(2,1) = 0; buff(2,2) = 0; pw(2,2) = 0; cr(2,2) = 0; iw(2,2) = 0; cw(2,2) = 0; cx(2,2) = 0; is(2,2) = 0; cs(2,2) = 0; crmax(2,2) = 0; buff(2,3) = 0; pw(2,3) = 0; cr(2,3) = 0; iw(2,3) = 0; cw(2,3) = 0; cx(2,3) = 0; is(2,3) = 0; cs(2,3) = 0; crmax(2,3) = 0; buff(2,4) = 0; pw(2,4) = 0; cr(2,4) = 0; iw(2,4) = 0; cw(2,4) = 0; cx(2,4) = 0; is(2,4) = 0; cs(2,4) = 0; crmax(2,4) = 0; buff(2,5) = 0; pw(2,5) = 0; cr(2,5) = 0; iw(2,5) = 0; cw(2,5) = 0; cx(2,5) = 0; is(2,5) = 0; cs(2,5) = 0; crmax(2,5) = 0; buff(2,6) = 0; pw(2,6) = 0; cr(2,6) = 0; iw(2,6) = 0; cw(2,6) = 0; cx(2,6) = 0; is(2,6) = 0; cs(2,6) = 0; crmax(2,6) = 0; buff(2,7) = 0; pw(2,7) = 0; cr(2,7) = 0; iw(2,7) = 0; cw(2,7) = 0; cx(2,7) = 0; is(2,7) = 0; cs(2,7) = 0; crmax(2,7) = 0; cl[2] = 0; cdy[2] = 0; cds[2] = 0; cdl[2] = 0; cisb[2] = 0; caddr[2] = 0; cctrl[2] = 0; cstart[2] = get_rng(0,NCONTEXT-1); creturn[2] = get_rng(0,NCONTEXT-1); // Dumping initializations mem(0+0,0) = 0; mem(0+1,0) = 0; mem(0+2,0) = 0; mem(3+0,0) = 0; mem(4+0,0) = 0; mem(5+0,0) = 0; mem(6+0,0) = 0; mem(7+0,0) = 0; // Dumping context matching equalities co(0,0) = 0; delta(0,0) = -1; co(1,0) = 0; delta(1,0) = -1; co(2,0) = 0; delta(2,0) = -1; co(3,0) = 0; delta(3,0) = -1; co(4,0) = 0; delta(4,0) = -1; co(5,0) = 0; delta(5,0) = -1; co(6,0) = 0; delta(6,0) = -1; co(7,0) = 0; delta(7,0) = -1; // Dumping thread 1 int ret_thread_1 = 0; cdy[1] = get_rng(0,NCONTEXT-1); ASSUME(cdy[1] >= cstart[1]); T1BLOCK0: // call void @llvm.dbg.value(metadata i8* %arg, metadata !37, metadata !DIExpression()), !dbg !46 // br label %label_1, !dbg !47 goto T1BLOCK1; T1BLOCK1: // call void @llvm.dbg.label(metadata !45), !dbg !48 // call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 0), metadata !38, metadata !DIExpression()), !dbg !49 // call void @llvm.dbg.value(metadata i64 1, metadata !41, metadata !DIExpression()), !dbg !49 // store atomic i64 1, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 0) monotonic, align 8, !dbg !50 // ST: Guess iw(1,0) = get_rng(0,NCONTEXT-1);// 1 ASSIGN STIW old_cw = cw(1,0); cw(1,0) = get_rng(0,NCONTEXT-1);// 1 ASSIGN STCOM // Check ASSUME(active[iw(1,0)] == 1); ASSUME(active[cw(1,0)] == 1); ASSUME(sforbid(0,cw(1,0))== 0); ASSUME(iw(1,0) >= 0); ASSUME(iw(1,0) >= 0); ASSUME(cw(1,0) >= iw(1,0)); ASSUME(cw(1,0) >= old_cw); ASSUME(cw(1,0) >= cr(1,0)); ASSUME(cw(1,0) >= cl[1]); ASSUME(cw(1,0) >= cisb[1]); ASSUME(cw(1,0) >= cdy[1]); ASSUME(cw(1,0) >= cdl[1]); ASSUME(cw(1,0) >= cds[1]); ASSUME(cw(1,0) >= cctrl[1]); ASSUME(cw(1,0) >= caddr[1]); // Update caddr[1] = max(caddr[1],0); buff(1,0) = 1; mem(0,cw(1,0)) = 1; co(0,cw(1,0))+=1; delta(0,cw(1,0)) = -1; ASSUME(creturn[1] >= cw(1,0)); // call void (...) @dmbsy(), !dbg !51 // dumbsy: Guess old_cdy = cdy[1]; cdy[1] = get_rng(0,NCONTEXT-1); // Check ASSUME(cdy[1] >= old_cdy); ASSUME(cdy[1] >= cisb[1]); ASSUME(cdy[1] >= cdl[1]); ASSUME(cdy[1] >= cds[1]); ASSUME(cdy[1] >= cctrl[1]); ASSUME(cdy[1] >= cw(1,0+0)); ASSUME(cdy[1] >= cw(1,0+1)); ASSUME(cdy[1] >= cw(1,0+2)); ASSUME(cdy[1] >= cw(1,3+0)); ASSUME(cdy[1] >= cw(1,4+0)); ASSUME(cdy[1] >= cw(1,5+0)); ASSUME(cdy[1] >= cw(1,6+0)); ASSUME(cdy[1] >= cw(1,7+0)); ASSUME(cdy[1] >= cr(1,0+0)); ASSUME(cdy[1] >= cr(1,0+1)); ASSUME(cdy[1] >= cr(1,0+2)); ASSUME(cdy[1] >= cr(1,3+0)); ASSUME(cdy[1] >= cr(1,4+0)); ASSUME(cdy[1] >= cr(1,5+0)); ASSUME(cdy[1] >= cr(1,6+0)); ASSUME(cdy[1] >= cr(1,7+0)); ASSUME(creturn[1] >= cdy[1]); // call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 1), metadata !42, metadata !DIExpression()), !dbg !52 // call void @llvm.dbg.value(metadata i64 1, metadata !44, metadata !DIExpression()), !dbg !52 // store atomic i64 1, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 1) monotonic, align 8, !dbg !53 // ST: Guess iw(1,0+1*1) = get_rng(0,NCONTEXT-1);// 1 ASSIGN STIW old_cw = cw(1,0+1*1); cw(1,0+1*1) = get_rng(0,NCONTEXT-1);// 1 ASSIGN STCOM // Check ASSUME(active[iw(1,0+1*1)] == 1); ASSUME(active[cw(1,0+1*1)] == 1); ASSUME(sforbid(0+1*1,cw(1,0+1*1))== 0); ASSUME(iw(1,0+1*1) >= 0); ASSUME(iw(1,0+1*1) >= 0); ASSUME(cw(1,0+1*1) >= iw(1,0+1*1)); ASSUME(cw(1,0+1*1) >= old_cw); ASSUME(cw(1,0+1*1) >= cr(1,0+1*1)); ASSUME(cw(1,0+1*1) >= cl[1]); ASSUME(cw(1,0+1*1) >= cisb[1]); ASSUME(cw(1,0+1*1) >= cdy[1]); ASSUME(cw(1,0+1*1) >= cdl[1]); ASSUME(cw(1,0+1*1) >= cds[1]); ASSUME(cw(1,0+1*1) >= cctrl[1]); ASSUME(cw(1,0+1*1) >= caddr[1]); // Update caddr[1] = max(caddr[1],0); buff(1,0+1*1) = 1; mem(0+1*1,cw(1,0+1*1)) = 1; co(0+1*1,cw(1,0+1*1))+=1; delta(0+1*1,cw(1,0+1*1)) = -1; ASSUME(creturn[1] >= cw(1,0+1*1)); // ret i8* null, !dbg !54 ret_thread_1 = (- 1); // Dumping thread 2 int ret_thread_2 = 0; cdy[2] = get_rng(0,NCONTEXT-1); ASSUME(cdy[2] >= cstart[2]); T2BLOCK0: // call void @llvm.dbg.value(metadata i8* %arg, metadata !57, metadata !DIExpression()), !dbg !97 // br label %label_2, !dbg !79 goto T2BLOCK1; T2BLOCK1: // call void @llvm.dbg.label(metadata !95), !dbg !99 // call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 1), metadata !60, metadata !DIExpression()), !dbg !100 // %0 = load atomic i64, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 1) monotonic, align 8, !dbg !82 // LD: Guess old_cr = cr(2,0+1*1); cr(2,0+1*1) = get_rng(0,NCONTEXT-1);// 2 ASSIGN LDCOM // Check ASSUME(active[cr(2,0+1*1)] == 2); ASSUME(cr(2,0+1*1) >= iw(2,0+1*1)); ASSUME(cr(2,0+1*1) >= 0); ASSUME(cr(2,0+1*1) >= cdy[2]); ASSUME(cr(2,0+1*1) >= cisb[2]); ASSUME(cr(2,0+1*1) >= cdl[2]); ASSUME(cr(2,0+1*1) >= cl[2]); // Update creg_r0 = cr(2,0+1*1); crmax(2,0+1*1) = max(crmax(2,0+1*1),cr(2,0+1*1)); caddr[2] = max(caddr[2],0); if(cr(2,0+1*1) < cw(2,0+1*1)) { r0 = buff(2,0+1*1); } else { if(pw(2,0+1*1) != co(0+1*1,cr(2,0+1*1))) { ASSUME(cr(2,0+1*1) >= old_cr); } pw(2,0+1*1) = co(0+1*1,cr(2,0+1*1)); r0 = mem(0+1*1,cr(2,0+1*1)); } ASSUME(creturn[2] >= cr(2,0+1*1)); // call void @llvm.dbg.value(metadata i64 %0, metadata !62, metadata !DIExpression()), !dbg !100 // %conv = trunc i64 %0 to i32, !dbg !83 // call void @llvm.dbg.value(metadata i32 %conv, metadata !58, metadata !DIExpression()), !dbg !97 // call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 1), metadata !63, metadata !DIExpression()), !dbg !103 // call void @llvm.dbg.value(metadata i64 2, metadata !65, metadata !DIExpression()), !dbg !103 // store atomic i64 2, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 1) monotonic, align 8, !dbg !85 // ST: Guess iw(2,0+1*1) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STIW old_cw = cw(2,0+1*1); cw(2,0+1*1) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STCOM // Check ASSUME(active[iw(2,0+1*1)] == 2); ASSUME(active[cw(2,0+1*1)] == 2); ASSUME(sforbid(0+1*1,cw(2,0+1*1))== 0); ASSUME(iw(2,0+1*1) >= 0); ASSUME(iw(2,0+1*1) >= 0); ASSUME(cw(2,0+1*1) >= iw(2,0+1*1)); ASSUME(cw(2,0+1*1) >= old_cw); ASSUME(cw(2,0+1*1) >= cr(2,0+1*1)); ASSUME(cw(2,0+1*1) >= cl[2]); ASSUME(cw(2,0+1*1) >= cisb[2]); ASSUME(cw(2,0+1*1) >= cdy[2]); ASSUME(cw(2,0+1*1) >= cdl[2]); ASSUME(cw(2,0+1*1) >= cds[2]); ASSUME(cw(2,0+1*1) >= cctrl[2]); ASSUME(cw(2,0+1*1) >= caddr[2]); // Update caddr[2] = max(caddr[2],0); buff(2,0+1*1) = 2; mem(0+1*1,cw(2,0+1*1)) = 2; co(0+1*1,cw(2,0+1*1))+=1; delta(0+1*1,cw(2,0+1*1)) = -1; ASSUME(creturn[2] >= cw(2,0+1*1)); // call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 1), metadata !67, metadata !DIExpression()), !dbg !105 // %1 = load atomic i64, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 1) monotonic, align 8, !dbg !87 // LD: Guess old_cr = cr(2,0+1*1); cr(2,0+1*1) = get_rng(0,NCONTEXT-1);// 2 ASSIGN LDCOM // Check ASSUME(active[cr(2,0+1*1)] == 2); ASSUME(cr(2,0+1*1) >= iw(2,0+1*1)); ASSUME(cr(2,0+1*1) >= 0); ASSUME(cr(2,0+1*1) >= cdy[2]); ASSUME(cr(2,0+1*1) >= cisb[2]); ASSUME(cr(2,0+1*1) >= cdl[2]); ASSUME(cr(2,0+1*1) >= cl[2]); // Update creg_r1 = cr(2,0+1*1); crmax(2,0+1*1) = max(crmax(2,0+1*1),cr(2,0+1*1)); caddr[2] = max(caddr[2],0); if(cr(2,0+1*1) < cw(2,0+1*1)) { r1 = buff(2,0+1*1); } else { if(pw(2,0+1*1) != co(0+1*1,cr(2,0+1*1))) { ASSUME(cr(2,0+1*1) >= old_cr); } pw(2,0+1*1) = co(0+1*1,cr(2,0+1*1)); r1 = mem(0+1*1,cr(2,0+1*1)); } ASSUME(creturn[2] >= cr(2,0+1*1)); // call void @llvm.dbg.value(metadata i64 %1, metadata !69, metadata !DIExpression()), !dbg !105 // %conv4 = trunc i64 %1 to i32, !dbg !88 // call void @llvm.dbg.value(metadata i32 %conv4, metadata !66, metadata !DIExpression()), !dbg !97 // %tobool = icmp ne i32 %conv4, 0, !dbg !89 // br i1 %tobool, label %if.then, label %if.else, !dbg !91 old_cctrl = cctrl[2]; cctrl[2] = get_rng(0,NCONTEXT-1); ASSUME(cctrl[2] >= old_cctrl); ASSUME(cctrl[2] >= creg_r1); ASSUME(cctrl[2] >= 0); if((r1!=0)) { goto T2BLOCK2; } else { goto T2BLOCK3; } T2BLOCK2: // br label %lbl_LC00, !dbg !92 goto T2BLOCK4; T2BLOCK3: // br label %lbl_LC00, !dbg !93 goto T2BLOCK4; T2BLOCK4: // call void @llvm.dbg.label(metadata !96), !dbg !113 // call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 2), metadata !71, metadata !DIExpression()), !dbg !114 // %2 = load atomic i64, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 2) monotonic, align 8, !dbg !96 // LD: Guess old_cr = cr(2,0+2*1); cr(2,0+2*1) = get_rng(0,NCONTEXT-1);// 2 ASSIGN LDCOM // Check ASSUME(active[cr(2,0+2*1)] == 2); ASSUME(cr(2,0+2*1) >= iw(2,0+2*1)); ASSUME(cr(2,0+2*1) >= 0); ASSUME(cr(2,0+2*1) >= cdy[2]); ASSUME(cr(2,0+2*1) >= cisb[2]); ASSUME(cr(2,0+2*1) >= cdl[2]); ASSUME(cr(2,0+2*1) >= cl[2]); // Update creg_r2 = cr(2,0+2*1); crmax(2,0+2*1) = max(crmax(2,0+2*1),cr(2,0+2*1)); caddr[2] = max(caddr[2],0); if(cr(2,0+2*1) < cw(2,0+2*1)) { r2 = buff(2,0+2*1); } else { if(pw(2,0+2*1) != co(0+2*1,cr(2,0+2*1))) { ASSUME(cr(2,0+2*1) >= old_cr); } pw(2,0+2*1) = co(0+2*1,cr(2,0+2*1)); r2 = mem(0+2*1,cr(2,0+2*1)); } ASSUME(creturn[2] >= cr(2,0+2*1)); // call void @llvm.dbg.value(metadata i64 %2, metadata !73, metadata !DIExpression()), !dbg !114 // %conv8 = trunc i64 %2 to i32, !dbg !97 // call void @llvm.dbg.value(metadata i32 %conv8, metadata !70, metadata !DIExpression()), !dbg !97 // call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 2), metadata !75, metadata !DIExpression()), !dbg !117 // %3 = load atomic i64, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 2) monotonic, align 8, !dbg !99 // LD: Guess old_cr = cr(2,0+2*1); cr(2,0+2*1) = get_rng(0,NCONTEXT-1);// 2 ASSIGN LDCOM // Check ASSUME(active[cr(2,0+2*1)] == 2); ASSUME(cr(2,0+2*1) >= iw(2,0+2*1)); ASSUME(cr(2,0+2*1) >= 0); ASSUME(cr(2,0+2*1) >= cdy[2]); ASSUME(cr(2,0+2*1) >= cisb[2]); ASSUME(cr(2,0+2*1) >= cdl[2]); ASSUME(cr(2,0+2*1) >= cl[2]); // Update creg_r3 = cr(2,0+2*1); crmax(2,0+2*1) = max(crmax(2,0+2*1),cr(2,0+2*1)); caddr[2] = max(caddr[2],0); if(cr(2,0+2*1) < cw(2,0+2*1)) { r3 = buff(2,0+2*1); } else { if(pw(2,0+2*1) != co(0+2*1,cr(2,0+2*1))) { ASSUME(cr(2,0+2*1) >= old_cr); } pw(2,0+2*1) = co(0+2*1,cr(2,0+2*1)); r3 = mem(0+2*1,cr(2,0+2*1)); } ASSUME(creturn[2] >= cr(2,0+2*1)); // call void @llvm.dbg.value(metadata i64 %3, metadata !77, metadata !DIExpression()), !dbg !117 // %conv12 = trunc i64 %3 to i32, !dbg !100 // call void @llvm.dbg.value(metadata i32 %conv12, metadata !74, metadata !DIExpression()), !dbg !97 // %xor = xor i32 %conv12, %conv12, !dbg !101 creg_r4 = max(creg_r3,creg_r3); ASSUME(active[creg_r4] == 2); r4 = r3 ^ r3; // call void @llvm.dbg.value(metadata i32 %xor, metadata !78, metadata !DIExpression()), !dbg !97 // %add = add nsw i32 0, %xor, !dbg !102 creg_r5 = max(0,creg_r4); ASSUME(active[creg_r5] == 2); r5 = 0 + r4; // %idxprom = sext i32 %add to i64, !dbg !102 // %arrayidx = getelementptr inbounds [3 x i64], [3 x i64]* @vars, i64 0, i64 %idxprom, !dbg !102 r6 = 0+r5*1; ASSUME(creg_r6 >= 0); ASSUME(creg_r6 >= creg_r5); ASSUME(active[creg_r6] == 2); // call void @llvm.dbg.value(metadata i64* %arrayidx, metadata !80, metadata !DIExpression()), !dbg !122 // %4 = load atomic i64, i64* %arrayidx monotonic, align 8, !dbg !102 // LD: Guess old_cr = cr(2,r6); cr(2,r6) = get_rng(0,NCONTEXT-1);// 2 ASSIGN LDCOM // Check ASSUME(active[cr(2,r6)] == 2); ASSUME(cr(2,r6) >= iw(2,r6)); ASSUME(cr(2,r6) >= creg_r6); ASSUME(cr(2,r6) >= cdy[2]); ASSUME(cr(2,r6) >= cisb[2]); ASSUME(cr(2,r6) >= cdl[2]); ASSUME(cr(2,r6) >= cl[2]); // Update creg_r7 = cr(2,r6); crmax(2,r6) = max(crmax(2,r6),cr(2,r6)); caddr[2] = max(caddr[2],creg_r6); if(cr(2,r6) < cw(2,r6)) { r7 = buff(2,r6); } else { if(pw(2,r6) != co(r6,cr(2,r6))) { ASSUME(cr(2,r6) >= old_cr); } pw(2,r6) = co(r6,cr(2,r6)); r7 = mem(r6,cr(2,r6)); } ASSUME(creturn[2] >= cr(2,r6)); // call void @llvm.dbg.value(metadata i64 %4, metadata !82, metadata !DIExpression()), !dbg !122 // %conv16 = trunc i64 %4 to i32, !dbg !104 // call void @llvm.dbg.value(metadata i32 %conv16, metadata !79, metadata !DIExpression()), !dbg !97 // %cmp = icmp eq i32 %conv, 1, !dbg !105 // %conv17 = zext i1 %cmp to i32, !dbg !105 // call void @llvm.dbg.value(metadata i32 %conv17, metadata !83, metadata !DIExpression()), !dbg !97 // call void @llvm.dbg.value(metadata i64* @atom_1_X0_1, metadata !84, metadata !DIExpression()), !dbg !125 // %5 = zext i32 %conv17 to i64 // call void @llvm.dbg.value(metadata i64 %5, metadata !86, metadata !DIExpression()), !dbg !125 // store atomic i64 %5, i64* @atom_1_X0_1 seq_cst, align 8, !dbg !107 // ST: Guess iw(2,3) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STIW old_cw = cw(2,3); cw(2,3) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STCOM // Check ASSUME(active[iw(2,3)] == 2); ASSUME(active[cw(2,3)] == 2); ASSUME(sforbid(3,cw(2,3))== 0); ASSUME(iw(2,3) >= max(creg_r0,0)); ASSUME(iw(2,3) >= 0); ASSUME(cw(2,3) >= iw(2,3)); ASSUME(cw(2,3) >= old_cw); ASSUME(cw(2,3) >= cr(2,3)); ASSUME(cw(2,3) >= cl[2]); ASSUME(cw(2,3) >= cisb[2]); ASSUME(cw(2,3) >= cdy[2]); ASSUME(cw(2,3) >= cdl[2]); ASSUME(cw(2,3) >= cds[2]); ASSUME(cw(2,3) >= cctrl[2]); ASSUME(cw(2,3) >= caddr[2]); // Update caddr[2] = max(caddr[2],0); buff(2,3) = (r0==1); mem(3,cw(2,3)) = (r0==1); co(3,cw(2,3))+=1; delta(3,cw(2,3)) = -1; ASSUME(creturn[2] >= cw(2,3)); // %cmp21 = icmp eq i32 %conv4, 2, !dbg !108 // %conv22 = zext i1 %cmp21 to i32, !dbg !108 // call void @llvm.dbg.value(metadata i32 %conv22, metadata !87, metadata !DIExpression()), !dbg !97 // call void @llvm.dbg.value(metadata i64* @atom_1_X3_2, metadata !88, metadata !DIExpression()), !dbg !128 // %6 = zext i32 %conv22 to i64 // call void @llvm.dbg.value(metadata i64 %6, metadata !90, metadata !DIExpression()), !dbg !128 // store atomic i64 %6, i64* @atom_1_X3_2 seq_cst, align 8, !dbg !110 // ST: Guess iw(2,4) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STIW old_cw = cw(2,4); cw(2,4) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STCOM // Check ASSUME(active[iw(2,4)] == 2); ASSUME(active[cw(2,4)] == 2); ASSUME(sforbid(4,cw(2,4))== 0); ASSUME(iw(2,4) >= max(creg_r1,0)); ASSUME(iw(2,4) >= 0); ASSUME(cw(2,4) >= iw(2,4)); ASSUME(cw(2,4) >= old_cw); ASSUME(cw(2,4) >= cr(2,4)); ASSUME(cw(2,4) >= cl[2]); ASSUME(cw(2,4) >= cisb[2]); ASSUME(cw(2,4) >= cdy[2]); ASSUME(cw(2,4) >= cdl[2]); ASSUME(cw(2,4) >= cds[2]); ASSUME(cw(2,4) >= cctrl[2]); ASSUME(cw(2,4) >= caddr[2]); // Update caddr[2] = max(caddr[2],0); buff(2,4) = (r1==2); mem(4,cw(2,4)) = (r1==2); co(4,cw(2,4))+=1; delta(4,cw(2,4)) = -1; ASSUME(creturn[2] >= cw(2,4)); // %cmp26 = icmp eq i32 %conv16, 0, !dbg !111 // %conv27 = zext i1 %cmp26 to i32, !dbg !111 // call void @llvm.dbg.value(metadata i32 %conv27, metadata !91, metadata !DIExpression()), !dbg !97 // call void @llvm.dbg.value(metadata i64* @atom_1_X8_0, metadata !92, metadata !DIExpression()), !dbg !131 // %7 = zext i32 %conv27 to i64 // call void @llvm.dbg.value(metadata i64 %7, metadata !94, metadata !DIExpression()), !dbg !131 // store atomic i64 %7, i64* @atom_1_X8_0 seq_cst, align 8, !dbg !113 // ST: Guess iw(2,5) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STIW old_cw = cw(2,5); cw(2,5) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STCOM // Check ASSUME(active[iw(2,5)] == 2); ASSUME(active[cw(2,5)] == 2); ASSUME(sforbid(5,cw(2,5))== 0); ASSUME(iw(2,5) >= max(creg_r7,0)); ASSUME(iw(2,5) >= 0); ASSUME(cw(2,5) >= iw(2,5)); ASSUME(cw(2,5) >= old_cw); ASSUME(cw(2,5) >= cr(2,5)); ASSUME(cw(2,5) >= cl[2]); ASSUME(cw(2,5) >= cisb[2]); ASSUME(cw(2,5) >= cdy[2]); ASSUME(cw(2,5) >= cdl[2]); ASSUME(cw(2,5) >= cds[2]); ASSUME(cw(2,5) >= cctrl[2]); ASSUME(cw(2,5) >= caddr[2]); // Update caddr[2] = max(caddr[2],0); buff(2,5) = (r7==0); mem(5,cw(2,5)) = (r7==0); co(5,cw(2,5))+=1; delta(5,cw(2,5)) = -1; ASSUME(creturn[2] >= cw(2,5)); // ret i8* null, !dbg !114 ret_thread_2 = (- 1); // Dumping thread 0 int ret_thread_0 = 0; cdy[0] = get_rng(0,NCONTEXT-1); ASSUME(cdy[0] >= cstart[0]); T0BLOCK0: // %thr0 = alloca i64, align 8 // %thr1 = alloca i64, align 8 // call void @llvm.dbg.value(metadata i32 %argc, metadata !141, metadata !DIExpression()), !dbg !192 // call void @llvm.dbg.value(metadata i8** %argv, metadata !142, metadata !DIExpression()), !dbg !192 // %0 = bitcast i64* %thr0 to i8*, !dbg !94 // call void @llvm.lifetime.start.p0i8(i64 8, i8* %0) #7, !dbg !94 // call void @llvm.dbg.declare(metadata i64* %thr0, metadata !143, metadata !DIExpression()), !dbg !194 // %1 = bitcast i64* %thr1 to i8*, !dbg !96 // call void @llvm.lifetime.start.p0i8(i64 8, i8* %1) #7, !dbg !96 // call void @llvm.dbg.declare(metadata i64* %thr1, metadata !147, metadata !DIExpression()), !dbg !196 // call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 2), metadata !148, metadata !DIExpression()), !dbg !197 // call void @llvm.dbg.value(metadata i64 0, metadata !150, metadata !DIExpression()), !dbg !197 // store atomic i64 0, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 2) monotonic, align 8, !dbg !99 // ST: Guess iw(0,0+2*1) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW old_cw = cw(0,0+2*1); cw(0,0+2*1) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM // Check ASSUME(active[iw(0,0+2*1)] == 0); ASSUME(active[cw(0,0+2*1)] == 0); ASSUME(sforbid(0+2*1,cw(0,0+2*1))== 0); ASSUME(iw(0,0+2*1) >= 0); ASSUME(iw(0,0+2*1) >= 0); ASSUME(cw(0,0+2*1) >= iw(0,0+2*1)); ASSUME(cw(0,0+2*1) >= old_cw); ASSUME(cw(0,0+2*1) >= cr(0,0+2*1)); ASSUME(cw(0,0+2*1) >= cl[0]); ASSUME(cw(0,0+2*1) >= cisb[0]); ASSUME(cw(0,0+2*1) >= cdy[0]); ASSUME(cw(0,0+2*1) >= cdl[0]); ASSUME(cw(0,0+2*1) >= cds[0]); ASSUME(cw(0,0+2*1) >= cctrl[0]); ASSUME(cw(0,0+2*1) >= caddr[0]); // Update caddr[0] = max(caddr[0],0); buff(0,0+2*1) = 0; mem(0+2*1,cw(0,0+2*1)) = 0; co(0+2*1,cw(0,0+2*1))+=1; delta(0+2*1,cw(0,0+2*1)) = -1; ASSUME(creturn[0] >= cw(0,0+2*1)); // call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 1), metadata !151, metadata !DIExpression()), !dbg !199 // call void @llvm.dbg.value(metadata i64 0, metadata !153, metadata !DIExpression()), !dbg !199 // store atomic i64 0, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 1) monotonic, align 8, !dbg !101 // ST: Guess iw(0,0+1*1) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW old_cw = cw(0,0+1*1); cw(0,0+1*1) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM // Check ASSUME(active[iw(0,0+1*1)] == 0); ASSUME(active[cw(0,0+1*1)] == 0); ASSUME(sforbid(0+1*1,cw(0,0+1*1))== 0); ASSUME(iw(0,0+1*1) >= 0); ASSUME(iw(0,0+1*1) >= 0); ASSUME(cw(0,0+1*1) >= iw(0,0+1*1)); ASSUME(cw(0,0+1*1) >= old_cw); ASSUME(cw(0,0+1*1) >= cr(0,0+1*1)); ASSUME(cw(0,0+1*1) >= cl[0]); ASSUME(cw(0,0+1*1) >= cisb[0]); ASSUME(cw(0,0+1*1) >= cdy[0]); ASSUME(cw(0,0+1*1) >= cdl[0]); ASSUME(cw(0,0+1*1) >= cds[0]); ASSUME(cw(0,0+1*1) >= cctrl[0]); ASSUME(cw(0,0+1*1) >= caddr[0]); // Update caddr[0] = max(caddr[0],0); buff(0,0+1*1) = 0; mem(0+1*1,cw(0,0+1*1)) = 0; co(0+1*1,cw(0,0+1*1))+=1; delta(0+1*1,cw(0,0+1*1)) = -1; ASSUME(creturn[0] >= cw(0,0+1*1)); // call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 0), metadata !154, metadata !DIExpression()), !dbg !201 // call void @llvm.dbg.value(metadata i64 0, metadata !156, metadata !DIExpression()), !dbg !201 // store atomic i64 0, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 0) monotonic, align 8, !dbg !103 // ST: Guess iw(0,0) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW old_cw = cw(0,0); cw(0,0) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM // Check ASSUME(active[iw(0,0)] == 0); ASSUME(active[cw(0,0)] == 0); ASSUME(sforbid(0,cw(0,0))== 0); ASSUME(iw(0,0) >= 0); ASSUME(iw(0,0) >= 0); ASSUME(cw(0,0) >= iw(0,0)); ASSUME(cw(0,0) >= old_cw); ASSUME(cw(0,0) >= cr(0,0)); ASSUME(cw(0,0) >= cl[0]); ASSUME(cw(0,0) >= cisb[0]); ASSUME(cw(0,0) >= cdy[0]); ASSUME(cw(0,0) >= cdl[0]); ASSUME(cw(0,0) >= cds[0]); ASSUME(cw(0,0) >= cctrl[0]); ASSUME(cw(0,0) >= caddr[0]); // Update caddr[0] = max(caddr[0],0); buff(0,0) = 0; mem(0,cw(0,0)) = 0; co(0,cw(0,0))+=1; delta(0,cw(0,0)) = -1; ASSUME(creturn[0] >= cw(0,0)); // call void @llvm.dbg.value(metadata i64* @atom_1_X0_1, metadata !157, metadata !DIExpression()), !dbg !203 // call void @llvm.dbg.value(metadata i64 0, metadata !159, metadata !DIExpression()), !dbg !203 // store atomic i64 0, i64* @atom_1_X0_1 monotonic, align 8, !dbg !105 // ST: Guess iw(0,3) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW old_cw = cw(0,3); cw(0,3) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM // Check ASSUME(active[iw(0,3)] == 0); ASSUME(active[cw(0,3)] == 0); ASSUME(sforbid(3,cw(0,3))== 0); ASSUME(iw(0,3) >= 0); ASSUME(iw(0,3) >= 0); ASSUME(cw(0,3) >= iw(0,3)); ASSUME(cw(0,3) >= old_cw); ASSUME(cw(0,3) >= cr(0,3)); ASSUME(cw(0,3) >= cl[0]); ASSUME(cw(0,3) >= cisb[0]); ASSUME(cw(0,3) >= cdy[0]); ASSUME(cw(0,3) >= cdl[0]); ASSUME(cw(0,3) >= cds[0]); ASSUME(cw(0,3) >= cctrl[0]); ASSUME(cw(0,3) >= caddr[0]); // Update caddr[0] = max(caddr[0],0); buff(0,3) = 0; mem(3,cw(0,3)) = 0; co(3,cw(0,3))+=1; delta(3,cw(0,3)) = -1; ASSUME(creturn[0] >= cw(0,3)); // call void @llvm.dbg.value(metadata i64* @atom_1_X3_2, metadata !160, metadata !DIExpression()), !dbg !205 // call void @llvm.dbg.value(metadata i64 0, metadata !162, metadata !DIExpression()), !dbg !205 // store atomic i64 0, i64* @atom_1_X3_2 monotonic, align 8, !dbg !107 // ST: Guess iw(0,4) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW old_cw = cw(0,4); cw(0,4) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM // Check ASSUME(active[iw(0,4)] == 0); ASSUME(active[cw(0,4)] == 0); ASSUME(sforbid(4,cw(0,4))== 0); ASSUME(iw(0,4) >= 0); ASSUME(iw(0,4) >= 0); ASSUME(cw(0,4) >= iw(0,4)); ASSUME(cw(0,4) >= old_cw); ASSUME(cw(0,4) >= cr(0,4)); ASSUME(cw(0,4) >= cl[0]); ASSUME(cw(0,4) >= cisb[0]); ASSUME(cw(0,4) >= cdy[0]); ASSUME(cw(0,4) >= cdl[0]); ASSUME(cw(0,4) >= cds[0]); ASSUME(cw(0,4) >= cctrl[0]); ASSUME(cw(0,4) >= caddr[0]); // Update caddr[0] = max(caddr[0],0); buff(0,4) = 0; mem(4,cw(0,4)) = 0; co(4,cw(0,4))+=1; delta(4,cw(0,4)) = -1; ASSUME(creturn[0] >= cw(0,4)); // call void @llvm.dbg.value(metadata i64* @atom_1_X8_0, metadata !163, metadata !DIExpression()), !dbg !207 // call void @llvm.dbg.value(metadata i64 0, metadata !165, metadata !DIExpression()), !dbg !207 // store atomic i64 0, i64* @atom_1_X8_0 monotonic, align 8, !dbg !109 // ST: Guess iw(0,5) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW old_cw = cw(0,5); cw(0,5) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM // Check ASSUME(active[iw(0,5)] == 0); ASSUME(active[cw(0,5)] == 0); ASSUME(sforbid(5,cw(0,5))== 0); ASSUME(iw(0,5) >= 0); ASSUME(iw(0,5) >= 0); ASSUME(cw(0,5) >= iw(0,5)); ASSUME(cw(0,5) >= old_cw); ASSUME(cw(0,5) >= cr(0,5)); ASSUME(cw(0,5) >= cl[0]); ASSUME(cw(0,5) >= cisb[0]); ASSUME(cw(0,5) >= cdy[0]); ASSUME(cw(0,5) >= cdl[0]); ASSUME(cw(0,5) >= cds[0]); ASSUME(cw(0,5) >= cctrl[0]); ASSUME(cw(0,5) >= caddr[0]); // Update caddr[0] = max(caddr[0],0); buff(0,5) = 0; mem(5,cw(0,5)) = 0; co(5,cw(0,5))+=1; delta(5,cw(0,5)) = -1; ASSUME(creturn[0] >= cw(0,5)); // %call = call i32 @pthread_create(i64* noundef %thr0, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef @t0, i8* noundef null) #7, !dbg !110 // dumbsy: Guess old_cdy = cdy[0]; cdy[0] = get_rng(0,NCONTEXT-1); // Check ASSUME(cdy[0] >= old_cdy); ASSUME(cdy[0] >= cisb[0]); ASSUME(cdy[0] >= cdl[0]); ASSUME(cdy[0] >= cds[0]); ASSUME(cdy[0] >= cctrl[0]); ASSUME(cdy[0] >= cw(0,0+0)); ASSUME(cdy[0] >= cw(0,0+1)); ASSUME(cdy[0] >= cw(0,0+2)); ASSUME(cdy[0] >= cw(0,3+0)); ASSUME(cdy[0] >= cw(0,4+0)); ASSUME(cdy[0] >= cw(0,5+0)); ASSUME(cdy[0] >= cw(0,6+0)); ASSUME(cdy[0] >= cw(0,7+0)); ASSUME(cdy[0] >= cr(0,0+0)); ASSUME(cdy[0] >= cr(0,0+1)); ASSUME(cdy[0] >= cr(0,0+2)); ASSUME(cdy[0] >= cr(0,3+0)); ASSUME(cdy[0] >= cr(0,4+0)); ASSUME(cdy[0] >= cr(0,5+0)); ASSUME(cdy[0] >= cr(0,6+0)); ASSUME(cdy[0] >= cr(0,7+0)); ASSUME(creturn[0] >= cdy[0]); ASSUME(cstart[1] >= cdy[0]); // %call11 = call i32 @pthread_create(i64* noundef %thr1, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef @t1, i8* noundef null) #7, !dbg !111 // dumbsy: Guess old_cdy = cdy[0]; cdy[0] = get_rng(0,NCONTEXT-1); // Check ASSUME(cdy[0] >= old_cdy); ASSUME(cdy[0] >= cisb[0]); ASSUME(cdy[0] >= cdl[0]); ASSUME(cdy[0] >= cds[0]); ASSUME(cdy[0] >= cctrl[0]); ASSUME(cdy[0] >= cw(0,0+0)); ASSUME(cdy[0] >= cw(0,0+1)); ASSUME(cdy[0] >= cw(0,0+2)); ASSUME(cdy[0] >= cw(0,3+0)); ASSUME(cdy[0] >= cw(0,4+0)); ASSUME(cdy[0] >= cw(0,5+0)); ASSUME(cdy[0] >= cw(0,6+0)); ASSUME(cdy[0] >= cw(0,7+0)); ASSUME(cdy[0] >= cr(0,0+0)); ASSUME(cdy[0] >= cr(0,0+1)); ASSUME(cdy[0] >= cr(0,0+2)); ASSUME(cdy[0] >= cr(0,3+0)); ASSUME(cdy[0] >= cr(0,4+0)); ASSUME(cdy[0] >= cr(0,5+0)); ASSUME(cdy[0] >= cr(0,6+0)); ASSUME(cdy[0] >= cr(0,7+0)); ASSUME(creturn[0] >= cdy[0]); ASSUME(cstart[2] >= cdy[0]); // %2 = load i64, i64* %thr0, align 8, !dbg !112, !tbaa !113 // LD: Guess old_cr = cr(0,6); cr(0,6) = get_rng(0,NCONTEXT-1);// 0 ASSIGN LDCOM // Check ASSUME(active[cr(0,6)] == 0); ASSUME(cr(0,6) >= iw(0,6)); ASSUME(cr(0,6) >= 0); ASSUME(cr(0,6) >= cdy[0]); ASSUME(cr(0,6) >= cisb[0]); ASSUME(cr(0,6) >= cdl[0]); ASSUME(cr(0,6) >= cl[0]); // Update creg_r9 = cr(0,6); crmax(0,6) = max(crmax(0,6),cr(0,6)); caddr[0] = max(caddr[0],0); if(cr(0,6) < cw(0,6)) { r9 = buff(0,6); } else { if(pw(0,6) != co(6,cr(0,6))) { ASSUME(cr(0,6) >= old_cr); } pw(0,6) = co(6,cr(0,6)); r9 = mem(6,cr(0,6)); } ASSUME(creturn[0] >= cr(0,6)); // %call12 = call i32 @pthread_join(i64 noundef %2, i8** noundef null), !dbg !117 // dumbsy: Guess old_cdy = cdy[0]; cdy[0] = get_rng(0,NCONTEXT-1); // Check ASSUME(cdy[0] >= old_cdy); ASSUME(cdy[0] >= cisb[0]); ASSUME(cdy[0] >= cdl[0]); ASSUME(cdy[0] >= cds[0]); ASSUME(cdy[0] >= cctrl[0]); ASSUME(cdy[0] >= cw(0,0+0)); ASSUME(cdy[0] >= cw(0,0+1)); ASSUME(cdy[0] >= cw(0,0+2)); ASSUME(cdy[0] >= cw(0,3+0)); ASSUME(cdy[0] >= cw(0,4+0)); ASSUME(cdy[0] >= cw(0,5+0)); ASSUME(cdy[0] >= cw(0,6+0)); ASSUME(cdy[0] >= cw(0,7+0)); ASSUME(cdy[0] >= cr(0,0+0)); ASSUME(cdy[0] >= cr(0,0+1)); ASSUME(cdy[0] >= cr(0,0+2)); ASSUME(cdy[0] >= cr(0,3+0)); ASSUME(cdy[0] >= cr(0,4+0)); ASSUME(cdy[0] >= cr(0,5+0)); ASSUME(cdy[0] >= cr(0,6+0)); ASSUME(cdy[0] >= cr(0,7+0)); ASSUME(creturn[0] >= cdy[0]); ASSUME(cdy[0] >= creturn[1]); // %3 = load i64, i64* %thr1, align 8, !dbg !118, !tbaa !113 // LD: Guess old_cr = cr(0,7); cr(0,7) = get_rng(0,NCONTEXT-1);// 0 ASSIGN LDCOM // Check ASSUME(active[cr(0,7)] == 0); ASSUME(cr(0,7) >= iw(0,7)); ASSUME(cr(0,7) >= 0); ASSUME(cr(0,7) >= cdy[0]); ASSUME(cr(0,7) >= cisb[0]); ASSUME(cr(0,7) >= cdl[0]); ASSUME(cr(0,7) >= cl[0]); // Update creg_r10 = cr(0,7); crmax(0,7) = max(crmax(0,7),cr(0,7)); caddr[0] = max(caddr[0],0); if(cr(0,7) < cw(0,7)) { r10 = buff(0,7); } else { if(pw(0,7) != co(7,cr(0,7))) { ASSUME(cr(0,7) >= old_cr); } pw(0,7) = co(7,cr(0,7)); r10 = mem(7,cr(0,7)); } ASSUME(creturn[0] >= cr(0,7)); // %call13 = call i32 @pthread_join(i64 noundef %3, i8** noundef null), !dbg !119 // dumbsy: Guess old_cdy = cdy[0]; cdy[0] = get_rng(0,NCONTEXT-1); // Check ASSUME(cdy[0] >= old_cdy); ASSUME(cdy[0] >= cisb[0]); ASSUME(cdy[0] >= cdl[0]); ASSUME(cdy[0] >= cds[0]); ASSUME(cdy[0] >= cctrl[0]); ASSUME(cdy[0] >= cw(0,0+0)); ASSUME(cdy[0] >= cw(0,0+1)); ASSUME(cdy[0] >= cw(0,0+2)); ASSUME(cdy[0] >= cw(0,3+0)); ASSUME(cdy[0] >= cw(0,4+0)); ASSUME(cdy[0] >= cw(0,5+0)); ASSUME(cdy[0] >= cw(0,6+0)); ASSUME(cdy[0] >= cw(0,7+0)); ASSUME(cdy[0] >= cr(0,0+0)); ASSUME(cdy[0] >= cr(0,0+1)); ASSUME(cdy[0] >= cr(0,0+2)); ASSUME(cdy[0] >= cr(0,3+0)); ASSUME(cdy[0] >= cr(0,4+0)); ASSUME(cdy[0] >= cr(0,5+0)); ASSUME(cdy[0] >= cr(0,6+0)); ASSUME(cdy[0] >= cr(0,7+0)); ASSUME(creturn[0] >= cdy[0]); ASSUME(cdy[0] >= creturn[2]); // call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 0), metadata !167, metadata !DIExpression()), !dbg !219 // %4 = load atomic i64, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 0) seq_cst, align 8, !dbg !121 // LD: Guess old_cr = cr(0,0); cr(0,0) = get_rng(0,NCONTEXT-1);// 0 ASSIGN LDCOM // Check ASSUME(active[cr(0,0)] == 0); ASSUME(cr(0,0) >= iw(0,0)); ASSUME(cr(0,0) >= 0); ASSUME(cr(0,0) >= cdy[0]); ASSUME(cr(0,0) >= cisb[0]); ASSUME(cr(0,0) >= cdl[0]); ASSUME(cr(0,0) >= cl[0]); // Update creg_r11 = cr(0,0); crmax(0,0) = max(crmax(0,0),cr(0,0)); caddr[0] = max(caddr[0],0); if(cr(0,0) < cw(0,0)) { r11 = buff(0,0); } else { if(pw(0,0) != co(0,cr(0,0))) { ASSUME(cr(0,0) >= old_cr); } pw(0,0) = co(0,cr(0,0)); r11 = mem(0,cr(0,0)); } ASSUME(creturn[0] >= cr(0,0)); // call void @llvm.dbg.value(metadata i64 %4, metadata !169, metadata !DIExpression()), !dbg !219 // %conv = trunc i64 %4 to i32, !dbg !122 // call void @llvm.dbg.value(metadata i32 %conv, metadata !166, metadata !DIExpression()), !dbg !192 // %cmp = icmp eq i32 %conv, 1, !dbg !123 // %conv14 = zext i1 %cmp to i32, !dbg !123 // call void @llvm.dbg.value(metadata i32 %conv14, metadata !170, metadata !DIExpression()), !dbg !192 // call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 1), metadata !172, metadata !DIExpression()), !dbg !223 // %5 = load atomic i64, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 1) seq_cst, align 8, !dbg !125 // LD: Guess old_cr = cr(0,0+1*1); cr(0,0+1*1) = get_rng(0,NCONTEXT-1);// 0 ASSIGN LDCOM // Check ASSUME(active[cr(0,0+1*1)] == 0); ASSUME(cr(0,0+1*1) >= iw(0,0+1*1)); ASSUME(cr(0,0+1*1) >= 0); ASSUME(cr(0,0+1*1) >= cdy[0]); ASSUME(cr(0,0+1*1) >= cisb[0]); ASSUME(cr(0,0+1*1) >= cdl[0]); ASSUME(cr(0,0+1*1) >= cl[0]); // Update creg_r12 = cr(0,0+1*1); crmax(0,0+1*1) = max(crmax(0,0+1*1),cr(0,0+1*1)); caddr[0] = max(caddr[0],0); if(cr(0,0+1*1) < cw(0,0+1*1)) { r12 = buff(0,0+1*1); } else { if(pw(0,0+1*1) != co(0+1*1,cr(0,0+1*1))) { ASSUME(cr(0,0+1*1) >= old_cr); } pw(0,0+1*1) = co(0+1*1,cr(0,0+1*1)); r12 = mem(0+1*1,cr(0,0+1*1)); } ASSUME(creturn[0] >= cr(0,0+1*1)); // call void @llvm.dbg.value(metadata i64 %5, metadata !174, metadata !DIExpression()), !dbg !223 // %conv18 = trunc i64 %5 to i32, !dbg !126 // call void @llvm.dbg.value(metadata i32 %conv18, metadata !171, metadata !DIExpression()), !dbg !192 // %cmp19 = icmp eq i32 %conv18, 2, !dbg !127 // %conv20 = zext i1 %cmp19 to i32, !dbg !127 // call void @llvm.dbg.value(metadata i32 %conv20, metadata !175, metadata !DIExpression()), !dbg !192 // call void @llvm.dbg.value(metadata i64* @atom_1_X0_1, metadata !177, metadata !DIExpression()), !dbg !227 // %6 = load atomic i64, i64* @atom_1_X0_1 seq_cst, align 8, !dbg !129 // LD: Guess old_cr = cr(0,3); cr(0,3) = get_rng(0,NCONTEXT-1);// 0 ASSIGN LDCOM // Check ASSUME(active[cr(0,3)] == 0); ASSUME(cr(0,3) >= iw(0,3)); ASSUME(cr(0,3) >= 0); ASSUME(cr(0,3) >= cdy[0]); ASSUME(cr(0,3) >= cisb[0]); ASSUME(cr(0,3) >= cdl[0]); ASSUME(cr(0,3) >= cl[0]); // Update creg_r13 = cr(0,3); crmax(0,3) = max(crmax(0,3),cr(0,3)); caddr[0] = max(caddr[0],0); if(cr(0,3) < cw(0,3)) { r13 = buff(0,3); } else { if(pw(0,3) != co(3,cr(0,3))) { ASSUME(cr(0,3) >= old_cr); } pw(0,3) = co(3,cr(0,3)); r13 = mem(3,cr(0,3)); } ASSUME(creturn[0] >= cr(0,3)); // call void @llvm.dbg.value(metadata i64 %6, metadata !179, metadata !DIExpression()), !dbg !227 // %conv24 = trunc i64 %6 to i32, !dbg !130 // call void @llvm.dbg.value(metadata i32 %conv24, metadata !176, metadata !DIExpression()), !dbg !192 // call void @llvm.dbg.value(metadata i64* @atom_1_X3_2, metadata !181, metadata !DIExpression()), !dbg !230 // %7 = load atomic i64, i64* @atom_1_X3_2 seq_cst, align 8, !dbg !132 // LD: Guess old_cr = cr(0,4); cr(0,4) = get_rng(0,NCONTEXT-1);// 0 ASSIGN LDCOM // Check ASSUME(active[cr(0,4)] == 0); ASSUME(cr(0,4) >= iw(0,4)); ASSUME(cr(0,4) >= 0); ASSUME(cr(0,4) >= cdy[0]); ASSUME(cr(0,4) >= cisb[0]); ASSUME(cr(0,4) >= cdl[0]); ASSUME(cr(0,4) >= cl[0]); // Update creg_r14 = cr(0,4); crmax(0,4) = max(crmax(0,4),cr(0,4)); caddr[0] = max(caddr[0],0); if(cr(0,4) < cw(0,4)) { r14 = buff(0,4); } else { if(pw(0,4) != co(4,cr(0,4))) { ASSUME(cr(0,4) >= old_cr); } pw(0,4) = co(4,cr(0,4)); r14 = mem(4,cr(0,4)); } ASSUME(creturn[0] >= cr(0,4)); // call void @llvm.dbg.value(metadata i64 %7, metadata !183, metadata !DIExpression()), !dbg !230 // %conv28 = trunc i64 %7 to i32, !dbg !133 // call void @llvm.dbg.value(metadata i32 %conv28, metadata !180, metadata !DIExpression()), !dbg !192 // call void @llvm.dbg.value(metadata i64* @atom_1_X8_0, metadata !185, metadata !DIExpression()), !dbg !233 // %8 = load atomic i64, i64* @atom_1_X8_0 seq_cst, align 8, !dbg !135 // LD: Guess old_cr = cr(0,5); cr(0,5) = get_rng(0,NCONTEXT-1);// 0 ASSIGN LDCOM // Check ASSUME(active[cr(0,5)] == 0); ASSUME(cr(0,5) >= iw(0,5)); ASSUME(cr(0,5) >= 0); ASSUME(cr(0,5) >= cdy[0]); ASSUME(cr(0,5) >= cisb[0]); ASSUME(cr(0,5) >= cdl[0]); ASSUME(cr(0,5) >= cl[0]); // Update creg_r15 = cr(0,5); crmax(0,5) = max(crmax(0,5),cr(0,5)); caddr[0] = max(caddr[0],0); if(cr(0,5) < cw(0,5)) { r15 = buff(0,5); } else { if(pw(0,5) != co(5,cr(0,5))) { ASSUME(cr(0,5) >= old_cr); } pw(0,5) = co(5,cr(0,5)); r15 = mem(5,cr(0,5)); } ASSUME(creturn[0] >= cr(0,5)); // call void @llvm.dbg.value(metadata i64 %8, metadata !187, metadata !DIExpression()), !dbg !233 // %conv32 = trunc i64 %8 to i32, !dbg !136 // call void @llvm.dbg.value(metadata i32 %conv32, metadata !184, metadata !DIExpression()), !dbg !192 // %and = and i32 %conv28, %conv32, !dbg !137 creg_r16 = max(creg_r14,creg_r15); ASSUME(active[creg_r16] == 0); r16 = r14 & r15; // call void @llvm.dbg.value(metadata i32 %and, metadata !188, metadata !DIExpression()), !dbg !192 // %and33 = and i32 %conv24, %and, !dbg !138 creg_r17 = max(creg_r13,creg_r16); ASSUME(active[creg_r17] == 0); r17 = r13 & r16; // call void @llvm.dbg.value(metadata i32 %and33, metadata !189, metadata !DIExpression()), !dbg !192 // %and34 = and i32 %conv20, %and33, !dbg !139 creg_r18 = max(max(creg_r12,0),creg_r17); ASSUME(active[creg_r18] == 0); r18 = (r12==2) & r17; // call void @llvm.dbg.value(metadata i32 %and34, metadata !190, metadata !DIExpression()), !dbg !192 // %and35 = and i32 %conv14, %and34, !dbg !140 creg_r19 = max(max(creg_r11,0),creg_r18); ASSUME(active[creg_r19] == 0); r19 = (r11==1) & r18; // call void @llvm.dbg.value(metadata i32 %and35, metadata !191, metadata !DIExpression()), !dbg !192 // %cmp36 = icmp eq i32 %and35, 1, !dbg !141 // br i1 %cmp36, label %if.then, label %if.end, !dbg !143 old_cctrl = cctrl[0]; cctrl[0] = get_rng(0,NCONTEXT-1); ASSUME(cctrl[0] >= old_cctrl); ASSUME(cctrl[0] >= creg_r19); ASSUME(cctrl[0] >= 0); if((r19==1)) { goto T0BLOCK1; } else { goto T0BLOCK2; } T0BLOCK1: // call void @__assert_fail(i8* noundef getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* noundef getelementptr inbounds ([116 x i8], [116 x i8]* @.str.1, i64 0, i64 0), i32 noundef 75, i8* noundef getelementptr inbounds ([23 x i8], [23 x i8]* @__PRETTY_FUNCTION__.main, i64 0, i64 0)) #8, !dbg !144 // unreachable, !dbg !144 r20 = 1; T0BLOCK2: // %9 = bitcast i64* %thr1 to i8*, !dbg !147 // call void @llvm.lifetime.end.p0i8(i64 8, i8* %9) #7, !dbg !147 // %10 = bitcast i64* %thr0 to i8*, !dbg !147 // call void @llvm.lifetime.end.p0i8(i64 8, i8* %10) #7, !dbg !147 // ret i32 0, !dbg !148 ret_thread_0 = 0; ASSERT(r20== 0); }
[ "tuan-phong.ngo@it.uu.se" ]
tuan-phong.ngo@it.uu.se
d2d347e241a2af12c0ec3e082eb4931e27d3ee85
66a176d25b47a474927b87552ea6f4b5f32b3fda
/src/151_reverse-words-in-a-string.cc
757e1823d2e0efa88b4422ba65daebf476f164d0
[ "MIT" ]
permissive
q191201771/yoko_leetcode
2fa4199eb45f63ad907f83ca9a7e1f9de02638d1
a29b163169f409856e9c9808890bcb25ca976f78
refs/heads/master
2020-03-24T10:16:23.228375
2019-02-17T04:19:14
2019-02-17T04:19:14
142,651,993
2
0
null
null
null
null
UTF-8
C++
false
false
2,380
cc
// Given an input string, reverse the string word by word. // // Example: // // Input: "the sky is blue", // Output: "blue is sky the". // Note: // // A word is defined as a sequence of non-space characters. // Input string may contain leading or trailing spaces. However, your reversed string should not contain leading or // trailing spaces. // You need to reduce multiple spaces between two words to a single space in the reversed string. // Follow up: For C programmers, try to solve it in-place in O(1) space. #ifdef YOKO_DEBUG #include "util/helper.hpp" #endif class Solution { private: void __replace(string &s, int f, int t, int len) { for (int i = 0; i < len; i++) { s[t+i] = s[f+i]; } } void __copy(string &s, int t, int len, const char *f) { for (int i = 0; i < len; i++) { s[t+i] = *(f+i); } } public: void reverseWords(string &s) { if (s.empty()) { return; } // trim left space int begin = 0; for (; begin < s.length(); begin++) { if (s[begin] != ' ') { break; } } if (begin == s.length()) { s = ""; return; } // trim right space int end = s.length() - 1; for (; end >= 0; end--) { if (s[end] != ' ') { break; } } if (end == -1) { s = ""; return; } // trim extra mid space int j = begin; for (int i = begin; i <= end;) { if (s[i] != ' ') { if (j != i) { s[j] = s[i]; } i++; j++; } else { for (; s[i] == ' '; i++); s[j++] = ' '; } } end = j-1; int i = begin; int ie = end; for (; i <= ie;) { if (s[i] == ' ') { // Am `item` count as extra space? string item = s.substr(begin, i-begin); __replace(s, i+1, begin, ie-i); s[ie-i+begin] = ' '; __copy(s, ie-i+begin+1, i-begin, item.c_str()); ie = ie - (i-begin) - 1; i = begin; } else { i++; } } s = s.substr(begin, end-begin+1); } }; #ifdef YOKO_DEBUG int main() { Solution s; string str = "the sky is blue"; //string str = " 1"; //string str = "1 "; std::cout << "origin:\'" << str << "\'" << std::endl; s.reverseWords(str); std::cout << "ret:\'" << str << "\'" << std::endl; return 0; } #endif
[ "191201771@qq.com" ]
191201771@qq.com