hexsha stringlengths 40 40 | size int64 7 1.05M | ext stringclasses 13
values | lang stringclasses 1
value | max_stars_repo_path stringlengths 4 269 | max_stars_repo_name stringlengths 5 108 | max_stars_repo_head_hexsha stringlengths 40 40 | max_stars_repo_licenses listlengths 1 9 | max_stars_count int64 1 191k ⌀ | max_stars_repo_stars_event_min_datetime stringlengths 24 24 ⌀ | max_stars_repo_stars_event_max_datetime stringlengths 24 24 ⌀ | max_issues_repo_path stringlengths 4 269 | max_issues_repo_name stringlengths 5 116 | max_issues_repo_head_hexsha stringlengths 40 40 | max_issues_repo_licenses listlengths 1 9 | max_issues_count int64 1 67k ⌀ | max_issues_repo_issues_event_min_datetime stringlengths 24 24 ⌀ | max_issues_repo_issues_event_max_datetime stringlengths 24 24 ⌀ | max_forks_repo_path stringlengths 4 269 | max_forks_repo_name stringlengths 5 116 | max_forks_repo_head_hexsha stringlengths 40 40 | max_forks_repo_licenses listlengths 1 9 | max_forks_count int64 1 105k ⌀ | max_forks_repo_forks_event_min_datetime stringlengths 24 24 ⌀ | max_forks_repo_forks_event_max_datetime stringlengths 24 24 ⌀ | content stringlengths 7 1.05M | avg_line_length float64 1.21 330k | max_line_length int64 6 990k | alphanum_fraction float64 0.01 0.99 | author_id stringlengths 2 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
3a8d99afc16a7f74affe9733ea3657ef04d0c661 | 572 | cc | C++ | src/snakebird/level10.cc | jsnell/snakebird | ceba0c40dbd854c4a2eadc9da63b18b636397601 | [
"MIT"
] | null | null | null | src/snakebird/level10.cc | jsnell/snakebird | ceba0c40dbd854c4a2eadc9da63b18b636397601 | [
"MIT"
] | null | null | null | src/snakebird/level10.cc | jsnell/snakebird | ceba0c40dbd854c4a2eadc9da63b18b636397601 | [
"MIT"
] | null | null | null | #include "main.h"
int main() {
const char* base_map =
".............."
". ... ."
". .... * ."
". . ."
". O . v.. ."
". R<<. ."
". .... .. ."
". ... . ."
". . O ."
". . .. ."
". . .. ."
". .. .. ."
". .... ."
"~~~~~~~~~~~~~~";
using St = State<Setup<14, 14, 2, 1, 6>>;
St::Map map(base_map);
St st(map);
st.print(map);
EXPECT_EQ(33, search(st, map));
return 0;
}
| 20.428571 | 45 | 0.22028 | jsnell |
3a8e00104759b41dfbebad693f692bd1a1dc9860 | 708 | cpp | C++ | lldb/unittests/Utility/ProcessInfoTest.cpp | dan-zheng/llvm-project | 6b792850da0345274758c9260fda5df5e57ab486 | [
"Apache-2.0"
] | 765 | 2015-12-03T16:44:59.000Z | 2022-03-07T12:41:10.000Z | lldb/unittests/Utility/ProcessInfoTest.cpp | dan-zheng/llvm-project | 6b792850da0345274758c9260fda5df5e57ab486 | [
"Apache-2.0"
] | 1,815 | 2015-12-11T23:56:05.000Z | 2020-01-10T19:28:43.000Z | lldb/unittests/Utility/ProcessInfoTest.cpp | dan-zheng/llvm-project | 6b792850da0345274758c9260fda5df5e57ab486 | [
"Apache-2.0"
] | 284 | 2015-12-03T16:47:25.000Z | 2022-03-12T05:39:48.000Z | //===-- ProcessInfoTest.cpp -------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "lldb/Utility/ProcessInfo.h"
#include "gtest/gtest.h"
using namespace lldb_private;
TEST(ProcessInfoTest, Constructor) {
ProcessInfo Info("foo", ArchSpec("x86_64-pc-linux"), 47);
EXPECT_STREQ("foo", Info.GetName());
EXPECT_EQ(ArchSpec("x86_64-pc-linux"), Info.GetArchitecture());
EXPECT_EQ(47u, Info.GetProcessID());
}
| 35.4 | 80 | 0.594633 | dan-zheng |
3a8e24ab21159768ef197defeae37a919d12830a | 11,677 | cpp | C++ | Server_Msg/MdfFileManager.cpp | suzhengquan/MBCAF | 6da9e994a30c1c228961328d19e71493f1fa7726 | [
"BSD-3-Clause"
] | 2 | 2020-10-24T15:44:31.000Z | 2021-05-31T03:22:02.000Z | Server_Msg/MdfFileManager.cpp | suzhengquan/MBCAF | 6da9e994a30c1c228961328d19e71493f1fa7726 | [
"BSD-3-Clause"
] | null | null | null | Server_Msg/MdfFileManager.cpp | suzhengquan/MBCAF | 6da9e994a30c1c228961328d19e71493f1fa7726 | [
"BSD-3-Clause"
] | null | null | null | /*
Copyright (c) "2018-2019", Shenzhen Mindeng Technology Co., Ltd(www.niiengine.com),
Mindeng Base Communication Application Framework
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list of
conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list
of conditions and the following disclaimer in the documentation and/or other materials
provided with the distribution.
Neither the name of the "ORGANIZATION" nor the names of its contributors may be used
to endorse or promote products derived from this software without specific prior written
permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "MdfFileManager.h"
#include "MdfServerConnect.h"
#include "MdfRouteClientConnect.h"
#include "MdfDatabaseClientConnect.h"
#include "MdfFileClientConnect.h"
#include "MdfUserManager.h"
#include "MBCAF.HubServer.pb.h"
#include "MBCAF.ServerBase.pb.h"
#include "MBCAF.MsgServer.pb.h"
using namespace MBCAF::Proto;
namespace Mdf
{
//-----------------------------------------------------------------------
M_SingletonImpl(FileManager);
//-----------------------------------------------------------------------
void FileManager::FileQ(ServerConnect * conn, MdfMessage * msg)
{
MBCAF::HubServer::FileQ proto;
if(!msg->toProto(&proto))
return;
Mui32 fromid = conn->getUserID();
Mui32 toid = proto.to_user_id();
String fname = proto.file_name();
Mui32 fsize = proto.file_size();
Mui32 tmode = proto.trans_mode();
Mlog("FileQ, %u->%u, fileName: %s, trans_mode: %u.", fromid, toid, fname.c_str(), tmode);
FileClientConnect * fileconn = FileClientConnect::getRandomConnect();
if (fileconn)
{
HandleExtData attach(conn->getID());
MBCAF::HubServer::FileTransferQ proto2;
proto2.set_from_user_id(fromid);
proto2.set_to_user_id(toid);
proto2.set_file_name(fname);
proto2.set_file_size(fsize);
proto2.set_trans_mode((MBCAF::Proto::TransferFileType)tmode);
proto2.set_attach_data(attach.getBuffer(), attach.getSize());
MdfMessage remsg;
remsg.setProto(&proto2);
remsg.setCommandID(SBMSG(FileTransferQ));
remsg.setSeqIdx(msg->getSeqIdx());
if (MBCAF::Proto::TFT_Offline == tmode)
{
fileconn->send(&remsg);
}
else
{
User * tempusr = M_Only(UserManager)->getUser(toid);
if (tempusr && tempusr->getPCState())
{
fileconn->send(&remsg);
}
else
{
RouteClientConnect * routeconn = RouteClientConnect::getPrimaryConnect();
if (routeconn)
{
MessageExtData extdata(MEDT_ProtoToFile, conn->getID(), remsg.getContentSize(), remsg.getContent());
MBCAF::MsgServer::BuddyObjectStateQ proto3;
proto3.set_user_id(fromid);
proto3.add_user_id_list(toid);
proto3.set_attach_data(extdata.getBuffer(), extdata.getSize());
MdfMessage remsg2;
remsg2.setProto(&proto3);
remsg2.setCommandID(MSMSG(BuddyObjectStateQ));
remsg2.setSeqIdx(msg->getSeqIdx());
routeconn->send(&remsg2);
}
}
}
}
else
{
Mlog("FileQ, no file server. ");
MBCAF::HubServer::FileA proto2;
proto2.set_result_code(1);
proto2.set_from_user_id(fromid);
proto2.set_to_user_id(toid);
proto2.set_file_name(fname);
proto2.set_task_id("");
proto2.set_trans_mode((MBCAF::Proto::TransferFileType)tmode);
MdfMessage remsg;
remsg.setProto(&proto2);
remsg.setCommandID(HSMSG(FileA));
remsg.setSeqIdx(msg->getSeqIdx());
conn->send(&remsg);
}
}
//-----------------------------------------------------------------------
void FileManager::OfflineFileQ(ServerConnect * conn, MdfMessage * msg)
{
Mui32 userid = conn->getUserID();
Mlog("OfflineFileQ, req_id=%u ", userid);
HandleExtData extdata(conn->getID());
DataBaseClientConnect * dbconn = DataBaseClientConnect::getPrimaryConnect();
if (dbconn)
{
MBCAF::HubServer::FileExistOfflineQ proto;
if(!msg->toProto(&proto))
return;
proto.set_user_id(userid);
proto.set_attach_data(extdata.getBuffer(), extdata.getSize());
msg->setProto(&proto);
dbconn->send(msg);
}
else
{
Mlog("warning no DB connection available ");
MBCAF::HubServer::FileExistOfflineA proto;
proto.set_user_id(userid);
MdfMessage remsg;
remsg.setProto(&proto);
remsg.setCommandID(HSMSG(OfflineFileA));
remsg.setSeqIdx(msg->getSeqIdx());
conn->send(&remsg);
}
}
//-----------------------------------------------------------------------
void FileManager::AddOfflineFileQ(ServerConnect * conn, MdfMessage * msg)
{
MBCAF::HubServer::FileAddOfflineQ proto;
if(!msg->toProto(&proto))
return;
Mui32 fromid = conn->getUserID();
Mui32 toid = proto.to_user_id();
String taskid = proto.task_id();
String fname = proto.file_name();
Mui32 fsize = proto.file_size();
Mlog("AddOfflineFileQ, %u->%u, task_id: %s, file_name: %s, size: %u ",
fromid, toid, taskid.c_str(), fname.c_str(), fsize);
DataBaseClientConnect * dbconn = DataBaseClientConnect::getPrimaryConnect();
if (dbconn)
{
proto.set_from_user_id(fromid);
msg->setProto(&proto);
dbconn->send(msg);
}
FileClientConnect * fileconn = FileClientConnect::getRandomConnect();
if (fileconn)
{
const list<MBCAF::Proto::IPAddress> & addrlist = fileconn->GetFileServerIPList();
MBCAF::HubServer::FileNotify proto2;
proto2.set_from_user_id(fromid);
proto2.set_to_user_id(toid);
proto2.set_file_name(fname);
proto2.set_file_size(fsize);
proto2.set_task_id(taskid);
proto2.set_trans_mode(MBCAF::Proto::TFT_Offline);
proto2.set_offline_ready(1);
list<MBCAF::Proto::IPAddress>::const_iterator it, itend = addrlist.end();
for (it = addrlist.begin(); it != itend; ++it)
{
MBCAF::Proto::IPAddress * ip_addr = proto2.add_ip_addr_list();
ip_addr->set_ip((*it).ip());
ip_addr->set_port((*it).port());
}
MdfMessage remsg;
remsg.setProto(&proto2);
remsg.setCommandID(HSMSG(FileNotify));
User * tempusr = M_Only(UserManager)->getUser(toid);
if (tempusr)
{
tempusr->broadcastToPC(&remsg);
}
RouteClientConnect * conn = RouteClientConnect::getPrimaryConnect();
if (conn)
{
conn->send(&remsg);
}
}
}
//-----------------------------------------------------------------------
void FileManager::DeleteOfflineFileQ(ServerConnect * conn, MdfMessage * msg)
{
MBCAF::HubServer::FileDeleteOfflineQ proto;
if(!msg->toProto(&proto))
return;
Mui32 fromid = proto.from_user_id();
Mui32 toid = proto.to_user_id();
String taskid = proto.task_id();
Mlog("DeleteOfflineFileQ, %u->%u, task_id=%s ", fromid, toid, taskid.c_str());
DataBaseClientConnect * dbconn = DataBaseClientConnect::getPrimaryConnect();
if (dbconn)
{
proto.set_from_user_id(fromid);
msg->setProto(&proto);
dbconn->send(msg);
}
}
//-----------------------------------------------------------------------
void FileManager::prcOfflineFileA(MdfMessage * msg)
{
MBCAF::HubServer::FileExistOfflineA proto;
if(!msg->toProto(&proto))
return;
Mui32 userid = proto.user_id();
Mui32 filecnt = proto.offline_file_list_size();
HandleExtData attach((Mui8*)proto.attach_data().c_str(), proto.attach_data().length());
Mlog("prcOfflineFileA, req_id=%u, file_cnt=%u ", userid, filecnt);
ServerConnect * conn = M_Only(UserManager)->getMsgConnect(userid, attach.getHandle());
if (conn)
{
FileClientConnect * fileconn = FileClientConnect::getRandomConnect();
if (fileconn)
{
const list<MBCAF::Proto::IPAddress> & iplist = fileconn->GetFileServerIPList();
for(list<MBCAF::Proto::IPAddress>::const_iterator it = iplist.begin(); it != iplist.end(); ++it)
{
MBCAF::Proto::IPAddress * ip_addr = proto.add_ip_addr_list();
ip_addr->set_ip((*it).ip());
ip_addr->set_port((*it).port());
}
}
else
{
Mlog("prcOfflineFileA, no file server. ");
}
msg->setProto(&proto);
conn->send(msg);
}
}
//-----------------------------------------------------------------------
void FileManager::prcFileNotify(MdfMessage * msg)
{
MBCAF::HubServer::FileNotify proto;
if(!msg->toProto(&proto))
return;
Mui32 fromid = proto.from_user_id();
Mui32 userid = proto.to_user_id();
String fname = proto.file_name();
String taskid = proto.task_id();
Mui32 tmode = proto.trans_mode();
Mui32 ready = proto.offline_ready();
Mlog("prcFileNotify, from_id: %u, to_id: %u, file_name: %s, task_id: %s, trans_mode: %u,\
offline_ready: %u. ", fromid, userid, fname.c_str(), taskid.c_str(), tmode, ready);
User * tempusr = M_Only(UserManager)->getUser(userid);
if(tempusr)
{
tempusr->broadcast(msg);
}
}
//-----------------------------------------------------------------------
} | 40.686411 | 124 | 0.548429 | suzhengquan |
3a9214a83e6cc62137686ba75998bc6fdb1d21d1 | 2,303 | cpp | C++ | Renderer/phong_shader.cpp | ZoonLogonEchon/SimpleSceneRenderer | 500fff6d1aca5d8fd293f96cc952db23175dfa0e | [
"MIT"
] | null | null | null | Renderer/phong_shader.cpp | ZoonLogonEchon/SimpleSceneRenderer | 500fff6d1aca5d8fd293f96cc952db23175dfa0e | [
"MIT"
] | null | null | null | Renderer/phong_shader.cpp | ZoonLogonEchon/SimpleSceneRenderer | 500fff6d1aca5d8fd293f96cc952db23175dfa0e | [
"MIT"
] | null | null | null | #include <iostream>
#include <vector>
#include <random>
#include <string>
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include "phong_shader.hpp"
#include "Shaders/shaders.hpp"
PhongShader::PhongShader()
{
std::string vSSrc = Shaders::getVertexShader();
std::string fSSrc = Shaders::getFragmentShader();
prog = std::make_shared<OGLProgram>();
prog->compileAndAttachShader(vSSrc.c_str(), GL_VERTEX_SHADER);
prog->compileAndAttachShader(fSSrc.c_str(), GL_FRAGMENT_SHADER);
prog->link();
attributeBindingPoints["aPos"] = 0;
attributeBindingPoints["aNormal"] = 1;
binding_point_pos_att = 0;
binding_point_normal_att = 1;
glGenVertexArrays(1, &vao);
glBindVertexArray(vao);
// position
auto pos_loc = prog->getAttributeLocation("aPos");
glVertexAttribFormat(pos_loc, 3, GL_FLOAT, GL_FALSE, 0);
glVertexAttribBinding(pos_loc, attributeBindingPoints["aPos"]);
glEnableVertexAttribArray(pos_loc);
// normals
auto normal_loc = prog->getAttributeLocation("aNormal");
glVertexAttribFormat(normal_loc, 3, GL_FLOAT, GL_FALSE, 0);
glVertexAttribBinding(normal_loc, attributeBindingPoints["aNormal"]);
glEnableVertexAttribArray(normal_loc);
glBindVertexArray(0);
}
PhongShader::~PhongShader()
{
}
void PhongShader::use()
{
prog->use();
}
void PhongShader::draw(Mesh* mesh)
{
glBindVertexArray(vao);
//glBindVertexBuffer(attributeBindingPoints["aPos"], mesh->getPositionsPointer(), 0, 0);
//glBindVertexBuffer(attributeBindingPoints["aNormal"], mesh->getNormalsPointer(), 0, 0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, mesh->getIndecesPointer());
glDrawElements(GL_TRIANGLES, mesh->getFaceIndeces().size(), GL_UNSIGNED_INT, 0);
glBindVertexArray(0);
}
void PhongShader::setAttributeBindingPoint(const char* attr_name, GLuint binding_point)
{
glBindVertexArray(vao);
prog->setAttributeBindingPoint(attr_name, binding_point);
glBindVertexArray(0);
}
void PhongShader::setUniformBlockBindingPoint(const char* unif_name, GLuint binding_point)
{
prog->setUniformBlockBindingPoint(unif_name, binding_point);
}
void PhongShader::setUniformMatrix4(const char* unif_name, const glm::mat4& mat)
{
prog->setUniformMatrix4(unif_name, mat);
}
void PhongShader::setUniformVector3(const char* unif_name, const glm::vec3& vec)
{
prog->setUniformVector3(unif_name, vec);
}
| 29.151899 | 90 | 0.775076 | ZoonLogonEchon |
3a966748ab81325074627b082b498a7023372bc4 | 688 | hpp | C++ | include/gridtools/stencil/core/cache_info.hpp | afanfa/gridtools | 6b1fd1f916d291f9a1cab1d27b48aa0282097d68 | [
"BSD-3-Clause"
] | 36 | 2019-04-05T15:54:48.000Z | 2022-03-31T13:25:40.000Z | include/gridtools/stencil/core/cache_info.hpp | afanfa/gridtools | 6b1fd1f916d291f9a1cab1d27b48aa0282097d68 | [
"BSD-3-Clause"
] | 411 | 2019-04-05T18:51:57.000Z | 2022-03-28T11:52:40.000Z | include/gridtools/stencil/core/cache_info.hpp | afanfa/gridtools | 6b1fd1f916d291f9a1cab1d27b48aa0282097d68 | [
"BSD-3-Clause"
] | 23 | 2019-04-05T15:48:26.000Z | 2021-09-28T16:54:24.000Z | /*
* GridTools
*
* Copyright (c) 2014-2021, ETH Zurich
* All rights reserved.
*
* Please, refer to the LICENSE file in the root directory.
* SPDX-License-Identifier: BSD-3-Clause
*/
#pragma once
#include "../../meta/list.hpp"
namespace gridtools {
namespace stencil {
namespace core {
template <class Plh, class CacheTypes = meta::list<>, class CacheIOPolicies = meta::list<>>
struct cache_info {
using plh_t = Plh;
using cache_types_t = CacheTypes;
using cache_io_policies_t = CacheIOPolicies;
};
} // namespace core
} // namespace stencil
} // namespace gridtools
| 26.461538 | 103 | 0.601744 | afanfa |
3a969ae2733d247d466afff9b84b0edbe343b34f | 1,532 | cpp | C++ | Christmas_Training_2011/Contest_2/GRANICA/granica.cpp | Zubieta/CPP | fb4a3cbf2e4edcc590df15663cd28fb9ecab679c | [
"MIT"
] | 8 | 2017-03-02T07:56:45.000Z | 2021-08-07T20:20:19.000Z | Christmas_Training_2011/Contest_2/GRANICA/granica.cpp | zubie7a/Algorithms | fb4a3cbf2e4edcc590df15663cd28fb9ecab679c | [
"MIT"
] | null | null | null | Christmas_Training_2011/Contest_2/GRANICA/granica.cpp | zubie7a/Algorithms | fb4a3cbf2e4edcc590df15663cd28fb9ecab679c | [
"MIT"
] | 1 | 2021-08-07T20:20:20.000Z | 2021-08-07T20:20:20.000Z | #include <iostream>
#include <numeric>
#include <fstream>
#include <climits>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <deque>
#include <vector>
#include <string>
#include <cstdlib>
#include <cassert>
#include <sstream>
#include <iterator>
#include <algorithm>
#define llu unsigned long long
using namespace std;
int main(){
llu n;
bool divTods;
bool divDiv;
vector<llu> tot;
vector<llu> tat;
while(cin >> n){
tot.clear();
tat.clear();
llu plate[n];
for(llu x=0; x<n; ++x){
cin >> plate[x];
}
sort(plate,plate+n);
for(llu y=1; y<n; ++y){
plate[y]-=plate[0];
}
plate[0]=0;
for(llu x=0; x<n; ++x){
for(llu dv=1; dv*dv<plate[x]; ++dv){
if(plate[x]%dv==0){
divTods=true;
for(llu y=0; y<n && divTods; ++y){
if(plate[y]%dv!=0){
divTods=false;
}
}
if(divTods){
tot.push_back(dv);
}
divDiv=true;
for(llu y=0; y<n && divDiv; ++y){
if(plate[y]%(plate[x]/dv)!=0){
divDiv=false;
}
}
if(divDiv){
tot.push_back(plate[x]/dv);
}
}
}
}
for(llu z=0;z<tot.size();++z){
if(tot[z]!=1){
cout << tot[z];
if(z+1!=tot.size()){
cout << " ";
}
for(llu s=0;s<tot.size();++s){
if(tot[s]!=tot[z]){
tat.push_back(tot[s]);
}
}
tot.clear();
for(llu s=0;s<tat.size();++s){
tot.push_back(tat[s]);
}
tat.clear();
z=0;
}
}
cout << endl;
}
} | 17.609195 | 39 | 0.528068 | Zubieta |
3a9714ebd6d3d4cf174b8e8d3546cdfdf910ad69 | 8,527 | cpp | C++ | ugene/src/plugins/genome_aligner/src/GenomeAlignerSettingsWidget.cpp | iganna/lspec | c75cba3e4fa9a46abeecbf31b5d467827cf4fec0 | [
"MIT"
] | null | null | null | ugene/src/plugins/genome_aligner/src/GenomeAlignerSettingsWidget.cpp | iganna/lspec | c75cba3e4fa9a46abeecbf31b5d467827cf4fec0 | [
"MIT"
] | null | null | null | ugene/src/plugins/genome_aligner/src/GenomeAlignerSettingsWidget.cpp | iganna/lspec | c75cba3e4fa9a46abeecbf31b5d467827cf4fec0 | [
"MIT"
] | null | null | null | /**
* UGENE - Integrated Bioinformatics Tools.
* Copyright (C) 2008-2012 UniPro <ugene@unipro.ru>
* http://ugene.unipro.ru
*
* 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.
*/
#include "GenomeAlignerIndex.h"
#include "GenomeAlignerSettingsController.h"
#include "GenomeAlignerTask.h"
#include <U2Core/AppContext.h>
#include <U2Core/AppResources.h>
#include <U2Core/AppSettings.h>
#include <U2Core/GUrl.h>
#include <U2Core/UserApplicationsSettings.h>
#include <U2Algorithm/OpenCLGpuRegistry.h>
#include <U2Gui/LastUsedDirHelper.h>
#include "GenomeAlignerSettingsWidget.h"
#include <QtGui/QFileDialog>
namespace U2 {
static const int MIN_READ_SIZE = 10;
static const int MIN_PART_SIZE = 1;
static const int DEFAULT_PART_SIZE = 10;
GenomeAlignerSettingsWidget::GenomeAlignerSettingsWidget(QWidget* parent) : DnaAssemblyAlgorithmMainWidget(parent) {
setupUi(this);
tabWidget->setCurrentIndex(0);
layout()->setContentsMargins(0,0,0,0);
connect(buildIndexFileButton, SIGNAL(clicked()), SLOT(sl_onSetIndexDirButtonClicked()));
connect(partSlider, SIGNAL(valueChanged(int)), SLOT(sl_onPartSliderChanged(int)));
connect(readSlider, SIGNAL(valueChanged(int)), SLOT(sl_onReadSliderChanged(int)));
buildIndexFileButton->toggle();
#ifdef OPENCL_SUPPORT
if (AppContext::getOpenCLGpuRegistry()->getEnabledGpus().empty()) {
#endif
gpuBox->setEnabled(false);
#ifdef OPENCL_SUPPORT
}
#endif
systemSize = AppContext::getAppSettings()->getAppResourcePool()->getMaxMemorySizeInMB();
systemSize = systemSize < 2000 ? systemSize : 2000; // TODO: UGENE-1181
partSlider->setEnabled(false);
readSlider->setMinimum(MIN_READ_SIZE);
readSlider->setMaximum(systemSize);
readSlider->setValue(systemSize*2/3);
QString indexDirPath = GenomeAlignerSettingsUtils::getIndexDir();
QDir indexDir(indexDirPath);
indexDir.mkpath(indexDirPath);
indexDirEdit->setText(indexDirPath);
partSizeLabel->setText(QByteArray::number(partSlider->value()) + " Mb");
indexSizeLabel->setText(QByteArray::number(partSlider->value()*13) + " Mb");
totalSizeLabel->setText(QByteArray::number(partSlider->value()*13 + readSlider->value()) + " Mb");
systemSizeLabel->setText(QByteArray::number(systemSize) + " Mb");
}
QMap<QString,QVariant> GenomeAlignerSettingsWidget::getDnaAssemblyCustomSettings() {
QMap<QString,QVariant> settings;
settings.insert(GenomeAlignerTask::OPTION_ALIGN_REVERSED, reverseBox->isChecked());
settings.insert(GenomeAlignerTask::OPTION_OPENCL, gpuBox->isChecked());
settings.insert(GenomeAlignerTask::OPTION_BEST, firstMatchBox->isChecked());
settings.insert(GenomeAlignerTask::OPTION_READS_MEMORY_SIZE, readSlider->value());
settings.insert(GenomeAlignerTask::OPTION_SEQ_PART_SIZE, partSlider->value());
settings.insert(GenomeAlignerTask::OPTION_INDEX_DIR, indexDirEdit->text());
if (omitQualitiesBox->isChecked()) {
settings.insert(GenomeAlignerTask::OPTION_QUAL_THRESHOLD, qualThresholdBox->value() );
}
if (groupBox_mismatches->isChecked()) {
settings.insert(GenomeAlignerTask::OPTION_MISMATCHES, mismatchesAllowedSpinBox->value());
settings.insert(GenomeAlignerTask::OPTION_IF_ABS_MISMATCHES, absRadioButton->isChecked());
settings.insert(GenomeAlignerTask::OPTION_PERCENTAGE_MISMATCHES, percentMismatchesAllowedSpinBox->value());
} else {
settings.insert(GenomeAlignerTask::OPTION_MISMATCHES, 0);
settings.insert(GenomeAlignerTask::OPTION_IF_ABS_MISMATCHES, true);
settings.insert(GenomeAlignerTask::OPTION_PERCENTAGE_MISMATCHES, 0);
}
return settings;
}
bool GenomeAlignerSettingsWidget::buildIndexUrl(const GUrl& url, bool prebuiltIndex, QString &error) {
if (prebuiltIndex) {
GenomeAlignerIndex index;
index.baseFileName = url.dirPath() + "/" + url.baseFileName();
QByteArray e;
bool res = index.deserialize(e);
if (!res || url.lastFileSuffix() != GenomeAlignerIndex::HEADER_EXTENSION) {
error = tr("This index file is corrupted. Please, load a valid index file.");
return false;
}
partSlider->setMinimum(MIN_PART_SIZE);
partSlider->setMaximum(index.seqPartSize);
partSlider->setEnabled(true);
partSlider->setValue(index.seqPartSize);
} else {
QString refUrl = url.getURLString();
QFile file(refUrl);
if (file.exists()) {
int fileSize = 1 + (int)(file.size()/(1024*1024));
int maxPartSize = qMin(fileSize*13, systemSize - MIN_READ_SIZE)/13;
partSlider->setMinimum(MIN_PART_SIZE);
partSlider->setMaximum(maxPartSize);
partSlider->setEnabled(true);
partSlider->setValue(qMin(maxPartSize, DEFAULT_PART_SIZE));
}
}
return true;
}
void GenomeAlignerSettingsWidget::prebuiltIndex(bool value) {
indexTab->setEnabled(!value);
}
bool GenomeAlignerSettingsWidget::isParametersOk(QString &error) {
bool gpuOk = (gpuBox->isChecked() == false) || ((gpuBox->isChecked() == true) && (partSlider->value() <= 10)); // 128MB is the minimum size for a buffer, according to CL_DEVICE_MAX_MEM_ALLOC_SIZE OpenCL documentation
if ((systemSize < readSlider->value() + 13*partSlider->value()) || !gpuOk) {
error = "There is no enough memory for the aligning on your computer. Try to reduce a memory size for short reads or for the reference fragment.";
return false;
}
return true;
}
bool GenomeAlignerSettingsWidget::isIndexOk(QString &error, GUrl refName) {
GenomeAlignerIndex index;
if (indexTab->isEnabled()) { //prebuiltIndex is not checked
index.baseFileName = indexDirEdit->text() + "/" + refName.baseFileName();
} else {
index.baseFileName = refName.dirPath() + "/" + refName.baseFileName();
}
QByteArray e;
bool res = index.deserialize(e);
if (indexTab->isEnabled()) { //prebuiltIndex is not checked
if (!res) {
return true;
}
if (index.seqPartSize == partSlider->value()) {
return true;
}
error = tr("The index directory has already contain the prebuilt index. But its reference fragmentation parameter is %1 and it doesn't equal to \
the parameter you have chosen (%2).\n\nPress \"Ok\" to delete this index file and create a new during the aligning.\nPress \"Cancel\" to change this parameter \
or the index directory.").arg(index.seqPartSize).arg(partSlider->value());
return false;
} else {
if (!res || refName.lastFileSuffix() != GenomeAlignerIndex::HEADER_EXTENSION) {
error = tr("This index file is corrupted. Please, load a valid index file.");
return false;
}
return true;
}
}
void GenomeAlignerSettingsWidget::sl_onSetIndexDirButtonClicked() {
LastUsedDirHelper lod;
lod.url = QFileDialog::getExistingDirectory(this, tr("Set index files directory"), indexDirEdit->text());
if (!lod.url.isEmpty()) {
GUrl result = lod.url;
indexDirEdit->setText(result.getURLString());
}
}
void GenomeAlignerSettingsWidget::sl_onPartSliderChanged(int value) {
partSizeLabel->setText(QByteArray::number(value) + " Mb");
indexSizeLabel->setText(QByteArray::number(value*13) + " Mb");
if (systemSize - 13*value >= MIN_READ_SIZE) {
readSlider->setMaximum(systemSize - 13*value);
} else {
readSlider->setMaximum(MIN_READ_SIZE);
}
totalSizeLabel->setText(QByteArray::number(value*13 + readSlider->value()) + " Mb");
}
void GenomeAlignerSettingsWidget::sl_onReadSliderChanged(int value) {
readSizeLabel->setText(QByteArray::number(value) + " Mb");
totalSizeLabel->setText(QByteArray::number(partSlider->value()*13 + value) + " Mb");
}
} //namespace
| 40.412322 | 220 | 0.705055 | iganna |
3a97da9892b03ccef4769225e3cead0e9d12c85f | 1,891 | cpp | C++ | src/telecom/src/telecomTest.cpp | GOFIRST-Robotics/NASA-Lunabotics-2022 | 6b9a2f8fa6e6a025274b3c5b305ef8bb07a42aa5 | [
"MIT"
] | 3 | 2021-11-05T22:05:40.000Z | 2022-01-25T23:58:40.000Z | src/telecom/src/telecomTest.cpp | GOFIRST-Robotics/NASA-Lunabotics-2022 | 6b9a2f8fa6e6a025274b3c5b305ef8bb07a42aa5 | [
"MIT"
] | 35 | 2019-10-12T15:34:30.000Z | 2020-10-07T23:45:03.000Z | src/telecom/src/telecomTest.cpp | GOFIRST-Robotics/NASA-RMC-2020-NorthstarRobotics | fd69e48baba53990fa60624005707b5edfb65741 | [
"MIT"
] | 2 | 2021-11-05T23:42:32.000Z | 2021-11-05T23:59:55.000Z | #include <cstdio>
#include <cstring>
#include <string>
//http://wjwwood.io/serial/doc/1.1.0/classserial_1_1_serial.html
#include "telecom/telecom.h"
#define ERR_CHECK \
do { if (com.status() != 0){ \
fprintf(stdout, "Error: %s\n", com.verboseStatus().c_str()); \
return com.status(); \
} } while(0)
int main(int argc, char *argv[]){
if (argc != 4){
fprintf(stderr, "usage: ./programname dst-hostname dst-udpport src-udpport\n");
exit(1);
}
Telecom com(argv[1], atoi(argv[2]), atoi(argv[3]));
com.setFailureAction(false);
com.setBlockingTime(0,0);
ERR_CHECK;
time_t timer;
time(&timer);
// Joystick js(); // #include "joystick.hh"
// Exit if !js.isFound()
// com.fdAdd(js.fd());
while(1){
com.update();
ERR_CHECK;
// JoystickEvent event;
// Receive from remote
if(com.recvAvail()){
std::string msg = com.recv();
//ERR_CHECK; // This makes it crash???
if(!msg.empty())
printf("Received message: %s\n", msg.c_str());
if(!msg.compare("EOM\n")){ break; } // delete if not want remote close
}
// Reboot if comunication channel closed
while(com.isComClosed()){
printf("Rebooting connection\n");
com.reboot();
}
// Get user stdio input to send
if(com.stdioReadAvail()){
std::string msg = com.stdioRead();
ERR_CHECK;
if(!msg.compare("EOM\n")){ // Assume desired for connection to close
com.send(msg); // Delete for debug connection testing
printf("Received EOM closing\n");
break;
}
com.send(msg);
ERR_CHECK;
}
// Example if including joystick
// if(com.fdReadAvail(js.fd()) && js.sample(&event)){
// ... process buttons and axis of event ... }
// heartbeat
if(difftime(time(NULL), timer) > 10){
timer = time(NULL);
printf(".\n");
}
}
}
| 23.936709 | 83 | 0.584876 | GOFIRST-Robotics |
3a981a399776b3a9d0d67b986dff21ebb8eca481 | 989 | cpp | C++ | 06-class-design/readerEx.06.05/main.cpp | heavy3/programming-abstractions | e10eab5fe7d9ca7d7d4cc96551524707214e43a8 | [
"MIT"
] | 81 | 2018-11-15T21:23:19.000Z | 2022-03-06T09:46:36.000Z | 06-class-design/readerEx.06.05/main.cpp | heavy3/programming-abstractions | e10eab5fe7d9ca7d7d4cc96551524707214e43a8 | [
"MIT"
] | null | null | null | 06-class-design/readerEx.06.05/main.cpp | heavy3/programming-abstractions | e10eab5fe7d9ca7d7d4cc96551524707214e43a8 | [
"MIT"
] | 41 | 2018-11-15T21:23:24.000Z | 2022-02-24T03:02:26.000Z | //
// main.cpp
//
// Exercises the calendar class.
//
// --------------------------------------------------------------------------
// Attribution: "Programming Abstractions in C++" by Eric Roberts
// Chapter 6, Exercise 5
// Stanford University, Autumn Quarter 2012
// http://web.stanford.edu/class/archive/cs/cs106b/cs106b.1136/materials/CS106BX-Reader.pdf
// --------------------------------------------------------------------------
//
// Created by Glenn Streiff on 12/16/15.
// Copyright © 2015 Glenn Streiff. All rights reserved.
//
#include <iostream>
#include "calendar.h"
const std::string HEADER = "CS106B Programming Abstractions in C++: Ex 6.5\n";
const std::string DETAIL = "Extend the Ex 2.11 calendar.h interface.";
const std::string BANNER = HEADER + DETAIL;
int main(int argc, char * argv[]) {
std::cout << BANNER << std::endl << std::endl;
Date moonLanding(JULY, 20, 1969);
std::cout << moonLanding.toString() << std::endl;
return 0;
}
| 29.969697 | 91 | 0.570273 | heavy3 |
3a993c8a2f338804af21fad468bb1c62b8bdad4b | 1,346 | cpp | C++ | src/0019_RemoveNthNodeFromEndofList/solution.cpp | hustzxd/leetcode | 83828602183e4709a6f20f163951e10b66f26935 | [
"MIT"
] | null | null | null | src/0019_RemoveNthNodeFromEndofList/solution.cpp | hustzxd/leetcode | 83828602183e4709a6f20f163951e10b66f26935 | [
"MIT"
] | null | null | null | src/0019_RemoveNthNodeFromEndofList/solution.cpp | hustzxd/leetcode | 83828602183e4709a6f20f163951e10b66f26935 | [
"MIT"
] | null | null | null | #include "../../include/solution.h"
class Solution {
public:
ListNode* removeNthFromEnd(ListNode* head, int n) {
int len = 0;
auto tail = head;
while (tail) {
len++;
tail = tail->next;
}
int id = 0;
ListNode* fake_head = new ListNode(0);
fake_head->next = head;
tail = fake_head;
while (tail) {
if (id == len - n) {
if (tail->next) tail->next = tail->next->next;
break;
}
tail = tail->next;
id++;
}
return fake_head->next;
}
ListNode* removeNthFromEndv2(ListNode* head, int n) {
ListNode* dummy = new ListNode();
dummy->next = head;
ListNode* slow = dummy;
ListNode* fast = dummy;
int gap = n + 1;
while (gap--) {
fast = fast->next;
}
while (fast) {
slow = slow->next;
fast = fast->next;
}
slow->next = slow->next->next;
return dummy->next;
}
};
int main() {
string line;
while (getline(cin, line)) {
ListNode* head = stringToListNode(line);
prettyPrintLinkedList(head);
head = Solution().removeNthFromEndv2(head, 2);
prettyPrintLinkedList(head);
}
return 0;
} | 24.925926 | 62 | 0.478455 | hustzxd |
3a9aab6dd9ef4684f24f77565cb943b6ef268c29 | 2,100 | cpp | C++ | Sources/AGEngine/Skinning/AnimationChannel.cpp | Another-Game-Engine/AGE | d5d9e98235198fe580a43007914f515437635830 | [
"MIT"
] | 47 | 2015-03-29T09:44:25.000Z | 2020-11-30T10:05:56.000Z | Sources/AGEngine/Skinning/AnimationChannel.cpp | Another-Game-Engine/AGE | d5d9e98235198fe580a43007914f515437635830 | [
"MIT"
] | 313 | 2015-01-01T18:16:30.000Z | 2015-11-30T07:54:07.000Z | Sources/AGEngine/Skinning/AnimationChannel.cpp | Another-Game-Engine/AGE | d5d9e98235198fe580a43007914f515437635830 | [
"MIT"
] | 9 | 2015-06-07T13:21:54.000Z | 2020-08-25T09:50:07.000Z | #include "AnimationChannel.hpp"
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtx/transform.hpp>
#include <glm/gtx/quaternion.hpp>
#include <glm/gtc/quaternion.hpp>
#include <glm/gtx/matrix_interpolation.hpp>
#include <Utils/Serialization/SerializationArchives.hpp>
namespace AGE{
void AnimationChannel::findKeyIndex(float t, glm::uvec3 &keys, glm::uvec3 &nextKeys)
{
if (scale.size() <= 1)
{
keys.x = 0;
nextKeys.x = 0;
}
else
{
for (unsigned int i = 0; i < scale.size() - 1; i++)
{
if (t < scale[i + 1].time) {
keys.x = i;
nextKeys.x = i + 1;
break;
}
}
}
if (rotation.size() <= 1)
{
keys.y = 0;
nextKeys.y = 0;
}
else
{
for (unsigned int i = 0; i < rotation.size() - 1; i++)
{
if (t < rotation[i + 1].time) {
keys.y = i;
nextKeys.y = i + 1;
break;
}
}
}
if (translation.size() <= 1)
{
keys.z = 0;
nextKeys.z = 0;
}
else
{
for (unsigned int i = 0; i < translation.size() - 1; i++)
{
if (t < translation[i + 1].time) {
keys.z = i;
nextKeys.z = i + 1;
break;
}
}
}
}
void AnimationChannel::getInterpolatedTransform(float t, glm::mat4 &res)
{
glm::uvec3 key = glm::uvec3(static_cast<unsigned int>(t));
glm::uvec3 nextKey = glm::uvec3(key.x + 1);
findKeyIndex(t, key, nextKey);
res = glm::translate(glm::mat4(1), glm::mix(translation[key.z].value, translation[nextKey.z].value, (t - translation[key.z].time) / translation[key.z].deltaTime));
res = glm::scale(res, glm::mix(scale[key.x].value, scale[nextKey.x].value, (t - scale[key.x].time) / scale[key.x].deltaTime));
res *= glm::mat4_cast(glm::normalize(glm::slerp(rotation[key.y].value, rotation[nextKey.y].value, (t - rotation[key.y].time) / rotation[key.y].deltaTime)));
}
}
SERIALIZATION_SERIALIZE_METHOD_DEFINITION(AGE::AnimationChannel, *"*/ ar(cereal::make_nvp(MACRO_STR(bone), boneIndex)); ar(cereal::make_nvp(MACRO_STR(scale), scale)); ar(cereal::make_nvp(MACRO_STR(rotation), rotation)); ar(cereal::make_nvp(MACRO_STR(translation), translation)); /*"*);
| 25.925926 | 285 | 0.618571 | Another-Game-Engine |
3a9ae9d17e1f973d051482a903d48ef8b5303db3 | 2,380 | cpp | C++ | tcbn/cplus/create/tcbn_create.cpp | ekzemplaro/data_base_language | e77030367ffc595f1fac8583f03f9a3ce5eb1611 | [
"MIT",
"Unlicense"
] | 3 | 2015-05-12T16:44:27.000Z | 2021-02-09T00:39:24.000Z | tcbn/cplus/create/tcbn_create.cpp | ekzemplaro/data_base_language | e77030367ffc595f1fac8583f03f9a3ce5eb1611 | [
"MIT",
"Unlicense"
] | null | null | null | tcbn/cplus/create/tcbn_create.cpp | ekzemplaro/data_base_language | e77030367ffc595f1fac8583f03f9a3ce5eb1611 | [
"MIT",
"Unlicense"
] | null | null | null | // --------------------------------------------------------------------
/*
tcbn_create.cpp
Dec/27/2011
*/
// --------------------------------------------------------------------
#include <iostream>
#include <cstring>
#include <map>
#include <tcbdb.h>
using namespace std;
// --------------------------------------------------------------------
typedef map<string,string> Unit;
// --------------------------------------------------------------------
extern map <string,Unit> dict_append_proc
(map <string,Unit> dict_aa,string id,string name,
int population,string date_mod);
// --------------------------------------------------------------------
extern void tcbn_display_proc (TCBDB *bdb);
extern void dict_to_tcbn_proc (map <string,Unit> dict_aa,TCBDB *bdb);
// --------------------------------------------------------------------
static map <string,Unit > data_prepare_proc ()
{
map <string,Unit> dict_aa;
dict_aa = dict_append_proc (dict_aa,"t0831","水戸",52673,"1922-11-7");
dict_aa = dict_append_proc (dict_aa,"t0832","古河",98231,"1922-12-12");
dict_aa = dict_append_proc (dict_aa,"t0833","結城",23429,"1922-3-28");
dict_aa = dict_append_proc (dict_aa,"t0834","土浦",51486,"1922-9-21");
dict_aa = dict_append_proc (dict_aa,"t0835","牛久",83971,"1922-1-5");
dict_aa = dict_append_proc (dict_aa,"t0836","取手",74948,"1922-5-22");
dict_aa = dict_append_proc (dict_aa,"t0837","つくば",46785,"1922-7-17");
dict_aa = dict_append_proc (dict_aa,"t0838","日立",59614,"1922-3-04");
dict_aa = dict_append_proc (dict_aa,"t0839","守谷",71823,"1922-5-9");
return dict_aa;
}
// --------------------------------------------------------------------
int main(int argc, char *argv[])
{
char file_in[160];
char id_in[10];
int population_in;
TCBDB *bdb;
int ecode;
cerr << "*** 開始 ***\n";
strcpy (file_in,argv[1]);
cerr << file_in << '\n';
map <string,Unit> dict_aa = data_prepare_proc ();
bdb = tcbdbnew();
if(!tcbdbopen(bdb, file_in, BDBOWRITER | BDBOCREAT))
{
ecode = tcbdbecode(bdb);
fprintf(stderr, "open error: %s\n", tcbdberrmsg(ecode));
}
dict_to_tcbn_proc (dict_aa,bdb);
tcbn_display_proc (bdb);
if(!tcbdbclose(bdb))
{
ecode = tcbdbecode(bdb);
fprintf(stderr, "close error: %s\n", tcbdberrmsg(ecode));
}
tcbdbdel(bdb);
cerr << "*** 終了 ***\n";
return 0;
}
// --------------------------------------------------------------------
| 26.153846 | 71 | 0.515126 | ekzemplaro |
3a9b4ced3ebb2d74b1cb8a18b6e42f117ba63d10 | 2,229 | hpp | C++ | randomprime/nod_wrapper/nod/include/nod/IFileIO.hpp | MeriKatt/metroid-prime-randomizer-custom | c431358af2ce3159909c1ae26034547053560fc6 | [
"MIT"
] | null | null | null | randomprime/nod_wrapper/nod/include/nod/IFileIO.hpp | MeriKatt/metroid-prime-randomizer-custom | c431358af2ce3159909c1ae26034547053560fc6 | [
"MIT"
] | null | null | null | randomprime/nod_wrapper/nod/include/nod/IFileIO.hpp | MeriKatt/metroid-prime-randomizer-custom | c431358af2ce3159909c1ae26034547053560fc6 | [
"MIT"
] | null | null | null | #pragma once
#include <memory>
#include <functional>
#include <cstdlib>
#include "IDiscIO.hpp"
#include "Util.hpp"
namespace nod {
class IFileIO {
public:
virtual ~IFileIO() = default;
virtual bool exists() = 0;
virtual uint64_t size() = 0;
struct IWriteStream : nod::IWriteStream {
uint64_t copyFromDisc(IPartReadStream& discio, uint64_t length) {
uint64_t read = 0;
uint8_t buf[0x7c00];
while (length) {
uint64_t thisSz = nod::min(uint64_t(0x7c00), length);
uint64_t readSz = discio.read(buf, thisSz);
if (thisSz != readSz) {
LogModule.report(logvisor::Error, "unable to read enough from disc");
return read;
}
if (write(buf, readSz) != readSz) {
LogModule.report(logvisor::Error, "unable to write in file");
return read;
}
length -= thisSz;
read += thisSz;
}
return read;
}
uint64_t copyFromDisc(IPartReadStream& discio, uint64_t length, const std::function<void(float)>& prog) {
uint64_t read = 0;
uint8_t buf[0x7c00];
uint64_t total = length;
while (length) {
uint64_t thisSz = nod::min(uint64_t(0x7c00), length);
uint64_t readSz = discio.read(buf, thisSz);
if (thisSz != readSz) {
LogModule.report(logvisor::Error, "unable to read enough from disc");
return read;
}
if (write(buf, readSz) != readSz) {
LogModule.report(logvisor::Error, "unable to write in file");
return read;
}
length -= thisSz;
read += thisSz;
prog(read / float(total));
}
return read;
}
};
virtual std::unique_ptr<IWriteStream> beginWriteStream() const = 0;
virtual std::unique_ptr<IWriteStream> beginWriteStream(uint64_t offset) const = 0;
struct IReadStream : nod::IReadStream {
virtual uint64_t copyToDisc(struct IPartWriteStream& discio, uint64_t length) = 0;
};
virtual std::unique_ptr<IReadStream> beginReadStream() const = 0;
virtual std::unique_ptr<IReadStream> beginReadStream(uint64_t offset) const = 0;
};
std::unique_ptr<IFileIO> NewFileIO(SystemStringView path, int64_t maxWriteSize = -1);
} // namespace nod
| 30.958333 | 109 | 0.631225 | MeriKatt |
3a9b949a19b0a3b27a2ae6c287d8caa4d4e2a04d | 633 | cpp | C++ | tests/101-150/test_problem106.cpp | abeccaro/project-euler | c3b124bb973dc3a1cf29e8c96c3e70c8816d5fa3 | [
"MIT"
] | 1 | 2019-12-25T10:17:15.000Z | 2019-12-25T10:17:15.000Z | tests/101-150/test_problem106.cpp | abeccaro/project-euler | c3b124bb973dc3a1cf29e8c96c3e70c8816d5fa3 | [
"MIT"
] | null | null | null | tests/101-150/test_problem106.cpp | abeccaro/project-euler | c3b124bb973dc3a1cf29e8c96c3e70c8816d5fa3 | [
"MIT"
] | null | null | null | //
// Created by Alex Beccaro on 03/12/18.
//
#define BOOST_TEST_DYN_LINK
#include <boost/test/unit_test.hpp>
#include "../../src/problems/101-150/106/problem106.hpp"
BOOST_AUTO_TEST_SUITE( Problem106 )
BOOST_AUTO_TEST_CASE( Example1 ) {
auto res = problems::problem106::solve(4);
BOOST_CHECK_EQUAL(res, 1);
}
BOOST_AUTO_TEST_CASE( Example2 ) {
auto res = problems::problem106::solve(7);
BOOST_CHECK_EQUAL(res, 70);
}
BOOST_AUTO_TEST_CASE( Solution ) {
auto res = problems::problem106::solve();
BOOST_CHECK_EQUAL(res, 21384);
}
BOOST_AUTO_TEST_SUITE_END() | 24.346154 | 56 | 0.665087 | abeccaro |
3a9ba823687c515f5d6f983ecc6e237fcc37bf80 | 5,030 | cpp | C++ | lib/tw/authenticator.cpp | frolv/lynxbot | e9c2e9ba23eca8918d69215850bd094488b9a33a | [
"MIT"
] | 3 | 2016-07-12T21:42:09.000Z | 2016-08-31T05:49:40.000Z | lib/tw/authenticator.cpp | frolv/osrs-twitch-bot | e9c2e9ba23eca8918d69215850bd094488b9a33a | [
"MIT"
] | null | null | null | lib/tw/authenticator.cpp | frolv/osrs-twitch-bot | e9c2e9ba23eca8918d69215850bd094488b9a33a | [
"MIT"
] | 1 | 2016-05-26T14:59:11.000Z | 2016-05-26T14:59:11.000Z | #include <algorithm>
#include <ctime>
#include <fstream>
#include <iostream>
#include <sstream>
#include <openssl/hmac.h>
#include <tw/authenticator.h>
#include <tw/base64.h>
#include <tw/oauth.h>
#include <utils.h>
static const char *INSTRUCTIONS = "In order to allow LynxBot to use your "
"Twitter account, you must register it as a Twitter app. This is done by "
"signing into https://apps.twitter.com and clicking the \"Create New App\" "
"button. Give your app a unique name (e.g. lynxbot-TWITTERNAME), fill in the "
"rest of the form and agree to the Developer Agreement.\n\nOnce you submit the "
"form you will be redirected to your app's overview page. You can change the "
"access level to read only (LynxBot does not do any writing).\nNext, click the "
"Keys and Access Tokens tab. Under \"Your Access Token\", click Create my "
"access token to generate access tokens for LynxBot.\n\nYou will now see four "
"tokens on the page:\nConsumer Key\nConsumer Secret\nAccess Token\nAccess "
"Token Secret\nYou will need to enter them into this console.\n\nWARNING: "
"Your access tokens will be stored in plaintext.\n";
static void get_str(std::string &target);
tw::Authenticator::Authenticator()
{
configpath = utils::configdir() + utils::config("twitter");
if (read_keys() == -1)
interactive_setup();
}
/* siggen: generate an oauth signature for a twitter api request */
void tw::Authenticator::siggen(const std::string &method, const std::string &URL,
const param_vec &head_params, const param_vec &body_params)
{
size_t i;
std::vector<std::string> enc_params;
std::string base_str, signing_key;
unsigned char digest[1024];
unsigned int digest_len;
/* get ouath data */
odata.c_key = consumerkey;
odata.nonce = noncegen();
odata.sig_method = "HMAC-SHA1";
odata.timestamp = std::to_string(time(nullptr));
odata.token = token;
odata.version = "1.0";
/* generate the base string */
for (auto p : head_params)
enc_params.push_back(pencode(p.first) + "=" + pencode(p.second));
for (auto p : body_params)
enc_params.push_back(pencode(p.first) + "=" + pencode(p.second));
enc_params.push_back("oauth_consumer_key=" + odata.c_key);
enc_params.push_back("oauth_nonce=" + odata.nonce);
enc_params.push_back("oauth_signature_method=" + odata.sig_method);
enc_params.push_back("oauth_timestamp=" + odata.timestamp);
enc_params.push_back("oauth_token=" + odata.token);
enc_params.push_back("oauth_version=" + odata.version);
std::sort(enc_params.begin(), enc_params.end());
std::string param_str;
for (i = 0; i < enc_params.size(); ++i) {
param_str += enc_params[i];
if (i != enc_params.size() - 1)
param_str += '&';
}
base_str += method + "&";
base_str += pencode(URL) + "&";
base_str += pencode(param_str);
/* get the signing key */
signing_key += pencode(consumersecret) + "&";
signing_key += pencode(tokensecret);
HMAC(EVP_sha1(), signing_key.c_str(), signing_key.length(),
(unsigned char *)base_str.c_str(), base_str.length(),
digest, &digest_len);
odata.sig = base64_enc((char *)digest, digest_len);
}
struct tw::Authenticator::oauth_data tw::Authenticator::auth_data()
{
return odata;
}
/* read_keys: read twitter keys from file (will be encrypted eventually) */
int tw::Authenticator::read_keys()
{
std::ifstream reader(configpath);
std::string line;
int lnum = 0;
if (!reader.is_open())
return -1;
while (std::getline(reader, line)) {
switch (++lnum) {
case 1:
consumerkey = line;
break;
case 2:
consumersecret = line;
break;
case 3:
token = line;
break;
case 4:
tokensecret = line;
break;
default:
return 1;
}
}
if (lnum != 4)
return 1;
return 0;
}
/* interactive_setup: obtain access tokens from user */
void tw::Authenticator::interactive_setup()
{
char c = '\0';
std::cout << configpath << " was not found." << std::endl;
std::cout << "Would you like to set up LynxBot to use Twitter? (y/n) ";
std::ofstream writer(configpath);
while (c != 'y' && c != 'n')
std::cin >> c;
if (c == 'n')
return;
std::cout << INSTRUCTIONS << std::endl;
std::cout << "Would you like to proceed? (y/n) ";
c = '\0';
while (c != 'y' && c != 'n')
std::cin >> c;
if (c == 'n')
return;
std::cout << "Enter your Consumer Key:" << std::endl;
get_str(consumerkey);
std::cout << "Enter your Consumer Secret:" << std::endl;
get_str(consumersecret);
std::cout << "Enter your Access Token:" << std::endl;
get_str(token);
std::cout << "Enter your Access Token Secret:" << std::endl;
get_str(tokensecret);
writer << consumerkey << std::endl << consumersecret << std::endl
<< token << std::endl << tokensecret << std::endl;
writer.close();
std::cout << "Your tokens have been saved to " << configpath
<< std::endl;
std::cin.get();
}
/* get_str: read a string from stdin */
static void get_str(std::string &target)
{
std::string line;
while (true) {
std::getline(std::cin, line);
if (!line.empty()) break;
std::cout << "Invalid string, try again:" << std::endl;
}
target = line;
}
| 28.418079 | 81 | 0.677932 | frolv |
3a9c2c8ace80b2c950d73f03b17e79f60d49363e | 6,685 | cpp | C++ | Schweizer-Messer/sm_kinematics/test/UncertainTransformationTests.cpp | PushyamiKaveti/kalibr | d8bdfc59ee666ef854012becc93571f96fe5d80c | [
"BSD-4-Clause"
] | 2,690 | 2015-01-07T03:50:23.000Z | 2022-03-31T20:27:01.000Z | Schweizer-Messer/sm_kinematics/test/UncertainTransformationTests.cpp | PushyamiKaveti/kalibr | d8bdfc59ee666ef854012becc93571f96fe5d80c | [
"BSD-4-Clause"
] | 481 | 2015-01-27T10:21:00.000Z | 2022-03-31T14:02:41.000Z | Schweizer-Messer/sm_kinematics/test/UncertainTransformationTests.cpp | PushyamiKaveti/kalibr | d8bdfc59ee666ef854012becc93571f96fe5d80c | [
"BSD-4-Clause"
] | 1,091 | 2015-01-26T21:21:13.000Z | 2022-03-30T01:55:33.000Z | // Bring in gtest
#include <gtest/gtest.h>
#include <boost/cstdint.hpp>
// Helpful functions from libsm
#include <sm/eigen/gtest.hpp>
#include <sm/kinematics/quaternion_algebra.hpp>
#include <sm/kinematics/UncertainTransformation.hpp>
TEST(UncertainTransformationTestSuite, testConstructor)
{
using namespace sm::kinematics;
UncertainTransformation T_a_b;
Eigen::Matrix4d T;
T.setIdentity();
UncertainTransformation::covariance_t U;
U.setZero();
sm::eigen::assertNear(T, T_a_b.T(), 1e-10, SM_SOURCE_FILE_POS, "Checking for the default constructor creating identity");
sm::eigen::assertNear(U, T_a_b.U(), 1e-10, SM_SOURCE_FILE_POS, "Checking for the default constructor creating zero uncertainty");
}
TEST(UncertainTransformationTestSuite, testTV4Multiplication)
{
using namespace sm::kinematics;
for(int i = 0; i < 100; i++)
{
UncertainTransformation T_a_b;
T_a_b.setRandom();
Eigen::Vector4d v_b;
v_b.setRandom();
v_b *= 100.0;
Eigen::Vector4d v_a = T_a_b * v_b;
Eigen::Vector4d v_a_prime = T_a_b.T() * v_b;
sm::eigen::assertNear(v_a, v_a_prime, 1e-10, SM_SOURCE_FILE_POS, "Checking for composition equal to matrix multiplication");
}
}
TEST(UncertainTransformationTestSuite, testTVhMultiplication)
{
using namespace sm::kinematics;
for(int i = 0; i < 100; i++)
{
UncertainTransformation T_a_b;
T_a_b.setRandom();
Eigen::Vector3d v_b;
v_b.setRandom();
v_b *= 100.0;
HomogeneousPoint V_b(v_b);
Eigen::Vector3d v_a = T_a_b * v_b;
HomogeneousPoint V_a = T_a_b * V_b;
sm::eigen::assertNear(V_a.toEuclidean(), v_a, 1e-10, SM_SOURCE_FILE_POS, "Checking for composition equal to matrix multiplication");
}
}
TEST(UncertainTransformationTestSuite, testTVMultiplication)
{
using namespace sm::kinematics;
for(int i = 0; i < 100; i++)
{
UncertainTransformation T_a_b;
T_a_b.setRandom();
Eigen::Vector3d v_b;
v_b.setRandom();
v_b *= 100.0;
Eigen::Vector3d v_a = T_a_b * v_b;
Eigen::Vector3d v_a_prime = T_a_b.C() * v_b + T_a_b.t();
sm::eigen::assertNear(v_a, v_a_prime, 1e-10, SM_SOURCE_FILE_POS, "Checking for composition equal to matrix multiplication");
}
}
TEST(UncertainTransformationTestSuite, testTTMultiplication)
{
try {
using namespace sm::kinematics;
for(int i = 0; i < 100; i++)
{
UncertainTransformation T_a_b;
T_a_b.setRandom();
UncertainTransformation T_b_c;
T_b_c.setRandom();
UncertainTransformation T_a_c = T_a_b * T_b_c;
Eigen::Matrix4d T_a_c_prime = T_a_b.T() * T_b_c.T();
sm::eigen::assertNear(T_a_c.T(), T_a_c_prime, 1e-10, SM_SOURCE_FILE_POS, "Checking for composition equal to matrix multiplication");
}
} catch(const std::exception & e)
{
FAIL() << e.what();
}
}
TEST(UncertainTransformationTestSuite, testInvert)
{
using namespace sm::kinematics;
for(int i = 0; i < 100; i++)
{
UncertainTransformation T_a_b;
T_a_b.setRandom();
UncertainTransformation T_b_a = T_a_b.inverse();
UncertainTransformation T_a_b_prime = T_b_a.inverse();
sm::eigen::assertNear(T_a_b_prime.T(), T_a_b.T(), 1e-10, SM_SOURCE_FILE_POS, "Checking for identity");
}
}
TEST(UncertainTransformationTestSuite, testInvertProducesIdentity)
{
using namespace sm::kinematics;
for(int i = 0; i < 100; i++)
{
UncertainTransformation T_a_b;
T_a_b.setRandom();
UncertainTransformation T_b_a = T_a_b.inverse();
UncertainTransformation Eye1 = T_a_b * T_b_a;
UncertainTransformation Eye2 = T_b_a * T_a_b;
sm::eigen::assertNear(Eye1.T(), Eigen::Matrix4d::Identity(), 1e-10, SM_SOURCE_FILE_POS, "Checking for identity");
sm::eigen::assertNear(Eye2.T(), Eigen::Matrix4d::Identity(), 1e-10, SM_SOURCE_FILE_POS, "Checking for identity");
}
}
TEST(UncertainTransformationTestSuite, testInverse)
{
using namespace sm::kinematics;
UncertainTransformation TT_01;
TT_01.setRandom();
UncertainTransformation TT_10 = TT_01.inverse();
UncertainTransformation TTT_01 = TT_10.inverse();
Eigen::Matrix4d r1_T_01 = TT_01.T();
Eigen::Matrix4d r2_T_01 = TTT_01.T();
sm::eigen::assertNear(r1_T_01, r2_T_01, 1e-10, SM_SOURCE_FILE_POS, "Testing that composition and inverse derive the same answer");
UncertainTransformation::covariance_t r1_U_01 = TT_01.U();
UncertainTransformation::covariance_t r2_U_01 = TTT_01.U();
sm::eigen::assertNear(r1_U_01, r2_U_01, 1e-10, SM_SOURCE_FILE_POS, "Testing that composition and inverse derive the same answer");
}
TEST(UncertainTransformationTestSuite, testComposition2)
{
using namespace sm::kinematics;
UncertainTransformation TT_01;
TT_01.setRandom();
UncertainTransformation TT_12;
TT_12.setRandom();
UncertainTransformation TT_02 = TT_01 * TT_12;
UncertainTransformation TT_10 = TT_01.inverse();
UncertainTransformation TT_21 = TT_12.inverse();
UncertainTransformation TT_20 = TT_21 * TT_10;
UncertainTransformation TT_20direct = TT_02.inverse();
Eigen::Matrix4d r1_T_20 = TT_20.T();
Eigen::Matrix4d r2_T_20 = TT_20direct.T();
sm::eigen::assertNear(r1_T_20, r2_T_20, 1e-10, SM_SOURCE_FILE_POS, "Testing that composition and inverse derive the same answer");
UncertainTransformation::covariance_t r1_U_20 = TT_20.U();
UncertainTransformation::covariance_t r2_U_20 = TT_20direct.U();
sm::eigen::assertNear(r1_U_20, r2_U_20, 1e-8, SM_SOURCE_FILE_POS, "Testing that composition and inverse derive the same answer");
}
TEST(UncertainTransformationTestSuite, testTVMultiplication2)
{
using namespace sm::kinematics;
for(int i = 0; i < 10; i++)
{
UncertainTransformation T_a_b;
T_a_b.setRandom();
UncertainHomogeneousPoint v_b;
v_b.setRandom();
UncertainHomogeneousPoint v_a = T_a_b * v_b;
Eigen::Vector3d v_a_prime = T_a_b.C() * v_b.toEuclidean() + T_a_b.t();
sm::eigen::assertNear(v_a.toEuclidean(), v_a_prime, 1e-10, SM_SOURCE_FILE_POS, "Checking for composition equal to matrix multiplication");
}
}
// lestefan: added this
TEST(UncertainTransformationTestSuite, testUOplus)
{
using namespace sm::kinematics;
for(int i = 0; i < 10; i++)
{
UncertainTransformation T_a_b_1;
T_a_b_1.setRandom();
UncertainTransformation::covariance_t UOplus = T_a_b_1.UOplus();
UncertainTransformation T_a_b_2=T_a_b_1;
T_a_b_2.setUOplus(UOplus);
sm::eigen::assertNear(T_a_b_1.U(), T_a_b_2.U(), 1e-10, SM_SOURCE_FILE_POS, "Checking for getting and setting OPlus-type uncertainties");
}
}
| 26.84739 | 144 | 0.702319 | PushyamiKaveti |
3a9dcb315724e01fdcce58267d5beb2fcc655e93 | 885 | cpp | C++ | Codeforces/DiagramsAndTableaux.cpp | aajjbb/contest-files | b8842681b96017063a7baeac52ae1318bf59d74d | [
"Apache-2.0"
] | 1 | 2018-08-28T19:58:40.000Z | 2018-08-28T19:58:40.000Z | Codeforces/DiagramsAndTableaux.cpp | aajjbb/contest-files | b8842681b96017063a7baeac52ae1318bf59d74d | [
"Apache-2.0"
] | 2 | 2017-04-16T00:48:05.000Z | 2017-08-03T20:12:26.000Z | Codeforces/DiagramsAndTableaux.cpp | aajjbb/contest-files | b8842681b96017063a7baeac52ae1318bf59d74d | [
"Apache-2.0"
] | 4 | 2016-03-04T19:42:00.000Z | 2018-01-08T11:42:00.000Z | #include <bits/stdc++.h>
using namespace std;
int N, V;
int K[10];
vector<int> C[10];
int ans;
void func(int r, int c) {
if (r == N) {
ans += 1;
} else if (c >= (int) C[r].size()) {
func(r + 1, 0);
} else {
int curr = 1;
if (c - 1 >= 0) {
curr = max(curr, C[r][c - 1]);
}
if (r - 1 >= 0) {
curr = max(curr, C[r - 1][c] + 1);
}
for ( ; curr <= V; curr++) {
C[r][c] = curr;
func(r, c + 1);
}
}
}
int main() {
while (cin >> N) {
for (int i = 0; i < N; i++) {
cin >> K[i];
C[i].clear();
for (int j = 0; j < K[i]; j++) {
C[i].push_back(0);
}
}
cin >> V;
ans = 0;
func(0, 0);
cout << ans << "\n";
}
return 0;
}
| 17.019231 | 46 | 0.316384 | aajjbb |
3a9e726e49ad4e7c4d31553e219b2c382afc11ff | 9,414 | cc | C++ | src/db_logger.cc | sunnyxhuang/2D-Placement | 53310fa7336430a1b82b3ed3fa98409ab5d4b7d5 | [
"Apache-2.0"
] | 4 | 2017-09-01T14:43:01.000Z | 2017-09-02T04:58:55.000Z | src/db_logger.cc | little-by/2D-Placement | 53310fa7336430a1b82b3ed3fa98409ab5d4b7d5 | [
"Apache-2.0"
] | null | null | null | src/db_logger.cc | little-by/2D-Placement | 53310fa7336430a1b82b3ed3fa98409ab5d4b7d5 | [
"Apache-2.0"
] | 3 | 2017-09-21T08:24:51.000Z | 2018-10-30T04:46:15.000Z | #include <unistd.h>
#include "db_logger.h"
#include "util.h"
// static
bool DbLogger::LOG_FLOW_INFO_ = false;
bool DbLogger::Connect() {
//
return true;
}
DbLogger::DbLogger(string table_subfix) : table_subfix_(table_subfix) {
if (!Connect()) {
exit(-1);
}
has_init_coflow_info_table_ = false;
if (LOG_FLOW_INFO_) InitFlowInfoTable();
}
DbLogger::~DbLogger() {
// flush all data to database if needed
}
string DbLogger::GetTableName(string tabel_type) {
return tabel_type + (table_subfix_ == "" ? "" : "_" + table_subfix_);
}
bool DbLogger::DropIfExist(string table_type) {
if (!Connect()) {
return false;
}
string table_name = GetTableName(table_type);
// sql to drop table. You may also write to file named TRAFFIC_AUDIT_FILE_NAME
// query << "drop table if exists " << table_name;
// if (!query.exec()) {
// cerr << query.str() << endl;
// cerr << query.error() << endl;
// return false;
// }
// cout << "Dropped table " << table_name << endl;
return true;
}
void DbLogger::InitCoflowInfoTable() {
if (has_init_coflow_info_table_) return;
if (!DropIfExist("CoflowInfo")) return;
string table_name = GetTableName("CoflowInfo");
// sql to write table. You may also write to file named TRAFFIC_AUDIT_FILE_NAME
// query << "CREATE TABLE `" << table_name << "` (\n"
// << " `job_id` INT(11) NOT NULL,\n"
// << " `insert_ts` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,\n"
// << " `*cast` VARCHAR(5) DEFAULT NULL,\n"
// << " `bin` VARCHAR(5) DEFAULT NULL,\n"
// << " `map` SMALLINT DEFAULT NULL,\n"
// << " `red` SMALLINT DEFAULT NULL,\n"
// << " `flow#` INT DEFAULT NULL,\n"
// << " `map_loc` VARCHAR(500) DEFAULT NULL,\n"
// << " `red_loc` VARCHAR(500) DEFAULT NULL,\n"
// << " `bn_load_Gbit` DOUBLE DEFAULT NULL,\n"
// << " `lb_optc` DOUBLE DEFAULT NULL,\n"
// << " `lb_elec` DOUBLE DEFAULT NULL,\n"
// << " `lb_elec_bit` BIGINT DEFAULT NULL,\n"
// << " `ttl_Gbit` DOUBLE DEFAULT NULL,\n"
// << " `avg_Gbit` DOUBLE DEFAULT NULL,\n"
// << " `min_Gbit` DOUBLE DEFAULT NULL,\n"
// << " `max_Gbit` DOUBLE DEFAULT NULL,\n"
// << " `tArr` DOUBLE DEFAULT NULL,\n"
// << " `tFin` DOUBLE DEFAULT NULL,\n"
// << " `cct` DOUBLE DEFAULT NULL,\n"
// << " `r_optc` DOUBLE DEFAULT NULL,\n"
// << " `r_elec` DOUBLE DEFAULT NULL,\n"
// << " PRIMARY KEY (`job_id`)\n"
// << ");";
// cout << "Created table " << table_name << endl;
has_init_coflow_info_table_ = true;
}
void DbLogger::WriteCoflowFeatures(Coflow *coflow) {
if (!Connect()) return;
if (!has_init_coflow_info_table_) InitCoflowInfoTable();
// read a coflow. start building up knowledge.
double total_flow_size_Gbit = 0.0;
double min_flow_size_Gbit = -1.0;
double max_flow_size_Gbit = -1.0;
const map<pair<int, int>, long> &mr_demand_byte = coflow->GetMRFlowBytes();
int flow_num = (int) coflow->GetFlows()->size();
for (Flow *flow : *(coflow->GetFlows())) {
double this_flow_size_Gbit = ((double) flow->GetSizeInBit() / 1e9);
total_flow_size_Gbit += this_flow_size_Gbit; // each flow >= 1MB
if (min_flow_size_Gbit > this_flow_size_Gbit || min_flow_size_Gbit < 0) {
min_flow_size_Gbit = this_flow_size_Gbit;
}
if (max_flow_size_Gbit < this_flow_size_Gbit || max_flow_size_Gbit < 0) {
max_flow_size_Gbit = this_flow_size_Gbit;
}
}
double avg_flow_size_Gbit = total_flow_size_Gbit / (double) flow_num;
string cast_pattern = "";
int map = coflow->GetNumMap();
int red = coflow->GetNumRed();
if (map == 1 && red == 1) {
cast_pattern = "1"; // single-flow
} else if (map > 1 && red == 1) {
cast_pattern = "m21"; // incast
} else if (map == 1 && red > 1) {
cast_pattern = "12m"; // one sender, multiple receiver.
} else if (map > 1 && red > 1) {
cast_pattern = "m2m"; // many-to-many
}
string bin;
// double lb_elec_MB = lb_elec / (double) 8.0/ 1000000;
bin += (avg_flow_size_Gbit / 8.0 * 1e3 < 5.0) ?
'S' : 'L'; // short if avg flow size < 5MB, long other wise
bin += (flow_num <= 50) ? 'N' : 'W';// narrow if max flow# <= 50
string table_name = GetTableName("CoflowInfo");
// sql to write table. You may also write to file named TRAFFIC_AUDIT_FILE_NAME
// use INSERT and UPDATE so that part of the info written may stay.
// query << "INSERT INTO " << table_name << " "
// << "(`job_id`, `*cast`, `bin`, `map`, `red`, `flow#`, "
// << "`map_loc`, `red_loc`, "
// << "`bn_load_Gbit`, `lb_optc`, `lb_elec`, `lb_elec_bit`, "
// << "`ttl_Gbit`, `avg_Gbit`, `min_Gbit`, `max_Gbit`) VALUES ("
// << coflow->GetJobId() << ','
// << "'" << cast_pattern << "'" << ','
// << "'" << bin << "'" << ','
// << map << ','
// << red << ','
// << flow_num << ','
// << "'" << Join(coflow->GetMapperLocations(), '_') << "'" << ','
// << "'" << Join(coflow->GetReducerLocations(), '_') << "'" << ','
// << coflow->GetMaxMapRedLoadGb() << ',' // bn_load_GB
// << coflow->GetMaxOptimalWorkSpanInSeconds() << ',' // lb_optc
// << coflow->GetMaxPortLoadInSec() << ',' // lb_elec
// << coflow->GetMaxPortLoadInBits() << ',' // lb_elec_bit
// << total_flow_size_Gbit << ','
// << avg_flow_size_Gbit << ','
// << min_flow_size_Gbit << ','
// << max_flow_size_Gbit << ") "
// << "ON DUPLICATE KEY UPDATE "
// << "`*cast`= values (`*cast`), "
// << "`bin`= values (`bin`), "
// << "`map`= values (`map`), "
// << "`red`= values (`red`), "
// << "`flow#`= values (`flow#`), "
// << "`map_loc`= values (`map_loc`), "
// << "`red_loc`= values (`red_loc`), "
// << "`lb_optc`= values (`lb_optc`), "
// << "`lb_elec`= values (`lb_elec`), "
// << "`lb_elec_bit`= values (`lb_elec_bit`), "
// << "`ttl_Gbit`= values (`ttl_Gbit`), "
// << "`avg_Gbit`= values (`avg_Gbit`), "
// << "`min_Gbit`= values (`min_Gbit`), "
// << "`max_Gbit`= values (`max_Gbit`); ";
}
void DbLogger::WriteOnCoflowFinish(double finish_time,
Coflow *coflow) {
if (!has_init_coflow_info_table_) InitCoflowInfoTable();
double cct = (finish_time - coflow->GetStartTime());
double optc_lb = coflow->GetMaxOptimalWorkSpanInSeconds();
double elec_lb = coflow->GetMaxPortLoadInSeconds();
double cct_over_optc = cct / optc_lb;
double cct_over_elec = cct / elec_lb;
string table_name = GetTableName("CoflowInfo");
// sql to write table. You may also write to file named TRAFFIC_AUDIT_FILE_NAME
// use INSERT and UPDATE so that part of the info written may stay.
// query << "INSERT INTO " << table_name << " "
// << "(`job_id`, `tArr`, `tFin`, `cct`, `r_optc`, `r_elec`) VALUES ("
// << coflow->GetJobId() << ','
// << coflow->GetStartTime() << ','
// << finish_time << ','
// << (cct > 0 ? to_string(cct) : "null") << ','
// << (optc_lb > 0 ? to_string(cct_over_optc) : "null") << ','
// << (optc_lb > 0 ? to_string(cct_over_elec) : "null") << ") "
// << "ON DUPLICATE KEY UPDATE "
// << "`tArr`= values (`tArr`), "
// << "`tFin`= values (`tFin`), "
// << "`cct`= values (`cct`), "
// << "`r_optc`= values (`r_optc`), "
// << "`r_elec`= values (`r_elec`); ";
}
void DbLogger::InitFlowInfoTable() {
if (!DropIfExist("FlowInfo")) return;
string table_name = GetTableName("FlowInfo");
// table schema
// query << "CREATE TABLE `" << table_name << "` (\n"
// << " `job_id` INT(11) NOT NULL,\n"
// << " `flow_id` INT(11) NOT NULL,\n"
// << " `insert_ts` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,\n"
// << " `src` smallint NOT NULL,\n"
// << " `dst` smallint NOT NULL,\n"
// << " `flow_size_bit` BIGINT DEFAULT NULL,\n"
// << " `tArr` DOUBLE DEFAULT NULL,\n"
// << " `tFin` DOUBLE DEFAULT NULL,\n"
// << " `fct` DOUBLE DEFAULT NULL,\n"
// << " PRIMARY KEY (`flow_id`)\n"
// << ");";
// cout << "Created table " << table_name << endl;
}
void DbLogger::WriteOnFlowFinish(double finish_time, Flow *flow) {
if (!LOG_FLOW_INFO_) return;
double fct = (finish_time - flow->GetStartTime());
string table_name = GetTableName("FlowInfo");
// sql to write table. You may also write to file named TRAFFIC_AUDIT_FILE_NAME
// always use INSERT as there is appending.
// query << "INSERT INTO " << table_name << " "
// << "(`job_id`, `flow_id`, `src` ,`dst`, `flow_size_bit`, "
// << "`tArr`, `tFin`, `fct`) VALUES ("
// << flow->GetParentCoflow()->GetJobId() << ','
// << flow->GetFlowId() << ','
// << flow->GetSrc() << ','
// << flow->GetDest() << ','
// << flow->GetSizeInBit() << ','
// << flow->GetStartTime() << ','
// << finish_time << ','
// << fct << ");";
} | 41.10917 | 81 | 0.533142 | sunnyxhuang |
3a9e8d3a248148df68aad154296185f0fdb0aa88 | 3,497 | cpp | C++ | Fantasyroguegame/Fantasy rogue game/Game.cpp | RichardsonDaniel/BSc-University-Coursework | f66351152826cafd4d0064c26efb7dc9c74f6ce6 | [
"MIT"
] | null | null | null | Fantasyroguegame/Fantasy rogue game/Game.cpp | RichardsonDaniel/BSc-University-Coursework | f66351152826cafd4d0064c26efb7dc9c74f6ce6 | [
"MIT"
] | null | null | null | Fantasyroguegame/Fantasy rogue game/Game.cpp | RichardsonDaniel/BSc-University-Coursework | f66351152826cafd4d0064c26efb7dc9c74f6ce6 | [
"MIT"
] | null | null | null | //sets up the game and starts the main loop
#include "Game.h"
int Game::instances = 0;
void Game::run() {
bool running = true; //set running to true
SDL_Event sdlEvent;
std::cout << "Progress: About to enter main loop" << std::endl;
while (running)
{
while (SDL_PollEvent(&sdlEvent))
{
if (sdlEvent.type == SDL_QUIT)
running = false;
else
stateCurrent->handleSDLEvent(sdlEvent, *this);
}
stateCurrent->draw(window, *this); //draw current state
stateCurrent->update(*this); //update the current state
}
}
Game::Game() {
window = setupRC(glContext);
//create and initialise all states
stateMap = new StateMap();
stateMainMenu = new StateMainMenu();
stateIntro = new StateIntro();
stateCredits = new StateCredits();
stateCombat = new StateCombat();
stateCharSelect = new StateCharSelect();
stateGameOver = new StateGameOver();
stateMap->init(*this);
stateMainMenu->init(*this);
stateIntro->init(*this);
stateCredits->init(*this);
stateCombat->init(*this);
stateCharSelect->init(*this);
stateGameOver->init(*this);
stateCurrent = stateIntro; //set starting state
instances++;
if (instances > 1)
Label::exitFatalError("Attempt to create multiple game instances"); //stop multiplse instances
//create and initalise all objects in the map
player = new Player();
monsterFactory = new MonsterFactory();
monArr[0] = monsterFactory->orderMonster("fodder");
monArr[1] = monsterFactory->orderMonster("fodder");
monArr[2] = monsterFactory->orderMonster("fodder");
monArr[3] = monsterFactory->orderMonster("fodder");
monArr[4] = monsterFactory->orderMonster("fodder");
monArr[5] = monsterFactory->orderMonster("brute");
monArr[6] = monsterFactory->orderMonster("brute");
monArr[7] = monsterFactory->orderMonster("brute");
monArr[8] = monsterFactory->orderMonster("raider");
itemArr[0]= new ItemStimulant(new Item("Stimulant", 0, 0, 1));
itemArr[1]= new ItemHealthPack(new Item("Health Pack", 0, 1, 0));
itemArr[2]= new ItemHealthPack(new Item("Health Pack", 0, 1, 0));
itemArr[3]= new ItemCombatPack(new Item("Combat Pack", 2, 0, 0));
itemArr[4]= new ItemCombatPack(new Item("Combat Pack", 2, 0, 0));
}
SDL_Window * Game::setupRC(SDL_GLContext &context) // setup SDL window
{
TTF_Font* textFont;
SDL_Window *window;
if (SDL_Init(SDL_INIT_VIDEO) < 0) // Initialize video
Label::exitFatalError("Unable to initialize SDL");
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1);
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1);
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 4);
window = SDL_CreateWindow("Fantasy Rogue Game",
SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
800, 600, SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN );
if (!window)
Label::exitFatalError("Unable to create window");
context = SDL_GL_CreateContext(window);
SDL_GL_SetSwapInterval(1);
if (TTF_Init()== -1)
Label::exitFatalError("TTF failed to initialise.");
textFont = TTF_OpenFont("MavenPro-Regular.ttf", 24);
if (textFont == NULL)
Label::exitFatalError("Failed to open font.");
return window;
}
Game::~Game() {
delete stateCurrent;
delete stateMap;
delete stateMainMenu;
delete stateIntro;
delete stateCredits;
delete stateCombat;
delete stateCharSelect;
delete stateGameOver;
SDL_DestroyWindow(window);
SDL_Quit();
}
| 28.900826 | 96 | 0.720046 | RichardsonDaniel |
3aa08ecdc21572485cd6784378357e823e2fc9a4 | 3,206 | cpp | C++ | Helper/Source/HelperApp.cpp | williamih/asset-pipeline | 077a50442e780f72c238c22d1eec8ab1b99e72f7 | [
"BSD-3-Clause"
] | null | null | null | Helper/Source/HelperApp.cpp | williamih/asset-pipeline | 077a50442e780f72c238c22d1eec8ab1b99e72f7 | [
"BSD-3-Clause"
] | null | null | null | Helper/Source/HelperApp.cpp | williamih/asset-pipeline | 077a50442e780f72c238c22d1eec8ab1b99e72f7 | [
"BSD-3-Clause"
] | null | null | null | #include "HelperApp.h"
#include <vector>
#include <QApplication>
#include <QHostAddress>
#include <Core/Macros.h>
HelperApp::HelperApp(u16 port, QObject* parent)
: QObject(parent)
, m_menu()
, m_tcpSocket()
, m_socketReadData()
, m_dbConn()
, m_projectsWindow(m_dbConn)
, m_errorsWindow(m_dbConn)
, m_aboutWindow()
, m_callbackQueue()
{
QHostAddress address(QHostAddress::LocalHost);
m_tcpSocket.connectToHost(address, port);
connect(&m_tcpSocket, &QTcpSocket::readyRead,
this, &HelperApp::SocketReadyForRead);
connect(&m_tcpSocket, &QTcpSocket::bytesWritten,
this, &HelperApp::OnBytesWritten);
QAction* aboutAction = m_menu.addAction("About Asset Pipeline");
aboutAction->setMenuRole(QAction::AboutRole);
connect(aboutAction, &QAction::triggered, this, &HelperApp::ShowAboutWindow);
QAction* quitAction = m_menu.addAction("Quit Asset Pipeline");
quitAction->setMenuRole(QAction::QuitRole);
quitAction->setShortcut(QKeySequence::Quit);
connect(quitAction, &QAction::triggered, [=] {
SendIPCMessage(IPCHELPERTOAPP_QUIT);
RegisterOnBytesSent([](size_t bytes) {
QMetaObject::invokeMethod(qApp, "quit", Qt::QueuedConnection);
});
});
m_tcpSocket.waitForConnected();
}
HelperApp::~HelperApp()
{}
void HelperApp::ShowAboutWindow()
{
m_aboutWindow.show();
}
void HelperApp::SocketReadyForRead()
{
qint64 bytesAvailable = m_tcpSocket.bytesAvailable();
m_socketReadData.resize((size_t)bytesAvailable);
m_tcpSocket.read((char*)&m_socketReadData[0],
(qint64)m_socketReadData.size());
for (size_t i = 0; i < m_socketReadData.size(); ++i) {
ReceiveByte(m_socketReadData[i]);
}
}
void HelperApp::ReceiveByte(u8 byte)
{
IPCAppToHelperAction action = (IPCAppToHelperAction)byte;
switch (action) {
case IPCAPPTOHELPER_SHOW_PROJECTS_WINDOW:
m_projectsWindow.show();
break;
case IPCAPPTOHELPER_SHOW_ERRORS_WINDOW:
m_errorsWindow.show();
break;
case IPCAPPTOHELPER_SHOW_ABOUT_WINDOW:
ShowAboutWindow();
break;
case IPCAPPTOHELPER_REFRESH_ERRORS:
// Only actually reload if the window is visible (this is a
// performance optimization). If the window becomes visible after
// this, it will reload the data anyway.
if (m_errorsWindow.isVisible())
m_errorsWindow.ReloadErrors();
break;
case IPCAPPTOHELPER_QUIT:
QMetaObject::invokeMethod(qApp, "quit", Qt::QueuedConnection);
break;
}
}
void HelperApp::SendIPCMessage(IPCHelperToAppAction action)
{
if ((u32)action > 0xFF)
FATAL("Size of message exceeded one byte");
u8 byte = (u8)action;
m_tcpSocket.write((const char*)&byte, 1);
}
void HelperApp::RegisterOnBytesSent(const BytesSentFunc& func)
{
m_callbackQueue.push_back(func);
}
void HelperApp::OnBytesWritten(qint64 bytes)
{
for (size_t i = 0; i < m_callbackQueue.size(); ++i) {
m_callbackQueue[i]((size_t)bytes);
}
m_callbackQueue.clear();
}
| 29.412844 | 81 | 0.66126 | williamih |
3aa138cd9d6192437137ad3ab0b3258a2208b03c | 499 | cpp | C++ | cameranorotation.cpp | AndersonMarco/trabalhoFinalParaADisciplinaDeCGDaUFABC | 83aacfad40db72d5fac7fca0b8c71a2b96bf24ba | [
"Apache-2.0"
] | null | null | null | cameranorotation.cpp | AndersonMarco/trabalhoFinalParaADisciplinaDeCGDaUFABC | 83aacfad40db72d5fac7fca0b8c71a2b96bf24ba | [
"Apache-2.0"
] | null | null | null | cameranorotation.cpp | AndersonMarco/trabalhoFinalParaADisciplinaDeCGDaUFABC | 83aacfad40db72d5fac7fca0b8c71a2b96bf24ba | [
"Apache-2.0"
] | null | null | null | #include "cameranorotation.h"
CameraNoRotation::CameraNoRotation()
{
}
void CameraNoRotation::mouseMove(const QPointF &p)
{
if(firstPassInMouseMove){
lastPos3D=mousePosTo3D(p);
firstPassInMouseMove=false;
return;
}
QTime currentTime = QTime::currentTime();
vp = mousePosTo3D(p);
//at=eye+atMinusEyeXPlane;
at.setY(vp.y());
direction=rotationXZByY(QVector3D(0,0,0.2),3*doubleRotationCameraX);
lastPos3D=vp;
lastTime = currentTime;
}
| 18.481481 | 72 | 0.675351 | AndersonMarco |
3aa1a076d877d5556c3738d2229ea097eaef5a92 | 3,094 | cc | C++ | src/parameters_parser.cc | krackers/kakoune | 7672387738ae1a2f38b843fe4b490a6ad882d94f | [
"Unlicense"
] | 10 | 2018-03-22T09:39:19.000Z | 2021-02-17T19:24:19.000Z | src/parameters_parser.cc | krackers/kakoune | 7672387738ae1a2f38b843fe4b490a6ad882d94f | [
"Unlicense"
] | null | null | null | src/parameters_parser.cc | krackers/kakoune | 7672387738ae1a2f38b843fe4b490a6ad882d94f | [
"Unlicense"
] | null | null | null | #include "parameters_parser.hh"
#include "flags.hh"
namespace Kakoune
{
String generate_switches_doc(const SwitchMap& switches)
{
String res;
if (switches.empty())
return res;
auto switch_len = [](auto& sw) { return sw.key.column_length() + (sw.value.takes_arg ? 5 : 0); };
auto switches_len = switches | transform(switch_len);
const ColumnCount maxlen = *std::max_element(switches_len.begin(), switches_len.end());
for (auto& sw : switches) {
res += format("-{} {}{}{}\n",
sw.key,
sw.value.takes_arg ? "<arg>" : "",
String{' ', maxlen - switch_len(sw) + 1},
sw.value.description);
}
return res;
}
ParametersParser::ParametersParser(ParameterList params, const ParameterDesc& desc)
: m_params(params),
m_desc(desc)
{
const bool switches_only_at_start = desc.flags & ParameterDesc::Flags::SwitchesOnlyAtStart;
const bool ignore_unknown_switches = desc.flags & ParameterDesc::Flags::IgnoreUnknownSwitches;
bool only_pos = desc.flags & ParameterDesc::Flags::SwitchesAsPositional;
Vector<bool> switch_seen(desc.switches.size(), false);
for (size_t i = 0; i < params.size(); ++i)
{
if (not only_pos and not ignore_unknown_switches and params[i] == "--")
only_pos = true;
else if (not only_pos and not params[i].empty() and params[i][0_byte] == '-')
{
auto it = m_desc.switches.find(params[i].substr(1_byte));
if (it == m_desc.switches.end())
{
if (ignore_unknown_switches)
{
m_positional_indices.push_back(i);
if (switches_only_at_start)
only_pos = true;
continue;
}
throw unknown_option(params[i]);
}
auto switch_index = it - m_desc.switches.begin();
if (switch_seen[switch_index])
throw runtime_error{format("switch '-{}' specified more than once", it->key)};
switch_seen[switch_index] = true;
if (it->value.takes_arg and ++i == params.size())
throw missing_option_value(it->key);
}
else // positional
{
if (switches_only_at_start)
only_pos = true;
m_positional_indices.push_back(i);
}
}
size_t count = m_positional_indices.size();
if (count > desc.max_positionals or count < desc.min_positionals)
throw wrong_argument_count();
}
Optional<StringView> ParametersParser::get_switch(StringView name) const
{
auto it = m_desc.switches.find(name);
kak_assert(it != m_desc.switches.end());
for (size_t i = 0; i < m_params.size(); ++i)
{
const auto& param = m_params[i];
if (param.substr(0_byte, 1_byte) == "-" and param.substr(1_byte) == name)
return it->value.takes_arg ? m_params[i+1] : StringView{};
if (param == "--")
break;
}
return {};
}
}
| 33.268817 | 101 | 0.572721 | krackers |
3aa1d4028df1976ffaada9f8cd536e5188443eaf | 3,202 | cpp | C++ | sdktools/apimon/apimon/apimonwn.cpp | npocmaka/Windows-Server-2003 | 5c6fe3db626b63a384230a1aa6b92ac416b0765f | [
"Unlicense"
] | 17 | 2020-11-13T13:42:52.000Z | 2021-09-16T09:13:13.000Z | sdktools/apimon/apimon/apimonwn.cpp | sancho1952007/Windows-Server-2003 | 5c6fe3db626b63a384230a1aa6b92ac416b0765f | [
"Unlicense"
] | 2 | 2020-10-19T08:02:06.000Z | 2020-10-19T08:23:18.000Z | sdktools/apimon/apimon/apimonwn.cpp | sancho1952007/Windows-Server-2003 | 5c6fe3db626b63a384230a1aa6b92ac416b0765f | [
"Unlicense"
] | 14 | 2020-11-14T09:43:20.000Z | 2021-08-28T08:59:57.000Z | /*++
Copyright (c) 1995 Microsoft Corporation
Module Name:
apimonwin.h
Abstract:
Implemenation for the base ApiMon child window class.
Author:
Wesley Witt (wesw) Dec-9-1995
Environment:
User Mode
--*/
#include "apimonp.h"
#pragma hdrstop
#include "apimonwn.h"
ApiMonWindow::ApiMonWindow()
{
hInstance = GetModuleHandle( NULL );
hwndWin = NULL;
hwndList = NULL;
SortRoutine = NULL;
hFont = NULL;
Color = 0;
ZeroMemory( &Position, sizeof(POSITION) );
}
ApiMonWindow::~ApiMonWindow()
{
}
BOOL
ApiMonWindow::Create(
LPSTR ClassName,
LPSTR Title
)
{
hwndWin = CreateMDIWindow(
ClassName,
Title,
0,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
hwndMDIClient,
hInstance,
(LPARAM) this
);
if (!hwndWin) {
return FALSE;
}
ShowWindow(
hwndWin,
SW_SHOW
);
return TRUE;
}
BOOL
ApiMonWindow::Register(
LPSTR ClassName,
ULONG ChildIconId,
WNDPROC WindowProc
)
{
WNDCLASSEX wc;
wc.cbSize = sizeof(WNDCLASSEX);
wc.style = CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(ChildIconId));
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)COLOR_APPWORKSPACE;
wc.lpszMenuName = NULL;
wc.hIconSm = (HICON)LoadImage(
hInstance,
MAKEINTRESOURCE(ChildIconId),
IMAGE_ICON,
16,
16,
0
);
wc.lpfnWndProc = WindowProc;
wc.lpszClassName = ClassName;
return RegisterClassEx( &wc );
}
void
ApiMonWindow::ChangeFont(
HFONT hFont
)
{
if (hwndList) {
ApiMonWindow::hFont = hFont;
SendMessage(
hwndList,
WM_SETFONT,
(WPARAM)hFont,
MAKELPARAM( TRUE, 0 )
);
}
}
void
ApiMonWindow::ChangeColor(
COLORREF Color
)
{
if (hwndList) {
ApiMonWindow::Color = Color;
ListView_SetBkColor( hwndList, Color );
ListView_SetTextBkColor( hwndList, Color );
InvalidateRect( hwndList, NULL, TRUE );
UpdateWindow( hwndList );
}
}
void
ApiMonWindow::ChangePosition(
PPOSITION Position
)
{
ApiMonWindow::Position = *Position;
SetWindowPosition( hwndWin, Position );
}
void
ApiMonWindow::SetFocus()
{
BringWindowToTop( hwndWin );
SetForegroundWindow( hwndWin );
}
BOOL
ApiMonWindow::Update(
BOOL ForceUpdate
)
{
if ((!hwndWin) || (!hwndList)) {
return FALSE;
}
return TRUE;
}
void
ApiMonWindow::DeleteAllItems()
{
ListView_DeleteAllItems( hwndList );
}
| 17.888268 | 74 | 0.527483 | npocmaka |
3aa1eb9ba9ba7eae43f867c0b1bfacbd702d6d77 | 500 | cpp | C++ | Control Work 2021.11.15/Project4/Source.cpp | ElitProffi/HW2021-2022 | 375abed060ad5a79e6486af0af367725294730d8 | [
"Apache-2.0"
] | null | null | null | Control Work 2021.11.15/Project4/Source.cpp | ElitProffi/HW2021-2022 | 375abed060ad5a79e6486af0af367725294730d8 | [
"Apache-2.0"
] | null | null | null | Control Work 2021.11.15/Project4/Source.cpp | ElitProffi/HW2021-2022 | 375abed060ad5a79e6486af0af367725294730d8 | [
"Apache-2.0"
] | null | null | null | #include<iostream>
using namespace std;
int main(int argc, char* argv[])
{
int n = 0;
cin >> n;
int* o = new int[n] {0};
for (int i = 0; i < n; ++i)
{
cin >> o[i];
}
int max = o[0];
int min = o[0];
for (int i = 0; i < n; ++i)
{
if (o[i] < min)
{
min = o[i];
}
if (o[i] > max)
{
max = o[i];
}
}
for (int i = 0; i < n; ++i)
{
if (o[i] == max)
{
o[i] = min;
}
}
for (int i = 0; i < n; ++i)
{
cout << o[i] << " ";
}
delete[] o;
return EXIT_SUCCESS;
} | 11.904762 | 32 | 0.414 | ElitProffi |
3aa2208960d7e1d9b1ef35c8b5979e8090a2c3d9 | 2,961 | cpp | C++ | turnpike/src/SED.cpp | shuai-huang/turnpike-beltway | 20b68a48b68c2daad02346b1c076c0dce99c4431 | [
"Apache-2.0"
] | null | null | null | turnpike/src/SED.cpp | shuai-huang/turnpike-beltway | 20b68a48b68c2daad02346b1c076c0dce99c4431 | [
"Apache-2.0"
] | null | null | null | turnpike/src/SED.cpp | shuai-huang/turnpike-beltway | 20b68a48b68c2daad02346b1c076c0dce99c4431 | [
"Apache-2.0"
] | 1 | 2020-01-06T17:17:17.000Z | 2020-01-06T17:17:17.000Z | #include "SED.h"
// Could remove the columns that are all zeros and speed up the computation
SED::SED(){}
void SED::ComputeObjFunMuti( vector<int> all_distance_block, VectorXd* smp_vec_muti, vector<double>* obj_seq_pt, int val_idx ) {
double obj_tmp = 0;
for (int i=0; i<all_distance_block.size(); i++) {
est_distribution[all_distance_block[i]] = ComputeEstDbt(smp_vec_muti, all_distance_block[i]);
obj_tmp += pow( est_distribution[all_distance_block[i]] - all_distribution[all_distance_block[i]] , 2);
}
(*obj_seq_pt)[val_idx] = obj_tmp;
}
double SED::ComputeObjFun(VectorXd smp_vec) {
vector<double> obj_seq(num_thread_assign, 0);
if (num_thread_assign>1) {
thread *multi_thread = new thread[num_thread_assign-1];
for (int i=0; i<num_thread_assign-1; i++) {
multi_thread[i] = thread(&SED::ComputeObjFunMuti, this, all_partition[i], &smp_vec, &obj_seq, i);
}
ComputeObjFunMuti( all_partition[num_thread_assign-1], &smp_vec, &obj_seq, num_thread-1);
for (int i=0; i<num_thread_assign-1; i++) {
multi_thread[i].join();
}
delete [] multi_thread;
} else {
ComputeObjFunMuti( all_partition[num_thread_assign-1], &smp_vec, &obj_seq, num_thread-1);
}
double obj = 0;
for (int i=0; i<num_thread_assign; i++) {
obj += obj_seq[i];
}
return obj;
}
void SED::ComputeGradientMuti( vector<int> all_distance_block, VectorXd* smp_vec_muti, VectorXd* smp_der_seq_pt, int val_idx ) {
VectorXd smp_der_seq_tmp = VectorXd::Zero(M);
for (int i=0; i<all_distance_block.size(); i++) {
double mut_factor = (2.0*( est_distribution[all_distance_block[i]] - all_distribution[all_distance_block[i]] ) );
ComputeEstProj(smp_vec_muti, smp_der_seq_pt, mut_factor, all_distance_block[i]);
}
}
VectorXd SED::ComputeGradient(VectorXd smp_vec) {
vector<VectorXd> smp_der_seq(num_thread_assign, VectorXd::Zero(M));
if (num_thread_assign>1) {
thread *multi_thread = new thread[num_thread_assign-1];
for (int i=0; i<num_thread_assign-1; i++) {
multi_thread[i] = thread(&SED::ComputeGradientMuti, this, all_partition[i], &smp_vec, &smp_der_seq[i], i);
}
ComputeGradientMuti( all_partition[num_thread_assign-1], &smp_vec, &smp_der_seq[num_thread_assign-1], num_thread_assign-1 );
for (int i=0; i<num_thread_assign-1; i++) {
multi_thread[i].join();
}
delete [] multi_thread;
} else {
ComputeGradientMuti( all_partition[num_thread_assign-1], &smp_vec, &smp_der_seq[num_thread_assign-1], num_thread_assign-1 );
}
VectorXd smp_der = VectorXd::Zero(M);
for (int i=0; i<num_thread_assign; i++) {
smp_der.noalias() += smp_der_seq[i];
}
return smp_der;
}
SED::~SED() {}
| 32.9 | 132 | 0.638973 | shuai-huang |
3aa43366f0b6c9c5b4429d04da437f9900db610e | 5,652 | cc | C++ | usr/src/cmd/audio/utilities/Fir.cc | AsahiOS/gate | 283d47da4e17a5871d9d575e7ffb81e8f6c52e51 | [
"MIT"
] | null | null | null | usr/src/cmd/audio/utilities/Fir.cc | AsahiOS/gate | 283d47da4e17a5871d9d575e7ffb81e8f6c52e51 | [
"MIT"
] | null | null | null | usr/src/cmd/audio/utilities/Fir.cc | AsahiOS/gate | 283d47da4e17a5871d9d575e7ffb81e8f6c52e51 | [
"MIT"
] | 1 | 2020-12-30T00:04:16.000Z | 2020-12-30T00:04:16.000Z | /*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright (c) 1992-2001 by Sun Microsystems, Inc.
* All rights reserved.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <memory.h>
#include <stddef.h>
#include <sys/types.h>
#include <Fir.h>
extern "C" {
char *bcopy(char *, char *, int);
char *memmove(char *, char *, int);
}
#define BCOPY(src, dest, num) memmove(dest, src, num)
/*
* convolve()
* returns the convolution of coef[length] and in_buf[length]:
*
* convolution = coef[0] * in_buf[length - 1] +
* coef[1] * in_buf[length - 2] +
* ...
* coef[length - 1] * in_buf[0]
*/
double
convolve(
double *coefs,
double *in_buf,
int length)
{
if (length <= 0)
return (0.0);
else {
in_buf += --length;
double sum = *coefs * *in_buf;
while (length--)
sum += *++coefs * *--in_buf;
return (sum);
}
}
void // convert short to double
short2double(
double *out,
short *in,
int size)
{
while (size-- > 0)
*out++ = (double)*in++;
}
short
double2short(double in) // limit double to short
{
if (in <= -32768.0)
return (-32768);
else if (in >= 32767.0)
return (32767);
else
return ((short)in);
}
void Fir:: // update state with data[size]
updateState(
double *data,
int size)
{
if (size >= order)
memcpy(state, data + size - order, order * sizeof (double));
else {
int old = order - size;
BCOPY((char *)(state + size), (char *)state,
old * sizeof (double));
memcpy(state + order - size, data, size * sizeof (double));
}
}
void Fir::
update_short(
short *in,
int size)
{
double *in_buf = new double[size];
short2double(in_buf, in, size);
updateState(in_buf, size);
delete in_buf;
}
void Fir::
resetState(void) // reset state to all zero
{
for (int i = 0; i < order; i++)
state[i] = 0.0;
}
Fir::
Fir(void)
{
}
Fir::
Fir(int order_in): order(order_in) // construct Fir object
{
state = new double[order];
resetState();
coef = new double[order + 1];
delay = (order + 1) >> 1; // assuming symmetric FIR
}
Fir::
~Fir() // destruct Fir object
{
delete coef;
delete state;
}
int Fir::
getOrder(void) // returns filter order
{
return (order);
}
int Fir::
getNumCoefs(void) // returns number of filter coefficients
{
return (order + 1);
}
void Fir::
putCoef(double *coef_in) // copy coef_in in filter coefficients
{
memcpy(coef, coef_in, (order + 1) * sizeof (double));
}
void Fir::
getCoef(double *coef_out) // returns filter coefs in coef_out
{
memcpy(coef_out, coef, (order + 1) * sizeof (double));
}
int Fir:: // filter in[size], and updates the state.
filter_noadjust(
short *in,
int size,
short *out)
{
if (size <= 0)
return (0);
double *in_buf = new double[size];
short2double(in_buf, in, size); // convert short input to double
int i;
int init_size = (size <= order)? size : order;
int init_order = order;
double *state_ptr = state;
short *out_ptr = out;
// the first "order" outputs need state in convolution
for (i = 1; i <= init_size; i++)
*out_ptr++ = double2short(convolve(coef, in_buf, i) +
convolve(coef + i, state_ptr++, init_order--));
// starting from "order + 1"th output, state is no longer needed
state_ptr = in_buf;
while (i++ <= size)
*out_ptr++ =
double2short(convolve(coef, state_ptr++, order + 1));
updateState(in_buf, size);
delete in_buf;
return (out_ptr - out);
}
int Fir::
getFlushSize(void)
{
int group_delay = (order + 1) >> 1;
return ((delay < group_delay)? group_delay - delay : 0);
}
int Fir::
flush(short *out) // zero input response of Fir
{
int num = getFlushSize();
if (num > 0) {
short *in = new short[num];
memset(in, 0, num * sizeof (short));
num = filter_noadjust(in, num, out);
delete in;
}
return (num);
}
/*
* filter() filters in[size] with filter delay adjusted to 0
*
* All FIR filters introduce a delay of "order" samples between input and
* output sequences. Most FIR filters are symmetric filters to keep the
* linear phase responses. For those FIR fitlers the group delay is
* "(order + 1) / 2". So filter_nodelay adjusts the group delay in the
* output sequence such that the output is aligned with the input and
* direct comparison between them is possible.
*
* The first call of filter returns "size - group_delay" output samples.
* After all the input samples have been filtered, filter() needs
* to be called with size = 0 to get the residual output samples to make
* the output sequence the same length as the input.
*
*/
int Fir::
filter(
short *in,
int size,
short *out)
{
if ((size <= 0) || (in == NULL))
return (flush(out));
else if (delay <= 0)
return (filter_noadjust(in, size, out));
else if (size <= delay) {
update_short(in, size);
delay -= size;
return (0);
} else {
update_short(in, delay);
in += delay;
size -= delay;
delay = 0;
return (filter_noadjust(in, size, out));
}
}
| 21.992218 | 73 | 0.655343 | AsahiOS |
3aa833e12e577cec543cb98e218b4b660b0a1cd7 | 3,366 | cc | C++ | test/test_kjv.cc | yhirose/cpp-searchlib | dd9102bbf0f3a22e77a0bacb8ab2a510ce96890e | [
"MIT"
] | 15 | 2021-08-13T06:28:15.000Z | 2022-03-14T06:43:53.000Z | test/test_kjv.cc | yhirose/cpp-searchlib | dd9102bbf0f3a22e77a0bacb8ab2a510ce96890e | [
"MIT"
] | null | null | null | test/test_kjv.cc | yhirose/cpp-searchlib | dd9102bbf0f3a22e77a0bacb8ab2a510ce96890e | [
"MIT"
] | null | null | null | #include <gtest/gtest.h>
#include <searchlib.h>
#include <filesystem>
#include <fstream>
#include "test_utils.h"
using namespace searchlib;
const auto KJV_PATH = "../../test/t_kjv.tsv";
auto normalizer = [](auto sv) { return unicode::to_lowercase(sv); };
static auto kjv_index() {
InMemoryInvertedIndex<TextRange> invidx;
InMemoryIndexer indexer(invidx, normalizer);
std::ifstream fs(KJV_PATH);
if (fs) {
std::string line;
while (std::getline(fs, line)) {
auto fields = split(line, '\t');
auto document_id = std::stoi(fields[0]);
const auto &s = fields[4];
indexer.index_document(document_id, UTF8PlainTextTokenizer(s));
}
}
return invidx;
}
TEST(KJVTest, SimpleTest) {
const auto &invidx = kjv_index();
{
auto expr = parse_query(invidx, normalizer, R"( apple )");
ASSERT_TRUE(expr);
auto postings = perform_search(invidx, *expr);
ASSERT_TRUE(postings);
ASSERT_EQ(8, postings->size());
auto term = U"apple";
EXPECT_EQ(8, invidx.df(term));
EXPECT_AP(0.411, tf_idf_score(invidx, *expr, *postings, 0));
EXPECT_AP(0.745, tf_idf_score(invidx, *expr, *postings, 1));
EXPECT_AP(0.852, tf_idf_score(invidx, *expr, *postings, 2));
EXPECT_AP(0.351, tf_idf_score(invidx, *expr, *postings, 3));
EXPECT_AP(0.341, tf_idf_score(invidx, *expr, *postings, 4));
EXPECT_AP(0.341, tf_idf_score(invidx, *expr, *postings, 5));
EXPECT_AP(0.298, tf_idf_score(invidx, *expr, *postings, 6));
EXPECT_AP(0.385, tf_idf_score(invidx, *expr, *postings, 7));
EXPECT_AP(0.660, bm25_score(invidx, *expr, *postings, 0));
EXPECT_AP(1.753, bm25_score(invidx, *expr, *postings, 1));
EXPECT_AP(2.146, bm25_score(invidx, *expr, *postings, 2));
EXPECT_AP(0.500, bm25_score(invidx, *expr, *postings, 3));
EXPECT_AP(0.475, bm25_score(invidx, *expr, *postings, 4));
EXPECT_AP(0.475, bm25_score(invidx, *expr, *postings, 5));
EXPECT_AP(0.374, bm25_score(invidx, *expr, *postings, 6));
EXPECT_AP(0.588, bm25_score(invidx, *expr, *postings, 7));
}
{
auto expr = parse_query(invidx, normalizer, R"( "apple tree" )");
ASSERT_TRUE(expr);
auto postings = perform_search(invidx, *expr);
ASSERT_TRUE(postings);
ASSERT_EQ(3, postings->size());
EXPECT_EQ(1, postings->search_hit_count(0));
EXPECT_EQ(1, postings->search_hit_count(1));
EXPECT_EQ(1, postings->search_hit_count(2));
EXPECT_EQ(2, term_count_score(invidx, *expr, *postings, 0));
EXPECT_EQ(2, term_count_score(invidx, *expr, *postings, 1));
EXPECT_EQ(5, term_count_score(invidx, *expr, *postings, 2));
EXPECT_AP(0.572, tf_idf_score(invidx, *expr, *postings, 0));
EXPECT_AP(0.556, tf_idf_score(invidx, *expr, *postings, 1));
EXPECT_AP(1.051, tf_idf_score(invidx, *expr, *postings, 2));
EXPECT_AP(0.817, bm25_score(invidx, *expr, *postings, 0));
EXPECT_AP(0.776, bm25_score(invidx, *expr, *postings, 1));
EXPECT_AP(1.285, bm25_score(invidx, *expr, *postings, 2));
}
}
TEST(KJVTest, UTF8DecodePerformance) {
// auto normalizer = [](const auto &str) {
// return unicode::to_lowercase(str);
// };
auto normalizer = to_lowercase;
std::ifstream fs(KJV_PATH);
std::string s;
while (std::getline(fs, s)) {
UTF8PlainTextTokenizer tokenizer(s);
tokenizer(normalizer, [&](auto &str, auto, auto) {});
}
}
| 31.754717 | 69 | 0.663102 | yhirose |
3aa9b603dfa74501ee025bf697e11c316aba7f96 | 3,405 | cpp | C++ | src/Generic/theories/Region.cpp | BBN-E/serif | 1e2662d82fb1c377ec3c79355a5a9b0644606cb4 | [
"Apache-2.0"
] | 1 | 2022-03-24T19:57:00.000Z | 2022-03-24T19:57:00.000Z | src/Generic/theories/Region.cpp | BBN-E/serif | 1e2662d82fb1c377ec3c79355a5a9b0644606cb4 | [
"Apache-2.0"
] | null | null | null | src/Generic/theories/Region.cpp | BBN-E/serif | 1e2662d82fb1c377ec3c79355a5a9b0644606cb4 | [
"Apache-2.0"
] | null | null | null | // Copyright 2009 by BBN Technologies Corp.
// All Rights Reserved.
#include "Generic/common/leak_detection.h"
#include "Generic/theories/Region.h"
#include "Generic/common/LocatedString.h"
#include "Generic/common/OutputUtil.h"
#include "Generic/common/InternalInconsistencyException.h"
#include <wchar.h>
#include "Generic/reader/DefaultDocumentReader.h"
#include "Generic/state/XMLStrings.h"
#include "Generic/state/XMLTheoryElement.h"
// Note: Region formerly kept a pointer to the document that contained it.
// But it was never used, and made things a little more difficult for
// serialization, so I removed the pointer. If you want to add it back, then
// be sure to modify Document::Document(SerifXML::XMLTheoryElement documentElem)
// appropriately (in particular, the new Regions created during zoning will
// need to have their document pointers adjusted when they are "stolen").
Region::Region(const Document* document, Symbol tagName, int region_no, LocatedString *content)
: _tagName(tagName), _region_no(region_no),
_is_speaker_region(false), _is_receiver_region(false), _content_flags(0x00)
{
if(content != 0) {
_content = _new LocatedString(*content);
}
else {
_content = 0;
}
}
Region::~Region() {
delete _content;
}
void Region::toLowerCase() {
if (_content != 0)
_content->toLowerCase();
}
void Region::dump(std::ostream &out, int indent) {
char *newline = OutputUtil::getNewIndentedLinebreakString(indent);
out << "(region " << _region_no << "):";
if (_content != 0) {
out << newline;
_content->dump(out, indent + 2);
}
delete[] newline;
}
void Region::updateObjectIDTable() const {
throw InternalInconsistencyException("Region::updateObjectIDTable()",
"Using unimplemented method.");
}
void Region::saveState(StateSaver *stateSaver) const {
throw InternalInconsistencyException("Region::saveState()",
"Using unimplemented method.");
}
void Region::resolvePointers(StateLoader * stateLoader) {
throw InternalInconsistencyException("Region::resolvePointers()",
"Using unimplemented method.");
}
const wchar_t* Region::XMLIdentifierPrefix() const {
return L"region";
}
void Region::saveXML(SerifXML::XMLTheoryElement regionElem, const Theory *context) const {
using namespace SerifXML;
if (context != 0)
throw InternalInconsistencyException("Region::saveXML", "Expected context to be NULL");
if (!getRegionTag().is_null()) {
regionElem.setAttribute(X_tag, getRegionTag());
}
regionElem.setAttribute(X_is_speaker, isSpeakerRegion());
regionElem.setAttribute(X_is_receiver, isReceiverRegion());
getString()->saveXML(regionElem);
// Note: we don't serialize getRegionNumber(), since it's redundant --
// in particular, the i-th region in a document will be given region
// number i.
}
Region::Region(SerifXML::XMLTheoryElement regionElem, size_t region_no)
: _region_no(static_cast<int>(region_no)), _tagName(),
_is_speaker_region(false), _is_receiver_region(false), _content(0)
{
using namespace SerifXML;
regionElem.loadId(this);
_tagName = regionElem.getAttribute<Symbol>(X_tag, Symbol());
_is_speaker_region = regionElem.getAttribute<bool>(X_is_speaker, false);
_is_receiver_region = regionElem.getAttribute<bool>(X_is_receiver, false);
_content = _new LocatedString(regionElem);
}
| 33.712871 | 96 | 0.727166 | BBN-E |
3aac997c8c7811035e9e2501c962c99e6a0f7bdf | 4,048 | cpp | C++ | server/src/lidar_controller.cpp | jenny5-robot/jenny5-html5-controller | b23ab10d6a0896cbf8d7c5728fa6fdb4b4327e9c | [
"MIT"
] | 1 | 2020-06-02T02:18:32.000Z | 2020-06-02T02:18:32.000Z | server/src/lidar_controller.cpp | jenny5-robot/jenny5-html5 | b23ab10d6a0896cbf8d7c5728fa6fdb4b4327e9c | [
"MIT"
] | null | null | null | server/src/lidar_controller.cpp | jenny5-robot/jenny5-html5 | b23ab10d6a0896cbf8d7c5728fa6fdb4b4327e9c | [
"MIT"
] | null | null | null | // Author: Mihai Oltean, https://mihaioltean.github.io, mihai.oltean@gmail.com
// More details: https://jenny5.org, https://jenny5-robot.github.io/
// Source code: github.com/jenny5-robot
// License: MIT
// ---------------------------------------------------------------------------
#include "lidar_controller.h"
#include "jenny5_defs.h"
t_lidar_controller LIDAR_controller;
//----------------------------------------------------------------
t_lidar_controller::t_lidar_controller(void)
{
}
//----------------------------------------------------------------
int t_lidar_controller::connect(const char* port)
{
//-------------- START INITIALIZATION ------------------------------
if (!arduino_controller.connect(port, 115200)) { // real number - 1
//sprintf(error_string, "Error attaching to Jenny 5' LIDAR!\n");
return CANNOT_CONNECT_TO_JENNY5_LIDAR_ERROR;
}
// now wait to see if I have been connected
// wait for no more than 3 seconds. If it takes more it means that something is not right, so we have to abandon it
clock_t start_time = clock();
bool LIDAR_responded = false;
while (1) {
if (!arduino_controller.update_commands_from_serial())
Sleep(5); // no new data from serial ... we make a little pause so that we don't kill the processor
if (!LIDAR_responded)
if (arduino_controller.query_for_event(IS_ALIVE_EVENT)) { // have we received the event from Serial ?
LIDAR_responded = true;
break;
}
// measure the passed time
clock_t end_time = clock();
double wait_time = (double)(end_time - start_time) / CLOCKS_PER_SEC;
// if more than 3 seconds then game over
if (wait_time > NUM_SECONDS_TO_WAIT_FOR_CONNECTION) {
if (!LIDAR_responded)
return LIDAR_does_not_respond_ERROR;
}
}
return E_OK;
}
//----------------------------------------------------------------
bool t_lidar_controller::setup(char* error_string)
{
arduino_controller.send_create_LiDAR(8, 9, 10, 12);// dir, step, enable, IR_pin
clock_t start_time = clock();
bool lidar_controller_created = false;
while (1) {
if (!arduino_controller.update_commands_from_serial())
Sleep(5); // no new data from serial ... we make a little pause so that we don't kill the processor
if (!lidar_controller_created)
if (arduino_controller.query_for_event(LIDAR_CONTROLLER_CREATED_EVENT)) // have we received the event from Serial ?
lidar_controller_created = true;
if (lidar_controller_created)
break;
// measure the passed time
clock_t end_time = clock();
double wait_time = (double)(end_time - start_time) / CLOCKS_PER_SEC;
// if more than 3 seconds then game over
if (wait_time > NUM_SECONDS_TO_WAIT_FOR_CONNECTION) {
if (!lidar_controller_created)
sprintf(error_string, "Cannot create LIDAR controller! Game over!\n");
return false;
}
}
return true;
}
//----------------------------------------------------------------
bool t_lidar_controller::update_data(void)
{
int motor_position;
intptr_t distance;
bool at_least_one_new_LIDAR_distance = false;
while (arduino_controller.query_for_event(LIDAR_READ_EVENT, &motor_position, &distance)) { // have we received the event from Serial ?
lidar_distances[motor_position] = int(distance);
at_least_one_new_LIDAR_distance = true;
}
return at_least_one_new_LIDAR_distance;
}
//----------------------------------------------------------------
void t_lidar_controller::disconnect(void)
{
arduino_controller.close_connection();
}
//----------------------------------------------------------------
bool t_lidar_controller::is_connected(void)
{
return arduino_controller.is_open();
}
//----------------------------------------------------------------
const char *t_lidar_controller::error_to_string(int error)
{
switch (error) {
case E_OK:
return "LIDAR PERFECT\n";
case CANNOT_CONNECT_TO_JENNY5_LIDAR_ERROR:
return CANNOT_CONNECT_TO_JENNY5_LIDAR_STR;
case LIDAR_does_not_respond_ERROR:
return LIDAR_does_not_respond_STR;
}
return NULL;
}
//---------------------------------------------------------------- | 32.126984 | 136 | 0.629447 | jenny5-robot |
3aaf692c7179baf6517b461469f942f7e5ef3a2c | 60 | cpp | C++ | java projects/jtop/jtopas/versions.alt/seeded/v3/src/de/susebox/jtopas/spi/PaxHeaders.74544/KeywordHandler.cpp | NazaninBayati/SMBFL | 999c4bca166a32571e9f0b1ad99085a5d48550eb | [
"MIT"
] | 3 | 2019-08-31T06:18:29.000Z | 2020-09-07T12:36:38.000Z | java projects/jtop/jtopas/versions.alt/seeded/v3/src/de/susebox/jtopas/spi/PaxHeaders.74544/KeywordHandler.cpp | NazaninBayati/SMBFL | 999c4bca166a32571e9f0b1ad99085a5d48550eb | [
"MIT"
] | null | null | null | java projects/jtop/jtopas/versions.alt/seeded/v3/src/de/susebox/jtopas/spi/PaxHeaders.74544/KeywordHandler.cpp | NazaninBayati/SMBFL | 999c4bca166a32571e9f0b1ad99085a5d48550eb | [
"MIT"
] | null | null | null | 30 atime=1476297919.065719166
30 ctime=1476297919.066923277
| 20 | 29 | 0.866667 | NazaninBayati |
3aafb630c90d53761ba8fef9bf2339b92ff7bf43 | 13,547 | hpp | C++ | include/lvr2/io/ChannelManager.hpp | jtpils/lvr2 | b1010dfcc930d9ae0ff5cfa5c88d0810d65368ce | [
"BSD-3-Clause"
] | 1 | 2019-08-07T03:55:27.000Z | 2019-08-07T03:55:27.000Z | include/lvr2/io/ChannelManager.hpp | jtpils/lvr2 | b1010dfcc930d9ae0ff5cfa5c88d0810d65368ce | [
"BSD-3-Clause"
] | null | null | null | include/lvr2/io/ChannelManager.hpp | jtpils/lvr2 | b1010dfcc930d9ae0ff5cfa5c88d0810d65368ce | [
"BSD-3-Clause"
] | null | null | null | /**
* Copyright (c) 2018, University Osnabrück
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the University Osnabrück nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL University Osnabrück BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef CHANNELHANDLER_HPP
#define CHANNELHANDLER_HPP
// LVR2 includes
#include <lvr2/io/DataStruct.hpp>
#include <lvr2/geometry/Handles.hpp>
// Std lib includes
#include <iostream>
#include <array>
#include <exception>
// Boost includes
#include <boost/optional.hpp>
namespace lvr2
{
// forward declaration for ElementProxyPtr
template<typename T>
class ElementProxy;
/**
* @brief This class emulates a Pointer behaviour for an ElementProxy if its & operator is
* used. The arithmetic is based on the width of an ElementProxy. It was necessary for the
* Octree. USE WITH CARE.
*
* @tparam T the type of the underlying data array.
*/
template<typename T>
class ElementProxyPtr
{
public:
ElementProxyPtr(T* ptr = nullptr, size_t w = 0) : m_ptr(ptr), m_w(w) {}
// "Pointer" arithmetic
ElementProxyPtr operator+(const ElementProxyPtr&) = delete;
ssize_t operator-(const ElementProxyPtr& p)
{
return (this->m_ptr - p.m_ptr) / m_w;
}
ElementProxyPtr& operator++()
{
m_ptr += m_w;
return *this;
}
ElementProxyPtr operator+(size_t i)
{
ElementProxyPtr tmp(*this);
tmp += i;
return tmp;
}
ElementProxyPtr operator++(int)
{
ElementProxyPtr tmp(*this);
operator++();
return tmp;
}
ElementProxyPtr& operator+=(size_t i)
{
m_ptr += (m_w * i);
return *this;
}
ElementProxyPtr operator-=(size_t i)
{
m_ptr -= (m_w * i);
}
// comparison operators
bool operator< (const ElementProxyPtr& rhs) const { return (*this).m_ptr < rhs.m_ptr; }
bool operator> (const ElementProxyPtr& rhs) const { return rhs < (*this); }
bool operator<=(const ElementProxyPtr& rhs) const { return !((*this) > rhs); }
bool operator>=(const ElementProxyPtr& rhs) const { return !((*this) < rhs); }
bool operator==(const ElementProxyPtr& rhs) const { return (*this).m_ptr == rhs.m_ptr; }
bool operator!=(const ElementProxyPtr& rhs) const { return !(*this == rhs); }
// member access.
ElementProxy<T> operator*() { return ElementProxy<T>(m_ptr, m_w); }
// TODO [] operator ?!
// I don't think we are able to return a useful raw pointer.
// Array pointer breaks the abstraction.
// Pointer to Elementproxy is pointless because we would need to create one with new.
// We cannot overload the -> operator in ElementProxy for the same reasons.
ElementProxy<T>* operator->() = delete;
private:
T* m_ptr;
size_t m_w;
};
template<typename T>
class ElementProxy
{
public:
friend class ElementProxyPtr<T>;
/**
* @brief look at ElementProxyPtr documentation.
*
* @return
*/
ElementProxyPtr<T> operator&()
{
return ElementProxyPtr<T>(m_ptr, m_w);
}
ElementProxy operator=(const T& v)
{
if( m_ptr && (m_w == 1))
m_ptr[0] = v;
return *this;
}
template<typename BaseVecT>
ElementProxy operator=(const BaseVecT& v)
{
if( m_ptr && (m_w > 2))
{
m_ptr[0] = v.x;
m_ptr[1] = v.y;
m_ptr[2] = v.z;
}
return *this;
}
template<typename BaseVecT>
ElementProxy operator+=(const BaseVecT& v)
{
if( m_ptr && (m_w > 2))
{
m_ptr[0] += v.x;
m_ptr[1] += v.y;
m_ptr[2] += v.z;
}
return *this;
}
template<typename BaseVecT>
ElementProxy operator-=(const BaseVecT& v)
{
if( m_ptr && (m_w > 2))
{
m_ptr[0] -= v.x;
m_ptr[1] -= v.y;
m_ptr[2] -= v.z;
}
return *this;
}
template<typename BaseVecT>
BaseVecT operator+(const BaseVecT& v)
{
if(m_w > 2)
{
*this += v;
return BaseVecT(m_ptr[0], m_ptr[1], m_ptr[2]);
}
throw std::range_error("Element Proxy: Width to small for BaseVec addition");
}
template<typename BaseVecT>
BaseVecT operator-(const BaseVecT& v)
{
if(m_w > 2)
{
*this -= v;
return BaseVecT(m_ptr[0], m_ptr[1], m_ptr[2]);
}
throw std::range_error("Element Proxy: Width to small for BaseVec subtraction");
}
ElementProxy(T* pos = nullptr, unsigned w = 0) : m_ptr(pos), m_w(w) {}
T& operator[](int i)
{
if(m_ptr && (i < m_w))
{
return m_ptr[i];
}
throw std::range_error("Element Proxy: Index larger than width");
}
const T& operator[](int i) const
{
if(m_ptr && (i < m_w))
{
return m_ptr[i];
}
throw std::range_error("Element Proxy: Index out of Bounds");
}
/// User defined conversion operator
template<typename BaseVecT>
operator BaseVecT() const
{
if(m_w == 3)
{
return BaseVecT(m_ptr[0], m_ptr[1], m_ptr[2]);
}
throw std::range_error("Element Proxy: Width != 3 in BaseVecT conversion");
}
operator std::array<VertexHandle, 3>() const
{
std::array<VertexHandle, 3> arr0 = {VertexHandle(0), VertexHandle(0), VertexHandle(0)};
if(m_w == 3)
{
std::array<VertexHandle, 3> arr = {VertexHandle(m_ptr[0]), VertexHandle(m_ptr[1]), VertexHandle(m_ptr[2])};
return arr;
}
throw std::range_error("Element Proxy: Width != 3 in std::array conversion.");
}
operator EdgeHandle() const
{
if(m_w == 1)
{
return EdgeHandle(m_ptr[0]);
}
throw std::range_error("Element Proxy: Width != 1 in EdgeHandle conversion.");
}
operator FaceHandle() const
{
if(m_w == 1)
{
return FaceHandle(m_ptr[0]);
}
throw std::range_error("Element Proxy: Width != 1 in FaceHandle conversion.");
}
operator T() const
{
if(m_w == 1)
{
return m_ptr[0];
}
throw std::range_error("Element Proxy: Width != 1 in content type conversion.");
}
private:
T* m_ptr;
unsigned m_w;
};
template<typename T>
class AttributeChannel
{
public:
typedef boost::optional<AttributeChannel<T>> Optional;
using DataPtr = boost::shared_array<T>;
AttributeChannel(size_t n, unsigned width)
: m_elementWidth(width), m_numElements(n),
m_data(new T[m_numElements * width])
{}
AttributeChannel(size_t n, unsigned width, DataPtr ptr)
: m_numElements(n),
m_elementWidth(width),
m_data(ptr)
{}
ElementProxy<T> operator[](const unsigned& idx)
{
T* ptr = m_data.get();
return ElementProxy<T>(&(ptr[idx * m_elementWidth]), m_elementWidth);
}
DataPtr dataPtr() const { return m_data;}
unsigned width() const { return m_elementWidth;}
size_t numElements() const { return m_numElements;}
private:
size_t m_numElements;
unsigned m_elementWidth;
DataPtr m_data;
};
// Some type aliases
using FloatChannel = AttributeChannel<float>;
using UCharChannel = AttributeChannel<unsigned char>;
using IndexChannel = AttributeChannel<unsigned int>;
using FloatChannelOptional = boost::optional<FloatChannel>;
using UCharChannelOptional= boost::optional<UCharChannel>;
using IndexChannelOptional = boost::optional<IndexChannel>;
using FloatProxy = ElementProxy<float>;
using UCharProxy = ElementProxy<unsigned char>;
using IndexProxy = ElementProxy<unsigned int>;
using FloatChannelPtr = std::shared_ptr<FloatChannel>;
using UCharChannelPtr = std::shared_ptr<UCharChannel>;
using IndexChannelPtr = std::shared_ptr<IndexChannel>;
using intOptional = boost::optional<int>;
using floatOptional = boost::optional<float>;
using ucharOptional = boost::optional<unsigned char>;
class ChannelManager
{
public:
ChannelManager() {}
bool removeIndexChannel(const std::string& name)
{
return m_indexChannels.erase(name) > 0;
}
bool removeFloatChannel(const std::string& name)
{
return m_floatChannels.erase(name) > 0;
}
bool removeUCharChannel(const std::string& name)
{
return m_ucharChannels.erase(name) > 0;
}
void addIndexChannel(
indexArray array,
std::string name,
size_t n,
unsigned width);
void addFloatChannel(
floatArr array,
std::string name,
size_t n,
unsigned width);
void addUCharChannel(
ucharArr array,
std::string name,
size_t n,
unsigned width);
void addEmptyFloatChannel(
std::string name,
size_t n,
unsigned width);
void addEmptyUCharChannel(
std::string name,
size_t n,
unsigned width);
void addEmptyIndexChannel(
std::string name,
size_t n,
unsigned width);
void addChannel(indexArray array, std::string name, size_t n, unsigned width)
{ addIndexChannel(array, name, n, width);}
void addChannel(floatArr array, std::string name, size_t n, unsigned width)
{ addFloatChannel(array, name, n, width);}
void addChannel(ucharArr array, std::string name, size_t n, unsigned width)
{ addUCharChannel(array, name, n, width);}
void getChannel(std::string name, FloatChannelOptional& channelOptional )
{ channelOptional = getFloatChannel(name);}
void getChannel(std::string name, IndexChannelOptional& channelOptional)
{ channelOptional = getIndexChannel(name);}
void getChannel(std::string name, UCharChannelOptional& channelOptional)
{ channelOptional = getUCharChannel(name);}
bool hasUCharChannel(std::string name);
bool hasFloatChannel(std::string name);
bool hasIndexChannel(std::string name);
unsigned ucharChannelWidth(std::string name);
unsigned floatChannelWidth(std::string name);
unsigned indexChannelWidth(std::string name);
FloatProxy getFloatHandle(int idx, const std::string& name);
UCharProxy getUCharHandle(int idx, const std::string& name);
IndexProxy getIndexHandle(int idx, const std::string& name);
FloatProxy operator[](size_t idx);
floatArr getFloatArray(size_t& n, unsigned& w, const std::string name);
ucharArr getUCharArray(size_t& n, unsigned& w, const std::string name);
indexArray getIndexArray(size_t& n, unsigned& w, const std::string name);
FloatChannelOptional getFloatChannel(std::string name);
UCharChannelOptional getUCharChannel(std::string name);
IndexChannelOptional getIndexChannel(std::string name);
floatOptional getFloatAtomic(std::string name);
ucharOptional getUCharAtomic(std::string name);
intOptional getIntAtomic(std::string name);
void addFloatChannel(FloatChannelPtr data, std::string name);
void addUCharChannel(UCharChannelPtr data, std::string name);
void addIndexChannel(IndexChannelPtr data, std::string name);
void addFloatAtomic(float data, std::string name);
void addUCharAtomic(unsigned char data, std::string name);
void addIntAtomic(int data, std::string name);
private:
std::map<std::string, FloatChannelPtr> m_floatChannels;
std::map<std::string, UCharChannelPtr> m_ucharChannels;
std::map<std::string, IndexChannelPtr> m_indexChannels;
std::map<std::string, float> m_floatAtomics;
std::map<std::string, unsigned char> m_ucharAtomics;
std::map<std::string, int> m_intAtomics;
using FloatChannelMap = std::map<std::string, FloatChannelPtr>;
using UCharChannelMap = std::map<std::string, UCharChannelPtr>;
using IndexChannelMap = std::map<std::string, IndexChannelPtr>;
};
} // namespace lvr2
#endif // CHANNELHANDLER_HPP
| 29.386117 | 119 | 0.634679 | jtpils |
3ab0a6b9c8ddbdd037e4722c75ea71ba10b1e211 | 11,113 | cpp | C++ | DT3Windows8/DeviceGraphicsDX11Shader.cpp | 9heart/DT3 | 4ba8fd2af3aebb5c0d77036ac3941e83cd4d1c7e | [
"MIT"
] | 3 | 2018-10-05T15:03:27.000Z | 2019-03-19T11:01:56.000Z | DT3Windows8/DeviceGraphicsDX11Shader.cpp | pakoito/DT3 | 4ba8fd2af3aebb5c0d77036ac3941e83cd4d1c7e | [
"MIT"
] | 1 | 2016-01-28T14:39:49.000Z | 2016-01-28T22:12:07.000Z | DT3Windows8/DeviceGraphicsDX11Shader.cpp | adderly/DT3 | e2605be091ec903d3582e182313837cbaf790857 | [
"MIT"
] | 3 | 2016-01-25T16:44:51.000Z | 2021-01-29T19:59:45.000Z | //==============================================================================
///
/// File: DeviceGraphicsDX11Shader.cpp
///
/// Copyright (C) 2000-2013 by Smells Like Donkey, Inc. All rights reserved.
///
/// This file is subject to the terms and conditions defined in
/// file 'LICENSE.txt', which is part of this source code package.
///
//==============================================================================
#include "DeviceGraphicsDX11Shader.hpp"
#include "DeviceGraphicsDX11Renderer.hpp"
#include "DeviceGraphicsDX11VertexShader.hpp"
#include "DeviceGraphicsDX11PixelShader.hpp"
#include "MoreMath.hpp"
#include "DeviceGlobalsManager.hpp"
#include "System.hpp"
#include "DeviceConsole.hpp"
#include "Factory.hpp"
#include "FilePath.hpp"
#include "ShaderResource.hpp"
#include "TextFileStream.hpp"
#include "DeviceFileManager.hpp"
#include "CheckedCast.hpp"
#include "StringCast.hpp"
#include "FragmentShaderResource.hpp"
#include "VertexShaderResource.hpp"
#include "GeometryShaderResource.hpp"
//==============================================================================
//==============================================================================
namespace DT2 {
//==============================================================================
/// Register with object factory
//==============================================================================
IMPLEMENT_FACTORY_CREATION(DeviceGraphicsDX11Shader)
//==============================================================================
/// Standard class constructors/destructors
//==============================================================================
DeviceGraphicsDX11Shader::DeviceGraphicsDX11Shader (void)
: _layout (NULL),
_pixel_shader (NULL),
_vertex_shader (NULL)
{
for (DTuint i = 0; i < ARRAY_SIZE(_constants); ++i) {
_constants[i] = NULL;
}
}
DeviceGraphicsDX11Shader::~DeviceGraphicsDX11Shader (void)
{
clear();
RELEASE(_pixel_shader);
RELEASE(_vertex_shader);
}
//==============================================================================
//==============================================================================
void DeviceGraphicsDX11Shader::clear(void)
{
SAFE_RELEASE(_layout);
for (DTuint i = 0; i < ARRAY_SIZE(_constants); ++i) {
SAFE_RELEASE(_constants[i]);
}
for (DTuint i = 0; i < _parameters.size(); ++i) {
SAFE_RELEASE(_parameters[i]);
}
_parameters.clear();
}
//==============================================================================
//==============================================================================
#define ADD_DESC(A,F) \
if (program->hasAttrib(A)) { \
String attrib_name = program->getAttribName(A); \
String index = attrib_name.endDigits(); \
name_buffer[desc_index] = attrib_name.trimEndDigits(); \
desc[desc_index].SemanticName = name_buffer[desc_index].cStr(); \
desc[desc_index].SemanticIndex = index.size() ? castFromString<DTint>(index) : 0; \
desc[desc_index].Format = F; \
desc[desc_index].InputSlot = A; \
desc[desc_index].AlignedByteOffset = 0; \
desc[desc_index].InputSlotClass = D3D11_INPUT_PER_VERTEX_DATA; \
desc[desc_index].InstanceDataStepRate = 0; \
++desc_index; \
}
#define ADD_CONSTANT(A,S) \
if (!program->getUniformName(A).empty()) { \
String constant_name = program->getUniformName(A); \
DTint ps_resource_index = program->getFragmentShader() ? program->getFragmentShader()->getShaderResourceIndex (constant_name) : -1; \
DTint vs_resource_index = program->getVertexShader() ? program->getVertexShader()->getShaderResourceIndex (constant_name) : -1; \
\
D3D11_BUFFER_DESC desc; \
desc.ByteWidth = S; \
desc.MiscFlags = 0; \
desc.StructureByteStride = 0; \
desc.BindFlags = D3D11_BIND_CONSTANT_BUFFER; \
desc.Usage = D3D11_USAGE_DYNAMIC; \
desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; \
\
HRESULT hr = device->CreateBuffer(&desc, NULL, &_constants[A]); \
Assert(SUCCEEDED(hr)); \
\
if (vs_resource_index >= 0) _vs_constants[vs_resource_index] = _constants[A]; \
if (ps_resource_index >= 0) _ps_constants[ps_resource_index] = _constants[A]; \
}
void DeviceGraphicsDX11Shader::syncToResource (ShaderResource *program)
{
if (program->getRecacheData()) {
DeviceGraphicsDX11Renderer *renderer = checkedCast<DeviceGraphicsDX11Renderer*>(System::getRenderer());
ID3D11Device1 *device = renderer->getD3D11Device();
ID3D11DeviceContext1 *context = renderer->getD3D11Context();
SAFE_ASSIGN(_pixel_shader, checkedCast<DeviceGraphicsDX11Renderer*>(System::getRenderer())->getPixelShaderCached(program->getFragmentShader()));
SAFE_ASSIGN(_vertex_shader, checkedCast<DeviceGraphicsDX11Renderer*>(System::getRenderer())->getVertexShaderCached(program->getVertexShader()));
if (!_pixel_shader || !_vertex_shader) { // Geometry shader is optional
program->setRecacheData(false);
return;
}
// Clear previous resources
clear();
HRESULT hr;
//
// Build a layout (Input element description)
//
D3D11_INPUT_ELEMENT_DESC desc[D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT];
String name_buffer[D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT];
::memset(desc,0,sizeof(desc));
DTuint desc_index = 0;
ADD_DESC(ShaderResource::ATTRIB_POSITION, DXGI_FORMAT_R32G32B32_FLOAT);
ADD_DESC(ShaderResource::ATTRIB_COLOR, DXGI_FORMAT_R8G8B8A8_UNORM);
ADD_DESC(ShaderResource::ATTRIB_NORMAL, DXGI_FORMAT_R32G32B32_FLOAT);
ADD_DESC(ShaderResource::ATTRIB_TEXCOORD0, DXGI_FORMAT_R32G32_FLOAT);
ADD_DESC(ShaderResource::ATTRIB_TEXCOORD1, DXGI_FORMAT_R32G32_FLOAT);
ADD_DESC(ShaderResource::ATTRIB_TEXCOORD2, DXGI_FORMAT_R32G32_FLOAT);
ADD_DESC(ShaderResource::ATTRIB_TEXCOORD3, DXGI_FORMAT_R32G32_FLOAT);
ADD_DESC(ShaderResource::ATTRIB_WEIGHTS_INDEX, DXGI_FORMAT_R16G16B16A16_UINT);
ADD_DESC(ShaderResource::ATTRIB_WEIGHTS_STRENGTH, DXGI_FORMAT_R32G32B32A32_FLOAT);
const String *bytecode = program->getVertexShader()->getShader("HLSL");
hr = device->CreateInputLayout(desc,desc_index,&(*bytecode)[0],bytecode->size(),&_layout);
Assert(SUCCEEDED(hr));
//
// Constants (Uniforms)
//
::memset(_constants,0,sizeof(_constants));
::memset(_vs_constants,0,sizeof(_vs_constants));
::memset(_ps_constants,0,sizeof(_ps_constants));
ADD_CONSTANT(ShaderResource::UNIFORM_COLOR, sizeof(float) * 4);
ADD_CONSTANT(ShaderResource::UNIFORM_TEXTURE0, sizeof(float) * 16);
ADD_CONSTANT(ShaderResource::UNIFORM_TEXTURE1, sizeof(float) * 16);
ADD_CONSTANT(ShaderResource::UNIFORM_MODELVIEW, sizeof(float) * 16);
ADD_CONSTANT(ShaderResource::UNIFORM_PROJECTION, sizeof(float) * 16);
ADD_CONSTANT(ShaderResource::UNIFORM_CAMERA, sizeof(float) * 16);
//ADD_CONSTANT(ShaderResource::UNIFORM_SKELETON,???);
const Array<ShaderResource::Parameter> ¶meters = program->getParameters();
_parameters.resize(parameters.size());
for (DTuint i = 0; i < parameters.size(); ++i) {
String constant_name = parameters[i].name;
DTint ps_resource_index = program->getFragmentShader() ? program->getFragmentShader()->getShaderResourceIndex (constant_name) : -1;
DTint vs_resource_index = program->getVertexShader() ? program->getVertexShader()->getShaderResourceIndex (constant_name) : -1;
D3D11_BUFFER_DESC desc;
desc.ByteWidth = parameters[i].data.size();
desc.MiscFlags = 0;
desc.StructureByteStride = 0;
desc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
desc.Usage = D3D11_USAGE_DYNAMIC;
desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
HRESULT hr = device->CreateBuffer(&desc, NULL, &_parameters[i]);
Assert(SUCCEEDED(hr));
if (vs_resource_index >= 0) _vs_constants[vs_resource_index] = _parameters[i];
if (ps_resource_index >= 0) _ps_constants[ps_resource_index] = _parameters[i];
}
program->setRecacheData(false);
}
// recache all of our parameters
if (program->getRecacheParameters()) {
DeviceGraphicsDX11Renderer *renderer = checkedCast<DeviceGraphicsDX11Renderer*>(System::getRenderer());
ID3D11DeviceContext1 *context = renderer->getD3D11Context();
// Get Parameters. This creates a mapping from our internal index to an opengl uniform location
const Array<ShaderResource::Parameter> ¶meters = program->getParameters();
for (DTuint i = 0; i < parameters.size(); ++i) {
const ShaderResource::Parameter &p = parameters[i];
context->UpdateSubresource(_parameters[i], 0, NULL, ¶meters[0].data[0], parameters[i].data.size(), parameters[i].data.size());
}
program->setRecacheParameters(false);
}
}
//==============================================================================
//==============================================================================
void DeviceGraphicsDX11Shader::setConstantValue (ID3D11Buffer *buffer, DTubyte *data, DTuint size)
{
if (!buffer)
return;
DeviceGraphicsDX11Renderer *renderer = checkedCast<DeviceGraphicsDX11Renderer*>(System::getRenderer());
ID3D11DeviceContext1 *context = renderer->getD3D11Context();
D3D11_MAPPED_SUBRESOURCE res;
HRESULT hr = context->Map(buffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &res);
::memcpy(res.pData,data,size);
context->Unmap(buffer, 0);
}
//==============================================================================
//==============================================================================
} // DT2
| 39.407801 | 154 | 0.541528 | 9heart |
3ab212d5c0c143d3fd822e31fe379b44bab6f909 | 1,162 | cpp | C++ | library/math/longestArithmeticSubsequence.cpp | bluedawnstar/algorithm_library | 4c7f64ec61fc2ba059b64ad7ba20fcb5b838ced6 | [
"Unlicense"
] | 40 | 2017-11-26T05:29:18.000Z | 2020-11-13T00:29:26.000Z | library/math/longestArithmeticSubsequence.cpp | bluedawnstar/algorithm_library | 4c7f64ec61fc2ba059b64ad7ba20fcb5b838ced6 | [
"Unlicense"
] | 101 | 2019-02-09T06:06:09.000Z | 2021-12-25T16:55:37.000Z | library/math/longestArithmeticSubsequence.cpp | bluedawnstar/algorithm_library | 4c7f64ec61fc2ba059b64ad7ba20fcb5b838ced6 | [
"Unlicense"
] | 6 | 2017-01-03T14:17:58.000Z | 2021-01-22T10:37:04.000Z | #include <vector>
#include <algorithm>
using namespace std;
#include "longestArithmeticSubsequence.h"
/////////// For Testing ///////////////////////////////////////////////////////
#include <time.h>
#include <cassert>
#include <string>
#include <iostream>
#include "../common/iostreamhelper.h"
void testLongestArithmeticSubsequence() {
//return; //TODO: if you want to test, make this line a comment.
cout << "--- Longest Arithmetic Subsequence -----------------------" << endl;
{
auto las1 = buildLongestArithmeticSubsequenceK(5, 2);
auto las1Len = lenghtOfLongestArithmeticSubsequence(las1);
cout << las1 << ", " << las1Len << endl;
assert(las1Len == 2);
auto las2 = buildLongestArithmeticSubsequenceK(5, 3);
auto las2Len = lenghtOfLongestArithmeticSubsequence(las2);
cout << las2 << ", " << las2Len << endl;
assert(las2Len == 3);
auto las3 = buildLongestArithmeticSubsequenceK(8, 2);
auto las3Len = lenghtOfLongestArithmeticSubsequence(las3);
cout << las3 << ", " << las3Len << endl;
assert(las3Len == 2);
}
cout << "OK!" << endl;
}
| 29.794872 | 81 | 0.589501 | bluedawnstar |
3ab21f975dd3dca35081fbc3c4746cd6bab45d4b | 775 | cc | C++ | examples/pxScene2d/external/libnode-v10.15.3/deps/v8/src/builtins/builtins-reflect-gen.cc | madanagopaltcomcast/pxCore | c4a3a40a190521c8b6383d126c87612eca5b3c42 | [
"Apache-2.0"
] | 5,964 | 2016-09-27T03:46:29.000Z | 2022-03-31T16:25:27.000Z | examples/pxScene2d/external/libnode-v10.15.3/deps/v8/src/builtins/builtins-reflect-gen.cc | madanagopaltcomcast/pxCore | c4a3a40a190521c8b6383d126c87612eca5b3c42 | [
"Apache-2.0"
] | 1,432 | 2017-06-21T04:08:48.000Z | 2020-08-25T16:21:15.000Z | examples/pxScene2d/external/libnode-v10.15.3/deps/v8/src/builtins/builtins-reflect-gen.cc | madanagopaltcomcast/pxCore | c4a3a40a190521c8b6383d126c87612eca5b3c42 | [
"Apache-2.0"
] | 1,006 | 2016-09-27T05:17:27.000Z | 2022-03-30T02:46:51.000Z | // Copyright 2017 the V8 project 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 "src/builtins/builtins-utils-gen.h"
#include "src/builtins/builtins.h"
#include "src/code-stub-assembler.h"
namespace v8 {
namespace internal {
// ES section #sec-reflect.has
TF_BUILTIN(ReflectHas, CodeStubAssembler) {
Node* target = Parameter(Descriptor::kTarget);
Node* key = Parameter(Descriptor::kKey);
Node* context = Parameter(Descriptor::kContext);
ThrowIfNotJSReceiver(context, target, MessageTemplate::kCalledOnNonObject,
"Reflect.has");
Return(CallBuiltin(Builtins::kHasProperty, context, key, target));
}
} // namespace internal
} // namespace v8
| 29.807692 | 76 | 0.727742 | madanagopaltcomcast |
3ab294441d0e1679bc7ee95e342b65aa3d7af470 | 19,705 | cc | C++ | third_party/blink/renderer/core/animation/timing_input_test.cc | sarang-apps/darshan_browser | 173649bb8a7c656dc60784d19e7bb73e07c20daa | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | null | null | null | third_party/blink/renderer/core/animation/timing_input_test.cc | sarang-apps/darshan_browser | 173649bb8a7c656dc60784d19e7bb73e07c20daa | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | null | null | null | third_party/blink/renderer/core/animation/timing_input_test.cc | sarang-apps/darshan_browser | 173649bb8a7c656dc60784d19e7bb73e07c20daa | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | null | null | null | // Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "third_party/blink/renderer/core/animation/timing_input.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/renderer/bindings/core/v8/unrestricted_double_or_keyframe_animation_options.h"
#include "third_party/blink/renderer/bindings/core/v8/unrestricted_double_or_keyframe_effect_options.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_binding_for_testing.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_keyframe_animation_options.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_keyframe_effect_options.h"
#include "third_party/blink/renderer/core/animation/animation_test_helper.h"
#include "third_party/blink/renderer/core/testing/dummy_page_holder.h"
#include "v8/include/v8.h"
namespace blink {
class AnimationTimingInputTest : public testing::Test {
public:
Timing ApplyTimingInputNumber(v8::Isolate*,
String timing_property,
double timing_property_value,
bool& timing_conversion_success,
bool is_keyframeeffectoptions = true);
Timing ApplyTimingInputString(v8::Isolate*,
String timing_property,
String timing_property_value,
bool& timing_conversion_success,
bool is_keyframeeffectoptions = true);
private:
void SetUp() override { page_holder_ = std::make_unique<DummyPageHolder>(); }
Document* GetDocument() const { return &page_holder_->GetDocument(); }
std::unique_ptr<DummyPageHolder> page_holder_;
};
Timing AnimationTimingInputTest::ApplyTimingInputNumber(
v8::Isolate* isolate,
String timing_property,
double timing_property_value,
bool& timing_conversion_success,
bool is_keyframeeffectoptions) {
v8::Local<v8::Object> timing_input = v8::Object::New(isolate);
SetV8ObjectPropertyAsNumber(isolate, timing_input, timing_property,
timing_property_value);
DummyExceptionStateForTesting exception_state;
Timing result;
if (is_keyframeeffectoptions) {
KeyframeEffectOptions* timing_input_dictionary =
NativeValueTraits<KeyframeEffectOptions>::NativeValue(
isolate, timing_input, exception_state);
UnrestrictedDoubleOrKeyframeEffectOptions timing_input =
UnrestrictedDoubleOrKeyframeEffectOptions::FromKeyframeEffectOptions(
timing_input_dictionary);
result = TimingInput::Convert(timing_input, GetDocument(), exception_state);
} else {
KeyframeAnimationOptions* timing_input_dictionary =
NativeValueTraits<KeyframeAnimationOptions>::NativeValue(
isolate, timing_input, exception_state);
UnrestrictedDoubleOrKeyframeAnimationOptions timing_input =
UnrestrictedDoubleOrKeyframeAnimationOptions::
FromKeyframeAnimationOptions(timing_input_dictionary);
result = TimingInput::Convert(timing_input, GetDocument(), exception_state);
}
timing_conversion_success = !exception_state.HadException();
return result;
}
Timing AnimationTimingInputTest::ApplyTimingInputString(
v8::Isolate* isolate,
String timing_property,
String timing_property_value,
bool& timing_conversion_success,
bool is_keyframeeffectoptions) {
v8::Local<v8::Object> timing_input = v8::Object::New(isolate);
SetV8ObjectPropertyAsString(isolate, timing_input, timing_property,
timing_property_value);
DummyExceptionStateForTesting exception_state;
Timing result;
if (is_keyframeeffectoptions) {
KeyframeEffectOptions* timing_input_dictionary =
NativeValueTraits<KeyframeEffectOptions>::NativeValue(
isolate, timing_input, exception_state);
UnrestrictedDoubleOrKeyframeEffectOptions timing_input =
UnrestrictedDoubleOrKeyframeEffectOptions::FromKeyframeEffectOptions(
timing_input_dictionary);
result = TimingInput::Convert(timing_input, GetDocument(), exception_state);
} else {
KeyframeAnimationOptions* timing_input_dictionary =
NativeValueTraits<KeyframeAnimationOptions>::NativeValue(
isolate, timing_input, exception_state);
UnrestrictedDoubleOrKeyframeAnimationOptions timing_input =
UnrestrictedDoubleOrKeyframeAnimationOptions::
FromKeyframeAnimationOptions(timing_input_dictionary);
result = TimingInput::Convert(timing_input, GetDocument(), exception_state);
}
timing_conversion_success = !exception_state.HadException();
return result;
}
TEST_F(AnimationTimingInputTest, TimingInputStartDelay) {
V8TestingScope scope;
bool ignored_success;
EXPECT_EQ(1.1, ApplyTimingInputNumber(scope.GetIsolate(), "delay", 1100,
ignored_success)
.start_delay);
EXPECT_EQ(-1, ApplyTimingInputNumber(scope.GetIsolate(), "delay", -1000,
ignored_success)
.start_delay);
EXPECT_EQ(1, ApplyTimingInputString(scope.GetIsolate(), "delay", "1000",
ignored_success)
.start_delay);
EXPECT_EQ(0, ApplyTimingInputString(scope.GetIsolate(), "delay", "1s",
ignored_success)
.start_delay);
EXPECT_EQ(0, ApplyTimingInputString(scope.GetIsolate(), "delay", "Infinity",
ignored_success)
.start_delay);
EXPECT_EQ(0, ApplyTimingInputString(scope.GetIsolate(), "delay", "-Infinity",
ignored_success)
.start_delay);
EXPECT_EQ(0, ApplyTimingInputString(scope.GetIsolate(), "delay", "NaN",
ignored_success)
.start_delay);
EXPECT_EQ(0, ApplyTimingInputString(scope.GetIsolate(), "delay", "rubbish",
ignored_success)
.start_delay);
}
TEST_F(AnimationTimingInputTest,
TimingInputStartDelayKeyframeAnimationOptions) {
V8TestingScope scope;
bool ignored_success;
EXPECT_EQ(1.1, ApplyTimingInputNumber(scope.GetIsolate(), "delay", 1100,
ignored_success, false)
.start_delay);
EXPECT_EQ(-1, ApplyTimingInputNumber(scope.GetIsolate(), "delay", -1000,
ignored_success, false)
.start_delay);
EXPECT_EQ(1, ApplyTimingInputString(scope.GetIsolate(), "delay", "1000",
ignored_success, false)
.start_delay);
EXPECT_EQ(0, ApplyTimingInputString(scope.GetIsolate(), "delay", "1s",
ignored_success, false)
.start_delay);
EXPECT_EQ(0, ApplyTimingInputString(scope.GetIsolate(), "delay", "Infinity",
ignored_success, false)
.start_delay);
EXPECT_EQ(0, ApplyTimingInputString(scope.GetIsolate(), "delay", "-Infinity",
ignored_success, false)
.start_delay);
EXPECT_EQ(0, ApplyTimingInputString(scope.GetIsolate(), "delay", "NaN",
ignored_success, false)
.start_delay);
EXPECT_EQ(0, ApplyTimingInputString(scope.GetIsolate(), "delay", "rubbish",
ignored_success, false)
.start_delay);
}
TEST_F(AnimationTimingInputTest, TimingInputEndDelay) {
V8TestingScope scope;
bool ignored_success;
EXPECT_EQ(10, ApplyTimingInputNumber(scope.GetIsolate(), "endDelay", 10000,
ignored_success)
.end_delay);
EXPECT_EQ(-2.5, ApplyTimingInputNumber(scope.GetIsolate(), "endDelay", -2500,
ignored_success)
.end_delay);
}
TEST_F(AnimationTimingInputTest, TimingInputFillMode) {
V8TestingScope scope;
Timing::FillMode default_fill_mode = Timing::FillMode::AUTO;
bool ignored_success;
EXPECT_EQ(Timing::FillMode::AUTO,
ApplyTimingInputString(scope.GetIsolate(), "fill", "auto",
ignored_success)
.fill_mode);
EXPECT_EQ(Timing::FillMode::FORWARDS,
ApplyTimingInputString(scope.GetIsolate(), "fill", "forwards",
ignored_success)
.fill_mode);
EXPECT_EQ(Timing::FillMode::NONE,
ApplyTimingInputString(scope.GetIsolate(), "fill", "none",
ignored_success)
.fill_mode);
EXPECT_EQ(Timing::FillMode::BACKWARDS,
ApplyTimingInputString(scope.GetIsolate(), "fill", "backwards",
ignored_success)
.fill_mode);
EXPECT_EQ(Timing::FillMode::BOTH,
ApplyTimingInputString(scope.GetIsolate(), "fill", "both",
ignored_success)
.fill_mode);
EXPECT_EQ(default_fill_mode,
ApplyTimingInputString(scope.GetIsolate(), "fill", "everything!",
ignored_success)
.fill_mode);
EXPECT_EQ(default_fill_mode,
ApplyTimingInputString(scope.GetIsolate(), "fill",
"backwardsandforwards", ignored_success)
.fill_mode);
EXPECT_EQ(
default_fill_mode,
ApplyTimingInputNumber(scope.GetIsolate(), "fill", 2, ignored_success)
.fill_mode);
}
TEST_F(AnimationTimingInputTest, TimingInputIterationStart) {
V8TestingScope scope;
bool success;
EXPECT_EQ(1.1, ApplyTimingInputNumber(scope.GetIsolate(), "iterationStart",
1.1, success)
.iteration_start);
EXPECT_TRUE(success);
ApplyTimingInputNumber(scope.GetIsolate(), "iterationStart", -1, success);
EXPECT_FALSE(success);
ApplyTimingInputString(scope.GetIsolate(), "iterationStart", "Infinity",
success);
EXPECT_FALSE(success);
ApplyTimingInputString(scope.GetIsolate(), "iterationStart", "-Infinity",
success);
EXPECT_FALSE(success);
ApplyTimingInputString(scope.GetIsolate(), "iterationStart", "NaN", success);
EXPECT_FALSE(success);
ApplyTimingInputString(scope.GetIsolate(), "iterationStart", "rubbish",
success);
EXPECT_FALSE(success);
}
TEST_F(AnimationTimingInputTest, TimingInputIterationCount) {
V8TestingScope scope;
bool success;
EXPECT_EQ(2.1, ApplyTimingInputNumber(scope.GetIsolate(), "iterations", 2.1,
success)
.iteration_count);
EXPECT_TRUE(success);
Timing timing = ApplyTimingInputString(scope.GetIsolate(), "iterations",
"Infinity", success);
EXPECT_TRUE(success);
EXPECT_TRUE(std::isinf(timing.iteration_count));
EXPECT_GT(timing.iteration_count, 0);
ApplyTimingInputNumber(scope.GetIsolate(), "iterations", -1, success);
EXPECT_FALSE(success);
ApplyTimingInputString(scope.GetIsolate(), "iterations", "-Infinity",
success);
EXPECT_FALSE(success);
ApplyTimingInputString(scope.GetIsolate(), "iterations", "NaN", success);
EXPECT_FALSE(success);
ApplyTimingInputString(scope.GetIsolate(), "iterations", "rubbish", success);
EXPECT_FALSE(success);
}
TEST_F(AnimationTimingInputTest, TimingInputIterationDuration) {
V8TestingScope scope;
bool success;
EXPECT_EQ(
AnimationTimeDelta::FromSecondsD(1.1),
ApplyTimingInputNumber(scope.GetIsolate(), "duration", 1100, success)
.iteration_duration);
EXPECT_TRUE(success);
Timing timing =
ApplyTimingInputNumber(scope.GetIsolate(), "duration",
std::numeric_limits<double>::infinity(), success);
EXPECT_TRUE(success);
EXPECT_TRUE(timing.iteration_duration->is_max());
EXPECT_FALSE(
ApplyTimingInputString(scope.GetIsolate(), "duration", "auto", success)
.iteration_duration);
EXPECT_TRUE(success);
ApplyTimingInputString(scope.GetIsolate(), "duration", "1000", success);
EXPECT_FALSE(success);
ApplyTimingInputNumber(scope.GetIsolate(), "duration", -1000, success);
EXPECT_FALSE(success);
ApplyTimingInputString(scope.GetIsolate(), "duration", "-Infinity", success);
EXPECT_FALSE(success);
ApplyTimingInputString(scope.GetIsolate(), "duration", "NaN", success);
EXPECT_FALSE(success);
ApplyTimingInputString(scope.GetIsolate(), "duration", "rubbish", success);
EXPECT_FALSE(success);
}
TEST_F(AnimationTimingInputTest, TimingInputDirection) {
V8TestingScope scope;
Timing::PlaybackDirection default_playback_direction =
Timing::PlaybackDirection::NORMAL;
bool ignored_success;
EXPECT_EQ(Timing::PlaybackDirection::NORMAL,
ApplyTimingInputString(scope.GetIsolate(), "direction", "normal",
ignored_success)
.direction);
EXPECT_EQ(Timing::PlaybackDirection::REVERSE,
ApplyTimingInputString(scope.GetIsolate(), "direction", "reverse",
ignored_success)
.direction);
EXPECT_EQ(Timing::PlaybackDirection::ALTERNATE_NORMAL,
ApplyTimingInputString(scope.GetIsolate(), "direction", "alternate",
ignored_success)
.direction);
EXPECT_EQ(Timing::PlaybackDirection::ALTERNATE_REVERSE,
ApplyTimingInputString(scope.GetIsolate(), "direction",
"alternate-reverse", ignored_success)
.direction);
EXPECT_EQ(default_playback_direction,
ApplyTimingInputString(scope.GetIsolate(), "direction", "rubbish",
ignored_success)
.direction);
EXPECT_EQ(default_playback_direction,
ApplyTimingInputNumber(scope.GetIsolate(), "direction", 2,
ignored_success)
.direction);
}
TEST_F(AnimationTimingInputTest, TimingInputTimingFunction) {
V8TestingScope scope;
const scoped_refptr<TimingFunction> default_timing_function =
LinearTimingFunction::Shared();
bool success;
EXPECT_EQ(
*CubicBezierTimingFunction::Preset(
CubicBezierTimingFunction::EaseType::EASE),
*ApplyTimingInputString(scope.GetIsolate(), "easing", "ease", success)
.timing_function);
EXPECT_TRUE(success);
EXPECT_EQ(
*CubicBezierTimingFunction::Preset(
CubicBezierTimingFunction::EaseType::EASE_IN),
*ApplyTimingInputString(scope.GetIsolate(), "easing", "ease-in", success)
.timing_function);
EXPECT_TRUE(success);
EXPECT_EQ(
*CubicBezierTimingFunction::Preset(
CubicBezierTimingFunction::EaseType::EASE_OUT),
*ApplyTimingInputString(scope.GetIsolate(), "easing", "ease-out", success)
.timing_function);
EXPECT_TRUE(success);
EXPECT_EQ(*CubicBezierTimingFunction::Preset(
CubicBezierTimingFunction::EaseType::EASE_IN_OUT),
*ApplyTimingInputString(scope.GetIsolate(), "easing", "ease-in-out",
success)
.timing_function);
EXPECT_TRUE(success);
EXPECT_EQ(
*LinearTimingFunction::Shared(),
*ApplyTimingInputString(scope.GetIsolate(), "easing", "linear", success)
.timing_function);
EXPECT_TRUE(success);
EXPECT_EQ(
*StepsTimingFunction::Preset(StepsTimingFunction::StepPosition::START),
*ApplyTimingInputString(scope.GetIsolate(), "easing", "step-start",
success)
.timing_function);
EXPECT_TRUE(success);
EXPECT_EQ(
*StepsTimingFunction::Preset(StepsTimingFunction::StepPosition::END),
*ApplyTimingInputString(scope.GetIsolate(), "easing", "step-end", success)
.timing_function);
EXPECT_TRUE(success);
EXPECT_EQ(*CubicBezierTimingFunction::Create(1, 1, 0.3, 0.3),
*ApplyTimingInputString(scope.GetIsolate(), "easing",
"cubic-bezier(1, 1, 0.3, 0.3)", success)
.timing_function);
EXPECT_TRUE(success);
EXPECT_EQ(
*StepsTimingFunction::Create(3, StepsTimingFunction::StepPosition::START),
*ApplyTimingInputString(scope.GetIsolate(), "easing", "steps(3, start)",
success)
.timing_function);
EXPECT_TRUE(success);
EXPECT_EQ(
*StepsTimingFunction::Create(5, StepsTimingFunction::StepPosition::END),
*ApplyTimingInputString(scope.GetIsolate(), "easing", "steps(5, end)",
success)
.timing_function);
EXPECT_TRUE(success);
ApplyTimingInputString(scope.GetIsolate(), "easing", "", success);
EXPECT_FALSE(success);
ApplyTimingInputString(scope.GetIsolate(), "easing", "steps(5.6, end)",
success);
EXPECT_FALSE(success);
ApplyTimingInputString(scope.GetIsolate(), "easing",
"cubic-bezier(2, 2, 0.3, 0.3)", success);
EXPECT_FALSE(success);
ApplyTimingInputString(scope.GetIsolate(), "easing", "rubbish", success);
EXPECT_FALSE(success);
ApplyTimingInputNumber(scope.GetIsolate(), "easing", 2, success);
EXPECT_FALSE(success);
ApplyTimingInputString(scope.GetIsolate(), "easing", "initial", success);
EXPECT_FALSE(success);
}
TEST_F(AnimationTimingInputTest, TimingInputEmpty) {
DummyExceptionStateForTesting exception_state;
Timing control_timing;
UnrestrictedDoubleOrKeyframeEffectOptions timing_input =
UnrestrictedDoubleOrKeyframeEffectOptions::FromKeyframeEffectOptions(
KeyframeEffectOptions::Create());
Timing updated_timing =
TimingInput::Convert(timing_input, nullptr, exception_state);
EXPECT_FALSE(exception_state.HadException());
EXPECT_EQ(control_timing.start_delay, updated_timing.start_delay);
EXPECT_EQ(control_timing.fill_mode, updated_timing.fill_mode);
EXPECT_EQ(control_timing.iteration_start, updated_timing.iteration_start);
EXPECT_EQ(control_timing.iteration_count, updated_timing.iteration_count);
EXPECT_FALSE(updated_timing.iteration_duration);
EXPECT_EQ(control_timing.direction, updated_timing.direction);
EXPECT_EQ(*control_timing.timing_function, *updated_timing.timing_function);
}
TEST_F(AnimationTimingInputTest, TimingInputEmptyKeyframeAnimationOptions) {
DummyExceptionStateForTesting exception_state;
Timing control_timing;
UnrestrictedDoubleOrKeyframeAnimationOptions input_timing =
UnrestrictedDoubleOrKeyframeAnimationOptions::
FromKeyframeAnimationOptions(KeyframeAnimationOptions::Create());
Timing updated_timing =
TimingInput::Convert(input_timing, nullptr, exception_state);
EXPECT_FALSE(exception_state.HadException());
EXPECT_EQ(control_timing.start_delay, updated_timing.start_delay);
EXPECT_EQ(control_timing.fill_mode, updated_timing.fill_mode);
EXPECT_EQ(control_timing.iteration_start, updated_timing.iteration_start);
EXPECT_EQ(control_timing.iteration_count, updated_timing.iteration_count);
EXPECT_FALSE(updated_timing.iteration_duration);
EXPECT_EQ(control_timing.direction, updated_timing.direction);
EXPECT_EQ(*control_timing.timing_function, *updated_timing.timing_function);
}
} // namespace blink
| 43.212719 | 106 | 0.666227 | sarang-apps |
3ab3a9ccf58887f4ab68196cd4b1f5b8ba487aec | 294 | cpp | C++ | patterns/floyds_pattern.cpp | neerajsingh869/data-structures-and-algorithms | 96087e68fdce743f90f75228af1c7d111f6b92b7 | [
"MIT"
] | null | null | null | patterns/floyds_pattern.cpp | neerajsingh869/data-structures-and-algorithms | 96087e68fdce743f90f75228af1c7d111f6b92b7 | [
"MIT"
] | null | null | null | patterns/floyds_pattern.cpp | neerajsingh869/data-structures-and-algorithms | 96087e68fdce743f90f75228af1c7d111f6b92b7 | [
"MIT"
] | null | null | null | #include<iostream>
using namespace std;
int main(){
// Floyd's Pattern
int n;
cin>>n;
int count = 0;
for(int i=1; i<=n; i++){
for(int j=1; j<=i; j++){
cout<<count+1<<" ";
count = count + 1;
}
cout<<endl;
}
return 0;
} | 17.294118 | 32 | 0.431973 | neerajsingh869 |
3ab45abf91c927889ac85ae800ae6cf75c6e1dd8 | 124,497 | cpp | C++ | Source/WebKit/UIProcess/API/glib/WebKitSettings.cpp | ijsf/DeniseEmbeddableWebKit | 57dfc6783d60f8f59b7129874e60f84d8c8556c9 | [
"BSD-3-Clause"
] | null | null | null | Source/WebKit/UIProcess/API/glib/WebKitSettings.cpp | ijsf/DeniseEmbeddableWebKit | 57dfc6783d60f8f59b7129874e60f84d8c8556c9 | [
"BSD-3-Clause"
] | 9 | 2020-04-18T18:47:18.000Z | 2020-04-18T18:52:41.000Z | Source/WebKit/UIProcess/API/glib/WebKitSettings.cpp | ijsf/DeniseEmbeddableWebKit | 57dfc6783d60f8f59b7129874e60f84d8c8556c9 | [
"BSD-3-Clause"
] | null | null | null | /*
* Copyright (c) 2011 Motorola Mobility, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation and/or
* other materials provided with the distribution.
*
* Neither the name of Motorola Mobility, Inc. nor the names of its contributors may
* be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#include "WebKitSettings.h"
#include "WebKitEnumTypes.h"
#include "WebKitSettingsPrivate.h"
#include "WebPageProxy.h"
#include "WebPreferences.h"
#include <WebCore/UserAgent.h>
#include <glib/gi18n-lib.h>
#include <wtf/glib/WTFGType.h>
#include <wtf/text/CString.h>
#if PLATFORM(GTK)
#include "HardwareAccelerationManager.h"
#endif
#if PLATFORM(WAYLAND)
#include <WebCore/PlatformDisplay.h>
#endif
using namespace WebKit;
struct _WebKitSettingsPrivate {
_WebKitSettingsPrivate()
: preferences(WebPreferences::create(String(), "WebKit2.", "WebKit2."))
{
defaultFontFamily = preferences->standardFontFamily().utf8();
monospaceFontFamily = preferences->fixedFontFamily().utf8();
serifFontFamily = preferences->serifFontFamily().utf8();
sansSerifFontFamily = preferences->sansSerifFontFamily().utf8();
cursiveFontFamily = preferences->cursiveFontFamily().utf8();
fantasyFontFamily = preferences->fantasyFontFamily().utf8();
pictographFontFamily = preferences->pictographFontFamily().utf8();
defaultCharset = preferences->defaultTextEncodingName().utf8();
}
RefPtr<WebPreferences> preferences;
CString defaultFontFamily;
CString monospaceFontFamily;
CString serifFontFamily;
CString sansSerifFontFamily;
CString cursiveFontFamily;
CString fantasyFontFamily;
CString pictographFontFamily;
CString defaultCharset;
CString userAgent;
bool allowModalDialogs { false };
bool zoomTextOnly { false };
};
/**
* SECTION:WebKitSettings
* @short_description: Control the behaviour of a #WebKitWebView
*
* #WebKitSettings can be applied to a #WebKitWebView to control text charset,
* color, font sizes, printing mode, script support, loading of images and various
* other things on a #WebKitWebView. After creation, a #WebKitSettings object
* contains default settings.
*
* <informalexample><programlisting>
* /<!-- -->* Disable JavaScript. *<!-- -->/
* WebKitSettings *settings = webkit_web_view_group_get_settings (my_view_group);
* webkit_settings_set_enable_javascript (settings, FALSE);
*
* </programlisting></informalexample>
*/
WEBKIT_DEFINE_TYPE(WebKitSettings, webkit_settings, G_TYPE_OBJECT)
enum {
PROP_0,
PROP_ENABLE_JAVASCRIPT,
PROP_AUTO_LOAD_IMAGES,
PROP_LOAD_ICONS_IGNORING_IMAGE_LOAD_SETTING,
PROP_ENABLE_OFFLINE_WEB_APPLICATION_CACHE,
PROP_ENABLE_HTML5_LOCAL_STORAGE,
PROP_ENABLE_HTML5_DATABASE,
PROP_ENABLE_XSS_AUDITOR,
PROP_ENABLE_FRAME_FLATTENING,
PROP_ENABLE_PLUGINS,
PROP_ENABLE_JAVA,
PROP_JAVASCRIPT_CAN_OPEN_WINDOWS_AUTOMATICALLY,
PROP_ENABLE_HYPERLINK_AUDITING,
PROP_DEFAULT_FONT_FAMILY,
PROP_MONOSPACE_FONT_FAMILY,
PROP_SERIF_FONT_FAMILY,
PROP_SANS_SERIF_FONT_FAMILY,
PROP_CURSIVE_FONT_FAMILY,
PROP_FANTASY_FONT_FAMILY,
PROP_PICTOGRAPH_FONT_FAMILY,
PROP_DEFAULT_FONT_SIZE,
PROP_DEFAULT_MONOSPACE_FONT_SIZE,
PROP_MINIMUM_FONT_SIZE,
PROP_DEFAULT_CHARSET,
PROP_ENABLE_PRIVATE_BROWSING,
PROP_ENABLE_DEVELOPER_EXTRAS,
PROP_ENABLE_RESIZABLE_TEXT_AREAS,
PROP_ENABLE_TABS_TO_LINKS,
PROP_ENABLE_DNS_PREFETCHING,
PROP_ENABLE_CARET_BROWSING,
PROP_ENABLE_FULLSCREEN,
PROP_PRINT_BACKGROUNDS,
PROP_ENABLE_WEBAUDIO,
PROP_ENABLE_WEBGL,
PROP_ALLOW_MODAL_DIALOGS,
PROP_ZOOM_TEXT_ONLY,
PROP_JAVASCRIPT_CAN_ACCESS_CLIPBOARD,
PROP_MEDIA_PLAYBACK_REQUIRES_USER_GESTURE,
PROP_MEDIA_PLAYBACK_ALLOWS_INLINE,
PROP_DRAW_COMPOSITING_INDICATORS,
PROP_ENABLE_SITE_SPECIFIC_QUIRKS,
PROP_ENABLE_PAGE_CACHE,
PROP_USER_AGENT,
PROP_ENABLE_SMOOTH_SCROLLING,
PROP_ENABLE_ACCELERATED_2D_CANVAS,
PROP_ENABLE_WRITE_CONSOLE_MESSAGES_TO_STDOUT,
PROP_ENABLE_MEDIA_STREAM,
PROP_ENABLE_SPATIAL_NAVIGATION,
PROP_ENABLE_MEDIASOURCE,
PROP_ALLOW_FILE_ACCESS_FROM_FILE_URLS,
PROP_ALLOW_UNIVERSAL_ACCESS_FROM_FILE_URLS,
#if PLATFORM(GTK)
PROP_HARDWARE_ACCELERATION_POLICY,
#endif
};
static void webKitSettingsConstructed(GObject* object)
{
G_OBJECT_CLASS(webkit_settings_parent_class)->constructed(object);
WebPreferences* prefs = WEBKIT_SETTINGS(object)->priv->preferences.get();
prefs->setShouldRespectImageOrientation(true);
}
static void webKitSettingsSetProperty(GObject* object, guint propId, const GValue* value, GParamSpec* paramSpec)
{
WebKitSettings* settings = WEBKIT_SETTINGS(object);
switch (propId) {
case PROP_ENABLE_JAVASCRIPT:
webkit_settings_set_enable_javascript(settings, g_value_get_boolean(value));
break;
case PROP_AUTO_LOAD_IMAGES:
webkit_settings_set_auto_load_images(settings, g_value_get_boolean(value));
break;
case PROP_LOAD_ICONS_IGNORING_IMAGE_LOAD_SETTING:
webkit_settings_set_load_icons_ignoring_image_load_setting(settings, g_value_get_boolean(value));
break;
case PROP_ENABLE_OFFLINE_WEB_APPLICATION_CACHE:
webkit_settings_set_enable_offline_web_application_cache(settings, g_value_get_boolean(value));
break;
case PROP_ENABLE_HTML5_LOCAL_STORAGE:
webkit_settings_set_enable_html5_local_storage(settings, g_value_get_boolean(value));
break;
case PROP_ENABLE_HTML5_DATABASE:
webkit_settings_set_enable_html5_database(settings, g_value_get_boolean(value));
break;
case PROP_ENABLE_XSS_AUDITOR:
webkit_settings_set_enable_xss_auditor(settings, g_value_get_boolean(value));
break;
case PROP_ENABLE_FRAME_FLATTENING:
webkit_settings_set_enable_frame_flattening(settings, g_value_get_boolean(value));
break;
case PROP_ENABLE_PLUGINS:
webkit_settings_set_enable_plugins(settings, g_value_get_boolean(value));
break;
case PROP_ENABLE_JAVA:
webkit_settings_set_enable_java(settings, g_value_get_boolean(value));
break;
case PROP_JAVASCRIPT_CAN_OPEN_WINDOWS_AUTOMATICALLY:
webkit_settings_set_javascript_can_open_windows_automatically(settings, g_value_get_boolean(value));
break;
case PROP_ENABLE_HYPERLINK_AUDITING:
webkit_settings_set_enable_hyperlink_auditing(settings, g_value_get_boolean(value));
break;
case PROP_DEFAULT_FONT_FAMILY:
webkit_settings_set_default_font_family(settings, g_value_get_string(value));
break;
case PROP_MONOSPACE_FONT_FAMILY:
webkit_settings_set_monospace_font_family(settings, g_value_get_string(value));
break;
case PROP_SERIF_FONT_FAMILY:
webkit_settings_set_serif_font_family(settings, g_value_get_string(value));
break;
case PROP_SANS_SERIF_FONT_FAMILY:
webkit_settings_set_sans_serif_font_family(settings, g_value_get_string(value));
break;
case PROP_CURSIVE_FONT_FAMILY:
webkit_settings_set_cursive_font_family(settings, g_value_get_string(value));
break;
case PROP_FANTASY_FONT_FAMILY:
webkit_settings_set_fantasy_font_family(settings, g_value_get_string(value));
break;
case PROP_PICTOGRAPH_FONT_FAMILY:
webkit_settings_set_pictograph_font_family(settings, g_value_get_string(value));
break;
case PROP_DEFAULT_FONT_SIZE:
webkit_settings_set_default_font_size(settings, g_value_get_uint(value));
break;
case PROP_DEFAULT_MONOSPACE_FONT_SIZE:
webkit_settings_set_default_monospace_font_size(settings, g_value_get_uint(value));
break;
case PROP_MINIMUM_FONT_SIZE:
webkit_settings_set_minimum_font_size(settings, g_value_get_uint(value));
break;
case PROP_DEFAULT_CHARSET:
webkit_settings_set_default_charset(settings, g_value_get_string(value));
break;
case PROP_ENABLE_PRIVATE_BROWSING:
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
webkit_settings_set_enable_private_browsing(settings, g_value_get_boolean(value));
G_GNUC_END_IGNORE_DEPRECATIONS;
break;
case PROP_ENABLE_DEVELOPER_EXTRAS:
webkit_settings_set_enable_developer_extras(settings, g_value_get_boolean(value));
break;
case PROP_ENABLE_RESIZABLE_TEXT_AREAS:
webkit_settings_set_enable_resizable_text_areas(settings, g_value_get_boolean(value));
break;
case PROP_ENABLE_TABS_TO_LINKS:
webkit_settings_set_enable_tabs_to_links(settings, g_value_get_boolean(value));
break;
case PROP_ENABLE_DNS_PREFETCHING:
webkit_settings_set_enable_dns_prefetching(settings, g_value_get_boolean(value));
break;
case PROP_ENABLE_CARET_BROWSING:
webkit_settings_set_enable_caret_browsing(settings, g_value_get_boolean(value));
break;
case PROP_ENABLE_FULLSCREEN:
webkit_settings_set_enable_fullscreen(settings, g_value_get_boolean(value));
break;
case PROP_PRINT_BACKGROUNDS:
webkit_settings_set_print_backgrounds(settings, g_value_get_boolean(value));
break;
case PROP_ENABLE_WEBAUDIO:
webkit_settings_set_enable_webaudio(settings, g_value_get_boolean(value));
break;
case PROP_ENABLE_WEBGL:
webkit_settings_set_enable_webgl(settings, g_value_get_boolean(value));
break;
case PROP_ALLOW_MODAL_DIALOGS:
webkit_settings_set_allow_modal_dialogs(settings, g_value_get_boolean(value));
break;
case PROP_ZOOM_TEXT_ONLY:
webkit_settings_set_zoom_text_only(settings, g_value_get_boolean(value));
break;
case PROP_JAVASCRIPT_CAN_ACCESS_CLIPBOARD:
webkit_settings_set_javascript_can_access_clipboard(settings, g_value_get_boolean(value));
break;
case PROP_MEDIA_PLAYBACK_REQUIRES_USER_GESTURE:
webkit_settings_set_media_playback_requires_user_gesture(settings, g_value_get_boolean(value));
break;
case PROP_MEDIA_PLAYBACK_ALLOWS_INLINE:
webkit_settings_set_media_playback_allows_inline(settings, g_value_get_boolean(value));
break;
case PROP_DRAW_COMPOSITING_INDICATORS:
if (g_value_get_boolean(value))
webkit_settings_set_draw_compositing_indicators(settings, g_value_get_boolean(value));
else {
char* debugVisualsEnvironment = getenv("WEBKIT_SHOW_COMPOSITING_DEBUG_VISUALS");
bool showDebugVisuals = debugVisualsEnvironment && !strcmp(debugVisualsEnvironment, "1");
webkit_settings_set_draw_compositing_indicators(settings, showDebugVisuals);
}
break;
case PROP_ENABLE_SITE_SPECIFIC_QUIRKS:
webkit_settings_set_enable_site_specific_quirks(settings, g_value_get_boolean(value));
break;
case PROP_ENABLE_PAGE_CACHE:
webkit_settings_set_enable_page_cache(settings, g_value_get_boolean(value));
break;
case PROP_USER_AGENT:
webkit_settings_set_user_agent(settings, g_value_get_string(value));
break;
case PROP_ENABLE_SMOOTH_SCROLLING:
webkit_settings_set_enable_smooth_scrolling(settings, g_value_get_boolean(value));
break;
case PROP_ENABLE_ACCELERATED_2D_CANVAS:
webkit_settings_set_enable_accelerated_2d_canvas(settings, g_value_get_boolean(value));
break;
case PROP_ENABLE_WRITE_CONSOLE_MESSAGES_TO_STDOUT:
webkit_settings_set_enable_write_console_messages_to_stdout(settings, g_value_get_boolean(value));
break;
case PROP_ENABLE_MEDIA_STREAM:
webkit_settings_set_enable_media_stream(settings, g_value_get_boolean(value));
break;
case PROP_ENABLE_SPATIAL_NAVIGATION:
webkit_settings_set_enable_spatial_navigation(settings, g_value_get_boolean(value));
break;
case PROP_ENABLE_MEDIASOURCE:
webkit_settings_set_enable_mediasource(settings, g_value_get_boolean(value));
break;
case PROP_ALLOW_FILE_ACCESS_FROM_FILE_URLS:
webkit_settings_set_allow_file_access_from_file_urls(settings, g_value_get_boolean(value));
break;
case PROP_ALLOW_UNIVERSAL_ACCESS_FROM_FILE_URLS:
webkit_settings_set_allow_universal_access_from_file_urls(settings, g_value_get_boolean(value));
break;
#if PLATFORM(GTK)
case PROP_HARDWARE_ACCELERATION_POLICY:
webkit_settings_set_hardware_acceleration_policy(settings, static_cast<WebKitHardwareAccelerationPolicy>(g_value_get_enum(value)));
break;
#endif
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propId, paramSpec);
break;
}
}
static void webKitSettingsGetProperty(GObject* object, guint propId, GValue* value, GParamSpec* paramSpec)
{
WebKitSettings* settings = WEBKIT_SETTINGS(object);
switch (propId) {
case PROP_ENABLE_JAVASCRIPT:
g_value_set_boolean(value, webkit_settings_get_enable_javascript(settings));
break;
case PROP_AUTO_LOAD_IMAGES:
g_value_set_boolean(value, webkit_settings_get_auto_load_images(settings));
break;
case PROP_LOAD_ICONS_IGNORING_IMAGE_LOAD_SETTING:
g_value_set_boolean(value, webkit_settings_get_load_icons_ignoring_image_load_setting(settings));
break;
case PROP_ENABLE_OFFLINE_WEB_APPLICATION_CACHE:
g_value_set_boolean(value, webkit_settings_get_enable_offline_web_application_cache(settings));
break;
case PROP_ENABLE_HTML5_LOCAL_STORAGE:
g_value_set_boolean(value, webkit_settings_get_enable_html5_local_storage(settings));
break;
case PROP_ENABLE_HTML5_DATABASE:
g_value_set_boolean(value, webkit_settings_get_enable_html5_database(settings));
break;
case PROP_ENABLE_XSS_AUDITOR:
g_value_set_boolean(value, webkit_settings_get_enable_xss_auditor(settings));
break;
case PROP_ENABLE_FRAME_FLATTENING:
g_value_set_boolean(value, webkit_settings_get_enable_frame_flattening(settings));
break;
case PROP_ENABLE_PLUGINS:
g_value_set_boolean(value, webkit_settings_get_enable_plugins(settings));
break;
case PROP_ENABLE_JAVA:
g_value_set_boolean(value, webkit_settings_get_enable_java(settings));
break;
case PROP_JAVASCRIPT_CAN_OPEN_WINDOWS_AUTOMATICALLY:
g_value_set_boolean(value, webkit_settings_get_javascript_can_open_windows_automatically(settings));
break;
case PROP_ENABLE_HYPERLINK_AUDITING:
g_value_set_boolean(value, webkit_settings_get_enable_hyperlink_auditing(settings));
break;
case PROP_DEFAULT_FONT_FAMILY:
g_value_set_string(value, webkit_settings_get_default_font_family(settings));
break;
case PROP_MONOSPACE_FONT_FAMILY:
g_value_set_string(value, webkit_settings_get_monospace_font_family(settings));
break;
case PROP_SERIF_FONT_FAMILY:
g_value_set_string(value, webkit_settings_get_serif_font_family(settings));
break;
case PROP_SANS_SERIF_FONT_FAMILY:
g_value_set_string(value, webkit_settings_get_sans_serif_font_family(settings));
break;
case PROP_CURSIVE_FONT_FAMILY:
g_value_set_string(value, webkit_settings_get_cursive_font_family(settings));
break;
case PROP_FANTASY_FONT_FAMILY:
g_value_set_string(value, webkit_settings_get_fantasy_font_family(settings));
break;
case PROP_PICTOGRAPH_FONT_FAMILY:
g_value_set_string(value, webkit_settings_get_pictograph_font_family(settings));
break;
case PROP_DEFAULT_FONT_SIZE:
g_value_set_uint(value, webkit_settings_get_default_font_size(settings));
break;
case PROP_DEFAULT_MONOSPACE_FONT_SIZE:
g_value_set_uint(value, webkit_settings_get_default_monospace_font_size(settings));
break;
case PROP_MINIMUM_FONT_SIZE:
g_value_set_uint(value, webkit_settings_get_minimum_font_size(settings));
break;
case PROP_DEFAULT_CHARSET:
g_value_set_string(value, webkit_settings_get_default_charset(settings));
break;
case PROP_ENABLE_PRIVATE_BROWSING:
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
g_value_set_boolean(value, webkit_settings_get_enable_private_browsing(settings));
G_GNUC_END_IGNORE_DEPRECATIONS;
break;
case PROP_ENABLE_DEVELOPER_EXTRAS:
g_value_set_boolean(value, webkit_settings_get_enable_developer_extras(settings));
break;
case PROP_ENABLE_RESIZABLE_TEXT_AREAS:
g_value_set_boolean(value, webkit_settings_get_enable_resizable_text_areas(settings));
break;
case PROP_ENABLE_TABS_TO_LINKS:
g_value_set_boolean(value, webkit_settings_get_enable_tabs_to_links(settings));
break;
case PROP_ENABLE_DNS_PREFETCHING:
g_value_set_boolean(value, webkit_settings_get_enable_dns_prefetching(settings));
break;
case PROP_ENABLE_CARET_BROWSING:
g_value_set_boolean(value, webkit_settings_get_enable_caret_browsing(settings));
break;
case PROP_ENABLE_FULLSCREEN:
g_value_set_boolean(value, webkit_settings_get_enable_fullscreen(settings));
break;
case PROP_PRINT_BACKGROUNDS:
g_value_set_boolean(value, webkit_settings_get_print_backgrounds(settings));
break;
case PROP_ENABLE_WEBAUDIO:
g_value_set_boolean(value, webkit_settings_get_enable_webaudio(settings));
break;
case PROP_ENABLE_WEBGL:
g_value_set_boolean(value, webkit_settings_get_enable_webgl(settings));
break;
case PROP_ALLOW_MODAL_DIALOGS:
g_value_set_boolean(value, webkit_settings_get_allow_modal_dialogs(settings));
break;
case PROP_ZOOM_TEXT_ONLY:
g_value_set_boolean(value, webkit_settings_get_zoom_text_only(settings));
break;
case PROP_JAVASCRIPT_CAN_ACCESS_CLIPBOARD:
g_value_set_boolean(value, webkit_settings_get_javascript_can_access_clipboard(settings));
break;
case PROP_MEDIA_PLAYBACK_REQUIRES_USER_GESTURE:
g_value_set_boolean(value, webkit_settings_get_media_playback_requires_user_gesture(settings));
break;
case PROP_MEDIA_PLAYBACK_ALLOWS_INLINE:
g_value_set_boolean(value, webkit_settings_get_media_playback_allows_inline(settings));
break;
case PROP_DRAW_COMPOSITING_INDICATORS:
g_value_set_boolean(value, webkit_settings_get_draw_compositing_indicators(settings));
break;
case PROP_ENABLE_SITE_SPECIFIC_QUIRKS:
g_value_set_boolean(value, webkit_settings_get_enable_site_specific_quirks(settings));
break;
case PROP_ENABLE_PAGE_CACHE:
g_value_set_boolean(value, webkit_settings_get_enable_page_cache(settings));
break;
case PROP_USER_AGENT:
g_value_set_string(value, webkit_settings_get_user_agent(settings));
break;
case PROP_ENABLE_SMOOTH_SCROLLING:
g_value_set_boolean(value, webkit_settings_get_enable_smooth_scrolling(settings));
break;
case PROP_ENABLE_ACCELERATED_2D_CANVAS:
g_value_set_boolean(value, webkit_settings_get_enable_accelerated_2d_canvas(settings));
break;
case PROP_ENABLE_WRITE_CONSOLE_MESSAGES_TO_STDOUT:
g_value_set_boolean(value, webkit_settings_get_enable_write_console_messages_to_stdout(settings));
break;
case PROP_ENABLE_MEDIA_STREAM:
g_value_set_boolean(value, webkit_settings_get_enable_media_stream(settings));
break;
case PROP_ENABLE_SPATIAL_NAVIGATION:
g_value_set_boolean(value, webkit_settings_get_enable_spatial_navigation(settings));
break;
case PROP_ENABLE_MEDIASOURCE:
g_value_set_boolean(value, webkit_settings_get_enable_mediasource(settings));
break;
case PROP_ALLOW_FILE_ACCESS_FROM_FILE_URLS:
g_value_set_boolean(value, webkit_settings_get_allow_file_access_from_file_urls(settings));
break;
case PROP_ALLOW_UNIVERSAL_ACCESS_FROM_FILE_URLS:
g_value_set_boolean(value, webkit_settings_get_allow_universal_access_from_file_urls(settings));
break;
#if PLATFORM(GTK)
case PROP_HARDWARE_ACCELERATION_POLICY:
g_value_set_enum(value, webkit_settings_get_hardware_acceleration_policy(settings));
break;
#endif
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propId, paramSpec);
break;
}
}
static void webkit_settings_class_init(WebKitSettingsClass* klass)
{
GObjectClass* gObjectClass = G_OBJECT_CLASS(klass);
gObjectClass->constructed = webKitSettingsConstructed;
gObjectClass->set_property = webKitSettingsSetProperty;
gObjectClass->get_property = webKitSettingsGetProperty;
GParamFlags readWriteConstructParamFlags = static_cast<GParamFlags>(WEBKIT_PARAM_READWRITE | G_PARAM_CONSTRUCT);
/**
* WebKitSettings:enable-javascript:
*
* Determines whether or not JavaScript executes within a page.
*/
g_object_class_install_property(gObjectClass,
PROP_ENABLE_JAVASCRIPT,
g_param_spec_boolean("enable-javascript",
_("Enable JavaScript"),
_("Enable JavaScript."),
TRUE,
readWriteConstructParamFlags));
/**
* WebKitSettings:auto-load-images:
*
* Determines whether images should be automatically loaded or not.
* On devices where network bandwidth is of concern, it might be
* useful to turn this property off.
*/
g_object_class_install_property(gObjectClass,
PROP_AUTO_LOAD_IMAGES,
g_param_spec_boolean("auto-load-images",
_("Auto load images"),
_("Load images automatically."),
TRUE,
readWriteConstructParamFlags));
/**
* WebKitSettings:load-icons-ignoring-image-load-setting:
*
* Determines whether a site can load favicons irrespective
* of the value of #WebKitSettings:auto-load-images.
*/
g_object_class_install_property(gObjectClass,
PROP_LOAD_ICONS_IGNORING_IMAGE_LOAD_SETTING,
g_param_spec_boolean("load-icons-ignoring-image-load-setting",
_("Load icons ignoring image load setting"),
_("Whether to load site icons ignoring image load setting."),
FALSE,
readWriteConstructParamFlags));
/**
* WebKitSettings:enable-offline-web-application-cache:
*
* Whether to enable HTML5 offline web application cache support. Offline
* web application cache allows web applications to run even when
* the user is not connected to the network.
*
* HTML5 offline web application specification is available at
* http://dev.w3.org/html5/spec/offline.html.
*/
g_object_class_install_property(gObjectClass,
PROP_ENABLE_OFFLINE_WEB_APPLICATION_CACHE,
g_param_spec_boolean("enable-offline-web-application-cache",
_("Enable offline web application cache"),
_("Whether to enable offline web application cache."),
TRUE,
readWriteConstructParamFlags));
/**
* WebKitSettings:enable-html5-local-storage:
*
* Whether to enable HTML5 local storage support. Local storage provides
* simple synchronous storage access.
*
* HTML5 local storage specification is available at
* http://dev.w3.org/html5/webstorage/.
*/
g_object_class_install_property(gObjectClass,
PROP_ENABLE_HTML5_LOCAL_STORAGE,
g_param_spec_boolean("enable-html5-local-storage",
_("Enable HTML5 local storage"),
_("Whether to enable HTML5 Local Storage support."),
TRUE,
readWriteConstructParamFlags));
/**
* WebKitSettings:enable-html5-database:
*
* Whether to enable HTML5 client-side SQL database support. Client-side
* SQL database allows web pages to store structured data and be able to
* use SQL to manipulate that data asynchronously.
*
* HTML5 database specification is available at
* http://www.w3.org/TR/webdatabase/.
*/
g_object_class_install_property(gObjectClass,
PROP_ENABLE_HTML5_DATABASE,
g_param_spec_boolean("enable-html5-database",
_("Enable HTML5 database"),
_("Whether to enable HTML5 database support."),
TRUE,
readWriteConstructParamFlags));
/**
* WebKitSettings:enable-xss-auditor:
*
* Whether to enable the XSS auditor. This feature filters some kinds of
* reflective XSS attacks on vulnerable web sites.
*/
g_object_class_install_property(gObjectClass,
PROP_ENABLE_XSS_AUDITOR,
g_param_spec_boolean("enable-xss-auditor",
_("Enable XSS auditor"),
_("Whether to enable the XSS auditor."),
TRUE,
readWriteConstructParamFlags));
/**
* WebKitSettings:enable-frame-flattening:
*
* Whether to enable the frame flattening. With this setting each subframe is expanded
* to its contents, which will flatten all the frames to become one scrollable page.
* On touch devices scrollable subframes on a page can result in a confusing user experience.
*/
g_object_class_install_property(gObjectClass,
PROP_ENABLE_FRAME_FLATTENING,
g_param_spec_boolean("enable-frame-flattening",
_("Enable frame flattening"),
_("Whether to enable frame flattening."),
FALSE,
readWriteConstructParamFlags));
/**
* WebKitSettings:enable-plugins:
*
* Determines whether or not plugins on the page are enabled.
*/
g_object_class_install_property(gObjectClass,
PROP_ENABLE_PLUGINS,
g_param_spec_boolean("enable-plugins",
_("Enable plugins"),
_("Enable embedded plugin objects."),
TRUE,
readWriteConstructParamFlags));
/**
* WebKitSettings:enable-java:
*
* Determines whether or not Java is enabled on the page.
*/
g_object_class_install_property(gObjectClass,
PROP_ENABLE_JAVA,
g_param_spec_boolean("enable-java",
_("Enable Java"),
_("Whether Java support should be enabled."),
TRUE,
readWriteConstructParamFlags));
/**
* WebKitSettings:javascript-can-open-windows-automatically:
*
* Whether JavaScript can open popup windows automatically without user
* intervention.
*/
g_object_class_install_property(gObjectClass,
PROP_JAVASCRIPT_CAN_OPEN_WINDOWS_AUTOMATICALLY,
g_param_spec_boolean("javascript-can-open-windows-automatically",
_("JavaScript can open windows automatically"),
_("Whether JavaScript can open windows automatically."),
FALSE,
readWriteConstructParamFlags));
/**
* WebKitSettings:enable-hyperlink-auditing:
*
* Determines whether or not hyperlink auditing is enabled.
*
* The hyperlink auditing specification is available at
* http://www.whatwg.org/specs/web-apps/current-work/multipage/links.html#hyperlink-auditing.
*/
g_object_class_install_property(gObjectClass,
PROP_ENABLE_HYPERLINK_AUDITING,
g_param_spec_boolean("enable-hyperlink-auditing",
_("Enable hyperlink auditing"),
_("Whether <a ping> should be able to send pings."),
FALSE,
readWriteConstructParamFlags));
/**
* WebKitSettings:default-font-family:
*
* The font family to use as the default for content that does not specify a font.
*/
g_object_class_install_property(gObjectClass,
PROP_DEFAULT_FONT_FAMILY,
g_param_spec_string("default-font-family",
_("Default font family"),
_("The font family to use as the default for content that does not specify a font."),
"sans-serif",
readWriteConstructParamFlags));
/**
* WebKitSettings:monospace-font-family:
*
* The font family used as the default for content using a monospace font.
*
*/
g_object_class_install_property(gObjectClass,
PROP_MONOSPACE_FONT_FAMILY,
g_param_spec_string("monospace-font-family",
_("Monospace font family"),
_("The font family used as the default for content using monospace font."),
"monospace",
readWriteConstructParamFlags));
/**
* WebKitSettings:serif-font-family:
*
* The font family used as the default for content using a serif font.
*/
g_object_class_install_property(gObjectClass,
PROP_SERIF_FONT_FAMILY,
g_param_spec_string("serif-font-family",
_("Serif font family"),
_("The font family used as the default for content using serif font."),
"serif",
readWriteConstructParamFlags));
/**
* WebKitSettings:sans-serif-font-family:
*
* The font family used as the default for content using a sans-serif font.
*/
g_object_class_install_property(gObjectClass,
PROP_SANS_SERIF_FONT_FAMILY,
g_param_spec_string("sans-serif-font-family",
_("Sans-serif font family"),
_("The font family used as the default for content using sans-serif font."),
"sans-serif",
readWriteConstructParamFlags));
/**
* WebKitSettings:cursive-font-family:
*
* The font family used as the default for content using a cursive font.
*/
g_object_class_install_property(gObjectClass,
PROP_CURSIVE_FONT_FAMILY,
g_param_spec_string("cursive-font-family",
_("Cursive font family"),
_("The font family used as the default for content using cursive font."),
"serif",
readWriteConstructParamFlags));
/**
* WebKitSettings:fantasy-font-family:
*
* The font family used as the default for content using a fantasy font.
*/
g_object_class_install_property(gObjectClass,
PROP_FANTASY_FONT_FAMILY,
g_param_spec_string("fantasy-font-family",
_("Fantasy font family"),
_("The font family used as the default for content using fantasy font."),
"serif",
readWriteConstructParamFlags));
/**
* WebKitSettings:pictograph-font-family:
*
* The font family used as the default for content using a pictograph font.
*/
g_object_class_install_property(gObjectClass,
PROP_PICTOGRAPH_FONT_FAMILY,
g_param_spec_string("pictograph-font-family",
_("Pictograph font family"),
_("The font family used as the default for content using pictograph font."),
"serif",
readWriteConstructParamFlags));
/**
* WebKitSettings:default-font-size:
*
* The default font size in pixels to use for content displayed if
* no font size is specified.
*/
g_object_class_install_property(gObjectClass,
PROP_DEFAULT_FONT_SIZE,
g_param_spec_uint("default-font-size",
_("Default font size"),
_("The default font size used to display text."),
0, G_MAXUINT, 16,
readWriteConstructParamFlags));
/**
* WebKitSettings:default-monospace-font-size:
*
* The default font size in pixels to use for content displayed in
* monospace font if no font size is specified.
*/
g_object_class_install_property(gObjectClass,
PROP_DEFAULT_MONOSPACE_FONT_SIZE,
g_param_spec_uint("default-monospace-font-size",
_("Default monospace font size"),
_("The default font size used to display monospace text."),
0, G_MAXUINT, 13,
readWriteConstructParamFlags));
/**
* WebKitSettings:minimum-font-size:
*
* The minimum font size in points used to display text. This setting
* controls the absolute smallest size. Values other than 0 can
* potentially break page layouts.
*/
g_object_class_install_property(gObjectClass,
PROP_MINIMUM_FONT_SIZE,
g_param_spec_uint("minimum-font-size",
_("Minimum font size"),
_("The minimum font size used to display text."),
0, G_MAXUINT, 0,
readWriteConstructParamFlags));
/**
* WebKitSettings:default-charset:
*
* The default text charset used when interpreting content with an unspecified charset.
*/
g_object_class_install_property(gObjectClass,
PROP_DEFAULT_CHARSET,
g_param_spec_string("default-charset",
_("Default charset"),
_("The default text charset used when interpreting content with unspecified charset."),
"iso-8859-1",
readWriteConstructParamFlags));
/**
* WebKitSettings:enable-private-browsing:
*
* Determines whether or not private browsing is enabled. Private browsing
* will disable history, cache and form auto-fill for any pages visited.
*
* Deprecated: 2.16. Use #WebKitWebView:is-ephemeral or #WebKitWebsiteDataManager:is-ephemeral instead.
*/
g_object_class_install_property(gObjectClass,
PROP_ENABLE_PRIVATE_BROWSING,
g_param_spec_boolean("enable-private-browsing",
_("Enable private browsing"),
_("Whether to enable private browsing"),
FALSE,
readWriteConstructParamFlags));
/**
* WebKitSettings:enable-developer-extras:
*
* Determines whether or not developer tools, such as the Web Inspector, are enabled.
*/
g_object_class_install_property(gObjectClass,
PROP_ENABLE_DEVELOPER_EXTRAS,
g_param_spec_boolean("enable-developer-extras",
_("Enable developer extras"),
_("Whether to enable developer extras"),
FALSE,
readWriteConstructParamFlags));
/**
* WebKitSettings:enable-resizable-text-areas:
*
* Determines whether or not text areas can be resized.
*/
g_object_class_install_property(gObjectClass,
PROP_ENABLE_RESIZABLE_TEXT_AREAS,
g_param_spec_boolean("enable-resizable-text-areas",
_("Enable resizable text areas"),
_("Whether to enable resizable text areas"),
TRUE,
readWriteConstructParamFlags));
/**
* WebKitSettings:enable-tabs-to-links:
*
* Determines whether the tab key cycles through the elements on the page.
* When this setting is enabled, users will be able to focus the next element
* in the page by pressing the tab key. If the selected element is editable,
* then pressing tab key will insert the tab character.
*/
g_object_class_install_property(gObjectClass,
PROP_ENABLE_TABS_TO_LINKS,
g_param_spec_boolean("enable-tabs-to-links",
_("Enable tabs to links"),
_("Whether to enable tabs to links"),
TRUE,
readWriteConstructParamFlags));
/**
* WebKitSettings:enable-dns-prefetching:
*
* Determines whether or not to prefetch domain names. DNS prefetching attempts
* to resolve domain names before a user tries to follow a link.
*/
g_object_class_install_property(gObjectClass,
PROP_ENABLE_DNS_PREFETCHING,
g_param_spec_boolean("enable-dns-prefetching",
_("Enable DNS prefetching"),
_("Whether to enable DNS prefetching"),
FALSE,
readWriteConstructParamFlags));
/**
* WebKitSettings:enable-caret-browsing:
*
* Whether to enable accessibility enhanced keyboard navigation.
*/
g_object_class_install_property(gObjectClass,
PROP_ENABLE_CARET_BROWSING,
g_param_spec_boolean("enable-caret-browsing",
_("Enable Caret Browsing"),
_("Whether to enable accessibility enhanced keyboard navigation"),
FALSE,
readWriteConstructParamFlags));
/**
* WebKitSettings:enable-fullscreen:
*
* Whether to enable the Javascript Fullscreen API. The API
* allows any HTML element to request fullscreen display. See also
* the current draft of the spec:
* http://www.w3.org/TR/fullscreen/
*/
g_object_class_install_property(gObjectClass,
PROP_ENABLE_FULLSCREEN,
g_param_spec_boolean("enable-fullscreen",
_("Enable Fullscreen"),
_("Whether to enable the Javascript Fullscreen API"),
TRUE,
readWriteConstructParamFlags));
/**
* WebKitSettings:print-backgrounds:
*
* Whether background images should be drawn during printing.
*/
g_object_class_install_property(gObjectClass,
PROP_PRINT_BACKGROUNDS,
g_param_spec_boolean("print-backgrounds",
_("Print Backgrounds"),
_("Whether background images should be drawn during printing"),
TRUE,
readWriteConstructParamFlags));
/**
* WebKitSettings:enable-webaudio:
*
*
* Enable or disable support for WebAudio on pages. WebAudio is an
* experimental proposal for allowing web pages to generate Audio
* WAVE data from JavaScript. The standard is currently a
* work-in-progress by the W3C Audio Working Group.
*
* See also https://dvcs.w3.org/hg/audio/raw-file/tip/webaudio/specification.html
*/
g_object_class_install_property(gObjectClass,
PROP_ENABLE_WEBAUDIO,
g_param_spec_boolean("enable-webaudio",
_("Enable WebAudio"),
_("Whether WebAudio content should be handled"),
FALSE,
readWriteConstructParamFlags));
/**
* WebKitSettings:enable-webgl:
*
* Enable or disable support for WebGL on pages. WebGL is an experimental
* proposal for allowing web pages to use OpenGL ES-like calls directly. The
* standard is currently a work-in-progress by the Khronos Group.
*/
g_object_class_install_property(gObjectClass,
PROP_ENABLE_WEBGL,
g_param_spec_boolean("enable-webgl",
_("Enable WebGL"),
_("Whether WebGL content should be rendered"),
FALSE,
readWriteConstructParamFlags));
/**
* WebKitSettings:allow-modal-dialogs:
*
* Determine whether it's allowed to create and run modal dialogs
* from a #WebKitWebView through JavaScript with
* <function>window.showModalDialog</function>. If it's set to
* %FALSE, the associated #WebKitWebView won't be able to create
* new modal dialogs, so not even the #WebKitWebView::create
* signal will be emitted.
*/
g_object_class_install_property(gObjectClass,
PROP_ALLOW_MODAL_DIALOGS,
g_param_spec_boolean("allow-modal-dialogs",
_("Allow modal dialogs"),
_("Whether it is possible to create modal dialogs"),
FALSE,
readWriteConstructParamFlags));
/**
* WebKitSettings:zoom-text-only:
*
* Whether #WebKitWebView:zoom-level affects only the
* text of the page or all the contents. Other contents containing text
* like form controls will be also affected by zoom factor when
* this property is enabled.
*/
g_object_class_install_property(gObjectClass,
PROP_ZOOM_TEXT_ONLY,
g_param_spec_boolean("zoom-text-only",
_("Zoom Text Only"),
_("Whether zoom level of web view changes only the text size"),
FALSE,
readWriteConstructParamFlags));
/**
* WebKitSettings:javascript-can-access-clipboard:
*
* Whether JavaScript can access the clipboard. The default value is %FALSE. If
* set to %TRUE, document.execCommand() allows cut, copy and paste commands.
*
*/
g_object_class_install_property(gObjectClass,
PROP_JAVASCRIPT_CAN_ACCESS_CLIPBOARD,
g_param_spec_boolean("javascript-can-access-clipboard",
_("JavaScript can access clipboard"),
_("Whether JavaScript can access Clipboard"),
FALSE,
readWriteConstructParamFlags));
/**
* WebKitSettings:media-playback-requires-user-gesture:
*
* Whether a user gesture (such as clicking the play button)
* would be required to start media playback or load media. This is off
* by default, so media playback could start automatically.
* Setting it on requires a gesture by the user to start playback, or to
* load the media.
*/
g_object_class_install_property(gObjectClass,
PROP_MEDIA_PLAYBACK_REQUIRES_USER_GESTURE,
g_param_spec_boolean("media-playback-requires-user-gesture",
_("Media playback requires user gesture"),
_("Whether media playback requires user gesture"),
FALSE,
readWriteConstructParamFlags));
/**
* WebKitSettings:media-playback-allows-inline:
*
* Whether media playback is full-screen only or inline playback is allowed.
* This is %TRUE by default, so media playback can be inline. Setting it to
* %FALSE allows specifying that media playback should be always fullscreen.
*/
g_object_class_install_property(gObjectClass,
PROP_MEDIA_PLAYBACK_ALLOWS_INLINE,
g_param_spec_boolean("media-playback-allows-inline",
_("Media playback allows inline"),
_("Whether media playback allows inline"),
TRUE,
readWriteConstructParamFlags));
/**
* WebKitSettings:draw-compositing-indicators:
*
* Whether to draw compositing borders and repaint counters on layers drawn
* with accelerated compositing. This is useful for debugging issues related
* to web content that is composited with the GPU.
*/
g_object_class_install_property(gObjectClass,
PROP_DRAW_COMPOSITING_INDICATORS,
g_param_spec_boolean("draw-compositing-indicators",
_("Draw compositing indicators"),
_("Whether to draw compositing borders and repaint counters"),
FALSE,
readWriteConstructParamFlags));
/**
* WebKitSettings:enable-site-specific-quirks:
*
* Whether to turn on site-specific quirks. Turning this on will
* tell WebKit to use some site-specific workarounds for
* better web compatibility. For example, older versions of
* MediaWiki will incorrectly send to WebKit a CSS file with KHTML
* workarounds. By turning on site-specific quirks, WebKit will
* special-case this and other cases to make some specific sites work.
*/
g_object_class_install_property(
gObjectClass,
PROP_ENABLE_SITE_SPECIFIC_QUIRKS,
g_param_spec_boolean(
"enable-site-specific-quirks",
_("Enable Site Specific Quirks"),
_("Enables the site-specific compatibility workarounds"),
TRUE,
readWriteConstructParamFlags));
/**
* WebKitSettings:enable-page-cache:
*
* Enable or disable the page cache. Disabling the page cache is
* generally only useful for special circumstances like low-memory
* scenarios or special purpose applications like static HTML
* viewers. This setting only controls the Page Cache, this cache
* is different than the disk-based or memory-based traditional
* resource caches, its point is to make going back and forth
* between pages much faster. For details about the different types
* of caches and their purposes see:
* http://webkit.org/blog/427/webkit-page-cache-i-the-basics/
*/
g_object_class_install_property(gObjectClass,
PROP_ENABLE_PAGE_CACHE,
g_param_spec_boolean("enable-page-cache",
_("Enable page cache"),
_("Whether the page cache should be used"),
TRUE,
readWriteConstructParamFlags));
/**
* WebKitSettings:user-agent:
*
* The user-agent string used by WebKit. Unusual user-agent strings may cause web
* content to render incorrectly or fail to run, as many web pages are written to
* parse the user-agent strings of only the most popular browsers. Therefore, it's
* typically better to not completely override the standard user-agent, but to use
* webkit_settings_set_user_agent_with_application_details() instead.
*
* If this property is set to the empty string or %NULL, it will revert to the standard
* user-agent.
*/
g_object_class_install_property(gObjectClass,
PROP_USER_AGENT,
g_param_spec_string("user-agent",
_("User agent string"),
_("The user agent string"),
0, // A null string forces the standard user agent.
readWriteConstructParamFlags));
/**
* WebKitSettings:enable-smooth-scrolling:
*
* Enable or disable smooth scrolling.
*/
g_object_class_install_property(gObjectClass,
PROP_ENABLE_SMOOTH_SCROLLING,
g_param_spec_boolean("enable-smooth-scrolling",
_("Enable smooth scrolling"),
_("Whether to enable smooth scrolling"),
FALSE,
readWriteConstructParamFlags));
/**
* WebKitSettings:enable-accelerated-2d-canvas:
*
* Enable or disable accelerated 2D canvas. Accelerated 2D canvas is only available
* if WebKitGTK+ was compiled with a version of Cairo including the unstable CairoGL API.
* When accelerated 2D canvas is enabled, WebKit may render some 2D canvas content
* using hardware accelerated drawing operations.
*
* Since: 2.2
*/
g_object_class_install_property(gObjectClass,
PROP_ENABLE_ACCELERATED_2D_CANVAS,
g_param_spec_boolean("enable-accelerated-2d-canvas",
_("Enable accelerated 2D canvas"),
_("Whether to enable accelerated 2D canvas"),
FALSE,
readWriteConstructParamFlags));
/**
* WebKitSettings:enable-write-console-messages-to-stdout:
*
* Enable or disable writing console messages to stdout. These are messages
* sent to the console with console.log and related methods.
*
* Since: 2.2
*/
g_object_class_install_property(gObjectClass,
PROP_ENABLE_WRITE_CONSOLE_MESSAGES_TO_STDOUT,
g_param_spec_boolean("enable-write-console-messages-to-stdout",
_("Write console messages on stdout"),
_("Whether to write console messages on stdout"),
FALSE,
readWriteConstructParamFlags));
/**
* WebKitSettings:enable-media-stream:
*
* Enable or disable support for MediaStream on pages. MediaStream
* is an experimental proposal for allowing web pages to access
* audio and video devices for capture.
*
* See also http://dev.w3.org/2011/webrtc/editor/getusermedia.html
*
* Since: 2.4
*/
g_object_class_install_property(gObjectClass,
PROP_ENABLE_MEDIA_STREAM,
g_param_spec_boolean("enable-media-stream",
_("Enable MediaStream"),
_("Whether MediaStream content should be handled"),
FALSE,
readWriteConstructParamFlags));
/**
* WebKitSettings:enable-spatial-navigation:
*
* Whether to enable Spatial Navigation. This feature consists in the ability
* to navigate between focusable elements in a Web page, such as hyperlinks
* and form controls, by using Left, Right, Up and Down arrow keys.
* For example, if an user presses the Right key, heuristics determine whether
* there is an element they might be trying to reach towards the right, and if
* there are multiple elements, which element they probably wants.
*
* Since: 2.4
*/
g_object_class_install_property(gObjectClass,
PROP_ENABLE_SPATIAL_NAVIGATION,
g_param_spec_boolean("enable-spatial-navigation",
_("Enable Spatial Navigation"),
_("Whether to enable Spatial Navigation support."),
FALSE,
readWriteConstructParamFlags));
/**
* WebKitSettings:enable-mediasource:
*
* Enable or disable support for MediaSource on pages. MediaSource is an
* experimental proposal which extends HTMLMediaElement to allow
* JavaScript to generate media streams for playback. The standard is
* currently a work-in-progress by the W3C HTML Media Task Force.
*
* See also http://www.w3.org/TR/media-source/
*
* Since: 2.4
*/
g_object_class_install_property(gObjectClass,
PROP_ENABLE_MEDIASOURCE,
g_param_spec_boolean("enable-mediasource",
_("Enable MediaSource"),
_("Whether MediaSource should be enabled."),
FALSE,
readWriteConstructParamFlags));
/**
* WebKitSettings:allow-file-access-from-file-urls:
*
* Whether file access is allowed from file URLs. By default, when
* something is loaded in a #WebKitWebView using a file URI, cross
* origin requests to other file resources are not allowed. This
* setting allows you to change that behaviour, so that it would be
* possible to do a XMLHttpRequest of a local file, for example.
*
* Since: 2.10
*/
g_object_class_install_property(gObjectClass,
PROP_ALLOW_FILE_ACCESS_FROM_FILE_URLS,
g_param_spec_boolean("allow-file-access-from-file-urls",
_("Allow file access from file URLs"),
_("Whether file access is allowed from file URLs."),
FALSE,
readWriteConstructParamFlags));
/**
* WebKitSettings:allow-universal-access-from-file-urls:
*
* Whether or not JavaScript running in the context of a file scheme URL
* should be allowed to access content from any origin. By default, when
* something is loaded in a #WebKitWebView using a file scheme URL,
* access to the local file system and arbitrary local storage is not
* allowed. This setting allows you to change that behaviour, so that
* it would be possible to use local storage, for example.
*
* Since: 2.14
*/
g_object_class_install_property(gObjectClass,
PROP_ALLOW_UNIVERSAL_ACCESS_FROM_FILE_URLS,
g_param_spec_boolean("allow-universal-access-from-file-urls",
_("Allow universal access from the context of file scheme URLs"),
_("Whether or not universal access is allowed from the context of file scheme URLs"),
FALSE,
readWriteConstructParamFlags));
#if PLATFORM(GTK)
/**
* WebKitSettings:hardware-acceleration-policy:
*
* The #WebKitHardwareAccelerationPolicy to decide how to enable and disable
* hardware acceleration. The default value %WEBKIT_HARDWARE_ACCELERATION_POLICY_ON_DEMAND
* enables the hardware acceleration when the web contents request it, disabling it again
* when no longer needed. It's possible to enforce hardware acceleration to be always enabled
* by using %WEBKIT_HARDWARE_ACCELERATION_POLICY_ALWAYS. And it's also possible to disable it
* completely using %WEBKIT_HARDWARE_ACCELERATION_POLICY_NEVER. Note that disabling hardware
* acceleration might cause some websites to not render correctly or consume more CPU.
*
* Note that changing this setting might not be possible if hardware acceleration is not
* supported by the hardware or the system. In that case you can get the value to know the
* actual policy being used, but changing the setting will not have any effect.
*
* Since: 2.16
*/
g_object_class_install_property(gObjectClass,
PROP_HARDWARE_ACCELERATION_POLICY,
g_param_spec_enum("hardware-acceleration-policy",
_("Hardware Acceleration Policy"),
_("The policy to decide how to enable and disable hardware acceleration"),
WEBKIT_TYPE_HARDWARE_ACCELERATION_POLICY,
WEBKIT_HARDWARE_ACCELERATION_POLICY_ON_DEMAND,
readWriteConstructParamFlags));
#endif // PLATFOTM(GTK)
}
WebPreferences* webkitSettingsGetPreferences(WebKitSettings* settings)
{
return settings->priv->preferences.get();
}
/**
* webkit_settings_new:
*
* Creates a new #WebKitSettings instance with default values. It must
* be manually attached to a #WebKitWebView.
* See also webkit_settings_new_with_settings().
*
* Returns: a new #WebKitSettings instance.
*/
WebKitSettings* webkit_settings_new()
{
return WEBKIT_SETTINGS(g_object_new(WEBKIT_TYPE_SETTINGS, NULL));
}
/**
* webkit_settings_new_with_settings:
* @first_setting_name: name of first setting to set
* @...: value of first setting, followed by more settings,
* %NULL-terminated
*
* Creates a new #WebKitSettings instance with the given settings. It must
* be manually attached to a #WebKitWebView.
*
* Returns: a new #WebKitSettings instance.
*/
WebKitSettings* webkit_settings_new_with_settings(const gchar* firstSettingName, ...)
{
va_list args;
va_start(args, firstSettingName);
WebKitSettings* settings = WEBKIT_SETTINGS(g_object_new_valist(WEBKIT_TYPE_SETTINGS, firstSettingName, args));
va_end(args);
return settings;
}
/**
* webkit_settings_get_enable_javascript:
* @settings: a #WebKitSettings
*
* Get the #WebKitSettings:enable-javascript property.
*
* Returns: %TRUE If JavaScript is enabled or %FALSE otherwise.
*/
gboolean webkit_settings_get_enable_javascript(WebKitSettings* settings)
{
g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE);
return settings->priv->preferences->javaScriptEnabled();
}
/**
* webkit_settings_set_enable_javascript:
* @settings: a #WebKitSettings
* @enabled: Value to be set
*
* Set the #WebKitSettings:enable-javascript property.
*/
void webkit_settings_set_enable_javascript(WebKitSettings* settings, gboolean enabled)
{
g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
WebKitSettingsPrivate* priv = settings->priv;
bool currentValue = priv->preferences->javaScriptEnabled();
if (currentValue == enabled)
return;
priv->preferences->setJavaScriptEnabled(enabled);
g_object_notify(G_OBJECT(settings), "enable-javascript");
}
/**
* webkit_settings_get_auto_load_images:
* @settings: a #WebKitSettings
*
* Get the #WebKitSettings:auto-load-images property.
*
* Returns: %TRUE If auto loading of images is enabled or %FALSE otherwise.
*/
gboolean webkit_settings_get_auto_load_images(WebKitSettings* settings)
{
g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE);
return settings->priv->preferences->loadsImagesAutomatically();
}
/**
* webkit_settings_set_auto_load_images:
* @settings: a #WebKitSettings
* @enabled: Value to be set
*
* Set the #WebKitSettings:auto-load-images property.
*/
void webkit_settings_set_auto_load_images(WebKitSettings* settings, gboolean enabled)
{
g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
WebKitSettingsPrivate* priv = settings->priv;
bool currentValue = priv->preferences->loadsImagesAutomatically();
if (currentValue == enabled)
return;
priv->preferences->setLoadsImagesAutomatically(enabled);
g_object_notify(G_OBJECT(settings), "auto-load-images");
}
/**
* webkit_settings_get_load_icons_ignoring_image_load_setting:
* @settings: a #WebKitSettings
*
* Get the #WebKitSettings:load-icons-ignoring-image-load-setting property.
*
* Returns: %TRUE If site icon can be loaded irrespective of image loading preference or %FALSE otherwise.
*/
gboolean webkit_settings_get_load_icons_ignoring_image_load_setting(WebKitSettings* settings)
{
g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE);
return settings->priv->preferences->loadsSiteIconsIgnoringImageLoadingPreference();
}
/**
* webkit_settings_set_load_icons_ignoring_image_load_setting:
* @settings: a #WebKitSettings
* @enabled: Value to be set
*
* Set the #WebKitSettings:load-icons-ignoring-image-load-setting property.
*/
void webkit_settings_set_load_icons_ignoring_image_load_setting(WebKitSettings* settings, gboolean enabled)
{
g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
WebKitSettingsPrivate* priv = settings->priv;
bool currentValue = priv->preferences->loadsSiteIconsIgnoringImageLoadingPreference();
if (currentValue == enabled)
return;
priv->preferences->setLoadsSiteIconsIgnoringImageLoadingPreference(enabled);
g_object_notify(G_OBJECT(settings), "load-icons-ignoring-image-load-setting");
}
/**
* webkit_settings_get_enable_offline_web_application_cache:
* @settings: a #WebKitSettings
*
* Get the #WebKitSettings:enable-offline-web-application-cache property.
*
* Returns: %TRUE If HTML5 offline web application cache support is enabled or %FALSE otherwise.
*/
gboolean webkit_settings_get_enable_offline_web_application_cache(WebKitSettings* settings)
{
g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE);
return settings->priv->preferences->offlineWebApplicationCacheEnabled();
}
/**
* webkit_settings_set_enable_offline_web_application_cache:
* @settings: a #WebKitSettings
* @enabled: Value to be set
*
* Set the #WebKitSettings:enable-offline-web-application-cache property.
*/
void webkit_settings_set_enable_offline_web_application_cache(WebKitSettings* settings, gboolean enabled)
{
g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
WebKitSettingsPrivate* priv = settings->priv;
bool currentValue = priv->preferences->offlineWebApplicationCacheEnabled();
if (currentValue == enabled)
return;
priv->preferences->setOfflineWebApplicationCacheEnabled(enabled);
g_object_notify(G_OBJECT(settings), "enable-offline-web-application-cache");
}
/**
* webkit_settings_get_enable_html5_local_storage:
* @settings: a #WebKitSettings
*
* Get the #WebKitSettings:enable-html5-local-storage property.
*
* Returns: %TRUE If HTML5 local storage support is enabled or %FALSE otherwise.
*/
gboolean webkit_settings_get_enable_html5_local_storage(WebKitSettings* settings)
{
g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE);
return settings->priv->preferences->localStorageEnabled();
}
/**
* webkit_settings_set_enable_html5_local_storage:
* @settings: a #WebKitSettings
* @enabled: Value to be set
*
* Set the #WebKitSettings:enable-html5-local-storage property.
*/
void webkit_settings_set_enable_html5_local_storage(WebKitSettings* settings, gboolean enabled)
{
g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
WebKitSettingsPrivate* priv = settings->priv;
bool currentValue = priv->preferences->localStorageEnabled();
if (currentValue == enabled)
return;
priv->preferences->setLocalStorageEnabled(enabled);
g_object_notify(G_OBJECT(settings), "enable-html5-local-storage");
}
/**
* webkit_settings_get_enable_html5_database:
* @settings: a #WebKitSettings
*
* Get the #WebKitSettings:enable-html5-database property.
*
* Returns: %TRUE If HTML5 database support is enabled or %FALSE otherwise.
*/
gboolean webkit_settings_get_enable_html5_database(WebKitSettings* settings)
{
g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE);
return settings->priv->preferences->databasesEnabled();
}
/**
* webkit_settings_set_enable_html5_database:
* @settings: a #WebKitSettings
* @enabled: Value to be set
*
* Set the #WebKitSettings:enable-html5-database property.
*/
void webkit_settings_set_enable_html5_database(WebKitSettings* settings, gboolean enabled)
{
g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
WebKitSettingsPrivate* priv = settings->priv;
bool currentValue = priv->preferences->databasesEnabled();
if (currentValue == enabled)
return;
priv->preferences->setDatabasesEnabled(enabled);
g_object_notify(G_OBJECT(settings), "enable-html5-database");
}
/**
* webkit_settings_get_enable_xss_auditor:
* @settings: a #WebKitSettings
*
* Get the #WebKitSettings:enable-xss-auditor property.
*
* Returns: %TRUE If XSS auditing is enabled or %FALSE otherwise.
*/
gboolean webkit_settings_get_enable_xss_auditor(WebKitSettings* settings)
{
g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE);
return settings->priv->preferences->xssAuditorEnabled();
}
/**
* webkit_settings_set_enable_xss_auditor:
* @settings: a #WebKitSettings
* @enabled: Value to be set
*
* Set the #WebKitSettings:enable-xss-auditor property.
*/
void webkit_settings_set_enable_xss_auditor(WebKitSettings* settings, gboolean enabled)
{
g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
WebKitSettingsPrivate* priv = settings->priv;
bool currentValue = priv->preferences->xssAuditorEnabled();
if (currentValue == enabled)
return;
priv->preferences->setXSSAuditorEnabled(enabled);
g_object_notify(G_OBJECT(settings), "enable-xss-auditor");
}
/**
* webkit_settings_get_enable_frame_flattening:
* @settings: a #WebKitSettings
*
* Get the #WebKitSettings:enable-frame-flattening property.
*
* Returns: %TRUE If frame flattening is enabled or %FALSE otherwise.
*
**/
gboolean webkit_settings_get_enable_frame_flattening(WebKitSettings* settings)
{
g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE);
// FIXME: Expose more frame flattening values.
return settings->priv->preferences->frameFlattening() != WebCore::FrameFlatteningDisabled;
}
/**
* webkit_settings_set_enable_frame_flattening:
* @settings: a #WebKitSettings
* @enabled: Value to be set
*
* Set the #WebKitSettings:enable-frame-flattening property.
*/
void webkit_settings_set_enable_frame_flattening(WebKitSettings* settings, gboolean enabled)
{
g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
WebKitSettingsPrivate* priv = settings->priv;
bool currentValue = priv->preferences->frameFlattening() != WebCore::FrameFlatteningDisabled;
if (currentValue == enabled)
return;
// FIXME: Expose more frame flattening values.
priv->preferences->setFrameFlattening(enabled ? WebCore::FrameFlatteningFullyEnabled : WebCore::FrameFlatteningDisabled);
g_object_notify(G_OBJECT(settings), "enable-frame-flattening");
}
/**
* webkit_settings_get_enable_plugins:
* @settings: a #WebKitSettings
*
* Get the #WebKitSettings:enable-plugins property.
*
* Returns: %TRUE If plugins are enabled or %FALSE otherwise.
*/
gboolean webkit_settings_get_enable_plugins(WebKitSettings* settings)
{
g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE);
return settings->priv->preferences->pluginsEnabled();
}
/**
* webkit_settings_set_enable_plugins:
* @settings: a #WebKitSettings
* @enabled: Value to be set
*
* Set the #WebKitSettings:enable-plugins property.
*/
void webkit_settings_set_enable_plugins(WebKitSettings* settings, gboolean enabled)
{
g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
WebKitSettingsPrivate* priv = settings->priv;
bool currentValue = priv->preferences->pluginsEnabled();
if (currentValue == enabled)
return;
priv->preferences->setPluginsEnabled(enabled);
g_object_notify(G_OBJECT(settings), "enable-plugins");
}
/**
* webkit_settings_get_enable_java:
* @settings: a #WebKitSettings
*
* Get the #WebKitSettings:enable-java property.
*
* Returns: %TRUE If Java is enabled or %FALSE otherwise.
*/
gboolean webkit_settings_get_enable_java(WebKitSettings* settings)
{
g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE);
return settings->priv->preferences->javaEnabled();
}
/**
* webkit_settings_set_enable_java:
* @settings: a #WebKitSettings
* @enabled: Value to be set
*
* Set the #WebKitSettings:enable-java property.
*/
void webkit_settings_set_enable_java(WebKitSettings* settings, gboolean enabled)
{
g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
WebKitSettingsPrivate* priv = settings->priv;
bool currentValue = priv->preferences->javaEnabled();
if (currentValue == enabled)
return;
priv->preferences->setJavaEnabled(enabled);
g_object_notify(G_OBJECT(settings), "enable-java");
}
/**
* webkit_settings_get_javascript_can_open_windows_automatically:
* @settings: a #WebKitSettings
*
* Get the #WebKitSettings:javascript-can-open-windows-automatically property.
*
* Returns: %TRUE If JavaScript can open window automatically or %FALSE otherwise.
*/
gboolean webkit_settings_get_javascript_can_open_windows_automatically(WebKitSettings* settings)
{
g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE);
return settings->priv->preferences->javaScriptCanOpenWindowsAutomatically();
}
/**
* webkit_settings_set_javascript_can_open_windows_automatically:
* @settings: a #WebKitSettings
* @enabled: Value to be set
*
* Set the #WebKitSettings:javascript-can-open-windows-automatically property.
*/
void webkit_settings_set_javascript_can_open_windows_automatically(WebKitSettings* settings, gboolean enabled)
{
g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
WebKitSettingsPrivate* priv = settings->priv;
bool currentValue = priv->preferences->javaScriptCanOpenWindowsAutomatically();
if (currentValue == enabled)
return;
priv->preferences->setJavaScriptCanOpenWindowsAutomatically(enabled);
g_object_notify(G_OBJECT(settings), "javascript-can-open-windows-automatically");
}
/**
* webkit_settings_get_enable_hyperlink_auditing:
* @settings: a #WebKitSettings
*
* Get the #WebKitSettings:enable-hyperlink-auditing property.
*
* Returns: %TRUE If hyper link auditing is enabled or %FALSE otherwise.
*/
gboolean webkit_settings_get_enable_hyperlink_auditing(WebKitSettings* settings)
{
g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE);
return settings->priv->preferences->hyperlinkAuditingEnabled();
}
/**
* webkit_settings_set_enable_hyperlink_auditing:
* @settings: a #WebKitSettings
* @enabled: Value to be set
*
* Set the #WebKitSettings:enable-hyperlink-auditing property.
*/
void webkit_settings_set_enable_hyperlink_auditing(WebKitSettings* settings, gboolean enabled)
{
g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
WebKitSettingsPrivate* priv = settings->priv;
bool currentValue = priv->preferences->hyperlinkAuditingEnabled();
if (currentValue == enabled)
return;
priv->preferences->setHyperlinkAuditingEnabled(enabled);
g_object_notify(G_OBJECT(settings), "enable-hyperlink-auditing");
}
/**
* webkit_web_settings_get_default_font_family:
* @settings: a #WebKitSettings
*
* Gets the #WebKitSettings:default-font-family property.
*
* Returns: The default font family used to display content that does not specify a font.
*/
const gchar* webkit_settings_get_default_font_family(WebKitSettings* settings)
{
g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), 0);
return settings->priv->defaultFontFamily.data();
}
/**
* webkit_settings_set_default_font_family:
* @settings: a #WebKitSettings
* @default_font_family: the new default font family
*
* Set the #WebKitSettings:default-font-family property.
*/
void webkit_settings_set_default_font_family(WebKitSettings* settings, const gchar* defaultFontFamily)
{
g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
g_return_if_fail(defaultFontFamily);
WebKitSettingsPrivate* priv = settings->priv;
if (!g_strcmp0(priv->defaultFontFamily.data(), defaultFontFamily))
return;
String standardFontFamily = String::fromUTF8(defaultFontFamily);
priv->preferences->setStandardFontFamily(standardFontFamily);
priv->defaultFontFamily = standardFontFamily.utf8();
g_object_notify(G_OBJECT(settings), "default-font-family");
}
/**
* webkit_settings_get_monospace_font_family:
* @settings: a #WebKitSettings
*
* Gets the #WebKitSettings:monospace-font-family property.
*
* Returns: Default font family used to display content marked with monospace font.
*/
const gchar* webkit_settings_get_monospace_font_family(WebKitSettings* settings)
{
g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), 0);
return settings->priv->monospaceFontFamily.data();
}
/**
* webkit_settings_set_monospace_font_family:
* @settings: a #WebKitSettings
* @monospace_font_family: the new default monospace font family
*
* Set the #WebKitSettings:monospace-font-family property.
*/
void webkit_settings_set_monospace_font_family(WebKitSettings* settings, const gchar* monospaceFontFamily)
{
g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
g_return_if_fail(monospaceFontFamily);
WebKitSettingsPrivate* priv = settings->priv;
if (!g_strcmp0(priv->monospaceFontFamily.data(), monospaceFontFamily))
return;
String fixedFontFamily = String::fromUTF8(monospaceFontFamily);
priv->preferences->setFixedFontFamily(fixedFontFamily);
priv->monospaceFontFamily = fixedFontFamily.utf8();
g_object_notify(G_OBJECT(settings), "monospace-font-family");
}
/**
* webkit_settings_get_serif_font_family:
* @settings: a #WebKitSettings
*
* Gets the #WebKitSettings:serif-font-family property.
*
* Returns: The default font family used to display content marked with serif font.
*/
const gchar* webkit_settings_get_serif_font_family(WebKitSettings* settings)
{
g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), 0);
return settings->priv->serifFontFamily.data();
}
/**
* webkit_settings_set_serif_font_family:
* @settings: a #WebKitSettings
* @serif_font_family: the new default serif font family
*
* Set the #WebKitSettings:serif-font-family property.
*/
void webkit_settings_set_serif_font_family(WebKitSettings* settings, const gchar* serifFontFamily)
{
g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
g_return_if_fail(serifFontFamily);
WebKitSettingsPrivate* priv = settings->priv;
if (!g_strcmp0(priv->serifFontFamily.data(), serifFontFamily))
return;
String serifFontFamilyString = String::fromUTF8(serifFontFamily);
priv->preferences->setSerifFontFamily(serifFontFamilyString);
priv->serifFontFamily = serifFontFamilyString.utf8();
g_object_notify(G_OBJECT(settings), "serif-font-family");
}
/**
* webkit_settings_get_sans_serif_font_family:
* @settings: a #WebKitSettings
*
* Gets the #WebKitSettings:sans-serif-font-family property.
*
* Returns: The default font family used to display content marked with sans-serif font.
*/
const gchar* webkit_settings_get_sans_serif_font_family(WebKitSettings* settings)
{
g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), 0);
return settings->priv->sansSerifFontFamily.data();
}
/**
* webkit_settings_set_sans_serif_font_family:
* @settings: a #WebKitSettings
* @sans_serif_font_family: the new default sans-serif font family
*
* Set the #WebKitSettings:sans-serif-font-family property.
*/
void webkit_settings_set_sans_serif_font_family(WebKitSettings* settings, const gchar* sansSerifFontFamily)
{
g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
g_return_if_fail(sansSerifFontFamily);
WebKitSettingsPrivate* priv = settings->priv;
if (!g_strcmp0(priv->sansSerifFontFamily.data(), sansSerifFontFamily))
return;
String sansSerifFontFamilyString = String::fromUTF8(sansSerifFontFamily);
priv->preferences->setSansSerifFontFamily(sansSerifFontFamilyString);
priv->sansSerifFontFamily = sansSerifFontFamilyString.utf8();
g_object_notify(G_OBJECT(settings), "sans-serif-font-family");
}
/**
* webkit_settings_get_cursive_font_family:
* @settings: a #WebKitSettings
*
* Gets the #WebKitSettings:cursive-font-family property.
*
* Returns: The default font family used to display content marked with cursive font.
*/
const gchar* webkit_settings_get_cursive_font_family(WebKitSettings* settings)
{
g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), 0);
return settings->priv->cursiveFontFamily.data();
}
/**
* webkit_settings_set_cursive_font_family:
* @settings: a #WebKitSettings
* @cursive_font_family: the new default cursive font family
*
* Set the #WebKitSettings:cursive-font-family property.
*/
void webkit_settings_set_cursive_font_family(WebKitSettings* settings, const gchar* cursiveFontFamily)
{
g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
g_return_if_fail(cursiveFontFamily);
WebKitSettingsPrivate* priv = settings->priv;
if (!g_strcmp0(priv->cursiveFontFamily.data(), cursiveFontFamily))
return;
String cursiveFontFamilyString = String::fromUTF8(cursiveFontFamily);
priv->preferences->setCursiveFontFamily(cursiveFontFamilyString);
priv->cursiveFontFamily = cursiveFontFamilyString.utf8();
g_object_notify(G_OBJECT(settings), "cursive-font-family");
}
/**
* webkit_settings_get_fantasy_font_family:
* @settings: a #WebKitSettings
*
* Gets the #WebKitSettings:fantasy-font-family property.
*
* Returns: The default font family used to display content marked with fantasy font.
*/
const gchar* webkit_settings_get_fantasy_font_family(WebKitSettings* settings)
{
g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), 0);
return settings->priv->fantasyFontFamily.data();
}
/**
* webkit_settings_set_fantasy_font_family:
* @settings: a #WebKitSettings
* @fantasy_font_family: the new default fantasy font family
*
* Set the #WebKitSettings:fantasy-font-family property.
*/
void webkit_settings_set_fantasy_font_family(WebKitSettings* settings, const gchar* fantasyFontFamily)
{
g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
g_return_if_fail(fantasyFontFamily);
WebKitSettingsPrivate* priv = settings->priv;
if (!g_strcmp0(priv->fantasyFontFamily.data(), fantasyFontFamily))
return;
String fantasyFontFamilyString = String::fromUTF8(fantasyFontFamily);
priv->preferences->setFantasyFontFamily(fantasyFontFamilyString);
priv->fantasyFontFamily = fantasyFontFamilyString.utf8();
g_object_notify(G_OBJECT(settings), "fantasy-font-family");
}
/**
* webkit_settings_get_pictograph_font_family:
* @settings: a #WebKitSettings
*
* Gets the #WebKitSettings:pictograph-font-family property.
*
* Returns: The default font family used to display content marked with pictograph font.
*/
const gchar* webkit_settings_get_pictograph_font_family(WebKitSettings* settings)
{
g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), 0);
return settings->priv->pictographFontFamily.data();
}
/**
* webkit_settings_set_pictograph_font_family:
* @settings: a #WebKitSettings
* @pictograph_font_family: the new default pictograph font family
*
* Set the #WebKitSettings:pictograph-font-family property.
*/
void webkit_settings_set_pictograph_font_family(WebKitSettings* settings, const gchar* pictographFontFamily)
{
g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
g_return_if_fail(pictographFontFamily);
WebKitSettingsPrivate* priv = settings->priv;
if (!g_strcmp0(priv->pictographFontFamily.data(), pictographFontFamily))
return;
String pictographFontFamilyString = String::fromUTF8(pictographFontFamily);
priv->preferences->setPictographFontFamily(pictographFontFamilyString);
priv->pictographFontFamily = pictographFontFamilyString.utf8();
g_object_notify(G_OBJECT(settings), "pictograph-font-family");
}
/**
* webkit_settings_get_default_font_size:
* @settings: a #WebKitSettings
*
* Gets the #WebKitSettings:default-font-size property.
*
* Returns: The default font size.
*/
guint32 webkit_settings_get_default_font_size(WebKitSettings* settings)
{
g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), 0);
return settings->priv->preferences->defaultFontSize();
}
/**
* webkit_settings_set_default_font_size:
* @settings: a #WebKitSettings
* @font_size: default font size to be set in pixels
*
* Set the #WebKitSettings:default-font-size property.
*/
void webkit_settings_set_default_font_size(WebKitSettings* settings, guint32 fontSize)
{
g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
WebKitSettingsPrivate* priv = settings->priv;
uint32_t currentSize = priv->preferences->defaultFontSize();
if (currentSize == fontSize)
return;
priv->preferences->setDefaultFontSize(fontSize);
g_object_notify(G_OBJECT(settings), "default-font-size");
}
/**
* webkit_settings_get_default_monospace_font_size:
* @settings: a #WebKitSettings
*
* Gets the #WebKitSettings:default-monospace-font-size property.
*
* Returns: Default monospace font size.
*/
guint32 webkit_settings_get_default_monospace_font_size(WebKitSettings* settings)
{
g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), 0);
return settings->priv->preferences->defaultFixedFontSize();
}
/**
* webkit_settings_set_default_monospace_font_size:
* @settings: a #WebKitSettings
* @font_size: default monospace font size to be set in pixels
*
* Set the #WebKitSettings:default-monospace-font-size property.
*/
void webkit_settings_set_default_monospace_font_size(WebKitSettings* settings, guint32 fontSize)
{
g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
WebKitSettingsPrivate* priv = settings->priv;
uint32_t currentSize = priv->preferences->defaultFixedFontSize();
if (currentSize == fontSize)
return;
priv->preferences->setDefaultFixedFontSize(fontSize);
g_object_notify(G_OBJECT(settings), "default-monospace-font-size");
}
/**
* webkit_settings_get_minimum_font_size:
* @settings: a #WebKitSettings
*
* Gets the #WebKitSettings:minimum-font-size property.
*
* Returns: Minimum font size.
*/
guint32 webkit_settings_get_minimum_font_size(WebKitSettings* settings)
{
g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), 0);
return settings->priv->preferences->minimumFontSize();
}
/**
* webkit_settings_set_minimum_font_size:
* @settings: a #WebKitSettings
* @font_size: minimum font size to be set in points
*
* Set the #WebKitSettings:minimum-font-size property.
*/
void webkit_settings_set_minimum_font_size(WebKitSettings* settings, guint32 fontSize)
{
g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
WebKitSettingsPrivate* priv = settings->priv;
uint32_t currentSize = priv->preferences->minimumFontSize();
if (currentSize == fontSize)
return;
priv->preferences->setMinimumFontSize(fontSize);
g_object_notify(G_OBJECT(settings), "minimum-font-size");
}
/**
* webkit_settings_get_default_charset:
* @settings: a #WebKitSettings
*
* Gets the #WebKitSettings:default-charset property.
*
* Returns: Default charset.
*/
const gchar* webkit_settings_get_default_charset(WebKitSettings* settings)
{
g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), 0);
return settings->priv->defaultCharset.data();
}
/**
* webkit_settings_set_default_charset:
* @settings: a #WebKitSettings
* @default_charset: default charset to be set
*
* Set the #WebKitSettings:default-charset property.
*/
void webkit_settings_set_default_charset(WebKitSettings* settings, const gchar* defaultCharset)
{
g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
g_return_if_fail(defaultCharset);
WebKitSettingsPrivate* priv = settings->priv;
if (!g_strcmp0(priv->defaultCharset.data(), defaultCharset))
return;
String defaultCharsetString = String::fromUTF8(defaultCharset);
priv->preferences->setDefaultTextEncodingName(defaultCharsetString);
priv->defaultCharset = defaultCharsetString.utf8();
g_object_notify(G_OBJECT(settings), "default-charset");
}
/**
* webkit_settings_get_enable_private_browsing:
* @settings: a #WebKitSettings
*
* Get the #WebKitSettings:enable-private-browsing property.
*
* Returns: %TRUE If private browsing is enabled or %FALSE otherwise.
*
* Deprecated: 2.16. Use #WebKitWebView:is-ephemeral or #WebKitWebContext:is-ephemeral instead.
*/
gboolean webkit_settings_get_enable_private_browsing(WebKitSettings* settings)
{
g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE);
return settings->priv->preferences->privateBrowsingEnabled();
}
/**
* webkit_settings_set_enable_private_browsing:
* @settings: a #WebKitSettings
* @enabled: Value to be set
*
* Set the #WebKitSettings:enable-private-browsing property.
*
* Deprecated: 2.16. Use #WebKitWebView:is-ephemeral or #WebKitWebContext:is-ephemeral instead.
*/
void webkit_settings_set_enable_private_browsing(WebKitSettings* settings, gboolean enabled)
{
g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
WebKitSettingsPrivate* priv = settings->priv;
bool currentValue = priv->preferences->privateBrowsingEnabled();
if (currentValue == enabled)
return;
priv->preferences->setPrivateBrowsingEnabled(enabled);
g_object_notify(G_OBJECT(settings), "enable-private-browsing");
}
/**
* webkit_settings_get_enable_developer_extras:
* @settings: a #WebKitSettings
*
* Get the #WebKitSettings:enable-developer-extras property.
*
* Returns: %TRUE If developer extras is enabled or %FALSE otherwise.
*/
gboolean webkit_settings_get_enable_developer_extras(WebKitSettings* settings)
{
g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE);
return settings->priv->preferences->developerExtrasEnabled();
}
/**
* webkit_settings_set_enable_developer_extras:
* @settings: a #WebKitSettings
* @enabled: Value to be set
*
* Set the #WebKitSettings:enable-developer-extras property.
*/
void webkit_settings_set_enable_developer_extras(WebKitSettings* settings, gboolean enabled)
{
g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
WebKitSettingsPrivate* priv = settings->priv;
bool currentValue = priv->preferences->developerExtrasEnabled();
if (currentValue == enabled)
return;
priv->preferences->setDeveloperExtrasEnabled(enabled);
g_object_notify(G_OBJECT(settings), "enable-developer-extras");
}
/**
* webkit_settings_get_enable_resizable_text_areas:
* @settings: a #WebKitSettings
*
* Get the #WebKitSettings:enable-resizable-text-areas property.
*
* Returns: %TRUE If text areas can be resized or %FALSE otherwise.
*/
gboolean webkit_settings_get_enable_resizable_text_areas(WebKitSettings* settings)
{
g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE);
return settings->priv->preferences->textAreasAreResizable();
}
/**
* webkit_settings_set_enable_resizable_text_areas:
* @settings: a #WebKitSettings
* @enabled: Value to be set
*
* Set the #WebKitSettings:enable-resizable-text-areas property.
*/
void webkit_settings_set_enable_resizable_text_areas(WebKitSettings* settings, gboolean enabled)
{
g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
WebKitSettingsPrivate* priv = settings->priv;
bool currentValue = priv->preferences->textAreasAreResizable();
if (currentValue == enabled)
return;
priv->preferences->setTextAreasAreResizable(enabled);
g_object_notify(G_OBJECT(settings), "enable-resizable-text-areas");
}
/**
* webkit_settings_get_enable_tabs_to_links:
* @settings: a #WebKitSettings
*
* Get the #WebKitSettings:enable-tabs-to-links property.
*
* Returns: %TRUE If tabs to link is enabled or %FALSE otherwise.
*/
gboolean webkit_settings_get_enable_tabs_to_links(WebKitSettings* settings)
{
g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE);
return settings->priv->preferences->tabsToLinks();
}
/**
* webkit_settings_set_enable_tabs_to_links:
* @settings: a #WebKitSettings
* @enabled: Value to be set
*
* Set the #WebKitSettings:enable-tabs-to-links property.
*/
void webkit_settings_set_enable_tabs_to_links(WebKitSettings* settings, gboolean enabled)
{
g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
WebKitSettingsPrivate* priv = settings->priv;
bool currentValue = priv->preferences->tabsToLinks();
if (currentValue == enabled)
return;
priv->preferences->setTabsToLinks(enabled);
g_object_notify(G_OBJECT(settings), "enable-tabs-to-links");
}
/**
* webkit_settings_get_enable_dns_prefetching:
* @settings: a #WebKitSettings
*
* Get the #WebKitSettings:enable-dns-prefetching property.
*
* Returns: %TRUE If DNS prefetching is enabled or %FALSE otherwise.
*/
gboolean webkit_settings_get_enable_dns_prefetching(WebKitSettings* settings)
{
g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE);
return settings->priv->preferences->dnsPrefetchingEnabled();
}
/**
* webkit_settings_set_enable_dns_prefetching:
* @settings: a #WebKitSettings
* @enabled: Value to be set
*
* Set the #WebKitSettings:enable-dns-prefetching property.
*/
void webkit_settings_set_enable_dns_prefetching(WebKitSettings* settings, gboolean enabled)
{
g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
WebKitSettingsPrivate* priv = settings->priv;
bool currentValue = priv->preferences->dnsPrefetchingEnabled();
if (currentValue == enabled)
return;
priv->preferences->setDNSPrefetchingEnabled(enabled);
g_object_notify(G_OBJECT(settings), "enable-dns-prefetching");
}
/**
* webkit_settings_get_enable_caret_browsing:
* @settings: a #WebKitSettings
*
* Get the #WebKitSettings:enable-caret-browsing property.
*
* Returns: %TRUE If caret browsing is enabled or %FALSE otherwise.
*/
gboolean webkit_settings_get_enable_caret_browsing(WebKitSettings* settings)
{
g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE);
return settings->priv->preferences->caretBrowsingEnabled();
}
/**
* webkit_settings_set_enable_caret_browsing:
* @settings: a #WebKitSettings
* @enabled: Value to be set
*
* Set the #WebKitSettings:enable-caret-browsing property.
*/
void webkit_settings_set_enable_caret_browsing(WebKitSettings* settings, gboolean enabled)
{
g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
WebKitSettingsPrivate* priv = settings->priv;
bool currentValue = priv->preferences->caretBrowsingEnabled();
if (currentValue == enabled)
return;
priv->preferences->setCaretBrowsingEnabled(enabled);
g_object_notify(G_OBJECT(settings), "enable-caret-browsing");
}
/**
* webkit_settings_get_enable_fullscreen:
* @settings: a #WebKitSettings
*
* Get the #WebKitSettings:enable-fullscreen property.
*
* Returns: %TRUE If fullscreen support is enabled or %FALSE otherwise.
*/
gboolean webkit_settings_get_enable_fullscreen(WebKitSettings* settings)
{
g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE);
return settings->priv->preferences->fullScreenEnabled();
}
/**
* webkit_settings_set_enable_fullscreen:
* @settings: a #WebKitSettings
* @enabled: Value to be set
*
* Set the #WebKitSettings:enable-fullscreen property.
*/
void webkit_settings_set_enable_fullscreen(WebKitSettings* settings, gboolean enabled)
{
g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
WebKitSettingsPrivate* priv = settings->priv;
bool currentValue = priv->preferences->fullScreenEnabled();
if (currentValue == enabled)
return;
priv->preferences->setFullScreenEnabled(enabled);
g_object_notify(G_OBJECT(settings), "enable-fullscreen");
}
/**
* webkit_settings_get_print_backgrounds:
* @settings: a #WebKitSettings
*
* Get the #WebKitSettings:print-backgrounds property.
*
* Returns: %TRUE If background images should be printed or %FALSE otherwise.
*/
gboolean webkit_settings_get_print_backgrounds(WebKitSettings* settings)
{
g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE);
return settings->priv->preferences->shouldPrintBackgrounds();
}
/**
* webkit_settings_set_print_backgrounds:
* @settings: a #WebKitSettings
* @print_backgrounds: Value to be set
*
* Set the #WebKitSettings:print-backgrounds property.
*/
void webkit_settings_set_print_backgrounds(WebKitSettings* settings, gboolean printBackgrounds)
{
g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
WebKitSettingsPrivate* priv = settings->priv;
bool currentValue = priv->preferences->shouldPrintBackgrounds();
if (currentValue == printBackgrounds)
return;
priv->preferences->setShouldPrintBackgrounds(printBackgrounds);
g_object_notify(G_OBJECT(settings), "print-backgrounds");
}
/**
* webkit_settings_get_enable_webaudio:
* @settings: a #WebKitSettings
*
* Get the #WebKitSettings:enable-webaudio property.
*
* Returns: %TRUE If webaudio support is enabled or %FALSE otherwise.
*/
gboolean webkit_settings_get_enable_webaudio(WebKitSettings* settings)
{
g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE);
return settings->priv->preferences->webAudioEnabled();
}
/**
* webkit_settings_set_enable_webaudio:
* @settings: a #WebKitSettings
* @enabled: Value to be set
*
* Set the #WebKitSettings:enable-webaudio property.
*/
void webkit_settings_set_enable_webaudio(WebKitSettings* settings, gboolean enabled)
{
g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
WebKitSettingsPrivate* priv = settings->priv;
bool currentValue = priv->preferences->webAudioEnabled();
if (currentValue == enabled)
return;
priv->preferences->setWebAudioEnabled(enabled);
g_object_notify(G_OBJECT(settings), "enable-webaudio");
}
/**
* webkit_settings_get_enable_webgl:
* @settings: a #WebKitSettings
*
* Get the #WebKitSettings:enable-webgl property.
*
* Returns: %TRUE If WebGL support is enabled or %FALSE otherwise.
*/
gboolean webkit_settings_get_enable_webgl(WebKitSettings* settings)
{
g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE);
return settings->priv->preferences->webGLEnabled();
}
/**
* webkit_settings_set_enable_webgl:
* @settings: a #WebKitSettings
* @enabled: Value to be set
*
* Set the #WebKitSettings:enable-webgl property.
*/
void webkit_settings_set_enable_webgl(WebKitSettings* settings, gboolean enabled)
{
g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
WebKitSettingsPrivate* priv = settings->priv;
bool currentValue = priv->preferences->webGLEnabled();
if (currentValue == enabled)
return;
priv->preferences->setWebGLEnabled(enabled);
g_object_notify(G_OBJECT(settings), "enable-webgl");
}
/**
* webkit_settings_get_allow_modal_dialogs:
* @settings: a #WebKitSettings
*
* Get the #WebKitSettings:allow-modal-dialogs property.
*
* Returns: %TRUE if it's allowed to create and run modal dialogs or %FALSE otherwise.
*/
gboolean webkit_settings_get_allow_modal_dialogs(WebKitSettings* settings)
{
g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE);
return settings->priv->allowModalDialogs;
}
/**
* webkit_settings_set_allow_modal_dialogs:
* @settings: a #WebKitSettings
* @allowed: Value to be set
*
* Set the #WebKitSettings:allow-modal-dialogs property.
*/
void webkit_settings_set_allow_modal_dialogs(WebKitSettings* settings, gboolean allowed)
{
g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
WebKitSettingsPrivate* priv = settings->priv;
if (priv->allowModalDialogs == allowed)
return;
priv->allowModalDialogs = allowed;
g_object_notify(G_OBJECT(settings), "allow-modal-dialogs");
}
/**
* webkit_settings_get_zoom_text_only:
* @settings: a #WebKitSettings
*
* Get the #WebKitSettings:zoom-text-only property.
*
* Returns: %TRUE If zoom level of the view should only affect the text
* or %FALSE if all view contents should be scaled.
*/
gboolean webkit_settings_get_zoom_text_only(WebKitSettings* settings)
{
g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE);
return settings->priv->zoomTextOnly;
}
/**
* webkit_settings_set_zoom_text_only:
* @settings: a #WebKitSettings
* @zoom_text_only: Value to be set
*
* Set the #WebKitSettings:zoom-text-only property.
*/
void webkit_settings_set_zoom_text_only(WebKitSettings* settings, gboolean zoomTextOnly)
{
g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
WebKitSettingsPrivate* priv = settings->priv;
if (priv->zoomTextOnly == zoomTextOnly)
return;
priv->zoomTextOnly = zoomTextOnly;
g_object_notify(G_OBJECT(settings), "zoom-text-only");
}
/**
* webkit_settings_get_javascript_can_access_clipboard:
* @settings: a #WebKitSettings
*
* Get the #WebKitSettings:javascript-can-access-clipboard property.
*
* Returns: %TRUE If javascript-can-access-clipboard is enabled or %FALSE otherwise.
*/
gboolean webkit_settings_get_javascript_can_access_clipboard(WebKitSettings* settings)
{
g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE);
return settings->priv->preferences->javaScriptCanAccessClipboard()
&& settings->priv->preferences->domPasteAllowed();
}
/**
* webkit_settings_set_javascript_can_access_clipboard:
* @settings: a #WebKitSettings
* @enabled: Value to be set
*
* Set the #WebKitSettings:javascript-can-access-clipboard property.
*/
void webkit_settings_set_javascript_can_access_clipboard(WebKitSettings* settings, gboolean enabled)
{
g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
WebKitSettingsPrivate* priv = settings->priv;
bool currentValue = priv->preferences->javaScriptCanAccessClipboard() && priv->preferences->domPasteAllowed();
if (currentValue == enabled)
return;
priv->preferences->setJavaScriptCanAccessClipboard(enabled);
priv->preferences->setDOMPasteAllowed(enabled);
g_object_notify(G_OBJECT(settings), "javascript-can-access-clipboard");
}
/**
* webkit_settings_get_media_playback_requires_user_gesture:
* @settings: a #WebKitSettings
*
* Get the #WebKitSettings:media-playback-requires-user-gesture property.
*
* Returns: %TRUE If an user gesture is needed to play or load media
* or %FALSE if no user gesture is needed.
*/
gboolean webkit_settings_get_media_playback_requires_user_gesture(WebKitSettings* settings)
{
g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE);
return settings->priv->preferences->requiresUserGestureForMediaPlayback();
}
/**
* webkit_settings_set_media_playback_requires_user_gesture:
* @settings: a #WebKitSettings
* @enabled: Value to be set
*
* Set the #WebKitSettings:media-playback-requires-user-gesture property.
*/
void webkit_settings_set_media_playback_requires_user_gesture(WebKitSettings* settings, gboolean enabled)
{
g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
WebKitSettingsPrivate* priv = settings->priv;
bool currentValue = priv->preferences->requiresUserGestureForMediaPlayback();
if (currentValue == enabled)
return;
priv->preferences->setRequiresUserGestureForMediaPlayback(enabled);
g_object_notify(G_OBJECT(settings), "media-playback-requires-user-gesture");
}
/**
* webkit_settings_get_media_playback_allows_inline:
* @settings: a #WebKitSettings
*
* Get the #WebKitSettings:media-playback-allows-inline property.
*
* Returns: %TRUE If inline playback is allowed for media
* or %FALSE if only fullscreen playback is allowed.
*/
gboolean webkit_settings_get_media_playback_allows_inline(WebKitSettings* settings)
{
g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), TRUE);
return settings->priv->preferences->allowsInlineMediaPlayback();
}
/**
* webkit_settings_set_media_playback_allows_inline:
* @settings: a #WebKitSettings
* @enabled: Value to be set
*
* Set the #WebKitSettings:media-playback-allows-inline property.
*/
void webkit_settings_set_media_playback_allows_inline(WebKitSettings* settings, gboolean enabled)
{
g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
WebKitSettingsPrivate* priv = settings->priv;
bool currentValue = priv->preferences->allowsInlineMediaPlayback();
if (currentValue == enabled)
return;
priv->preferences->setAllowsInlineMediaPlayback(enabled);
g_object_notify(G_OBJECT(settings), "media-playback-allows-inline");
}
/**
* webkit_settings_get_draw_compositing_indicators:
* @settings: a #WebKitSettings
*
* Get the #WebKitSettings:draw-compositing-indicators property.
*
* Returns: %TRUE If compositing borders are drawn or %FALSE otherwise.
*/
gboolean webkit_settings_get_draw_compositing_indicators(WebKitSettings* settings)
{
g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE);
return settings->priv->preferences->compositingBordersVisible()
&& settings->priv->preferences->compositingRepaintCountersVisible();
}
/**
* webkit_settings_set_draw_compositing_indicators:
* @settings: a #WebKitSettings
* @enabled: Value to be set
*
* Set the #WebKitSettings:draw-compositing-indicators property.
*/
void webkit_settings_set_draw_compositing_indicators(WebKitSettings* settings, gboolean enabled)
{
g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
WebKitSettingsPrivate* priv = settings->priv;
if (priv->preferences->compositingBordersVisible() == enabled
&& priv->preferences->compositingRepaintCountersVisible() == enabled)
return;
priv->preferences->setCompositingBordersVisible(enabled);
priv->preferences->setCompositingRepaintCountersVisible(enabled);
g_object_notify(G_OBJECT(settings), "draw-compositing-indicators");
}
/**
* webkit_settings_get_enable_site_specific_quirks:
* @settings: a #WebKitSettings
*
* Get the #WebKitSettings:enable-site-specific-quirks property.
*
* Returns: %TRUE if site specific quirks are enabled or %FALSE otherwise.
*/
gboolean webkit_settings_get_enable_site_specific_quirks(WebKitSettings* settings)
{
g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE);
return settings->priv->preferences->needsSiteSpecificQuirks();
}
/**
* webkit_settings_set_enable_site_specific_quirks:
* @settings: a #WebKitSettings
* @enabled: Value to be set
*
* Set the #WebKitSettings:enable-site-specific-quirks property.
*/
void webkit_settings_set_enable_site_specific_quirks(WebKitSettings* settings, gboolean enabled)
{
g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
WebKitSettingsPrivate* priv = settings->priv;
bool currentValue = priv->preferences->needsSiteSpecificQuirks();
if (currentValue == enabled)
return;
priv->preferences->setNeedsSiteSpecificQuirks(enabled);
g_object_notify(G_OBJECT(settings), "enable-site-specific-quirks");
}
/**
* webkit_settings_get_enable_page_cache:
* @settings: a #WebKitSettings
*
* Get the #WebKitSettings:enable-page-cache property.
*
* Returns: %TRUE if page cache enabled or %FALSE otherwise.
*/
gboolean webkit_settings_get_enable_page_cache(WebKitSettings* settings)
{
g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE);
return settings->priv->preferences->usesPageCache();
}
/**
* webkit_settings_set_enable_page_cache:
* @settings: a #WebKitSettings
* @enabled: Value to be set
*
* Set the #WebKitSettings:enable-page-cache property.
*/
void webkit_settings_set_enable_page_cache(WebKitSettings* settings, gboolean enabled)
{
g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
WebKitSettingsPrivate* priv = settings->priv;
bool currentValue = priv->preferences->usesPageCache();
if (currentValue == enabled)
return;
priv->preferences->setUsesPageCache(enabled);
g_object_notify(G_OBJECT(settings), "enable-page-cache");
}
/**
* webkit_settings_get_user_agent:
* @settings: a #WebKitSettings
*
* Get the #WebKitSettings:user-agent property.
*
* Returns: The current value of the user-agent property.
*/
const char* webkit_settings_get_user_agent(WebKitSettings* settings)
{
g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), 0);
WebKitSettingsPrivate* priv = settings->priv;
ASSERT(!priv->userAgent.isNull());
return priv->userAgent.data();
}
/**
* webkit_settings_set_user_agent:
* @settings: a #WebKitSettings
* @user_agent: (allow-none): The new custom user agent string or %NULL to use the default user agent
*
* Set the #WebKitSettings:user-agent property.
*/
void webkit_settings_set_user_agent(WebKitSettings* settings, const char* userAgent)
{
g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
WebKitSettingsPrivate* priv = settings->priv;
CString newUserAgent = (!userAgent || !strlen(userAgent)) ? WebCore::standardUserAgent("").utf8() : userAgent;
if (newUserAgent == priv->userAgent)
return;
priv->userAgent = newUserAgent;
g_object_notify(G_OBJECT(settings), "user-agent");
}
/**
* webkit_settings_set_user_agent_with_application_details:
* @settings: a #WebKitSettings
* @application_name: (allow-none): The application name used for the user agent or %NULL to use the default user agent.
* @application_version: (allow-none): The application version for the user agent or %NULL to user the default version.
*
* Set the #WebKitSettings:user-agent property by appending the application details to the default user
* agent. If no application name or version is given, the default user agent used will be used. If only
* the version is given, the default engine version is used with the given application name.
*/
void webkit_settings_set_user_agent_with_application_details(WebKitSettings* settings, const char* applicationName, const char* applicationVersion)
{
g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
CString newUserAgent = WebCore::standardUserAgent(String::fromUTF8(applicationName), String::fromUTF8(applicationVersion)).utf8();
webkit_settings_set_user_agent(settings, newUserAgent.data());
}
/**
* webkit_settings_get_enable_smooth_scrolling:
* @settings: a #WebKitSettings
*
* Get the #WebKitSettings:enable-smooth-scrolling property.
*
* Returns: %TRUE if smooth scrolling is enabled or %FALSE otherwise.
*/
gboolean webkit_settings_get_enable_smooth_scrolling(WebKitSettings* settings)
{
g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE);
return settings->priv->preferences->scrollAnimatorEnabled();
}
/**
* webkit_settings_set_enable_smooth_scrolling:
* @settings: a #WebKitSettings
* @enabled: Value to be set
*
* Set the #WebKitSettings:enable-smooth-scrolling property.
*/
void webkit_settings_set_enable_smooth_scrolling(WebKitSettings* settings, gboolean enabled)
{
g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
WebKitSettingsPrivate* priv = settings->priv;
bool currentValue = priv->preferences->scrollAnimatorEnabled();
if (currentValue == enabled)
return;
priv->preferences->setScrollAnimatorEnabled(enabled);
g_object_notify(G_OBJECT(settings), "enable-smooth-scrolling");
}
/**
* webkit_settings_get_enable_accelerated_2d_canvas:
* @settings: a #WebKitSettings
*
* Get the #WebKitSettings:enable-accelerated-2d-canvas property.
*
* Returns: %TRUE if accelerated 2D canvas is enabled or %FALSE otherwise.
*
* Since: 2.2
*/
gboolean webkit_settings_get_enable_accelerated_2d_canvas(WebKitSettings* settings)
{
g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE);
return settings->priv->preferences->accelerated2dCanvasEnabled();
}
/**
* webkit_settings_set_enable_accelerated_2d_canvas:
* @settings: a #WebKitSettings
* @enabled: Value to be set
*
* Set the #WebKitSettings:enable-accelerated-2d-canvas property.
*
* Since: 2.2
*/
void webkit_settings_set_enable_accelerated_2d_canvas(WebKitSettings* settings, gboolean enabled)
{
g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
WebKitSettingsPrivate* priv = settings->priv;
if (priv->preferences->accelerated2dCanvasEnabled() == enabled)
return;
priv->preferences->setAccelerated2dCanvasEnabled(enabled);
g_object_notify(G_OBJECT(settings), "enable-accelerated-2d-canvas");
}
/**
* webkit_settings_get_enable_write_console_messages_to_stdout:
* @settings: a #WebKitSettings
*
* Get the #WebKitSettings:enable-write-console-messages-to-stdout property.
*
* Returns: %TRUE if writing console messages to stdout is enabled or %FALSE
* otherwise.
*
* Since: 2.2
*/
gboolean webkit_settings_get_enable_write_console_messages_to_stdout(WebKitSettings* settings)
{
g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE);
return settings->priv->preferences->logsPageMessagesToSystemConsoleEnabled();
}
/**
* webkit_settings_set_enable_write_console_messages_to_stdout:
* @settings: a #WebKitSettings
* @enabled: Value to be set
*
* Set the #WebKitSettings:enable-write-console-messages-to-stdout property.
*
* Since: 2.2
*/
void webkit_settings_set_enable_write_console_messages_to_stdout(WebKitSettings* settings, gboolean enabled)
{
g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
WebKitSettingsPrivate* priv = settings->priv;
bool currentValue = priv->preferences->logsPageMessagesToSystemConsoleEnabled();
if (currentValue == enabled)
return;
priv->preferences->setLogsPageMessagesToSystemConsoleEnabled(enabled);
g_object_notify(G_OBJECT(settings), "enable-write-console-messages-to-stdout");
}
/**
* webkit_settings_get_enable_media_stream:
* @settings: a #WebKitSettings
*
* Get the #WebKitSettings:enable-media-stream property.
*
* Returns: %TRUE If mediastream support is enabled or %FALSE otherwise.
*
* Since: 2.4
*/
gboolean webkit_settings_get_enable_media_stream(WebKitSettings* settings)
{
g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE);
return settings->priv->preferences->mediaStreamEnabled();
}
/**
* webkit_settings_set_enable_media_stream:
* @settings: a #WebKitSettings
* @enabled: Value to be set
*
* Set the #WebKitSettings:enable-media-stream property.
*
* Since: 2.4
*/
void webkit_settings_set_enable_media_stream(WebKitSettings* settings, gboolean enabled)
{
g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
WebKitSettingsPrivate* priv = settings->priv;
bool currentValue = priv->preferences->mediaStreamEnabled();
if (currentValue == enabled)
return;
priv->preferences->setMediaDevicesEnabled(enabled);
priv->preferences->setMediaStreamEnabled(enabled);
priv->preferences->setPeerConnectionEnabled(enabled);
g_object_notify(G_OBJECT(settings), "enable-media-stream");
}
/**
* webkit_settings_set_enable_spatial_navigation:
* @settings: a #WebKitSettings
* @enabled: Value to be set
*
* Set the #WebKitSettings:enable-spatial-navigation property.
*
* Since: 2.2
*/
void webkit_settings_set_enable_spatial_navigation(WebKitSettings* settings, gboolean enabled)
{
g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
WebKitSettingsPrivate* priv = settings->priv;
bool currentValue = priv->preferences->spatialNavigationEnabled();
if (currentValue == enabled)
return;
priv->preferences->setSpatialNavigationEnabled(enabled);
g_object_notify(G_OBJECT(settings), "enable-spatial-navigation");
}
/**
* webkit_settings_get_enable_spatial_navigation:
* @settings: a #WebKitSettings
*
* Get the #WebKitSettings:enable-spatial-navigation property.
*
* Returns: %TRUE If HTML5 spatial navigation support is enabled or %FALSE otherwise.
*
* Since: 2.2
*/
gboolean webkit_settings_get_enable_spatial_navigation(WebKitSettings* settings)
{
g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE);
return settings->priv->preferences->spatialNavigationEnabled();
}
/**
* webkit_settings_get_enable_mediasource:
* @settings: a #WebKitSettings
*
* Get the #WebKitSettings:enable-mediasource property.
*
* Returns: %TRUE If MediaSource support is enabled or %FALSE otherwise.
*
* Since: 2.4
*/
gboolean webkit_settings_get_enable_mediasource(WebKitSettings* settings)
{
g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE);
return settings->priv->preferences->mediaSourceEnabled();
}
/**
* webkit_settings_set_enable_mediasource:
* @settings: a #WebKitSettings
* @enabled: Value to be set
*
* Set the #WebKitSettings:enable-mediasource property.
*
* Since: 2.4
*/
void webkit_settings_set_enable_mediasource(WebKitSettings* settings, gboolean enabled)
{
g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
WebKitSettingsPrivate* priv = settings->priv;
bool currentValue = priv->preferences->mediaSourceEnabled();
if (currentValue == enabled)
return;
priv->preferences->setMediaSourceEnabled(enabled);
g_object_notify(G_OBJECT(settings), "enable-mediasource");
}
/**
* webkit_settings_get_allow_file_access_from_file_urls:
* @settings: a #WebKitSettings
*
* Get the #WebKitSettings:allow-file-access-from-file-urls property.
*
* Returns: %TRUE If file access from file URLs is allowed or %FALSE otherwise.
*
* Since: 2.10
*/
gboolean webkit_settings_get_allow_file_access_from_file_urls(WebKitSettings* settings)
{
g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE);
return settings->priv->preferences->allowFileAccessFromFileURLs();
}
/**
* webkit_settings_set_allow_file_access_from_file_urls:
* @settings: a #WebKitSettings
* @allowed: Value to be set
*
* Set the #WebKitSettings:allow-file-access-from-file-urls property.
*
* Since: 2.10
*/
void webkit_settings_set_allow_file_access_from_file_urls(WebKitSettings* settings, gboolean allowed)
{
g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
WebKitSettingsPrivate* priv = settings->priv;
if (priv->preferences->allowFileAccessFromFileURLs() == allowed)
return;
priv->preferences->setAllowFileAccessFromFileURLs(allowed);
g_object_notify(G_OBJECT(settings), "allow-file-access-from-file-urls");
}
/**
* webkit_settings_get_allow_universal_access_from_file_urls:
* @settings: a #WebKitSettings
*
* Get the #WebKitSettings:allow-universal-access-from-file-urls property.
*
* Returns: %TRUE If universal access from file URLs is allowed or %FALSE otherwise.
*
* Since: 2.14
*/
gboolean webkit_settings_get_allow_universal_access_from_file_urls(WebKitSettings* settings)
{
g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE);
return settings->priv->preferences->allowUniversalAccessFromFileURLs();
}
/**
* webkit_settings_set_allow_universal_access_from_file_urls:
* @settings: a #WebKitSettings
* @allowed: Value to be set
*
* Set the #WebKitSettings:allow-universal-access-from-file-urls property.
*
* Since: 2.14
*/
void webkit_settings_set_allow_universal_access_from_file_urls(WebKitSettings* settings, gboolean allowed)
{
g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
WebKitSettingsPrivate* priv = settings->priv;
if (priv->preferences->allowUniversalAccessFromFileURLs() == allowed)
return;
priv->preferences->setAllowUniversalAccessFromFileURLs(allowed);
g_object_notify(G_OBJECT(settings), "allow-universal-access-from-file-urls");
}
#if PLATFORM(GTK)
/**
* webkit_settings_get_hardware_acceleration_policy:
* @settings: a #WebKitSettings
*
* Get the #WebKitSettings:hardware-acceleration-policy property.
*
* Return: a #WebKitHardwareAccelerationPolicy
*
* Since: 2.16
*/
WebKitHardwareAccelerationPolicy webkit_settings_get_hardware_acceleration_policy(WebKitSettings* settings)
{
g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), WEBKIT_HARDWARE_ACCELERATION_POLICY_ON_DEMAND);
WebKitSettingsPrivate* priv = settings->priv;
if (!priv->preferences->acceleratedCompositingEnabled())
return WEBKIT_HARDWARE_ACCELERATION_POLICY_NEVER;
if (priv->preferences->forceCompositingMode())
return WEBKIT_HARDWARE_ACCELERATION_POLICY_ALWAYS;
return WEBKIT_HARDWARE_ACCELERATION_POLICY_ON_DEMAND;
}
/**
* webkit_settings_set_hardware_acceleration_policy:
* @settings: a #WebKitSettings
* @policy: a #WebKitHardwareAccelerationPolicy
*
* Set the #WebKitSettings:hardware-acceleration-policy property.
*
* Since: 2.16
*/
void webkit_settings_set_hardware_acceleration_policy(WebKitSettings* settings, WebKitHardwareAccelerationPolicy policy)
{
g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
WebKitSettingsPrivate* priv = settings->priv;
bool changed = false;
switch (policy) {
case WEBKIT_HARDWARE_ACCELERATION_POLICY_ALWAYS:
if (!HardwareAccelerationManager::singleton().canUseHardwareAcceleration())
return;
if (!priv->preferences->acceleratedCompositingEnabled()) {
priv->preferences->setAcceleratedCompositingEnabled(true);
changed = true;
}
if (!priv->preferences->forceCompositingMode()) {
priv->preferences->setForceCompositingMode(true);
changed = true;
}
break;
case WEBKIT_HARDWARE_ACCELERATION_POLICY_NEVER:
if (HardwareAccelerationManager::singleton().forceHardwareAcceleration())
return;
if (priv->preferences->acceleratedCompositingEnabled()) {
priv->preferences->setAcceleratedCompositingEnabled(false);
changed = true;
}
if (priv->preferences->forceCompositingMode()) {
priv->preferences->setForceCompositingMode(false);
changed = true;
}
break;
case WEBKIT_HARDWARE_ACCELERATION_POLICY_ON_DEMAND:
if (!priv->preferences->acceleratedCompositingEnabled() && HardwareAccelerationManager::singleton().canUseHardwareAcceleration()) {
priv->preferences->setAcceleratedCompositingEnabled(true);
changed = true;
}
if (priv->preferences->forceCompositingMode() && !HardwareAccelerationManager::singleton().forceHardwareAcceleration()) {
priv->preferences->setForceCompositingMode(false);
changed = true;
}
break;
}
if (changed)
g_object_notify(G_OBJECT(settings), "hardware-acceleration-policy");
}
#endif // PLATFORM(GTK)
| 38.03758 | 147 | 0.680129 | ijsf |
3ab967d72f4e80ea5ef374a7ab3eccdd5bbfa3df | 3,283 | hpp | C++ | src/xercesc/dom/deprecated/DOM_RangeException.hpp | ksmyth/xerces-c | 245d0f626041add542ab7deabd6ba9c3e4641f6d | [
"ECL-2.0",
"Apache-2.0"
] | null | null | null | src/xercesc/dom/deprecated/DOM_RangeException.hpp | ksmyth/xerces-c | 245d0f626041add542ab7deabd6ba9c3e4641f6d | [
"ECL-2.0",
"Apache-2.0"
] | null | null | null | src/xercesc/dom/deprecated/DOM_RangeException.hpp | ksmyth/xerces-c | 245d0f626041add542ab7deabd6ba9c3e4641f6d | [
"ECL-2.0",
"Apache-2.0"
] | null | null | null | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
*/
/*
* $Id: DOM_RangeException.hpp 568078 2007-08-21 11:43:25Z amassari $
*/
#ifndef DOM_RangeException_HEADER_GUARD_
#define DOM_RangeException_HEADER_GUARD_
#include "DOM_DOMException.hpp"
XERCES_CPP_NAMESPACE_BEGIN
/**
* Encapsulate range related DOM error or warning. DOM level 2 implementation.
*
* <p> The DOM will create and throw an instance of DOM_RangeException
* when an error condition in range is detected. Exceptions can occur
* when an application directly manipulates the range elements in DOM document
* tree that is produced by the parser.
*
* <p>Unlike the other classes in the C++ DOM API, DOM_RangeException
* is NOT a reference to an underlying implementation class, and
* does not provide automatic memory management. Code that catches
* a DOM Range exception is responsible for deleting it, or otherwise
* arranging for its disposal.
*
*/
class DEPRECATED_DOM_EXPORT DOM_RangeException : public DOM_DOMException {
public:
/** @name Enumerators for DOM Range Exceptions */
//@{
enum RangeExceptionCode {
BAD_BOUNDARYPOINTS_ERR = 1,
INVALID_NODE_TYPE_ERR = 2
};
//@}
public:
/** @name Constructors and assignment operator */
//@{
/**
* Default constructor for DOM_RangeException.
*
*/
DOM_RangeException();
/**
* Constructor which takes an error code and a message.
*
* @param code The error code which indicates the exception
* @param message The string containing the error message
*/
DOM_RangeException(RangeExceptionCode code, const DOMString &message);
/**
* Copy constructor.
*
* @param other The object to be copied.
*/
DOM_RangeException(const DOM_RangeException &other);
//@}
/** @name Destructor. */
//@{
/**
* Destructor for DOM_RangeException. Applications are responsible
* for deleting DOM_RangeException objects that they catch after they
* have completed their exception processing.
*
*/
virtual ~DOM_RangeException();
//@}
/** @name Public variables. */
//@{
/**
* A code value, from the set defined by the RangeExceptionCode enum,
* indicating the type of error that occured.
*/
RangeExceptionCode code;
//@}
};
XERCES_CPP_NAMESPACE_END
#endif
| 30.971698 | 80 | 0.670423 | ksmyth |
3ab99c7d949f1bb73acdc49237737b2dc417a183 | 7,976 | hh | C++ | Chaos/Utility/ContextRef.hh | ASMlover/Chaos | 06afc6a729204f4c7e6883606b4576987e050fb3 | [
"BSD-2-Clause"
] | 4 | 2016-12-03T18:58:45.000Z | 2020-08-29T05:09:54.000Z | Chaos/Utility/ContextRef.hh | ASMlover/Chaos | 06afc6a729204f4c7e6883606b4576987e050fb3 | [
"BSD-2-Clause"
] | null | null | null | Chaos/Utility/ContextRef.hh | ASMlover/Chaos | 06afc6a729204f4c7e6883606b4576987e050fb3 | [
"BSD-2-Clause"
] | null | null | null | // Copyright (c) 2016 ASMlover. All rights reserved.
//
// ____ __
// /\ _`\ /\ \
// \ \ \/\_\\ \ \___ __ ___ ____
// \ \ \/_/_\ \ _ `\ /'__`\ / __`\ /',__\
// \ \ \L\ \\ \ \ \ \/\ \L\.\_/\ \L\ \/\__, `\
// \ \____/ \ \_\ \_\ \__/.\_\ \____/\/\____/
// \/___/ \/_/\/_/\/__/\/_/\/___/ \/___/
//
// 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 ofconditions 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 materialsprovided with the
// distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
// COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
#pragma once
#include <memory>
#include <Chaos/Base/Copyable.hh>
namespace Chaos {
template <typename T, typename Allocator = std::allocator<char>>
class ContextRef : public Copyable {
struct Node {
std::shared_ptr<void> parent;
T value;
template <typename... Args>
Node(std::shared_ptr<void> p, Args&&... args)
: parent(std::move(p))
, value(std::forward<Args>(args)...) {
}
};
std::shared_ptr<Node> node_;
Allocator alloc_;
template <typename Y, typename YAllocator>
friend class ContextRef;
public:
using value_type = T;
using allocator_type = Allocator;
explicit ContextRef(const allocator_type& alloc) noexcept
: alloc_(alloc) {
}
template <typename... Args>
ContextRef(
std::shared_ptr<void> parent, const allocator_type& alloc, Args&&... args)
: node_(std::allocate_shared<Node>(
alloc, std::move(parent), std::forward<Args>(args)...))
, alloc_(alloc) {
}
ContextRef(const ContextRef& r) noexcept
: node_(r.node_)
, alloc_(r.alloc_) {
}
ContextRef(ContextRef&& r) noexcept
: node_(std::move(r.node_))
, alloc_(std::move(r.alloc_)) {
}
ContextRef& operator=(const ContextRef& r) noexcept {
node_ = r.node_;
alloc_ = r.alloc_;
return *this;
}
ContextRef& operator=(ContextRef&& r) noexcept {
node_ = std::move(r.node_);
alloc_ = std::move(r.alloc_);
return *this;
}
void swap(ContextRef& r) noexcept {
std::swap(node_, r.node_);
std::swap(alloc_, r.alloc_);
}
template <typename U, typename... Args>
ContextRef<U, Allocator> spawn(Args&&... args) const {
return ContextRef<U, Allocator>(node_, alloc_, std::forward<Args>(args)...);
}
template <typename U, typename UAllocator, typename... Args>
ContextRef<U, UAllocator> spawn_with_allocator(
const UAllocator& alloc, Args&&... args) const {
return ContextRef<U, UAllocator>(node_, alloc, std::forward<Args>(args)...);
}
std::shared_ptr<void> get_pointer(void) const {
return node_;
}
allocator_type get_allocator(void) const {
return alloc_;
}
T* get(void) {
return node_ == nullptr ? nullptr : &node_->value;
}
const T* get(void) const {
return node_ == nullptr ? nullptr : &node_->value;
}
T& operator*(void) {
return node_->value;
}
const T& operator*(void) const {
return node_->value;
}
T* operator->(void) {
return &node_->value;
}
const T* operator->(void) const {
return &node_->value;
}
explicit operator bool(void) const {
return node_ != nullptr;
}
ContextRef<void, Allocator> operator()(void) const {
return ContextRef<void, Allocator>(*this);
}
};
template <typename Allocator>
class ContextRef<void, Allocator> : public Copyable {
std::shared_ptr<void> node_;
Allocator alloc_;
public:
using value_type = void;
using allocator_type = Allocator;
explicit ContextRef(const allocator_type& alloc) noexcept
: alloc_(alloc) {
}
ContextRef(std::shared_ptr<void> parent, const allocator_type& alloc) noexcept
: node_(std::move(parent))
, alloc_(alloc) {
}
ContextRef(std::shared_ptr<void> parent) noexcept
: ContextRef(parent, Allocator()) {
}
ContextRef(const ContextRef& r) noexcept
: node_(r.node_)
, alloc_(r.alloc_) {
}
template <typename Y>
ContextRef(const ContextRef<Y, Allocator>& r) noexcept
: node_(r.node_)
, alloc_(r.alloc_) {
}
ContextRef(ContextRef&& r) noexcept
: node_(std::move(r.node_))
, alloc_(std::move(r.alloc_)) {
}
template <typename Y>
ContextRef(ContextRef<Y, Allocator>&& r) noexcept
: node_(std::move(r.node_))
, alloc_(std::move(r.alloc_)) {
}
ContextRef& operator=(const ContextRef& r) {
node_ = r.node_;
alloc_ = r.alloc_;
return *this;
}
template <typename Y>
ContextRef& operator=(const ContextRef<Y>& r) {
node_ = r.node_;
alloc_ = r.alloc_;
return *this;
}
ContextRef& operator=(ContextRef&& r) noexcept {
node_ = std::move(r.node_);
alloc_ = std::move(r.alloc_);
return *this;
}
template <typename Y>
ContextRef& operator=(ContextRef<Y>&& r) noexcept {
node_ = std::move(r.node_);
alloc_ = std::move(r.alloc_);
return *this;
}
ContextRef& operator=(std::shared_ptr<void> parent) noexcept {
node_ = std::move(parent);
return *this;
}
void swap(ContextRef& r) noexcept {
std::swap(node_, r.node_);
std::swap(alloc_, r.alloc_);
}
template <typename U, typename... Args>
ContextRef<U, Allocator> spawn(Args&&... args) const {
return ContextRef<U, Allocator>(node_, alloc_, std::forward<Args>(args)...);
}
template <typename U, typename UAllocator, typename... Args>
ContextRef<U, UAllocator> spawn_with_allocator(
const UAllocator& alloc, Args&&... args) const {
return ContextRef<U, UAllocator>(node_, alloc, std::forward<Args>(args)...);
}
std::shared_ptr<void> get_pointer(void) const {
return node_;
}
allocator_type get_allocator(void) const {
return alloc_;
}
explicit operator bool(void) const {
return node_ != nullptr;
}
ContextRef<void, Allocator> operator()(void) const {
return *this;
}
};
template <typename T, typename Allocator>
inline bool operator==(const ContextRef<T, Allocator>& p, std::nullptr_t) {
return !p;
}
template <typename T, typename Allocator>
inline bool operator==(std::nullptr_t, const ContextRef<T, Allocator>& p) {
return p == nullptr;
}
template <typename T, typename Allocator>
inline bool operator!=(const ContextRef<T, Allocator>& p, std::nullptr_t) {
return !(p == nullptr);
}
template <typename T, typename Allocator>
inline bool operator!=(std::nullptr_t, const ContextRef<T, Allocator>& p) {
return !(p == nullptr);
}
template <typename T, typename Allocator, typename... Args>
inline ContextRef<T, Allocator> make_context_with_allocator(
const Allocator& alloc, Args&&... args) {
return ContextRef<T, Allocator>(
std::shared_ptr<void>(), alloc, std::forward<Args>(args)...);
}
template <typename T,
typename Allocator = std::allocator<char>, typename... Args>
inline ContextRef<T, Allocator> make_context(Args&&... args) {
return make_context_with_allocator(Allocator(), std::forward<Args>(args)...);
}
}
| 26.945946 | 80 | 0.660607 | ASMlover |
3abcd5f2313c1b03d646c267736efd357596a537 | 3,100 | cc | C++ | modules/prediction/common/validation_checker.cc | seeclong/apollo | 99c8afb5ebcae2a3c9359a156a957ff03944b27b | [
"Apache-2.0"
] | 22,688 | 2017-07-04T23:17:19.000Z | 2022-03-31T18:56:48.000Z | modules/prediction/common/validation_checker.cc | Songjiarui3313/apollo | df9113ae656e28e5374db32529d68e59455058a0 | [
"Apache-2.0"
] | 4,804 | 2017-07-04T22:30:12.000Z | 2022-03-31T12:58:21.000Z | modules/prediction/common/validation_checker.cc | Songjiarui3313/apollo | df9113ae656e28e5374db32529d68e59455058a0 | [
"Apache-2.0"
] | 9,985 | 2017-07-04T22:01:17.000Z | 2022-03-31T14:18:16.000Z | /******************************************************************************
* Copyright 2018 The Apollo Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*****************************************************************************/
#include "modules/prediction/common/validation_checker.h"
#include "modules/common/math/math_utils.h"
#include "modules/prediction/common/prediction_gflags.h"
namespace apollo {
namespace prediction {
using common::TrajectoryPoint;
double ValidationChecker::ProbabilityByCentripetalAcceleration(
const LaneSequence& lane_sequence, const double speed) {
double centripetal_acc_cost_sum = 0.0;
double centripetal_acc_cost_sqr_sum = 0.0;
for (int i = 0; i < lane_sequence.path_point_size(); ++i) {
const auto& path_point = lane_sequence.path_point(i);
double centripetal_acc = speed * speed * std::fabs(path_point.kappa());
double centripetal_acc_cost =
centripetal_acc / FLAGS_centripedal_acc_threshold;
centripetal_acc_cost_sum += centripetal_acc_cost;
centripetal_acc_cost_sqr_sum += centripetal_acc_cost * centripetal_acc_cost;
}
double mean_cost = centripetal_acc_cost_sqr_sum /
(centripetal_acc_cost_sum + FLAGS_double_precision);
return std::exp(-FLAGS_centripetal_acc_coeff * mean_cost);
}
bool ValidationChecker::ValidCentripetalAcceleration(
const std::vector<TrajectoryPoint>& trajectory_points) {
for (size_t i = 0; i + 1 < trajectory_points.size(); ++i) {
const auto& p0 = trajectory_points[i];
const auto& p1 = trajectory_points[i + 1];
double time_diff = std::abs(p1.relative_time() - p0.relative_time());
if (time_diff < FLAGS_double_precision) {
continue;
}
double theta_diff = std::abs(common::math::NormalizeAngle(
p1.path_point().theta() - p0.path_point().theta()));
double v = (p0.v() + p1.v()) * 0.5;
double angular_a = v * theta_diff / time_diff;
if (angular_a > FLAGS_centripedal_acc_threshold) {
return false;
}
}
return true;
}
bool ValidationChecker::ValidTrajectoryPoint(
const TrajectoryPoint& trajectory_point) {
return trajectory_point.has_path_point() &&
(!std::isnan(trajectory_point.path_point().x())) &&
(!std::isnan(trajectory_point.path_point().y())) &&
(!std::isnan(trajectory_point.path_point().theta())) &&
(!std::isnan(trajectory_point.v())) &&
(!std::isnan(trajectory_point.a())) &&
(!std::isnan(trajectory_point.relative_time()));
}
} // namespace prediction
} // namespace apollo
| 39.74359 | 80 | 0.677097 | seeclong |
3ac3a182940b0e79008ca76a10863f6924418311 | 2,177 | cpp | C++ | rosbag2_cpp/src/rosbag2_cpp/cache/cache_consumer.cpp | youliangtan/rosbag2 | 140169befa6f7179a49a6cfd312f48db47094a23 | [
"Apache-2.0"
] | null | null | null | rosbag2_cpp/src/rosbag2_cpp/cache/cache_consumer.cpp | youliangtan/rosbag2 | 140169befa6f7179a49a6cfd312f48db47094a23 | [
"Apache-2.0"
] | 14 | 2021-11-30T00:30:00.000Z | 2022-03-22T14:06:55.000Z | rosbag2_cpp/src/rosbag2_cpp/cache/cache_consumer.cpp | youliangtan/rosbag2 | 140169befa6f7179a49a6cfd312f48db47094a23 | [
"Apache-2.0"
] | 3 | 2022-01-25T15:02:52.000Z | 2022-03-13T22:51:04.000Z | // Copyright 2020, Robotec.ai sp. z o.o.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include <memory>
#include "rosbag2_cpp/cache/cache_consumer.hpp"
#include "rosbag2_cpp/logging.hpp"
namespace rosbag2_cpp
{
namespace cache
{
CacheConsumer::CacheConsumer(
std::shared_ptr<MessageCacheInterface> message_cache,
consume_callback_function_t consume_callback)
: message_cache_(message_cache),
consume_callback_(consume_callback)
{
consumer_thread_ = std::thread(&CacheConsumer::exec_consuming, this);
}
CacheConsumer::~CacheConsumer()
{
stop();
}
void CacheConsumer::stop()
{
message_cache_->begin_flushing();
is_stop_issued_ = true;
ROSBAG2_CPP_LOG_INFO_STREAM(
"Writing remaining messages from cache to the bag. It may take a while");
if (consumer_thread_.joinable()) {
consumer_thread_.join();
}
message_cache_->done_flushing();
}
void CacheConsumer::start()
{
is_stop_issued_ = false;
if (!consumer_thread_.joinable()) {
consumer_thread_ = std::thread(&CacheConsumer::exec_consuming, this);
}
}
void CacheConsumer::exec_consuming()
{
bool exit_flag = false;
bool flushing = false;
while (!exit_flag) {
message_cache_->wait_for_data();
message_cache_->swap_buffers();
// Get the current consumer buffer.
auto consumer_buffer = message_cache_->get_consumer_buffer();
consume_callback_(consumer_buffer->data());
consumer_buffer->clear();
message_cache_->release_consumer_buffer();
if (flushing) {exit_flag = true;} // this was the final run
if (is_stop_issued_) {flushing = true;} // run one final time to flush
}
}
} // namespace cache
} // namespace rosbag2_cpp
| 26.876543 | 77 | 0.734497 | youliangtan |
3ac3f0c2fed63182b0b49f0cd779a79f7eef3b61 | 8,742 | cpp | C++ | src/frameworks/wilhelm/src/itf/IRecord.cpp | dAck2cC2/m3e | 475b89b59d5022a94e00b636438b25e27e4eaab2 | [
"Apache-2.0"
] | 3 | 2015-08-31T15:24:31.000Z | 2020-04-24T20:31:29.000Z | src/frameworks/wilhelm/src/itf/IRecord.cpp | dAck2cC2/m3e | 475b89b59d5022a94e00b636438b25e27e4eaab2 | [
"Apache-2.0"
] | null | null | null | src/frameworks/wilhelm/src/itf/IRecord.cpp | dAck2cC2/m3e | 475b89b59d5022a94e00b636438b25e27e4eaab2 | [
"Apache-2.0"
] | 3 | 2015-07-29T07:17:15.000Z | 2020-11-04T06:55:37.000Z | /*
* Copyright (C) 2010 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* Record implementation */
#include "sles_allinclusive.h"
static SLresult IRecord_SetRecordState(SLRecordItf self, SLuint32 state)
{
SL_ENTER_INTERFACE
switch (state) {
case SL_RECORDSTATE_STOPPED:
case SL_RECORDSTATE_PAUSED:
case SL_RECORDSTATE_RECORDING:
{
IRecord *thiz = (IRecord *) self;
interface_lock_exclusive(thiz);
thiz->mState = state;
#ifdef ANDROID
android_audioRecorder_setRecordState(InterfaceToCAudioRecorder(thiz), state);
#endif
interface_unlock_exclusive(thiz);
result = SL_RESULT_SUCCESS;
}
break;
default:
result = SL_RESULT_PARAMETER_INVALID;
break;
}
SL_LEAVE_INTERFACE
}
static SLresult IRecord_GetRecordState(SLRecordItf self, SLuint32 *pState)
{
SL_ENTER_INTERFACE
IRecord *thiz = (IRecord *) self;
if (NULL == pState) {
result = SL_RESULT_PARAMETER_INVALID;
} else {
interface_lock_shared(thiz);
SLuint32 state = thiz->mState;
interface_unlock_shared(thiz);
*pState = state;
result = SL_RESULT_SUCCESS;
}
SL_LEAVE_INTERFACE
}
static SLresult IRecord_SetDurationLimit(SLRecordItf self, SLmillisecond msec)
{
SL_ENTER_INTERFACE
IRecord *thiz = (IRecord *) self;
interface_lock_exclusive(thiz);
if (thiz->mDurationLimit != msec) {
thiz->mDurationLimit = msec;
interface_unlock_exclusive_attributes(thiz, ATTR_TRANSPORT);
} else {
interface_unlock_exclusive(thiz);
}
result = SL_RESULT_SUCCESS;
SL_LEAVE_INTERFACE
}
static SLresult IRecord_GetPosition(SLRecordItf self, SLmillisecond *pMsec)
{
SL_ENTER_INTERFACE
if (NULL == pMsec) {
result = SL_RESULT_PARAMETER_INVALID;
} else {
IRecord *thiz = (IRecord *) self;
SLmillisecond position;
interface_lock_shared(thiz);
#ifdef ANDROID
// Android does not use the mPosition field for audio recorders
if (SL_OBJECTID_AUDIORECORDER == InterfaceToObjectID(thiz)) {
android_audioRecorder_getPosition(InterfaceToCAudioRecorder(thiz), &position);
} else {
position = thiz->mPosition;
}
#else
position = thiz->mPosition;
#endif
interface_unlock_shared(thiz);
*pMsec = position;
result = SL_RESULT_SUCCESS;
}
SL_LEAVE_INTERFACE
}
static SLresult IRecord_RegisterCallback(SLRecordItf self, slRecordCallback callback,
void *pContext)
{
SL_ENTER_INTERFACE
IRecord *thiz = (IRecord *) self;
interface_lock_exclusive(thiz);
thiz->mCallback = callback;
thiz->mContext = pContext;
interface_unlock_exclusive(thiz);
result = SL_RESULT_SUCCESS;
SL_LEAVE_INTERFACE
}
static SLresult IRecord_SetCallbackEventsMask(SLRecordItf self, SLuint32 eventFlags)
{
SL_ENTER_INTERFACE
if (eventFlags & ~(
SL_RECORDEVENT_HEADATLIMIT |
SL_RECORDEVENT_HEADATMARKER |
SL_RECORDEVENT_HEADATNEWPOS |
SL_RECORDEVENT_HEADMOVING |
SL_RECORDEVENT_HEADSTALLED |
SL_RECORDEVENT_BUFFER_FULL)) {
result = SL_RESULT_PARAMETER_INVALID;
} else {
IRecord *thiz = (IRecord *) self;
interface_lock_exclusive(thiz);
if (thiz->mCallbackEventsMask != eventFlags) {
thiz->mCallbackEventsMask = eventFlags;
interface_unlock_exclusive_attributes(thiz, ATTR_TRANSPORT);
} else {
interface_unlock_exclusive(thiz);
}
result = SL_RESULT_SUCCESS;
}
SL_LEAVE_INTERFACE
}
static SLresult IRecord_GetCallbackEventsMask(SLRecordItf self, SLuint32 *pEventFlags)
{
SL_ENTER_INTERFACE
if (NULL == pEventFlags) {
result = SL_RESULT_PARAMETER_INVALID;
} else {
IRecord *thiz = (IRecord *) self;
interface_lock_shared(thiz);
SLuint32 callbackEventsMask = thiz->mCallbackEventsMask;
interface_unlock_shared(thiz);
*pEventFlags = callbackEventsMask;
result = SL_RESULT_SUCCESS;
}
SL_LEAVE_INTERFACE
}
static SLresult IRecord_SetMarkerPosition(SLRecordItf self, SLmillisecond mSec)
{
SL_ENTER_INTERFACE
if (SL_TIME_UNKNOWN == mSec) {
result = SL_RESULT_PARAMETER_INVALID;
} else {
IRecord *thiz = (IRecord *) self;
bool significant = false;
interface_lock_exclusive(thiz);
if (thiz->mMarkerPosition != mSec) {
thiz->mMarkerPosition = mSec;
if (thiz->mCallbackEventsMask & SL_PLAYEVENT_HEADATMARKER) {
significant = true;
}
}
if (significant) {
interface_unlock_exclusive_attributes(thiz, ATTR_TRANSPORT);
} else {
interface_unlock_exclusive(thiz);
}
result = SL_RESULT_SUCCESS;
}
SL_LEAVE_INTERFACE
}
static SLresult IRecord_ClearMarkerPosition(SLRecordItf self)
{
SL_ENTER_INTERFACE
IRecord *thiz = (IRecord *) self;
bool significant = false;
interface_lock_exclusive(thiz);
// clearing the marker position is equivalent to setting the marker to SL_TIME_UNKNOWN
if (thiz->mMarkerPosition != SL_TIME_UNKNOWN) {
thiz->mMarkerPosition = SL_TIME_UNKNOWN;
if (thiz->mCallbackEventsMask & SL_PLAYEVENT_HEADATMARKER) {
significant = true;
}
}
if (significant) {
interface_unlock_exclusive_attributes(thiz, ATTR_TRANSPORT);
} else {
interface_unlock_exclusive(thiz);
}
result = SL_RESULT_SUCCESS;
SL_LEAVE_INTERFACE
}
static SLresult IRecord_GetMarkerPosition(SLRecordItf self, SLmillisecond *pMsec)
{
SL_ENTER_INTERFACE
if (NULL == pMsec) {
result = SL_RESULT_PARAMETER_INVALID;
} else {
IRecord *thiz = (IRecord *) self;
interface_lock_shared(thiz);
SLmillisecond markerPosition = thiz->mMarkerPosition;
interface_unlock_shared(thiz);
*pMsec = markerPosition;
if (SL_TIME_UNKNOWN == markerPosition) {
result = SL_RESULT_PRECONDITIONS_VIOLATED;
} else {
result = SL_RESULT_SUCCESS;
}
}
SL_LEAVE_INTERFACE
}
static SLresult IRecord_SetPositionUpdatePeriod(SLRecordItf self, SLmillisecond mSec)
{
SL_ENTER_INTERFACE
if (0 == mSec) {
result = SL_RESULT_PARAMETER_INVALID;
} else {
IRecord *thiz = (IRecord *) self;
interface_lock_exclusive(thiz);
if (thiz->mPositionUpdatePeriod != mSec) {
thiz->mPositionUpdatePeriod = mSec;
interface_unlock_exclusive_attributes(thiz, ATTR_TRANSPORT);
} else {
interface_unlock_exclusive(thiz);
}
result = SL_RESULT_SUCCESS;
}
SL_LEAVE_INTERFACE
}
static SLresult IRecord_GetPositionUpdatePeriod(SLRecordItf self, SLmillisecond *pMsec)
{
SL_ENTER_INTERFACE
if (NULL == pMsec) {
result = SL_RESULT_PARAMETER_INVALID;
} else {
IRecord *thiz = (IRecord *) self;
interface_lock_shared(thiz);
SLmillisecond positionUpdatePeriod = thiz->mPositionUpdatePeriod;
interface_unlock_shared(thiz);
*pMsec = positionUpdatePeriod;
result = SL_RESULT_SUCCESS;
}
SL_LEAVE_INTERFACE
}
static const struct SLRecordItf_ IRecord_Itf = {
IRecord_SetRecordState,
IRecord_GetRecordState,
IRecord_SetDurationLimit,
IRecord_GetPosition,
IRecord_RegisterCallback,
IRecord_SetCallbackEventsMask,
IRecord_GetCallbackEventsMask,
IRecord_SetMarkerPosition,
IRecord_ClearMarkerPosition,
IRecord_GetMarkerPosition,
IRecord_SetPositionUpdatePeriod,
IRecord_GetPositionUpdatePeriod
};
void IRecord_init(void *self)
{
IRecord *thiz = (IRecord *) self;
thiz->mItf = &IRecord_Itf;
thiz->mState = SL_RECORDSTATE_STOPPED;
thiz->mDurationLimit = 0;
thiz->mPosition = (SLmillisecond) 0;
thiz->mCallback = NULL;
thiz->mContext = NULL;
thiz->mCallbackEventsMask = 0;
thiz->mMarkerPosition = SL_TIME_UNKNOWN;
thiz->mPositionUpdatePeriod = 1000; // per spec
}
| 26.981481 | 90 | 0.676847 | dAck2cC2 |
3ac3ffc9ebbcf65fd7f24f104a98d7264c0f13c4 | 4,302 | cpp | C++ | gtsam/discrete/tests/testDiscreteConditional.cpp | xxiao-1/gtsam | 8b1516f43ffdf6b5098fc282b566f2ee1edb50f6 | [
"BSD-3-Clause"
] | 1,402 | 2017-03-28T00:18:11.000Z | 2022-03-30T10:28:32.000Z | gtsam/discrete/tests/testDiscreteConditional.cpp | xxiao-1/gtsam | 8b1516f43ffdf6b5098fc282b566f2ee1edb50f6 | [
"BSD-3-Clause"
] | 851 | 2017-11-27T15:09:56.000Z | 2022-03-31T22:26:38.000Z | gtsam/discrete/tests/testDiscreteConditional.cpp | xxiao-1/gtsam | 8b1516f43ffdf6b5098fc282b566f2ee1edb50f6 | [
"BSD-3-Clause"
] | 565 | 2017-11-30T16:15:59.000Z | 2022-03-31T02:53:04.000Z | /* ----------------------------------------------------------------------------
* GTSAM Copyright 2010, Georgia Tech Research Corporation,
* Atlanta, Georgia 30332-0415
* All Rights Reserved
* Authors: Frank Dellaert, et al. (see THANKS for the full author list)
* See LICENSE for the license information
* -------------------------------------------------------------------------- */
/*
* @file testDecisionTreeFactor.cpp
* @brief unit tests for DiscreteConditional
* @author Duy-Nguyen Ta
* @date Feb 14, 2011
*/
#include <boost/assign/std/map.hpp>
#include <boost/assign/std/vector.hpp>
#include <boost/make_shared.hpp>
using namespace boost::assign;
#include <CppUnitLite/TestHarness.h>
#include <gtsam/discrete/DecisionTreeFactor.h>
#include <gtsam/discrete/DiscreteConditional.h>
using namespace std;
using namespace gtsam;
/* ************************************************************************* */
TEST( DiscreteConditional, constructors)
{
DiscreteKey X(0, 2), Y(2, 3), Z(1, 2); // watch ordering !
DiscreteConditional::shared_ptr expected1 = //
boost::make_shared<DiscreteConditional>(X | Y = "1/1 2/3 1/4");
EXPECT(expected1);
EXPECT_LONGS_EQUAL(0, *(expected1->beginFrontals()));
EXPECT_LONGS_EQUAL(2, *(expected1->beginParents()));
EXPECT(expected1->endParents() == expected1->end());
EXPECT(expected1->endFrontals() == expected1->beginParents());
DecisionTreeFactor f1(X & Y, "0.5 0.4 0.2 0.5 0.6 0.8");
DiscreteConditional actual1(1, f1);
EXPECT(assert_equal(*expected1, actual1, 1e-9));
DecisionTreeFactor f2(X & Y & Z,
"0.2 0.5 0.3 0.6 0.4 0.7 0.25 0.55 0.35 0.65 0.45 0.75");
DiscreteConditional actual2(1, f2);
EXPECT(assert_equal(f2 / *f2.sum(1), *actual2.toFactor(), 1e-9));
}
/* ************************************************************************* */
TEST(DiscreteConditional, constructors_alt_interface) {
DiscreteKey X(0, 2), Y(2, 3), Z(1, 2); // watch ordering !
Signature::Table table;
Signature::Row r1, r2, r3;
r1 += 1.0, 1.0;
r2 += 2.0, 3.0;
r3 += 1.0, 4.0;
table += r1, r2, r3;
auto actual1 = boost::make_shared<DiscreteConditional>(X | Y = table);
EXPECT(actual1);
DecisionTreeFactor f1(X & Y, "0.5 0.4 0.2 0.5 0.6 0.8");
DiscreteConditional expected1(1, f1);
EXPECT(assert_equal(expected1, *actual1, 1e-9));
DecisionTreeFactor f2(
X & Y & Z, "0.2 0.5 0.3 0.6 0.4 0.7 0.25 0.55 0.35 0.65 0.45 0.75");
DiscreteConditional actual2(1, f2);
EXPECT(assert_equal(f2 / *f2.sum(1), *actual2.toFactor(), 1e-9));
}
/* ************************************************************************* */
TEST(DiscreteConditional, constructors2) {
// Declare keys and ordering
DiscreteKey C(0, 2), B(1, 2);
DecisionTreeFactor actual(C & B, "0.8 0.75 0.2 0.25");
Signature signature((C | B) = "4/1 3/1");
DiscreteConditional expected(signature);
DecisionTreeFactor::shared_ptr expectedFactor = expected.toFactor();
EXPECT(assert_equal(*expectedFactor, actual));
}
/* ************************************************************************* */
TEST(DiscreteConditional, constructors3) {
// Declare keys and ordering
DiscreteKey C(0, 2), B(1, 2), A(2, 2);
DecisionTreeFactor actual(C & B & A, "0.8 0.5 0.5 0.2 0.2 0.5 0.5 0.8");
Signature signature((C | B, A) = "4/1 1/1 1/1 1/4");
DiscreteConditional expected(signature);
DecisionTreeFactor::shared_ptr expectedFactor = expected.toFactor();
EXPECT(assert_equal(*expectedFactor, actual));
}
/* ************************************************************************* */
TEST(DiscreteConditional, Combine) {
DiscreteKey A(0, 2), B(1, 2);
vector<DiscreteConditional::shared_ptr> c;
c.push_back(boost::make_shared<DiscreteConditional>(A | B = "1/2 2/1"));
c.push_back(boost::make_shared<DiscreteConditional>(B % "1/2"));
DecisionTreeFactor factor(A & B, "0.111111 0.444444 0.222222 0.222222");
DiscreteConditional actual(2, factor);
auto expected = DiscreteConditional::Combine(c.begin(), c.end());
EXPECT(assert_equal(*expected, actual, 1e-5));
}
/* ************************************************************************* */
int main() {
TestResult tr;
return TestRegistry::runAllTests(tr);
}
/* ************************************************************************* */
| 37.086207 | 80 | 0.574152 | xxiao-1 |
3ac49573cdbed32e06553d8e384dfac8e470d59c | 2,063 | cpp | C++ | torch/inference/ptb_lm_torch.cpp | Joejiong/Inference_benchmark | eb208e8f80b124e99a4f9461a6db2106ec857f62 | [
"Apache-2.0"
] | null | null | null | torch/inference/ptb_lm_torch.cpp | Joejiong/Inference_benchmark | eb208e8f80b124e99a4f9461a6db2106ec857f62 | [
"Apache-2.0"
] | null | null | null | torch/inference/ptb_lm_torch.cpp | Joejiong/Inference_benchmark | eb208e8f80b124e99a4f9461a6db2106ec857f62 | [
"Apache-2.0"
] | null | null | null | #include <torch/script.h> // One-stop header.
#include <torch/torch.h>
#include <chrono>
#include <iostream>
#include <memory>
using Time = decltype(std::chrono::high_resolution_clock::now());
Time time() {return std::chrono::high_resolution_clock::now();};
double
time_diff(Time t1, Time t2)
{
typedef std::chrono::microseconds ms;
auto diff = t2 - t1;
ms counter = std::chrono::duration_cast<ms>(diff);
return counter.count() / 1000.0;
}
bool
test_predictor_latency(const char* argv[])
{
auto model_path = argv[1];
int batch_size = 64;
int repeat = 100;
bool use_gpu = true;
torch::Device device = torch::kCPU;
if (torch::cuda::is_available() && use_gpu){
std::cout << "CUDA is available, running on GPU" << std::endl;
device = torch::Device("cuda:5");
}
std::cout << "start to load model from " << argv[1] << std::endl;
torch::jit::script::Module module = torch::jit::load(argv[1]);
module.to(device);
std::cout << "create input tensor..." << std::endl;
// Create a vector of inputs.
std::vector<torch::jit::IValue> inputs;
inputs.push_back(torch::ones({20, batch_size}, at::kLong).to(device));
inputs.push_back(torch::ones({20, batch_size, 200}).to(device));
inputs.push_back(torch::ones({20, batch_size, 200}).to(device));
// warmup
std::cout << "warm up..." << std::endl;
auto output = module.forward(inputs);
std::cout << "start to inference..." << std::endl;
Time time1 = time();
for(int i=0; i < repeat; ++i){
auto output = module.forward(inputs);
}
auto time2 = time();
std::cout << "repeat time: " << repeat << " , model: " << model_path << std::endl;
std::cout << "batch: " << batch_size << " , predict cost: " << time_diff(time1, time2) / static_cast<float>(repeat) << " ms." << std::endl;
}
int main(int argc, const char* argv[]) {
if (argc < 2) {
std::cerr << "usage: ./exe model_dir_name\n";
return -1;
}
test_predictor_latency(argv);
}
| 29.898551 | 143 | 0.600582 | Joejiong |
3ac52abc9531315ab99458ea582d5ea35e025d9f | 12,580 | hpp | C++ | src/xpcc/architecture/platform/driver/adc/lpc/adc.hpp | roboterclubaachen/xpcc | 010924901947381d20e83b838502880eb2ffea72 | [
"BSD-3-Clause"
] | 161 | 2015-01-13T15:52:06.000Z | 2020-02-13T01:26:04.000Z | src/xpcc/architecture/platform/driver/adc/lpc/adc.hpp | salkinium/xpcc | 010924901947381d20e83b838502880eb2ffea72 | [
"BSD-3-Clause"
] | 281 | 2015-01-06T12:46:40.000Z | 2019-01-06T13:06:57.000Z | src/xpcc/architecture/platform/driver/adc/lpc/adc.hpp | salkinium/xpcc | 010924901947381d20e83b838502880eb2ffea72 | [
"BSD-3-Clause"
] | 51 | 2015-03-03T19:56:12.000Z | 2020-03-22T02:13:36.000Z | #ifndef XPCC_LPC111X__ADC_HPP
#define XPCC_LPC111X__ADC_HPP
#include "../device.h"
/* ---------- ADC Data Register bit names --------------------*/
#define ADC_GDR_DONE (1 << 31)
#define ADC_DR_DONE ADC_GDR_DONE
/* ---------- ADC Control Register bit names ------------------*/
#define ADC_CR_SEL_MASK (0xff << 0) ///< Mask for deleting Channel selection
#define ADC_CR_BURST ( 1 << 16) ///< Burst mode
#define ADC_CR_START_NOW (0x1 << 24) ///< Manually start a conversion now
#define ADC_CR_START_PIO0_2 (0x2 << 24) ///< Start conversion whenever the selected edge on PIO0_2 occurs
#define ADC_CR_START_PIO1_5 (0x3 << 24) ///< Start conversion whenever the selected edge on PIO1_5 occurs
#define ADC_CR_START_CT32B0_MAT0 (0x4 << 24) ///< Start conversion whenever the selected edge on CT32B0_MAT0 occurs (timer match)
#define ADC_CR_START_CT32B0_MAT1 (0x5 << 24) ///< Start conversion whenever the selected edge on CT32B0_MAT1 occurs (timer match)
#define ADC_CR_START_CT16B0_MAT0 (0x6 << 24) ///< Start conversion whenever the selected edge on CT16B0_MAT0 occurs (timer match)
#define ADC_CR_START_CT16B0_MAT1 (0x7 << 24) ///< Start conversion whenever the selected edge on CT16B0_MAT1 occurs (timer match)
#define ADC_CR_EDGE_RISING ( 0 << 27) ///< Start conversion whenever a rising edge occurs
#define ADC_CR_EDGE_FALLING ( 1 << 27) ///< Start conversion whenever a falling edge occurs
#define ADC_CR_START_EDGE_MASK ADC_CR_START_CT16B0_MAT1 | ADC_CR_EDGE_FALLING
/* ---------- ADC Status Register bit names -------------------*/
#define ADC_STAT_DONE_MASK ( 0xff) ///< Individual DONE flags for channels 7 to 0.
/* ---------- ADC INterrtup Enable Register bit names ---------*/
#define ADC_INTEN_ADGINTEN ( 1 << 8) ///< Interrupt when global DONE is 1
/* ---------- Power-down configuration register bit names -----*/
#define PDRUNCFG_ADC_PD (1 << 4)
/* ---------- System AHB clock control register bit names -----*/
#define SYSAHBCLKCTRL_ADC (1 << 13)
#define ADC_OFFSET 0x10
#define ADC_INDEX 4
namespace xpcc
{
namespace lpc
{
/**
* \brief Analog-to-Digital Converter Module of
* LPC111x, LPC11D14 and LPC11Cxx parts.
*
* Two usage scenarios where considered when designing this class:
*
* 1) Manual control: Single Channel, Single Shot
* From a given set of channels a conversion can be started
* manually and the result is fetched after waiting for the
* ADC to finish this single channel. The ADC stops after
* this sample automatically.
* When using timers or external pins as a start condition repeated
* conversion can be achieved.
*
* 2) Automatic mode: Multiple Channels, automatic repeat
* Some channels are selected to be sampled automatically.
* The latest result can be fetched by polling or an interrupt
* handler can be installed.
*
* Whats not possible by hardware: convert multiple channels
* triggered by a timer. When triggered by a timer only a single
* channel (BURST = 0) can be selected.
*
* AD4 is not supported because the pin is used by the Serial Wire
* Debug interface.
*
* TOOD:
* - Overrun flag support
* - Enable/Disable/Test Interrupts
* - Clock setting depending on the CPU frequency. 48 MHz is used now.
*/
class Adc
{
public:
/**
* \brief Channels which can be used as ADC input.
*
* You can specify the channel by using a pin-name, like PIO0_11
* or just the plain channel number, like CHANNEL_0.
*
* ChannelMask corresponds directly to the bitmask in the ADC module
* Channel can be casted to and from an integer.
*
*/
enum class ChannelMask
{
PIO0_11 = 0x01,
PIO1_0 = 0x02,
PIO1_1 = 0x04,
PIO1_2 = 0x08,
// PIO1_3 = 0x10,
PIO1_4 = 0x20,
PIO1_10 = 0x40,
PIO1_11 = 0x80,
CHANNEL_0 = 0x01,
CHANNEL_1 = 0x02,
CHANNEL_2 = 0x04,
CHANNEL_3 = 0x08,
// CHANNEL_4 = 0x10,
CHANNEL_5 = 0x20,
CHANNEL_6 = 0x40,
CHANNEL_7 = 0x80,
};
enum class Channel
{
PIO0_11 = 0,
PIO1_0 = 1,
PIO1_1 = 2,
PIO1_2 = 3,
// PIO1_3 = 4,
PIO1_4 = 5,
PIO1_10 = 6,
PIO1_11 = 7,
CHANNEL_0 = 0,
CHANNEL_1 = 1,
CHANNEL_2 = 2,
CHANNEL_3 = 3,
// CHANNEL_4 = 4,
CHANNEL_5 = 5,
CHANNEL_6 = 6,
CHANNEL_7 = 7,
};
/**
* \brief Configure the selected channels as analog input.
*
* \param channelBitmask Select which channels are configured
* by a bitmask. The corresponding IO pins
* are changed to analog mode.
*/
static void inline
configurePins(uint8_t channelBitmask = 0xff)
{
if (channelBitmask & 0x01) {
LPC_IOCON->R_PIO0_11 = 0x02; /* ADC IN0 */
}
if (channelBitmask & 0x02) {
LPC_IOCON->R_PIO1_0 = 0x02; /* ADC IN1 */
}
if (channelBitmask & 0x04) {
LPC_IOCON->R_PIO1_1 = 0x02; /* ADC IN2 */
}
if (channelBitmask & 0x08) {
LPC_IOCON->R_PIO1_2 = 0x02; /* ADC IN3 */
}
// if (channelBitmask & 0x10) {}
if (channelBitmask & 0x20) {
LPC_IOCON->PIO1_4 = 0x01; // Select AD5 pin function
}
if (channelBitmask & 0x40) {
LPC_IOCON->PIO1_10 = 0x01; // Select AD6 pin function
}
if (channelBitmask & 0x80) {
LPC_IOCON->PIO1_11 = 0x01; // Select AD7 pin function
}
}
protected:
/**
* \brief Read a ADC data register. Clears DONE and OVERRUN flags.
*/
static inline uint32_t
getAdcRegister(Channel channel)
{
return (*(volatile unsigned long *)
(LPC_ADC_BASE + ADC_OFFSET + ADC_INDEX * static_cast<uint8_t>(channel)));
}
};
/**
* \brief Implementation of the Manual Single Mode.
*
* Use all the common features from Adc class.
*/
class AdcManualSingle : public Adc
{
public:
/**
* \brief Start condition of the ADC.
*
* Only in software controlled mode a start condition can be given.
* If the conversion is started manually with START_NOW only one
* conversion is made.
* If a hardware source as a start condition is selected repeated
* samples can be generated if this condition appears regularly
* (e.g. repeated timer match)
*/
enum class StartCondition
{
START_NOW = ADC_CR_START_NOW, ///< Manually start a conversion now
START_PIO0_2 = ADC_CR_START_PIO0_2, ///< Start conversion whenever the selected edge on PIO0_2 occurs
START_PIO1_5 = ADC_CR_START_PIO1_5, ///< Start conversion whenever the selected edge on PIO1_5 occurs
START_CT32B0_MAT0 = ADC_CR_START_CT32B0_MAT0, ///< Start conversion whenever the selected edge on CT32B0_MAT0 occurs (timer match)
START_CT32B0_MAT1 = ADC_CR_START_CT32B0_MAT1, ///< Start conversion whenever the selected edge on CT32B0_MAT1 occurs (timer match)
START_CT16B0_MAT0 = ADC_CR_START_CT16B0_MAT0, ///< Start conversion whenever the selected edge on CT16B0_MAT0 occurs (timer match)
START_CT16B0_MAT1 = ADC_CR_START_CT16B0_MAT1, ///< Start conversion whenever the selected edge on CT16B0_MAT1 occurs (timer match)
};
enum class StartEdge
{
RISING = ADC_CR_EDGE_RISING,
FALLING = ADC_CR_EDGE_FALLING,
};
/**
* \brief Initialise the ADC block in Manual Single Mode.
*/
static void inline
initialize()
{
/* Disable Power down bit to the ADC block. */
LPC_SYSCON->PDRUNCFG &= ~(PDRUNCFG_ADC_PD);
/* Enable AHB clock to the ADC. */
LPC_SYSCON->SYSAHBCLKCTRL |= SYSAHBCLKCTRL_ADC;
/* Set clock: 48 MHz / (10 + 1) = 4.36 MHz < 4.5 MHz */
LPC_ADC->CR = (10 << 8);
}
/**
* \brief Start a single conversion of the single selected channel.
*/
static inline void
startConversion(
ChannelMask channelMask,
StartCondition startCondition = StartCondition::START_NOW,
StartEdge startEdge = StartEdge::RISING)
{
// clear and then select channel bits
LPC_ADC->CR &= ~(ADC_CR_SEL_MASK | ADC_CR_START_EDGE_MASK);
LPC_ADC->CR |=
static_cast<uint32_t>(startCondition) |
static_cast<uint32_t>(startEdge) |
static_cast<uint32_t>(channelMask);
}
/**
* \brief Check if the conversion is finished.
*/
static inline bool
isConversionFinished(void)
{
return (LPC_ADC->GDR & ADC_GDR_DONE);
}
/**
* \brief Get the latest value from the ADC from the global data register
*/
static inline uint16_t
getValue()
{
// Result is left adjusted to a 16 bit boundary
// Convert to right adjusted value.
return ((LPC_ADC->GDR & 0xffff) >> 6);
}
/**
* \brief Get the latest value from the ADC from the channel register. Clear the interrupt flag.
*/
static inline uint16_t
getValue(Channel channel)
{
return ((getAdcRegister(channel) & 0xffff) >> 6);
}
static inline bool
read(uint16_t & val)
{
if (isConversionFinished()) {
val = getValue();
return true;
}
else {
return false;
}
}
/**
* Clear the interrupt flag of the given channel.
*/
static inline void
clearInterruptFlag(Channel channel)
{
// just read to clear flag
getAdcRegister(channel);
}
};
/**
* \brief Converting multiple channels in free running mode
*/
class AdcAutomaticBurst : public Adc
{
public:
/**
* \brief Resolution of the successive-approximation ADC.
*/
enum class Resolution
{
BITS_10 = (0x0 << 17), ///< 11 clocks / 10 bits
BITS_9 = (0x1 << 17), ///< 10 clocks / 9 bits
BITS_8 = (0x2 << 17), ///< 9 clocks / 8 bits
BITS_7 = (0x3 << 17), ///< 8 clocks / 7 bits
BITS_6 = (0x4 << 17), ///< 7 clocks / 6 bits
BITS_5 = (0x5 << 17), ///< 6 clocks / 5 bits
BITS_4 = (0x6 << 17), ///< 5 clocks / 4 bits
BITS_3 = (0x7 << 17), ///< 4 clocks / 3 bits
};
/**
* \brief Initialise the ADC module in free running mode.
*
* \param resolution More bits mean lower conversion rate.
*/
static inline void
initialize (Resolution resolution = Resolution::BITS_10)
{
/* Disable Power down bit to the ADC block. */
LPC_SYSCON->PDRUNCFG &= ~(PDRUNCFG_ADC_PD);
/* Enable AHB clock to the ADC. */
LPC_SYSCON->SYSAHBCLKCTRL |= SYSAHBCLKCTRL_ADC;
/* Disable ADGINTEN in INTEN */
LPC_ADC->INTEN &= ~ADC_INTEN_ADGINTEN;
/* Set clock and resolution */
LPC_ADC->CR = (static_cast<uint32_t>(resolution)) | (10 << 8);
/* Enable interrupts */
NVIC_EnableIRQ(ADC_IRQn);
}
/**
* \brief Start a conversion of the selected channel(s).
*
* The conversion is repeated automatically.
* When using interrupts it may be a good idea to set only on bit in the
* interruptMask to generate an interrupt when all channels are converted once.
*
* \param channelMask Bitmask of the channels that should be converted
* \param interruptMask Bitmask of channels that will generate an interrupt.
*/
static inline void
startConversion(uint8_t channelMask, uint8_t interruptMask = 0)
{
// clear and then set the interrupt Mask, ADGINEN is cleared, too.
LPC_ADC->INTEN = 0;
LPC_ADC->INTEN = interruptMask;
// clear and then select channel bits
LPC_ADC->CR &= ~(ADC_CR_SEL_MASK | ADC_CR_START_EDGE_MASK);
LPC_ADC->CR |= channelMask;
// Set burst to start conversion now.
LPC_ADC->CR |= ADC_CR_BURST;
}
/**
* \brief Check if a single channel has finished
*/
static inline bool
isConversionFinished(Channel channel)
{
return (getAdcRegister(channel) & ADC_DR_DONE);
}
/**
* \brief Check if a group of channels have finished.
*
* Can be used for a single channel too if the ChannelMask is known.
*/
static inline bool
isConversionFinished(uint8_t channelMask)
{
return ((LPC_ADC->STAT & ADC_STAT_DONE_MASK) & channelMask);
}
/**
* \brief Get the value of a single channel. Check before if result is ready.
*/
static inline uint16_t
getValue(Channel channel)
{
return ((getAdcRegister(channel) & 0xffff) >> 6);
}
/**
* \brief Returns true if the value is ready and puts it into the variable.
*/
static inline bool
read(uint16_t & val, Channel channel)
{
uint32_t reg = getAdcRegister(channel);
if (reg & ADC_DR_DONE) {
val = (reg & 0xffff) >> 6;
return true;
}
else {
return false;
}
}
};
} // namespace lpc
}
#endif // XPCC_LPC111X__ADC_HPP
| 30.167866 | 134 | 0.64372 | roboterclubaachen |
3ac5f4c99e4f14bbff71d760129abf7f22f09de3 | 147 | cpp | C++ | assets/listings/item42-2.cpp | feserr/ResumenEffectiveCpp | 8c535b2c9acc53fc117d38e35e1dd2cb7c8750fc | [
"BSD-2-Clause"
] | null | null | null | assets/listings/item42-2.cpp | feserr/ResumenEffectiveCpp | 8c535b2c9acc53fc117d38e35e1dd2cb7c8750fc | [
"BSD-2-Clause"
] | null | null | null | assets/listings/item42-2.cpp | feserr/ResumenEffectiveCpp | 8c535b2c9acc53fc117d38e35e1dd2cb7c8750fc | [
"BSD-2-Clause"
] | null | null | null | template<typename C>
void print2nd(const C& container) {
if (container.size() > 2) {
C::const_iterator iter(container.begin());
...
}
} | 21 | 46 | 0.632653 | feserr |
3ac637de6c0ff0e9fef3fe12e8118a0cca33519a | 10,305 | cpp | C++ | src/renderer/src/SimpleRenderModeFactory.cpp | Ashimaru/narnia_engine | 66419b9e19a05546616b4450b12cb5f426dd6be7 | [
"MIT"
] | null | null | null | src/renderer/src/SimpleRenderModeFactory.cpp | Ashimaru/narnia_engine | 66419b9e19a05546616b4450b12cb5f426dd6be7 | [
"MIT"
] | null | null | null | src/renderer/src/SimpleRenderModeFactory.cpp | Ashimaru/narnia_engine | 66419b9e19a05546616b4450b12cb5f426dd6be7 | [
"MIT"
] | null | null | null | #include "SimpleRenderModeFactory.h"
#include "LoggerAPI.h"
#include "Vertex.h"
#include <array>
#include <cassert>
using std::array;
SimpleRenderModeFactory::SimpleRenderModeFactory(GPUPtr &gpu, const ScenePtr &scene) :
m_gpu(gpu),
m_scene(scene)
{
}
SimpleRenderMode SimpleRenderModeFactory::createRenderMode(vk::Format swapchainFormat, vk::Extent2D extent, const std::vector<vk::PipelineShaderStageCreateInfo> &shaders)
{
bool succeed = createRenderPass(swapchainFormat);
assert(succeed);
createPipelineLayout();
auto viewport = vk::Viewport();
viewport.setWidth((float)extent.width);
viewport.setHeight((float)extent.height);
viewport.setX(0);
viewport.setY(0);
viewport.setMinDepth(0.0f);
viewport.setMaxDepth(1.0f);
auto scissors = vk::Rect2D();
scissors.setOffset({ 0,0 });
scissors.setExtent(extent);
succeed = createPipeline(shaders, viewport, scissors);
assert(succeed);
succeed = createSwapchain(extent);
assert(succeed);
createCommandPool();
recordCommandBuffers();
return m_result;
}
void SimpleRenderModeFactory::recordCommandBuffers()
{
m_result.commandBuffers.resize(m_result.swapchainFramebuffers.size());
auto commandBufferAllocInfo = vk::CommandBufferAllocateInfo();
commandBufferAllocInfo.setCommandBufferCount(static_cast<uint32_t>(m_result.commandBuffers.size()));
commandBufferAllocInfo.setCommandPool(m_result.commandPool);
commandBufferAllocInfo.setLevel(vk::CommandBufferLevel::ePrimary);
m_gpu->createCommandBuffers(commandBufferAllocInfo, m_result.commandBuffers.data());
for (size_t i = 0; i < m_result.commandBuffers.size(); ++i)
{
auto beginInfo = vk::CommandBufferBeginInfo();
beginInfo.setFlags(vk::CommandBufferUsageFlagBits::eSimultaneousUse);
if (vk::Result::eSuccess != m_result.commandBuffers[i].begin(&beginInfo))
{
LoggerAPI::getLogger()->logCritical("Could not begin record command buffer");
}
auto renderPassBeginInfo = vk::RenderPassBeginInfo();
renderPassBeginInfo.setRenderPass(m_result.renderPass);
renderPassBeginInfo.setFramebuffer(m_result.swapchainFramebuffers[i]);
auto renderArea = vk::Rect2D({ 0,0 }, m_gpu->getPresentationExtent());
renderPassBeginInfo.setRenderArea(renderArea);
renderPassBeginInfo.setClearValueCount(1);
vk::ClearValue clearValues[] = { 0.0, 0.0, 0.0, 1.0 };
renderPassBeginInfo.setPClearValues(clearValues);
m_result.commandBuffers[i].beginRenderPass(renderPassBeginInfo, vk::SubpassContents::eInline);
m_result.commandBuffers[i].bindPipeline(vk::PipelineBindPoint::eGraphics, m_result.pipeline);
for (const auto &ro : m_scene->renderableObjects)
{
vk::DeviceSize offset[] = { 0 };
m_result.commandBuffers[i].bindVertexBuffers(0, 1, &ro->sharedBuffer, offset);
m_result.commandBuffers[i].bindIndexBuffer(ro->sharedBuffer, ro->vertexOffset, vk::IndexType::eUint32);
m_result.commandBuffers[i].drawIndexed(ro->indexCount, 1, 0, 0, 0);
}
m_result.commandBuffers[i].endRenderPass();
m_result.commandBuffers[i].end();
}
}
bool SimpleRenderModeFactory::createRenderPass(vk::Format swapchainFormat)
{
auto colorAttachment = vk::AttachmentDescription();
colorAttachment.setFormat(swapchainFormat);
colorAttachment.setSamples(vk::SampleCountFlagBits::e1);
colorAttachment.setLoadOp(vk::AttachmentLoadOp::eClear);
colorAttachment.setStoreOp(vk::AttachmentStoreOp::eStore);
colorAttachment.setStencilLoadOp(vk::AttachmentLoadOp::eDontCare);
colorAttachment.setStencilStoreOp(vk::AttachmentStoreOp::eDontCare);
colorAttachment.setInitialLayout(vk::ImageLayout::eUndefined);
colorAttachment.setFinalLayout(vk::ImageLayout::ePresentSrcKHR);
auto attatchmentRef = vk::AttachmentReference();
attatchmentRef.setAttachment(0);
attatchmentRef.setLayout(vk::ImageLayout::eColorAttachmentOptimal);
auto subpassDesc = vk::SubpassDescription();
subpassDesc.setPipelineBindPoint(vk::PipelineBindPoint::eGraphics);
subpassDesc.setColorAttachmentCount(1);
subpassDesc.setPColorAttachments(&attatchmentRef);
auto subpassDependency = vk::SubpassDependency();
subpassDependency.setSrcSubpass(VK_SUBPASS_EXTERNAL);
subpassDependency.setDstSubpass(0);
subpassDependency.setSrcStageMask(vk::PipelineStageFlags(vk::PipelineStageFlagBits::eColorAttachmentOutput));
subpassDependency.setSrcAccessMask(vk::AccessFlags(0));
subpassDependency.setDstStageMask(vk::PipelineStageFlags(vk::PipelineStageFlagBits::eColorAttachmentOutput));
subpassDependency.setDstAccessMask(vk::AccessFlags(vk::AccessFlagBits::eColorAttachmentRead | vk::AccessFlagBits::eColorAttachmentWrite));
auto renderPassInfo = vk::RenderPassCreateInfo();
renderPassInfo.setSubpassCount(1);
renderPassInfo.setPSubpasses(&subpassDesc);
renderPassInfo.setAttachmentCount(1);
renderPassInfo.setPAttachments(&colorAttachment);
renderPassInfo.setDependencyCount(1);
renderPassInfo.setPDependencies(&subpassDependency);
m_gpu->createRenderPass(renderPassInfo, m_result.renderPass);
return true;
}
void SimpleRenderModeFactory::createPipelineLayout()
{
auto layoutCreateInfo = vk::PipelineLayoutCreateInfo();
layoutCreateInfo.setSetLayoutCount(0);
layoutCreateInfo.setPushConstantRangeCount(0);
m_gpu->createPipelineLayout(layoutCreateInfo, m_result.pipelineLayout);
}
bool SimpleRenderModeFactory::createPipeline(const std::vector<vk::PipelineShaderStageCreateInfo> &shaders, const vk::Viewport &viewport, const vk::Rect2D &scissors)
{
auto pipelineCreateInfo = vk::GraphicsPipelineCreateInfo();
pipelineCreateInfo.setStageCount(static_cast<uint32_t>(shaders.size()));
pipelineCreateInfo.setPStages(shaders.data());
auto bindingDescription = new vk::VertexInputBindingDescription();
bindingDescription->setBinding(0);
bindingDescription->setInputRate(vk::VertexInputRate::eVertex);
bindingDescription->setStride(sizeof(Vertex));
auto attributeDescriptions = array<vk::VertexInputAttributeDescription, 2>();
attributeDescriptions.at(0).setBinding(0);
attributeDescriptions.at(0).setFormat(vk::Format::eR32G32B32Sfloat);
attributeDescriptions.at(0).setLocation(0);
attributeDescriptions.at(0).setOffset(offsetof(Vertex, Vertex::postion));
attributeDescriptions.at(1).setBinding(0);
attributeDescriptions.at(1).setFormat(vk::Format::eR32G32B32A32Sfloat);
attributeDescriptions.at(1).setLocation(1);
attributeDescriptions.at(1).setOffset(offsetof(Vertex, Vertex::color));
auto vertexInputState = vk::PipelineVertexInputStateCreateInfo();
vertexInputState.setPVertexAttributeDescriptions(attributeDescriptions.data());
vertexInputState.setPVertexBindingDescriptions(bindingDescription);
vertexInputState.setVertexAttributeDescriptionCount(static_cast<uint32_t>(attributeDescriptions.size()));
vertexInputState.setVertexBindingDescriptionCount(1);
pipelineCreateInfo.setPVertexInputState(&vertexInputState);
auto inputAssemblyState = vk::PipelineInputAssemblyStateCreateInfo();
inputAssemblyState.setTopology(vk::PrimitiveTopology::eTriangleList);
inputAssemblyState.setPrimitiveRestartEnable(false);
pipelineCreateInfo.setPInputAssemblyState(&inputAssemblyState);
auto viewportState = vk::PipelineViewportStateCreateInfo();
viewportState.setViewportCount(1);
viewportState.setScissorCount(1);
viewportState.setPScissors(&scissors);
viewportState.setPViewports(&viewport);
pipelineCreateInfo.setPViewportState(&viewportState);
auto rasteizerState = vk::PipelineRasterizationStateCreateInfo();
rasteizerState.setDepthClampEnable(false);
rasteizerState.setRasterizerDiscardEnable(false);
rasteizerState.setPolygonMode(vk::PolygonMode::eFill);
rasteizerState.setLineWidth(1.0f);
rasteizerState.setCullMode(vk::CullModeFlagBits::eBack);
rasteizerState.setFrontFace(vk::FrontFace::eClockwise);
rasteizerState.setDepthBiasEnable(false);
pipelineCreateInfo.setPRasterizationState(&rasteizerState);
auto multisampleState = vk::PipelineMultisampleStateCreateInfo();
multisampleState.setSampleShadingEnable(false);
multisampleState.setRasterizationSamples(vk::SampleCountFlagBits::e1);
pipelineCreateInfo.setPMultisampleState(&multisampleState);
pipelineCreateInfo.setPDepthStencilState(nullptr);
auto attachState = vk::PipelineColorBlendAttachmentState();
attachState.setColorWriteMask(vk::ColorComponentFlags(vk::ColorComponentFlagBits::eR | vk::ColorComponentFlagBits::eG |
vk::ColorComponentFlagBits::eB | vk::ColorComponentFlagBits::eA));
attachState.setBlendEnable(false);
attachState.setSrcAlphaBlendFactor(vk::BlendFactor::eOne);
attachState.setDstAlphaBlendFactor(vk::BlendFactor::eZero);
attachState.setColorBlendOp(vk::BlendOp::eAdd);
attachState.setAlphaBlendOp(vk::BlendOp::eAdd);
auto colorBlendState = vk::PipelineColorBlendStateCreateInfo();
colorBlendState.setLogicOpEnable(false);
colorBlendState.setLogicOp(vk::LogicOp::eCopy);
colorBlendState.setBlendConstants({ 0.0f, 0.0f, 0.0f, 0.0f });
colorBlendState.setAttachmentCount(1);
colorBlendState.setPAttachments(&attachState);
pipelineCreateInfo.setPColorBlendState(&colorBlendState);
pipelineCreateInfo.setPDynamicState(nullptr); //not supported
pipelineCreateInfo.setLayout(m_result.pipelineLayout);
pipelineCreateInfo.setRenderPass(m_result.renderPass);
pipelineCreateInfo.setSubpass(0);
m_gpu->createPipeline(pipelineCreateInfo, m_result.pipeline);
return true;
}
bool SimpleRenderModeFactory::createSwapchain(vk::Extent2D extent)
{
m_result.swapchainFramebuffers.resize(m_gpu->getSwapchainImagesCount());
for (int i = 0; i < m_result.swapchainFramebuffers.size(); ++i)
{
auto createInfo = vk::FramebufferCreateInfo();
createInfo.setRenderPass(m_result.renderPass);
createInfo.setAttachmentCount(1);
createInfo.setWidth(extent.width);
createInfo.setHeight(extent.height);
createInfo.setLayers(1);
m_gpu->createFramebuffer(createInfo, i, m_result.swapchainFramebuffers[i]);
}
return true;
}
void SimpleRenderModeFactory::createCommandPool()
{
m_gpu->createGraphicsCommandPool(m_result.commandPool);
}
bool createCommandBuffers()
{
return false;
}
bool createSyncObjects()
{
return false;
}
| 36.803571 | 171 | 0.787579 | Ashimaru |
3ac652eda4f48a1019464c983ff25cd02ef7cc8f | 1,522 | cpp | C++ | src/tracker/src/track.cpp | apennisi/mctracker | 29a89046f796f84eac922b2dc9cf4cd6c7aebb6b | [
"MIT"
] | 16 | 2019-08-04T04:29:12.000Z | 2022-03-07T02:18:49.000Z | src/tracker/src/track.cpp | apennisi/mctracker | 29a89046f796f84eac922b2dc9cf4cd6c7aebb6b | [
"MIT"
] | 3 | 2020-06-03T02:15:08.000Z | 2021-01-07T03:31:10.000Z | src/tracker/src/track.cpp | apennisi/mctracker | 29a89046f796f84eac922b2dc9cf4cd6c7aebb6b | [
"MIT"
] | 1 | 2021-01-06T03:33:05.000Z | 2021-01-06T03:33:05.000Z | #include "track.h"
using namespace mctracker::tracker;
Track
::Track(const float& _x, const float& _y, const KalmanParam& _param, const cv::Mat& h, const int cameraNum)
: Entity(), hist(h)
{
kf = std::shared_ptr<KalmanFilter>(new KalmanFilter(_x, _y, _param.getDt()));
ntimes_propagated = 0;
freezed = 0;
ntime_missed = 0;
isgood = false;
m_label = -1;
time = (double)cv::getTickCount();
sizes.resize(cameraNum);
}
const cv::Mat
Track::update()
{
if(points.size() > 0)
{
cv::Point2f result(0,0);
for(const auto& p : points)
{
result += p;
}
const auto& correction = correct(result.x, result.y);
points.clear();
return correction;
}
ntime_missed++;
return cv::Mat();
}
const cv::Mat
Track::predict()
{
const auto& prediction = kf->predict();
m_history.push_back(cv::Point2f(prediction.at<float>(0), prediction.at<float>(1)));
checkHistory();
return prediction;
}
const cv::Mat
Track::correct(const float& _x, const float& _y)
{
ntimes_propagated++;
time_in_sec = ((double) cv::getTickCount() - time) / cv::getTickFrequency();
return kf->correct(_x, _y);
}
const cv::Point2f
Track::getPoint()
{
const auto& prediction = kf->getPrediction();
return cv::Point2f(prediction.at<float>(0), prediction.at<float>(1));
}
const std::string
Track::label2string()
{
std::stringstream ss;
ss << m_label;
return ss.str();
}
| 21.138889 | 108 | 0.604468 | apennisi |
3ac797c7ee8a0f28d17a4cc5c7905430bba2e3be | 20,848 | cc | C++ | src/mem/ruby/network/orion/sleep_model/cacti_area_sleep/parameter.cc | pnkfb9/gem5_priority | fbf766277df78a470758cf7d798d12fb1e7c51c4 | [
"BSD-3-Clause"
] | null | null | null | src/mem/ruby/network/orion/sleep_model/cacti_area_sleep/parameter.cc | pnkfb9/gem5_priority | fbf766277df78a470758cf7d798d12fb1e7c51c4 | [
"BSD-3-Clause"
] | null | null | null | src/mem/ruby/network/orion/sleep_model/cacti_area_sleep/parameter.cc | pnkfb9/gem5_priority | fbf766277df78a470758cf7d798d12fb1e7c51c4 | [
"BSD-3-Clause"
] | null | null | null | /*------------------------------------------------------------
* CACTI 6.5
* Copyright 2008 Hewlett-Packard Development Corporation
* All Rights Reserved
*
* Permission to use, copy, and modify this software and its documentation is
* hereby granted only under the following terms and conditions. Both the
* above copyright notice and this permission notice must appear in all copies
* of the software, derivative works or modified versions, and any portions
* thereof, and both notices must appear in supporting documentation.
*
* Users of this software agree to the terms and conditions set forth herein, and
* hereby grant back to Hewlett-Packard Company and its affiliated companies ("HP")
* a non-exclusive, unrestricted, royalty-free right and license under any changes,
* enhancements or extensions made to the core functions of the software, including
* but not limited to those affording compatibility with other hardware or software
* environments, but excluding applications which incorporate this software.
* Users further agree to use their best efforts to return to HP any such changes,
* enhancements or extensions that they make and inform HP of noteworthy uses of
* this software. Correspondence should be provided to HP at:
*
* Director of Intellectual Property Licensing
* Office of Strategy and Technology
* Hewlett-Packard Company
* 1501 Page Mill Road
* Palo Alto, California 94304
*
* This software may be distributed (but not offered for sale or transferred
* for compensation) to third parties, provided such third parties agree to
* abide by the terms and conditions of this notice.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND HP DISCLAIMS ALL
* WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL HP
* CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*------------------------------------------------------------*/
#include <iostream>
#include <string>
#include <iomanip>
#include "parameter.h"
#include "area.h"
using namespace std;
namespace CactiArea
{
InputParameter * g_ip;
TechnologyParameter g_tp;
void TechnologyParameter::DeviceType::display(uint32_t indent)
{
string indent_str(indent, ' ');
cout << indent_str << "C_g_ideal = " << setw(12) << C_g_ideal << " F/um" << endl;
cout << indent_str << "C_fringe = " << setw(12) << C_fringe << " F/um" << endl;
cout << indent_str << "C_overlap = " << setw(12) << C_overlap << " F/um" << endl;
cout << indent_str << "C_junc = " << setw(12) << C_junc << " F/um^2" << endl;
cout << indent_str << "l_phy = " << setw(12) << l_phy << " um" << endl;
cout << indent_str << "l_elec = " << setw(12) << l_elec << " um" << endl;
cout << indent_str << "R_nch_on = " << setw(12) << R_nch_on << " ohm-um" << endl;
cout << indent_str << "R_pch_on = " << setw(12) << R_pch_on << " ohm-um" << endl;
cout << indent_str << "Vdd = " << setw(12) << Vdd_cacti << " V" << endl;
cout << indent_str << "Vth = " << setw(12) << Vth << " V" << endl;
cout << indent_str << "I_on_n = " << setw(12) << I_on_n << " A/um" << endl;
cout << indent_str << "I_on_p = " << setw(12) << I_on_p << " A/um" << endl;
cout << indent_str << "I_off_n = " << setw(12) << I_off_n << " A/um" << endl;
cout << indent_str << "I_off_p = " << setw(12) << I_off_p << " A/um" << endl;
cout << indent_str << "C_ox = " << setw(12) << C_ox << " F/um^2" << endl;
cout << indent_str << "t_ox = " << setw(12) << t_ox << " um" << endl;
cout << indent_str << "n_to_p_eff_curr_drv_ratio = " << n_to_p_eff_curr_drv_ratio << endl;
}
void TechnologyParameter::InterconnectType::display(uint32_t indent)
{
string indent_str(indent, ' ');
cout << indent_str << "pitch = " << setw(12) << pitch << " um" << endl;
cout << indent_str << "R_per_um = " << setw(12) << R_per_um << " ohm/um" << endl;
cout << indent_str << "C_per_um = " << setw(12) << C_per_um << " F/um" << endl;
}
void TechnologyParameter::MemoryType::display(uint32_t indent)
{
string indent_str(indent, ' ');
cout << indent_str << "b_w = " << setw(12) << b_w << " um" << endl;
cout << indent_str << "b_h = " << setw(12) << b_h << " um" << endl;
cout << indent_str << "cell_a_w = " << setw(12) << cell_a_w << " um" << endl;
cout << indent_str << "cell_pmos_w = " << setw(12) << cell_pmos_w << " um" << endl;
cout << indent_str << "cell_nmos_w = " << setw(12) << cell_nmos_w << " um" << endl;
cout << indent_str << "Vbitpre = " << setw(12) << Vbitpre_cacti << " V" << endl;
}
void TechnologyParameter::display(uint32_t indent)
{
string indent_str(indent, ' ');
cout << indent_str << "ram_wl_stitching_overhead_ = " << setw(12) << ram_wl_stitching_overhead_ << " um" << endl;
cout << indent_str << "min_w_nmos_ = " << setw(12) << min_w_nmos_ << " um" << endl;
cout << indent_str << "max_w_nmos_ = " << setw(12) << max_w_nmos_ << " um" << endl;
cout << indent_str << "unit_len_wire_del = " << setw(12) << unit_len_wire_del << " s/um^2" << endl;
cout << indent_str << "FO4 = " << setw(12) << FO4 << " s" << endl;
cout << indent_str << "kinv = " << setw(12) << kinv << " s" << endl;
cout << indent_str << "vpp = " << setw(12) << vpp << " V" << endl;
cout << indent_str << "w_sense_en = " << setw(12) << w_sense_en << " um" << endl;
cout << indent_str << "w_sense_n = " << setw(12) << w_sense_n << " um" << endl;
cout << indent_str << "w_sense_p = " << setw(12) << w_sense_p << " um" << endl;
cout << indent_str << "w_iso = " << setw(12) << w_iso << " um" << endl;
cout << indent_str << "w_poly_contact = " << setw(12) << w_poly_contact << " um" << endl;
cout << indent_str << "spacing_poly_to_poly = " << setw(12) << spacing_poly_to_poly << " um" << endl;
cout << indent_str << "spacing_poly_to_contact = " << setw(12) << spacing_poly_to_contact << " um" << endl;
cout << endl;
cout << indent_str << "w_comp_inv_p1 = " << setw(12) << w_comp_inv_p1 << " um" << endl;
cout << indent_str << "w_comp_inv_p2 = " << setw(12) << w_comp_inv_p2 << " um" << endl;
cout << indent_str << "w_comp_inv_p3 = " << setw(12) << w_comp_inv_p3 << " um" << endl;
cout << indent_str << "w_comp_inv_n1 = " << setw(12) << w_comp_inv_n1 << " um" << endl;
cout << indent_str << "w_comp_inv_n2 = " << setw(12) << w_comp_inv_n2 << " um" << endl;
cout << indent_str << "w_comp_inv_n3 = " << setw(12) << w_comp_inv_n3 << " um" << endl;
cout << indent_str << "w_eval_inv_p = " << setw(12) << w_eval_inv_p << " um" << endl;
cout << indent_str << "w_eval_inv_n = " << setw(12) << w_eval_inv_n << " um" << endl;
cout << indent_str << "w_comp_n = " << setw(12) << w_comp_n << " um" << endl;
cout << indent_str << "w_comp_p = " << setw(12) << w_comp_p << " um" << endl;
cout << endl;
cout << indent_str << "dram_cell_I_on = " << setw(12) << dram_cell_I_on << " A/um" << endl;
cout << indent_str << "dram_cell_Vdd = " << setw(12) << dram_cell_Vdd << " V" << endl;
cout << indent_str << "dram_cell_I_off_worst_case_len_temp = " << setw(12) << dram_cell_I_off_worst_case_len_temp << " A/um" << endl;
cout << indent_str << "dram_cell_C = " << setw(12) << dram_cell_C << " F" << endl;
cout << indent_str << "gm_sense_amp_latch = " << setw(12) << gm_sense_amp_latch << " F/s" << endl;
cout << endl;
cout << indent_str << "w_nmos_b_mux = " << setw(12) << w_nmos_b_mux << " um" << endl;
cout << indent_str << "w_nmos_sa_mux = " << setw(12) << w_nmos_sa_mux << " um" << endl;
cout << indent_str << "w_pmos_bl_precharge = " << setw(12) << w_pmos_bl_precharge << " um" << endl;
cout << indent_str << "w_pmos_bl_eq = " << setw(12) << w_pmos_bl_eq << " um" << endl;
cout << indent_str << "MIN_GAP_BET_P_AND_N_DIFFS = " << setw(12) << MIN_GAP_BET_P_AND_N_DIFFS << " um" << endl;
cout << indent_str << "HPOWERRAIL = " << setw(12) << HPOWERRAIL << " um" << endl;
cout << indent_str << "cell_h_def = " << setw(12) << cell_h_def << " um" << endl;
cout << endl;
cout << indent_str << "SRAM cell transistor: " << endl;
sram_cell.display(indent + 2);
cout << endl;
cout << indent_str << "DRAM access transistor: " << endl;
dram_acc.display(indent + 2);
cout << endl;
cout << indent_str << "DRAM wordline transistor: " << endl;
dram_wl.display(indent + 2);
cout << endl;
cout << indent_str << "peripheral global transistor: " << endl;
peri_global.display(indent + 2);
cout << endl;
cout << indent_str << "wire local" << endl;
wire_local.display(indent + 2);
cout << endl;
cout << indent_str << "wire inside mat" << endl;
wire_inside_mat.display(indent + 2);
cout << endl;
cout << indent_str << "wire outside mat" << endl;
wire_outside_mat.display(indent + 2);
cout << endl;
cout << indent_str << "SRAM" << endl;
sram.display(indent + 2);
cout << endl;
cout << indent_str << "DRAM" << endl;
dram.display(indent + 2);
}
DynamicParameter::DynamicParameter():
use_inp_params(0), cell(), is_valid(true)
{
}
DynamicParameter::DynamicParameter(
bool is_tag_,
int pure_ram_,
double Nspd_,
unsigned int Ndwl_,
unsigned int Ndbl_,
unsigned int Ndcm,
unsigned int Ndsam_lev_1_,
unsigned int Ndsam_lev_2_,
bool is_main_mem_):
is_tag(is_tag_), pure_ram(pure_ram_), tagbits(0), Nspd(Nspd_), Ndwl(Ndwl_), Ndbl(Ndbl_),
Ndsam_lev_1(Ndsam_lev_1_), Ndsam_lev_2(Ndsam_lev_2_),
number_way_select_signals_mat(0), V_b_sense(0), use_inp_params(0),
is_main_mem(is_main_mem_), cell(), is_valid(false)
{
ram_cell_tech_type = (is_tag) ? g_ip->tag_arr_ram_cell_tech_type : g_ip->data_arr_ram_cell_tech_type;
is_dram = ((ram_cell_tech_type == lp_dram) || (ram_cell_tech_type == comm_dram));
unsigned int capacity_per_die = g_ip->cache_sz / NUMBER_STACKED_DIE_LAYERS; // capacity per stacked die layer
const TechnologyParameter::InterconnectType & wire_local = g_tp.wire_local;
bool fully_assoc = (g_ip->fully_assoc) ? true : false;
if (fully_assoc)
{ // fully-assocative cache -- ref: CACTi 2.0 report
if (Ndwl != 1 || //Ndwl is fixed to 1 for FA
Ndcm != 1 || //Ndcm is fixed to 1 for FA
Nspd < 1 || Nspd > 1 || //Nspd is fixed to 1 for FA
Ndsam_lev_1 != 1 || //Ndsam_lev_1 is fixed to one
Ndsam_lev_2 != 1 || //Ndsam_lev_2 is fixed to one
Ndbl < 2)
{
return;
}
}
if ((is_dram) && (!is_tag) && (Ndcm > 1))
{
return; // For a DRAM array, each bitline has its own sense-amp
}
// If it's not an FA tag/data array, Ndwl should be at least two and Ndbl should be
// at least two because an array is assumed to have at least one mat. And a mat
// is formed out of two horizontal subarrays and two vertical subarrays
if (fully_assoc == false && (Ndwl < 1 || Ndbl < 1))
{
return;
}
// if data array, let tagbits = 0
if (is_tag)
{
if (g_ip->specific_tag)
{
tagbits = g_ip->tag_w;
}
else
{
if (fully_assoc)
{
tagbits = ADDRESS_BITS + EXTRA_TAG_BITS - _log2(g_ip->block_sz);
}
else
{
tagbits = ADDRESS_BITS + EXTRA_TAG_BITS - _log2(capacity_per_die) +
_log2(g_ip->tag_assoc*2 - 1) - _log2(g_ip->nbanks);
}
}
tagbits = (((tagbits + 3) >> 2) << 2);
if (fully_assoc)
{
num_r_subarray = (int)(capacity_per_die / (g_ip->block_sz * Ndbl));
num_c_subarray = (int)((tagbits * Nspd / Ndwl) + EPSILON);
}
else
{
num_r_subarray = (int)(capacity_per_die / (g_ip->nbanks *
g_ip->block_sz * g_ip->tag_assoc * Ndbl * Nspd) + EPSILON);
num_c_subarray = (int)((tagbits * g_ip->tag_assoc * Nspd / Ndwl) + EPSILON);
}
//burst_length = 1;
}
else
{
if (fully_assoc)
{
num_r_subarray = (int) (capacity_per_die) / (g_ip->block_sz * Ndbl);
num_c_subarray = 8 * g_ip->block_sz;
}
else
{
num_r_subarray = (int)(capacity_per_die / (g_ip->nbanks *
g_ip->block_sz * g_ip->data_assoc * Ndbl * Nspd) + EPSILON);
num_c_subarray = (int)((8 * g_ip->block_sz * g_ip->data_assoc * Nspd / Ndwl) + EPSILON);
}
// burst_length = g_ip->block_sz * 8 / g_ip->out_w;
}
if ((!fully_assoc)&&(num_r_subarray < MINSUBARRAYROWS)) return;
if (num_r_subarray == 0) return;
if (num_r_subarray > MAXSUBARRAYROWS) return;
if (num_c_subarray < MINSUBARRAYCOLS) return;
if (num_c_subarray > MAXSUBARRAYCOLS) return;
num_subarrays = Ndwl * Ndbl;
// calculate wire parameters
if(is_tag)
{
cell.h = g_tp.sram.b_h + 2 * wire_local.pitch * (g_ip->num_rw_ports - 1 + g_ip->num_rd_ports);
cell.w = g_tp.sram.b_w + 2 * wire_local.pitch * (g_ip->num_rw_ports - 1 +
(g_ip->num_rd_ports - g_ip->num_se_rd_ports)) +
wire_local.pitch * g_ip->num_se_rd_ports;
}
else
{
if (is_dram)
{
cell.h = g_tp.dram.b_h;
cell.w = g_tp.dram.b_w;
}
else
{
cell.h = g_tp.sram.b_h + 2 * wire_local.pitch * (g_ip->num_wr_ports +
g_ip->num_rw_ports - 1 + g_ip->num_rd_ports);
cell.w = g_tp.sram.b_w + 2 * wire_local.pitch * (g_ip->num_rw_ports - 1 +
(g_ip->num_rd_ports - g_ip->num_se_rd_ports) +
g_ip->num_wr_ports) + g_tp.wire_local.pitch * g_ip->num_se_rd_ports;
}
}
double c_b_metal = cell.h * wire_local.C_per_um;
double C_bl;
if (is_dram)
{
deg_bl_muxing = 1;
if (ram_cell_tech_type == comm_dram)
{
C_bl = num_r_subarray * c_b_metal;
V_b_sense = (g_tp.dram_cell_Vdd/2) * g_tp.dram_cell_C / (g_tp.dram_cell_C + C_bl);
if (V_b_sense < VBITSENSEMIN)
{
return;
}
V_b_sense = VBITSENSEMIN; // in any case, we fix sense amp input signal to a constant value
dram_refresh_period = 64e-3;
}
else
{
double Cbitrow_drain_cap = drain_C_(g_tp.dram.cell_a_w, NCH, 1, 0, cell.w, true, true) / 2.0;
C_bl = num_r_subarray * (Cbitrow_drain_cap + c_b_metal);
V_b_sense = (g_tp.dram_cell_Vdd/2) * g_tp.dram_cell_C /(g_tp.dram_cell_C + C_bl);
if (V_b_sense < VBITSENSEMIN)
{
return; //Sense amp input signal is smaller that minimum allowable sense amp input signal
}
V_b_sense = VBITSENSEMIN; // in any case, we fix sense amp input signal to a constant value
//v_storage_worst = g_tp.dram_cell_Vdd / 2 - VBITSENSEMIN * (g_tp.dram_cell_C + C_bl) / g_tp.dram_cell_C;
//dram_refresh_period = 1.1 * g_tp.dram_cell_C * v_storage_worst / g_tp.dram_cell_I_off_worst_case_len_temp;
dram_refresh_period = 0.9 * g_tp.dram_cell_C * VDD_STORAGE_LOSS_FRACTION_WORST * g_tp.dram_cell_Vdd / g_tp.dram_cell_I_off_worst_case_len_temp;
}
}
else
{ //SRAM
V_b_sense = (0.05 * g_tp.sram_cell.Vdd_cacti > VBITSENSEMIN) ? 0.05 * g_tp.sram_cell.Vdd_cacti : VBITSENSEMIN;
deg_bl_muxing = Ndcm;
// "/ 2.0" below is due to the fact that two adjacent access transistors share drain
// contacts in a physical layout
double Cbitrow_drain_cap = drain_C_(g_tp.sram.cell_a_w, NCH, 1, 0, cell.w, false, true) / 2.0;
C_bl = num_r_subarray * (Cbitrow_drain_cap + c_b_metal);
dram_refresh_period = 0;
}
if (fully_assoc)
{
num_mats_h_dir = 1;
num_mats_v_dir = Ndbl / 2;
num_do_b_mat = 8 * g_ip->block_sz;
num_mats = num_mats_h_dir * num_mats_v_dir;
}
else
{
num_mats_h_dir = MAX(Ndwl / 2, 1);
num_mats_v_dir = MAX(Ndbl / 2, 1);
num_mats = num_mats_h_dir * num_mats_v_dir;
num_do_b_mat = MAX((num_subarrays/num_mats) * num_c_subarray / (deg_bl_muxing * Ndsam_lev_1 * Ndsam_lev_2), 1);
}
if (!(fully_assoc&&is_tag) && (num_do_b_mat < (num_subarrays/num_mats)))
{
return;
}
int deg_sa_mux_l1_non_assoc;
if (!is_tag)
{
if (is_main_mem == true)
{
num_do_b_subbank = g_ip->int_prefetch_w * g_ip->out_w;
deg_sa_mux_l1_non_assoc = Ndsam_lev_1;
}
else
{
if (g_ip->fast_access == true)
{
num_do_b_subbank = g_ip->out_w * g_ip->data_assoc;
deg_sa_mux_l1_non_assoc = Ndsam_lev_1;
}
else
{
if (!fully_assoc)
{
num_do_b_subbank = g_ip->out_w;
deg_sa_mux_l1_non_assoc = Ndsam_lev_1 / g_ip->data_assoc;
if (deg_sa_mux_l1_non_assoc < 1)
{
return;
}
}
else
{
num_do_b_subbank = 8 * g_ip->block_sz;
deg_sa_mux_l1_non_assoc = 1;
}
}
}
}
else
{
num_do_b_subbank = tagbits * g_ip->tag_assoc;
if (fully_assoc == false && (num_do_b_mat < tagbits))
{
return;
}
deg_sa_mux_l1_non_assoc = Ndsam_lev_1;
//num_do_b_mat = g_ip->tag_assoc / num_mats_h_dir;
}
deg_senseamp_muxing_non_associativity = deg_sa_mux_l1_non_assoc;
if (fully_assoc)
{
num_act_mats_hor_dir = 1;
}
else
{
num_act_mats_hor_dir = num_do_b_subbank / num_do_b_mat;
if (num_act_mats_hor_dir == 0)
{
return;
}
}
if (is_tag)
{
if (fully_assoc)
{
num_do_b_mat = 0;
num_do_b_subbank = 0;
}
else
{
num_do_b_mat = g_ip->tag_assoc / num_act_mats_hor_dir;
num_do_b_subbank = num_act_mats_hor_dir * num_do_b_mat;
}
}
if ((g_ip->is_cache == false && is_main_mem == true) || (PAGE_MODE == 1 && is_dram))
{
if (num_act_mats_hor_dir * num_do_b_mat * Ndsam_lev_1 * Ndsam_lev_2 != (int)g_ip->page_sz_bits)
{
return;
}
}
if (is_tag == false && g_ip->is_main_mem == true &&
num_act_mats_hor_dir*num_do_b_mat*Ndsam_lev_1*Ndsam_lev_2 < ((int) g_ip->out_w * (int) g_ip->burst_len * (int) g_ip->data_assoc))
{
return;
}
if (num_act_mats_hor_dir > num_mats_h_dir)
{
return;
}
if(!is_tag)
{
if(g_ip->fast_access == true)
{
num_di_b_mat = num_do_b_mat / g_ip->data_assoc;
}
else
{
num_di_b_mat = num_do_b_mat;
}
}
else
{
num_di_b_mat = tagbits;
}
int num_di_b_subbank = num_di_b_mat * num_act_mats_hor_dir;
int num_addr_b_row_dec = (fully_assoc == true) ? 0 : _log2(num_r_subarray);
int number_subbanks = num_mats / num_act_mats_hor_dir;
number_subbanks_decode = _log2(number_subbanks);
num_rw_ports = g_ip->num_rw_ports;
num_rd_ports = g_ip->num_rd_ports;
num_wr_ports = g_ip->num_wr_ports;
num_se_rd_ports = g_ip->num_se_rd_ports;
if (is_dram && is_main_mem)
{
number_addr_bits_mat = MAX((unsigned int) num_addr_b_row_dec,
_log2(deg_bl_muxing) + _log2(deg_sa_mux_l1_non_assoc) + _log2(Ndsam_lev_2));
}
else
{
number_addr_bits_mat = num_addr_b_row_dec + _log2(deg_bl_muxing) +
_log2(deg_sa_mux_l1_non_assoc) + _log2(Ndsam_lev_2);
}
if (is_tag)
{
num_di_b_bank_per_port = tagbits;
num_do_b_bank_per_port = g_ip->data_assoc;
}
else
{
num_di_b_bank_per_port = g_ip->out_w + g_ip->data_assoc;
num_do_b_bank_per_port = g_ip->out_w;
}
if ((!is_tag) && (g_ip->data_assoc > 1) && (!g_ip->fast_access))
{
number_way_select_signals_mat = g_ip->data_assoc;
}
// add ECC adjustment to all data signals that traverse on H-trees.
if (g_ip->add_ecc_b_ == true)
{
num_do_b_mat += (int) (ceil(num_do_b_mat / num_bits_per_ecc_b_));
num_di_b_mat += (int) (ceil(num_di_b_mat / num_bits_per_ecc_b_));
num_di_b_subbank += (int) (ceil(num_di_b_subbank / num_bits_per_ecc_b_));
num_do_b_subbank += (int) (ceil(num_do_b_subbank / num_bits_per_ecc_b_));
}
is_valid = true;
}
}/*namespace cactiarea*/
| 37.563964 | 149 | 0.59387 | pnkfb9 |
3aca6ffb1e33d1985823da482e25a1befeb417b7 | 556 | hpp | C++ | include/Table.hpp | DeynegaEkaterina/lab_01 | 60f6621f48a4ca2beb1a635c8d162631852f4877 | [
"MIT"
] | null | null | null | include/Table.hpp | DeynegaEkaterina/lab_01 | 60f6621f48a4ca2beb1a635c8d162631852f4877 | [
"MIT"
] | null | null | null | include/Table.hpp | DeynegaEkaterina/lab_01 | 60f6621f48a4ca2beb1a635c8d162631852f4877 | [
"MIT"
] | null | null | null | //
// Created by ekaterina on 08.10.2020.
//
// Copyright 2020 Your Name <ekaterina>
#ifndef INCLUDE_HEADER_HPP_
#define INCLUDE_HEADER_HPP_
#include <vector>
#include <string>
#include "Student.hpp"
class Table {
public:
explicit Table(const json& j);
~Table();
static Table parseFile(const std::string& s);
//вызов метода без создания экземпляра класса
size_t w_name, w_group, w_avg, w_debt, w_space;
void print(std::ostream& out) const;
std::vector<Student> m_students;
std::vector<size_t> m_w;
};
#endif // INCLUDE_HEADER_HPP_
| 18.533333 | 49 | 0.719424 | DeynegaEkaterina |
3acbe8e00fec917d08f548a155df54140c293df0 | 53,068 | cpp | C++ | src/tests/relay/t_relay_io_hdf5.cpp | aaroncblack/conduit | f54f834eb8aaff4fc97613e04cfdb360997867be | [
"BSD-3-Clause"
] | null | null | null | src/tests/relay/t_relay_io_hdf5.cpp | aaroncblack/conduit | f54f834eb8aaff4fc97613e04cfdb360997867be | [
"BSD-3-Clause"
] | null | null | null | src/tests/relay/t_relay_io_hdf5.cpp | aaroncblack/conduit | f54f834eb8aaff4fc97613e04cfdb360997867be | [
"BSD-3-Clause"
] | null | null | null | // Copyright (c) Lawrence Livermore National Security, LLC and other Conduit
// Project developers. See top-level LICENSE AND COPYRIGHT files for dates and
// other details. No copyright assignment is required to contribute to Conduit.
//-----------------------------------------------------------------------------
///
/// file: t_relay_io_hdf5.cpp
///
//-----------------------------------------------------------------------------
#include "conduit_relay.hpp"
#include "conduit_relay_io_hdf5.hpp"
#include "hdf5.h"
#include <iostream>
#include "gtest/gtest.h"
using namespace conduit;
using namespace conduit::relay;
//-----------------------------------------------------------------------------
TEST(conduit_relay_io_hdf5, conduit_hdf5_write_read_by_file_name)
{
uint32 a_val = 20;
uint32 b_val = 8;
uint32 c_val = 13;
uint32 d_val = 121;
Node n;
n["a"] = a_val;
n["b"] = b_val;
n["c"] = c_val;
EXPECT_EQ(n["a"].as_uint32(), a_val);
EXPECT_EQ(n["b"].as_uint32(), b_val);
EXPECT_EQ(n["c"].as_uint32(), c_val);
// write our node as a group @ "myobj"
io::hdf5_write(n,"tout_hdf5_wr.hdf5:myobj");
// directly read our object
Node n_load;
io::hdf5_read("tout_hdf5_wr.hdf5:myobj",n_load);
n_load.print_detailed();
EXPECT_EQ(n_load["a"].as_uint32(), a_val);
EXPECT_EQ(n_load["b"].as_uint32(), b_val);
EXPECT_EQ(n_load["c"].as_uint32(), c_val);
Node n_load_2;
// read from root of hdf5 file
io::hdf5_read("tout_hdf5_wr.hdf5",n_load_2);
EXPECT_EQ(n_load_2["myobj/a"].as_uint32(), a_val);
EXPECT_EQ(n_load_2["myobj/b"].as_uint32(), b_val);
EXPECT_EQ(n_load_2["myobj/c"].as_uint32(), c_val);
Node n_load_generic;
// read from root of hdf5 file
io::load("tout_hdf5_wr.hdf5",n_load_generic);
EXPECT_EQ(n_load_generic["myobj/a"].as_uint32(), a_val);
EXPECT_EQ(n_load_generic["myobj/b"].as_uint32(), b_val);
EXPECT_EQ(n_load_generic["myobj/c"].as_uint32(), c_val);
// save load from generic io interface
io::save(n_load_generic["myobj"],"tout_hdf5_wr_generic.hdf5:myobj");
n_load_generic["myobj/d"] = d_val;
io::load_merged("tout_hdf5_wr_generic.hdf5",n_load_generic);
EXPECT_EQ(n_load_generic["myobj/a"].as_uint32(), a_val);
EXPECT_EQ(n_load_generic["myobj/b"].as_uint32(), b_val);
EXPECT_EQ(n_load_generic["myobj/c"].as_uint32(), c_val);
EXPECT_EQ(n_load_generic["myobj/d"].as_uint32(), d_val);
}
//-----------------------------------------------------------------------------
TEST(conduit_relay_io_hdf5, conduit_hdf5_write_read_special_paths)
{
uint32 a_val = 20;
uint32 b_val = 8;
Node n;
n["a"] = a_val;
n["b"] = b_val;
EXPECT_EQ(n["a"].as_uint32(), a_val);
EXPECT_EQ(n["b"].as_uint32(), b_val);
// write our node as a group @ "/myobj"
io::hdf5_write(n,"tout_hdf5_wr_special_paths_1.hdf5:/myobj");
// write our node as a group @ "/"
// make sure "/" works
io::hdf5_write(n,"tout_hdf5_wr_special_paths_2.hdf5:/");
// make sure empty after ":" this works
io::hdf5_write(n,"tout_hdf5_wr_special_paths_3.hdf5:");
Node n_load;
io::hdf5_read("tout_hdf5_wr_special_paths_2.hdf5:/",n_load);
EXPECT_EQ(n_load["a"].as_uint32(), a_val);
EXPECT_EQ(n_load["b"].as_uint32(), b_val);
n_load.reset();
io::hdf5_read("tout_hdf5_wr_special_paths_2.hdf5:/",n_load);
EXPECT_EQ(n_load["a"].as_uint32(), a_val);
EXPECT_EQ(n_load["b"].as_uint32(), b_val);
n_load.reset();
io::hdf5_read("tout_hdf5_wr_special_paths_2.hdf5:",n_load);
EXPECT_EQ(n_load["a"].as_uint32(), a_val);
EXPECT_EQ(n_load["b"].as_uint32(), b_val);
}
//-----------------------------------------------------------------------------
TEST(conduit_relay_io_hdf5, conduit_hdf5_write_read_string)
{
uint32 a_val = 20;
std::string s_val = "{string value!}";
Node n;
n["a"] = a_val;
n["s"] = s_val;
EXPECT_EQ(n["a"].as_uint32(), a_val);
EXPECT_EQ(n["s"].as_string(), s_val);
// write our node as a group @ "myobj"
io::hdf5_write(n,"tout_hdf5_wr_string.hdf5:myobj");
Node n_out;
io::hdf5_read("tout_hdf5_wr_string.hdf5:myobj",n_out);
EXPECT_EQ(n_out["a"].as_uint32(), a_val);
EXPECT_EQ(n_out["s"].as_string(), s_val);
}
//-----------------------------------------------------------------------------
TEST(conduit_relay_io_hdf5, conduit_hdf5_write_read_array)
{
Node n_in(DataType::float64(10));
float64_array val_in = n_in.value();
for(index_t i=0;i<10;i++)
{
val_in[i] = 3.1415 * i;
}
// write our node as a group @ "myobj"
io::hdf5_write(n_in,"tout_hdf5_wr_array.hdf5:myobj");
Node n_out;
io::hdf5_read("tout_hdf5_wr_array.hdf5:myobj",n_out);
float64_array val_out = n_out.value();
for(index_t i=0;i<10;i++)
{
EXPECT_EQ(val_in[i],val_out[i]);
}
}
//-----------------------------------------------------------------------------
TEST(conduit_relay_io_hdf5, write_and_read_conduit_leaf_to_hdf5_dataset_handle)
{
std::string ofname = "tout_hdf5_wr_conduit_leaf_to_hdf5_dataset_handle.hdf5";
hid_t h5_file_id = H5Fcreate(ofname.c_str(),
H5F_ACC_TRUNC,
H5P_DEFAULT,
H5P_DEFAULT);
// create a dataset for a 16-bit signed integer array with 2 elements
hid_t h5_dtype = H5T_NATIVE_SHORT;
hsize_t num_eles = 2;
hid_t h5_dspace_id = H5Screate_simple(1,
&num_eles,
NULL);
// create new dataset
hid_t h5_dset_id = H5Dcreate(h5_file_id,
"mydata",
h5_dtype,
h5_dspace_id,
H5P_DEFAULT,
H5P_DEFAULT,
H5P_DEFAULT);
Node n;
n.set(DataType::c_short(2));
short_array vals = n.value();
vals[0] = -16;
vals[1] = -16;
// this should succeed
io::hdf5_write(n,h5_dset_id);
// this should also succeed
vals[1] = 16;
io::hdf5_write(n,h5_dset_id);
n.set(DataType::uint16(10));
// this should fail
EXPECT_THROW(io::hdf5_write(n,h5_dset_id),Error);
Node n_read;
io::hdf5_read(h5_dset_id,n_read);
// check values of data
short_array read_vals = n_read.value();
EXPECT_EQ(-16,read_vals[0]);
EXPECT_EQ(16,read_vals[1]);
H5Sclose(h5_dspace_id);
H5Dclose(h5_dset_id);
H5Fclose(h5_file_id);
}
//-----------------------------------------------------------------------------
TEST(conduit_relay_io_hdf5, write_and_read_conduit_leaf_to_extendible_hdf5_dataset_handle_with_offset)
{
std::string ofname = "tout_hdf5_wr_conduit_leaf_to_hdf5_extendible_dataset_handle_with_offset.hdf5";
hid_t h5_file_id = H5Fcreate(ofname.c_str(),
H5F_ACC_TRUNC,
H5P_DEFAULT,
H5P_DEFAULT);
// create a dataset for a 16-bit signed integer array with 2 elements
hid_t h5_dtype = H5T_NATIVE_SHORT;
hsize_t num_eles = 2;
hsize_t dims[1] = {H5S_UNLIMITED};
hid_t h5_dspace_id = H5Screate_simple(1,
&num_eles,
dims);
/*
* Modify dataset creation properties, i.e. enable chunking.
*/
hid_t cparms;
hsize_t chunk_dims[1] = {1};
cparms = H5Pcreate (H5P_DATASET_CREATE);
H5Pset_chunk(cparms, 1, chunk_dims);
// create new dataset
hid_t h5_dset_id = H5Dcreate1(h5_file_id,
"mydata",
h5_dtype,
h5_dspace_id,
cparms);
Node n, opts;
n.set(DataType::c_short(2));
short_array vals = n.value();
vals[0] = -16;
vals[1] = -15;
// this should succeed
io::hdf5_write(n,h5_dset_id);
vals[0] = 1;
vals[1] = 2;
opts["offset"] = 2;
opts["stride"] = 1;
io::hdf5_write(n,h5_dset_id,opts);
Node n_read, opts_read;
io::hdf5_read_info(h5_dset_id,opts_read,n_read);
EXPECT_EQ(4,(int) n_read["num_elements"].to_value());
io::hdf5_read(h5_dset_id,opts_read,n_read);
// check values of data
short_array read_vals = n_read.value();
EXPECT_EQ(-16,read_vals[0]);
EXPECT_EQ(-15,read_vals[1]);
EXPECT_EQ(1,read_vals[2]);
EXPECT_EQ(2,read_vals[3]);
opts_read["offset"] = 2;
opts_read["stride"] = 1;
io::hdf5_read(h5_dset_id,opts_read,n_read);
// check values of data
read_vals = n_read.value();
EXPECT_EQ(1,read_vals[0]);
EXPECT_EQ(2,read_vals[1]);
vals[0] = -1;
vals[1] = -3;
opts["offset"] = 0;
opts["stride"] = 2;
io::hdf5_write(n,h5_dset_id,opts);
opts_read["offset"] = 0;
opts_read["stride"] = 1;
io::hdf5_read(h5_dset_id,opts_read,n_read);
// check values of data
read_vals = n_read.value();
EXPECT_EQ(-1,read_vals[0]);
EXPECT_EQ(-15,read_vals[1]);
EXPECT_EQ(-3,read_vals[2]);
EXPECT_EQ(2,read_vals[3]);
vals[0] = 5;
vals[1] = 6;
opts["offset"] = 7;
opts["stride"] = 1;
io::hdf5_write(n,h5_dset_id,opts);
opts_read["offset"] = 0;
opts_read["stride"] = 1;
io::hdf5_read(h5_dset_id,opts_read,n_read);
// check values of data
read_vals = n_read.value();
EXPECT_EQ(-1,read_vals[0]);
EXPECT_EQ(-15,read_vals[1]);
EXPECT_EQ(-3,read_vals[2]);
EXPECT_EQ(2,read_vals[3]);
EXPECT_EQ(0,read_vals[4]);
EXPECT_EQ(0,read_vals[5]);
EXPECT_EQ(0,read_vals[6]);
EXPECT_EQ(5,read_vals[7]);
EXPECT_EQ(6,read_vals[8]);
opts["offset"] = -1;
opts["stride"] = 2;
opts_read["offset"] = -1;
opts_read["stride"] = 2;
//this should fail
EXPECT_THROW(io::hdf5_write(n,h5_dset_id,opts),Error);
EXPECT_THROW(io::hdf5_read(h5_dset_id,opts_read,n_read),Error);
opts["offset"] = 0;
opts["stride"] = 0;
opts_read["offset"] = 0;
opts_read["stride"] = 0;
//this should fail
EXPECT_THROW(io::hdf5_write(n,h5_dset_id,opts),Error);
EXPECT_THROW(io::hdf5_read(h5_dset_id,opts_read,n_read),Error);
H5Sclose(h5_dspace_id);
H5Dclose(h5_dset_id);
H5Fclose(h5_file_id);
}
//-----------------------------------------------------------------------------
TEST(conduit_relay_io_hdf5, write_and_read_conduit_leaf_to_fixed_hdf5_dataset_handle_with_offset)
{
std::string ofname = "tout_hdf5_wr_conduit_leaf_to_fixed_hdf5_dataset_handle_with_offset.hdf5";
hid_t h5_file_id = H5Fcreate(ofname.c_str(),
H5F_ACC_TRUNC,
H5P_DEFAULT,
H5P_DEFAULT);
// create a dataset for a 16-bit signed integer array with 2 elements
hid_t h5_dtype = H5T_NATIVE_SHORT;
hsize_t num_eles = 2;
hid_t h5_dspace_id = H5Screate_simple(1,
&num_eles,
NULL);
// create new dataset
hid_t h5_dset_id = H5Dcreate(h5_file_id,
"mydata",
h5_dtype,
h5_dspace_id,
H5P_DEFAULT,
H5P_DEFAULT,
H5P_DEFAULT);
Node n, opts;
n.set(DataType::c_short(2));
short_array vals = n.value();
vals[0] = -16;
vals[1] = -15;
// this should succeed
io::hdf5_write(n,h5_dset_id);
vals[0] = 1;
vals[1] = 2;
opts["offset"] = 2;
opts["stride"] = 1;
io::hdf5_write(n,h5_dset_id,opts);
Node n_read, opts_read;
io::hdf5_read_info(h5_dset_id,opts_read,n_read);
EXPECT_EQ(4,(int) n_read["num_elements"].to_value());
io::hdf5_read(h5_dset_id,opts_read,n_read);
// check values of data
short_array read_vals = n_read.value();
EXPECT_EQ(-16,read_vals[0]);
EXPECT_EQ(-15,read_vals[1]);
EXPECT_EQ(1,read_vals[2]);
EXPECT_EQ(2,read_vals[3]);
opts_read["offset"] = 2;
opts_read["stride"] = 1;
io::hdf5_read(h5_dset_id,opts_read,n_read);
// check values of data
read_vals = n_read.value();
EXPECT_EQ(1,read_vals[0]);
EXPECT_EQ(2,read_vals[1]);
vals[0] = -1;
vals[1] = -3;
opts["offset"] = 0;
opts["stride"] = 2;
io::hdf5_write(n,h5_dset_id,opts);
opts_read["offset"] = 0;
opts_read["stride"] = 1;
io::hdf5_read(h5_dset_id,opts_read,n_read);
// check values of data
read_vals = n_read.value();
EXPECT_EQ(-1,read_vals[0]);
EXPECT_EQ(-15,read_vals[1]);
EXPECT_EQ(-3,read_vals[2]);
EXPECT_EQ(2,read_vals[3]);
vals[0] = 5;
vals[1] = 6;
opts["offset"] = 7;
opts["stride"] = 1;
io::hdf5_write(n,h5_dset_id,opts);
opts_read["offset"] = 0;
opts_read["stride"] = 1;
io::hdf5_read(h5_dset_id,opts_read,n_read);
// check values of data
read_vals = n_read.value();
EXPECT_EQ(-1,read_vals[0]);
EXPECT_EQ(-15,read_vals[1]);
EXPECT_EQ(-3,read_vals[2]);
EXPECT_EQ(2,read_vals[3]);
EXPECT_EQ(0,read_vals[4]);
EXPECT_EQ(0,read_vals[5]);
EXPECT_EQ(0,read_vals[6]);
EXPECT_EQ(5,read_vals[7]);
EXPECT_EQ(6,read_vals[8]);
opts["offset"] = -1;
opts["stride"] = 2;
opts_read["offset"] = -1;
opts_read["stride"] = 2;
//this should fail
EXPECT_THROW(io::hdf5_write(n,h5_dset_id,opts),Error);
EXPECT_THROW(io::hdf5_read(h5_dset_id,opts_read,n_read),Error);
opts["offset"] = 0;
opts["stride"] = 0;
opts_read["offset"] = 0;
opts_read["stride"] = 0;
//this should fail
EXPECT_THROW(io::hdf5_write(n,h5_dset_id,opts),Error);
EXPECT_THROW(io::hdf5_read(h5_dset_id,opts_read,n_read),Error);
H5Sclose(h5_dspace_id);
H5Dclose(h5_dset_id);
H5Fclose(h5_file_id);
}
//-----------------------------------------------------------------------------
TEST(conduit_relay_io_hdf5, write_conduit_object_to_hdf5_group_handle_with_offset)
{
std::string ofname = "tout_hdf5_wr_conduit_object_to_hdf5_group_handle_with_offset.hdf5";
hid_t h5_file_id = H5Fcreate(ofname.c_str(),
H5F_ACC_TRUNC,
H5P_DEFAULT,
H5P_DEFAULT);
hid_t h5_group_id = H5Gcreate(h5_file_id,
"mygroup",
H5P_DEFAULT,
H5P_DEFAULT,
H5P_DEFAULT);
Node n, opts;
n["a/b"].set(DataType::int16(2));
int16_array vals = n["a/b"].value();
vals[0] =-16;
vals[1] =-16;
// this should succeed
io::hdf5_write(n,h5_group_id);
n["a/c"] = "mystring";
// this should also succeed
vals[1] = 16;
io::hdf5_write(n,h5_group_id);
Node n_read;
io::hdf5_read(h5_group_id,n_read);
n["a/b"].set(DataType::int16(10));
// this should fail
EXPECT_THROW(io::hdf5_write(n,h5_group_id),Error);
n["a/b"].set(DataType::int16(10));
vals = n["a/b"].value();
opts["offset"] = 5;
for (int i = 0; i < 10; i++) {
vals[i] = i + 1;
}
io::hdf5_write(n,h5_group_id,opts);
io::hdf5_read(h5_group_id,n_read);
// check values of data with offset
int16_array read_vals = n_read["a/b"].value();
for (int i = 0; i < 10; i++) {
EXPECT_EQ(i + 1, read_vals[i + 5]);
}
// this is also offset
EXPECT_EQ("mystrmystring",n_read["a/c"].as_string());
opts["offset"] = 20;
opts["stride"] = 2;
for (int i = 0; i < 10; i++) {
vals[i] = i + 1;
}
n["a/d"].set(DataType::int16(5));
int16_array vals2 = n["a/d"].value();
for (int i = 0; i < 5; i++) {
vals2[i] = (i + 1) * -1;
}
io::hdf5_write(n,h5_group_id,opts);
io::hdf5_read(h5_group_id,n_read);
// check values of data
read_vals = n_read["a/b"].value();
for (int i = 0; i < 10; i++) {
EXPECT_EQ(i + 1, read_vals[i + 5]);
}
for (int i = 0; i < 10; i++) {
EXPECT_EQ(i + 1, read_vals[2*i + 20]);
}
read_vals = n_read["a/d"].value();
for (int i = 0; i < 5; i++) {
EXPECT_EQ((i + 1) * -1, read_vals[2*i + 20]);
}
Node n_read_info;
io::hdf5_read_info(h5_group_id,n_read_info);
EXPECT_EQ(39,(int) n_read_info["a/b/num_elements"].to_value());
EXPECT_EQ(37,(int) n_read_info["a/c/num_elements"].to_value());
EXPECT_EQ(29,(int) n_read_info["a/d/num_elements"].to_value());
// this doesn't change because the null-terminated character
// wasn't overwritten
EXPECT_EQ("mystrmystring",n_read["a/c"].as_string());
Node opts_read;
opts_read["offset"] = 5;
io::hdf5_read_info(h5_group_id,opts_read,n_read_info);
io::hdf5_read(h5_group_id,opts_read,n_read);
// check values of data
read_vals = n_read["a/b"].value();
for (int i = 0; i < 10; i++) {
EXPECT_EQ(i + 1, read_vals[i]);
}
EXPECT_EQ("mystring",n_read["a/c"].as_string());
EXPECT_EQ(34,(int) n_read_info["a/b/num_elements"].to_value());
EXPECT_EQ(32,(int) n_read_info["a/c/num_elements"].to_value());
opts_read["offset"] = 20;
opts_read["stride"] = 2;
io::hdf5_read_info(h5_group_id,opts_read,n_read_info);
io::hdf5_read(h5_group_id,opts_read,n_read);
// check values of data
read_vals = n_read["a/b"].value();
for (int i = 0; i < 10; i++) {
EXPECT_EQ(i + 1, read_vals[i]);
}
read_vals = n_read["a/d"].value();
for (int i = 0; i < 5; i++) {
EXPECT_EQ((i + 1) * -1, read_vals[i]);
}
EXPECT_EQ(10,(int) n_read_info["a/b/num_elements"].to_value());
EXPECT_EQ(5,(int) n_read_info["a/d/num_elements"].to_value());
opts_read["offset"] = 20;
opts_read["stride"] = 3;
io::hdf5_read_info(h5_group_id,opts_read,n_read_info);
io::hdf5_read(h5_group_id,opts_read,n_read);
// check values of data
read_vals = n_read["a/b"].value();
EXPECT_EQ(1, read_vals[0]);
EXPECT_EQ(4, read_vals[2]);
EXPECT_EQ(7, read_vals[4]);
EXPECT_EQ(10, read_vals[6]);
read_vals = n_read["a/d"].value();
EXPECT_EQ(-1, read_vals[0]);
EXPECT_EQ(-4, read_vals[2]);
EXPECT_EQ(7,(int) n_read_info["a/b/num_elements"].to_value());
EXPECT_EQ(3,(int) n_read_info["a/d/num_elements"].to_value());
H5Gclose(h5_group_id);
H5Fclose(h5_file_id);
}
//-----------------------------------------------------------------------------
TEST(conduit_relay_io_hdf5, write_conduit_object_to_hdf5_group_handle)
{
std::string ofname = "tout_hdf5_wr_conduit_object_to_hdf5_group_handle.hdf5";
hid_t h5_file_id = H5Fcreate(ofname.c_str(),
H5F_ACC_TRUNC,
H5P_DEFAULT,
H5P_DEFAULT);
hid_t h5_group_id = H5Gcreate(h5_file_id,
"mygroup",
H5P_DEFAULT,
H5P_DEFAULT,
H5P_DEFAULT);
Node n;
n["a/b"].set(DataType::int16(2));
int16_array vals = n["a/b"].value();
vals[0] =-16;
vals[1] =-16;
// this should succeed
io::hdf5_write(n,h5_group_id);
n["a/c"] = "mystring";
// this should also succeed
vals[1] = 16;
io::hdf5_write(n,h5_group_id);
n["a/b"].set(DataType::uint16(10));
// this should fail
EXPECT_THROW(io::hdf5_write(n,h5_group_id),Error);
Node n_read;
io::hdf5_read(h5_group_id,n_read);
// check values of data
int16_array read_vals = n_read["a/b"].value();
EXPECT_EQ(-16,read_vals[0]);
EXPECT_EQ(16,read_vals[1]);
EXPECT_EQ("mystring",n_read["a/c"].as_string());
H5Gclose(h5_group_id);
H5Fclose(h5_file_id);
}
//-----------------------------------------------------------------------------
// This variant tests when a caller code has already opened a HDF5 file
// and has a handle ready.
TEST(conduit_relay_io_hdf5, conduit_hdf5_write_read_by_file_handle)
{
uint32 a_val = 20;
uint32 b_val = 8;
uint32 c_val = 13;
Node n;
n["a"] = a_val;
n["b"] = b_val;
n["c"] = c_val;
EXPECT_EQ(n["a"].as_uint32(), a_val);
EXPECT_EQ(n["b"].as_uint32(), b_val);
EXPECT_EQ(n["c"].as_uint32(), c_val);
std::string test_file_name = "tout_hdf5_write_read_by_file_handle.hdf5";
// Set up hdf5 file and group that caller code would already have.
hid_t h5_file_id = H5Fcreate(test_file_name.c_str(),
H5F_ACC_TRUNC,
H5P_DEFAULT,
H5P_DEFAULT);
// Prepare group that caller code wants conduit to save it's tree to that
// group. (could also specify group name for conduit to create via
// hdf5_path argument to write call.
hid_t h5_group_id = H5Gcreate(h5_file_id,
"sample_group_name",
H5P_DEFAULT,
H5P_DEFAULT,
H5P_DEFAULT);
io::hdf5_write(n,h5_group_id);
hid_t status = H5Gclose(h5_group_id);
// Another variant of this - caller code has a pre-existing group they
// want to write into, but they want to use the 'group name' arg to do it
// Relay should be able to write into existing group.
h5_group_id = H5Gcreate(h5_file_id,
"sample_group_name2",
H5P_DEFAULT,
H5P_DEFAULT,
H5P_DEFAULT);
io::hdf5_write(n,h5_file_id, "sample_group_name2");
status = H5Gclose(h5_group_id);
status = H5Fclose(h5_file_id);
h5_file_id = H5Fopen(test_file_name.c_str(),
H5F_ACC_RDONLY,
H5P_DEFAULT);
// Caller code switches to group it wants to read in. (could also
// specify group name for conduit to read out via hdf5_path arg to read
// call)
h5_group_id = H5Gopen(h5_file_id, "sample_group_name", 0);
Node n_load;
io::hdf5_read(h5_group_id, n_load);
status = H5Gclose(h5_group_id);
status = H5Fclose(h5_file_id);
EXPECT_EQ(n_load["a"].as_uint32(), a_val);
EXPECT_EQ(n_load["b"].as_uint32(), b_val);
EXPECT_EQ(n_load["c"].as_uint32(), c_val);
}
//-----------------------------------------------------------------------------
TEST(conduit_relay_io_hdf5, conduit_hdf5_write_to_existing_dset)
{
Node n_in(DataType::uint32(2));
uint32_array val_in = n_in.value();
val_in[0] = 1;
val_in[1] = 2;
// Set up hdf5 file and group that caller code would already have.
hid_t h5_file_id = H5Fcreate("tout_hdf5_wr_existing_dset.hdf5",
H5F_ACC_TRUNC,
H5P_DEFAULT,
H5P_DEFAULT);
io::hdf5_write(n_in,h5_file_id,"myarray");
val_in[0] = 3;
val_in[1] = 4;
io::hdf5_write(n_in,h5_file_id,"myarray");
// trying to write an incompatible dataset will throw an error
Node n_incompat;
n_incompat = 64;
EXPECT_THROW(io::hdf5_write(n_incompat,h5_file_id,"myarray"),
conduit::Error);
H5Fclose(h5_file_id);
// check that the second set of values are the ones we get back
Node n_read;
io::hdf5_read("tout_hdf5_wr_existing_dset.hdf5:myarray",n_read);
uint32_array val = n_read.value();
EXPECT_EQ(val[0],3);
EXPECT_EQ(val[1],4);
Node n_w2;
n_w2["myarray"].set_external(n_read);
n_w2["a/b/c"].set_uint64(123);
// this should be compatible
io::hdf5_write(n_w2,"tout_hdf5_wr_existing_dset.hdf5");
n_read.reset();
io::hdf5_read("tout_hdf5_wr_existing_dset.hdf5",n_read);
uint32_array myarray_val = n_read["myarray"].value();
uint64 a_b_c_val = n_read["a/b/c"].value();
EXPECT_EQ(myarray_val[0],3);
EXPECT_EQ(myarray_val[1],4);
EXPECT_EQ(a_b_c_val,123);
}
//-----------------------------------------------------------------------------
TEST(conduit_relay_io_hdf5, conduit_hdf5_write_read_leaf_arrays)
{
Node n;
n["v_int8"].set(DataType::int8(5));
n["v_int16"].set(DataType::int16(5));
n["v_int32"].set(DataType::int32(5));
n["v_int64"].set(DataType::int64(5));
n["v_uint8"].set(DataType::uint8(5));
n["v_uint16"].set(DataType::uint16(5));
n["v_uint32"].set(DataType::uint32(5));
n["v_uint64"].set(DataType::uint64(5));
n["v_float32"].set(DataType::float32(5));
n["v_float64"].set(DataType::float64(5));
n["v_string"].set("my_string");
int8 *v_int8_ptr = n["v_int8"].value();
int16 *v_int16_ptr = n["v_int16"].value();
int32 *v_int32_ptr = n["v_int32"].value();
int64 *v_int64_ptr = n["v_int64"].value();
uint8 *v_uint8_ptr = n["v_uint8"].value();
uint16 *v_uint16_ptr = n["v_uint16"].value();
uint32 *v_uint32_ptr = n["v_uint32"].value();
uint64 *v_uint64_ptr = n["v_uint64"].value();
float32 *v_float32_ptr = n["v_float32"].value();
float64 *v_float64_ptr = n["v_float64"].value();
for(index_t i=0; i < 5; i++)
{
v_int8_ptr[i] = -8;
v_int16_ptr[i] = -16;
v_int32_ptr[i] = -32;
v_int64_ptr[i] = -64;
v_uint8_ptr[i] = 8;
v_uint16_ptr[i] = 16;
v_uint32_ptr[i] = 32;
v_uint64_ptr[i] = 64;
v_float32_ptr[i] = 32.0;
v_float64_ptr[i] = 64.0;
}
n.print_detailed();
io::hdf5_write(n,"tout_hdf5_wr_leaf_arrays.hdf5");
Node n_load;
io::hdf5_read("tout_hdf5_wr_leaf_arrays.hdf5",n_load);
n_load.print_detailed();
int8_array v_int8_out = n_load["v_int8"].value();
int16_array v_int16_out = n_load["v_int16"].value();
int32_array v_int32_out = n_load["v_int32"].value();
int64_array v_int64_out = n_load["v_int64"].value();
EXPECT_EQ(v_int8_out.number_of_elements(),5);
EXPECT_EQ(v_int16_out.number_of_elements(),5);
EXPECT_EQ(v_int32_out.number_of_elements(),5);
EXPECT_EQ(v_int64_out.number_of_elements(),5);
uint8_array v_uint8_out = n_load["v_uint8"].value();
uint16_array v_uint16_out = n_load["v_uint16"].value();
uint32_array v_uint32_out = n_load["v_uint32"].value();
uint64_array v_uint64_out = n_load["v_uint64"].value();
EXPECT_EQ(v_uint8_out.number_of_elements(),5);
EXPECT_EQ(v_uint16_out.number_of_elements(),5);
EXPECT_EQ(v_uint32_out.number_of_elements(),5);
EXPECT_EQ(v_uint64_out.number_of_elements(),5);
float32_array v_float32_out = n_load["v_float32"].value();
float64_array v_float64_out = n_load["v_float64"].value();
EXPECT_EQ(v_float32_out.number_of_elements(),5);
EXPECT_EQ(v_float64_out.number_of_elements(),5);
std::string v_string_out = n_load["v_string"].as_string();
EXPECT_EQ(v_string_out,"my_string");
}
//-----------------------------------------------------------------------------
TEST(conduit_relay_io_hdf5, conduit_hdf5_write_read_empty)
{
Node n;
n["path/to/empty"];
n.print_detailed();
io::hdf5_write(n,"tout_hdf5_wr_empty.hdf5");
Node n_load;
io::hdf5_read("tout_hdf5_wr_empty.hdf5",n_load);
n_load.print_detailed();
EXPECT_EQ(n["path/to/empty"].dtype().id(),
n_load["path/to/empty"].dtype().id());
}
//-----------------------------------------------------------------------------
TEST(conduit_relay_io_hdf5, hdf5_write_zero_sized_leaf)
{
// this tests
Node n;
n["a"].set(DataType::float64(0));
n.print_detailed();
io::hdf5_write(n,"tout_hdf5_w_0.hdf5");
EXPECT_EQ(n["a"].dtype().number_of_elements(),0);
EXPECT_EQ(n["a"].dtype().id(),DataType::FLOAT64_ID);
Node n_load;
io::hdf5_read("tout_hdf5_w_0.hdf5",n_load);
n_load.print_detailed();
EXPECT_EQ(n_load["a"].dtype().number_of_elements(),0);
EXPECT_EQ(n_load["a"].dtype().id(),DataType::FLOAT64_ID);
}
//-----------------------------------------------------------------------------
TEST(conduit_relay_io_hdf5, conduit_hdf5_write_read_childless_object)
{
Node n;
n["path/to/empty"].set(DataType::object());
n.print_detailed();
io::hdf5_write(n,"tout_hdf5_wr_cl_obj.hdf5");
Node n_load;
io::hdf5_read("tout_hdf5_wr_cl_obj.hdf5",n_load);
n_load.print_detailed();
EXPECT_EQ(n["path/to/empty"].dtype().id(),
n_load["path/to/empty"].dtype().id());
}
//-----------------------------------------------------------------------------
TEST(conduit_relay_io_hdf5, conduit_hdf5_test_write_incompat)
{
Node n;
n["a/b/leaf"] = DataType::uint32(2);
n["a/b/grp/leaf"].set_uint32(10);
uint32_array vals = n["a/b/leaf"].value();
vals[0] = 1;
vals[1] = 2;
io::hdf5_write(n,"tout_hdf5_test_write_incompat.hdf5");
n.print();
Node n2;
n2["a/b/leaf/v"] = DataType::float64(2);
n2["a/b/grp/leaf/v"].set_float64(10.0);
n2.print();
hid_t h5_file_id = H5Fopen("tout_hdf5_test_write_incompat.hdf5",
H5F_ACC_RDWR,
H5P_DEFAULT);
try
{
io::hdf5_write(n2,h5_file_id);
}
catch(Error &e)
{
CONDUIT_INFO(e.message());
}
H5Fclose(h5_file_id);
}
//-----------------------------------------------------------------------------
TEST(conduit_relay_io_hdf5, auto_endian)
{
Node n;
n["a"].set_int64(12345689);
n["b"].set_int64(-12345689);
if(Endianness::machine_is_big_endian())
{
n.endian_swap_to_little();
}
else
{
n.endian_swap_to_big();
}
io::hdf5_write(n,"tout_hdf5_wr_opp_endian.hdf5");
Node n_load;
io::hdf5_read("tout_hdf5_wr_opp_endian.hdf5",n_load);
EXPECT_EQ(n_load["a"].as_int64(),12345689);
EXPECT_EQ(n_load["b"].as_int64(),-12345689);
}
//-----------------------------------------------------------------------------
TEST(conduit_relay_io_hdf5, hdf5_path_exists)
{
std::string test_file_name = "tout_hdf5_wr_hdf5_path_exists.hdf5";
Node n;
n["a/b/c/d"] = 10;
n["a/b/c/f"] = 20;
io::hdf5_write(n,test_file_name);
hid_t h5_file_id = H5Fopen(test_file_name.c_str(),
H5F_ACC_RDONLY,
H5P_DEFAULT);
hid_t h5_grp_a = H5Gopen(h5_file_id, "a", 0);
EXPECT_TRUE(io::hdf5_has_path(h5_file_id,"a"));
EXPECT_TRUE(io::hdf5_has_path(h5_file_id,"a/b"));
EXPECT_TRUE(io::hdf5_has_path(h5_file_id,"a/b/c"));
EXPECT_TRUE(io::hdf5_has_path(h5_file_id,"a/b/c/d"));
EXPECT_TRUE(io::hdf5_has_path(h5_file_id,"a/b/c/f"));
EXPECT_TRUE(io::hdf5_has_path(h5_grp_a,"b"));
EXPECT_TRUE(io::hdf5_has_path(h5_grp_a,"b/c"));
EXPECT_TRUE(io::hdf5_has_path(h5_grp_a,"b/c/d"));
EXPECT_TRUE(io::hdf5_has_path(h5_grp_a,"b/c/f"));
EXPECT_FALSE(io::hdf5_has_path(h5_file_id,"BAD"));
EXPECT_FALSE(io::hdf5_has_path(h5_file_id,"a/BAD"));
EXPECT_FALSE(io::hdf5_has_path(h5_file_id,"a/b/BAD"));
EXPECT_FALSE(io::hdf5_has_path(h5_file_id,"a/b/c/BAD"));
EXPECT_FALSE(io::hdf5_has_path(h5_file_id,"a/b/c/d/e/f/g"));
EXPECT_FALSE(io::hdf5_has_path(h5_grp_a,"BAD"));
EXPECT_FALSE(io::hdf5_has_path(h5_grp_a,"b/BAD"));
EXPECT_FALSE(io::hdf5_has_path(h5_grp_a,"b/c/BAD"));
EXPECT_FALSE(io::hdf5_has_path(h5_grp_a,"b/c/d/e/f/g"));
H5Gclose(h5_grp_a);
H5Fclose(h5_file_id);
}
//-----------------------------------------------------------------------------
TEST(conduit_relay_io_hdf5, hdf5_create_append_methods)
{
std::string test_file_name = "tout_hdf5_open_append.hdf5";
utils::remove_path_if_exists(test_file_name);
Node n;
n["a/b/c/d"] = 10;
io::hdf5_write(n,test_file_name,true);
n.reset();
n["a/b/c/e"] = 20;
io::hdf5_write(n,test_file_name,true);
Node n_load;
io::hdf5_read(test_file_name,n_load);
EXPECT_TRUE(n_load.has_path("a"));
EXPECT_TRUE(n_load.has_path("a/b"));
EXPECT_TRUE(n_load.has_path("a/b/c"));
EXPECT_TRUE(n_load.has_path("a/b/c/d"));
EXPECT_TRUE(n_load.has_path("a/b/c/e"));
EXPECT_EQ(n_load["a/b/c/d"].to_int32(),10);
EXPECT_EQ(n_load["a/b/c/e"].to_int32(),20);
io::hdf5_write(n,test_file_name,false);
n_load.reset();
io::hdf5_read(test_file_name,n_load);
EXPECT_FALSE(n_load.has_path("a/b/c/d"));
EXPECT_EQ(n_load["a/b/c/e"].to_int32(),20);
n.reset();
n["a/b/c/d"] = 10;
io::hdf5_save(n,test_file_name);
n_load.reset();
io::hdf5_read(test_file_name,n_load);
EXPECT_FALSE(n_load.has_path("a/b/c/e"));
EXPECT_EQ(n_load["a/b/c/d"].to_int32(),10);
n.reset();
n["a/b/c/e"] = 20;
io::hdf5_write(n,test_file_name,true);
n.reset();
n["a/b/c/e"] = 20;
io::hdf5_append(n,test_file_name);
n_load.reset();
io::hdf5_read(test_file_name,n_load);
EXPECT_TRUE(n_load.has_path("a/b/c/d"));
EXPECT_TRUE(n_load.has_path("a/b/c/e"));
EXPECT_EQ(n_load["a/b/c/d"].to_int32(),10);
EXPECT_EQ(n_load["a/b/c/e"].to_int32(),20);
}
//-----------------------------------------------------------------------------
TEST(conduit_relay_io_hdf5, hdf5_create_open_methods)
{
std::string test_file_name = "tout_hdf5_open_and_create.hdf5";
Node n;
n["a/b/c/d"] = 10;
hid_t h5_file_id = io::hdf5_create_file(test_file_name);
io::hdf5_write(n,h5_file_id);
io::hdf5_close_file(h5_file_id);
h5_file_id = io::hdf5_open_file_for_read(test_file_name);
EXPECT_TRUE(io::hdf5_has_path(h5_file_id,"a"));
EXPECT_TRUE(io::hdf5_has_path(h5_file_id,"a/b"));
EXPECT_TRUE(io::hdf5_has_path(h5_file_id,"a/b/c"));
EXPECT_TRUE(io::hdf5_has_path(h5_file_id,"a/b/c/d"));
Node n_read;
io::hdf5_read(h5_file_id,"a/b/c/d",n_read);
EXPECT_EQ(10,n_read.to_int());
io::hdf5_close_file(h5_file_id);
h5_file_id = io::hdf5_open_file_for_read_write(test_file_name);
Node n2;
n2 = 12;
io::hdf5_write(n2,h5_file_id,"a/b/c/e");
EXPECT_TRUE(io::hdf5_has_path(h5_file_id,"a/b/c/e"));
io::hdf5_read(h5_file_id,"a/b/c/e",n_read);
EXPECT_EQ(12,n_read.to_int());
io::hdf5_close_file(h5_file_id);
}
//-----------------------------------------------------------------------------
TEST(conduit_relay_io_hdf5, conduit_hdf5_save_generic_options)
{
// 5k zeros, should compress well, but under default
// threshold size
Node n;
n["value"] = DataType::float64(5000);
Node opts;
opts["hdf5/chunking/threshold"] = 2000;
opts["hdf5/chunking/chunk_size"] = 2000;
std::string tout_std = "tout_hdf5_save_generic_default_options.hdf5";
std::string tout_cmp = "tout_hdf5_save_generic_test_options.hdf5";
utils::remove_path_if_exists(tout_std);
utils::remove_path_if_exists(tout_cmp);
io::save(n,tout_std, "hdf5");
io::save(n,tout_cmp, "hdf5", opts);
EXPECT_TRUE(utils::is_file(tout_std));
EXPECT_TRUE(utils::is_file(tout_cmp));
int64 tout_std_fs = utils::file_size(tout_std);
int64 tout_cmp_fs = utils::file_size(tout_cmp);
CONDUIT_INFO("fs test: std = "
<< tout_std_fs
<< ", cmp ="
<< tout_cmp_fs);
EXPECT_TRUE(tout_cmp_fs < tout_std_fs);
}
//-----------------------------------------------------------------------------
TEST(conduit_relay_io_hdf5, conduit_hdf5_group_list_children)
{
Node n;
n["path/sub1/a"];
n["path/sub1/b"];
n["path/sub1/c"];
n["path/sub2/d"];
n["path/sub2/e"];
n["path/sub2/f"];
std::string tout = "tout_hdf5_grp_chld_names.hdf5";
utils::remove_path_if_exists(tout);
io::save(n,tout, "hdf5");
EXPECT_TRUE(utils::is_file(tout));
hid_t h5_file_id = io::hdf5_open_file_for_read(tout);
std::vector<std::string> cnames;
io::hdf5_group_list_child_names(h5_file_id,"/",cnames);
EXPECT_EQ(cnames.size(),1);
EXPECT_EQ(cnames[0],"path");
io::hdf5_group_list_child_names(h5_file_id,"path",cnames);
EXPECT_EQ(cnames.size(),2);
EXPECT_EQ(cnames[0],"sub1");
EXPECT_EQ(cnames[1],"sub2");
io::hdf5_group_list_child_names(h5_file_id,"path/sub1",cnames);
EXPECT_EQ(cnames.size(),3);
EXPECT_EQ(cnames[0],"a");
EXPECT_EQ(cnames[1],"b");
EXPECT_EQ(cnames[2],"c");
io::hdf5_group_list_child_names(h5_file_id,"path/sub2",cnames);
EXPECT_EQ(cnames.size(),3);
EXPECT_EQ(cnames[0],"d");
EXPECT_EQ(cnames[1],"e");
EXPECT_EQ(cnames[2],"f");
// check leaf, which has no children
// this doesn't throw an error, but it creates an empty list
io::hdf5_group_list_child_names(h5_file_id,"path/sub1/a",cnames);
EXPECT_EQ(cnames.size(),0);
// totally bogus paths will trigger an error
EXPECT_THROW(io::hdf5_group_list_child_names(h5_file_id,"this/isnt/right",cnames),Error);
// empty string won't work in this case
EXPECT_THROW(io::hdf5_group_list_child_names(h5_file_id,"",cnames),Error);
}
//-----------------------------------------------------------------------------
TEST(conduit_relay_io_hdf5, check_if_file_is_hdf5_file)
{
Node n;
n["path/mydata"] = 20;
std::string tout = "tout_hdf5_check_hdf5_file.hdf5";
utils::remove_path_if_exists(tout);
io::save(n,tout, "hdf5");
// this should be recoged as hdf5
EXPECT_TRUE(io::is_hdf5_file(tout));
// check behavior with files that have open handles
hid_t h5_file_id = io::hdf5_open_file_for_read_write(tout);
EXPECT_TRUE(io::is_hdf5_file(tout));
io::hdf5_close_file(h5_file_id);
h5_file_id = io::hdf5_open_file_for_read(tout);
EXPECT_TRUE(io::is_hdf5_file(tout));
io::hdf5_close_file(h5_file_id);
tout = "tout_hdf5_check_non_hdf5_file.json";
utils::remove_path_if_exists(tout);
io::save(n,tout,"json");
// this should *not* be recoged as hdf5
EXPECT_FALSE(io::is_hdf5_file(tout));
// check totally bad path
EXPECT_FALSE(io::is_hdf5_file("/path/to/somewhere/that/cant/exist"));
}
//-----------------------------------------------------------------------------
TEST(conduit_relay_io_hdf5, test_remove_path)
{
Node n;
n["path/mydata"] = 20;
n["path/otherdata/leaf"] = 42;
std::string tout = "tout_test_remove_path.hdf5";
utils::remove_path_if_exists(tout);
io::save(n,tout, "hdf5");
hid_t h5_file_id = io::hdf5_open_file_for_read_write(tout);
io::hdf5_remove_path(h5_file_id,"path/otherdata/leaf");
io::hdf5_close_file(h5_file_id);
n.reset();
io::load(tout,n);
EXPECT_FALSE(n.has_path("path/otherdata/leaf"));
EXPECT_TRUE(n.has_path("path/otherdata"));
n.print();
h5_file_id = io::hdf5_open_file_for_read_write(tout);
io::hdf5_remove_path(h5_file_id,"path/otherdata");
io::hdf5_close_file(h5_file_id);
n.reset();
io::load(tout,n);
EXPECT_FALSE(n.has_path("path/otherdata"));
EXPECT_TRUE(n.has_path("path"));
n.print();
}
//-----------------------------------------------------------------------------
TEST(conduit_relay_io_hdf5, file_name_in_error)
{
Node n;
n["path/mydata"] = 20;
n["path/otherdata/leaf"] = 42;
std::string tout = "tout_our_file_to_test.hdf5";
utils::remove_path_if_exists(tout);
io::save(n,tout, "hdf5");
hid_t h5_file_id = io::hdf5_open_file_for_read_write(tout);
Node n_read;
bool had_error = false;
try
{
io::hdf5_read(h5_file_id,"bad",n_read);
}
catch(Error &e)
{
had_error = true;
std::cout << "error message: " << e.message() ;
// error should have the file name in it
std::size_t found = e.message().find(tout);
EXPECT_TRUE(found!=std::string::npos);
}
// make sure we took the error path
EXPECT_TRUE(had_error);
io::hdf5_close_file(h5_file_id);
}
//-----------------------------------------------------------------------------
TEST(conduit_relay_io_hdf5, test_read_various_string_style)
{
std::string tout = "tout_hdf5_wr_various_string_style.hdf5";
hid_t h5_file_id = H5Fcreate(tout.c_str(),
H5F_ACC_TRUNC,
H5P_DEFAULT,
H5P_DEFAULT);
// write this string several ways and make sure relay
// can reads them all as we expect
// 21 chars + null term (22 total)
std::string my_string = "this is my {} string!";
// case 0: conduit's current way to of doing things
Node n;
n.set(my_string);
io::hdf5_write(n,h5_file_id,"case_0");
// case 1: string that reflects our current data type
hid_t h5_dtype_id = H5Tcopy(H5T_C_S1);
// set size
hsize_t num_eles = 22;
H5Tset_size(h5_dtype_id, (size_t)num_eles);
H5Tset_strpad(h5_dtype_id, H5T_STR_NULLTERM);
hid_t h5_dspace_id = H5Screate(H5S_SCALAR);
// create new dataset
hid_t h5_dset_id = H5Dcreate(h5_file_id,
"case_1",
h5_dtype_id,
h5_dspace_id,
H5P_DEFAULT,
H5P_DEFAULT,
H5P_DEFAULT);
// write data
hid_t status = H5Dwrite(h5_dset_id,
h5_dtype_id,
H5S_ALL,
H5S_ALL,
H5P_DEFAULT,
my_string.c_str());
H5Tclose(h5_dtype_id);
H5Sclose(h5_dspace_id);
H5Dclose(h5_dset_id);
// case 2: string that is a simple array (old conduit way)
h5_dtype_id = H5T_C_S1;
num_eles = 22;
h5_dspace_id = H5Screate_simple(1,
&num_eles,
NULL);
// create new dataset
h5_dset_id = H5Dcreate(h5_file_id,
"case_2",
h5_dtype_id,
h5_dspace_id,
H5P_DEFAULT,
H5P_DEFAULT,
H5P_DEFAULT);
// write data
status = H5Dwrite(h5_dset_id,
h5_dtype_id,
H5S_ALL,
H5S_ALL,
H5P_DEFAULT,
my_string.c_str());
// H5Tclose(h5_dtype_id) -- don't need b/c we are using standard dtype
H5Sclose(h5_dspace_id);
H5Dclose(h5_dset_id);
// case 3: fixed lenght with diff term style
std::string my_string3 = "this is my {} string! ";
// len w/o null = 30
h5_dtype_id = H5Tcopy(H5T_C_S1);
num_eles = 30;
H5Tset_size(h5_dtype_id, (size_t)num_eles);
H5Tset_strpad(h5_dtype_id, H5T_STR_SPACEPAD);
h5_dspace_id = H5Screate(H5S_SCALAR);
// create new dataset
h5_dset_id = H5Dcreate(h5_file_id,
"case_3",
h5_dtype_id,
h5_dspace_id,
H5P_DEFAULT,
H5P_DEFAULT,
H5P_DEFAULT);
// write data
status = H5Dwrite(h5_dset_id,
h5_dtype_id,
H5S_ALL,
H5S_ALL,
H5P_DEFAULT,
my_string3.c_str());
H5Tclose(h5_dtype_id);
H5Sclose(h5_dspace_id);
H5Dclose(h5_dset_id);
// temp buffer to create a null padded string as
// input to write to hdf5
Node n_tmp;
n_tmp.set(DataType::uint8(30));
uint8 *mystring4_char_ptr = n_tmp.value();
// null out entire string (leave no doubt for test)
for(int i=0; i < 30; i++)
{
mystring4_char_ptr[i] = 0;
}
// copy over part of my_string before final space pad
for(size_t i=0; i < my_string.size(); i++)
{
mystring4_char_ptr[i] = my_string[i];
}
h5_dtype_id = H5Tcopy(H5T_C_S1);
num_eles = 30;
H5Tset_size(h5_dtype_id, (size_t)num_eles);
H5Tset_strpad(h5_dtype_id, H5T_STR_NULLPAD);
h5_dspace_id = H5Screate(H5S_SCALAR);
// create new dataset
h5_dset_id = H5Dcreate(h5_file_id,
"case_4",
h5_dtype_id,
h5_dspace_id,
H5P_DEFAULT,
H5P_DEFAULT,
H5P_DEFAULT);
// write data
status = H5Dwrite(h5_dset_id,
h5_dtype_id,
H5S_ALL,
H5S_ALL,
H5P_DEFAULT,
mystring4_char_ptr);
H5Tclose(h5_dtype_id);
H5Sclose(h5_dspace_id);
H5Dclose(h5_dset_id);
// case 5: string written using variable length
h5_dtype_id = H5Tcreate(H5T_STRING, H5T_VARIABLE);
h5_dspace_id = H5Screate(H5S_SCALAR);
const char *mystr_char_ptr = my_string.c_str();
// create new dataset
h5_dset_id = H5Dcreate(h5_file_id,
"case_5",
h5_dtype_id,
h5_dspace_id,
H5P_DEFAULT,
H5P_DEFAULT,
H5P_DEFAULT);
// write data
status = H5Dwrite(h5_dset_id,
h5_dtype_id,
H5S_ALL,
H5S_ALL,
H5P_DEFAULT,
&mystr_char_ptr);
//
H5Tclose(h5_dtype_id);
H5Sclose(h5_dspace_id);
H5Dclose(h5_dset_id);
H5Fclose(h5_file_id);
// load back in and make sure we get the correct string for each case
Node n_load;
io::load(tout,n_load);
n_load.print();
EXPECT_EQ(n_load["case_0"].as_string(), my_string );
EXPECT_EQ(n_load["case_1"].as_string(), my_string );
EXPECT_EQ(n_load["case_2"].as_string(), my_string );
EXPECT_EQ(n_load["case_3"].as_string(), my_string3 );
EXPECT_EQ(n_load["case_4"].as_string(), my_string );
EXPECT_EQ(n_load["case_5"].as_string(), my_string );
}
//-----------------------------------------------------------------------------
TEST(conduit_relay_io_hdf5, conduit_hdf5_write_read_string_compress)
{
uint32 s_len = 10000;
std::string tout_std = "tout_hdf5_wr_string_no_compression.hdf5";
std::string tout_cmp = "tout_hdf5_wr_string_with_compression.hdf5";
std::string s_val = std::string(s_len, 'z');
Node n;
n["my_string"] = s_val;
Node opts;
opts["hdf5/chunking/threshold"] = 100;
opts["hdf5/chunking/chunk_size"] = 100;
// write out the string w and w/o compression
io::save(n,tout_std, "hdf5");
io::save(n,tout_cmp, "hdf5", opts);
Node n_out;
io::hdf5_read(tout_cmp,n_out);
EXPECT_EQ(n_out["my_string"].as_string(), s_val);
int64 tout_std_fs = utils::file_size(tout_std);
int64 tout_cmp_fs = utils::file_size(tout_cmp);
CONDUIT_INFO("fs test: std = "
<< tout_std_fs
<< ", cmp ="
<< tout_cmp_fs);
EXPECT_TRUE(tout_cmp_fs < tout_std_fs);
}
//-----------------------------------------------------------------------------
TEST(conduit_relay_io_hdf5, conduit_hdf5_list)
{
std::string tout_std = "tout_hdf5_list.hdf5";
Node n;
n.append() = "42";
n.append() = "42";
n.append() = "42";
n.append() = "42";
Node &n_sub = n.append();
n_sub.append() = 42;
n_sub.append() = 42;
n_sub.append() = 42;
n_sub.append() = 42;
n_sub.append() = 42.0;
io::save(n,tout_std, "hdf5");
Node n_load, info;
io::load(tout_std,"hdf5",n_load);
n_load.print();
EXPECT_FALSE(n.diff(n_load,info));
hid_t h5_file_id = io::hdf5_open_file_for_read(tout_std);
/// check subpath of written list
EXPECT_TRUE(io::hdf5_has_path(h5_file_id,"0"));
EXPECT_TRUE(io::hdf5_has_path(h5_file_id,"4"));
EXPECT_FALSE(io::hdf5_has_path(h5_file_id,"5"));
EXPECT_TRUE(io::hdf5_has_path(h5_file_id,"4/0"));
EXPECT_TRUE(io::hdf5_has_path(h5_file_id,"4/4"));
EXPECT_FALSE(io::hdf5_has_path(h5_file_id,"4/5"));
n_load.reset();
io::hdf5_read(h5_file_id,"4/4",n_load);
EXPECT_EQ(n_load.to_float64(),42.0);
io::hdf5_close_file(h5_file_id);
// simple compat check (could be expanded)
Node n_check;
n_check = 42.0;
// this isn't compat with the existing file
h5_file_id = io::hdf5_open_file_for_read_write(tout_std);
EXPECT_THROW(io::hdf5_write(n_check,h5_file_id),Error);
// orig should be compat
n_check.set(n);
io::hdf5_write(n_check,h5_file_id);
// lets change the value of one of the list entries
n_check[4][4] = 3.1415;
io::hdf5_write(n_check,h5_file_id);
io::hdf5_close_file(h5_file_id);
io::load(tout_std,"hdf5",n_load);
n_load.print();
EXPECT_FALSE(n_check.diff(n_load,info));
}
//-----------------------------------------------------------------------------
TEST(conduit_relay_io_hdf5, conduit_hdf5_list_with_offset)
{
std::string tout_std = "tout_hdf5_list_with_offset.hdf5";
Node n, opts;
n.append() = DataType::c_short(1);
short_array vals = n[0].value();
vals[0] = 1;
io::save(n,tout_std, "hdf5");
vals[0] = 2;
opts["offset"] = 1;
io::save(n,tout_std, "hdf5",opts);
Node n_load, info;
io::load(tout_std,"hdf5",n_load);
// check values of data
// since we didn't use save_merged, the first value should be overwritten
short_array read_vals = n_load[0].value();
EXPECT_EQ(0,read_vals[0]);
EXPECT_EQ(2,read_vals[1]);
// let's try again
vals[0] = 1;
io::save(n,tout_std, "hdf5");
vals[0] = 2;
opts["offset"] = 1;
io::save_merged(n,tout_std, "hdf5",opts);
io::load(tout_std,"hdf5",n_load);
read_vals = n_load[0].value();
EXPECT_EQ(1,read_vals[0]);
EXPECT_EQ(2,read_vals[1]);
vals[0] = 3;
opts["offset"] = 2;
io::save_merged(n,tout_std, "hdf5",opts);
vals[0] = 4;
opts["offset"] = 3;
io::save_merged(n,tout_std, "hdf5",opts);
vals[0] = 5;
opts["offset"] = 4;
io::save_merged(n,tout_std, "hdf5",opts);
vals[0] = 6;
opts["offset"] = 5;
io::save_merged(n,tout_std, "hdf5",opts);
io::load_merged(tout_std,"hdf5",n_load);
read_vals = n_load[0].value();
EXPECT_EQ(1,read_vals[0]);
EXPECT_EQ(2,read_vals[1]);
EXPECT_EQ(3,read_vals[2]);
EXPECT_EQ(4,read_vals[3]);
EXPECT_EQ(5,read_vals[4]);
EXPECT_EQ(6,read_vals[5]);
// try loading with offset and size
Node opts_read;
opts_read["offset"] = 2;
opts_read["size"] = 2;
io::load(tout_std,"hdf5",opts_read,n_load);
read_vals = n_load[0].value();
EXPECT_EQ(3,read_vals[0]);
EXPECT_EQ(4,read_vals[1]);
EXPECT_EQ(2, read_vals.number_of_elements());
}
//-----------------------------------------------------------------------------
TEST(conduit_relay_io_hdf5, conduit_hdf5_compat_with_empty)
{
std::string tout_std = "tout_hdf5_empty_compat.hdf5";
Node n;
n["myval"] = 42;
io::save(n,tout_std);
n["empty"] = DataType::empty();
n.print();
io::save_merged(n,tout_std);
// used to fail due to bad compat check
io::save_merged(n,tout_std);
Node n_load, n_diff_info;
io::load(tout_std,"hdf5",n_load);
n_load.print();
EXPECT_FALSE(n.diff(n_load,n_diff_info));
}
//-----------------------------------------------------------------------------
TEST(conduit_relay_io_hdf5, test_ref_path_error_msg)
{
// check that ref path only appears in the error message string once
Node n_about;
io::about(n_about);
// skip test if hdf5 isn't enabled
if(n_about["protocols/hdf5"].as_string() != "enabled")
return;
std::string tfile_out = "tout_hdf5_io_for_ref_path_error_msg.hdf5";
// remove files if they already exist
utils::remove_path_if_exists(tfile_out);
Node n, n_read, n_check, opts, info;
n["my/path/to/some/data"]= { 0,1,2,3,4,5,6,7,8,9};
io::save(n,tfile_out, "hdf5");
// bad offset
opts.reset();
opts["offset"] = 1000;
try
{
io::load(tfile_out,"hdf5",opts,n_read);
}
catch(conduit::Error &e)
{
std::string msg = e.message();
std::cout << "error message:"
<< msg << std::endl;
int count = 0;
std::string::size_type pos = 0;
std::string path = "my/path/to/some/data";
while ((pos = msg.find(path, pos )) != std::string::npos)
{
count++;
pos += path.length();
}
std::cout << "# of occurrences of path: " << count << std::endl;
// the path should only appear in the error message string once
EXPECT_EQ(count,1);
}
}
| 27.496373 | 104 | 0.572548 | aaroncblack |
3accd4ecf9d7168deee13dfd0f91a40e2270d982 | 721 | cpp | C++ | Painting Fence Algorithm/code_1.cpp | Jatin-Goyal5/Data-Structures-and-Algorithms | f6bd0f77e5640c2e0568f3fffc4694758e77af96 | [
"MIT"
] | 27 | 2019-01-31T10:22:29.000Z | 2021-08-29T08:25:12.000Z | Painting Fence Algorithm/code_1.cpp | Jatin-Goyal5/Data-Structures-and-Algorithms | f6bd0f77e5640c2e0568f3fffc4694758e77af96 | [
"MIT"
] | 6 | 2020-09-30T19:01:49.000Z | 2020-12-17T15:10:54.000Z | Painting Fence Algorithm/code_1.cpp | Jatin-Goyal5/Data-Structures-and-Algorithms | f6bd0f77e5640c2e0568f3fffc4694758e77af96 | [
"MIT"
] | 27 | 2019-09-21T14:19:32.000Z | 2021-09-15T03:06:41.000Z | //
// code_1.cpp
// Algorithm
//
// Created by Mohd Shoaib Rayeen on 23/11/18.
// Copyright © 2018 Shoaib Rayeen. All rights reserved.
//
#include <iostream>
using namespace std;
long countWays(int n, int k) {
long dp[n + 1];
memset(dp, 0, sizeof(dp));
int mod = 1000000007;
dp[1] = k;
long same = 0, diff = k;
for (int i = 2; i <= n; i++) {
same = diff;
diff = dp[i-1] * (k-1);
diff = diff % mod;
dp[i] = (same + diff) % mod;
}
return dp[n];
}
int main() {
int n;
cout << "\nEnter N\t:\t";
cin >> n;
int k;
cout << "\nEnter K\t:\t";
cin >> k;
cout << "\nNumber of Ways\t:\t" << countWays(n,k) << endl;
return 0;
}
| 18.025 | 62 | 0.496533 | Jatin-Goyal5 |
3acdf001bfc1070540e2bab81a7d5715a5784b1f | 7,723 | cpp | C++ | Control_movement/chassis/Src/CrosshairDrawer.cpp | PhilosopheAM/21_Fall_project_gabbishSorting | 15ef612d9e483ad72f9e37953875a7303f94b38e | [
"MIT"
] | 1 | 2021-12-31T09:27:00.000Z | 2021-12-31T09:27:00.000Z | Control_movement/chassis/Src/CrosshairDrawer.cpp | PhilosopheAM/21_Fall_project_gabbishSorting | 15ef612d9e483ad72f9e37953875a7303f94b38e | [
"MIT"
] | null | null | null | Control_movement/chassis/Src/CrosshairDrawer.cpp | PhilosopheAM/21_Fall_project_gabbishSorting | 15ef612d9e483ad72f9e37953875a7303f94b38e | [
"MIT"
] | 1 | 2021-12-22T03:34:04.000Z | 2021-12-22T03:34:04.000Z | #include "CrosshairDrawer.hpp"
#include "Dr16.hpp"
#include "math.h"
#include "BoardPacket.hpp"
void CrosshairDrawner::Init()
{
SetDefaultTicksToUpdate(550);
m_pGimbalController = (GimbalController*)GetOwner()->GetEntity(ECT_GimbalController);
m_rpcIndex = 255;
BoardPacketManager::Instance()->GetTestPacket().AddObserver(this);
m_lastMaxProjectileVelocity = JudgeSystem::Instance()->GameRobotStatus.shooter_id1_17mm_speed_limit;
}
void CrosshairDrawner::Update()
{
if(m_rpcIndex == 0)
{
m_DrawBuffer.operate_tpye = JudgeSystem::GOT_Add;
m_DrawBuffer.graphic_name[2] = 1;
m_DrawBuffer.color = JudgeSystem::GCT_Cyan;
m_DrawBuffer.width = 2;
m_DrawBuffer.graphic_tpye = JudgeSystem::GT_Line;
JudgeSystem::Instance()->ModfiyShapeOnClient(&m_DrawBuffer);
m_DrawBuffer.color = JudgeSystem::GCT_Green;
m_DrawBuffer.graphic_name[2] = 2;
m_DrawBuffer.radius = 50;
JudgeSystem::Instance()->ModfiyShapeOnClient(&m_DrawBuffer);
m_DrawBuffer.graphic_name[2] = 3;
m_DrawBuffer.radius = 50;
JudgeSystem::Instance()->ModfiyShapeOnClient(&m_DrawBuffer);
m_DrawBuffer.graphic_name[2] = 4;
m_DrawBuffer.radius = 50;
JudgeSystem::Instance()->ModfiyShapeOnClient(&m_DrawBuffer);
m_DrawBuffer.graphic_name[2] = 5;
m_DrawBuffer.radius = 50;
JudgeSystem::Instance()->ModfiyShapeOnClient(&m_DrawBuffer);
m_DrawBuffer.graphic_name[2] = 6;
m_DrawBuffer.radius = 50;
JudgeSystem::Instance()->ModfiyShapeOnClient(&m_DrawBuffer);
m_DrawBuffer.graphic_name[2] = 7;
m_DrawBuffer.radius = 50;
JudgeSystem::Instance()->ModfiyShapeOnClient(&m_DrawBuffer);
}
uint16_t latestMaxVel = JudgeSystem::Instance()->GameRobotStatus.shooter_id1_17mm_speed_limit;
if(latestMaxVel == m_lastMaxProjectileVelocity)
{
return;
}
m_lastMaxProjectileVelocity = latestMaxVel;
if(m_rpcIndex == 1)
{
m_DrawBuffer.operate_tpye = JudgeSystem::GOT_Modify;
m_DrawBuffer.graphic_tpye = JudgeSystem::GT_Line;
float _v = m_lastMaxProjectileVelocity;
float _v2 = _v * _v;
float _gimbalPitchAngle = - m_pGimbalController->GetGimbalMotor(GimbalController::GMT_Pitch)->sensorFeedBack.positionFdb;
float _cos = cos(_gimbalPitchAngle);
float _sin = sin(_gimbalPitchAngle);
float _time = 0.0f;
float _atan = 0.0f;
float _halfArmorLanding = 0.0;
float _l = 0.0f;
int16_t _dropPixel;
float _invV = 1 / _v;
m_DrawBuffer.graphic_name[2] = 1;
m_DrawBuffer.color = JudgeSystem::GCT_Orange;
m_DrawBuffer.width = 2;
_time = (_v * _sin + sqrt(_v2 * _sin * _sin + 2.0f * GRAVITY * GIMBAL_HEIGHT)) * INV_GRAVITY;
_atan = atan2(_sin - 0.5f * GRAVITY * _time * _invV, _cos);
_dropPixel = (int16_t)(PIXEL_RATIO * tan(_gimbalPitchAngle - _atan));
if(_dropPixel > 539)
{
_dropPixel = 539;
}
m_DrawBuffer.start_x = 960;
m_DrawBuffer.start_y = 540;
m_DrawBuffer.end_x = 960;
m_DrawBuffer.end_y = 540 - _dropPixel;
JudgeSystem::Instance()->ModfiyShapeOnClient(&m_DrawBuffer);
m_DrawBuffer.graphic_name[2] = 2;
m_DrawBuffer.start_y = 540 - _dropPixel;
m_DrawBuffer.end_y = 540 - _dropPixel;
_l = _v * _time * _cos / cos(_atan);
_halfArmorLanding = PIXEL_RATIO * REF_LEN / _l;
m_DrawBuffer.start_x = 960 - _halfArmorLanding;
m_DrawBuffer.end_x = 960 + _halfArmorLanding;
JudgeSystem::Instance()->ModfiyShapeOnClient(&m_DrawBuffer);
m_DrawBuffer.graphic_name[2] = 3;
m_DrawBuffer.color = JudgeSystem::GCT_Green;
_time = 0.1f;
_atan = atan2(_sin - 0.5f * GRAVITY * _time * _invV, _cos);
_dropPixel = (int16_t)(PIXEL_RATIO * tan(_gimbalPitchAngle - _atan));
if(_dropPixel > 539)
{
_dropPixel = 539;
}
m_DrawBuffer.start_y = 540 - _dropPixel;
m_DrawBuffer.end_y = 540 - _dropPixel;
_l = _v * _time * _cos / cos(_atan);
_halfArmorLanding = PIXEL_RATIO * REF_LEN / _l;
m_DrawBuffer.start_x = 960 - _halfArmorLanding;
m_DrawBuffer.end_x = 960 + _halfArmorLanding;
JudgeSystem::Instance()->ModfiyShapeOnClient(&m_DrawBuffer);
m_DrawBuffer.graphic_name[2] = 4;
_time = 0.2f;
_atan = atan2(_sin - 0.5f * GRAVITY * _time * _invV, _cos);
_dropPixel = (int16_t)(PIXEL_RATIO * tan(_gimbalPitchAngle - _atan));
if(_dropPixel > 539)
{
_dropPixel = 539;
}
m_DrawBuffer.start_y = 540 - _dropPixel;
m_DrawBuffer.end_y = 540 - _dropPixel;
_l = _v * _time * _cos / cos(_atan);
_halfArmorLanding = PIXEL_RATIO * REF_LEN / _l;
m_DrawBuffer.start_x = 960 - _halfArmorLanding;
m_DrawBuffer.end_x = 960 + _halfArmorLanding;
JudgeSystem::Instance()->ModfiyShapeOnClient(&m_DrawBuffer);
m_DrawBuffer.graphic_name[2] = 5;
_time = 0.4f;
_atan = atan2(_sin - 0.5f * GRAVITY * _time * _invV, _cos);
_dropPixel = (int16_t)(PIXEL_RATIO * tan(_gimbalPitchAngle - _atan));
if(_dropPixel > 539)
{
_dropPixel = 539;
}
m_DrawBuffer.start_y = 540 - _dropPixel;
m_DrawBuffer.end_y = 540 - _dropPixel;
_l = _v * _time * _cos / cos(_atan);
_halfArmorLanding = PIXEL_RATIO * REF_LEN / _l;
m_DrawBuffer.start_x = 960 - _halfArmorLanding;
m_DrawBuffer.end_x = 960 + _halfArmorLanding;
JudgeSystem::Instance()->ModfiyShapeOnClient(&m_DrawBuffer);
m_DrawBuffer.graphic_name[2] = 6;
_time = 0.6f;
_atan = atan2(_sin - 0.5f * GRAVITY * _time * _invV, _cos);
_dropPixel = (int16_t)(PIXEL_RATIO * tan(_gimbalPitchAngle - _atan));
if(_dropPixel > 539)
{
_dropPixel = 539;
}
m_DrawBuffer.start_y = 540 - _dropPixel;
m_DrawBuffer.end_y = 540 - _dropPixel;
_l = _v * _time * _cos / cos(_atan);
_halfArmorLanding = PIXEL_RATIO * REF_LEN / _l;
m_DrawBuffer.start_x = 960 - _halfArmorLanding;
m_DrawBuffer.end_x = 960 + _halfArmorLanding;
JudgeSystem::Instance()->ModfiyShapeOnClient(&m_DrawBuffer);
m_DrawBuffer.graphic_name[2] = 7;
_time = 0.8f;
_atan = atan2(_sin - 0.5f * GRAVITY * _time * _invV, _cos);
_dropPixel = (int16_t)(PIXEL_RATIO * tan(_gimbalPitchAngle - _atan));
if(_dropPixel > 539)
{
_dropPixel = 539;
}
m_DrawBuffer.start_y = 540 - _dropPixel;
m_DrawBuffer.end_y = 540 - _dropPixel;
_l = _v * _time * _cos / cos(_atan);
_halfArmorLanding = PIXEL_RATIO * REF_LEN / _l;
m_DrawBuffer.start_x = 960 - _halfArmorLanding;
m_DrawBuffer.end_x = 960 + _halfArmorLanding;
JudgeSystem::Instance()->ModfiyShapeOnClient(&m_DrawBuffer);
}
else if(m_rpcIndex == 2)
{
/* code */
m_DrawBuffer.operate_tpye = JudgeSystem::GOT_Delete;
m_DrawBuffer.graphic_tpye = JudgeSystem::GT_Line;
m_DrawBuffer.layer = 0;
m_DrawBuffer.color = JudgeSystem::GCT_Black;
m_DrawBuffer.width = 2;
m_DrawBuffer.start_x = 960;
m_DrawBuffer.start_y = 540;
m_DrawBuffer.radius = m_Radius;
JudgeSystem::Instance()->ModfiyShapeOnClient(&m_DrawBuffer);
}
}
void CrosshairDrawner::OnNotify(void* _param)
{
m_rpcIndex = *(uint8_t*)_param;
}
| 31.913223 | 129 | 0.628512 | PhilosopheAM |
3acdf07a1776d4219021b43bdc75de37c973b8e1 | 1,701 | cpp | C++ | src/sst/elements/VaultSimC/app.cpp | sudhanshu2/sst-elements | d658e5e4b26e5725488f9e93528506ddb22072ee | [
"BSD-3-Clause"
] | 58 | 2015-10-05T15:22:27.000Z | 2022-03-31T01:58:36.000Z | src/sst/elements/VaultSimC/app.cpp | sudhanshu2/sst-elements | d658e5e4b26e5725488f9e93528506ddb22072ee | [
"BSD-3-Clause"
] | 1,453 | 2015-10-07T14:51:06.000Z | 2022-03-31T22:22:28.000Z | src/sst/elements/VaultSimC/app.cpp | sudhanshu2/sst-elements | d658e5e4b26e5725488f9e93528506ddb22072ee | [
"BSD-3-Clause"
] | 109 | 2015-10-16T22:03:10.000Z | 2022-03-22T23:21:32.000Z | // Copyright 2009-2021 NTESS. Under the terms
// of Contract DE-NA0003525 with NTESS, the U.S.
// Government retains certain rights in this software.
//
// Copyright (c) 2009-2021, NTESS
// All rights reserved.
//
// Portions are copyright of other developers:
// See the file CONTRIBUTORS.TXT in the top level directory
// the distribution for more information.
//
// This file is part of the SST software package. For license
// information, see the LICENSE file in the top level directory of the
// distribution.
#include <sst_config.h>
#include "cpu.h"
#include <stdio.h>
#include <stdlib.h>
#include <stdlib.h>
static unsigned int missRate[][3] = {{0,51,32}, //app 0
{0,18,15}}; //app 1
static unsigned int isLoad[] = {3,32}; // out of 64
using namespace SST::VaultSim;
MemReqEvent *cpu::getInst(int cacheLevel, int app, int core) {
/*
app: MD(0) PHD(1)
l/s ratio 21:1 1:1
L1 miss/1Kinst 51 18
L2 miss/inst 32 15
*/
//printf("using missrate %d\n", missRate[app][cacheLevel]);
unsigned int roll1K = rng->generateNextUInt32() & 0x3ff;
if (roll1K <= missRate[app][cacheLevel]) {
//is a memory access
unsigned int roll = rng->generateNextUInt32();
unsigned int memRoll = roll & 0x3f;
Addr addr;
if ((memRoll & 0x1) == 0) {
// stride
addr = coreAddr[core] + (1 << 6);
addr = (addr >> 6) << 6;
} else {
//random
addr = (roll >> 6) << 6;
}
coreAddr[core] = addr;
bool isWrite;
if (memRoll <= isLoad[app]) {
isWrite = false;
} else {
isWrite = true;
}
MemReqEvent *event = new MemReqEvent((ReqId)this, addr, isWrite, 0, 0 );
return event;
} else {
return 0;
}
}
| 24.652174 | 76 | 0.627866 | sudhanshu2 |
3ace271a087f904c18f6fc8def9e716a452047b4 | 248 | cpp | C++ | CodeForces/Complete/700-799/750A-NewYearAndHurry.cpp | Ashwanigupta9125/code-DS-ALGO | 49f6cf7d0c682da669db23619aef3f80697b352b | [
"MIT"
] | 36 | 2019-12-27T08:23:08.000Z | 2022-01-24T20:35:47.000Z | CodeForces/Complete/700-799/750A-NewYearAndHurry.cpp | Ashwanigupta9125/code-DS-ALGO | 49f6cf7d0c682da669db23619aef3f80697b352b | [
"MIT"
] | 10 | 2019-11-13T02:55:18.000Z | 2021-10-13T23:28:09.000Z | CodeForces/Complete/700-799/750A-NewYearAndHurry.cpp | Ashwanigupta9125/code-DS-ALGO | 49f6cf7d0c682da669db23619aef3f80697b352b | [
"MIT"
] | 53 | 2020-08-15T11:08:40.000Z | 2021-10-09T15:51:38.000Z | #include <cstdio>
int main(){
int n, k; scanf("%d %d", &n, &k);
int t = 240 - k;
int count(0);
while(t >= 5 * (count + 1)){++count; t -= 5 * count;}
count = (n < count) ? n : count;
printf("%d\n", count);
return 0;
}
| 17.714286 | 57 | 0.455645 | Ashwanigupta9125 |
3ace55404cef53142c74d770448f7e0c120997ca | 13,990 | hh | C++ | src/vp8/decoder/boolreader.hh | interiorem/lepton | 8435d22b1f0ee9180b8b99610f8823589d7cb982 | [
"Apache-2.0"
] | 4 | 2018-10-29T20:11:40.000Z | 2018-11-01T11:10:47.000Z | src/vp8/decoder/boolreader.hh | interiorem/lepton | 8435d22b1f0ee9180b8b99610f8823589d7cb982 | [
"Apache-2.0"
] | 4 | 2018-11-08T14:11:42.000Z | 2018-12-18T17:03:52.000Z | src/vp8/decoder/boolreader.hh | interiorem/lepton | 8435d22b1f0ee9180b8b99610f8823589d7cb982 | [
"Apache-2.0"
] | 1 | 2018-12-13T08:34:54.000Z | 2018-12-13T08:34:54.000Z | /*
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE banner below
* An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the VPX_AUTHORS file in this directory
*/
/*
Copyright (c) 2010, Google Inc. All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
Neither the name of Google nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef VPX_DSP_BITREADER_H_
#define VPX_DSP_BITREADER_H_
#include <stddef.h>
#include <assert.h>
#include <limits.h>
#include <stdint.h>
#include "vpx_config.hh"
#include "billing.hh"
#include "../model/numeric.hh"
//#include "vpx_ports/mem.h"
//#include "vpx/vp8dx.h"
//#include "vpx/vpx_integer.h"
//#include "vpx_dsp/prob.h"
typedef size_t BD_VALUE;
#define BD_VALUE_SIZE ((int)sizeof(BD_VALUE) * CHAR_BIT)
// This is meant to be a large, positive constant that can still be efficiently
// loaded as an immediate (on platforms like ARM, for example).
// Even relatively modest values like 100 would work fine.
#define LOTS_OF_BITS 0x40000000
static std::atomic<uint32_t> test_packet_reader_atomic_test;
typedef std::pair<const uint8_t*, const uint8_t*> ROBuffer;
class PacketReader{
protected:
bool isEof;
public:
PacketReader() {
isEof = false;
}
// returns a buffer with at least sizeof(BD_VALUE) before it
virtual ROBuffer getNext() = 0;
bool eof()const {
return isEof;
}
virtual ~PacketReader(){}
};
class TestPacketReader :public PacketReader{
const uint8_t*cur;
const uint8_t*end;
public:
TestPacketReader(const uint8_t *start, const uint8_t *ed) {
isEof = false;
cur = start;
end = ed;
}
ROBuffer getNext(){
if (cur == end) {
isEof = true;
return {NULL, NULL};
}
if (end - cur > 16) {
size_t val = (test_packet_reader_atomic_test += 7)%16 + 1;
cur += val;
return {cur - val, cur};
}
const uint8_t *ret = cur;
cur = end;
return {ret, end};
}
bool eof()const {
return isEof;
}
};
class BiRope {
public:
ROBuffer rope[2];
// if we want partial data from a previous valuex
uint8_t backing[sizeof(BD_VALUE)];
BiRope() {
memset(&backing[0], 0, sizeof(BD_VALUE));
for (size_t i= 0; i < sizeof(rope)/sizeof(rope[0]); ++i) {
rope[i] = {NULL, NULL};
}
}
void push(ROBuffer data) {
if(rope[0].first == NULL) {
rope[0] = data;
}else {
always_assert(rope[1].first == NULL);
rope[1] = data;
}
}
size_t size() const {
return (rope[0].second-rope[0].first) +
(rope[1].second - rope[1].first);
}
void memcpy_ro(uint8_t *dest, size_t size) const {
if ((ptrdiff_t)size < rope[0].second-rope[0].first) {
memcpy(dest, rope[0].first, size);
return;
}
size_t del = rope[0].second-rope[0].first;
if (del) {
memcpy(dest, rope[0].first, del);
}
dest += del;
size -=del;
if (size) {
always_assert(rope[1].second - rope[1].first >= (ptrdiff_t)size);
memcpy(dest, rope[1].first, size);
}
}
void operator += (size_t del) {
if ((ptrdiff_t)del < rope[0].second - rope[0].first) {
rope[0].first += del;
return;
}
del -= rope[0].second - rope[0].first;
rope[0] = rope[1];
rope[1] = {NULL, NULL};
always_assert((ptrdiff_t)del <= rope[0].second - rope[0].first);
rope[0].first += del;
if (rope[0].first == rope[0].second) {
rope[0] = {NULL, NULL};
}
}
/*
void memcpy_pop(uint8_t *dest, size_t size) {
if (size < rope[0].second-rope[0].first) {
memcpy(dest, rope[0].first, size);
rope[0].first += size;
return;
} else {
size_t del = rope[0].second-rope[0].first;
memcpy(dest, rope[0].first, del);
dest += del;
size -= del;
rope[0] = rope[1];
rope[1] = {NULL, NULL};
}
if (size) {
always_assert(rope[0].second - rope[0].first < size);
memcpy(dest, rope[0].first, size);
rope[0].first += size;
if (rope[0].first == rope[0].second) {
rope[0] = {NULL, NULL};
}
}
}*/
};
typedef struct {
// Be careful when reordering this struct, it may impact the cache negatively.
BD_VALUE value;
unsigned int range;
int count;
BiRope buffer;
PacketReader *reader;
// vpx_decrypt_cb decrypt_cb;
// void *decrypt_state;
} vpx_reader;
int vpx_reader_init(vpx_reader *r,
PacketReader *reader);
static INLINE void vpx_reader_fill(vpx_reader *r) {
BD_VALUE value = r->value;
int count = r->count;
size_t bytes_left = r->buffer.size();
size_t bits_left = bytes_left * CHAR_BIT;
int shift = BD_VALUE_SIZE - CHAR_BIT - (count + CHAR_BIT);
if (bits_left <= BD_VALUE_SIZE && !r->reader->eof()) {
// pull some from reader
uint8_t local_buffer[sizeof(BD_VALUE)] = {0};
r->buffer.memcpy_ro(local_buffer, bytes_left);
r->buffer += bytes_left; // clear it out
while(true) {
auto next = r->reader->getNext();
if (next.second - next.first + bytes_left <= sizeof(BD_VALUE)) {
if (next.first != next.second) {
memcpy(local_buffer + bytes_left, next.first, next.second - next.first);
}
bytes_left += next.second - next.first;
} else {
if (bytes_left) {
memcpy(r->buffer.backing, local_buffer, bytes_left);
r->buffer.push({r->buffer.backing, r->buffer.backing + bytes_left});
}
r->buffer.push(next);
break;
}
if (r->reader->eof()) {
always_assert(bytes_left <= sizeof(BD_VALUE)); // otherwise we'd have break'd
memcpy(r->buffer.backing, local_buffer, bytes_left);
r->buffer.push({r->buffer.backing, r->buffer.backing + bytes_left});
break; // setup a simplistic rope that just points to the backing store
}
}
bytes_left = r->buffer.size();
bits_left = bytes_left * CHAR_BIT;
}
if (bits_left > BD_VALUE_SIZE) {
const int bits = (shift & 0xfffffff8) + CHAR_BIT;
BD_VALUE nv;
BD_VALUE big_endian_values;
r->buffer.memcpy_ro((uint8_t*)&big_endian_values, sizeof(BD_VALUE));
if (sizeof(BD_VALUE) == 8) {
big_endian_values = htobe64(big_endian_values);
} else {
big_endian_values = htobe32(big_endian_values);
}
nv = big_endian_values >> (BD_VALUE_SIZE - bits);
count += bits;
r->buffer += (bits >> 3);
value = r->value | (nv << (shift & 0x7));
} else {
const int bits_over = (int)(shift + CHAR_BIT - bits_left);
int loop_end = 0;
if (bits_over >= 0) {
count += LOTS_OF_BITS;
loop_end = bits_over;
}
if (bits_over < 0 || bits_left) {
while (shift >= loop_end) {
count += CHAR_BIT;
uint8_t cur_val = 0;
r->buffer.memcpy_ro(&cur_val, 1);
r->buffer += 1;
value |= ((BD_VALUE)cur_val) << shift;
shift -= CHAR_BIT;
}
}
}
// NOTE: Variable 'buffer' may not relate to 'r->buffer' after decryption,
// so we increase 'r->buffer' by the amount that 'buffer' moved, rather than
// assign 'buffer' to 'r->buffer'.
r->value = value;
r->count = count;
}
// Check if we have reached the end of the buffer.
//
// Variable 'count' stores the number of bits in the 'value' buffer, minus
// 8. The top byte is part of the algorithm, and the remainder is buffered
// to be shifted into it. So if count == 8, the top 16 bits of 'value' are
// occupied, 8 for the algorithm and 8 in the buffer.
//
// When reading a byte from the user's buffer, count is filled with 8 and
// one byte is filled into the value buffer. When we reach the end of the
// data, count is additionally filled with LOTS_OF_BITS. So when
// count == LOTS_OF_BITS - 1, the user's data has been exhausted.
//
// 1 if we have tried to decode bits after the end of stream was encountered.
// 0 No error.
#define vpx_reader_has_error(r) ((r)->count > BD_VALUE_SIZE && (r)->count < LOTS_OF_BITS)
extern int r_bitcount;
constexpr static uint8_t vpx_norm[256] = {
0, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
/*
inline unsigned int count_leading_zeros_uint8(uint8_t split) {
unsigned int shift = 0;
if (split < 128) {
shift = 1;
}
if (split < 64) {
shift = 2;
}
if (split < 32) {
shift = 3;
}
if (split < 16) {
shift = 4;
}
if (split < 8) {
shift = 5;
}
if (split < 4) {
shift = 6;
}
if (split == 1) {
shift = 7;
}
return shift;
}
*/
#ifndef _WIN32
__attribute__((always_inline))
#endif
inline uint8_t count_leading_zeros_uint8(uint8_t v) {
return vpx_norm[v];
dev_assert(v);
return __builtin_clz((uint32_t)v) - 24; // slower
uint8_t r = 0; // result of log2(v) will go here
if (v & 0xf0) {
r |= 4;
v >>= 4;
}
if (v & 0xc) {
v >>= 2;
r |= 2;
}
if (v & 0x2) {
v >>= 1;
r |= 1;
}
return 7 - r;
}
inline bool vpx_reader_fill_and_read(vpx_reader *r, unsigned int split, Billing bill) {
BD_VALUE bigsplit = (BD_VALUE)split << (BD_VALUE_SIZE - CHAR_BIT);
vpx_reader_fill(r);
BD_VALUE value = r->value;
bool bit = (value >= bigsplit);
int count = r->count;
unsigned int range;
if (bit) {
range = r->range - split;
value = value - bigsplit;
} else {
range = split;
}
//unsigned int shift = vpx_norm[range];
unsigned int shift = count_leading_zeros_uint8(range);
range <<= shift;
value <<= shift;
count -= shift;
write_bit_bill(bill, true, shift);
r->value = value;
r->count = count;
r->range = range;
return bit;
}
#ifndef _WIN32
__attribute__((always_inline))
#endif
inline bool vpx_read(vpx_reader *r, int prob, Billing bill) {
int split = (r->range * prob + (256 - prob)) >> CHAR_BIT;
BD_VALUE value = r->value;
int count = r->count;
BD_VALUE bigsplit = (BD_VALUE)split << (BD_VALUE_SIZE - CHAR_BIT);
bool bit = value >= bigsplit;
unsigned int range;
#if 0
BD_VALUE mask = -(long long)bit;
value -= mask & bigsplit;
range = (r->range & mask) + (split ^ mask) - mask;
#else
if (bit) {
range = r->range - split;
value = value - bigsplit;
} else {
range = split;
}
#endif
if (__builtin_expect(r->count < 0, 0)) {
bit = vpx_reader_fill_and_read(r, split, bill);
#ifdef DEBUG_ARICODER
fprintf(stderr, "R %d %d %d\n", r_bitcount++, prob, bit);
#endif
return bit;
}
//unsigned int shift = vpx_norm[range];
unsigned int shift = count_leading_zeros_uint8(range);
range <<= shift;
value <<= shift;
count -= shift;
write_bit_bill(bill, true, shift);
r->value = value;
r->count = count;
r->range = range;
#ifdef DEBUG_ARICODER
fprintf(stderr, "R %d %d %d\n", r_bitcount++, prob, bit);
#endif
return bit;
}
#endif // VPX_DSP_BITREADER_H_
| 33.549161 | 755 | 0.573838 | interiorem |
3acf0979eed3861f923b342aae77dc26dbfba0f3 | 310 | cpp | C++ | Tests/LinearSolvers/CellEB2/main.cpp | ylunalin/amrex | 5715b2fc8a77e0db17bfe7907982e29ec44811ca | [
"BSD-3-Clause-LBNL"
] | null | null | null | Tests/LinearSolvers/CellEB2/main.cpp | ylunalin/amrex | 5715b2fc8a77e0db17bfe7907982e29ec44811ca | [
"BSD-3-Clause-LBNL"
] | null | null | null | Tests/LinearSolvers/CellEB2/main.cpp | ylunalin/amrex | 5715b2fc8a77e0db17bfe7907982e29ec44811ca | [
"BSD-3-Clause-LBNL"
] | 1 | 2020-01-17T05:00:26.000Z | 2020-01-17T05:00:26.000Z |
#include <AMReX.H>
#include "MyTest.H"
int main (int argc, char* argv[])
{
amrex::Initialize(argc, argv);
{
BL_PROFILE("main");
MyTest mytest;
for (int i = 0; i < 1; ++i) {
mytest.solve();
}
mytest.writePlotfile();
}
amrex::Finalize();
}
| 15.5 | 37 | 0.490323 | ylunalin |
3ad2fa631e1b001886c4bd5911ef229e87d4de44 | 14,056 | cpp | C++ | gen/blink/bindings/core/v8/V8TouchEvent.cpp | gergul/MiniBlink | 7a11c52f141d54d5f8e1a9af31867cd120a2c3c4 | [
"Apache-2.0"
] | 8 | 2019-05-05T16:38:05.000Z | 2021-11-09T11:45:38.000Z | gen/blink/bindings/core/v8/V8TouchEvent.cpp | gergul/MiniBlink | 7a11c52f141d54d5f8e1a9af31867cd120a2c3c4 | [
"Apache-2.0"
] | null | null | null | gen/blink/bindings/core/v8/V8TouchEvent.cpp | gergul/MiniBlink | 7a11c52f141d54d5f8e1a9af31867cd120a2c3c4 | [
"Apache-2.0"
] | 4 | 2018-12-14T07:52:46.000Z | 2021-06-11T18:06:09.000Z | // Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// This file has been auto-generated by code_generator_v8.py. DO NOT MODIFY!
#include "config.h"
#include "V8TouchEvent.h"
#include "bindings/core/v8/ExceptionState.h"
#include "bindings/core/v8/ScriptState.h"
#include "bindings/core/v8/V8DOMConfiguration.h"
#include "bindings/core/v8/V8HiddenValue.h"
#include "bindings/core/v8/V8ObjectConstructor.h"
#include "bindings/core/v8/V8TouchList.h"
#include "bindings/core/v8/V8Window.h"
#include "core/dom/ContextFeatures.h"
#include "core/dom/Document.h"
#include "core/frame/UseCounter.h"
#include "platform/RuntimeEnabledFeatures.h"
#include "platform/TraceEvent.h"
#include "wtf/GetPtr.h"
#include "wtf/RefPtr.h"
namespace blink {
// Suppress warning: global constructors, because struct WrapperTypeInfo is trivial
// and does not depend on another global objects.
#if defined(COMPONENT_BUILD) && defined(WIN32) && COMPILER(CLANG)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wglobal-constructors"
#endif
const WrapperTypeInfo V8TouchEvent::wrapperTypeInfo = { gin::kEmbedderBlink, V8TouchEvent::domTemplate, V8TouchEvent::refObject, V8TouchEvent::derefObject, V8TouchEvent::trace, 0, 0, V8TouchEvent::preparePrototypeObject, V8TouchEvent::installConditionallyEnabledProperties, "TouchEvent", &V8UIEvent::wrapperTypeInfo, WrapperTypeInfo::WrapperTypeObjectPrototype, WrapperTypeInfo::ObjectClassId, WrapperTypeInfo::NotInheritFromEventTarget, WrapperTypeInfo::Independent, WrapperTypeInfo::WillBeGarbageCollectedObject };
#if defined(COMPONENT_BUILD) && defined(WIN32) && COMPILER(CLANG)
#pragma clang diagnostic pop
#endif
// This static member must be declared by DEFINE_WRAPPERTYPEINFO in TouchEvent.h.
// For details, see the comment of DEFINE_WRAPPERTYPEINFO in
// bindings/core/v8/ScriptWrappable.h.
const WrapperTypeInfo& TouchEvent::s_wrapperTypeInfo = V8TouchEvent::wrapperTypeInfo;
namespace TouchEventV8Internal {
static void touchesAttributeGetter(const v8::FunctionCallbackInfo<v8::Value>& info)
{
v8::Local<v8::Object> holder = info.Holder();
TouchEvent* impl = V8TouchEvent::toImpl(holder);
RefPtrWillBeRawPtr<TouchList> cppValue(impl->touches());
if (cppValue && DOMDataStore::setReturnValue(info.GetReturnValue(), cppValue.get()))
return;
v8::Local<v8::Value> v8Value(toV8(cppValue.get(), holder, info.GetIsolate()));
if (!v8Value.IsEmpty()) {
V8HiddenValue::setHiddenValue(info.GetIsolate(), holder, v8AtomicString(info.GetIsolate(), "touches"), v8Value);
v8SetReturnValue(info, v8Value);
}
}
static void touchesAttributeGetterCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter");
TouchEventV8Internal::touchesAttributeGetter(info);
TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}
static void targetTouchesAttributeGetter(const v8::FunctionCallbackInfo<v8::Value>& info)
{
v8::Local<v8::Object> holder = info.Holder();
TouchEvent* impl = V8TouchEvent::toImpl(holder);
RefPtrWillBeRawPtr<TouchList> cppValue(impl->targetTouches());
if (cppValue && DOMDataStore::setReturnValue(info.GetReturnValue(), cppValue.get()))
return;
v8::Local<v8::Value> v8Value(toV8(cppValue.get(), holder, info.GetIsolate()));
if (!v8Value.IsEmpty()) {
V8HiddenValue::setHiddenValue(info.GetIsolate(), holder, v8AtomicString(info.GetIsolate(), "targetTouches"), v8Value);
v8SetReturnValue(info, v8Value);
}
}
static void targetTouchesAttributeGetterCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter");
TouchEventV8Internal::targetTouchesAttributeGetter(info);
TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}
static void changedTouchesAttributeGetter(const v8::FunctionCallbackInfo<v8::Value>& info)
{
v8::Local<v8::Object> holder = info.Holder();
TouchEvent* impl = V8TouchEvent::toImpl(holder);
RefPtrWillBeRawPtr<TouchList> cppValue(impl->changedTouches());
if (cppValue && DOMDataStore::setReturnValue(info.GetReturnValue(), cppValue.get()))
return;
v8::Local<v8::Value> v8Value(toV8(cppValue.get(), holder, info.GetIsolate()));
if (!v8Value.IsEmpty()) {
V8HiddenValue::setHiddenValue(info.GetIsolate(), holder, v8AtomicString(info.GetIsolate(), "changedTouches"), v8Value);
v8SetReturnValue(info, v8Value);
}
}
static void changedTouchesAttributeGetterCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter");
TouchEventV8Internal::changedTouchesAttributeGetter(info);
TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}
static void altKeyAttributeGetter(const v8::FunctionCallbackInfo<v8::Value>& info)
{
v8::Local<v8::Object> holder = info.Holder();
TouchEvent* impl = V8TouchEvent::toImpl(holder);
v8SetReturnValueBool(info, impl->altKey());
}
static void altKeyAttributeGetterCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter");
TouchEventV8Internal::altKeyAttributeGetter(info);
TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}
static void metaKeyAttributeGetter(const v8::FunctionCallbackInfo<v8::Value>& info)
{
v8::Local<v8::Object> holder = info.Holder();
TouchEvent* impl = V8TouchEvent::toImpl(holder);
v8SetReturnValueBool(info, impl->metaKey());
}
static void metaKeyAttributeGetterCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter");
TouchEventV8Internal::metaKeyAttributeGetter(info);
TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}
static void ctrlKeyAttributeGetter(const v8::FunctionCallbackInfo<v8::Value>& info)
{
v8::Local<v8::Object> holder = info.Holder();
TouchEvent* impl = V8TouchEvent::toImpl(holder);
v8SetReturnValueBool(info, impl->ctrlKey());
}
static void ctrlKeyAttributeGetterCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter");
TouchEventV8Internal::ctrlKeyAttributeGetter(info);
TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}
static void shiftKeyAttributeGetter(const v8::FunctionCallbackInfo<v8::Value>& info)
{
v8::Local<v8::Object> holder = info.Holder();
TouchEvent* impl = V8TouchEvent::toImpl(holder);
v8SetReturnValueBool(info, impl->shiftKey());
}
static void shiftKeyAttributeGetterCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter");
TouchEventV8Internal::shiftKeyAttributeGetter(info);
TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}
static void initTouchEventMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
{
ExceptionState exceptionState(ExceptionState::ExecutionContext, "initTouchEvent", "TouchEvent", info.Holder(), info.GetIsolate());
TouchEvent* impl = V8TouchEvent::toImpl(info.Holder());
TouchList* touches;
TouchList* targetTouches;
TouchList* changedTouches;
V8StringResource<> type;
DOMWindow* view;
int unused1;
int unused2;
int unused3;
int unused4;
bool ctrlKey;
bool altKey;
bool shiftKey;
bool metaKey;
{
touches = V8TouchList::toImplWithTypeCheck(info.GetIsolate(), info[0]);
targetTouches = V8TouchList::toImplWithTypeCheck(info.GetIsolate(), info[1]);
changedTouches = V8TouchList::toImplWithTypeCheck(info.GetIsolate(), info[2]);
type = info[3];
if (!type.prepare())
return;
view = toDOMWindow(info.GetIsolate(), info[4]);
unused1 = toInt32(info.GetIsolate(), info[5], NormalConversion, exceptionState);
if (exceptionState.throwIfNeeded())
return;
unused2 = toInt32(info.GetIsolate(), info[6], NormalConversion, exceptionState);
if (exceptionState.throwIfNeeded())
return;
unused3 = toInt32(info.GetIsolate(), info[7], NormalConversion, exceptionState);
if (exceptionState.throwIfNeeded())
return;
unused4 = toInt32(info.GetIsolate(), info[8], NormalConversion, exceptionState);
if (exceptionState.throwIfNeeded())
return;
ctrlKey = toBoolean(info.GetIsolate(), info[9], exceptionState);
if (exceptionState.throwIfNeeded())
return;
altKey = toBoolean(info.GetIsolate(), info[10], exceptionState);
if (exceptionState.throwIfNeeded())
return;
shiftKey = toBoolean(info.GetIsolate(), info[11], exceptionState);
if (exceptionState.throwIfNeeded())
return;
metaKey = toBoolean(info.GetIsolate(), info[12], exceptionState);
if (exceptionState.throwIfNeeded())
return;
}
ScriptState* scriptState = ScriptState::current(info.GetIsolate());
impl->initTouchEvent(scriptState, touches, targetTouches, changedTouches, type, view, unused1, unused2, unused3, unused4, ctrlKey, altKey, shiftKey, metaKey);
}
static void initTouchEventMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod");
UseCounter::countIfNotPrivateScript(info.GetIsolate(), callingExecutionContext(info.GetIsolate()), UseCounter::V8TouchEvent_InitTouchEvent_Method);
TouchEventV8Internal::initTouchEventMethod(info);
TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
}
} // namespace TouchEventV8Internal
static const V8DOMConfiguration::AccessorConfiguration V8TouchEventAccessors[] = {
{"touches", TouchEventV8Internal::touchesAttributeGetterCallback, 0, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnPrototype, V8DOMConfiguration::CheckHolder},
{"targetTouches", TouchEventV8Internal::targetTouchesAttributeGetterCallback, 0, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnPrototype, V8DOMConfiguration::CheckHolder},
{"changedTouches", TouchEventV8Internal::changedTouchesAttributeGetterCallback, 0, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnPrototype, V8DOMConfiguration::CheckHolder},
{"altKey", TouchEventV8Internal::altKeyAttributeGetterCallback, 0, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnPrototype, V8DOMConfiguration::CheckHolder},
{"metaKey", TouchEventV8Internal::metaKeyAttributeGetterCallback, 0, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnPrototype, V8DOMConfiguration::CheckHolder},
{"ctrlKey", TouchEventV8Internal::ctrlKeyAttributeGetterCallback, 0, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnPrototype, V8DOMConfiguration::CheckHolder},
{"shiftKey", TouchEventV8Internal::shiftKeyAttributeGetterCallback, 0, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnPrototype, V8DOMConfiguration::CheckHolder},
};
static const V8DOMConfiguration::MethodConfiguration V8TouchEventMethods[] = {
{"initTouchEvent", TouchEventV8Internal::initTouchEventMethodCallback, 0, 0, V8DOMConfiguration::ExposedToAllScripts},
};
static void installV8TouchEventTemplate(v8::Local<v8::FunctionTemplate> functionTemplate, v8::Isolate* isolate)
{
functionTemplate->ReadOnlyPrototype();
v8::Local<v8::Signature> defaultSignature;
defaultSignature = V8DOMConfiguration::installDOMClassTemplate(isolate, functionTemplate, "TouchEvent", V8UIEvent::domTemplate(isolate), V8TouchEvent::internalFieldCount,
0, 0,
V8TouchEventAccessors, WTF_ARRAY_LENGTH(V8TouchEventAccessors),
V8TouchEventMethods, WTF_ARRAY_LENGTH(V8TouchEventMethods));
v8::Local<v8::ObjectTemplate> instanceTemplate = functionTemplate->InstanceTemplate();
ALLOW_UNUSED_LOCAL(instanceTemplate);
v8::Local<v8::ObjectTemplate> prototypeTemplate = functionTemplate->PrototypeTemplate();
ALLOW_UNUSED_LOCAL(prototypeTemplate);
// Custom toString template
functionTemplate->Set(v8AtomicString(isolate, "toString"), V8PerIsolateData::from(isolate)->toStringTemplate());
}
v8::Local<v8::FunctionTemplate> V8TouchEvent::domTemplate(v8::Isolate* isolate)
{
return V8DOMConfiguration::domClassTemplate(isolate, const_cast<WrapperTypeInfo*>(&wrapperTypeInfo), installV8TouchEventTemplate);
}
bool V8TouchEvent::hasInstance(v8::Local<v8::Value> v8Value, v8::Isolate* isolate)
{
return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, v8Value);
}
v8::Local<v8::Object> V8TouchEvent::findInstanceInPrototypeChain(v8::Local<v8::Value> v8Value, v8::Isolate* isolate)
{
return V8PerIsolateData::from(isolate)->findInstanceInPrototypeChain(&wrapperTypeInfo, v8Value);
}
TouchEvent* V8TouchEvent::toImplWithTypeCheck(v8::Isolate* isolate, v8::Local<v8::Value> value)
{
return hasInstance(value, isolate) ? toImpl(v8::Local<v8::Object>::Cast(value)) : 0;
}
void V8TouchEvent::refObject(ScriptWrappable* scriptWrappable)
{
#if !ENABLE(OILPAN)
scriptWrappable->toImpl<TouchEvent>()->ref();
#endif
}
void V8TouchEvent::derefObject(ScriptWrappable* scriptWrappable)
{
#if !ENABLE(OILPAN)
scriptWrappable->toImpl<TouchEvent>()->deref();
#endif
}
} // namespace blink
| 47.647458 | 516 | 0.75434 | gergul |
3ad3d2b5f3fe498e5c94217c4a0518db7ca0052b | 18,162 | cpp | C++ | MyNetPhoneServer/encoder/countbit.cpp | Vladimir-Novick/MyNetPhone | 3994085b46ac059e0523ddaf0f5b6effc388106a | [
"MIT"
] | 2 | 2019-06-03T07:29:08.000Z | 2022-01-08T17:41:28.000Z | MyNetPhoneServer/encoder/countbit.cpp | Vladimir-Novick/MyNetPhone | 3994085b46ac059e0523ddaf0f5b6effc388106a | [
"MIT"
] | 1 | 2020-08-28T07:37:25.000Z | 2020-08-28T07:37:25.000Z | MyNetPhoneServer/encoder/countbit.cpp | Vladimir-Novick/MyNetPhone | 3994085b46ac059e0523ddaf0f5b6effc388106a | [
"MIT"
] | null | null | null | ////////////////////////////////////////////////////////////////////////////
//
//
// Project : VideoNet Ver. 1.0.
// Description : Video Conferencing over the LAN.
// Author : Vladiimir Novick ( v_novick@yahoo.com )
// Date : 17/12/2005
//
// I have converted origional fast h.263 encoder library from C to C++
// so that it can be integrated into any windows application easily.
// I have removed some of unnecessary codes/files from the
// fast h263 library.Also moved definitions and declarations
// in their proper .h and .cpp files.
//
// File description :
// Name : countbit.cpp
//
//
/////////////////////////////////////////////////////////////////////////////
/*************************************************
* libr263: fast H.263 encoder library
*
* Copyright (C) 1996, Roalt Aalmoes, Twente University
* SPA multimedia group
*
* Based on Telenor TMN 1.6 encoder (Copyright (C) 1995, Telenor R&D)
* created by Karl Lillevold
*
* Author encoder: Roalt Aalmoes, <aalmoes@huygens.nl>
*
* Date: 31-07-96
**************************************************/
/**********************************************************************
*
* Name: CountBitsMB
* Description: counts bits used for MB info
*
* Input: Mode, COD, CBP, Picture and Bits structures
* Returns:
* Side effects:
*
* Date: 941129 Author: Karl.Lillevold@nta.no
*
***********************************************************************/
#include "stdafx.h"
#include "countbit.h"
void CountBitsMB(int Mode, int COD, int CBP, int CBPB, Pict *pic, Bits *bits)
{
extern EHUFF *vlc_cbpy, *vlc_cbpcm, *vlc_cbpcm_intra;
int cbpy, cbpcm, length;
/* COD */
if (Global::trace) {
fprintf(Global::tf,"MB-nr: %d",pic->MB);
if (pic->picture_coding_type == PCT_INTER)
fprintf(Global::tf," COD: %d\n",COD);
}
if (pic->picture_coding_type == PCT_INTER) {
mputv(1,COD);
bits->COD++;
}
if (COD)
return; /* not coded */
/* CBPCM */
cbpcm = Mode | ((CBP&3)<<4);
if (Global::trace) {
fprintf(Global::tf,"CBPCM (CBP=%d) (cbpcm=%d): ",CBP,cbpcm);
}
if (pic->picture_coding_type == PCT_INTRA) {
length = Encode(cbpcm,vlc_cbpcm_intra);
} else {
length = Encode(cbpcm,vlc_cbpcm);
}
bits->CBPCM += length;
/* CBPY */
cbpy = CBP>>2;
if (Mode == MODE_INTRA || Mode == MODE_INTRA_Q) /* Intra */
cbpy = cbpy^15;
if (Global::trace) {
fprintf(Global::tf,"CBPY (CBP=%d) (cbpy=%d): ",CBP,cbpy);
}
length = Encode(cbpy, vlc_cbpy);
bits->CBPY += length;
return;
}
/**********************************************************************
*
* Name: CountBitsSlice
* Description: couonts bits used for slice (GOB) info
*
* Input: slice no., quantizer
*
* Date: 94???? Author: Karl.Lillevold@nta.no
*
***********************************************************************/
int CountBitsSlice(int slice, int quant)
{
int bits = 0;
/* Picture Start Code */
if (Global::trace)
fprintf(Global::tf,"GOB sync (GBSC): ");
mputv(PSC_LENGTH,PSC); /* PSC */
bits += PSC_LENGTH;
/* Group Number */
if (Global::trace)
fprintf(Global::tf,"GN: ");
mputv(5,slice);
bits += 5;
/* GOB Sub Bitstream Indicator */
/* if CPM == 1: read 2 bits GSBI */
/* not supported in this version */
/* GOB Frame ID */
if (Global::trace)
fprintf(Global::tf,"GFID: ");
mputv(2, 0);
/* NB: in error-prone environments this value should change if
PTYPE in picture header changes. In this version of the encoder
PTYPE only changes when PB-frames are used in the following cases:
(i) after the first intra frame
(ii) if the distance between two P-frames is very large
Therefore I haven't implemented this GFID change */
/* GFID is not allowed to change unless PTYPE changes */
bits += 2;
/* Gquant */
if (Global::trace)
fprintf(Global::tf,"GQUANT: ");
mputv(5,quant);
bits += 5;
return bits;
}
/**********************************************************************
*
* Name: CountBitsCoeff
* Description: counts bits used for coeffs
*
* Input: qcoeff, coding mode CBP, bits structure, no. of
* coeffs
*
* Returns: struct with no. of bits used
* Side effects:
*
* Date: 940111 Author: Karl.Lillevold@nta.no
*
***********************************************************************/
void CountBitsCoeff(int *qcoeff, int Mode, int CBP, Bits *bits, int ncoeffs)
{
int i;
if (Mode == MODE_INTRA) {
for (i = 0; i < 4; i++) {
bits->Y += CodeCoeff(Mode, qcoeff,i,ncoeffs);
}
for (i = 4; i < 6; i++) {
bits->C += CodeCoeff(Mode, qcoeff,i,ncoeffs);
}
}
else {
for (i = 0; i < 4; i++) {
if ((i==0 && CBP&32) ||
(i==1 && CBP&16) ||
(i==2 && CBP&8) ||
(i==3 && CBP&4) ||
(i==4 && CBP&2) ||
(i==5 && CBP&1)) {
bits->Y += CodeCoeff(Mode, qcoeff, i, ncoeffs);
}
}
for (i = 4; i < 6; i++) {
if ((i==0 && CBP&32) ||
(i==1 && CBP&16) ||
(i==2 && CBP&8) ||
(i==3 && CBP&4) ||
(i==4 && CBP&2) ||
(i==5 && CBP&1)) {
bits->C += CodeCoeff(Mode, qcoeff, i, ncoeffs);
}
}
}
return;
}
int CodeCoeff(int Mode, int *qcoeff, int block, int ncoeffs)
{
int j, bits;
int prev_run, run, prev_level, level, first;
int prev_ind, ind, prev_s, s, length;
extern EHUFF *vlc_3d;
run = bits = 0;
first = 1;
prev_run = prev_level = prev_ind = level = s = prev_s = ind = 0;
for (j = block*ncoeffs; j< (block + 1)*ncoeffs; j++) {
/* Do this block's DC-coefficient first */
if (!(j%ncoeffs) && (Mode == MODE_INTRA)) {
/* DC coeff */
if (Global::trace) {
fprintf(Global::tf,"DC: ");
}
if (qcoeff[block*ncoeffs] != 128)
mputv(8,qcoeff[block*ncoeffs]);
else
mputv(8,255);
bits += 8;
}
else {
/* AC coeff */
s = 0;
/* Increment run if coeff is zero */
if ((level = qcoeff[j]) == 0) {
run++;
}
else {
/* code run & level and count bits */
if (level < 0) {
s = 1;
level = -level;
}
ind = level | run<<4;
ind = ind | 0<<12; /* Not last coeff */
if (!first) {
/* Encode the previous ind */
if (prev_level < 13 && prev_run < 64) {
length = Encode(prev_ind,vlc_3d);
} else
length = 0;
if (length == 0) { /* Escape coding */
if (Global::trace) {
fprintf(Global::tf,"Escape coding:\n");
}
if (prev_s == 1) {prev_level = (prev_level^0xff)+1;}
Encode(ESCAPE,vlc_3d);
mputv(1,0);
mputv(6,prev_run);
mputv(8,prev_level);
bits += 22;
}
else {
mputv(1,prev_s);
bits += length + 1;
}
}
prev_run = run; prev_s = s;
prev_level = level; prev_ind = ind;
run = first = 0;
}
}
}
/* Encode the last coeff */
if (!first) {
if (Global::trace) {
fprintf(Global::tf,"Last coeff: ");
}
prev_ind = prev_ind | 1<<12; /* last coeff */
if (prev_level < 13 && prev_run < 64) {
length = Encode(prev_ind,vlc_3d);
} else
length = 0;
if (length == 0) { /* Escape coding */
if (Global::trace) {
fprintf(Global::tf,"Escape coding:\n");
}
if (prev_s == 1) {prev_level = (prev_level^0xff)+1;}
Encode(ESCAPE,vlc_3d);
mputv(1,1);
mputv(6,prev_run);
mputv(8,prev_level);
bits += 22;
}
else {
mputv(1,prev_s);
bits += length + 1;
}
}
return bits;
}
/**********************************************************************
*
* Name: FindCBP
* Description: Finds the CBP for a macroblock
*
* Input: qcoeff and mode
*
* Returns: CBP
* Side effects:
*
* Date: 940829 Author: Karl.Lillevold@nta.no
*
***********************************************************************/
int FindCBP(int *qcoeff, int Mode, int ncoeffs)
{
int i,j;
int CBP = 0;
/* IF INTRABLOCK then intra =1 else 0 */
int intra = (Mode == MODE_INTRA);
/* Set CBP for this Macroblock */
for (i = 0; i < 6; i++) {
/* First time i = 0: j = 0 ..64-1 set bit 5 if coeff != 0
Sec. time i = 1; j = 64..128-1 set bit 4 if coeff != 0
*/
/* OPTIMIZE: I think for i can be removed
and only values i=0 must be proessed */
for (j = i*ncoeffs + intra; j < (i+1)*ncoeffs; j++) {
if (qcoeff[j]) {
if (i == 0) {CBP |= 32;}
else if (i == 1) {CBP |= 16;}
else if (i == 2) {CBP |= 8;}
else if (i == 3) {CBP |= 4;}
else if (i == 4) {CBP |= 2;}
else if (i == 5) {CBP |= 1;}
else {
fprintf(stderr,"Error in CBP assignment\n");
exit(-1);
}
break;
}
}
}
return CBP;
}
void CountBitsVectors(MotionVector *MV_ptr, Bits *bits,
int x, int y, int Mode, int newgob, Pict *pic)
{
int y_vec, x_vec;
extern EHUFF *vlc_mv;
int pmv0, pmv1;
int start,stop,block;
MotionVector *MV_xy;
start = 0; stop = 0;
MV_xy = MV_ptr + y*Global::mbc + x;
for (block = start; block <= stop; block++) {
FindPMV(MV_ptr,x,y,&pmv0,&pmv1, block, newgob, 1);
x_vec = (2*(*MV_xy).x + (*MV_xy).x_half) - pmv0;
y_vec = (2*(*MV_xy).y + (*MV_xy).y_half) - pmv1;
if (!Global::long_vectors) {
if (x_vec < -32) x_vec += 64;
else if (x_vec > 31) x_vec -= 64;
if (y_vec < -32) y_vec += 64;
else if (y_vec > 31) y_vec -= 64;
}
else {
if (pmv0 < -31 && x_vec < -63) x_vec += 64;
else if (pmv0 > 32 && x_vec > 63) x_vec -= 64;
if (pmv1 < -31 && y_vec < -63) y_vec += 64;
else if (pmv1 > 32 && y_vec > 63) y_vec -= 64;
}
if (x_vec < 0) x_vec += 64;
if (y_vec < 0) y_vec += 64;
if (Global::trace) {
fprintf(Global::tf,"Vectors:\n");
}
bits->vec += Encode(x_vec,vlc_mv);
bits->vec += Encode(y_vec,vlc_mv);
if (Global::trace) {
if (x_vec > 31) x_vec -= 64;
if (y_vec > 31) y_vec -= 64;
fprintf(Global::tf,"(x,y) = (%d,%d) - ",
(2*(*MV_xy).x + (*MV_xy).x_half),
(2*(*MV_xy).y + (*MV_xy).y_half));
fprintf(Global::tf,"(Px,Py) = (%d,%d)\n", pmv0,pmv1);
fprintf(Global::tf,"(x_diff,y_diff) = (%d,%d)\n",x_vec,y_vec);
}
}
return;
}
void FindPMV(MotionVector *MV_ptr, int x, int y,
int *pmv0, int *pmv1, int block, int newgob, int half_pel)
{
int p1,p2,p3;
int xin1,xin2,xin3;
int yin1,yin2,yin3;
int vec1,vec2,vec3;
int l8,o8,or8;
l8 = o8 = or8 = 0;
vec1 = (l8 ? 2 : 0) ; yin1 = y ; xin1 = x-1;
vec2 = (o8 ? 3 : 0) ; yin2 = y-1; xin2 = x;
vec3 = (or8? 3 : 0) ; yin3 = y-1; xin3 = x+1;
if (half_pel) {
p1 = (x > 0) ?
2*((*(MV_ptr + yin1*Global::mbc + xin1)).x) + (*(MV_ptr+ yin1*Global::mbc + xin1)).x_half : 0;
p2 = (y > 0) ?
2*((*(MV_ptr + yin2*Global::mbc + xin2)).x) + (*(MV_ptr + yin2*Global::mbc + xin2)).x_half : 2*NO_VEC;
if((y > 0) && (x < Global::mbc - 1))
p3 = 2*((*(MV_ptr+yin3*Global::mbc + xin3)).x) + ((*(MV_ptr + yin3*Global::mbc + xin3)).x_half);
else if(x == Global::mbc - 1)
p3 = 0;
else /* y == 0 && x != Global::mbc - 1 */
p3 = 2*NO_VEC;
}
else {
p1 = (x > 0) ?
(2*((*(MV_ptr + yin1*Global::mbc + xin1)).x)) : 0;
p2 = (y > 0) ?
(2*((*(MV_ptr + yin2*Global::mbc + xin2)).x)) : 2*NO_VEC;
if((y > 0) && (x < Global::mbc - 1))
p3 = 2*((*(MV_ptr + yin3*Global::mbc + xin3)).x);
else if(x == Global::mbc - 1)
p3 = 0;
else /* y == 0 && x != Global::mbc - 1 */
p3 = 2*NO_VEC;
}
if (newgob && (block == 0 || block == 1 || block == 2))
p2 = 2*NO_VEC;
if (p2 == 2*NO_VEC) { p2 = p3 = p1; }
*pmv0 = p1+p2+p3 - mmax(p1,mmax(p2,p3)) - mmin(p1,mmin(p2,p3));
if (half_pel) {
p1 = (x > 0) ?
(2*((*(MV_ptr + yin1*Global::mbc + xin1)).y)) + ((*(MV_ptr + yin1*Global::mbc + xin1)).y_half) : 0;
p2 = (y > 0) ?
2*((*(MV_ptr + yin2*Global::mbc + xin2)).y) + ((*(MV_ptr + yin2*Global::mbc + xin2)).y_half) : 2*NO_VEC;
if((y > 0) && (x < Global::mbc - 1))
p3 = 2*((*(MV_ptr + yin3*Global::mbc + xin3)).y) + ((*(MV_ptr + Global::mbc*yin3 + xin3)).y_half);
else if(x == Global::mbc - 1)
p3 = 0;
else /* y == 0 && x != Global::mbc - 1 */
p3 = 2*NO_VEC;
}
else {
p1 = (x > 0) ?
(2*((*(MV_ptr + yin1*Global::mbc + xin1)).y)) : 0;
p2 = (y > 0) ?
(2*((*(MV_ptr + yin2*Global::mbc + xin2)).y)) : 2*NO_VEC;
if((y > 0) && (x < Global::mbc - 1))
p3 = 2*((*(MV_ptr + yin3*Global::mbc + xin3)).y);
else if(x == Global::mbc - 1)
p3 = 0;
else /* y == 0 && x != Global::mbc - 1 */
p3 = 2*NO_VEC;
}
if (newgob && (block == 0 || block == 1 || block == 2))
p2 = 2*NO_VEC;
if (p2 == 2*NO_VEC) { p2 = p3 = p1; }
*pmv1 = p1+p2+p3 - mmax(p1,mmax(p2,p3)) - mmin(p1,mmin(p2,p3));
return;
}
void ZeroBits(Bits *bits)
{
#ifndef MINIMAL_REPORT
bits->Y = 0;
bits->C = 0;
bits->vec = 0;
bits->CBPY = 0;
bits->CBPCM = 0;
bits->MODB = 0;
bits->CBPB = 0;
bits->COD = 0;
bits->DQUANT = 0;
bits->header = 0;
bits->total = 0;
bits->no_inter = 0;
bits->no_inter4v = 0;
bits->no_intra = 0;
#endif
return;
}
void ZeroRes(Results *res)
{
#ifndef MINIMAL_REPORT
res->SNR_l = 0;
res->SNR_Cr = 0;
res->SNR_Cb = 0;
res->QP_mean = 0;
#endif
}
void AddBits(Bits *total, Bits *bits)
{
#ifndef MINIMAL_REPORT
total->Y += bits->Y;
total->C += bits->C;
total->vec += bits->vec;
total->CBPY += bits->CBPY;
total->CBPCM += bits->CBPCM;
total->MODB += bits->MODB;
total->CBPB += bits->CBPB;
total->COD += bits->COD;
total->DQUANT += bits->DQUANT;
total->header += bits->header;
total->total += bits->total;
total->no_inter += bits->no_inter;
total->no_inter4v += bits->no_inter4v;
total->no_intra += bits->no_intra;
#endif
return;
}
void AddRes(Results *total, Results *res, Pict *pic)
{
#ifndef MINIMAL_REPORT
total->SNR_l += res->SNR_l;
total->SNR_Cr += res->SNR_Cr;
total->SNR_Cb += res->SNR_Cb;
total->QP_mean += pic->QP_mean;
#endif
return;
}
void AddBitsPicture(Bits *bits)
{
#ifndef MINIMAL_REPORT
bits->total =
bits->Y +
bits->C +
bits->vec +
bits->CBPY +
bits->CBPCM +
bits->MODB +
bits->CBPB +
bits->COD +
bits->DQUANT +
bits->header ;
#endif
}
void ZeroVec(MotionVector *MV)
{
MV->x = 0;
MV->y = 0;
MV->x_half = 0;
MV->y_half = 0;
return;
}
void MarkVec(MotionVector *MV)
{
MV->x = NO_VEC;
MV->y = NO_VEC;
MV->x_half = 0;
MV->y_half = 0;
return;
}
void CopyVec(MotionVector *MV2, MotionVector *MV1)
{
MV2->x = MV1->x;
MV2->x_half = MV1->x_half;
MV2->y = MV1->y;
MV2->y_half = MV1->y_half;
return;
}
int EqualVec(MotionVector *MV2, MotionVector *MV1)
{
if (MV1->x != MV2->x)
return 0;
if (MV1->y != MV2->y)
return 0;
if (MV1->x_half != MV2->x_half)
return 0;
if (MV1->y_half != MV2->y_half)
return 0;
return 1;
}
/**********************************************************************
*
* Name: CountBitsPicture(Pict *pic)
* Description: counts the number of bits needed for picture
* header
*
* Input: pointer to picture structure
* Returns: number of bits
* Side effects:
*
* Date: 941128 Author:Karl.Lillevold@nta.no
*
***********************************************************************/
int CountBitsPicture(Pict *pic)
{
int bits = 0;
/* Picture start code */
if (Global::trace) {
fprintf(Global::tf,"picture_start_code: ");
}
mputv(PSC_LENGTH,PSC);
bits += PSC_LENGTH;
/* Group number */
if (Global::trace) {
fprintf(Global::tf,"Group number in picture header: ");
}
mputv(5,0);
bits += 5;
/* Time reference */
if (Global::trace) {
fprintf(Global::tf,"Time reference: ");
}
mputv(8,pic->TR);
bits += 8;
/* bit 1 */
if (Global::trace) {
fprintf(Global::tf,"spare: ");
}
pic->spare = 1; /* always 1 to avoid start code emulation */
mputv(1,pic->spare);
bits += 1;
/* bit 2 */
if (Global::trace) {
fprintf(Global::tf,"always zero for distinction with H.261\n");
}
mputv(1,0);
bits += 1;
/* bit 3 */
if (Global::trace) {
fprintf(Global::tf,"split_screen_indicator: ");
}
mputv(1,0); /* no support for split-screen in this software */
bits += 1;
/* bit 4 */
if (Global::trace) {
fprintf(Global::tf,"document_camera_indicator: ");
}
mputv(1,0);
bits += 1;
/* bit 5 */
if (Global::trace) {
fprintf(Global::tf,"freeze_picture_release: ");
}
mputv(1,0);
bits += 1;
/* bit 6-8 */
if (Global::trace) {
fprintf(Global::tf,"source_format: ");
}
mputv(3,pic->source_format);
bits += 3;
/* bit 9 */
if (Global::trace) {
fprintf(Global::tf,"picture_coding_type: ");
}
mputv(1,pic->picture_coding_type);
bits += 1;
/* bit 10 */
if (Global::trace) {
fprintf(Global::tf,"Global::mv_outside_frame: ");
}
mputv(1,pic->unrestricted_mv_mode); /* Unrestricted Motion Vector mode */
bits += 1;
/* bit 11 */
if (Global::trace) {
fprintf(Global::tf,"sac_coding: ");
}
mputv(1,0); /* Syntax-based Arithmetic Coding mode not used*/
bits += 1;
/* bit 12 */
if (Global::trace) {
fprintf(Global::tf,"adv_pred_mode: ");
}
mputv(1,Global::advanced); /* Advanced Prediction mode */
bits += 1;
/* bit 13 */
if (Global::trace) {
fprintf(Global::tf,"PB-coded: "); /* PB-frames mode */
}
mputv(1,pic->PB);
bits += 1;
/* QUANT */
if (Global::trace) {
fprintf(Global::tf,"QUANT: ");
}
mputv(5,pic->QUANT);
bits += 5;
/* Continuous Presence Multipoint (CPM) */
mputv(1,0); /* CPM is not supported in this software */
bits += 1;
/* Picture Sub Bitstream Indicator (PSBI) */
/* if CPM == 1: 2 bits PSBI */
/* not supported */
/* PEI (extra information) */
if (Global::trace) {
fprintf(Global::tf,"PEI: ");
}
/* "Encoders shall not insert PSPARE until specified by the ITU" */
mputv(1,0);
bits += 1;
/* PSPARE */
/* if PEI == 1: 8 bits PSPARE + another PEI bit */
/* not supported */
return bits;
}
| 23.465116 | 110 | 0.515086 | Vladimir-Novick |
3ad4e3bc5b94c28b7cebaed5d154cd076fb3d5a8 | 9,310 | cpp | C++ | src/boost/webclient/polyfill/shared_composed_op.spec.cpp | madmongo1/webclient | 7eb52899443a76ced83b6f286b0e0d688f02fc65 | [
"BSL-1.0"
] | 3 | 2020-06-12T02:22:41.000Z | 2021-03-23T14:18:01.000Z | src/boost/webclient/polyfill/shared_composed_op.spec.cpp | madmongo1/webclient | 7eb52899443a76ced83b6f286b0e0d688f02fc65 | [
"BSL-1.0"
] | 1 | 2020-06-12T02:29:08.000Z | 2020-07-18T10:07:05.000Z | src/boost/webclient/polyfill/shared_composed_op.spec.cpp | madmongo1/webclient | 7eb52899443a76ced83b6f286b0e0d688f02fc65 | [
"BSL-1.0"
] | null | null | null | //
// Copyright (c) 2020 Richard Hodges (hodges.r@gmail.com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
// Official repository: https://github.com/madmongo1/webclient
//
// This project was made possible with the generous support of:
// The C++ Alliance (https://cppalliance.org/)
// Jetbrains (https://www.jetbrains.com/)
//
// Talk to us on Slack (https://cppalliance.org/slack/)
//
// Many thanks to Vinnie Falco for continuous mentoring and support
//
#include "boost/webclient/polyfill/shared_composed_op.hpp"
#include <boost/asio/async_result.hpp>
#include <boost/asio/coroutine.hpp>
#include <boost/asio/executor.hpp>
#include <boost/asio/high_resolution_timer.hpp>
#include <boost/asio/ip/tcp.hpp>
#include <boost/beast/_experimental/test/handler.hpp>
#include <boost/beast/core/bind_handler.hpp>
#include <catch2/catch.hpp>
#include <iostream>
using namespace boost::webclient;
using boost::beast::bind_front_handler;
struct has_error
{
error_code error;
error_code &assign_error(error_code &ec)
{
if (not error.failed() and ec.failed())
error = ec;
return error;
}
};
template < class Derived >
struct has_timeout
{
has_timeout(net::executor e, std::chrono::milliseconds to)
: timer_(e)
, to_(to)
{
}
struct timer_event
{
};
template < class Self >
void start_timeout(Self self)
{
timer_.expires_after(to_);
timer_.async_wait(bind_front_handler(self, timer_event()));
}
void cancel_timeout() { timer_.cancel(); }
template < class Self >
void operator()(Self &self, timer_event, error_code ec)
{
auto &this_ = *static_cast< Derived * >(this);
timeout = true;
if (ec == net::error::operation_aborted)
ec.clear();
else if (ec == error_code())
{
ec = net::error::timed_out;
this_.on_timeout();
}
this_(self, this_.assign_error(ec));
}
bool timeout = false;
net::high_resolution_timer timer_;
net::high_resolution_timer::duration to_;
};
template < class Protocol, class Derived >
struct has_resolver
{
using resolver = typename Protocol::resolver;
using resolver_results = typename resolver::results_type;
has_resolver(net::executor e)
: resolver_(e)
{
}
void cancel_resolver() { resolver_.cancel(); }
template < class Self >
void start_resolving(Self self, std::string const &hostname, std::string const &service)
{
resolver_.async_resolve(hostname, service, self);
}
template < class Self >
void operator()(Self &self, error_code ec, typename resolver::results_type results)
{
auto &this_ = *static_cast< Derived * >(this);
resolved = true;
if (ec == net::error::operation_aborted)
ec.clear();
else if (ec.failed())
this_.cancel_timeout();
else
endpoints = results;
this_(self, this_.assign_error(ec));
}
resolver resolver_;
resolver_results endpoints;
bool resolved = false;
};
template < class Protocol, class Derived >
struct has_multiconnect
{
has_multiconnect() {}
private:
using protocol = Protocol;
using socket_type = typename protocol::socket;
using endpoint_type = typename protocol::endpoint;
using resolver = typename protocol::resolver;
using resolver_results = typename resolver::results_type;
struct socket_id
{
std::size_t sock;
};
public:
void cancel_connects()
{
if (not sockets_canceled)
{
sockets_canceled = true;
for (auto &s : socks)
s.cancel();
}
}
template < class Self >
void operator()(Self &self, socket_id id, error_code ec)
{
auto &this_ = *static_cast< Derived * >(this);
--sockets_remaining;
if (not ec.failed() and not sockets_canceled) // we are first socket to complete
{
this->cancel_connects();
this_.on_socket_connect(std::move(socks[id.sock]));
}
else if (ec == net::error::operation_aborted)
ec.clear();
if (sockets_remaining)
ec.clear();
this_(self, this_.assign_error(ec));
}
template < class Self >
void initiate_connects(Self self, resolver_results const &endpoints)
{
std::transform(endpoints.begin(),
endpoints.end(),
std::back_inserter(socks),
[&](typename resolver_results::value_type const&) { return socket_type(self.get_executor()); });
auto i = std::size_t(0);
for (auto &&epi : endpoints)
{
socks[i].async_connect(epi.endpoint(), boost::beast::bind_front_handler(self, socket_id { i }));
++i;
}
sockets_remaining = i;
}
std::vector< socket_type > socks;
std::size_t sockets_remaining = 0;
bool sockets_canceled = false;
};
template < class Socket >
struct mass_connect_op
: net::coroutine
, has_error
, has_timeout< mass_connect_op< Socket > >
, has_resolver< typename Socket::protocol_type, mass_connect_op< Socket > >
, has_multiconnect< typename Socket::protocol_type, mass_connect_op< Socket > >
{
using protocol = typename Socket::protocol_type;
using socket_type = typename protocol::socket;
using endpoint_type = typename protocol::endpoint;
using resolver = typename protocol::resolver;
mass_connect_op(Socket &sock, std::string hostname, std::string port, std::chrono::milliseconds timeout)
: net::coroutine()
, has_error()
, has_timeout< mass_connect_op< Socket > >(sock.get_executor(), timeout)
, has_resolver< protocol, mass_connect_op< Socket > >(sock.get_executor())
, has_multiconnect< protocol, mass_connect_op< Socket > >()
, sock_(sock)
, hostname_(std::move(hostname))
, port_(std::move(port))
{
}
using has_timeout< mass_connect_op< Socket > >:: operator();
using has_resolver< protocol, mass_connect_op< Socket > >:: operator();
using has_multiconnect< protocol, mass_connect_op< Socket > >::operator();
void on_timeout()
{
this->cancel_resolver();
this->cancel_connects();
}
void on_resolved() { this->cancel_timeout(); }
void on_socket_connect(Socket s)
{
this->cancel_timeout();
sock_ = std::move(s);
}
template < class Self >
void operator()(Self &self, error_code ec = {})
{
using polyfill::share;
#include <boost/asio/yield.hpp>
reenter(this) for (;;)
{
// transform this coroutine into a shared coroutine
yield share(self);
// start the timer and a resolve operation
yield
{
this->start_timeout(share(self));
this->start_resolving(share(self), hostname_, port_);
}
// wait for the resolve to complete one way or another
while (not this->resolved)
yield;
// if we have a failure, complete...
if (ec.failed())
{
// ... after ensuring that the timer completion handler has been invoked
while (not this->timeout)
yield;
}
else
{
// otherwise, simulatenously connect to all endpoints
yield this->initiate_connects(share(self), this->endpoints);
// yield until all connect completion handlers have been invoked
while (this->sockets_remaining)
yield;
// and yield until the timer completion handler has been invoked
while (not this->timeout)
yield;
}
// return the result of the connect
return self.complete(ec);
}
#include <boost/asio/unyield.hpp>
}
Socket & sock_;
std::string hostname_, port_;
};
template < class Socket, class CompletionToken >
auto async_mass_connect(Socket & sock,
std::string host,
std::string port,
std::chrono::milliseconds timeout,
CompletionToken && token)
-> BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(CompletionToken, void(error_code))
{
return net::async_compose< CompletionToken, void(error_code) >(
mass_connect_op< Socket >(sock, std::move(host), std::move(port), timeout), token, sock);
}
TEST_CASE("boost::webclient::polyfill::shared_composed_op")
{
net::io_context ioc;
auto s = net::ip::tcp::socket(ioc);
async_mass_connect(s, "www.example.com", "http", std::chrono::seconds(10), [&](error_code ec) {
std::cout << ec.message() << std::endl;
auto ep = s.remote_endpoint(ec);
std::cout << ep << std::endl;
});
boost::beast::test::run(ioc);
} | 29.27673 | 119 | 0.596563 | madmongo1 |
3ad60ba5845969a9b65dbf3984d84a27b34c7700 | 13,036 | tcc | C++ | include/elements/3d/hexahedron_bspline_element.tcc | jgiven100/mpm-1 | adc83ab57782874d4dce1ac13be46bca1754a0fe | [
"MIT"
] | null | null | null | include/elements/3d/hexahedron_bspline_element.tcc | jgiven100/mpm-1 | adc83ab57782874d4dce1ac13be46bca1754a0fe | [
"MIT"
] | null | null | null | include/elements/3d/hexahedron_bspline_element.tcc | jgiven100/mpm-1 | adc83ab57782874d4dce1ac13be46bca1754a0fe | [
"MIT"
] | null | null | null | //! Assign nodal connectivity property for bspline elements
template <unsigned Tdim, unsigned Tnfunctions>
void mpm::HexahedronBSplineElement<Tdim, Tnfunctions>::
initialise_bspline_connectivity_properties(
const Eigen::MatrixXd& nodal_coordinates,
const std::vector<std::vector<unsigned>>& nodal_properties) {
assert(nodal_coordinates.rows() == nodal_properties.size());
this->nconnectivity_ = nodal_coordinates.rows();
this->nodal_coordinates_ = nodal_coordinates;
this->node_type_ = nodal_properties;
//! Uniform spacing length in 3D
this->spacing_length_ =
std::abs(nodal_coordinates(1, 0) - nodal_coordinates(0, 0));
}
//! Return shape functions of a Hexahedron BSpline Element at a given
//! local coordinate
template <unsigned Tdim, unsigned Tpolynomial>
inline Eigen::VectorXd
mpm::HexahedronBSplineElement<Tdim, Tpolynomial>::shapefn(
const Eigen::Matrix<double, Tdim, 1>& xi,
const Eigen::Matrix<double, Tdim, 1>& particle_size,
const Eigen::Matrix<double, Tdim, 1>& deformation_gradient) const {
//! To store shape functions
Eigen::VectorXd shapefn =
Eigen::VectorXd::Constant(this->nconnectivity_, 1.0);
if (this->nconnectivity_ == 8)
return mpm::HexahedronElement<Tdim, 8>::shapefn(xi, particle_size,
deformation_gradient);
try {
//! Convert local coordinates to real coordinates
Eigen::Matrix<double, Tdim, 1> pcoord;
pcoord.setZero();
auto local_shapefn =
this->shapefn_local(xi, particle_size, deformation_gradient);
for (unsigned i = 0; i < local_shapefn.size(); ++i)
pcoord.noalias() +=
local_shapefn(i) * nodal_coordinates_.row(i).transpose();
//! Compute shape function following a multiplicative rule
for (unsigned n = 0; n < this->nconnectivity_; ++n) {
//! Loop over dimension
for (unsigned i = 0; i < Tdim; ++i) {
double N = this->kernel(pcoord[i], nodal_coordinates_.row(n)[i],
this->node_type_[n][i], Tpolynomial);
switch (this->node_type_[n][i]) {
case 1:
N += this->kernel(pcoord[i], nodal_coordinates_.row(n)[i], 5,
Tpolynomial);
break;
case 4:
N += this->kernel(pcoord[i], nodal_coordinates_.row(n)[i], 6,
Tpolynomial);
break;
}
shapefn[n] = shapefn[n] * N;
}
}
} catch (std::exception& exception) {
console_->error("{} #{}: {}\n", __FILE__, __LINE__, exception.what());
return shapefn;
}
return shapefn;
}
//! Return gradient of shape functions of a Hexahedron BSpline Element at a
//! given local coordinate
template <unsigned Tdim, unsigned Tpolynomial>
inline Eigen::MatrixXd
mpm::HexahedronBSplineElement<Tdim, Tpolynomial>::grad_shapefn(
const Eigen::Matrix<double, Tdim, 1>& xi,
const Eigen::Matrix<double, Tdim, 1>& particle_size,
const Eigen::Matrix<double, Tdim, 1>& deformation_gradient) const {
//! To store grad shape functions
Eigen::MatrixXd grad_shapefn(this->nconnectivity_, Tdim);
if (this->nconnectivity_ == 8)
return mpm::HexahedronElement<Tdim, 8>::grad_shapefn(xi, particle_size,
deformation_gradient);
try {
//! Convert local coordinates to real coordinates
Eigen::Matrix<double, Tdim, 1> pcoord;
pcoord.setZero();
auto local_shapefn =
this->shapefn_local(xi, particle_size, deformation_gradient);
for (unsigned i = 0; i < local_shapefn.size(); ++i)
pcoord.noalias() +=
local_shapefn(i) * nodal_coordinates_.row(i).transpose();
//! Compute the shape function gradient following a multiplicative rule
for (unsigned n = 0; n < this->nconnectivity_; ++n)
//! Loop over dimension
for (unsigned i = 0; i < Tdim; ++i) {
double dN_dx = this->gradient(pcoord[i], nodal_coordinates_.row(n)[i],
(this->node_type_[n])[i], Tpolynomial);
switch (this->node_type_[n][i]) {
case 1:
dN_dx += this->gradient(pcoord[i], nodal_coordinates_.row(n)[i], 5,
Tpolynomial);
break;
case 4:
dN_dx += this->gradient(pcoord[i], nodal_coordinates_.row(n)[i], 6,
Tpolynomial);
break;
}
for (unsigned j = 0; j < Tdim; ++j) {
if (j != i) {
double N = this->kernel(pcoord[j], nodal_coordinates_.row(n)[j],
this->node_type_[n][j], Tpolynomial);
switch (this->node_type_[n][j]) {
case 1:
N += this->kernel(pcoord[j], nodal_coordinates_.row(n)[j], 5,
Tpolynomial);
break;
case 4:
N += this->kernel(pcoord[j], nodal_coordinates_.row(n)[j], 6,
Tpolynomial);
break;
}
dN_dx = dN_dx * N;
}
}
grad_shapefn(n, i) = dN_dx;
}
} catch (std::exception& exception) {
console_->error("{} #{}: {}\n", __FILE__, __LINE__, exception.what());
return grad_shapefn;
}
return grad_shapefn;
}
//! Return local shape functions of a BSpline Hexahedron Element at a given
//! Return local shape functions of a Hexahedron Element at a given local
//! coordinate, with particle size and deformation gradient
template <unsigned Tdim, unsigned Tpolynomial>
inline Eigen::VectorXd
mpm::HexahedronBSplineElement<Tdim, Tpolynomial>::shapefn_local(
const Eigen::Matrix<double, Tdim, 1>& xi,
const Eigen::Matrix<double, Tdim, 1>& particle_size,
const Eigen::Matrix<double, Tdim, 1>& deformation_gradient) const {
return mpm::HexahedronElement<Tdim, 8>::shapefn(xi, particle_size,
deformation_gradient);
}
//! Compute Jacobian
template <unsigned Tdim, unsigned Tpolynomial>
inline Eigen::Matrix<double, Tdim, Tdim>
mpm::HexahedronBSplineElement<Tdim, Tpolynomial>::jacobian(
const Eigen::Matrix<double, 3, 1>& xi,
const Eigen::MatrixXd& nodal_coordinates,
const Eigen::Matrix<double, 3, 1>& particle_size,
const Eigen::Matrix<double, 3, 1>& deformation_gradient) const {
// Get gradient shape functions
const Eigen::MatrixXd grad_shapefn =
this->grad_shapefn(xi, particle_size, deformation_gradient);
try {
// Check if dimensions are correct
if ((grad_shapefn.rows() != nodal_coordinates.rows()) ||
(xi.size() != nodal_coordinates.cols()))
throw std::runtime_error(
"Jacobian calculation: Incorrect dimension of xi and "
"nodal_coordinates");
} catch (std::exception& exception) {
console_->error("{} #{}: {}\n", __FILE__, __LINE__, exception.what());
return Eigen::Matrix<double, Tdim, Tdim>::Zero();
}
// Jacobian
return (grad_shapefn.transpose() * nodal_coordinates);
}
//! Compute dn_dx
template <unsigned Tdim, unsigned Tpolynomial>
inline Eigen::MatrixXd mpm::HexahedronBSplineElement<Tdim, Tpolynomial>::dn_dx(
const VectorDim& xi, const Eigen::MatrixXd& nodal_coordinates,
const VectorDim& particle_size,
const VectorDim& deformation_gradient) const {
// Get gradient shape functions
return this->grad_shapefn(xi, particle_size, deformation_gradient);
}
//! Compute Jacobian local with particle size and deformation gradient
template <unsigned Tdim, unsigned Tpolynomial>
inline Eigen::Matrix<double, Tdim, Tdim>
mpm::HexahedronBSplineElement<Tdim, Tpolynomial>::jacobian_local(
const Eigen::Matrix<double, 3, 1>& xi,
const Eigen::MatrixXd& nodal_coordinates,
const Eigen::Matrix<double, 3, 1>& particle_size,
const Eigen::Matrix<double, 3, 1>& deformation_gradient) const {
// Jacobian dx_i/dxi_j
return this->jacobian(xi, nodal_coordinates, particle_size,
deformation_gradient);
}
//! Compute Bmatrix
template <unsigned Tdim, unsigned Tpolynomial>
inline std::vector<Eigen::MatrixXd>
mpm::HexahedronBSplineElement<Tdim, Tpolynomial>::bmatrix(
const VectorDim& xi, const Eigen::MatrixXd& nodal_coordinates,
const VectorDim& particle_size,
const VectorDim& deformation_gradient) const {
// Get gradient shape functions
Eigen::MatrixXd grad_sf =
this->grad_shapefn(xi, particle_size, deformation_gradient);
// B-Matrix
std::vector<Eigen::MatrixXd> bmatrix;
bmatrix.reserve(this->nconnectivity_);
try {
// Check if matrices dimensions are correct
if ((grad_sf.rows() != nodal_coordinates.rows()) ||
(xi.rows() != nodal_coordinates.cols()))
throw std::runtime_error(
"BMatrix - Jacobian calculation: Incorrect dimension of xi and "
"nodal_coordinates");
} catch (std::exception& exception) {
console_->error("{} #{}: {}\n", __FILE__, __LINE__, exception.what());
return bmatrix;
}
// Jacobian dx_i/dxi_j
Eigen::Matrix<double, Tdim, Tdim> jacobian =
(grad_sf.transpose() * nodal_coordinates);
// Gradient shapefn of the cell
// dN/dx = [J]^-1 * dN/dxi
Eigen::MatrixXd grad_shapefn = grad_sf * (jacobian.inverse()).transpose();
for (unsigned i = 0; i < this->nconnectivity_; ++i) {
// clang-format off
Eigen::Matrix<double, 6, Tdim> bi;
bi(0, 0) = grad_shapefn(i, 0); bi(0, 1) = 0.; bi(0, 2) = 0.;
bi(1, 0) = 0.; bi(1, 1) = grad_shapefn(i, 1); bi(1, 2) = 0.;
bi(2, 0) = 0.; bi(2, 1) = 0.; bi(2, 2) = grad_shapefn(i, 2);
bi(3, 0) = grad_shapefn(i, 1); bi(3, 1) = grad_shapefn(i, 0); bi(3, 2) = 0.;
bi(4, 0) = 0.; bi(4, 1) = grad_shapefn(i, 2); bi(4, 2) = grad_shapefn(i, 1);
bi(5, 0) = grad_shapefn(i, 2); bi(5, 1) = 0.; bi(5, 2) = grad_shapefn(i, 0);
// clang-format on
bmatrix.push_back(bi);
}
return bmatrix;
}
//! Compute B-Spline Basis Function using the recursive De Boor's algorithm
//! for single direction
template <unsigned Tdim, unsigned Tpolynomial>
double mpm::HexahedronBSplineElement<Tdim, Tpolynomial>::kernel(
double point_coord, double nodal_coord, unsigned node_type,
unsigned poly_order, unsigned index) const {
double value = 0.0;
//! Compute knot coordinate
Eigen::VectorXd knot_vector = Eigen::Map<Eigen::VectorXd, Eigen::Unaligned>(
(this->knot(node_type)).data(), (this->knot(node_type)).size());
const Eigen::VectorXd one =
Eigen::VectorXd::Constant(knot_vector.size(), 1.0);
const Eigen::VectorXd knot_coord =
nodal_coord * one + spacing_length_ * knot_vector;
if (poly_order == 0) {
if (point_coord >= knot_coord[index] &&
point_coord < knot_coord[index + 1]) {
value = 1.0;
} else {
value = 0.0;
}
} else {
const double den_a = (knot_coord[index + poly_order] - knot_coord[index]);
double a = (point_coord - knot_coord(index)) / den_a;
if (den_a < std::numeric_limits<double>::epsilon()) a = 0;
const double den_b =
(knot_coord[index + poly_order + 1] - knot_coord[index + 1]);
double b = (knot_coord[index + poly_order + 1] - point_coord) / den_b;
if (den_b < std::numeric_limits<double>::epsilon()) b = 0;
value = a * this->kernel(point_coord, nodal_coord, node_type,
poly_order - 1, index) +
b * this->kernel(point_coord, nodal_coord, node_type,
poly_order - 1, index + 1);
}
return value;
}
//! Compute B-Spline Basis Function Gradient using the recursive De Boor's
//! algorithm for single direction
template <unsigned Tdim, unsigned Tpolynomial>
double mpm::HexahedronBSplineElement<Tdim, Tpolynomial>::gradient(
double point_coord, double nodal_coord, unsigned node_type,
unsigned poly_order, unsigned index) const {
double value = 0;
Eigen::VectorXd knot_vector = Eigen::Map<Eigen::VectorXd, Eigen::Unaligned>(
(this->knot(node_type)).data(), (this->knot(node_type)).size());
const Eigen::VectorXd one =
Eigen::VectorXd::Constant(knot_vector.size(), 1.0);
const Eigen::VectorXd knot_coord =
nodal_coord * one + spacing_length_ * knot_vector;
const double den_a = (knot_coord[index + poly_order] - knot_coord[index]);
double a = poly_order / den_a;
if (den_a < std::numeric_limits<double>::epsilon()) a = 0;
const double den_b =
(knot_coord[index + poly_order + 1] - knot_coord[index + 1]);
double b = poly_order / den_b;
if (den_b < std::numeric_limits<double>::epsilon()) b = 0;
value = a * this->kernel(point_coord, nodal_coord, node_type, poly_order - 1,
index) -
b * this->kernel(point_coord, nodal_coord, node_type, poly_order - 1,
index + 1);
return value;
}
| 39.98773 | 96 | 0.625038 | jgiven100 |
3ad6b4e1d8a65ef656542d390021b5ac8527d0aa | 1,262 | hpp | C++ | climate-change/src/VS-Project/Libraries/godot-cpp-bindings/include/gen/Skeleton2D.hpp | jerry871002/CSE201-project | c42cc0e51d0c8367e4d06fc33756ab2ec4118ff4 | [
"MIT"
] | 5 | 2021-05-27T21:50:33.000Z | 2022-01-28T11:54:32.000Z | climate-change/src/VS-Project/Libraries/godot-cpp-bindings/include/gen/Skeleton2D.hpp | jerry871002/CSE201-project | c42cc0e51d0c8367e4d06fc33756ab2ec4118ff4 | [
"MIT"
] | null | null | null | climate-change/src/VS-Project/Libraries/godot-cpp-bindings/include/gen/Skeleton2D.hpp | jerry871002/CSE201-project | c42cc0e51d0c8367e4d06fc33756ab2ec4118ff4 | [
"MIT"
] | 1 | 2021-01-04T21:12:05.000Z | 2021-01-04T21:12:05.000Z | #ifndef GODOT_CPP_SKELETON2D_HPP
#define GODOT_CPP_SKELETON2D_HPP
#include <gdnative_api_struct.gen.h>
#include <stdint.h>
#include <core/CoreTypes.hpp>
#include <core/Ref.hpp>
#include "Node2D.hpp"
namespace godot {
class Bone2D;
class Skeleton2D : public Node2D {
struct ___method_bindings {
godot_method_bind *mb__update_bone_setup;
godot_method_bind *mb__update_transform;
godot_method_bind *mb_get_bone;
godot_method_bind *mb_get_bone_count;
godot_method_bind *mb_get_skeleton;
};
static ___method_bindings ___mb;
static void *_detail_class_tag;
public:
static void ___init_method_bindings();
inline static size_t ___get_id() { return (size_t)_detail_class_tag; }
static inline const char *___get_class_name() { return (const char *) "Skeleton2D"; }
static inline Object *___get_from_variant(Variant a) { godot_object *o = (godot_object*) a; return (o) ? (Object *) godot::nativescript_1_1_api->godot_nativescript_get_instance_binding_data(godot::_RegisterState::language_index, o) : nullptr; }
// enums
// constants
static Skeleton2D *_new();
// methods
void _update_bone_setup();
void _update_transform();
Bone2D *get_bone(const int64_t idx);
int64_t get_bone_count() const;
RID get_skeleton() const;
};
}
#endif | 24.269231 | 245 | 0.774168 | jerry871002 |
3ad6fc8a6037695e2b52cf5b74671b4f27aa8896 | 1,104 | cc | C++ | Graph_ADTs_Interfaces/SparseMultiGRAPH.cc | mightyjoe781/Markdown-Notes | 4d8afdbfed75dc2a9f474579b49c9948dd3b4978 | [
"MIT"
] | null | null | null | Graph_ADTs_Interfaces/SparseMultiGRAPH.cc | mightyjoe781/Markdown-Notes | 4d8afdbfed75dc2a9f474579b49c9948dd3b4978 | [
"MIT"
] | null | null | null | Graph_ADTs_Interfaces/SparseMultiGRAPH.cc | mightyjoe781/Markdown-Notes | 4d8afdbfed75dc2a9f474579b49c9948dd3b4978 | [
"MIT"
] | null | null | null | class SparseMultiGRAPH
{
int Vcnt, Ecnt; bool digraph;
struct node
{
int v; node* next;
node(int x, node* t){ v = x; next = t; }
};
typedef node* link;
vector<link> adj;
public:
SparseMultiGRAPH(int V, bool digraph = false):
adj(V), Vcnt(V), Ecnt(0), digraph(digraph)
{ adj.assign(V,0);}
int V() const { return Vcnt; }
int E() const { return Ecnt; }
bool directed() const { return digraph; }
void insert(Edge e)
{
int v = e.v , w = e.w;
adj[v] = new node(w, adj[v]);
if(!digraph) adj[w] = new node(v,adj[w]);
}
void remove(Edge e);
bool edge(int v,int w) const;
class adjIterator;
friend class adjIterator;
};
class SparseMultiGRAPH::adjIterator
{
const SparseMultiGRAPH &G;
int v;
link t;
public:
adjIterator(const SparseMultiGRAPH &G, int v):
G(G), v(v) { t= 0; }
int begin()
{ t= G.adj[v]; return t? t->v : -1;}
int nxt()
{if(t) t = t->next; return t ? t->v : -1;}
bool end()
{ return t == 0; }
};
| 25.090909 | 51 | 0.522645 | mightyjoe781 |
3ae03db192d52d3599845bc934b3da129f1e1f84 | 1,089 | cpp | C++ | main.cpp | hongshunyang/cellcounter | 5a4576208e0b2011147e6eac4c739eab9a963014 | [
"MIT"
] | 3 | 2018-07-20T19:07:15.000Z | 2021-05-20T01:59:02.000Z | main.cpp | hongshunyang/cellcounter | 5a4576208e0b2011147e6eac4c739eab9a963014 | [
"MIT"
] | null | null | null | main.cpp | hongshunyang/cellcounter | 5a4576208e0b2011147e6eac4c739eab9a963014 | [
"MIT"
] | 3 | 2017-04-25T17:14:46.000Z | 2020-07-12T11:52:36.000Z | #include <QtWidgets/QApplication>
#include "cellcounter.h"
#include<QMessageBox>
#include<QIcon>
class CC: public QApplication
{
public:
CC(int argc, char **argv): QApplication(argc, argv)
{
}
bool notify(QObject *rec, QEvent *ev)
{
try{
return QApplication::notify(rec, ev);
}
catch (...)
{
QMessageBox::warning(NULL,
tr("Error"),
tr("Error occurred\n")+
tr("Please restart application."),
QMessageBox::Ok,NULL);
return false;
}
}
};
int main(int argc, char *argv[])
{
CC a(argc, argv);
//settings
CC::addLibraryPath(QCoreApplication::applicationDirPath());
CC::setApplicationName("CellCounter");
CC::setOrganizationDomain("cellcounter.org");
CC::setOrganizationName("Laboratory for Tumor Pathology,School of Life Sciences, University of Science and Technology of China");
CellCounter w;
w.showMaximized();
return a.exec();
}
| 25.325581 | 133 | 0.561983 | hongshunyang |
3ae0f76780a921ad7ef212da44f73b1fcff75d11 | 1,947 | cpp | C++ | modules/task_1/krasilnikov_a_count_sentences/count_sentences.cpp | RachinIA/pp_2020_autumn_engineer | 23f7df688a77cad9496b9d95bbe2645e0528f106 | [
"BSD-3-Clause"
] | 1 | 2020-10-30T13:49:58.000Z | 2020-10-30T13:49:58.000Z | modules/task_1/krasilnikov_a_count_sentences/count_sentences.cpp | RachinIA/pp_2020_autumn_engineer | 23f7df688a77cad9496b9d95bbe2645e0528f106 | [
"BSD-3-Clause"
] | 2 | 2020-11-14T18:00:55.000Z | 2020-11-19T16:12:50.000Z | modules/task_1/krasilnikov_a_count_sentences/count_sentences.cpp | RachinIA/pp_2020_autumn_engineer | 23f7df688a77cad9496b9d95bbe2645e0528f106 | [
"BSD-3-Clause"
] | 1 | 2020-10-14T19:37:21.000Z | 2020-10-14T19:37:21.000Z | // Copyright 2020 Krasilnikov Alexey
#include "../../../modules/task_1/krasilnikov_a_count_sentences/count_sentences.h"
#include <mpi.h>
#include <ctime>
#include <random>
#include <string>
std::string getRandomString(const size_t size) {
std::mt19937 generator;
std::string str(size, '_');
for (auto &symbol : str) {
if (generator() % 10 == 0) {
symbol = '.';
} else {
symbol = static_cast<char>(generator() % 128);
}
}
return str;
}
uint32_t getCountSentencesSequential(const std::string& str) {
uint32_t count_sentences = 0;
for (const auto symbol : str) {
if (symbol == '.') {
++count_sentences;
}
}
return count_sentences;
}
uint32_t getCountSentencesParallel(const std::string& str, const size_t size_str) {
int rank, size;
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &size);
uint32_t total_count = 0;
std::string local_str;
const uint32_t delta = size_str / size;
const uint32_t remain = size_str % size;
if (rank == 0) {
for (size_t process = 0; process < remain; ++process) {
MPI_Send(&str[0] + process * (delta + 1), delta + 1, MPI_CHAR, process + 1, 0, MPI_COMM_WORLD);
}
for (size_t process = remain; static_cast<int>(process) < size - 1; ++process) {
MPI_Send(&str[0] + process * delta + remain, delta, MPI_CHAR, process + 1, 0, MPI_COMM_WORLD);
}
local_str = str.substr((size - 1) * delta + remain);
} else {
MPI_Status status;
if (rank <= static_cast<int>(remain)) {
local_str.resize(delta + 1);
MPI_Recv(&local_str[0], delta + 1, MPI_CHAR, 0, 0, MPI_COMM_WORLD, &status);
} else {
local_str.resize(delta);
MPI_Recv(&local_str[0], delta, MPI_CHAR, 0, 0, MPI_COMM_WORLD, &status);
}
}
uint32_t local_count = getCountSentencesSequential(local_str);
MPI_Reduce(&local_count, &total_count, 1, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD);
return total_count;
}
| 30.904762 | 101 | 0.655367 | RachinIA |
3ae33e2c4fb2a58a73717aa19afa4f2adbc22eac | 3,106 | hpp | C++ | Viewer/ecflowUI/src/ChangeNotifyDialog.hpp | mpartio/ecflow | ea4b89399d1e7b897ff48c59b1e885e6d53cc8d6 | [
"Apache-2.0"
] | null | null | null | Viewer/ecflowUI/src/ChangeNotifyDialog.hpp | mpartio/ecflow | ea4b89399d1e7b897ff48c59b1e885e6d53cc8d6 | [
"Apache-2.0"
] | null | null | null | Viewer/ecflowUI/src/ChangeNotifyDialog.hpp | mpartio/ecflow | ea4b89399d1e7b897ff48c59b1e885e6d53cc8d6 | [
"Apache-2.0"
] | null | null | null | //============================================================================
// Copyright 2009- ECMWF.
// This software is licensed under the terms of the Apache Licence version 2.0
// which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
// In applying this licence, ECMWF does not waive the privileges and immunities
// granted to it by virtue of its status as an intergovernmental organisation
// nor does it submit to any jurisdiction.
//
//============================================================================
#ifndef CHANGENOTIFYDIALOG_HPP_
#define CHANGENOTIFYDIALOG_HPP_
#include <QtGlobal>
#include <QDialog>
#include <QLinearGradient>
#include <QSettings>
#include <QToolButton>
#include <QWidget>
#include "ui_ChangeNotifyDialog.h"
#include "ui_ChangeNotifyDialogWidget.h"
#include "VInfo.hpp"
class ChangeNotify;
class VProperty;
class QAbstractButton;
class QButtonGroup;
class QHBoxLayout;
class QLabel;
class ChangeNotifyDialogButton : public QToolButton
{
Q_OBJECT
public:
explicit ChangeNotifyDialogButton(QWidget* parent=nullptr);
void setNotifier(ChangeNotify*);
void updateSettings();
public Q_SLOTS:
void slotAppend();
void slotRemoveRow(int);
void slotReset();
protected:
ChangeNotify* notifier_{nullptr};
};
class ChangeNotifyDialogWidget : public QWidget, protected Ui::ChangeNotifyDialogWidget
{
Q_OBJECT
public:
explicit ChangeNotifyDialogWidget(QWidget* parent=nullptr);
~ChangeNotifyDialogWidget() override = default;
void init(ChangeNotify*);
void updateSettings();
ChangeNotify* notifier() const {return notifier_;}
void writeSettings(QSettings& settings);
void readSettings(const QSettings& settings);
protected Q_SLOTS:
void slotSelectItem(const QModelIndex&);
void slotDoubleClickItem(const QModelIndex&);
Q_SIGNALS:
void selectionChanged(VInfo_ptr);
protected:
ChangeNotify* notifier_{nullptr};
};
class ChangeNotifyDialog : public QDialog, protected Ui::ChangeNotifyDialog
{
Q_OBJECT
public:
explicit ChangeNotifyDialog(QWidget *parent=nullptr);
~ChangeNotifyDialog() override;
void add(ChangeNotify*);
void setCurrent(ChangeNotify*);
void setEnabled(ChangeNotify*,bool b);
void updateSettings(ChangeNotify*);
public Q_SLOTS:
void on_closePb__clicked(bool b);
void on_clearPb__clicked(bool b);
protected Q_SLOTS:
void slotSelectionChanged(VInfo_ptr);
void slotOptions();
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
void slotButtonToggled(QAbstractButton*, bool);
#else
void slotButtonToggled(int,bool);
#endif
protected:
ChangeNotify* indexToNtf(int idx);
int ntfToIndex(ChangeNotify* ntf);
void closeEvent(QCloseEvent*) override;
void clearCurrentData();
void writeSettings();
void readSettings();
void readNtfWidgetSettings(int tabIndex);
QList<ChangeNotifyDialogWidget*> ntfWidgets_;
QList<ChangeNotifyDialogButton*> ntfButtons_;
QButtonGroup* buttonGroup_;
bool ignoreCurrentChange_{false};
QLinearGradient grad_;
QHBoxLayout* buttonHb_;
VProperty* switchWsProp_{nullptr};
};
#endif
| 25.252033 | 87 | 0.729234 | mpartio |
3ae350e30f2d4ad631b19ae59993bcd027abfe05 | 1,784 | cpp | C++ | test/test-Color.inc.cpp | Arnaud-de-Grandmaison/ratrac | d2ab18235ff9b61e6f63694e02f53790e81ed4a7 | [
"Apache-2.0"
] | null | null | null | test/test-Color.inc.cpp | Arnaud-de-Grandmaison/ratrac | d2ab18235ff9b61e6f63694e02f53790e81ed4a7 | [
"Apache-2.0"
] | null | null | null | test/test-Color.inc.cpp | Arnaud-de-Grandmaison/ratrac | d2ab18235ff9b61e6f63694e02f53790e81ed4a7 | [
"Apache-2.0"
] | null | null | null | TEST(Color, base) {
// Testing same operations on colors.
// ==================================
// Colors are red, green, blue tuples.
Color c(-0.5, 0.4, 1.7);
EXPECT_EQ(c.red(), -0.5f);
EXPECT_EQ(c.green(), 0.4f);
EXPECT_EQ(c.blue(), 1.7f);
// Adding colors.
Color c1(0.9, 0.6, 0.75);
Color c2(0.7, 0.1, 0.25);
EXPECT_EQ(c1 + c2, Color(1.6, 0.7, 1.0));
// Subtracting colors.
c1 = Color(0.9, 0.6, 0.75);
c2 = Color(0.7, 0.1, 0.25);
EXPECT_EQ(c1 - c2, Color(0.2, 0.5, 0.5));
// Multiplying a color by a scalar.
c = Color(0.2, 0.3, 0.4);
EXPECT_EQ(c * 2.0, Color(0.4, 0.6, 0.8));
EXPECT_EQ(2.0 * c, Color(0.4, 0.6, 0.8));
// Dividing a color by a scalar.
c = Color(0.4, 0.6, 0.8);
EXPECT_EQ(c / 2.0, Color(0.2, 0.3, 0.4));
// Multiplying colors.
c1 = Color(1.0, 0.2, 0.4);
c2 = Color(0.9, 1.0, 0.1);
EXPECT_EQ(c1 * c2, Color(0.9, 0.2, 0.04));
// Multiplying colors/Hadamard product/Schur product
}
TEST(Color, output) {
Color c1(0.9, 0.6, 0.75);
EXPECT_EQ(std::string(c1),
"Color { red:0.9, green:0.6, blue:0.75, alpha:1}");
std::ostringstream string_stream;
string_stream << c1;
EXPECT_EQ(string_stream.str(),
"Color { red:0.9, green:0.6, blue:0.75, alpha:1}");
string_stream.str("");
Color c2(0.7, 0.1, 0.25, 0.5);
EXPECT_EQ(std::string(c2),
"Color { red:0.7, green:0.1, blue:0.25, alpha:0.5}");
string_stream << c2;
EXPECT_EQ(string_stream.str(),
"Color { red:0.7, green:0.1, blue:0.25, alpha:0.5}");
}
TEST(Color, helpers) {
EXPECT_EQ(Color::BLACK(), Color(0, 0, 0));
EXPECT_EQ(Color::WHITE(), Color(1, 1, 1));
EXPECT_EQ(Color::RED(), Color(1, 0, 0));
EXPECT_EQ(Color::GREEN(), Color(0, 1, 0));
EXPECT_EQ(Color::BLUE(), Color(0, 0, 1));
}
| 28.31746 | 65 | 0.559978 | Arnaud-de-Grandmaison |
3ae38974d5fc957e8c535dcfc5eb65ff0d9c96eb | 2,237 | cc | C++ | chrome/browser/chromeos/login/help_app_launcher.cc | junmin-zhu/chromium-rivertrail | eb1a57aca71fe68d96e48af8998dcfbe45171ee1 | [
"BSD-3-Clause"
] | 5 | 2018-03-10T13:08:42.000Z | 2021-07-26T15:02:11.000Z | chrome/browser/chromeos/login/help_app_launcher.cc | sanyaade-mobiledev/chromium.src | d496dfeebb0f282468827654c2b3769b3378c087 | [
"BSD-3-Clause"
] | 1 | 2015-07-21T08:02:01.000Z | 2015-07-21T08:02:01.000Z | chrome/browser/chromeos/login/help_app_launcher.cc | jianglong0156/chromium.src | d496dfeebb0f282468827654c2b3769b3378c087 | [
"BSD-3-Clause"
] | 6 | 2016-11-14T10:13:35.000Z | 2021-01-23T15:29:53.000Z | // Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/chromeos/login/help_app_launcher.h"
#include <string>
#include "base/stringprintf.h"
#include "base/utf_string_conversions.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "content/public/browser/browser_thread.h"
#include "grit/generated_resources.h"
#include "ui/base/l10n/l10n_util.h"
using content::BrowserThread;
namespace {
const char kHelpAppFormat[] =
"chrome-extension://honijodknafkokifofgiaalefdiedpko/oobe.html?id=%d";
} // namespace
namespace chromeos {
///////////////////////////////////////////////////////////////////////////////
// HelpApp, public:
HelpAppLauncher::HelpAppLauncher(gfx::NativeWindow parent_window)
: parent_window_(parent_window) {
}
void HelpAppLauncher::ShowHelpTopic(HelpTopic help_topic_id) {
Profile* profile = ProfileManager::GetDefaultProfile();
ExtensionService* service = profile->GetExtensionService();
DCHECK(service);
if (!service)
return;
GURL url(base::StringPrintf(kHelpAppFormat,
static_cast<int>(help_topic_id)));
// HelpApp component extension presents only in official builds so we can
// show help only when the extensions is installed.
if (service->extensions()->GetByID(url.host()))
ShowHelpTopicDialog(GURL(url));
}
///////////////////////////////////////////////////////////////////////////////
// HelpApp, protected:
HelpAppLauncher::~HelpAppLauncher() {}
///////////////////////////////////////////////////////////////////////////////
// HelpApp, private:
void HelpAppLauncher::ShowHelpTopicDialog(const GURL& topic_url) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
LoginWebDialog* dialog = new LoginWebDialog(
this,
parent_window_,
l10n_util::GetStringUTF16(IDS_LOGIN_OOBE_HELP_DIALOG_TITLE),
topic_url,
LoginWebDialog::STYLE_BUBBLE);
dialog->Show();
// The dialog object will be deleted on dialog close.
}
} // namespace chromeos
| 30.643836 | 79 | 0.665177 | junmin-zhu |
3ae96931426aaff88e89b534543d0ca13acfcc2c | 237,049 | cpp | C++ | TestApps/Rosetta/BNN/Prebuilt/Synth/_sds/vhls/top/solution/syn/systemc/a0_bin_conv_5.cpp | stephenneuendorffer/hls_tuner | fa7de78f0e2bb4b8f9f2e0a0368ed071b379c875 | [
"MIT"
] | 1 | 2021-02-21T12:13:09.000Z | 2021-02-21T12:13:09.000Z | TestApps/Rosetta/BNN/Prebuilt/Synth/_sds/vhls/top/solution/syn/systemc/a0_bin_conv_5.cpp | stephenneuendorffer/hls_tuner | fa7de78f0e2bb4b8f9f2e0a0368ed071b379c875 | [
"MIT"
] | null | null | null | TestApps/Rosetta/BNN/Prebuilt/Synth/_sds/vhls/top/solution/syn/systemc/a0_bin_conv_5.cpp | stephenneuendorffer/hls_tuner | fa7de78f0e2bb4b8f9f2e0a0368ed071b379c875 | [
"MIT"
] | 1 | 2019-09-10T16:45:27.000Z | 2019-09-10T16:45:27.000Z | #include "a0_bin_conv.h"
#include "AESL_pkg.h"
using namespace std;
namespace ap_rtl {
void a0_bin_conv::thread_sel_tmp175_fu_26354_p3() {
sel_tmp175_fu_26354_p3 = (!tmp_170_reg_51104.read()[0].is_01())? sc_lv<2>(): ((tmp_170_reg_51104.read()[0].to_bool())? old_word_buffer_0_5_18_fu_1550.read(): sel_tmp174_fu_26347_p3.read());
}
void a0_bin_conv::thread_sel_tmp176_fu_26509_p3() {
sel_tmp176_fu_26509_p3 = (!cond6_reg_50242.read()[0].is_01())? sc_lv<2>(): ((cond6_reg_50242.read()[0].to_bool())? old_word_buffer_0_2_11_fu_1418.read(): old_word_buffer_0_7_10_fu_1594.read());
}
void a0_bin_conv::thread_sel_tmp177_fu_26516_p3() {
sel_tmp177_fu_26516_p3 = (!tmp_168_reg_50922.read()[0].is_01())? sc_lv<2>(): ((tmp_168_reg_50922.read()[0].to_bool())? old_word_buffer_0_3_11_fu_1454.read(): sel_tmp176_fu_26509_p3.read());
}
void a0_bin_conv::thread_sel_tmp178_fu_26523_p3() {
sel_tmp178_fu_26523_p3 = (!tmp_169_reg_51016.read()[0].is_01())? sc_lv<2>(): ((tmp_169_reg_51016.read()[0].to_bool())? old_word_buffer_0_4_12_fu_1490.read(): sel_tmp177_fu_26516_p3.read());
}
void a0_bin_conv::thread_sel_tmp179_fu_26530_p3() {
sel_tmp179_fu_26530_p3 = (!tmp_171_reg_51180.read()[0].is_01())? sc_lv<2>(): ((tmp_171_reg_51180.read()[0].to_bool())? old_word_buffer_0_5_11_fu_1522.read(): sel_tmp178_fu_26523_p3.read());
}
void a0_bin_conv::thread_sel_tmp180_fu_32499_p3() {
sel_tmp180_fu_32499_p3 = (!cond6_reg_50242.read()[0].is_01())? sc_lv<2>(): ((cond6_reg_50242.read()[0].to_bool())? old_word_buffer_0_2_29_reg_53917.read(): old_word_buffer_0_7_43_reg_54213.read());
}
void a0_bin_conv::thread_sel_tmp181_fu_32504_p3() {
sel_tmp181_fu_32504_p3 = (!tmp_168_reg_50922.read()[0].is_01())? sc_lv<2>(): ((tmp_168_reg_50922.read()[0].to_bool())? old_word_buffer_0_3_29_reg_53958.read(): sel_tmp180_fu_32499_p3.read());
}
void a0_bin_conv::thread_sel_tmp182_fu_32510_p3() {
sel_tmp182_fu_32510_p3 = (!tmp_169_reg_51016.read()[0].is_01())? sc_lv<2>(): ((tmp_169_reg_51016.read()[0].to_bool())? old_word_buffer_0_4_30_reg_54009.read(): sel_tmp181_fu_32504_p3.read());
}
void a0_bin_conv::thread_sel_tmp183_fu_32516_p3() {
sel_tmp183_fu_32516_p3 = (!tmp_171_reg_51180.read()[0].is_01())? sc_lv<2>(): ((tmp_171_reg_51180.read()[0].to_bool())? old_word_buffer_0_5_29_reg_54058.read(): sel_tmp182_fu_32510_p3.read());
}
void a0_bin_conv::thread_sel_tmp184_fu_26544_p3() {
sel_tmp184_fu_26544_p3 = (!cond6_reg_50242.read()[0].is_01())? sc_lv<2>(): ((cond6_reg_50242.read()[0].to_bool())? old_word_buffer_0_2_13_fu_1426.read(): old_word_buffer_0_7_12_fu_1602.read());
}
void a0_bin_conv::thread_sel_tmp185_fu_26551_p3() {
sel_tmp185_fu_26551_p3 = (!tmp_168_reg_50922.read()[0].is_01())? sc_lv<2>(): ((tmp_168_reg_50922.read()[0].to_bool())? old_word_buffer_0_3_13_fu_1462.read(): sel_tmp184_fu_26544_p3.read());
}
void a0_bin_conv::thread_sel_tmp186_fu_26558_p3() {
sel_tmp186_fu_26558_p3 = (!tmp_169_reg_51016.read()[0].is_01())? sc_lv<2>(): ((tmp_169_reg_51016.read()[0].to_bool())? old_word_buffer_0_4_14_fu_1498.read(): sel_tmp185_fu_26551_p3.read());
}
void a0_bin_conv::thread_sel_tmp187_fu_26565_p3() {
sel_tmp187_fu_26565_p3 = (!tmp_171_reg_51180.read()[0].is_01())? sc_lv<2>(): ((tmp_171_reg_51180.read()[0].to_bool())? old_word_buffer_0_5_13_fu_1530.read(): sel_tmp186_fu_26558_p3.read());
}
void a0_bin_conv::thread_sel_tmp188_fu_32528_p3() {
sel_tmp188_fu_32528_p3 = (!cond6_reg_50242.read()[0].is_01())? sc_lv<2>(): ((cond6_reg_50242.read()[0].to_bool())? old_word_buffer_0_2_30_reg_53925.read(): old_word_buffer_0_7_45_reg_54237.read());
}
void a0_bin_conv::thread_sel_tmp189_fu_32533_p3() {
sel_tmp189_fu_32533_p3 = (!tmp_168_reg_50922.read()[0].is_01())? sc_lv<2>(): ((tmp_168_reg_50922.read()[0].to_bool())? old_word_buffer_0_3_30_reg_53968.read(): sel_tmp188_fu_32528_p3.read());
}
void a0_bin_conv::thread_sel_tmp190_fu_32539_p3() {
sel_tmp190_fu_32539_p3 = (!tmp_169_reg_51016.read()[0].is_01())? sc_lv<2>(): ((tmp_169_reg_51016.read()[0].to_bool())? old_word_buffer_0_4_31_reg_54021.read(): sel_tmp189_fu_32533_p3.read());
}
void a0_bin_conv::thread_sel_tmp191_fu_32545_p3() {
sel_tmp191_fu_32545_p3 = (!tmp_171_reg_51180.read()[0].is_01())? sc_lv<2>(): ((tmp_171_reg_51180.read()[0].to_bool())? old_word_buffer_0_5_30_reg_54072.read(): sel_tmp190_fu_32539_p3.read());
}
void a0_bin_conv::thread_sel_tmp192_fu_26579_p3() {
sel_tmp192_fu_26579_p3 = (!cond6_reg_50242.read()[0].is_01())? sc_lv<2>(): ((cond6_reg_50242.read()[0].to_bool())? old_word_buffer_0_2_15_fu_1434.read(): old_word_buffer_0_7_14_fu_1610.read());
}
void a0_bin_conv::thread_sel_tmp193_fu_26586_p3() {
sel_tmp193_fu_26586_p3 = (!tmp_168_reg_50922.read()[0].is_01())? sc_lv<2>(): ((tmp_168_reg_50922.read()[0].to_bool())? old_word_buffer_0_3_15_fu_1470.read(): sel_tmp192_fu_26579_p3.read());
}
void a0_bin_conv::thread_sel_tmp194_fu_26593_p3() {
sel_tmp194_fu_26593_p3 = (!tmp_169_reg_51016.read()[0].is_01())? sc_lv<2>(): ((tmp_169_reg_51016.read()[0].to_bool())? old_word_buffer_0_4_16_fu_1506.read(): sel_tmp193_fu_26586_p3.read());
}
void a0_bin_conv::thread_sel_tmp195_fu_26600_p3() {
sel_tmp195_fu_26600_p3 = (!tmp_171_reg_51180.read()[0].is_01())? sc_lv<2>(): ((tmp_171_reg_51180.read()[0].to_bool())? old_word_buffer_0_5_15_fu_1538.read(): sel_tmp194_fu_26593_p3.read());
}
void a0_bin_conv::thread_sel_tmp196_fu_32557_p3() {
sel_tmp196_fu_32557_p3 = (!cond6_reg_50242.read()[0].is_01())? sc_lv<2>(): ((cond6_reg_50242.read()[0].to_bool())? old_word_buffer_0_2_31_reg_53933.read(): old_word_buffer_0_7_47_reg_54261.read());
}
void a0_bin_conv::thread_sel_tmp197_fu_32562_p3() {
sel_tmp197_fu_32562_p3 = (!tmp_168_reg_50922.read()[0].is_01())? sc_lv<2>(): ((tmp_168_reg_50922.read()[0].to_bool())? old_word_buffer_0_3_31_reg_53978.read(): sel_tmp196_fu_32557_p3.read());
}
void a0_bin_conv::thread_sel_tmp198_fu_32568_p3() {
sel_tmp198_fu_32568_p3 = (!tmp_169_reg_51016.read()[0].is_01())? sc_lv<2>(): ((tmp_169_reg_51016.read()[0].to_bool())? old_word_buffer_0_4_29_reg_53874.read(): sel_tmp197_fu_32562_p3.read());
}
void a0_bin_conv::thread_sel_tmp199_fu_32574_p3() {
sel_tmp199_fu_32574_p3 = (!tmp_171_reg_51180.read()[0].is_01())? sc_lv<2>(): ((tmp_171_reg_51180.read()[0].to_bool())? old_word_buffer_0_5_31_reg_54086.read(): sel_tmp198_fu_32568_p3.read());
}
void a0_bin_conv::thread_sel_tmp200_fu_23702_p3() {
sel_tmp200_fu_23702_p3 = (!cond6_reg_50242.read()[0].is_01())? sc_lv<2>(): ((cond6_reg_50242.read()[0].to_bool())? old_word_buffer_0_2_17_fu_1442.read(): old_word_buffer_0_7_16_fu_1618.read());
}
void a0_bin_conv::thread_sel_tmp201_fu_23709_p3() {
sel_tmp201_fu_23709_p3 = (!tmp_168_reg_50922.read()[0].is_01())? sc_lv<2>(): ((tmp_168_reg_50922.read()[0].to_bool())? old_word_buffer_0_3_17_fu_1478.read(): sel_tmp200_fu_23702_p3.read());
}
void a0_bin_conv::thread_sel_tmp202_fu_23716_p3() {
sel_tmp202_fu_23716_p3 = (!tmp_169_reg_51016.read()[0].is_01())? sc_lv<2>(): ((tmp_169_reg_51016.read()[0].to_bool())? old_word_buffer_0_4_17_fu_1510.read(): sel_tmp201_fu_23709_p3.read());
}
void a0_bin_conv::thread_sel_tmp203_fu_23723_p3() {
sel_tmp203_fu_23723_p3 = (!tmp_171_reg_51180.read()[0].is_01())? sc_lv<2>(): ((tmp_171_reg_51180.read()[0].to_bool())? old_word_buffer_0_5_17_fu_1546.read(): sel_tmp202_fu_23716_p3.read());
}
void a0_bin_conv::thread_sel_tmp204_fu_32586_p3() {
sel_tmp204_fu_32586_p3 = (!cond6_reg_50242.read()[0].is_01())? sc_lv<2>(): ((cond6_reg_50242.read()[0].to_bool())? old_word_buffer_0_2_32_reg_53941.read(): ap_reg_pp0_iter2_old_word_buffer_0_7_49_reg_52193.read());
}
void a0_bin_conv::thread_sel_tmp205_fu_32591_p3() {
sel_tmp205_fu_32591_p3 = (!tmp_168_reg_50922.read()[0].is_01())? sc_lv<2>(): ((tmp_168_reg_50922.read()[0].to_bool())? old_word_buffer_0_3_32_reg_53988.read(): sel_tmp204_fu_32586_p3.read());
}
void a0_bin_conv::thread_sel_tmp206_fu_32597_p3() {
sel_tmp206_fu_32597_p3 = (!tmp_169_reg_51016.read()[0].is_01())? sc_lv<2>(): ((tmp_169_reg_51016.read()[0].to_bool())? old_word_buffer_0_4_32_reg_54033.read(): sel_tmp205_fu_32591_p3.read());
}
void a0_bin_conv::thread_sel_tmp207_fu_32603_p3() {
sel_tmp207_fu_32603_p3 = (!tmp_171_reg_51180.read()[0].is_01())? sc_lv<2>(): ((tmp_171_reg_51180.read()[0].to_bool())? old_word_buffer_0_5_32_reg_54100.read(): sel_tmp206_fu_32597_p3.read());
}
void a0_bin_conv::thread_sel_tmp208_fu_26614_p3() {
sel_tmp208_fu_26614_p3 = (!tmp_1225_reg_45756.read()[0].is_01())? sc_lv<2>(): ((tmp_1225_reg_45756.read()[0].to_bool())? old_word_buffer_0_7_fu_686.read(): ap_const_lv2_0);
}
void a0_bin_conv::thread_sel_tmp209_fu_26621_p3() {
sel_tmp209_fu_26621_p3 = (!sel_tmp79_reg_51283.read()[0].is_01())? sc_lv<2>(): ((sel_tmp79_reg_51283.read()[0].to_bool())? old_word_buffer_0_3_fu_670.read(): sel_tmp208_fu_26614_p3.read());
}
void a0_bin_conv::thread_sel_tmp210_fu_26628_p3() {
sel_tmp210_fu_26628_p3 = (!sel_tmp80_reg_51289.read()[0].is_01())? sc_lv<2>(): ((sel_tmp80_reg_51289.read()[0].to_bool())? old_word_buffer_0_4_fu_674.read(): sel_tmp209_fu_26621_p3.read());
}
void a0_bin_conv::thread_sel_tmp211_fu_26635_p3() {
sel_tmp211_fu_26635_p3 = (!sel_tmp81_reg_51295.read()[0].is_01())? sc_lv<2>(): ((sel_tmp81_reg_51295.read()[0].to_bool())? old_word_buffer_0_5_fu_678.read(): sel_tmp210_fu_26628_p3.read());
}
void a0_bin_conv::thread_sel_tmp212_fu_26642_p3() {
sel_tmp212_fu_26642_p3 = (!sel_tmp82_reg_51301.read()[0].is_01())? sc_lv<2>(): ((sel_tmp82_reg_51301.read()[0].to_bool())? old_word_buffer_0_6_fu_682.read(): sel_tmp211_fu_26635_p3.read());
}
void a0_bin_conv::thread_sel_tmp213_fu_26730_p3() {
sel_tmp213_fu_26730_p3 = (!cond6_reg_50242.read()[0].is_01())? sc_lv<2>(): ((cond6_reg_50242.read()[0].to_bool())? old_word_buffer_0_3_11_fu_1454.read(): old_word_buffer_0_7_10_fu_1594.read());
}
void a0_bin_conv::thread_sel_tmp214_fu_26737_p3() {
sel_tmp214_fu_26737_p3 = (!tmp_168_reg_50922.read()[0].is_01())? sc_lv<2>(): ((tmp_168_reg_50922.read()[0].to_bool())? old_word_buffer_0_4_12_fu_1490.read(): sel_tmp213_fu_26730_p3.read());
}
void a0_bin_conv::thread_sel_tmp215_fu_26744_p3() {
sel_tmp215_fu_26744_p3 = (!tmp_169_reg_51016.read()[0].is_01())? sc_lv<2>(): ((tmp_169_reg_51016.read()[0].to_bool())? old_word_buffer_0_5_11_fu_1522.read(): sel_tmp214_fu_26737_p3.read());
}
void a0_bin_conv::thread_sel_tmp216_fu_32665_p3() {
sel_tmp216_fu_32665_p3 = (!cond6_reg_50242.read()[0].is_01())? sc_lv<2>(): ((cond6_reg_50242.read()[0].to_bool())? old_word_buffer_0_3_29_reg_53958.read(): old_word_buffer_0_7_43_reg_54213.read());
}
void a0_bin_conv::thread_sel_tmp217_fu_32670_p3() {
sel_tmp217_fu_32670_p3 = (!tmp_168_reg_50922.read()[0].is_01())? sc_lv<2>(): ((tmp_168_reg_50922.read()[0].to_bool())? old_word_buffer_0_4_30_reg_54009.read(): sel_tmp216_fu_32665_p3.read());
}
void a0_bin_conv::thread_sel_tmp218_fu_32676_p3() {
sel_tmp218_fu_32676_p3 = (!tmp_169_reg_51016.read()[0].is_01())? sc_lv<2>(): ((tmp_169_reg_51016.read()[0].to_bool())? old_word_buffer_0_5_29_reg_54058.read(): sel_tmp217_fu_32670_p3.read());
}
void a0_bin_conv::thread_sel_tmp219_fu_26758_p3() {
sel_tmp219_fu_26758_p3 = (!cond6_reg_50242.read()[0].is_01())? sc_lv<2>(): ((cond6_reg_50242.read()[0].to_bool())? old_word_buffer_0_3_13_fu_1462.read(): old_word_buffer_0_7_12_fu_1602.read());
}
void a0_bin_conv::thread_sel_tmp220_fu_26765_p3() {
sel_tmp220_fu_26765_p3 = (!tmp_168_reg_50922.read()[0].is_01())? sc_lv<2>(): ((tmp_168_reg_50922.read()[0].to_bool())? old_word_buffer_0_4_14_fu_1498.read(): sel_tmp219_fu_26758_p3.read());
}
void a0_bin_conv::thread_sel_tmp221_fu_26772_p3() {
sel_tmp221_fu_26772_p3 = (!tmp_169_reg_51016.read()[0].is_01())? sc_lv<2>(): ((tmp_169_reg_51016.read()[0].to_bool())? old_word_buffer_0_5_13_fu_1530.read(): sel_tmp220_fu_26765_p3.read());
}
void a0_bin_conv::thread_sel_tmp222_fu_32688_p3() {
sel_tmp222_fu_32688_p3 = (!cond6_reg_50242.read()[0].is_01())? sc_lv<2>(): ((cond6_reg_50242.read()[0].to_bool())? old_word_buffer_0_3_30_reg_53968.read(): old_word_buffer_0_7_45_reg_54237.read());
}
void a0_bin_conv::thread_sel_tmp223_fu_32693_p3() {
sel_tmp223_fu_32693_p3 = (!tmp_168_reg_50922.read()[0].is_01())? sc_lv<2>(): ((tmp_168_reg_50922.read()[0].to_bool())? old_word_buffer_0_4_31_reg_54021.read(): sel_tmp222_fu_32688_p3.read());
}
void a0_bin_conv::thread_sel_tmp224_fu_32699_p3() {
sel_tmp224_fu_32699_p3 = (!tmp_169_reg_51016.read()[0].is_01())? sc_lv<2>(): ((tmp_169_reg_51016.read()[0].to_bool())? old_word_buffer_0_5_30_reg_54072.read(): sel_tmp223_fu_32693_p3.read());
}
void a0_bin_conv::thread_sel_tmp225_fu_26786_p3() {
sel_tmp225_fu_26786_p3 = (!cond6_reg_50242.read()[0].is_01())? sc_lv<2>(): ((cond6_reg_50242.read()[0].to_bool())? old_word_buffer_0_3_15_fu_1470.read(): old_word_buffer_0_7_14_fu_1610.read());
}
void a0_bin_conv::thread_sel_tmp226_fu_26793_p3() {
sel_tmp226_fu_26793_p3 = (!tmp_168_reg_50922.read()[0].is_01())? sc_lv<2>(): ((tmp_168_reg_50922.read()[0].to_bool())? old_word_buffer_0_4_16_fu_1506.read(): sel_tmp225_fu_26786_p3.read());
}
void a0_bin_conv::thread_sel_tmp227_fu_26800_p3() {
sel_tmp227_fu_26800_p3 = (!tmp_169_reg_51016.read()[0].is_01())? sc_lv<2>(): ((tmp_169_reg_51016.read()[0].to_bool())? old_word_buffer_0_5_15_fu_1538.read(): sel_tmp226_fu_26793_p3.read());
}
void a0_bin_conv::thread_sel_tmp228_fu_32711_p3() {
sel_tmp228_fu_32711_p3 = (!cond6_reg_50242.read()[0].is_01())? sc_lv<2>(): ((cond6_reg_50242.read()[0].to_bool())? old_word_buffer_0_3_31_reg_53978.read(): old_word_buffer_0_7_47_reg_54261.read());
}
void a0_bin_conv::thread_sel_tmp229_fu_32716_p3() {
sel_tmp229_fu_32716_p3 = (!tmp_168_reg_50922.read()[0].is_01())? sc_lv<2>(): ((tmp_168_reg_50922.read()[0].to_bool())? old_word_buffer_0_4_29_reg_53874.read(): sel_tmp228_fu_32711_p3.read());
}
void a0_bin_conv::thread_sel_tmp230_fu_32722_p3() {
sel_tmp230_fu_32722_p3 = (!tmp_169_reg_51016.read()[0].is_01())? sc_lv<2>(): ((tmp_169_reg_51016.read()[0].to_bool())? old_word_buffer_0_5_31_reg_54086.read(): sel_tmp229_fu_32716_p3.read());
}
void a0_bin_conv::thread_sel_tmp231_fu_23740_p3() {
sel_tmp231_fu_23740_p3 = (!cond6_reg_50242.read()[0].is_01())? sc_lv<2>(): ((cond6_reg_50242.read()[0].to_bool())? old_word_buffer_0_3_17_fu_1478.read(): old_word_buffer_0_7_16_fu_1618.read());
}
void a0_bin_conv::thread_sel_tmp232_fu_23747_p3() {
sel_tmp232_fu_23747_p3 = (!tmp_168_reg_50922.read()[0].is_01())? sc_lv<2>(): ((tmp_168_reg_50922.read()[0].to_bool())? old_word_buffer_0_4_17_fu_1510.read(): sel_tmp231_fu_23740_p3.read());
}
void a0_bin_conv::thread_sel_tmp233_fu_23754_p3() {
sel_tmp233_fu_23754_p3 = (!tmp_169_reg_51016.read()[0].is_01())? sc_lv<2>(): ((tmp_169_reg_51016.read()[0].to_bool())? old_word_buffer_0_5_17_fu_1546.read(): sel_tmp232_fu_23747_p3.read());
}
void a0_bin_conv::thread_sel_tmp234_fu_32734_p3() {
sel_tmp234_fu_32734_p3 = (!cond6_reg_50242.read()[0].is_01())? sc_lv<2>(): ((cond6_reg_50242.read()[0].to_bool())? old_word_buffer_0_3_32_reg_53988.read(): ap_reg_pp0_iter2_old_word_buffer_0_7_49_reg_52193.read());
}
void a0_bin_conv::thread_sel_tmp235_fu_32739_p3() {
sel_tmp235_fu_32739_p3 = (!tmp_168_reg_50922.read()[0].is_01())? sc_lv<2>(): ((tmp_168_reg_50922.read()[0].to_bool())? old_word_buffer_0_4_32_reg_54033.read(): sel_tmp234_fu_32734_p3.read());
}
void a0_bin_conv::thread_sel_tmp236_fu_32745_p3() {
sel_tmp236_fu_32745_p3 = (!tmp_169_reg_51016.read()[0].is_01())? sc_lv<2>(): ((tmp_169_reg_51016.read()[0].to_bool())? old_word_buffer_0_5_32_reg_54100.read(): sel_tmp235_fu_32739_p3.read());
}
void a0_bin_conv::thread_sel_tmp237_fu_26814_p3() {
sel_tmp237_fu_26814_p3 = (!tmp_1227_reg_45800.read()[0].is_01())? sc_lv<2>(): ((tmp_1227_reg_45800.read()[0].to_bool())? old_word_buffer_0_7_fu_686.read(): ap_const_lv2_0);
}
void a0_bin_conv::thread_sel_tmp238_fu_26821_p3() {
sel_tmp238_fu_26821_p3 = (!sel_tmp84_reg_51313.read()[0].is_01())? sc_lv<2>(): ((sel_tmp84_reg_51313.read()[0].to_bool())? old_word_buffer_0_4_fu_674.read(): sel_tmp237_fu_26814_p3.read());
}
void a0_bin_conv::thread_sel_tmp239_fu_26828_p3() {
sel_tmp239_fu_26828_p3 = (!sel_tmp85_reg_51319.read()[0].is_01())? sc_lv<2>(): ((sel_tmp85_reg_51319.read()[0].to_bool())? old_word_buffer_0_5_fu_678.read(): sel_tmp238_fu_26821_p3.read());
}
void a0_bin_conv::thread_sel_tmp240_fu_26835_p3() {
sel_tmp240_fu_26835_p3 = (!sel_tmp86_reg_51325.read()[0].is_01())? sc_lv<2>(): ((sel_tmp86_reg_51325.read()[0].to_bool())? old_word_buffer_0_6_fu_682.read(): sel_tmp239_fu_26828_p3.read());
}
void a0_bin_conv::thread_sel_tmp241_fu_26656_p3() {
sel_tmp241_fu_26656_p3 = (!tmp_167_reg_50852.read()[0].is_01())? sc_lv<2>(): ((tmp_167_reg_50852.read()[0].to_bool())? word_buffer_0_0_1_1_fu_26044_p3.read(): word_buffer_0_2_1_fu_25951_p3.read());
}
void a0_bin_conv::thread_sel_tmp242_fu_26670_p3() {
sel_tmp242_fu_26670_p3 = (!tmp_167_reg_50852.read()[0].is_01())? sc_lv<2>(): ((tmp_167_reg_50852.read()[0].to_bool())? word_buffer_0_0_3_1_fu_26031_p3.read(): word_buffer_0_2_3_1_reg_53427.read());
}
void a0_bin_conv::thread_sel_tmp243_fu_26682_p3() {
sel_tmp243_fu_26682_p3 = (!tmp_167_reg_50852.read()[0].is_01())? sc_lv<2>(): ((tmp_167_reg_50852.read()[0].to_bool())? word_buffer_0_0_5_1_fu_26018_p3.read(): word_buffer_0_2_5_1_reg_53393.read());
}
void a0_bin_conv::thread_sel_tmp244_fu_26694_p3() {
sel_tmp244_fu_26694_p3 = (!tmp_167_reg_50852.read()[0].is_01())? sc_lv<2>(): ((tmp_167_reg_50852.read()[0].to_bool())? word_buffer_0_0_7_1_fu_26005_p3.read(): word_buffer_0_2_7_1_reg_53360.read());
}
void a0_bin_conv::thread_sel_tmp245_fu_32624_p2() {
sel_tmp245_fu_32624_p2 = (tmp_1227_reg_45800.read() & last_wrd_not_fu_32619_p2.read());
}
void a0_bin_conv::thread_sel_tmp246_fu_32629_p2() {
sel_tmp246_fu_32629_p2 = (tmp_167_reg_50852.read() & sel_tmp245_fu_32624_p2.read());
}
void a0_bin_conv::thread_sel_tmp247_fu_32634_p3() {
sel_tmp247_fu_32634_p3 = (!sel_tmp246_fu_32629_p2.read()[0].is_01())? sc_lv<2>(): ((sel_tmp246_fu_32629_p2.read()[0].to_bool())? ap_const_lv2_0: word_buffer_0_2_0_reg_55355.read());
}
void a0_bin_conv::thread_sel_tmp248_fu_32641_p2() {
sel_tmp248_fu_32641_p2 = (cond1_reg_50498.read() & sel_tmp245_fu_32624_p2.read());
}
void a0_bin_conv::thread_sel_tmp249_fu_32646_p3() {
sel_tmp249_fu_32646_p3 = (!sel_tmp248_fu_32641_p2.read()[0].is_01())? sc_lv<2>(): ((sel_tmp248_fu_32641_p2.read()[0].to_bool())? word_buffer_0_1_0_reg_55417.read(): sel_tmp247_fu_32634_p3.read());
}
void a0_bin_conv::thread_sel_tmp250_fu_26954_p3() {
sel_tmp250_fu_26954_p3 = (!cond6_reg_50242.read()[0].is_01())? sc_lv<2>(): ((cond6_reg_50242.read()[0].to_bool())? old_word_buffer_0_4_12_fu_1490.read(): old_word_buffer_0_7_10_fu_1594.read());
}
void a0_bin_conv::thread_sel_tmp251_fu_26961_p3() {
sel_tmp251_fu_26961_p3 = (!tmp_168_reg_50922.read()[0].is_01())? sc_lv<2>(): ((tmp_168_reg_50922.read()[0].to_bool())? old_word_buffer_0_5_11_fu_1522.read(): sel_tmp250_fu_26954_p3.read());
}
void a0_bin_conv::thread_sel_tmp252_fu_32815_p3() {
sel_tmp252_fu_32815_p3 = (!cond6_reg_50242.read()[0].is_01())? sc_lv<2>(): ((cond6_reg_50242.read()[0].to_bool())? old_word_buffer_0_4_30_reg_54009.read(): old_word_buffer_0_7_43_reg_54213.read());
}
void a0_bin_conv::thread_sel_tmp253_fu_32820_p3() {
sel_tmp253_fu_32820_p3 = (!tmp_168_reg_50922.read()[0].is_01())? sc_lv<2>(): ((tmp_168_reg_50922.read()[0].to_bool())? old_word_buffer_0_5_29_reg_54058.read(): sel_tmp252_fu_32815_p3.read());
}
void a0_bin_conv::thread_sel_tmp254_fu_26975_p3() {
sel_tmp254_fu_26975_p3 = (!cond6_reg_50242.read()[0].is_01())? sc_lv<2>(): ((cond6_reg_50242.read()[0].to_bool())? old_word_buffer_0_4_14_fu_1498.read(): old_word_buffer_0_7_12_fu_1602.read());
}
void a0_bin_conv::thread_sel_tmp255_fu_26982_p3() {
sel_tmp255_fu_26982_p3 = (!tmp_168_reg_50922.read()[0].is_01())? sc_lv<2>(): ((tmp_168_reg_50922.read()[0].to_bool())? old_word_buffer_0_5_13_fu_1530.read(): sel_tmp254_fu_26975_p3.read());
}
void a0_bin_conv::thread_sel_tmp256_fu_32832_p3() {
sel_tmp256_fu_32832_p3 = (!cond6_reg_50242.read()[0].is_01())? sc_lv<2>(): ((cond6_reg_50242.read()[0].to_bool())? old_word_buffer_0_4_31_reg_54021.read(): old_word_buffer_0_7_45_reg_54237.read());
}
void a0_bin_conv::thread_sel_tmp257_fu_32837_p3() {
sel_tmp257_fu_32837_p3 = (!tmp_168_reg_50922.read()[0].is_01())? sc_lv<2>(): ((tmp_168_reg_50922.read()[0].to_bool())? old_word_buffer_0_5_30_reg_54072.read(): sel_tmp256_fu_32832_p3.read());
}
void a0_bin_conv::thread_sel_tmp258_fu_26996_p3() {
sel_tmp258_fu_26996_p3 = (!cond6_reg_50242.read()[0].is_01())? sc_lv<2>(): ((cond6_reg_50242.read()[0].to_bool())? old_word_buffer_0_4_16_fu_1506.read(): old_word_buffer_0_7_14_fu_1610.read());
}
void a0_bin_conv::thread_sel_tmp259_fu_27003_p3() {
sel_tmp259_fu_27003_p3 = (!tmp_168_reg_50922.read()[0].is_01())? sc_lv<2>(): ((tmp_168_reg_50922.read()[0].to_bool())? old_word_buffer_0_5_15_fu_1538.read(): sel_tmp258_fu_26996_p3.read());
}
void a0_bin_conv::thread_sel_tmp260_fu_32849_p3() {
sel_tmp260_fu_32849_p3 = (!cond6_reg_50242.read()[0].is_01())? sc_lv<2>(): ((cond6_reg_50242.read()[0].to_bool())? old_word_buffer_0_4_29_reg_53874.read(): old_word_buffer_0_7_47_reg_54261.read());
}
void a0_bin_conv::thread_sel_tmp261_fu_32854_p3() {
sel_tmp261_fu_32854_p3 = (!tmp_168_reg_50922.read()[0].is_01())? sc_lv<2>(): ((tmp_168_reg_50922.read()[0].to_bool())? old_word_buffer_0_5_31_reg_54086.read(): sel_tmp260_fu_32849_p3.read());
}
void a0_bin_conv::thread_sel_tmp262_fu_23774_p3() {
sel_tmp262_fu_23774_p3 = (!cond6_reg_50242.read()[0].is_01())? sc_lv<2>(): ((cond6_reg_50242.read()[0].to_bool())? old_word_buffer_0_4_17_fu_1510.read(): old_word_buffer_0_7_16_fu_1618.read());
}
void a0_bin_conv::thread_sel_tmp263_fu_23781_p3() {
sel_tmp263_fu_23781_p3 = (!tmp_168_reg_50922.read()[0].is_01())? sc_lv<2>(): ((tmp_168_reg_50922.read()[0].to_bool())? old_word_buffer_0_5_17_fu_1546.read(): sel_tmp262_fu_23774_p3.read());
}
void a0_bin_conv::thread_sel_tmp264_fu_32866_p3() {
sel_tmp264_fu_32866_p3 = (!cond6_reg_50242.read()[0].is_01())? sc_lv<2>(): ((cond6_reg_50242.read()[0].to_bool())? old_word_buffer_0_4_32_reg_54033.read(): ap_reg_pp0_iter2_old_word_buffer_0_7_49_reg_52193.read());
}
void a0_bin_conv::thread_sel_tmp265_fu_32871_p3() {
sel_tmp265_fu_32871_p3 = (!tmp_168_reg_50922.read()[0].is_01())? sc_lv<2>(): ((tmp_168_reg_50922.read()[0].to_bool())? old_word_buffer_0_5_32_reg_54100.read(): sel_tmp264_fu_32866_p3.read());
}
void a0_bin_conv::thread_sel_tmp266_fu_27017_p3() {
sel_tmp266_fu_27017_p3 = (!lb_3_reg_45835.read()[0].is_01())? sc_lv<2>(): ((lb_3_reg_45835.read()[0].to_bool())? ap_const_lv2_0: old_word_buffer_0_7_fu_686.read());
}
void a0_bin_conv::thread_sel_tmp267_fu_27024_p3() {
sel_tmp267_fu_27024_p3 = (!sel_tmp89_reg_51337.read()[0].is_01())? sc_lv<2>(): ((sel_tmp89_reg_51337.read()[0].to_bool())? old_word_buffer_0_5_fu_678.read(): sel_tmp266_fu_27017_p3.read());
}
void a0_bin_conv::thread_sel_tmp268_fu_27031_p3() {
sel_tmp268_fu_27031_p3 = (!sel_tmp90_reg_51343.read()[0].is_01())? sc_lv<2>(): ((sel_tmp90_reg_51343.read()[0].to_bool())? old_word_buffer_0_6_fu_682.read(): sel_tmp267_fu_27024_p3.read());
}
void a0_bin_conv::thread_sel_tmp269_fu_26849_p3() {
sel_tmp269_fu_26849_p3 = (!tmp_170_reg_51104.read()[0].is_01())? sc_lv<2>(): ((tmp_170_reg_51104.read()[0].to_bool())? word_buffer_0_0_1_1_fu_26044_p3.read(): word_buffer_0_3_1_fu_25925_p3.read());
}
void a0_bin_conv::thread_sel_tmp270_fu_26856_p3() {
sel_tmp270_fu_26856_p3 = (!tmp_167_reg_50852.read()[0].is_01())? sc_lv<2>(): ((tmp_167_reg_50852.read()[0].to_bool())? word_buffer_0_1_1_fu_25979_p3.read(): sel_tmp269_fu_26849_p3.read());
}
void a0_bin_conv::thread_sel_tmp271_fu_26870_p3() {
sel_tmp271_fu_26870_p3 = (!tmp_170_reg_51104.read()[0].is_01())? sc_lv<2>(): ((tmp_170_reg_51104.read()[0].to_bool())? word_buffer_0_0_3_1_fu_26031_p3.read(): word_buffer_0_3_3_1_reg_53330.read());
}
void a0_bin_conv::thread_sel_tmp272_fu_26876_p3() {
sel_tmp272_fu_26876_p3 = (!tmp_167_reg_50852.read()[0].is_01())? sc_lv<2>(): ((tmp_167_reg_50852.read()[0].to_bool())? word_buffer_0_1_3_1_reg_53536.read(): sel_tmp271_fu_26870_p3.read());
}
void a0_bin_conv::thread_sel_tmp273_fu_26888_p3() {
sel_tmp273_fu_26888_p3 = (!tmp_170_reg_51104.read()[0].is_01())? sc_lv<2>(): ((tmp_170_reg_51104.read()[0].to_bool())? word_buffer_0_0_5_1_fu_26018_p3.read(): word_buffer_0_3_5_1_reg_53300.read());
}
void a0_bin_conv::thread_sel_tmp274_fu_26894_p3() {
sel_tmp274_fu_26894_p3 = (!tmp_167_reg_50852.read()[0].is_01())? sc_lv<2>(): ((tmp_167_reg_50852.read()[0].to_bool())? word_buffer_0_1_5_1_reg_53498.read(): sel_tmp273_fu_26888_p3.read());
}
void a0_bin_conv::thread_sel_tmp275_fu_26906_p3() {
sel_tmp275_fu_26906_p3 = (!tmp_170_reg_51104.read()[0].is_01())? sc_lv<2>(): ((tmp_170_reg_51104.read()[0].to_bool())? word_buffer_0_0_7_1_fu_26005_p3.read(): word_buffer_0_3_7_1_reg_53271.read());
}
void a0_bin_conv::thread_sel_tmp276_fu_26912_p3() {
sel_tmp276_fu_26912_p3 = (!tmp_167_reg_50852.read()[0].is_01())? sc_lv<2>(): ((tmp_167_reg_50852.read()[0].to_bool())? word_buffer_0_1_7_1_reg_53461.read(): sel_tmp275_fu_26906_p3.read());
}
void a0_bin_conv::thread_sel_tmp277_fu_32761_p2() {
sel_tmp277_fu_32761_p2 = (brmerge5_fu_32757_p2.read() ^ ap_const_lv1_1);
}
void a0_bin_conv::thread_sel_tmp278_fu_32767_p2() {
sel_tmp278_fu_32767_p2 = (tmp_170_reg_51104.read() & sel_tmp277_fu_32761_p2.read());
}
void a0_bin_conv::thread_sel_tmp279_fu_32772_p3() {
sel_tmp279_fu_32772_p3 = (!sel_tmp278_fu_32767_p2.read()[0].is_01())? sc_lv<2>(): ((sel_tmp278_fu_32767_p2.read()[0].to_bool())? ap_const_lv2_0: word_buffer_0_3_0_reg_55296.read());
}
void a0_bin_conv::thread_sel_tmp280_fu_32779_p2() {
sel_tmp280_fu_32779_p2 = (tmp_167_reg_50852.read() & sel_tmp277_fu_32761_p2.read());
}
void a0_bin_conv::thread_sel_tmp281_fu_32784_p3() {
sel_tmp281_fu_32784_p3 = (!sel_tmp280_fu_32779_p2.read()[0].is_01())? sc_lv<2>(): ((sel_tmp280_fu_32779_p2.read()[0].to_bool())? word_buffer_0_1_0_reg_55417.read(): sel_tmp279_fu_32772_p3.read());
}
void a0_bin_conv::thread_sel_tmp282_fu_32791_p2() {
sel_tmp282_fu_32791_p2 = (cond1_reg_50498.read() & sel_tmp277_fu_32761_p2.read());
}
void a0_bin_conv::thread_sel_tmp283_fu_32796_p3() {
sel_tmp283_fu_32796_p3 = (!sel_tmp282_fu_32791_p2.read()[0].is_01())? sc_lv<2>(): ((sel_tmp282_fu_32791_p2.read()[0].to_bool())? word_buffer_0_2_0_reg_55355.read(): sel_tmp281_fu_32784_p3.read());
}
void a0_bin_conv::thread_sel_tmp284_fu_27176_p3() {
sel_tmp284_fu_27176_p3 = (!cond6_reg_50242.read()[0].is_01())? sc_lv<2>(): ((cond6_reg_50242.read()[0].to_bool())? old_word_buffer_0_5_11_fu_1522.read(): old_word_buffer_0_7_10_fu_1594.read());
}
void a0_bin_conv::thread_sel_tmp285_fu_32947_p3() {
sel_tmp285_fu_32947_p3 = (!cond6_reg_50242.read()[0].is_01())? sc_lv<2>(): ((cond6_reg_50242.read()[0].to_bool())? old_word_buffer_0_5_29_reg_54058.read(): old_word_buffer_0_7_43_reg_54213.read());
}
void a0_bin_conv::thread_sel_tmp286_fu_27190_p3() {
sel_tmp286_fu_27190_p3 = (!cond6_reg_50242.read()[0].is_01())? sc_lv<2>(): ((cond6_reg_50242.read()[0].to_bool())? old_word_buffer_0_5_13_fu_1530.read(): old_word_buffer_0_7_12_fu_1602.read());
}
void a0_bin_conv::thread_sel_tmp287_fu_32958_p3() {
sel_tmp287_fu_32958_p3 = (!cond6_reg_50242.read()[0].is_01())? sc_lv<2>(): ((cond6_reg_50242.read()[0].to_bool())? old_word_buffer_0_5_30_reg_54072.read(): old_word_buffer_0_7_45_reg_54237.read());
}
void a0_bin_conv::thread_sel_tmp288_fu_27204_p3() {
sel_tmp288_fu_27204_p3 = (!cond6_reg_50242.read()[0].is_01())? sc_lv<2>(): ((cond6_reg_50242.read()[0].to_bool())? old_word_buffer_0_5_15_fu_1538.read(): old_word_buffer_0_7_14_fu_1610.read());
}
void a0_bin_conv::thread_sel_tmp289_fu_32969_p3() {
sel_tmp289_fu_32969_p3 = (!cond6_reg_50242.read()[0].is_01())? sc_lv<2>(): ((cond6_reg_50242.read()[0].to_bool())? old_word_buffer_0_5_31_reg_54086.read(): old_word_buffer_0_7_47_reg_54261.read());
}
void a0_bin_conv::thread_sel_tmp290_fu_23801_p3() {
sel_tmp290_fu_23801_p3 = (!cond6_reg_50242.read()[0].is_01())? sc_lv<2>(): ((cond6_reg_50242.read()[0].to_bool())? old_word_buffer_0_5_17_fu_1546.read(): old_word_buffer_0_7_16_fu_1618.read());
}
void a0_bin_conv::thread_sel_tmp291_fu_32980_p3() {
sel_tmp291_fu_32980_p3 = (!cond6_reg_50242.read()[0].is_01())? sc_lv<2>(): ((cond6_reg_50242.read()[0].to_bool())? old_word_buffer_0_5_32_reg_54100.read(): ap_reg_pp0_iter2_old_word_buffer_0_7_49_reg_52193.read());
}
void a0_bin_conv::thread_sel_tmp292_fu_27218_p3() {
sel_tmp292_fu_27218_p3 = (!lb_4_reg_45859.read()[0].is_01())? sc_lv<2>(): ((lb_4_reg_45859.read()[0].to_bool())? ap_const_lv2_0: old_word_buffer_0_7_fu_686.read());
}
void a0_bin_conv::thread_sel_tmp293_fu_27225_p3() {
sel_tmp293_fu_27225_p3 = (!sel_tmp93_reg_51355.read()[0].is_01())? sc_lv<2>(): ((sel_tmp93_reg_51355.read()[0].to_bool())? old_word_buffer_0_6_fu_682.read(): sel_tmp292_fu_27218_p3.read());
}
void a0_bin_conv::thread_sel_tmp294_fu_27045_p3() {
sel_tmp294_fu_27045_p3 = (!tmp_171_reg_51180.read()[0].is_01())? sc_lv<2>(): ((tmp_171_reg_51180.read()[0].to_bool())? word_buffer_0_0_1_1_fu_26044_p3.read(): word_buffer_0_4_1_fu_25899_p3.read());
}
void a0_bin_conv::thread_sel_tmp295_fu_27052_p3() {
sel_tmp295_fu_27052_p3 = (!tmp_170_reg_51104.read()[0].is_01())? sc_lv<2>(): ((tmp_170_reg_51104.read()[0].to_bool())? word_buffer_0_1_1_fu_25979_p3.read(): sel_tmp294_fu_27045_p3.read());
}
void a0_bin_conv::thread_sel_tmp296_fu_27059_p3() {
sel_tmp296_fu_27059_p3 = (!tmp_167_reg_50852.read()[0].is_01())? sc_lv<2>(): ((tmp_167_reg_50852.read()[0].to_bool())? word_buffer_0_2_1_fu_25951_p3.read(): sel_tmp295_fu_27052_p3.read());
}
void a0_bin_conv::thread_sel_tmp297_fu_27073_p3() {
sel_tmp297_fu_27073_p3 = (!tmp_171_reg_51180.read()[0].is_01())? sc_lv<2>(): ((tmp_171_reg_51180.read()[0].to_bool())? word_buffer_0_0_3_1_fu_26031_p3.read(): word_buffer_0_4_3_1_reg_53245.read());
}
void a0_bin_conv::thread_sel_tmp298_fu_27079_p3() {
sel_tmp298_fu_27079_p3 = (!tmp_170_reg_51104.read()[0].is_01())? sc_lv<2>(): ((tmp_170_reg_51104.read()[0].to_bool())? word_buffer_0_1_3_1_reg_53536.read(): sel_tmp297_fu_27073_p3.read());
}
void a0_bin_conv::thread_sel_tmp299_fu_27085_p3() {
sel_tmp299_fu_27085_p3 = (!tmp_167_reg_50852.read()[0].is_01())? sc_lv<2>(): ((tmp_167_reg_50852.read()[0].to_bool())? word_buffer_0_2_3_1_reg_53427.read(): sel_tmp298_fu_27079_p3.read());
}
void a0_bin_conv::thread_sel_tmp300_fu_27097_p3() {
sel_tmp300_fu_27097_p3 = (!tmp_171_reg_51180.read()[0].is_01())? sc_lv<2>(): ((tmp_171_reg_51180.read()[0].to_bool())? word_buffer_0_0_5_1_fu_26018_p3.read(): word_buffer_0_4_5_1_reg_53219.read());
}
void a0_bin_conv::thread_sel_tmp301_fu_27103_p3() {
sel_tmp301_fu_27103_p3 = (!tmp_170_reg_51104.read()[0].is_01())? sc_lv<2>(): ((tmp_170_reg_51104.read()[0].to_bool())? word_buffer_0_1_5_1_reg_53498.read(): sel_tmp300_fu_27097_p3.read());
}
void a0_bin_conv::thread_sel_tmp302_fu_27109_p3() {
sel_tmp302_fu_27109_p3 = (!tmp_167_reg_50852.read()[0].is_01())? sc_lv<2>(): ((tmp_167_reg_50852.read()[0].to_bool())? word_buffer_0_2_5_1_reg_53393.read(): sel_tmp301_fu_27103_p3.read());
}
void a0_bin_conv::thread_sel_tmp303_fu_27121_p3() {
sel_tmp303_fu_27121_p3 = (!tmp_171_reg_51180.read()[0].is_01())? sc_lv<2>(): ((tmp_171_reg_51180.read()[0].to_bool())? word_buffer_0_0_7_1_fu_26005_p3.read(): word_buffer_0_4_7_1_reg_53194.read());
}
void a0_bin_conv::thread_sel_tmp304_fu_27127_p3() {
sel_tmp304_fu_27127_p3 = (!tmp_170_reg_51104.read()[0].is_01())? sc_lv<2>(): ((tmp_170_reg_51104.read()[0].to_bool())? word_buffer_0_1_7_1_reg_53461.read(): sel_tmp303_fu_27121_p3.read());
}
void a0_bin_conv::thread_sel_tmp305_fu_27133_p3() {
sel_tmp305_fu_27133_p3 = (!tmp_167_reg_50852.read()[0].is_01())? sc_lv<2>(): ((tmp_167_reg_50852.read()[0].to_bool())? word_buffer_0_2_7_1_reg_53360.read(): sel_tmp304_fu_27127_p3.read());
}
void a0_bin_conv::thread_sel_tmp306_fu_32883_p2() {
sel_tmp306_fu_32883_p2 = (brmerge7_reg_55982.read() ^ ap_const_lv1_1);
}
void a0_bin_conv::thread_sel_tmp307_fu_32888_p2() {
sel_tmp307_fu_32888_p2 = (tmp_171_reg_51180.read() & sel_tmp306_fu_32883_p2.read());
}
void a0_bin_conv::thread_sel_tmp308_fu_32893_p3() {
sel_tmp308_fu_32893_p3 = (!sel_tmp307_fu_32888_p2.read()[0].is_01())? sc_lv<2>(): ((sel_tmp307_fu_32888_p2.read()[0].to_bool())? ap_const_lv2_0: word_buffer_0_4_0_reg_55244.read());
}
void a0_bin_conv::thread_sel_tmp309_fu_32900_p2() {
sel_tmp309_fu_32900_p2 = (tmp_170_reg_51104.read() & sel_tmp306_fu_32883_p2.read());
}
void a0_bin_conv::thread_sel_tmp310_fu_32905_p3() {
sel_tmp310_fu_32905_p3 = (!sel_tmp309_fu_32900_p2.read()[0].is_01())? sc_lv<2>(): ((sel_tmp309_fu_32900_p2.read()[0].to_bool())? word_buffer_0_1_0_reg_55417.read(): sel_tmp308_fu_32893_p3.read());
}
void a0_bin_conv::thread_sel_tmp311_fu_32912_p2() {
sel_tmp311_fu_32912_p2 = (tmp_167_reg_50852.read() & sel_tmp306_fu_32883_p2.read());
}
void a0_bin_conv::thread_sel_tmp312_fu_32917_p3() {
sel_tmp312_fu_32917_p3 = (!sel_tmp311_fu_32912_p2.read()[0].is_01())? sc_lv<2>(): ((sel_tmp311_fu_32912_p2.read()[0].to_bool())? word_buffer_0_2_0_reg_55355.read(): sel_tmp310_fu_32905_p3.read());
}
void a0_bin_conv::thread_sel_tmp313_fu_32924_p2() {
sel_tmp313_fu_32924_p2 = (cond1_reg_50498.read() & sel_tmp306_fu_32883_p2.read());
}
void a0_bin_conv::thread_sel_tmp314_fu_32929_p3() {
sel_tmp314_fu_32929_p3 = (!sel_tmp313_fu_32924_p2.read()[0].is_01())? sc_lv<2>(): ((sel_tmp313_fu_32924_p2.read()[0].to_bool())? word_buffer_0_3_0_reg_55296.read(): sel_tmp312_fu_32917_p3.read());
}
void a0_bin_conv::thread_sel_tmp315_fu_27239_p3() {
sel_tmp315_fu_27239_p3 = (!tmp_169_reg_51016.read()[0].is_01())? sc_lv<2>(): ((tmp_169_reg_51016.read()[0].to_bool())? word_buffer_0_0_1_1_fu_26044_p3.read(): word_buffer_0_5_1_fu_25871_p3.read());
}
void a0_bin_conv::thread_sel_tmp316_fu_27246_p3() {
sel_tmp316_fu_27246_p3 = (!tmp_171_reg_51180.read()[0].is_01())? sc_lv<2>(): ((tmp_171_reg_51180.read()[0].to_bool())? word_buffer_0_1_1_fu_25979_p3.read(): sel_tmp315_fu_27239_p3.read());
}
void a0_bin_conv::thread_sel_tmp317_fu_32991_p3() {
sel_tmp317_fu_32991_p3 = (!tmp_170_reg_51104.read()[0].is_01())? sc_lv<2>(): ((tmp_170_reg_51104.read()[0].to_bool())? word_buffer_0_2_1_reg_55342.read(): sel_tmp316_reg_56020.read());
}
void a0_bin_conv::thread_sel_tmp318_fu_32996_p3() {
sel_tmp318_fu_32996_p3 = (!tmp_167_reg_50852.read()[0].is_01())? sc_lv<2>(): ((tmp_167_reg_50852.read()[0].to_bool())? word_buffer_0_3_1_reg_55284.read(): sel_tmp317_fu_32991_p3.read());
}
void a0_bin_conv::thread_sel_tmp319_fu_27253_p3() {
sel_tmp319_fu_27253_p3 = (!tmp_169_reg_51016.read()[0].is_01())? sc_lv<2>(): ((tmp_169_reg_51016.read()[0].to_bool())? word_buffer_0_0_3_1_fu_26031_p3.read(): word_buffer_0_5_3_1_reg_53172.read());
}
void a0_bin_conv::thread_sel_tmp320_fu_27259_p3() {
sel_tmp320_fu_27259_p3 = (!tmp_171_reg_51180.read()[0].is_01())? sc_lv<2>(): ((tmp_171_reg_51180.read()[0].to_bool())? word_buffer_0_1_3_1_reg_53536.read(): sel_tmp319_fu_27253_p3.read());
}
void a0_bin_conv::thread_sel_tmp321_fu_33014_p3() {
sel_tmp321_fu_33014_p3 = (!tmp_170_reg_51104.read()[0].is_01())? sc_lv<2>(): ((tmp_170_reg_51104.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_0_2_3_1_reg_53427.read(): sel_tmp320_reg_56025.read());
}
void a0_bin_conv::thread_sel_tmp322_fu_33019_p3() {
sel_tmp322_fu_33019_p3 = (!tmp_167_reg_50852.read()[0].is_01())? sc_lv<2>(): ((tmp_167_reg_50852.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_0_3_3_1_reg_53330.read(): sel_tmp321_fu_33014_p3.read());
}
void a0_bin_conv::thread_sel_tmp323_fu_27265_p3() {
sel_tmp323_fu_27265_p3 = (!tmp_169_reg_51016.read()[0].is_01())? sc_lv<2>(): ((tmp_169_reg_51016.read()[0].to_bool())? word_buffer_0_0_5_1_fu_26018_p3.read(): word_buffer_0_5_5_1_reg_53150.read());
}
void a0_bin_conv::thread_sel_tmp324_fu_27271_p3() {
sel_tmp324_fu_27271_p3 = (!tmp_171_reg_51180.read()[0].is_01())? sc_lv<2>(): ((tmp_171_reg_51180.read()[0].to_bool())? word_buffer_0_1_5_1_reg_53498.read(): sel_tmp323_fu_27265_p3.read());
}
void a0_bin_conv::thread_sel_tmp325_fu_33037_p3() {
sel_tmp325_fu_33037_p3 = (!tmp_170_reg_51104.read()[0].is_01())? sc_lv<2>(): ((tmp_170_reg_51104.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_0_2_5_1_reg_53393.read(): sel_tmp324_reg_56030.read());
}
void a0_bin_conv::thread_sel_tmp326_fu_33042_p3() {
sel_tmp326_fu_33042_p3 = (!tmp_167_reg_50852.read()[0].is_01())? sc_lv<2>(): ((tmp_167_reg_50852.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_0_3_5_1_reg_53300.read(): sel_tmp325_fu_33037_p3.read());
}
void a0_bin_conv::thread_sel_tmp327_fu_27277_p3() {
sel_tmp327_fu_27277_p3 = (!tmp_169_reg_51016.read()[0].is_01())? sc_lv<2>(): ((tmp_169_reg_51016.read()[0].to_bool())? word_buffer_0_0_7_1_fu_26005_p3.read(): word_buffer_0_5_7_1_reg_53129.read());
}
void a0_bin_conv::thread_sel_tmp328_fu_27283_p3() {
sel_tmp328_fu_27283_p3 = (!tmp_171_reg_51180.read()[0].is_01())? sc_lv<2>(): ((tmp_171_reg_51180.read()[0].to_bool())? word_buffer_0_1_7_1_reg_53461.read(): sel_tmp327_fu_27277_p3.read());
}
void a0_bin_conv::thread_sel_tmp329_fu_33060_p3() {
sel_tmp329_fu_33060_p3 = (!tmp_170_reg_51104.read()[0].is_01())? sc_lv<2>(): ((tmp_170_reg_51104.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_0_2_7_1_reg_53360.read(): sel_tmp328_reg_56035.read());
}
void a0_bin_conv::thread_sel_tmp330_fu_33065_p3() {
sel_tmp330_fu_33065_p3 = (!tmp_167_reg_50852.read()[0].is_01())? sc_lv<2>(): ((tmp_167_reg_50852.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_0_3_7_1_reg_53271.read(): sel_tmp329_fu_33060_p3.read());
}
void a0_bin_conv::thread_sel_tmp331_fu_27293_p2() {
sel_tmp331_fu_27293_p2 = (brmerge9_fu_27289_p2.read() ^ ap_const_lv1_1);
}
void a0_bin_conv::thread_sel_tmp332_fu_27299_p2() {
sel_tmp332_fu_27299_p2 = (tmp_169_reg_51016.read() & sel_tmp331_fu_27293_p2.read());
}
void a0_bin_conv::thread_sel_tmp333_fu_27304_p3() {
sel_tmp333_fu_27304_p3 = (!sel_tmp332_fu_27299_p2.read()[0].is_01())? sc_lv<2>(): ((sel_tmp332_fu_27299_p2.read()[0].to_bool())? ap_const_lv2_0: word_buffer_0_5_0_fu_25878_p3.read());
}
void a0_bin_conv::thread_sel_tmp334_fu_27312_p2() {
sel_tmp334_fu_27312_p2 = (tmp_171_reg_51180.read() & sel_tmp331_fu_27293_p2.read());
}
void a0_bin_conv::thread_sel_tmp335_fu_27317_p3() {
sel_tmp335_fu_27317_p3 = (!sel_tmp334_fu_27312_p2.read()[0].is_01())? sc_lv<2>(): ((sel_tmp334_fu_27312_p2.read()[0].to_bool())? word_buffer_0_1_0_fu_25985_p3.read(): sel_tmp333_fu_27304_p3.read());
}
void a0_bin_conv::thread_sel_tmp336_fu_33083_p2() {
sel_tmp336_fu_33083_p2 = (tmp_170_reg_51104.read() & sel_tmp331_reg_56045.read());
}
void a0_bin_conv::thread_sel_tmp337_fu_33087_p3() {
sel_tmp337_fu_33087_p3 = (!sel_tmp336_fu_33083_p2.read()[0].is_01())? sc_lv<2>(): ((sel_tmp336_fu_33083_p2.read()[0].to_bool())? word_buffer_0_2_0_reg_55355.read(): sel_tmp335_reg_56052.read());
}
void a0_bin_conv::thread_sel_tmp338_fu_33093_p2() {
sel_tmp338_fu_33093_p2 = (tmp_167_reg_50852.read() & sel_tmp331_reg_56045.read());
}
void a0_bin_conv::thread_sel_tmp339_fu_33097_p3() {
sel_tmp339_fu_33097_p3 = (!sel_tmp338_fu_33093_p2.read()[0].is_01())? sc_lv<2>(): ((sel_tmp338_fu_33093_p2.read()[0].to_bool())? word_buffer_0_3_0_reg_55296.read(): sel_tmp337_fu_33087_p3.read());
}
void a0_bin_conv::thread_sel_tmp340_fu_33104_p2() {
sel_tmp340_fu_33104_p2 = (cond1_reg_50498.read() & sel_tmp331_reg_56045.read());
}
void a0_bin_conv::thread_sel_tmp341_fu_33108_p3() {
sel_tmp341_fu_33108_p3 = (!sel_tmp340_fu_33104_p2.read()[0].is_01())? sc_lv<2>(): ((sel_tmp340_fu_33104_p2.read()[0].to_bool())? word_buffer_0_4_0_reg_55244.read(): sel_tmp339_fu_33097_p3.read());
}
void a0_bin_conv::thread_sel_tmp342_fu_27354_p3() {
sel_tmp342_fu_27354_p3 = (!tmp_168_reg_50922.read()[0].is_01())? sc_lv<2>(): ((tmp_168_reg_50922.read()[0].to_bool())? word_buffer_0_0_1_1_fu_26044_p3.read(): word_buffer_0_6_1_fu_25843_p3.read());
}
void a0_bin_conv::thread_sel_tmp343_fu_27361_p3() {
sel_tmp343_fu_27361_p3 = (!tmp_169_reg_51016.read()[0].is_01())? sc_lv<2>(): ((tmp_169_reg_51016.read()[0].to_bool())? word_buffer_0_1_1_fu_25979_p3.read(): sel_tmp342_fu_27354_p3.read());
}
void a0_bin_conv::thread_sel_tmp344_fu_33172_p3() {
sel_tmp344_fu_33172_p3 = (!tmp_171_reg_51180.read()[0].is_01())? sc_lv<2>(): ((tmp_171_reg_51180.read()[0].to_bool())? word_buffer_0_2_1_reg_55342.read(): sel_tmp343_reg_56078.read());
}
void a0_bin_conv::thread_sel_tmp345_fu_33177_p3() {
sel_tmp345_fu_33177_p3 = (!tmp_170_reg_51104.read()[0].is_01())? sc_lv<2>(): ((tmp_170_reg_51104.read()[0].to_bool())? word_buffer_0_3_1_reg_55284.read(): sel_tmp344_fu_33172_p3.read());
}
void a0_bin_conv::thread_sel_tmp346_fu_33183_p3() {
sel_tmp346_fu_33183_p3 = (!tmp_167_reg_50852.read()[0].is_01())? sc_lv<2>(): ((tmp_167_reg_50852.read()[0].to_bool())? word_buffer_0_4_1_reg_55233.read(): sel_tmp345_fu_33177_p3.read());
}
void a0_bin_conv::thread_sel_tmp347_fu_27368_p3() {
sel_tmp347_fu_27368_p3 = (!tmp_168_reg_50922.read()[0].is_01())? sc_lv<2>(): ((tmp_168_reg_50922.read()[0].to_bool())? word_buffer_0_0_3_1_fu_26031_p3.read(): word_buffer_0_6_3_1_reg_53111.read());
}
void a0_bin_conv::thread_sel_tmp348_fu_27374_p3() {
sel_tmp348_fu_27374_p3 = (!tmp_169_reg_51016.read()[0].is_01())? sc_lv<2>(): ((tmp_169_reg_51016.read()[0].to_bool())? word_buffer_0_1_3_1_reg_53536.read(): sel_tmp347_fu_27368_p3.read());
}
void a0_bin_conv::thread_sel_tmp349_fu_27380_p3() {
sel_tmp349_fu_27380_p3 = (!tmp_171_reg_51180.read()[0].is_01())? sc_lv<2>(): ((tmp_171_reg_51180.read()[0].to_bool())? word_buffer_0_2_3_1_reg_53427.read(): sel_tmp348_fu_27374_p3.read());
}
void a0_bin_conv::thread_sel_tmp350_fu_27386_p3() {
sel_tmp350_fu_27386_p3 = (!tmp_170_reg_51104.read()[0].is_01())? sc_lv<2>(): ((tmp_170_reg_51104.read()[0].to_bool())? word_buffer_0_3_3_1_reg_53330.read(): sel_tmp349_fu_27380_p3.read());
}
void a0_bin_conv::thread_sel_tmp351_fu_27392_p3() {
sel_tmp351_fu_27392_p3 = (!tmp_167_reg_50852.read()[0].is_01())? sc_lv<2>(): ((tmp_167_reg_50852.read()[0].to_bool())? word_buffer_0_4_3_1_reg_53245.read(): sel_tmp350_fu_27386_p3.read());
}
void a0_bin_conv::thread_sel_tmp352_fu_27404_p3() {
sel_tmp352_fu_27404_p3 = (!tmp_168_reg_50922.read()[0].is_01())? sc_lv<2>(): ((tmp_168_reg_50922.read()[0].to_bool())? word_buffer_0_0_5_1_fu_26018_p3.read(): word_buffer_0_6_5_1_reg_53093.read());
}
void a0_bin_conv::thread_sel_tmp353_fu_27410_p3() {
sel_tmp353_fu_27410_p3 = (!tmp_169_reg_51016.read()[0].is_01())? sc_lv<2>(): ((tmp_169_reg_51016.read()[0].to_bool())? word_buffer_0_1_5_1_reg_53498.read(): sel_tmp352_fu_27404_p3.read());
}
void a0_bin_conv::thread_sel_tmp354_fu_33202_p3() {
sel_tmp354_fu_33202_p3 = (!tmp_171_reg_51180.read()[0].is_01())? sc_lv<2>(): ((tmp_171_reg_51180.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_0_2_5_1_reg_53393.read(): sel_tmp353_reg_56094.read());
}
void a0_bin_conv::thread_sel_tmp355_fu_33207_p3() {
sel_tmp355_fu_33207_p3 = (!tmp_170_reg_51104.read()[0].is_01())? sc_lv<2>(): ((tmp_170_reg_51104.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_0_3_5_1_reg_53300.read(): sel_tmp354_fu_33202_p3.read());
}
void a0_bin_conv::thread_sel_tmp356_fu_33213_p3() {
sel_tmp356_fu_33213_p3 = (!tmp_167_reg_50852.read()[0].is_01())? sc_lv<2>(): ((tmp_167_reg_50852.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_0_4_5_1_reg_53219.read(): sel_tmp355_fu_33207_p3.read());
}
void a0_bin_conv::thread_sel_tmp357_fu_27416_p3() {
sel_tmp357_fu_27416_p3 = (!tmp_168_reg_50922.read()[0].is_01())? sc_lv<2>(): ((tmp_168_reg_50922.read()[0].to_bool())? word_buffer_0_0_7_1_fu_26005_p3.read(): word_buffer_0_6_7_1_reg_53076.read());
}
void a0_bin_conv::thread_sel_tmp358_fu_27422_p3() {
sel_tmp358_fu_27422_p3 = (!tmp_169_reg_51016.read()[0].is_01())? sc_lv<2>(): ((tmp_169_reg_51016.read()[0].to_bool())? word_buffer_0_1_7_1_reg_53461.read(): sel_tmp357_fu_27416_p3.read());
}
void a0_bin_conv::thread_sel_tmp359_fu_33232_p3() {
sel_tmp359_fu_33232_p3 = (!tmp_171_reg_51180.read()[0].is_01())? sc_lv<2>(): ((tmp_171_reg_51180.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_0_2_7_1_reg_53360.read(): sel_tmp358_reg_56099.read());
}
void a0_bin_conv::thread_sel_tmp360_fu_33237_p3() {
sel_tmp360_fu_33237_p3 = (!tmp_170_reg_51104.read()[0].is_01())? sc_lv<2>(): ((tmp_170_reg_51104.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_0_3_7_1_reg_53271.read(): sel_tmp359_fu_33232_p3.read());
}
void a0_bin_conv::thread_sel_tmp361_fu_33243_p3() {
sel_tmp361_fu_33243_p3 = (!tmp_167_reg_50852.read()[0].is_01())? sc_lv<2>(): ((tmp_167_reg_50852.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_0_4_7_1_reg_53194.read(): sel_tmp360_fu_33237_p3.read());
}
void a0_bin_conv::thread_sel_tmp362_fu_27432_p2() {
sel_tmp362_fu_27432_p2 = (brmerge11_fu_27428_p2.read() ^ ap_const_lv1_1);
}
void a0_bin_conv::thread_sel_tmp363_fu_27438_p2() {
sel_tmp363_fu_27438_p2 = (tmp_168_reg_50922.read() & sel_tmp362_fu_27432_p2.read());
}
void a0_bin_conv::thread_sel_tmp364_fu_27443_p3() {
sel_tmp364_fu_27443_p3 = (!sel_tmp363_fu_27438_p2.read()[0].is_01())? sc_lv<2>(): ((sel_tmp363_fu_27438_p2.read()[0].to_bool())? ap_const_lv2_0: word_buffer_0_6_0_fu_25850_p3.read());
}
void a0_bin_conv::thread_sel_tmp365_fu_27451_p2() {
sel_tmp365_fu_27451_p2 = (tmp_169_reg_51016.read() & sel_tmp362_fu_27432_p2.read());
}
void a0_bin_conv::thread_sel_tmp366_fu_27456_p3() {
sel_tmp366_fu_27456_p3 = (!sel_tmp365_fu_27451_p2.read()[0].is_01())? sc_lv<2>(): ((sel_tmp365_fu_27451_p2.read()[0].to_bool())? word_buffer_0_1_0_fu_25985_p3.read(): sel_tmp364_fu_27443_p3.read());
}
void a0_bin_conv::thread_sel_tmp367_fu_27464_p2() {
sel_tmp367_fu_27464_p2 = (tmp_171_reg_51180.read() & sel_tmp362_fu_27432_p2.read());
}
void a0_bin_conv::thread_sel_tmp368_fu_27469_p3() {
sel_tmp368_fu_27469_p3 = (!sel_tmp367_fu_27464_p2.read()[0].is_01())? sc_lv<2>(): ((sel_tmp367_fu_27464_p2.read()[0].to_bool())? word_buffer_0_2_0_fu_25958_p3.read(): sel_tmp366_fu_27456_p3.read());
}
void a0_bin_conv::thread_sel_tmp369_fu_33262_p2() {
sel_tmp369_fu_33262_p2 = (tmp_170_reg_51104.read() & sel_tmp362_reg_56109.read());
}
void a0_bin_conv::thread_sel_tmp370_fu_33266_p3() {
sel_tmp370_fu_33266_p3 = (!sel_tmp369_fu_33262_p2.read()[0].is_01())? sc_lv<2>(): ((sel_tmp369_fu_33262_p2.read()[0].to_bool())? word_buffer_0_3_0_reg_55296.read(): sel_tmp368_reg_56116.read());
}
void a0_bin_conv::thread_sel_tmp371_fu_33272_p2() {
sel_tmp371_fu_33272_p2 = (tmp_167_reg_50852.read() & sel_tmp362_reg_56109.read());
}
void a0_bin_conv::thread_sel_tmp372_fu_33276_p3() {
sel_tmp372_fu_33276_p3 = (!sel_tmp371_fu_33272_p2.read()[0].is_01())? sc_lv<2>(): ((sel_tmp371_fu_33272_p2.read()[0].to_bool())? word_buffer_0_4_0_reg_55244.read(): sel_tmp370_fu_33266_p3.read());
}
void a0_bin_conv::thread_sel_tmp373_fu_33283_p2() {
sel_tmp373_fu_33283_p2 = (cond1_reg_50498.read() & sel_tmp362_reg_56109.read());
}
void a0_bin_conv::thread_sel_tmp374_fu_33287_p3() {
sel_tmp374_fu_33287_p3 = (!sel_tmp373_fu_33283_p2.read()[0].is_01())? sc_lv<2>(): ((sel_tmp373_fu_33283_p2.read()[0].to_bool())? word_buffer_0_5_0_reg_55200.read(): sel_tmp372_fu_33276_p3.read());
}
void a0_bin_conv::thread_sel_tmp375_fu_27648_p3() {
sel_tmp375_fu_27648_p3 = (!tmp_143_reg_50572.read()[0].is_01())? sc_lv<2>(): ((tmp_143_reg_50572.read()[0].to_bool())? old_word_buffer_0_1_11_fu_1382.read(): old_word_buffer_0_7_10_fu_1594.read());
}
void a0_bin_conv::thread_sel_tmp376_fu_27655_p3() {
sel_tmp376_fu_27655_p3 = (!tmp_148_reg_50586.read()[0].is_01())? sc_lv<2>(): ((tmp_148_reg_50586.read()[0].to_bool())? old_word_buffer_0_2_11_fu_1418.read(): sel_tmp375_fu_27648_p3.read());
}
void a0_bin_conv::thread_sel_tmp377_fu_27662_p3() {
sel_tmp377_fu_27662_p3 = (!tmp_149_reg_50600.read()[0].is_01())? sc_lv<2>(): ((tmp_149_reg_50600.read()[0].to_bool())? old_word_buffer_0_3_11_fu_1454.read(): sel_tmp376_fu_27655_p3.read());
}
void a0_bin_conv::thread_sel_tmp378_fu_27669_p3() {
sel_tmp378_fu_27669_p3 = (!tmp_150_reg_50614.read()[0].is_01())? sc_lv<2>(): ((tmp_150_reg_50614.read()[0].to_bool())? old_word_buffer_0_4_12_fu_1490.read(): sel_tmp377_fu_27662_p3.read());
}
void a0_bin_conv::thread_sel_tmp379_fu_27676_p3() {
sel_tmp379_fu_27676_p3 = (!tmp_151_reg_50628.read()[0].is_01())? sc_lv<2>(): ((tmp_151_reg_50628.read()[0].to_bool())? old_word_buffer_0_5_11_fu_1522.read(): sel_tmp378_fu_27669_p3.read());
}
void a0_bin_conv::thread_sel_tmp380_fu_27708_p3() {
sel_tmp380_fu_27708_p3 = (!tmp_143_reg_50572.read()[0].is_01())? sc_lv<2>(): ((tmp_143_reg_50572.read()[0].to_bool())? old_word_buffer_0_1_13_fu_1390.read(): old_word_buffer_0_7_12_fu_1602.read());
}
void a0_bin_conv::thread_sel_tmp381_fu_27715_p3() {
sel_tmp381_fu_27715_p3 = (!tmp_148_reg_50586.read()[0].is_01())? sc_lv<2>(): ((tmp_148_reg_50586.read()[0].to_bool())? old_word_buffer_0_2_13_fu_1426.read(): sel_tmp380_fu_27708_p3.read());
}
void a0_bin_conv::thread_sel_tmp382_fu_27722_p3() {
sel_tmp382_fu_27722_p3 = (!tmp_149_reg_50600.read()[0].is_01())? sc_lv<2>(): ((tmp_149_reg_50600.read()[0].to_bool())? old_word_buffer_0_3_13_fu_1462.read(): sel_tmp381_fu_27715_p3.read());
}
void a0_bin_conv::thread_sel_tmp383_fu_27729_p3() {
sel_tmp383_fu_27729_p3 = (!tmp_150_reg_50614.read()[0].is_01())? sc_lv<2>(): ((tmp_150_reg_50614.read()[0].to_bool())? old_word_buffer_0_4_14_fu_1498.read(): sel_tmp382_fu_27722_p3.read());
}
void a0_bin_conv::thread_sel_tmp384_fu_27736_p3() {
sel_tmp384_fu_27736_p3 = (!tmp_151_reg_50628.read()[0].is_01())? sc_lv<2>(): ((tmp_151_reg_50628.read()[0].to_bool())? old_word_buffer_0_5_13_fu_1530.read(): sel_tmp383_fu_27729_p3.read());
}
void a0_bin_conv::thread_sel_tmp385_fu_27768_p3() {
sel_tmp385_fu_27768_p3 = (!tmp_143_reg_50572.read()[0].is_01())? sc_lv<2>(): ((tmp_143_reg_50572.read()[0].to_bool())? old_word_buffer_0_1_15_fu_1398.read(): old_word_buffer_0_7_14_fu_1610.read());
}
void a0_bin_conv::thread_sel_tmp386_fu_27775_p3() {
sel_tmp386_fu_27775_p3 = (!tmp_148_reg_50586.read()[0].is_01())? sc_lv<2>(): ((tmp_148_reg_50586.read()[0].to_bool())? old_word_buffer_0_2_15_fu_1434.read(): sel_tmp385_fu_27768_p3.read());
}
void a0_bin_conv::thread_sel_tmp387_fu_27782_p3() {
sel_tmp387_fu_27782_p3 = (!tmp_149_reg_50600.read()[0].is_01())? sc_lv<2>(): ((tmp_149_reg_50600.read()[0].to_bool())? old_word_buffer_0_3_15_fu_1470.read(): sel_tmp386_fu_27775_p3.read());
}
void a0_bin_conv::thread_sel_tmp388_fu_27789_p3() {
sel_tmp388_fu_27789_p3 = (!tmp_150_reg_50614.read()[0].is_01())? sc_lv<2>(): ((tmp_150_reg_50614.read()[0].to_bool())? old_word_buffer_0_4_16_fu_1506.read(): sel_tmp387_fu_27782_p3.read());
}
void a0_bin_conv::thread_sel_tmp389_fu_27796_p3() {
sel_tmp389_fu_27796_p3 = (!tmp_151_reg_50628.read()[0].is_01())? sc_lv<2>(): ((tmp_151_reg_50628.read()[0].to_bool())? old_word_buffer_0_5_15_fu_1538.read(): sel_tmp388_fu_27789_p3.read());
}
void a0_bin_conv::thread_sel_tmp390_fu_23854_p3() {
sel_tmp390_fu_23854_p3 = (!tmp_143_reg_50572.read()[0].is_01())? sc_lv<2>(): ((tmp_143_reg_50572.read()[0].to_bool())? old_word_buffer_0_1_17_fu_1406.read(): old_word_buffer_0_7_16_fu_1618.read());
}
void a0_bin_conv::thread_sel_tmp391_fu_23861_p3() {
sel_tmp391_fu_23861_p3 = (!tmp_148_reg_50586.read()[0].is_01())? sc_lv<2>(): ((tmp_148_reg_50586.read()[0].to_bool())? old_word_buffer_0_2_17_fu_1442.read(): sel_tmp390_fu_23854_p3.read());
}
void a0_bin_conv::thread_sel_tmp392_fu_23868_p3() {
sel_tmp392_fu_23868_p3 = (!tmp_149_reg_50600.read()[0].is_01())? sc_lv<2>(): ((tmp_149_reg_50600.read()[0].to_bool())? old_word_buffer_0_3_17_fu_1478.read(): sel_tmp391_fu_23861_p3.read());
}
void a0_bin_conv::thread_sel_tmp393_fu_23875_p3() {
sel_tmp393_fu_23875_p3 = (!tmp_150_reg_50614.read()[0].is_01())? sc_lv<2>(): ((tmp_150_reg_50614.read()[0].to_bool())? old_word_buffer_0_4_17_fu_1510.read(): sel_tmp392_fu_23868_p3.read());
}
void a0_bin_conv::thread_sel_tmp394_fu_23882_p3() {
sel_tmp394_fu_23882_p3 = (!tmp_151_reg_50628.read()[0].is_01())? sc_lv<2>(): ((tmp_151_reg_50628.read()[0].to_bool())? old_word_buffer_0_5_17_fu_1546.read(): sel_tmp393_fu_23875_p3.read());
}
void a0_bin_conv::thread_sel_tmp395_fu_27833_p2() {
sel_tmp395_fu_27833_p2 = (tmp_1225_reg_45756.read() & first_wrd_not_fu_27828_p2.read());
}
void a0_bin_conv::thread_sel_tmp396_fu_27838_p2() {
sel_tmp396_fu_27838_p2 = (tmp_148_reg_50586.read() & sel_tmp395_fu_27833_p2.read());
}
void a0_bin_conv::thread_sel_tmp397_fu_27843_p3() {
sel_tmp397_fu_27843_p3 = (!sel_tmp396_fu_27838_p2.read()[0].is_01())? sc_lv<2>(): ((sel_tmp396_fu_27838_p2.read()[0].to_bool())? old_word_buffer_0_2_fu_666.read(): old_word_buffer_0_7_fu_686.read());
}
void a0_bin_conv::thread_sel_tmp398_fu_27851_p2() {
sel_tmp398_fu_27851_p2 = (tmp_149_reg_50600.read() & sel_tmp395_fu_27833_p2.read());
}
void a0_bin_conv::thread_sel_tmp399_fu_27856_p3() {
sel_tmp399_fu_27856_p3 = (!sel_tmp398_fu_27851_p2.read()[0].is_01())? sc_lv<2>(): ((sel_tmp398_fu_27851_p2.read()[0].to_bool())? old_word_buffer_0_3_fu_670.read(): sel_tmp397_fu_27843_p3.read());
}
void a0_bin_conv::thread_sel_tmp400_fu_27864_p2() {
sel_tmp400_fu_27864_p2 = (tmp_150_reg_50614.read() & sel_tmp395_fu_27833_p2.read());
}
void a0_bin_conv::thread_sel_tmp401_fu_27869_p3() {
sel_tmp401_fu_27869_p3 = (!sel_tmp400_fu_27864_p2.read()[0].is_01())? sc_lv<2>(): ((sel_tmp400_fu_27864_p2.read()[0].to_bool())? old_word_buffer_0_4_fu_674.read(): sel_tmp399_fu_27856_p3.read());
}
void a0_bin_conv::thread_sel_tmp402_fu_27877_p2() {
sel_tmp402_fu_27877_p2 = (tmp_151_reg_50628.read() & sel_tmp395_fu_27833_p2.read());
}
void a0_bin_conv::thread_sel_tmp403_fu_27882_p3() {
sel_tmp403_fu_27882_p3 = (!sel_tmp402_fu_27877_p2.read()[0].is_01())? sc_lv<2>(): ((sel_tmp402_fu_27877_p2.read()[0].to_bool())? old_word_buffer_0_5_fu_678.read(): sel_tmp401_fu_27869_p3.read());
}
void a0_bin_conv::thread_sel_tmp404_fu_33564_p2() {
sel_tmp404_fu_33564_p2 = (tmp_152_reg_50642.read() & sel_tmp395_reg_56184.read());
}
void a0_bin_conv::thread_sel_tmp405_fu_33568_p3() {
sel_tmp405_fu_33568_p3 = (!sel_tmp404_fu_33564_p2.read()[0].is_01())? sc_lv<2>(): ((sel_tmp404_fu_33564_p2.read()[0].to_bool())? old_word_buffer_0_6_54_reg_56179.read(): sel_tmp403_reg_56190.read());
}
void a0_bin_conv::thread_sel_tmp406_fu_33574_p2() {
sel_tmp406_fu_33574_p2 = (tmp_143_reg_50572.read() & sel_tmp395_reg_56184.read());
}
void a0_bin_conv::thread_sel_tmp407_fu_33578_p3() {
sel_tmp407_fu_33578_p3 = (!sel_tmp406_fu_33574_p2.read()[0].is_01())? sc_lv<2>(): ((sel_tmp406_fu_33574_p2.read()[0].to_bool())? old_word_buffer_0_1_fu_662.read(): sel_tmp405_fu_33568_p3.read());
}
void a0_bin_conv::thread_sel_tmp408_fu_27905_p3() {
sel_tmp408_fu_27905_p3 = (!tmp_153_reg_50656.read()[0].is_01())? sc_lv<2>(): ((tmp_153_reg_50656.read()[0].to_bool())? old_word_buffer_0_2_11_fu_1418.read(): old_word_buffer_0_7_10_fu_1594.read());
}
void a0_bin_conv::thread_sel_tmp409_fu_27912_p3() {
sel_tmp409_fu_27912_p3 = (!tmp_154_reg_50670.read()[0].is_01())? sc_lv<2>(): ((tmp_154_reg_50670.read()[0].to_bool())? old_word_buffer_0_3_11_fu_1454.read(): sel_tmp408_fu_27905_p3.read());
}
void a0_bin_conv::thread_sel_tmp410_fu_27919_p3() {
sel_tmp410_fu_27919_p3 = (!tmp_155_reg_50684.read()[0].is_01())? sc_lv<2>(): ((tmp_155_reg_50684.read()[0].to_bool())? old_word_buffer_0_4_12_fu_1490.read(): sel_tmp409_fu_27912_p3.read());
}
void a0_bin_conv::thread_sel_tmp411_fu_27926_p3() {
sel_tmp411_fu_27926_p3 = (!tmp_156_reg_50698.read()[0].is_01())? sc_lv<2>(): ((tmp_156_reg_50698.read()[0].to_bool())? old_word_buffer_0_5_11_fu_1522.read(): sel_tmp410_fu_27919_p3.read());
}
void a0_bin_conv::thread_sel_tmp412_fu_27955_p3() {
sel_tmp412_fu_27955_p3 = (!tmp_153_reg_50656.read()[0].is_01())? sc_lv<2>(): ((tmp_153_reg_50656.read()[0].to_bool())? old_word_buffer_0_2_13_fu_1426.read(): old_word_buffer_0_7_12_fu_1602.read());
}
void a0_bin_conv::thread_sel_tmp413_fu_27962_p3() {
sel_tmp413_fu_27962_p3 = (!tmp_154_reg_50670.read()[0].is_01())? sc_lv<2>(): ((tmp_154_reg_50670.read()[0].to_bool())? old_word_buffer_0_3_13_fu_1462.read(): sel_tmp412_fu_27955_p3.read());
}
void a0_bin_conv::thread_sel_tmp414_fu_27969_p3() {
sel_tmp414_fu_27969_p3 = (!tmp_155_reg_50684.read()[0].is_01())? sc_lv<2>(): ((tmp_155_reg_50684.read()[0].to_bool())? old_word_buffer_0_4_14_fu_1498.read(): sel_tmp413_fu_27962_p3.read());
}
void a0_bin_conv::thread_sel_tmp415_fu_27976_p3() {
sel_tmp415_fu_27976_p3 = (!tmp_156_reg_50698.read()[0].is_01())? sc_lv<2>(): ((tmp_156_reg_50698.read()[0].to_bool())? old_word_buffer_0_5_13_fu_1530.read(): sel_tmp414_fu_27969_p3.read());
}
void a0_bin_conv::thread_sel_tmp416_fu_28005_p3() {
sel_tmp416_fu_28005_p3 = (!tmp_153_reg_50656.read()[0].is_01())? sc_lv<2>(): ((tmp_153_reg_50656.read()[0].to_bool())? old_word_buffer_0_2_15_fu_1434.read(): old_word_buffer_0_7_14_fu_1610.read());
}
void a0_bin_conv::thread_sel_tmp417_fu_28012_p3() {
sel_tmp417_fu_28012_p3 = (!tmp_154_reg_50670.read()[0].is_01())? sc_lv<2>(): ((tmp_154_reg_50670.read()[0].to_bool())? old_word_buffer_0_3_15_fu_1470.read(): sel_tmp416_fu_28005_p3.read());
}
void a0_bin_conv::thread_sel_tmp418_fu_28019_p3() {
sel_tmp418_fu_28019_p3 = (!tmp_155_reg_50684.read()[0].is_01())? sc_lv<2>(): ((tmp_155_reg_50684.read()[0].to_bool())? old_word_buffer_0_4_16_fu_1506.read(): sel_tmp417_fu_28012_p3.read());
}
void a0_bin_conv::thread_sel_tmp419_fu_28026_p3() {
sel_tmp419_fu_28026_p3 = (!tmp_156_reg_50698.read()[0].is_01())? sc_lv<2>(): ((tmp_156_reg_50698.read()[0].to_bool())? old_word_buffer_0_5_15_fu_1538.read(): sel_tmp418_fu_28019_p3.read());
}
void a0_bin_conv::thread_sel_tmp420_fu_23911_p3() {
sel_tmp420_fu_23911_p3 = (!tmp_153_reg_50656.read()[0].is_01())? sc_lv<2>(): ((tmp_153_reg_50656.read()[0].to_bool())? old_word_buffer_0_2_17_fu_1442.read(): old_word_buffer_0_7_16_fu_1618.read());
}
void a0_bin_conv::thread_sel_tmp421_fu_23918_p3() {
sel_tmp421_fu_23918_p3 = (!tmp_154_reg_50670.read()[0].is_01())? sc_lv<2>(): ((tmp_154_reg_50670.read()[0].to_bool())? old_word_buffer_0_3_17_fu_1478.read(): sel_tmp420_fu_23911_p3.read());
}
void a0_bin_conv::thread_sel_tmp422_fu_23925_p3() {
sel_tmp422_fu_23925_p3 = (!tmp_155_reg_50684.read()[0].is_01())? sc_lv<2>(): ((tmp_155_reg_50684.read()[0].to_bool())? old_word_buffer_0_4_17_fu_1510.read(): sel_tmp421_fu_23918_p3.read());
}
void a0_bin_conv::thread_sel_tmp423_fu_23932_p3() {
sel_tmp423_fu_23932_p3 = (!tmp_156_reg_50698.read()[0].is_01())? sc_lv<2>(): ((tmp_156_reg_50698.read()[0].to_bool())? old_word_buffer_0_5_17_fu_1546.read(): sel_tmp422_fu_23925_p3.read());
}
void a0_bin_conv::thread_sel_tmp424_fu_23951_p2() {
sel_tmp424_fu_23951_p2 = (tmp_1227_reg_45800.read() & first_wrd_not1_fu_23946_p2.read());
}
void a0_bin_conv::thread_sel_tmp425_fu_28062_p2() {
sel_tmp425_fu_28062_p2 = (tmp_154_reg_50670.read() & sel_tmp424_reg_53680.read());
}
void a0_bin_conv::thread_sel_tmp426_fu_28066_p3() {
sel_tmp426_fu_28066_p3 = (!sel_tmp425_fu_28062_p2.read()[0].is_01())? sc_lv<2>(): ((sel_tmp425_fu_28062_p2.read()[0].to_bool())? old_word_buffer_0_3_fu_670.read(): old_word_buffer_0_7_fu_686.read());
}
void a0_bin_conv::thread_sel_tmp427_fu_28074_p2() {
sel_tmp427_fu_28074_p2 = (tmp_155_reg_50684.read() & sel_tmp424_reg_53680.read());
}
void a0_bin_conv::thread_sel_tmp428_fu_28078_p3() {
sel_tmp428_fu_28078_p3 = (!sel_tmp427_fu_28074_p2.read()[0].is_01())? sc_lv<2>(): ((sel_tmp427_fu_28074_p2.read()[0].to_bool())? old_word_buffer_0_4_fu_674.read(): sel_tmp426_fu_28066_p3.read());
}
void a0_bin_conv::thread_sel_tmp429_fu_28086_p2() {
sel_tmp429_fu_28086_p2 = (tmp_156_reg_50698.read() & sel_tmp424_reg_53680.read());
}
void a0_bin_conv::thread_sel_tmp430_fu_28090_p3() {
sel_tmp430_fu_28090_p3 = (!sel_tmp429_fu_28086_p2.read()[0].is_01())? sc_lv<2>(): ((sel_tmp429_fu_28086_p2.read()[0].to_bool())? old_word_buffer_0_5_fu_678.read(): sel_tmp428_fu_28078_p3.read());
}
void a0_bin_conv::thread_sel_tmp431_fu_28098_p2() {
sel_tmp431_fu_28098_p2 = (tmp_157_reg_50712.read() & sel_tmp424_reg_53680.read());
}
void a0_bin_conv::thread_sel_tmp432_fu_28102_p3() {
sel_tmp432_fu_28102_p3 = (!sel_tmp431_fu_28098_p2.read()[0].is_01())? sc_lv<2>(): ((sel_tmp431_fu_28098_p2.read()[0].to_bool())? old_word_buffer_0_6_fu_682.read(): sel_tmp430_fu_28090_p3.read());
}
void a0_bin_conv::thread_sel_tmp433_fu_28110_p2() {
sel_tmp433_fu_28110_p2 = (tmp_153_reg_50656.read() & sel_tmp424_reg_53680.read());
}
void a0_bin_conv::thread_sel_tmp434_fu_28114_p3() {
sel_tmp434_fu_28114_p3 = (!sel_tmp433_fu_28110_p2.read()[0].is_01())? sc_lv<2>(): ((sel_tmp433_fu_28110_p2.read()[0].to_bool())? old_word_buffer_0_2_fu_666.read(): sel_tmp432_fu_28102_p3.read());
}
void a0_bin_conv::thread_sel_tmp435_fu_33649_p3() {
sel_tmp435_fu_33649_p3 = (!sel_tmp95_reg_51373.read()[0].is_01())? sc_lv<2>(): ((sel_tmp95_reg_51373.read()[0].to_bool())? word_buffer_0_1_1_reg_55405.read(): word_buffer_0_2_1_reg_55342.read());
}
void a0_bin_conv::thread_sel_tmp436_fu_33660_p3() {
sel_tmp436_fu_33660_p3 = (!sel_tmp95_reg_51373.read()[0].is_01())? sc_lv<2>(): ((sel_tmp95_reg_51373.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_0_1_2_1_reg_53555.read(): ap_reg_pp0_iter2_word_buffer_0_2_2_1_reg_53444.read());
}
void a0_bin_conv::thread_sel_tmp437_fu_33671_p3() {
sel_tmp437_fu_33671_p3 = (!sel_tmp95_reg_51373.read()[0].is_01())? sc_lv<2>(): ((sel_tmp95_reg_51373.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_0_1_3_1_reg_53536.read(): ap_reg_pp0_iter2_word_buffer_0_2_3_1_reg_53427.read());
}
void a0_bin_conv::thread_sel_tmp438_fu_33682_p3() {
sel_tmp438_fu_33682_p3 = (!sel_tmp95_reg_51373.read()[0].is_01())? sc_lv<2>(): ((sel_tmp95_reg_51373.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_0_1_4_1_reg_53517.read(): ap_reg_pp0_iter2_word_buffer_0_2_4_1_reg_53410.read());
}
void a0_bin_conv::thread_sel_tmp439_fu_33693_p3() {
sel_tmp439_fu_33693_p3 = (!sel_tmp95_reg_51373.read()[0].is_01())? sc_lv<2>(): ((sel_tmp95_reg_51373.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_0_1_5_1_reg_53498.read(): ap_reg_pp0_iter2_word_buffer_0_2_5_1_reg_53393.read());
}
void a0_bin_conv::thread_sel_tmp440_fu_33704_p3() {
sel_tmp440_fu_33704_p3 = (!sel_tmp95_reg_51373.read()[0].is_01())? sc_lv<2>(): ((sel_tmp95_reg_51373.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_0_1_6_1_reg_53479.read(): ap_reg_pp0_iter2_word_buffer_0_2_6_1_reg_53376.read());
}
void a0_bin_conv::thread_sel_tmp441_fu_33715_p3() {
sel_tmp441_fu_33715_p3 = (!sel_tmp95_reg_51373.read()[0].is_01())? sc_lv<2>(): ((sel_tmp95_reg_51373.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_0_1_7_1_reg_53461.read(): ap_reg_pp0_iter2_word_buffer_0_2_7_1_reg_53360.read());
}
void a0_bin_conv::thread_sel_tmp442_fu_33726_p3() {
sel_tmp442_fu_33726_p3 = (!sel_tmp95_reg_51373.read()[0].is_01())? sc_lv<2>(): ((sel_tmp95_reg_51373.read()[0].to_bool())? word_buffer_0_2_0_1_reg_55388.read(): word_buffer_0_3_0_1_reg_55326.read());
}
void a0_bin_conv::thread_sel_tmp443_fu_33737_p3() {
sel_tmp443_fu_33737_p3 = (!tmp_173_reg_51413.read()[0].is_01())? sc_lv<2>(): ((tmp_173_reg_51413.read()[0].to_bool())? ap_const_lv2_0: word_buffer_0_2_0_reg_55355.read());
}
void a0_bin_conv::thread_sel_tmp444_fu_28142_p3() {
sel_tmp444_fu_28142_p3 = (!tmp_158_reg_50726.read()[0].is_01())? sc_lv<2>(): ((tmp_158_reg_50726.read()[0].to_bool())? old_word_buffer_0_3_11_fu_1454.read(): old_word_buffer_0_7_10_fu_1594.read());
}
void a0_bin_conv::thread_sel_tmp445_fu_28149_p3() {
sel_tmp445_fu_28149_p3 = (!tmp_159_reg_50740.read()[0].is_01())? sc_lv<2>(): ((tmp_159_reg_50740.read()[0].to_bool())? old_word_buffer_0_4_12_fu_1490.read(): sel_tmp444_fu_28142_p3.read());
}
void a0_bin_conv::thread_sel_tmp446_fu_28156_p3() {
sel_tmp446_fu_28156_p3 = (!tmp_160_reg_50754.read()[0].is_01())? sc_lv<2>(): ((tmp_160_reg_50754.read()[0].to_bool())? old_word_buffer_0_5_11_fu_1522.read(): sel_tmp445_fu_28149_p3.read());
}
void a0_bin_conv::thread_sel_tmp447_fu_28182_p3() {
sel_tmp447_fu_28182_p3 = (!tmp_158_reg_50726.read()[0].is_01())? sc_lv<2>(): ((tmp_158_reg_50726.read()[0].to_bool())? old_word_buffer_0_3_13_fu_1462.read(): old_word_buffer_0_7_12_fu_1602.read());
}
void a0_bin_conv::thread_sel_tmp448_fu_28189_p3() {
sel_tmp448_fu_28189_p3 = (!tmp_159_reg_50740.read()[0].is_01())? sc_lv<2>(): ((tmp_159_reg_50740.read()[0].to_bool())? old_word_buffer_0_4_14_fu_1498.read(): sel_tmp447_fu_28182_p3.read());
}
void a0_bin_conv::thread_sel_tmp449_fu_28196_p3() {
sel_tmp449_fu_28196_p3 = (!tmp_160_reg_50754.read()[0].is_01())? sc_lv<2>(): ((tmp_160_reg_50754.read()[0].to_bool())? old_word_buffer_0_5_13_fu_1530.read(): sel_tmp448_fu_28189_p3.read());
}
void a0_bin_conv::thread_sel_tmp450_fu_28222_p3() {
sel_tmp450_fu_28222_p3 = (!tmp_158_reg_50726.read()[0].is_01())? sc_lv<2>(): ((tmp_158_reg_50726.read()[0].to_bool())? old_word_buffer_0_3_15_fu_1470.read(): old_word_buffer_0_7_14_fu_1610.read());
}
void a0_bin_conv::thread_sel_tmp451_fu_28229_p3() {
sel_tmp451_fu_28229_p3 = (!tmp_159_reg_50740.read()[0].is_01())? sc_lv<2>(): ((tmp_159_reg_50740.read()[0].to_bool())? old_word_buffer_0_4_16_fu_1506.read(): sel_tmp450_fu_28222_p3.read());
}
void a0_bin_conv::thread_sel_tmp452_fu_28236_p3() {
sel_tmp452_fu_28236_p3 = (!tmp_160_reg_50754.read()[0].is_01())? sc_lv<2>(): ((tmp_160_reg_50754.read()[0].to_bool())? old_word_buffer_0_5_15_fu_1538.read(): sel_tmp451_fu_28229_p3.read());
}
void a0_bin_conv::thread_sel_tmp453_fu_23968_p3() {
sel_tmp453_fu_23968_p3 = (!tmp_158_reg_50726.read()[0].is_01())? sc_lv<2>(): ((tmp_158_reg_50726.read()[0].to_bool())? old_word_buffer_0_3_17_fu_1478.read(): old_word_buffer_0_7_16_fu_1618.read());
}
void a0_bin_conv::thread_sel_tmp454_fu_23975_p3() {
sel_tmp454_fu_23975_p3 = (!tmp_159_reg_50740.read()[0].is_01())? sc_lv<2>(): ((tmp_159_reg_50740.read()[0].to_bool())? old_word_buffer_0_4_17_fu_1510.read(): sel_tmp453_fu_23968_p3.read());
}
void a0_bin_conv::thread_sel_tmp455_fu_23982_p3() {
sel_tmp455_fu_23982_p3 = (!tmp_160_reg_50754.read()[0].is_01())? sc_lv<2>(): ((tmp_160_reg_50754.read()[0].to_bool())? old_word_buffer_0_5_17_fu_1546.read(): sel_tmp454_fu_23975_p3.read());
}
void a0_bin_conv::thread_sel_tmp456_fu_28265_p2() {
sel_tmp456_fu_28265_p2 = (brmerge18_reg_53698.read() ^ ap_const_lv1_1);
}
void a0_bin_conv::thread_sel_tmp457_fu_28270_p2() {
sel_tmp457_fu_28270_p2 = (tmp_159_reg_50740.read() & sel_tmp456_fu_28265_p2.read());
}
void a0_bin_conv::thread_sel_tmp458_fu_28275_p3() {
sel_tmp458_fu_28275_p3 = (!sel_tmp457_fu_28270_p2.read()[0].is_01())? sc_lv<2>(): ((sel_tmp457_fu_28270_p2.read()[0].to_bool())? old_word_buffer_0_4_fu_674.read(): old_word_buffer_0_7_fu_686.read());
}
void a0_bin_conv::thread_sel_tmp459_fu_28283_p2() {
sel_tmp459_fu_28283_p2 = (tmp_160_reg_50754.read() & sel_tmp456_fu_28265_p2.read());
}
void a0_bin_conv::thread_sel_tmp460_fu_28288_p3() {
sel_tmp460_fu_28288_p3 = (!sel_tmp459_fu_28283_p2.read()[0].is_01())? sc_lv<2>(): ((sel_tmp459_fu_28283_p2.read()[0].to_bool())? old_word_buffer_0_5_fu_678.read(): sel_tmp458_fu_28275_p3.read());
}
void a0_bin_conv::thread_sel_tmp461_fu_28296_p2() {
sel_tmp461_fu_28296_p2 = (tmp_161_reg_50768.read() & sel_tmp456_fu_28265_p2.read());
}
void a0_bin_conv::thread_sel_tmp462_fu_28301_p3() {
sel_tmp462_fu_28301_p3 = (!sel_tmp461_fu_28296_p2.read()[0].is_01())? sc_lv<2>(): ((sel_tmp461_fu_28296_p2.read()[0].to_bool())? old_word_buffer_0_6_fu_682.read(): sel_tmp460_fu_28288_p3.read());
}
void a0_bin_conv::thread_sel_tmp463_fu_28309_p2() {
sel_tmp463_fu_28309_p2 = (tmp_158_reg_50726.read() & sel_tmp456_fu_28265_p2.read());
}
void a0_bin_conv::thread_sel_tmp464_fu_28314_p3() {
sel_tmp464_fu_28314_p3 = (!sel_tmp463_fu_28309_p2.read()[0].is_01())? sc_lv<2>(): ((sel_tmp463_fu_28309_p2.read()[0].to_bool())? old_word_buffer_0_3_fu_670.read(): sel_tmp462_fu_28301_p3.read());
}
void a0_bin_conv::thread_sel_tmp465_fu_33753_p3() {
sel_tmp465_fu_33753_p3 = (!sel_tmp99_reg_51425.read()[0].is_01())? sc_lv<2>(): ((sel_tmp99_reg_51425.read()[0].to_bool())? word_buffer_0_1_1_reg_55405.read(): word_buffer_0_3_1_reg_55284.read());
}
void a0_bin_conv::thread_sel_tmp466_fu_33758_p3() {
sel_tmp466_fu_33758_p3 = (!sel_tmp100_reg_51445.read()[0].is_01())? sc_lv<2>(): ((sel_tmp100_reg_51445.read()[0].to_bool())? word_buffer_0_2_1_reg_55342.read(): sel_tmp465_fu_33753_p3.read());
}
void a0_bin_conv::thread_sel_tmp467_fu_33770_p3() {
sel_tmp467_fu_33770_p3 = (!sel_tmp99_reg_51425.read()[0].is_01())? sc_lv<2>(): ((sel_tmp99_reg_51425.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_0_1_2_1_reg_53555.read(): ap_reg_pp0_iter2_word_buffer_0_3_2_1_reg_53345.read());
}
void a0_bin_conv::thread_sel_tmp468_fu_33775_p3() {
sel_tmp468_fu_33775_p3 = (!sel_tmp100_reg_51445.read()[0].is_01())? sc_lv<2>(): ((sel_tmp100_reg_51445.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_0_2_2_1_reg_53444.read(): sel_tmp467_fu_33770_p3.read());
}
void a0_bin_conv::thread_sel_tmp469_fu_33787_p3() {
sel_tmp469_fu_33787_p3 = (!sel_tmp99_reg_51425.read()[0].is_01())? sc_lv<2>(): ((sel_tmp99_reg_51425.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_0_1_3_1_reg_53536.read(): ap_reg_pp0_iter2_word_buffer_0_3_3_1_reg_53330.read());
}
void a0_bin_conv::thread_sel_tmp470_fu_33792_p3() {
sel_tmp470_fu_33792_p3 = (!sel_tmp100_reg_51445.read()[0].is_01())? sc_lv<2>(): ((sel_tmp100_reg_51445.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_0_2_3_1_reg_53427.read(): sel_tmp469_fu_33787_p3.read());
}
void a0_bin_conv::thread_sel_tmp471_fu_33804_p3() {
sel_tmp471_fu_33804_p3 = (!sel_tmp99_reg_51425.read()[0].is_01())? sc_lv<2>(): ((sel_tmp99_reg_51425.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_0_1_4_1_reg_53517.read(): ap_reg_pp0_iter2_word_buffer_0_3_4_1_reg_53315.read());
}
void a0_bin_conv::thread_sel_tmp472_fu_33809_p3() {
sel_tmp472_fu_33809_p3 = (!sel_tmp100_reg_51445.read()[0].is_01())? sc_lv<2>(): ((sel_tmp100_reg_51445.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_0_2_4_1_reg_53410.read(): sel_tmp471_fu_33804_p3.read());
}
void a0_bin_conv::thread_sel_tmp473_fu_33821_p3() {
sel_tmp473_fu_33821_p3 = (!sel_tmp99_reg_51425.read()[0].is_01())? sc_lv<2>(): ((sel_tmp99_reg_51425.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_0_1_5_1_reg_53498.read(): ap_reg_pp0_iter2_word_buffer_0_3_5_1_reg_53300.read());
}
void a0_bin_conv::thread_sel_tmp474_fu_33826_p3() {
sel_tmp474_fu_33826_p3 = (!sel_tmp100_reg_51445.read()[0].is_01())? sc_lv<2>(): ((sel_tmp100_reg_51445.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_0_2_5_1_reg_53393.read(): sel_tmp473_fu_33821_p3.read());
}
void a0_bin_conv::thread_sel_tmp475_fu_33838_p3() {
sel_tmp475_fu_33838_p3 = (!sel_tmp99_reg_51425.read()[0].is_01())? sc_lv<2>(): ((sel_tmp99_reg_51425.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_0_1_6_1_reg_53479.read(): ap_reg_pp0_iter2_word_buffer_0_3_6_1_reg_53285.read());
}
void a0_bin_conv::thread_sel_tmp476_fu_33843_p3() {
sel_tmp476_fu_33843_p3 = (!sel_tmp100_reg_51445.read()[0].is_01())? sc_lv<2>(): ((sel_tmp100_reg_51445.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_0_2_6_1_reg_53376.read(): sel_tmp475_fu_33838_p3.read());
}
void a0_bin_conv::thread_sel_tmp477_fu_33855_p3() {
sel_tmp477_fu_33855_p3 = (!sel_tmp99_reg_51425.read()[0].is_01())? sc_lv<2>(): ((sel_tmp99_reg_51425.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_0_1_7_1_reg_53461.read(): ap_reg_pp0_iter2_word_buffer_0_3_7_1_reg_53271.read());
}
void a0_bin_conv::thread_sel_tmp478_fu_33860_p3() {
sel_tmp478_fu_33860_p3 = (!sel_tmp100_reg_51445.read()[0].is_01())? sc_lv<2>(): ((sel_tmp100_reg_51445.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_0_2_7_1_reg_53360.read(): sel_tmp477_fu_33855_p3.read());
}
void a0_bin_conv::thread_sel_tmp479_fu_33872_p3() {
sel_tmp479_fu_33872_p3 = (!sel_tmp99_reg_51425.read()[0].is_01())? sc_lv<2>(): ((sel_tmp99_reg_51425.read()[0].to_bool())? word_buffer_0_2_0_1_reg_55388.read(): word_buffer_0_4_0_1_reg_55270.read());
}
void a0_bin_conv::thread_sel_tmp480_fu_33877_p3() {
sel_tmp480_fu_33877_p3 = (!sel_tmp100_reg_51445.read()[0].is_01())? sc_lv<2>(): ((sel_tmp100_reg_51445.read()[0].to_bool())? word_buffer_0_3_0_1_reg_55326.read(): sel_tmp479_fu_33872_p3.read());
}
void a0_bin_conv::thread_sel_tmp481_fu_33889_p3() {
sel_tmp481_fu_33889_p3 = (!tmp_174_reg_51465.read()[0].is_01())? sc_lv<2>(): ((tmp_174_reg_51465.read()[0].to_bool())? ap_const_lv2_0: word_buffer_0_3_0_reg_55296.read());
}
void a0_bin_conv::thread_sel_tmp482_fu_33895_p3() {
sel_tmp482_fu_33895_p3 = (!sel_tmp102_reg_51471.read()[0].is_01())? sc_lv<2>(): ((sel_tmp102_reg_51471.read()[0].to_bool())? word_buffer_0_1_0_reg_55417.read(): sel_tmp481_fu_33889_p3.read());
}
void a0_bin_conv::thread_sel_tmp483_fu_28338_p3() {
sel_tmp483_fu_28338_p3 = (!tmp_162_reg_50782.read()[0].is_01())? sc_lv<2>(): ((tmp_162_reg_50782.read()[0].to_bool())? old_word_buffer_0_4_12_fu_1490.read(): old_word_buffer_0_7_10_fu_1594.read());
}
void a0_bin_conv::thread_sel_tmp484_fu_28345_p3() {
sel_tmp484_fu_28345_p3 = (!tmp_163_reg_50796.read()[0].is_01())? sc_lv<2>(): ((tmp_163_reg_50796.read()[0].to_bool())? old_word_buffer_0_5_11_fu_1522.read(): sel_tmp483_fu_28338_p3.read());
}
void a0_bin_conv::thread_sel_tmp485_fu_28368_p3() {
sel_tmp485_fu_28368_p3 = (!tmp_162_reg_50782.read()[0].is_01())? sc_lv<2>(): ((tmp_162_reg_50782.read()[0].to_bool())? old_word_buffer_0_4_14_fu_1498.read(): old_word_buffer_0_7_12_fu_1602.read());
}
void a0_bin_conv::thread_sel_tmp486_fu_28375_p3() {
sel_tmp486_fu_28375_p3 = (!tmp_163_reg_50796.read()[0].is_01())? sc_lv<2>(): ((tmp_163_reg_50796.read()[0].to_bool())? old_word_buffer_0_5_13_fu_1530.read(): sel_tmp485_fu_28368_p3.read());
}
void a0_bin_conv::thread_sel_tmp487_fu_28398_p3() {
sel_tmp487_fu_28398_p3 = (!tmp_162_reg_50782.read()[0].is_01())? sc_lv<2>(): ((tmp_162_reg_50782.read()[0].to_bool())? old_word_buffer_0_4_16_fu_1506.read(): old_word_buffer_0_7_14_fu_1610.read());
}
void a0_bin_conv::thread_sel_tmp488_fu_28405_p3() {
sel_tmp488_fu_28405_p3 = (!tmp_163_reg_50796.read()[0].is_01())? sc_lv<2>(): ((tmp_163_reg_50796.read()[0].to_bool())? old_word_buffer_0_5_15_fu_1538.read(): sel_tmp487_fu_28398_p3.read());
}
void a0_bin_conv::thread_sel_tmp489_fu_24009_p3() {
sel_tmp489_fu_24009_p3 = (!tmp_162_reg_50782.read()[0].is_01())? sc_lv<2>(): ((tmp_162_reg_50782.read()[0].to_bool())? old_word_buffer_0_4_17_fu_1510.read(): old_word_buffer_0_7_16_fu_1618.read());
}
void a0_bin_conv::thread_sel_tmp490_fu_24016_p3() {
sel_tmp490_fu_24016_p3 = (!tmp_163_reg_50796.read()[0].is_01())? sc_lv<2>(): ((tmp_163_reg_50796.read()[0].to_bool())? old_word_buffer_0_5_17_fu_1546.read(): sel_tmp489_fu_24009_p3.read());
}
void a0_bin_conv::thread_sel_tmp491_fu_28435_p2() {
sel_tmp491_fu_28435_p2 = (brmerge20_fu_28431_p2.read() ^ ap_const_lv1_1);
}
void a0_bin_conv::thread_sel_tmp492_fu_28441_p2() {
sel_tmp492_fu_28441_p2 = (tmp_163_reg_50796.read() & sel_tmp491_fu_28435_p2.read());
}
void a0_bin_conv::thread_sel_tmp493_fu_28446_p3() {
sel_tmp493_fu_28446_p3 = (!sel_tmp492_fu_28441_p2.read()[0].is_01())? sc_lv<2>(): ((sel_tmp492_fu_28441_p2.read()[0].to_bool())? old_word_buffer_0_5_fu_678.read(): old_word_buffer_0_7_fu_686.read());
}
void a0_bin_conv::thread_sel_tmp494_fu_28454_p2() {
sel_tmp494_fu_28454_p2 = (tmp_164_reg_50810.read() & sel_tmp491_fu_28435_p2.read());
}
void a0_bin_conv::thread_sel_tmp495_fu_28459_p3() {
sel_tmp495_fu_28459_p3 = (!sel_tmp494_fu_28454_p2.read()[0].is_01())? sc_lv<2>(): ((sel_tmp494_fu_28454_p2.read()[0].to_bool())? old_word_buffer_0_6_fu_682.read(): sel_tmp493_fu_28446_p3.read());
}
void a0_bin_conv::thread_sel_tmp496_fu_28467_p2() {
sel_tmp496_fu_28467_p2 = (tmp_162_reg_50782.read() & sel_tmp491_fu_28435_p2.read());
}
void a0_bin_conv::thread_sel_tmp497_fu_28472_p3() {
sel_tmp497_fu_28472_p3 = (!sel_tmp496_fu_28467_p2.read()[0].is_01())? sc_lv<2>(): ((sel_tmp496_fu_28467_p2.read()[0].to_bool())? old_word_buffer_0_4_fu_674.read(): sel_tmp495_fu_28459_p3.read());
}
void a0_bin_conv::thread_sel_tmp498_fu_33911_p3() {
sel_tmp498_fu_33911_p3 = (!sel_tmp104_reg_51483.read()[0].is_01())? sc_lv<2>(): ((sel_tmp104_reg_51483.read()[0].to_bool())? word_buffer_0_1_1_reg_55405.read(): word_buffer_0_4_1_reg_55233.read());
}
void a0_bin_conv::thread_sel_tmp499_fu_33916_p3() {
sel_tmp499_fu_33916_p3 = (!sel_tmp105_reg_51503.read()[0].is_01())? sc_lv<2>(): ((sel_tmp105_reg_51503.read()[0].to_bool())? word_buffer_0_2_1_reg_55342.read(): sel_tmp498_fu_33911_p3.read());
}
void a0_bin_conv::thread_sel_tmp500_fu_33922_p3() {
sel_tmp500_fu_33922_p3 = (!sel_tmp106_reg_51523.read()[0].is_01())? sc_lv<2>(): ((sel_tmp106_reg_51523.read()[0].to_bool())? word_buffer_0_3_1_reg_55284.read(): sel_tmp499_fu_33916_p3.read());
}
void a0_bin_conv::thread_sel_tmp501_fu_33934_p3() {
sel_tmp501_fu_33934_p3 = (!sel_tmp104_reg_51483.read()[0].is_01())? sc_lv<2>(): ((sel_tmp104_reg_51483.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_0_1_2_1_reg_53555.read(): ap_reg_pp0_iter2_word_buffer_0_4_2_1_reg_53258.read());
}
void a0_bin_conv::thread_sel_tmp502_fu_33939_p3() {
sel_tmp502_fu_33939_p3 = (!sel_tmp105_reg_51503.read()[0].is_01())? sc_lv<2>(): ((sel_tmp105_reg_51503.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_0_2_2_1_reg_53444.read(): sel_tmp501_fu_33934_p3.read());
}
void a0_bin_conv::thread_sel_tmp503_fu_33945_p3() {
sel_tmp503_fu_33945_p3 = (!sel_tmp106_reg_51523.read()[0].is_01())? sc_lv<2>(): ((sel_tmp106_reg_51523.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_0_3_2_1_reg_53345.read(): sel_tmp502_fu_33939_p3.read());
}
void a0_bin_conv::thread_sel_tmp504_fu_33957_p3() {
sel_tmp504_fu_33957_p3 = (!sel_tmp104_reg_51483.read()[0].is_01())? sc_lv<2>(): ((sel_tmp104_reg_51483.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_0_1_3_1_reg_53536.read(): ap_reg_pp0_iter2_word_buffer_0_4_3_1_reg_53245.read());
}
void a0_bin_conv::thread_sel_tmp505_fu_33962_p3() {
sel_tmp505_fu_33962_p3 = (!sel_tmp105_reg_51503.read()[0].is_01())? sc_lv<2>(): ((sel_tmp105_reg_51503.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_0_2_3_1_reg_53427.read(): sel_tmp504_fu_33957_p3.read());
}
void a0_bin_conv::thread_sel_tmp506_fu_33968_p3() {
sel_tmp506_fu_33968_p3 = (!sel_tmp106_reg_51523.read()[0].is_01())? sc_lv<2>(): ((sel_tmp106_reg_51523.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_0_3_3_1_reg_53330.read(): sel_tmp505_fu_33962_p3.read());
}
void a0_bin_conv::thread_sel_tmp507_fu_33980_p3() {
sel_tmp507_fu_33980_p3 = (!sel_tmp104_reg_51483.read()[0].is_01())? sc_lv<2>(): ((sel_tmp104_reg_51483.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_0_1_4_1_reg_53517.read(): ap_reg_pp0_iter2_word_buffer_0_4_4_1_reg_53232.read());
}
void a0_bin_conv::thread_sel_tmp508_fu_33985_p3() {
sel_tmp508_fu_33985_p3 = (!sel_tmp105_reg_51503.read()[0].is_01())? sc_lv<2>(): ((sel_tmp105_reg_51503.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_0_2_4_1_reg_53410.read(): sel_tmp507_fu_33980_p3.read());
}
void a0_bin_conv::thread_sel_tmp509_fu_33991_p3() {
sel_tmp509_fu_33991_p3 = (!sel_tmp106_reg_51523.read()[0].is_01())? sc_lv<2>(): ((sel_tmp106_reg_51523.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_0_3_4_1_reg_53315.read(): sel_tmp508_fu_33985_p3.read());
}
void a0_bin_conv::thread_sel_tmp510_fu_34003_p3() {
sel_tmp510_fu_34003_p3 = (!sel_tmp104_reg_51483.read()[0].is_01())? sc_lv<2>(): ((sel_tmp104_reg_51483.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_0_1_5_1_reg_53498.read(): ap_reg_pp0_iter2_word_buffer_0_4_5_1_reg_53219.read());
}
void a0_bin_conv::thread_sel_tmp511_fu_34008_p3() {
sel_tmp511_fu_34008_p3 = (!sel_tmp105_reg_51503.read()[0].is_01())? sc_lv<2>(): ((sel_tmp105_reg_51503.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_0_2_5_1_reg_53393.read(): sel_tmp510_fu_34003_p3.read());
}
void a0_bin_conv::thread_sel_tmp512_fu_34014_p3() {
sel_tmp512_fu_34014_p3 = (!sel_tmp106_reg_51523.read()[0].is_01())? sc_lv<2>(): ((sel_tmp106_reg_51523.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_0_3_5_1_reg_53300.read(): sel_tmp511_fu_34008_p3.read());
}
void a0_bin_conv::thread_sel_tmp513_fu_34026_p3() {
sel_tmp513_fu_34026_p3 = (!sel_tmp104_reg_51483.read()[0].is_01())? sc_lv<2>(): ((sel_tmp104_reg_51483.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_0_1_6_1_reg_53479.read(): ap_reg_pp0_iter2_word_buffer_0_4_6_1_reg_53206.read());
}
void a0_bin_conv::thread_sel_tmp514_fu_34031_p3() {
sel_tmp514_fu_34031_p3 = (!sel_tmp105_reg_51503.read()[0].is_01())? sc_lv<2>(): ((sel_tmp105_reg_51503.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_0_2_6_1_reg_53376.read(): sel_tmp513_fu_34026_p3.read());
}
void a0_bin_conv::thread_sel_tmp515_fu_34037_p3() {
sel_tmp515_fu_34037_p3 = (!sel_tmp106_reg_51523.read()[0].is_01())? sc_lv<2>(): ((sel_tmp106_reg_51523.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_0_3_6_1_reg_53285.read(): sel_tmp514_fu_34031_p3.read());
}
void a0_bin_conv::thread_sel_tmp516_fu_34049_p3() {
sel_tmp516_fu_34049_p3 = (!sel_tmp104_reg_51483.read()[0].is_01())? sc_lv<2>(): ((sel_tmp104_reg_51483.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_0_1_7_1_reg_53461.read(): ap_reg_pp0_iter2_word_buffer_0_4_7_1_reg_53194.read());
}
void a0_bin_conv::thread_sel_tmp517_fu_34054_p3() {
sel_tmp517_fu_34054_p3 = (!sel_tmp105_reg_51503.read()[0].is_01())? sc_lv<2>(): ((sel_tmp105_reg_51503.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_0_2_7_1_reg_53360.read(): sel_tmp516_fu_34049_p3.read());
}
void a0_bin_conv::thread_sel_tmp518_fu_34060_p3() {
sel_tmp518_fu_34060_p3 = (!sel_tmp106_reg_51523.read()[0].is_01())? sc_lv<2>(): ((sel_tmp106_reg_51523.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_0_3_7_1_reg_53271.read(): sel_tmp517_fu_34054_p3.read());
}
void a0_bin_conv::thread_sel_tmp519_fu_34072_p3() {
sel_tmp519_fu_34072_p3 = (!sel_tmp104_reg_51483.read()[0].is_01())? sc_lv<2>(): ((sel_tmp104_reg_51483.read()[0].to_bool())? word_buffer_0_2_0_1_reg_55388.read(): word_buffer_0_5_0_1_reg_55221.read());
}
void a0_bin_conv::thread_sel_tmp520_fu_34077_p3() {
sel_tmp520_fu_34077_p3 = (!sel_tmp105_reg_51503.read()[0].is_01())? sc_lv<2>(): ((sel_tmp105_reg_51503.read()[0].to_bool())? word_buffer_0_3_0_1_reg_55326.read(): sel_tmp519_fu_34072_p3.read());
}
void a0_bin_conv::thread_sel_tmp521_fu_34083_p3() {
sel_tmp521_fu_34083_p3 = (!sel_tmp106_reg_51523.read()[0].is_01())? sc_lv<2>(): ((sel_tmp106_reg_51523.read()[0].to_bool())? word_buffer_0_4_0_1_reg_55270.read(): sel_tmp520_fu_34077_p3.read());
}
void a0_bin_conv::thread_sel_tmp522_fu_34095_p3() {
sel_tmp522_fu_34095_p3 = (!tmp_175_reg_51563.read()[0].is_01())? sc_lv<2>(): ((tmp_175_reg_51563.read()[0].to_bool())? ap_const_lv2_0: word_buffer_0_4_0_reg_55244.read());
}
void a0_bin_conv::thread_sel_tmp523_fu_34101_p3() {
sel_tmp523_fu_34101_p3 = (!sel_tmp110_reg_51569.read()[0].is_01())? sc_lv<2>(): ((sel_tmp110_reg_51569.read()[0].to_bool())? word_buffer_0_1_0_reg_55417.read(): sel_tmp522_fu_34095_p3.read());
}
void a0_bin_conv::thread_sel_tmp524_fu_34107_p3() {
sel_tmp524_fu_34107_p3 = (!sel_tmp111_reg_51575.read()[0].is_01())? sc_lv<2>(): ((sel_tmp111_reg_51575.read()[0].to_bool())? word_buffer_0_2_0_reg_55355.read(): sel_tmp523_fu_34101_p3.read());
}
void a0_bin_conv::thread_sel_tmp525_fu_28494_p3() {
sel_tmp525_fu_28494_p3 = (!tmp_165_reg_50824.read()[0].is_01())? sc_lv<2>(): ((tmp_165_reg_50824.read()[0].to_bool())? old_word_buffer_0_5_11_fu_1522.read(): old_word_buffer_0_7_10_fu_1594.read());
}
void a0_bin_conv::thread_sel_tmp526_fu_28514_p3() {
sel_tmp526_fu_28514_p3 = (!tmp_165_reg_50824.read()[0].is_01())? sc_lv<2>(): ((tmp_165_reg_50824.read()[0].to_bool())? old_word_buffer_0_5_13_fu_1530.read(): old_word_buffer_0_7_12_fu_1602.read());
}
void a0_bin_conv::thread_sel_tmp527_fu_28534_p3() {
sel_tmp527_fu_28534_p3 = (!tmp_165_reg_50824.read()[0].is_01())? sc_lv<2>(): ((tmp_165_reg_50824.read()[0].to_bool())? old_word_buffer_0_5_15_fu_1538.read(): old_word_buffer_0_7_14_fu_1610.read());
}
void a0_bin_conv::thread_sel_tmp528_fu_24036_p3() {
sel_tmp528_fu_24036_p3 = (!tmp_165_reg_50824.read()[0].is_01())? sc_lv<2>(): ((tmp_165_reg_50824.read()[0].to_bool())? old_word_buffer_0_5_17_fu_1546.read(): old_word_buffer_0_7_16_fu_1618.read());
}
void a0_bin_conv::thread_sel_tmp529_fu_28561_p2() {
sel_tmp529_fu_28561_p2 = (brmerge22_fu_28557_p2.read() ^ ap_const_lv1_1);
}
void a0_bin_conv::thread_sel_tmp530_fu_28567_p2() {
sel_tmp530_fu_28567_p2 = (tmp_166_reg_50838.read() & sel_tmp529_fu_28561_p2.read());
}
void a0_bin_conv::thread_sel_tmp531_fu_28572_p3() {
sel_tmp531_fu_28572_p3 = (!sel_tmp530_fu_28567_p2.read()[0].is_01())? sc_lv<2>(): ((sel_tmp530_fu_28567_p2.read()[0].to_bool())? old_word_buffer_0_6_fu_682.read(): old_word_buffer_0_7_fu_686.read());
}
void a0_bin_conv::thread_sel_tmp532_fu_28580_p2() {
sel_tmp532_fu_28580_p2 = (tmp_165_reg_50824.read() & sel_tmp529_fu_28561_p2.read());
}
void a0_bin_conv::thread_sel_tmp533_fu_28585_p3() {
sel_tmp533_fu_28585_p3 = (!sel_tmp532_fu_28580_p2.read()[0].is_01())? sc_lv<2>(): ((sel_tmp532_fu_28580_p2.read()[0].to_bool())? old_word_buffer_0_5_fu_678.read(): sel_tmp531_fu_28572_p3.read());
}
void a0_bin_conv::thread_sel_tmp534_fu_34123_p3() {
sel_tmp534_fu_34123_p3 = (!sel_tmp113_reg_51587.read()[0].is_01())? sc_lv<2>(): ((sel_tmp113_reg_51587.read()[0].to_bool())? word_buffer_0_1_1_reg_55405.read(): word_buffer_0_5_1_reg_55191.read());
}
void a0_bin_conv::thread_sel_tmp535_fu_34128_p3() {
sel_tmp535_fu_34128_p3 = (!sel_tmp114_reg_51607.read()[0].is_01())? sc_lv<2>(): ((sel_tmp114_reg_51607.read()[0].to_bool())? word_buffer_0_2_1_reg_55342.read(): sel_tmp534_fu_34123_p3.read());
}
void a0_bin_conv::thread_sel_tmp536_fu_34134_p3() {
sel_tmp536_fu_34134_p3 = (!sel_tmp115_reg_51627.read()[0].is_01())? sc_lv<2>(): ((sel_tmp115_reg_51627.read()[0].to_bool())? word_buffer_0_3_1_reg_55284.read(): sel_tmp535_fu_34128_p3.read());
}
void a0_bin_conv::thread_sel_tmp537_fu_34140_p3() {
sel_tmp537_fu_34140_p3 = (!sel_tmp116_reg_51647.read()[0].is_01())? sc_lv<2>(): ((sel_tmp116_reg_51647.read()[0].to_bool())? word_buffer_0_4_1_reg_55233.read(): sel_tmp536_fu_34134_p3.read());
}
void a0_bin_conv::thread_sel_tmp538_fu_34152_p3() {
sel_tmp538_fu_34152_p3 = (!sel_tmp113_reg_51587.read()[0].is_01())? sc_lv<2>(): ((sel_tmp113_reg_51587.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_0_1_2_1_reg_53555.read(): ap_reg_pp0_iter2_word_buffer_0_5_2_1_reg_53183.read());
}
void a0_bin_conv::thread_sel_tmp539_fu_34157_p3() {
sel_tmp539_fu_34157_p3 = (!sel_tmp114_reg_51607.read()[0].is_01())? sc_lv<2>(): ((sel_tmp114_reg_51607.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_0_2_2_1_reg_53444.read(): sel_tmp538_fu_34152_p3.read());
}
void a0_bin_conv::thread_sel_tmp540_fu_34163_p3() {
sel_tmp540_fu_34163_p3 = (!sel_tmp115_reg_51627.read()[0].is_01())? sc_lv<2>(): ((sel_tmp115_reg_51627.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_0_3_2_1_reg_53345.read(): sel_tmp539_fu_34157_p3.read());
}
void a0_bin_conv::thread_sel_tmp541_fu_34169_p3() {
sel_tmp541_fu_34169_p3 = (!sel_tmp116_reg_51647.read()[0].is_01())? sc_lv<2>(): ((sel_tmp116_reg_51647.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_0_4_2_1_reg_53258.read(): sel_tmp540_fu_34163_p3.read());
}
void a0_bin_conv::thread_sel_tmp542_fu_34181_p3() {
sel_tmp542_fu_34181_p3 = (!sel_tmp113_reg_51587.read()[0].is_01())? sc_lv<2>(): ((sel_tmp113_reg_51587.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_0_1_3_1_reg_53536.read(): ap_reg_pp0_iter2_word_buffer_0_5_3_1_reg_53172.read());
}
void a0_bin_conv::thread_sel_tmp543_fu_34186_p3() {
sel_tmp543_fu_34186_p3 = (!sel_tmp114_reg_51607.read()[0].is_01())? sc_lv<2>(): ((sel_tmp114_reg_51607.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_0_2_3_1_reg_53427.read(): sel_tmp542_fu_34181_p3.read());
}
void a0_bin_conv::thread_sel_tmp544_fu_34192_p3() {
sel_tmp544_fu_34192_p3 = (!sel_tmp115_reg_51627.read()[0].is_01())? sc_lv<2>(): ((sel_tmp115_reg_51627.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_0_3_3_1_reg_53330.read(): sel_tmp543_fu_34186_p3.read());
}
void a0_bin_conv::thread_sel_tmp545_fu_34198_p3() {
sel_tmp545_fu_34198_p3 = (!sel_tmp116_reg_51647.read()[0].is_01())? sc_lv<2>(): ((sel_tmp116_reg_51647.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_0_4_3_1_reg_53245.read(): sel_tmp544_fu_34192_p3.read());
}
void a0_bin_conv::thread_sel_tmp546_fu_34210_p3() {
sel_tmp546_fu_34210_p3 = (!sel_tmp113_reg_51587.read()[0].is_01())? sc_lv<2>(): ((sel_tmp113_reg_51587.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_0_1_4_1_reg_53517.read(): ap_reg_pp0_iter2_word_buffer_0_5_4_1_reg_53161.read());
}
void a0_bin_conv::thread_sel_tmp547_fu_34215_p3() {
sel_tmp547_fu_34215_p3 = (!sel_tmp114_reg_51607.read()[0].is_01())? sc_lv<2>(): ((sel_tmp114_reg_51607.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_0_2_4_1_reg_53410.read(): sel_tmp546_fu_34210_p3.read());
}
void a0_bin_conv::thread_sel_tmp548_fu_34221_p3() {
sel_tmp548_fu_34221_p3 = (!sel_tmp115_reg_51627.read()[0].is_01())? sc_lv<2>(): ((sel_tmp115_reg_51627.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_0_3_4_1_reg_53315.read(): sel_tmp547_fu_34215_p3.read());
}
void a0_bin_conv::thread_sel_tmp549_fu_34227_p3() {
sel_tmp549_fu_34227_p3 = (!sel_tmp116_reg_51647.read()[0].is_01())? sc_lv<2>(): ((sel_tmp116_reg_51647.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_0_4_4_1_reg_53232.read(): sel_tmp548_fu_34221_p3.read());
}
void a0_bin_conv::thread_sel_tmp550_fu_34239_p3() {
sel_tmp550_fu_34239_p3 = (!sel_tmp113_reg_51587.read()[0].is_01())? sc_lv<2>(): ((sel_tmp113_reg_51587.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_0_1_5_1_reg_53498.read(): ap_reg_pp0_iter2_word_buffer_0_5_5_1_reg_53150.read());
}
void a0_bin_conv::thread_sel_tmp551_fu_34244_p3() {
sel_tmp551_fu_34244_p3 = (!sel_tmp114_reg_51607.read()[0].is_01())? sc_lv<2>(): ((sel_tmp114_reg_51607.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_0_2_5_1_reg_53393.read(): sel_tmp550_fu_34239_p3.read());
}
void a0_bin_conv::thread_sel_tmp552_fu_34250_p3() {
sel_tmp552_fu_34250_p3 = (!sel_tmp115_reg_51627.read()[0].is_01())? sc_lv<2>(): ((sel_tmp115_reg_51627.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_0_3_5_1_reg_53300.read(): sel_tmp551_fu_34244_p3.read());
}
void a0_bin_conv::thread_sel_tmp553_fu_34256_p3() {
sel_tmp553_fu_34256_p3 = (!sel_tmp116_reg_51647.read()[0].is_01())? sc_lv<2>(): ((sel_tmp116_reg_51647.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_0_4_5_1_reg_53219.read(): sel_tmp552_fu_34250_p3.read());
}
void a0_bin_conv::thread_sel_tmp554_fu_34268_p3() {
sel_tmp554_fu_34268_p3 = (!sel_tmp113_reg_51587.read()[0].is_01())? sc_lv<2>(): ((sel_tmp113_reg_51587.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_0_1_6_1_reg_53479.read(): ap_reg_pp0_iter2_word_buffer_0_5_6_1_reg_53139.read());
}
void a0_bin_conv::thread_sel_tmp555_fu_34273_p3() {
sel_tmp555_fu_34273_p3 = (!sel_tmp114_reg_51607.read()[0].is_01())? sc_lv<2>(): ((sel_tmp114_reg_51607.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_0_2_6_1_reg_53376.read(): sel_tmp554_fu_34268_p3.read());
}
void a0_bin_conv::thread_sel_tmp556_fu_34279_p3() {
sel_tmp556_fu_34279_p3 = (!sel_tmp115_reg_51627.read()[0].is_01())? sc_lv<2>(): ((sel_tmp115_reg_51627.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_0_3_6_1_reg_53285.read(): sel_tmp555_fu_34273_p3.read());
}
void a0_bin_conv::thread_sel_tmp557_fu_34285_p3() {
sel_tmp557_fu_34285_p3 = (!sel_tmp116_reg_51647.read()[0].is_01())? sc_lv<2>(): ((sel_tmp116_reg_51647.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_0_4_6_1_reg_53206.read(): sel_tmp556_fu_34279_p3.read());
}
void a0_bin_conv::thread_sel_tmp558_fu_34297_p3() {
sel_tmp558_fu_34297_p3 = (!sel_tmp113_reg_51587.read()[0].is_01())? sc_lv<2>(): ((sel_tmp113_reg_51587.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_0_1_7_1_reg_53461.read(): ap_reg_pp0_iter2_word_buffer_0_5_7_1_reg_53129.read());
}
void a0_bin_conv::thread_sel_tmp559_fu_34302_p3() {
sel_tmp559_fu_34302_p3 = (!sel_tmp114_reg_51607.read()[0].is_01())? sc_lv<2>(): ((sel_tmp114_reg_51607.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_0_2_7_1_reg_53360.read(): sel_tmp558_fu_34297_p3.read());
}
void a0_bin_conv::thread_sel_tmp560_fu_34308_p3() {
sel_tmp560_fu_34308_p3 = (!sel_tmp115_reg_51627.read()[0].is_01())? sc_lv<2>(): ((sel_tmp115_reg_51627.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_0_3_7_1_reg_53271.read(): sel_tmp559_fu_34302_p3.read());
}
void a0_bin_conv::thread_sel_tmp561_fu_34314_p3() {
sel_tmp561_fu_34314_p3 = (!sel_tmp116_reg_51647.read()[0].is_01())? sc_lv<2>(): ((sel_tmp116_reg_51647.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_0_4_7_1_reg_53194.read(): sel_tmp560_fu_34308_p3.read());
}
void a0_bin_conv::thread_sel_tmp562_fu_34326_p3() {
sel_tmp562_fu_34326_p3 = (!sel_tmp113_reg_51587.read()[0].is_01())? sc_lv<2>(): ((sel_tmp113_reg_51587.read()[0].to_bool())? word_buffer_0_2_0_1_reg_55388.read(): word_buffer_0_6_0_1_reg_55181.read());
}
void a0_bin_conv::thread_sel_tmp563_fu_34331_p3() {
sel_tmp563_fu_34331_p3 = (!sel_tmp114_reg_51607.read()[0].is_01())? sc_lv<2>(): ((sel_tmp114_reg_51607.read()[0].to_bool())? word_buffer_0_3_0_1_reg_55326.read(): sel_tmp562_fu_34326_p3.read());
}
void a0_bin_conv::thread_sel_tmp564_fu_34337_p3() {
sel_tmp564_fu_34337_p3 = (!sel_tmp115_reg_51627.read()[0].is_01())? sc_lv<2>(): ((sel_tmp115_reg_51627.read()[0].to_bool())? word_buffer_0_4_0_1_reg_55270.read(): sel_tmp563_fu_34331_p3.read());
}
void a0_bin_conv::thread_sel_tmp565_fu_34343_p3() {
sel_tmp565_fu_34343_p3 = (!sel_tmp116_reg_51647.read()[0].is_01())? sc_lv<2>(): ((sel_tmp116_reg_51647.read()[0].to_bool())? word_buffer_0_5_0_1_reg_55221.read(): sel_tmp564_fu_34337_p3.read());
}
void a0_bin_conv::thread_sel_tmp566_fu_34355_p3() {
sel_tmp566_fu_34355_p3 = (!tmp_176_reg_51687.read()[0].is_01())? sc_lv<2>(): ((tmp_176_reg_51687.read()[0].to_bool())? ap_const_lv2_0: word_buffer_0_5_0_reg_55200.read());
}
void a0_bin_conv::thread_sel_tmp567_fu_34361_p3() {
sel_tmp567_fu_34361_p3 = (!sel_tmp120_reg_51693.read()[0].is_01())? sc_lv<2>(): ((sel_tmp120_reg_51693.read()[0].to_bool())? word_buffer_0_1_0_reg_55417.read(): sel_tmp566_fu_34355_p3.read());
}
void a0_bin_conv::thread_sel_tmp568_fu_34367_p3() {
sel_tmp568_fu_34367_p3 = (!sel_tmp121_reg_51699.read()[0].is_01())? sc_lv<2>(): ((sel_tmp121_reg_51699.read()[0].to_bool())? word_buffer_0_2_0_reg_55355.read(): sel_tmp567_fu_34361_p3.read());
}
void a0_bin_conv::thread_sel_tmp569_fu_34373_p3() {
sel_tmp569_fu_34373_p3 = (!sel_tmp122_reg_51705.read()[0].is_01())? sc_lv<2>(): ((sel_tmp122_reg_51705.read()[0].to_bool())? word_buffer_0_3_0_reg_55296.read(): sel_tmp568_fu_34367_p3.read());
}
void a0_bin_conv::thread_sel_tmp570_fu_34395_p3() {
sel_tmp570_fu_34395_p3 = (!sel_tmp124_reg_51717.read()[0].is_01())? sc_lv<2>(): ((sel_tmp124_reg_51717.read()[0].to_bool())? word_buffer_0_1_1_reg_55405.read(): word_buffer_0_6_1_reg_55157.read());
}
void a0_bin_conv::thread_sel_tmp571_fu_34400_p3() {
sel_tmp571_fu_34400_p3 = (!sel_tmp125_reg_51737.read()[0].is_01())? sc_lv<2>(): ((sel_tmp125_reg_51737.read()[0].to_bool())? word_buffer_0_2_1_reg_55342.read(): sel_tmp570_fu_34395_p3.read());
}
void a0_bin_conv::thread_sel_tmp572_fu_34406_p3() {
sel_tmp572_fu_34406_p3 = (!sel_tmp126_reg_51757.read()[0].is_01())? sc_lv<2>(): ((sel_tmp126_reg_51757.read()[0].to_bool())? word_buffer_0_3_1_reg_55284.read(): sel_tmp571_fu_34400_p3.read());
}
void a0_bin_conv::thread_sel_tmp573_fu_34412_p3() {
sel_tmp573_fu_34412_p3 = (!sel_tmp127_reg_51777.read()[0].is_01())? sc_lv<2>(): ((sel_tmp127_reg_51777.read()[0].to_bool())? word_buffer_0_4_1_reg_55233.read(): sel_tmp572_fu_34406_p3.read());
}
void a0_bin_conv::thread_sel_tmp574_fu_34418_p3() {
sel_tmp574_fu_34418_p3 = (!sel_tmp128_reg_51797.read()[0].is_01())? sc_lv<2>(): ((sel_tmp128_reg_51797.read()[0].to_bool())? word_buffer_0_5_1_reg_55191.read(): sel_tmp573_fu_34412_p3.read());
}
void a0_bin_conv::thread_sel_tmp575_fu_34430_p3() {
sel_tmp575_fu_34430_p3 = (!sel_tmp124_reg_51717.read()[0].is_01())? sc_lv<2>(): ((sel_tmp124_reg_51717.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_0_1_2_1_reg_53555.read(): ap_reg_pp0_iter2_word_buffer_0_6_2_1_reg_53120.read());
}
void a0_bin_conv::thread_sel_tmp576_fu_34435_p3() {
sel_tmp576_fu_34435_p3 = (!sel_tmp125_reg_51737.read()[0].is_01())? sc_lv<2>(): ((sel_tmp125_reg_51737.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_0_2_2_1_reg_53444.read(): sel_tmp575_fu_34430_p3.read());
}
void a0_bin_conv::thread_sel_tmp577_fu_34441_p3() {
sel_tmp577_fu_34441_p3 = (!sel_tmp126_reg_51757.read()[0].is_01())? sc_lv<2>(): ((sel_tmp126_reg_51757.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_0_3_2_1_reg_53345.read(): sel_tmp576_fu_34435_p3.read());
}
void a0_bin_conv::thread_sel_tmp578_fu_34447_p3() {
sel_tmp578_fu_34447_p3 = (!sel_tmp127_reg_51777.read()[0].is_01())? sc_lv<2>(): ((sel_tmp127_reg_51777.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_0_4_2_1_reg_53258.read(): sel_tmp577_fu_34441_p3.read());
}
void a0_bin_conv::thread_sel_tmp579_fu_34453_p3() {
sel_tmp579_fu_34453_p3 = (!sel_tmp128_reg_51797.read()[0].is_01())? sc_lv<2>(): ((sel_tmp128_reg_51797.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_0_5_2_1_reg_53183.read(): sel_tmp578_fu_34447_p3.read());
}
void a0_bin_conv::thread_sel_tmp580_fu_34465_p3() {
sel_tmp580_fu_34465_p3 = (!sel_tmp124_reg_51717.read()[0].is_01())? sc_lv<2>(): ((sel_tmp124_reg_51717.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_0_1_3_1_reg_53536.read(): ap_reg_pp0_iter2_word_buffer_0_6_3_1_reg_53111.read());
}
void a0_bin_conv::thread_sel_tmp581_fu_34470_p3() {
sel_tmp581_fu_34470_p3 = (!sel_tmp125_reg_51737.read()[0].is_01())? sc_lv<2>(): ((sel_tmp125_reg_51737.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_0_2_3_1_reg_53427.read(): sel_tmp580_fu_34465_p3.read());
}
void a0_bin_conv::thread_sel_tmp582_fu_34476_p3() {
sel_tmp582_fu_34476_p3 = (!sel_tmp126_reg_51757.read()[0].is_01())? sc_lv<2>(): ((sel_tmp126_reg_51757.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_0_3_3_1_reg_53330.read(): sel_tmp581_fu_34470_p3.read());
}
void a0_bin_conv::thread_sel_tmp583_fu_34482_p3() {
sel_tmp583_fu_34482_p3 = (!sel_tmp127_reg_51777.read()[0].is_01())? sc_lv<2>(): ((sel_tmp127_reg_51777.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_0_4_3_1_reg_53245.read(): sel_tmp582_fu_34476_p3.read());
}
void a0_bin_conv::thread_sel_tmp584_fu_34488_p3() {
sel_tmp584_fu_34488_p3 = (!sel_tmp128_reg_51797.read()[0].is_01())? sc_lv<2>(): ((sel_tmp128_reg_51797.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_0_5_3_1_reg_53172.read(): sel_tmp583_fu_34482_p3.read());
}
void a0_bin_conv::thread_sel_tmp585_fu_34500_p3() {
sel_tmp585_fu_34500_p3 = (!sel_tmp124_reg_51717.read()[0].is_01())? sc_lv<2>(): ((sel_tmp124_reg_51717.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_0_1_4_1_reg_53517.read(): ap_reg_pp0_iter2_word_buffer_0_6_4_1_reg_53102.read());
}
void a0_bin_conv::thread_sel_tmp586_fu_34505_p3() {
sel_tmp586_fu_34505_p3 = (!sel_tmp125_reg_51737.read()[0].is_01())? sc_lv<2>(): ((sel_tmp125_reg_51737.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_0_2_4_1_reg_53410.read(): sel_tmp585_fu_34500_p3.read());
}
void a0_bin_conv::thread_sel_tmp587_fu_34511_p3() {
sel_tmp587_fu_34511_p3 = (!sel_tmp126_reg_51757.read()[0].is_01())? sc_lv<2>(): ((sel_tmp126_reg_51757.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_0_3_4_1_reg_53315.read(): sel_tmp586_fu_34505_p3.read());
}
void a0_bin_conv::thread_sel_tmp588_fu_34517_p3() {
sel_tmp588_fu_34517_p3 = (!sel_tmp127_reg_51777.read()[0].is_01())? sc_lv<2>(): ((sel_tmp127_reg_51777.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_0_4_4_1_reg_53232.read(): sel_tmp587_fu_34511_p3.read());
}
void a0_bin_conv::thread_sel_tmp589_fu_34523_p3() {
sel_tmp589_fu_34523_p3 = (!sel_tmp128_reg_51797.read()[0].is_01())? sc_lv<2>(): ((sel_tmp128_reg_51797.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_0_5_4_1_reg_53161.read(): sel_tmp588_fu_34517_p3.read());
}
void a0_bin_conv::thread_sel_tmp590_fu_34535_p3() {
sel_tmp590_fu_34535_p3 = (!sel_tmp124_reg_51717.read()[0].is_01())? sc_lv<2>(): ((sel_tmp124_reg_51717.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_0_1_5_1_reg_53498.read(): ap_reg_pp0_iter2_word_buffer_0_6_5_1_reg_53093.read());
}
void a0_bin_conv::thread_sel_tmp591_fu_34540_p3() {
sel_tmp591_fu_34540_p3 = (!sel_tmp125_reg_51737.read()[0].is_01())? sc_lv<2>(): ((sel_tmp125_reg_51737.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_0_2_5_1_reg_53393.read(): sel_tmp590_fu_34535_p3.read());
}
void a0_bin_conv::thread_sel_tmp592_fu_34546_p3() {
sel_tmp592_fu_34546_p3 = (!sel_tmp126_reg_51757.read()[0].is_01())? sc_lv<2>(): ((sel_tmp126_reg_51757.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_0_3_5_1_reg_53300.read(): sel_tmp591_fu_34540_p3.read());
}
void a0_bin_conv::thread_sel_tmp593_fu_34552_p3() {
sel_tmp593_fu_34552_p3 = (!sel_tmp127_reg_51777.read()[0].is_01())? sc_lv<2>(): ((sel_tmp127_reg_51777.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_0_4_5_1_reg_53219.read(): sel_tmp592_fu_34546_p3.read());
}
void a0_bin_conv::thread_sel_tmp594_fu_34558_p3() {
sel_tmp594_fu_34558_p3 = (!sel_tmp128_reg_51797.read()[0].is_01())? sc_lv<2>(): ((sel_tmp128_reg_51797.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_0_5_5_1_reg_53150.read(): sel_tmp593_fu_34552_p3.read());
}
void a0_bin_conv::thread_sel_tmp595_fu_34570_p3() {
sel_tmp595_fu_34570_p3 = (!sel_tmp124_reg_51717.read()[0].is_01())? sc_lv<2>(): ((sel_tmp124_reg_51717.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_0_1_6_1_reg_53479.read(): ap_reg_pp0_iter2_word_buffer_0_6_6_1_reg_53084.read());
}
void a0_bin_conv::thread_sel_tmp596_fu_34575_p3() {
sel_tmp596_fu_34575_p3 = (!sel_tmp125_reg_51737.read()[0].is_01())? sc_lv<2>(): ((sel_tmp125_reg_51737.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_0_2_6_1_reg_53376.read(): sel_tmp595_fu_34570_p3.read());
}
void a0_bin_conv::thread_sel_tmp597_fu_34581_p3() {
sel_tmp597_fu_34581_p3 = (!sel_tmp126_reg_51757.read()[0].is_01())? sc_lv<2>(): ((sel_tmp126_reg_51757.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_0_3_6_1_reg_53285.read(): sel_tmp596_fu_34575_p3.read());
}
void a0_bin_conv::thread_sel_tmp598_fu_34587_p3() {
sel_tmp598_fu_34587_p3 = (!sel_tmp127_reg_51777.read()[0].is_01())? sc_lv<2>(): ((sel_tmp127_reg_51777.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_0_4_6_1_reg_53206.read(): sel_tmp597_fu_34581_p3.read());
}
void a0_bin_conv::thread_sel_tmp599_fu_34593_p3() {
sel_tmp599_fu_34593_p3 = (!sel_tmp128_reg_51797.read()[0].is_01())? sc_lv<2>(): ((sel_tmp128_reg_51797.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_0_5_6_1_reg_53139.read(): sel_tmp598_fu_34587_p3.read());
}
void a0_bin_conv::thread_sel_tmp600_fu_34605_p3() {
sel_tmp600_fu_34605_p3 = (!sel_tmp124_reg_51717.read()[0].is_01())? sc_lv<2>(): ((sel_tmp124_reg_51717.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_0_1_7_1_reg_53461.read(): ap_reg_pp0_iter2_word_buffer_0_6_7_1_reg_53076.read());
}
void a0_bin_conv::thread_sel_tmp601_fu_34610_p3() {
sel_tmp601_fu_34610_p3 = (!sel_tmp125_reg_51737.read()[0].is_01())? sc_lv<2>(): ((sel_tmp125_reg_51737.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_0_2_7_1_reg_53360.read(): sel_tmp600_fu_34605_p3.read());
}
void a0_bin_conv::thread_sel_tmp602_fu_34616_p3() {
sel_tmp602_fu_34616_p3 = (!sel_tmp126_reg_51757.read()[0].is_01())? sc_lv<2>(): ((sel_tmp126_reg_51757.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_0_3_7_1_reg_53271.read(): sel_tmp601_fu_34610_p3.read());
}
void a0_bin_conv::thread_sel_tmp603_fu_34622_p3() {
sel_tmp603_fu_34622_p3 = (!sel_tmp127_reg_51777.read()[0].is_01())? sc_lv<2>(): ((sel_tmp127_reg_51777.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_0_4_7_1_reg_53194.read(): sel_tmp602_fu_34616_p3.read());
}
void a0_bin_conv::thread_sel_tmp604_fu_34628_p3() {
sel_tmp604_fu_34628_p3 = (!sel_tmp128_reg_51797.read()[0].is_01())? sc_lv<2>(): ((sel_tmp128_reg_51797.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_0_5_7_1_reg_53129.read(): sel_tmp603_fu_34622_p3.read());
}
void a0_bin_conv::thread_sel_tmp605_fu_34640_p3() {
sel_tmp605_fu_34640_p3 = (!sel_tmp124_reg_51717.read()[0].is_01())? sc_lv<2>(): ((sel_tmp124_reg_51717.read()[0].to_bool())? word_buffer_0_2_0_1_reg_55388.read(): word_buffer_0_7_0_1_reg_55149.read());
}
void a0_bin_conv::thread_sel_tmp606_fu_34645_p3() {
sel_tmp606_fu_34645_p3 = (!sel_tmp125_reg_51737.read()[0].is_01())? sc_lv<2>(): ((sel_tmp125_reg_51737.read()[0].to_bool())? word_buffer_0_3_0_1_reg_55326.read(): sel_tmp605_fu_34640_p3.read());
}
void a0_bin_conv::thread_sel_tmp607_fu_34651_p3() {
sel_tmp607_fu_34651_p3 = (!sel_tmp126_reg_51757.read()[0].is_01())? sc_lv<2>(): ((sel_tmp126_reg_51757.read()[0].to_bool())? word_buffer_0_4_0_1_reg_55270.read(): sel_tmp606_fu_34645_p3.read());
}
void a0_bin_conv::thread_sel_tmp608_fu_34657_p3() {
sel_tmp608_fu_34657_p3 = (!sel_tmp127_reg_51777.read()[0].is_01())? sc_lv<2>(): ((sel_tmp127_reg_51777.read()[0].to_bool())? word_buffer_0_5_0_1_reg_55221.read(): sel_tmp607_fu_34651_p3.read());
}
void a0_bin_conv::thread_sel_tmp609_fu_34663_p3() {
sel_tmp609_fu_34663_p3 = (!sel_tmp128_reg_51797.read()[0].is_01())? sc_lv<2>(): ((sel_tmp128_reg_51797.read()[0].to_bool())? word_buffer_0_6_0_1_reg_55181.read(): sel_tmp608_fu_34657_p3.read());
}
void a0_bin_conv::thread_sel_tmp610_fu_34675_p3() {
sel_tmp610_fu_34675_p3 = (!tmp_177_reg_51837.read()[0].is_01())? sc_lv<2>(): ((tmp_177_reg_51837.read()[0].to_bool())? ap_const_lv2_0: word_buffer_0_6_0_reg_55164.read());
}
void a0_bin_conv::thread_sel_tmp611_fu_34681_p3() {
sel_tmp611_fu_34681_p3 = (!sel_tmp132_reg_51843.read()[0].is_01())? sc_lv<2>(): ((sel_tmp132_reg_51843.read()[0].to_bool())? word_buffer_0_1_0_reg_55417.read(): sel_tmp610_fu_34675_p3.read());
}
void a0_bin_conv::thread_sel_tmp612_fu_34687_p3() {
sel_tmp612_fu_34687_p3 = (!sel_tmp133_reg_51849.read()[0].is_01())? sc_lv<2>(): ((sel_tmp133_reg_51849.read()[0].to_bool())? word_buffer_0_2_0_reg_55355.read(): sel_tmp611_fu_34681_p3.read());
}
void a0_bin_conv::thread_sel_tmp613_fu_34693_p3() {
sel_tmp613_fu_34693_p3 = (!sel_tmp134_reg_51855.read()[0].is_01())? sc_lv<2>(): ((sel_tmp134_reg_51855.read()[0].to_bool())? word_buffer_0_3_0_reg_55296.read(): sel_tmp612_fu_34687_p3.read());
}
void a0_bin_conv::thread_sel_tmp614_fu_34699_p3() {
sel_tmp614_fu_34699_p3 = (!sel_tmp135_reg_51861.read()[0].is_01())? sc_lv<2>(): ((sel_tmp135_reg_51861.read()[0].to_bool())? word_buffer_0_4_0_reg_55244.read(): sel_tmp613_fu_34693_p3.read());
}
void a0_bin_conv::thread_sel_tmp615_fu_28709_p3() {
sel_tmp615_fu_28709_p3 = (!cond6_reg_50242.read()[0].is_01())? sc_lv<2>(): ((cond6_reg_50242.read()[0].to_bool())? old_word_buffer_1_1_11_fu_1666.read(): old_word_buffer_1_7_11_fu_1882.read());
}
void a0_bin_conv::thread_sel_tmp616_fu_28716_p3() {
sel_tmp616_fu_28716_p3 = (!tmp_168_reg_50922.read()[0].is_01())? sc_lv<2>(): ((tmp_168_reg_50922.read()[0].to_bool())? old_word_buffer_1_2_11_fu_1702.read(): sel_tmp615_fu_28709_p3.read());
}
void a0_bin_conv::thread_sel_tmp617_fu_28723_p3() {
sel_tmp617_fu_28723_p3 = (!tmp_169_reg_51016.read()[0].is_01())? sc_lv<2>(): ((tmp_169_reg_51016.read()[0].to_bool())? old_word_buffer_1_3_11_fu_1738.read(): sel_tmp616_fu_28716_p3.read());
}
void a0_bin_conv::thread_sel_tmp618_fu_28730_p3() {
sel_tmp618_fu_28730_p3 = (!tmp_171_reg_51180.read()[0].is_01())? sc_lv<2>(): ((tmp_171_reg_51180.read()[0].to_bool())? old_word_buffer_1_4_11_fu_1774.read(): sel_tmp617_fu_28723_p3.read());
}
void a0_bin_conv::thread_sel_tmp619_fu_28737_p3() {
sel_tmp619_fu_28737_p3 = (!tmp_170_reg_51104.read()[0].is_01())? sc_lv<2>(): ((tmp_170_reg_51104.read()[0].to_bool())? old_word_buffer_1_5_11_fu_1810.read(): sel_tmp618_fu_28730_p3.read());
}
void a0_bin_conv::thread_sel_tmp620_fu_28751_p3() {
sel_tmp620_fu_28751_p3 = (!cond6_reg_50242.read()[0].is_01())? sc_lv<2>(): ((cond6_reg_50242.read()[0].to_bool())? old_word_buffer_1_1_12_fu_1670.read(): old_word_buffer_1_7_12_fu_1886.read());
}
void a0_bin_conv::thread_sel_tmp621_fu_28758_p3() {
sel_tmp621_fu_28758_p3 = (!tmp_168_reg_50922.read()[0].is_01())? sc_lv<2>(): ((tmp_168_reg_50922.read()[0].to_bool())? old_word_buffer_1_2_12_fu_1706.read(): sel_tmp620_fu_28751_p3.read());
}
void a0_bin_conv::thread_sel_tmp622_fu_28765_p3() {
sel_tmp622_fu_28765_p3 = (!tmp_169_reg_51016.read()[0].is_01())? sc_lv<2>(): ((tmp_169_reg_51016.read()[0].to_bool())? old_word_buffer_1_3_12_fu_1742.read(): sel_tmp621_fu_28758_p3.read());
}
void a0_bin_conv::thread_sel_tmp623_fu_28772_p3() {
sel_tmp623_fu_28772_p3 = (!tmp_171_reg_51180.read()[0].is_01())? sc_lv<2>(): ((tmp_171_reg_51180.read()[0].to_bool())? old_word_buffer_1_4_12_fu_1778.read(): sel_tmp622_fu_28765_p3.read());
}
void a0_bin_conv::thread_sel_tmp624_fu_28779_p3() {
sel_tmp624_fu_28779_p3 = (!tmp_170_reg_51104.read()[0].is_01())? sc_lv<2>(): ((tmp_170_reg_51104.read()[0].to_bool())? old_word_buffer_1_5_12_fu_1814.read(): sel_tmp623_fu_28772_p3.read());
}
void a0_bin_conv::thread_sel_tmp625_fu_28793_p3() {
sel_tmp625_fu_28793_p3 = (!cond6_reg_50242.read()[0].is_01())? sc_lv<2>(): ((cond6_reg_50242.read()[0].to_bool())? old_word_buffer_1_1_13_fu_1674.read(): old_word_buffer_1_7_13_fu_1890.read());
}
void a0_bin_conv::thread_sel_tmp626_fu_28800_p3() {
sel_tmp626_fu_28800_p3 = (!tmp_168_reg_50922.read()[0].is_01())? sc_lv<2>(): ((tmp_168_reg_50922.read()[0].to_bool())? old_word_buffer_1_2_13_fu_1710.read(): sel_tmp625_fu_28793_p3.read());
}
void a0_bin_conv::thread_sel_tmp627_fu_28807_p3() {
sel_tmp627_fu_28807_p3 = (!tmp_169_reg_51016.read()[0].is_01())? sc_lv<2>(): ((tmp_169_reg_51016.read()[0].to_bool())? old_word_buffer_1_3_13_fu_1746.read(): sel_tmp626_fu_28800_p3.read());
}
void a0_bin_conv::thread_sel_tmp628_fu_28814_p3() {
sel_tmp628_fu_28814_p3 = (!tmp_171_reg_51180.read()[0].is_01())? sc_lv<2>(): ((tmp_171_reg_51180.read()[0].to_bool())? old_word_buffer_1_4_13_fu_1782.read(): sel_tmp627_fu_28807_p3.read());
}
void a0_bin_conv::thread_sel_tmp629_fu_28821_p3() {
sel_tmp629_fu_28821_p3 = (!tmp_170_reg_51104.read()[0].is_01())? sc_lv<2>(): ((tmp_170_reg_51104.read()[0].to_bool())? old_word_buffer_1_5_13_fu_1818.read(): sel_tmp628_fu_28814_p3.read());
}
void a0_bin_conv::thread_sel_tmp630_fu_28835_p3() {
sel_tmp630_fu_28835_p3 = (!cond6_reg_50242.read()[0].is_01())? sc_lv<2>(): ((cond6_reg_50242.read()[0].to_bool())? old_word_buffer_1_1_14_fu_1678.read(): old_word_buffer_1_7_14_fu_1894.read());
}
void a0_bin_conv::thread_sel_tmp631_fu_28842_p3() {
sel_tmp631_fu_28842_p3 = (!tmp_168_reg_50922.read()[0].is_01())? sc_lv<2>(): ((tmp_168_reg_50922.read()[0].to_bool())? old_word_buffer_1_2_14_fu_1714.read(): sel_tmp630_fu_28835_p3.read());
}
void a0_bin_conv::thread_sel_tmp632_fu_28849_p3() {
sel_tmp632_fu_28849_p3 = (!tmp_169_reg_51016.read()[0].is_01())? sc_lv<2>(): ((tmp_169_reg_51016.read()[0].to_bool())? old_word_buffer_1_3_14_fu_1750.read(): sel_tmp631_fu_28842_p3.read());
}
void a0_bin_conv::thread_sel_tmp633_fu_28856_p3() {
sel_tmp633_fu_28856_p3 = (!tmp_171_reg_51180.read()[0].is_01())? sc_lv<2>(): ((tmp_171_reg_51180.read()[0].to_bool())? old_word_buffer_1_4_14_fu_1786.read(): sel_tmp632_fu_28849_p3.read());
}
void a0_bin_conv::thread_sel_tmp634_fu_28863_p3() {
sel_tmp634_fu_28863_p3 = (!tmp_170_reg_51104.read()[0].is_01())? sc_lv<2>(): ((tmp_170_reg_51104.read()[0].to_bool())? old_word_buffer_1_5_14_fu_1822.read(): sel_tmp633_fu_28856_p3.read());
}
void a0_bin_conv::thread_sel_tmp635_fu_28877_p3() {
sel_tmp635_fu_28877_p3 = (!cond6_reg_50242.read()[0].is_01())? sc_lv<2>(): ((cond6_reg_50242.read()[0].to_bool())? old_word_buffer_1_1_15_fu_1682.read(): old_word_buffer_1_7_15_fu_1898.read());
}
void a0_bin_conv::thread_sel_tmp636_fu_28884_p3() {
sel_tmp636_fu_28884_p3 = (!tmp_168_reg_50922.read()[0].is_01())? sc_lv<2>(): ((tmp_168_reg_50922.read()[0].to_bool())? old_word_buffer_1_2_15_fu_1718.read(): sel_tmp635_fu_28877_p3.read());
}
void a0_bin_conv::thread_sel_tmp637_fu_28891_p3() {
sel_tmp637_fu_28891_p3 = (!tmp_169_reg_51016.read()[0].is_01())? sc_lv<2>(): ((tmp_169_reg_51016.read()[0].to_bool())? old_word_buffer_1_3_15_fu_1754.read(): sel_tmp636_fu_28884_p3.read());
}
void a0_bin_conv::thread_sel_tmp638_fu_28898_p3() {
sel_tmp638_fu_28898_p3 = (!tmp_171_reg_51180.read()[0].is_01())? sc_lv<2>(): ((tmp_171_reg_51180.read()[0].to_bool())? old_word_buffer_1_4_15_fu_1790.read(): sel_tmp637_fu_28891_p3.read());
}
void a0_bin_conv::thread_sel_tmp639_fu_28905_p3() {
sel_tmp639_fu_28905_p3 = (!tmp_170_reg_51104.read()[0].is_01())? sc_lv<2>(): ((tmp_170_reg_51104.read()[0].to_bool())? old_word_buffer_1_5_15_fu_1826.read(): sel_tmp638_fu_28898_p3.read());
}
void a0_bin_conv::thread_sel_tmp640_fu_28919_p3() {
sel_tmp640_fu_28919_p3 = (!cond6_reg_50242.read()[0].is_01())? sc_lv<2>(): ((cond6_reg_50242.read()[0].to_bool())? old_word_buffer_1_1_16_fu_1686.read(): old_word_buffer_1_7_16_fu_1902.read());
}
void a0_bin_conv::thread_sel_tmp641_fu_28926_p3() {
sel_tmp641_fu_28926_p3 = (!tmp_168_reg_50922.read()[0].is_01())? sc_lv<2>(): ((tmp_168_reg_50922.read()[0].to_bool())? old_word_buffer_1_2_16_fu_1722.read(): sel_tmp640_fu_28919_p3.read());
}
void a0_bin_conv::thread_sel_tmp642_fu_28933_p3() {
sel_tmp642_fu_28933_p3 = (!tmp_169_reg_51016.read()[0].is_01())? sc_lv<2>(): ((tmp_169_reg_51016.read()[0].to_bool())? old_word_buffer_1_3_16_fu_1758.read(): sel_tmp641_fu_28926_p3.read());
}
void a0_bin_conv::thread_sel_tmp643_fu_28940_p3() {
sel_tmp643_fu_28940_p3 = (!tmp_171_reg_51180.read()[0].is_01())? sc_lv<2>(): ((tmp_171_reg_51180.read()[0].to_bool())? old_word_buffer_1_4_16_fu_1794.read(): sel_tmp642_fu_28933_p3.read());
}
void a0_bin_conv::thread_sel_tmp644_fu_28947_p3() {
sel_tmp644_fu_28947_p3 = (!tmp_170_reg_51104.read()[0].is_01())? sc_lv<2>(): ((tmp_170_reg_51104.read()[0].to_bool())? old_word_buffer_1_5_16_fu_1830.read(): sel_tmp643_fu_28940_p3.read());
}
void a0_bin_conv::thread_sel_tmp645_fu_24059_p3() {
sel_tmp645_fu_24059_p3 = (!cond6_reg_50242.read()[0].is_01())? sc_lv<2>(): ((cond6_reg_50242.read()[0].to_bool())? old_word_buffer_1_1_17_fu_1690.read(): old_word_buffer_1_7_17_fu_1906.read());
}
void a0_bin_conv::thread_sel_tmp646_fu_24066_p3() {
sel_tmp646_fu_24066_p3 = (!tmp_168_reg_50922.read()[0].is_01())? sc_lv<2>(): ((tmp_168_reg_50922.read()[0].to_bool())? old_word_buffer_1_2_17_fu_1726.read(): sel_tmp645_fu_24059_p3.read());
}
void a0_bin_conv::thread_sel_tmp647_fu_24073_p3() {
sel_tmp647_fu_24073_p3 = (!tmp_169_reg_51016.read()[0].is_01())? sc_lv<2>(): ((tmp_169_reg_51016.read()[0].to_bool())? old_word_buffer_1_3_17_fu_1762.read(): sel_tmp646_fu_24066_p3.read());
}
void a0_bin_conv::thread_sel_tmp648_fu_24080_p3() {
sel_tmp648_fu_24080_p3 = (!tmp_171_reg_51180.read()[0].is_01())? sc_lv<2>(): ((tmp_171_reg_51180.read()[0].to_bool())? old_word_buffer_1_4_17_fu_1798.read(): sel_tmp647_fu_24073_p3.read());
}
void a0_bin_conv::thread_sel_tmp649_fu_24087_p3() {
sel_tmp649_fu_24087_p3 = (!tmp_170_reg_51104.read()[0].is_01())? sc_lv<2>(): ((tmp_170_reg_51104.read()[0].to_bool())? old_word_buffer_1_5_17_fu_1834.read(): sel_tmp648_fu_24080_p3.read());
}
void a0_bin_conv::thread_sel_tmp650_fu_28961_p3() {
sel_tmp650_fu_28961_p3 = (!cond6_reg_50242.read()[0].is_01())? sc_lv<2>(): ((cond6_reg_50242.read()[0].to_bool())? old_word_buffer_1_1_18_fu_1694.read(): old_word_buffer_1_7_42_reg_52212.read());
}
void a0_bin_conv::thread_sel_tmp651_fu_28967_p3() {
sel_tmp651_fu_28967_p3 = (!tmp_168_reg_50922.read()[0].is_01())? sc_lv<2>(): ((tmp_168_reg_50922.read()[0].to_bool())? old_word_buffer_1_2_18_fu_1730.read(): sel_tmp650_fu_28961_p3.read());
}
void a0_bin_conv::thread_sel_tmp652_fu_28974_p3() {
sel_tmp652_fu_28974_p3 = (!tmp_169_reg_51016.read()[0].is_01())? sc_lv<2>(): ((tmp_169_reg_51016.read()[0].to_bool())? old_word_buffer_1_3_18_fu_1766.read(): sel_tmp651_fu_28967_p3.read());
}
void a0_bin_conv::thread_sel_tmp653_fu_28981_p3() {
sel_tmp653_fu_28981_p3 = (!tmp_171_reg_51180.read()[0].is_01())? sc_lv<2>(): ((tmp_171_reg_51180.read()[0].to_bool())? old_word_buffer_1_4_18_fu_1802.read(): sel_tmp652_fu_28974_p3.read());
}
void a0_bin_conv::thread_sel_tmp654_fu_28988_p3() {
sel_tmp654_fu_28988_p3 = (!tmp_170_reg_51104.read()[0].is_01())? sc_lv<2>(): ((tmp_170_reg_51104.read()[0].to_bool())? old_word_buffer_1_5_18_fu_1838.read(): sel_tmp653_fu_28981_p3.read());
}
void a0_bin_conv::thread_sel_tmp655_fu_29143_p3() {
sel_tmp655_fu_29143_p3 = (!cond6_reg_50242.read()[0].is_01())? sc_lv<2>(): ((cond6_reg_50242.read()[0].to_bool())? old_word_buffer_1_2_11_fu_1702.read(): old_word_buffer_1_7_11_fu_1882.read());
}
void a0_bin_conv::thread_sel_tmp656_fu_29150_p3() {
sel_tmp656_fu_29150_p3 = (!tmp_168_reg_50922.read()[0].is_01())? sc_lv<2>(): ((tmp_168_reg_50922.read()[0].to_bool())? old_word_buffer_1_3_11_fu_1738.read(): sel_tmp655_fu_29143_p3.read());
}
void a0_bin_conv::thread_sel_tmp657_fu_29157_p3() {
sel_tmp657_fu_29157_p3 = (!tmp_169_reg_51016.read()[0].is_01())? sc_lv<2>(): ((tmp_169_reg_51016.read()[0].to_bool())? old_word_buffer_1_4_11_fu_1774.read(): sel_tmp656_fu_29150_p3.read());
}
void a0_bin_conv::thread_sel_tmp658_fu_29164_p3() {
sel_tmp658_fu_29164_p3 = (!tmp_171_reg_51180.read()[0].is_01())? sc_lv<2>(): ((tmp_171_reg_51180.read()[0].to_bool())? old_word_buffer_1_5_11_fu_1810.read(): sel_tmp657_fu_29157_p3.read());
}
void a0_bin_conv::thread_sel_tmp659_fu_34795_p3() {
sel_tmp659_fu_34795_p3 = (!cond6_reg_50242.read()[0].is_01())? sc_lv<2>(): ((cond6_reg_50242.read()[0].to_bool())? old_word_buffer_1_2_29_reg_54309.read(): old_word_buffer_1_7_44_reg_54617.read());
}
void a0_bin_conv::thread_sel_tmp660_fu_34800_p3() {
sel_tmp660_fu_34800_p3 = (!tmp_168_reg_50922.read()[0].is_01())? sc_lv<2>(): ((tmp_168_reg_50922.read()[0].to_bool())? old_word_buffer_1_3_29_reg_54350.read(): sel_tmp659_fu_34795_p3.read());
}
void a0_bin_conv::thread_sel_tmp661_fu_34806_p3() {
sel_tmp661_fu_34806_p3 = (!tmp_169_reg_51016.read()[0].is_01())? sc_lv<2>(): ((tmp_169_reg_51016.read()[0].to_bool())? old_word_buffer_1_4_29_reg_54401.read(): sel_tmp660_fu_34800_p3.read());
}
void a0_bin_conv::thread_sel_tmp662_fu_34812_p3() {
sel_tmp662_fu_34812_p3 = (!tmp_171_reg_51180.read()[0].is_01())? sc_lv<2>(): ((tmp_171_reg_51180.read()[0].to_bool())? old_word_buffer_1_5_29_reg_54462.read(): sel_tmp661_fu_34806_p3.read());
}
void a0_bin_conv::thread_sel_tmp663_fu_29178_p3() {
sel_tmp663_fu_29178_p3 = (!cond6_reg_50242.read()[0].is_01())? sc_lv<2>(): ((cond6_reg_50242.read()[0].to_bool())? old_word_buffer_1_2_13_fu_1710.read(): old_word_buffer_1_7_13_fu_1890.read());
}
void a0_bin_conv::thread_sel_tmp664_fu_29185_p3() {
sel_tmp664_fu_29185_p3 = (!tmp_168_reg_50922.read()[0].is_01())? sc_lv<2>(): ((tmp_168_reg_50922.read()[0].to_bool())? old_word_buffer_1_3_13_fu_1746.read(): sel_tmp663_fu_29178_p3.read());
}
void a0_bin_conv::thread_sel_tmp665_fu_29192_p3() {
sel_tmp665_fu_29192_p3 = (!tmp_169_reg_51016.read()[0].is_01())? sc_lv<2>(): ((tmp_169_reg_51016.read()[0].to_bool())? old_word_buffer_1_4_13_fu_1782.read(): sel_tmp664_fu_29185_p3.read());
}
void a0_bin_conv::thread_sel_tmp666_fu_29199_p3() {
sel_tmp666_fu_29199_p3 = (!tmp_171_reg_51180.read()[0].is_01())? sc_lv<2>(): ((tmp_171_reg_51180.read()[0].to_bool())? old_word_buffer_1_5_13_fu_1818.read(): sel_tmp665_fu_29192_p3.read());
}
void a0_bin_conv::thread_sel_tmp667_fu_34824_p3() {
sel_tmp667_fu_34824_p3 = (!cond6_reg_50242.read()[0].is_01())? sc_lv<2>(): ((cond6_reg_50242.read()[0].to_bool())? old_word_buffer_1_2_30_reg_54317.read(): old_word_buffer_1_7_46_reg_54641.read());
}
void a0_bin_conv::thread_sel_tmp668_fu_34829_p3() {
sel_tmp668_fu_34829_p3 = (!tmp_168_reg_50922.read()[0].is_01())? sc_lv<2>(): ((tmp_168_reg_50922.read()[0].to_bool())? old_word_buffer_1_3_30_reg_54360.read(): sel_tmp667_fu_34824_p3.read());
}
void a0_bin_conv::thread_sel_tmp669_fu_34835_p3() {
sel_tmp669_fu_34835_p3 = (!tmp_169_reg_51016.read()[0].is_01())? sc_lv<2>(): ((tmp_169_reg_51016.read()[0].to_bool())? old_word_buffer_1_4_30_reg_54413.read(): sel_tmp668_fu_34829_p3.read());
}
void a0_bin_conv::thread_sel_tmp670_fu_34841_p3() {
sel_tmp670_fu_34841_p3 = (!tmp_171_reg_51180.read()[0].is_01())? sc_lv<2>(): ((tmp_171_reg_51180.read()[0].to_bool())? old_word_buffer_1_5_30_reg_54476.read(): sel_tmp669_fu_34835_p3.read());
}
void a0_bin_conv::thread_sel_tmp671_fu_29213_p3() {
sel_tmp671_fu_29213_p3 = (!cond6_reg_50242.read()[0].is_01())? sc_lv<2>(): ((cond6_reg_50242.read()[0].to_bool())? old_word_buffer_1_2_15_fu_1718.read(): old_word_buffer_1_7_15_fu_1898.read());
}
void a0_bin_conv::thread_sel_tmp672_fu_29220_p3() {
sel_tmp672_fu_29220_p3 = (!tmp_168_reg_50922.read()[0].is_01())? sc_lv<2>(): ((tmp_168_reg_50922.read()[0].to_bool())? old_word_buffer_1_3_15_fu_1754.read(): sel_tmp671_fu_29213_p3.read());
}
void a0_bin_conv::thread_sel_tmp673_fu_29227_p3() {
sel_tmp673_fu_29227_p3 = (!tmp_169_reg_51016.read()[0].is_01())? sc_lv<2>(): ((tmp_169_reg_51016.read()[0].to_bool())? old_word_buffer_1_4_15_fu_1790.read(): sel_tmp672_fu_29220_p3.read());
}
void a0_bin_conv::thread_sel_tmp674_fu_29234_p3() {
sel_tmp674_fu_29234_p3 = (!tmp_171_reg_51180.read()[0].is_01())? sc_lv<2>(): ((tmp_171_reg_51180.read()[0].to_bool())? old_word_buffer_1_5_15_fu_1826.read(): sel_tmp673_fu_29227_p3.read());
}
void a0_bin_conv::thread_sel_tmp675_fu_34853_p3() {
sel_tmp675_fu_34853_p3 = (!cond6_reg_50242.read()[0].is_01())? sc_lv<2>(): ((cond6_reg_50242.read()[0].to_bool())? old_word_buffer_1_2_31_reg_54325.read(): old_word_buffer_1_7_48_reg_54664.read());
}
void a0_bin_conv::thread_sel_tmp676_fu_34858_p3() {
sel_tmp676_fu_34858_p3 = (!tmp_168_reg_50922.read()[0].is_01())? sc_lv<2>(): ((tmp_168_reg_50922.read()[0].to_bool())? old_word_buffer_1_3_31_reg_54370.read(): sel_tmp675_fu_34853_p3.read());
}
void a0_bin_conv::thread_sel_tmp677_fu_34864_p3() {
sel_tmp677_fu_34864_p3 = (!tmp_169_reg_51016.read()[0].is_01())? sc_lv<2>(): ((tmp_169_reg_51016.read()[0].to_bool())? old_word_buffer_1_4_31_reg_54425.read(): sel_tmp676_fu_34858_p3.read());
}
void a0_bin_conv::thread_sel_tmp678_fu_34870_p3() {
sel_tmp678_fu_34870_p3 = (!tmp_171_reg_51180.read()[0].is_01())? sc_lv<2>(): ((tmp_171_reg_51180.read()[0].to_bool())? old_word_buffer_1_5_31_reg_54490.read(): sel_tmp677_fu_34864_p3.read());
}
void a0_bin_conv::thread_sel_tmp679_fu_24104_p3() {
sel_tmp679_fu_24104_p3 = (!cond6_reg_50242.read()[0].is_01())? sc_lv<2>(): ((cond6_reg_50242.read()[0].to_bool())? old_word_buffer_1_2_17_fu_1726.read(): old_word_buffer_1_7_17_fu_1906.read());
}
void a0_bin_conv::thread_sel_tmp680_fu_24111_p3() {
sel_tmp680_fu_24111_p3 = (!tmp_168_reg_50922.read()[0].is_01())? sc_lv<2>(): ((tmp_168_reg_50922.read()[0].to_bool())? old_word_buffer_1_3_17_fu_1762.read(): sel_tmp679_fu_24104_p3.read());
}
void a0_bin_conv::thread_sel_tmp681_fu_24118_p3() {
sel_tmp681_fu_24118_p3 = (!tmp_169_reg_51016.read()[0].is_01())? sc_lv<2>(): ((tmp_169_reg_51016.read()[0].to_bool())? old_word_buffer_1_4_17_fu_1798.read(): sel_tmp680_fu_24111_p3.read());
}
void a0_bin_conv::thread_sel_tmp682_fu_24125_p3() {
sel_tmp682_fu_24125_p3 = (!tmp_171_reg_51180.read()[0].is_01())? sc_lv<2>(): ((tmp_171_reg_51180.read()[0].to_bool())? old_word_buffer_1_5_17_fu_1834.read(): sel_tmp681_fu_24118_p3.read());
}
void a0_bin_conv::thread_sel_tmp683_fu_34882_p3() {
sel_tmp683_fu_34882_p3 = (!cond6_reg_50242.read()[0].is_01())? sc_lv<2>(): ((cond6_reg_50242.read()[0].to_bool())? old_word_buffer_1_2_32_reg_54333.read(): ap_reg_pp0_iter2_old_word_buffer_1_7_42_reg_52212.read());
}
void a0_bin_conv::thread_sel_tmp684_fu_34887_p3() {
sel_tmp684_fu_34887_p3 = (!tmp_168_reg_50922.read()[0].is_01())? sc_lv<2>(): ((tmp_168_reg_50922.read()[0].to_bool())? old_word_buffer_1_3_32_reg_54380.read(): sel_tmp683_fu_34882_p3.read());
}
void a0_bin_conv::thread_sel_tmp685_fu_34893_p3() {
sel_tmp685_fu_34893_p3 = (!tmp_169_reg_51016.read()[0].is_01())? sc_lv<2>(): ((tmp_169_reg_51016.read()[0].to_bool())? old_word_buffer_1_4_32_reg_54437.read(): sel_tmp684_fu_34887_p3.read());
}
void a0_bin_conv::thread_sel_tmp686_fu_34899_p3() {
sel_tmp686_fu_34899_p3 = (!tmp_171_reg_51180.read()[0].is_01())? sc_lv<2>(): ((tmp_171_reg_51180.read()[0].to_bool())? old_word_buffer_1_5_32_reg_54504.read(): sel_tmp685_fu_34893_p3.read());
}
void a0_bin_conv::thread_sel_tmp687_fu_29248_p3() {
sel_tmp687_fu_29248_p3 = (!tmp_1225_reg_45756.read()[0].is_01())? sc_lv<2>(): ((tmp_1225_reg_45756.read()[0].to_bool())? old_word_buffer_1_7_fu_714.read(): ap_const_lv2_0);
}
void a0_bin_conv::thread_sel_tmp688_fu_29255_p3() {
sel_tmp688_fu_29255_p3 = (!sel_tmp79_reg_51283.read()[0].is_01())? sc_lv<2>(): ((sel_tmp79_reg_51283.read()[0].to_bool())? old_word_buffer_1_3_fu_698.read(): sel_tmp687_fu_29248_p3.read());
}
void a0_bin_conv::thread_sel_tmp689_fu_29262_p3() {
sel_tmp689_fu_29262_p3 = (!sel_tmp80_reg_51289.read()[0].is_01())? sc_lv<2>(): ((sel_tmp80_reg_51289.read()[0].to_bool())? old_word_buffer_1_4_fu_702.read(): sel_tmp688_fu_29255_p3.read());
}
void a0_bin_conv::thread_sel_tmp690_fu_29269_p3() {
sel_tmp690_fu_29269_p3 = (!sel_tmp81_reg_51295.read()[0].is_01())? sc_lv<2>(): ((sel_tmp81_reg_51295.read()[0].to_bool())? old_word_buffer_1_5_fu_706.read(): sel_tmp689_fu_29262_p3.read());
}
void a0_bin_conv::thread_sel_tmp691_fu_29276_p3() {
sel_tmp691_fu_29276_p3 = (!sel_tmp82_reg_51301.read()[0].is_01())? sc_lv<2>(): ((sel_tmp82_reg_51301.read()[0].to_bool())? old_word_buffer_1_6_fu_710.read(): sel_tmp690_fu_29269_p3.read());
}
void a0_bin_conv::thread_sel_tmp692_fu_29364_p3() {
sel_tmp692_fu_29364_p3 = (!cond6_reg_50242.read()[0].is_01())? sc_lv<2>(): ((cond6_reg_50242.read()[0].to_bool())? old_word_buffer_1_3_11_fu_1738.read(): old_word_buffer_1_7_11_fu_1882.read());
}
void a0_bin_conv::thread_sel_tmp693_fu_29371_p3() {
sel_tmp693_fu_29371_p3 = (!tmp_168_reg_50922.read()[0].is_01())? sc_lv<2>(): ((tmp_168_reg_50922.read()[0].to_bool())? old_word_buffer_1_4_11_fu_1774.read(): sel_tmp692_fu_29364_p3.read());
}
void a0_bin_conv::thread_sel_tmp694_fu_29378_p3() {
sel_tmp694_fu_29378_p3 = (!tmp_169_reg_51016.read()[0].is_01())? sc_lv<2>(): ((tmp_169_reg_51016.read()[0].to_bool())? old_word_buffer_1_5_11_fu_1810.read(): sel_tmp693_fu_29371_p3.read());
}
void a0_bin_conv::thread_sel_tmp695_fu_34961_p3() {
sel_tmp695_fu_34961_p3 = (!cond6_reg_50242.read()[0].is_01())? sc_lv<2>(): ((cond6_reg_50242.read()[0].to_bool())? old_word_buffer_1_3_29_reg_54350.read(): old_word_buffer_1_7_44_reg_54617.read());
}
void a0_bin_conv::thread_sel_tmp696_fu_34966_p3() {
sel_tmp696_fu_34966_p3 = (!tmp_168_reg_50922.read()[0].is_01())? sc_lv<2>(): ((tmp_168_reg_50922.read()[0].to_bool())? old_word_buffer_1_4_29_reg_54401.read(): sel_tmp695_fu_34961_p3.read());
}
void a0_bin_conv::thread_sel_tmp697_fu_34972_p3() {
sel_tmp697_fu_34972_p3 = (!tmp_169_reg_51016.read()[0].is_01())? sc_lv<2>(): ((tmp_169_reg_51016.read()[0].to_bool())? old_word_buffer_1_5_29_reg_54462.read(): sel_tmp696_fu_34966_p3.read());
}
void a0_bin_conv::thread_sel_tmp698_fu_29392_p3() {
sel_tmp698_fu_29392_p3 = (!cond6_reg_50242.read()[0].is_01())? sc_lv<2>(): ((cond6_reg_50242.read()[0].to_bool())? old_word_buffer_1_3_13_fu_1746.read(): old_word_buffer_1_7_13_fu_1890.read());
}
void a0_bin_conv::thread_sel_tmp699_fu_29399_p3() {
sel_tmp699_fu_29399_p3 = (!tmp_168_reg_50922.read()[0].is_01())? sc_lv<2>(): ((tmp_168_reg_50922.read()[0].to_bool())? old_word_buffer_1_4_13_fu_1782.read(): sel_tmp698_fu_29392_p3.read());
}
void a0_bin_conv::thread_sel_tmp700_fu_29406_p3() {
sel_tmp700_fu_29406_p3 = (!tmp_169_reg_51016.read()[0].is_01())? sc_lv<2>(): ((tmp_169_reg_51016.read()[0].to_bool())? old_word_buffer_1_5_13_fu_1818.read(): sel_tmp699_fu_29399_p3.read());
}
void a0_bin_conv::thread_sel_tmp701_fu_34984_p3() {
sel_tmp701_fu_34984_p3 = (!cond6_reg_50242.read()[0].is_01())? sc_lv<2>(): ((cond6_reg_50242.read()[0].to_bool())? old_word_buffer_1_3_30_reg_54360.read(): old_word_buffer_1_7_46_reg_54641.read());
}
void a0_bin_conv::thread_sel_tmp702_fu_34989_p3() {
sel_tmp702_fu_34989_p3 = (!tmp_168_reg_50922.read()[0].is_01())? sc_lv<2>(): ((tmp_168_reg_50922.read()[0].to_bool())? old_word_buffer_1_4_30_reg_54413.read(): sel_tmp701_fu_34984_p3.read());
}
void a0_bin_conv::thread_sel_tmp703_fu_34995_p3() {
sel_tmp703_fu_34995_p3 = (!tmp_169_reg_51016.read()[0].is_01())? sc_lv<2>(): ((tmp_169_reg_51016.read()[0].to_bool())? old_word_buffer_1_5_30_reg_54476.read(): sel_tmp702_fu_34989_p3.read());
}
void a0_bin_conv::thread_sel_tmp704_fu_29420_p3() {
sel_tmp704_fu_29420_p3 = (!cond6_reg_50242.read()[0].is_01())? sc_lv<2>(): ((cond6_reg_50242.read()[0].to_bool())? old_word_buffer_1_3_15_fu_1754.read(): old_word_buffer_1_7_15_fu_1898.read());
}
void a0_bin_conv::thread_sel_tmp705_fu_29427_p3() {
sel_tmp705_fu_29427_p3 = (!tmp_168_reg_50922.read()[0].is_01())? sc_lv<2>(): ((tmp_168_reg_50922.read()[0].to_bool())? old_word_buffer_1_4_15_fu_1790.read(): sel_tmp704_fu_29420_p3.read());
}
void a0_bin_conv::thread_sel_tmp706_fu_29434_p3() {
sel_tmp706_fu_29434_p3 = (!tmp_169_reg_51016.read()[0].is_01())? sc_lv<2>(): ((tmp_169_reg_51016.read()[0].to_bool())? old_word_buffer_1_5_15_fu_1826.read(): sel_tmp705_fu_29427_p3.read());
}
void a0_bin_conv::thread_sel_tmp707_fu_35007_p3() {
sel_tmp707_fu_35007_p3 = (!cond6_reg_50242.read()[0].is_01())? sc_lv<2>(): ((cond6_reg_50242.read()[0].to_bool())? old_word_buffer_1_3_31_reg_54370.read(): old_word_buffer_1_7_48_reg_54664.read());
}
void a0_bin_conv::thread_sel_tmp708_fu_35012_p3() {
sel_tmp708_fu_35012_p3 = (!tmp_168_reg_50922.read()[0].is_01())? sc_lv<2>(): ((tmp_168_reg_50922.read()[0].to_bool())? old_word_buffer_1_4_31_reg_54425.read(): sel_tmp707_fu_35007_p3.read());
}
void a0_bin_conv::thread_sel_tmp709_fu_35018_p3() {
sel_tmp709_fu_35018_p3 = (!tmp_169_reg_51016.read()[0].is_01())? sc_lv<2>(): ((tmp_169_reg_51016.read()[0].to_bool())? old_word_buffer_1_5_31_reg_54490.read(): sel_tmp708_fu_35012_p3.read());
}
void a0_bin_conv::thread_sel_tmp710_fu_24142_p3() {
sel_tmp710_fu_24142_p3 = (!cond6_reg_50242.read()[0].is_01())? sc_lv<2>(): ((cond6_reg_50242.read()[0].to_bool())? old_word_buffer_1_3_17_fu_1762.read(): old_word_buffer_1_7_17_fu_1906.read());
}
void a0_bin_conv::thread_sel_tmp711_fu_24149_p3() {
sel_tmp711_fu_24149_p3 = (!tmp_168_reg_50922.read()[0].is_01())? sc_lv<2>(): ((tmp_168_reg_50922.read()[0].to_bool())? old_word_buffer_1_4_17_fu_1798.read(): sel_tmp710_fu_24142_p3.read());
}
void a0_bin_conv::thread_sel_tmp712_fu_24156_p3() {
sel_tmp712_fu_24156_p3 = (!tmp_169_reg_51016.read()[0].is_01())? sc_lv<2>(): ((tmp_169_reg_51016.read()[0].to_bool())? old_word_buffer_1_5_17_fu_1834.read(): sel_tmp711_fu_24149_p3.read());
}
void a0_bin_conv::thread_sel_tmp713_fu_35030_p3() {
sel_tmp713_fu_35030_p3 = (!cond6_reg_50242.read()[0].is_01())? sc_lv<2>(): ((cond6_reg_50242.read()[0].to_bool())? old_word_buffer_1_3_32_reg_54380.read(): ap_reg_pp0_iter2_old_word_buffer_1_7_42_reg_52212.read());
}
void a0_bin_conv::thread_sel_tmp714_fu_35035_p3() {
sel_tmp714_fu_35035_p3 = (!tmp_168_reg_50922.read()[0].is_01())? sc_lv<2>(): ((tmp_168_reg_50922.read()[0].to_bool())? old_word_buffer_1_4_32_reg_54437.read(): sel_tmp713_fu_35030_p3.read());
}
void a0_bin_conv::thread_sel_tmp715_fu_35041_p3() {
sel_tmp715_fu_35041_p3 = (!tmp_169_reg_51016.read()[0].is_01())? sc_lv<2>(): ((tmp_169_reg_51016.read()[0].to_bool())? old_word_buffer_1_5_32_reg_54504.read(): sel_tmp714_fu_35035_p3.read());
}
void a0_bin_conv::thread_sel_tmp716_fu_29448_p3() {
sel_tmp716_fu_29448_p3 = (!tmp_1227_reg_45800.read()[0].is_01())? sc_lv<2>(): ((tmp_1227_reg_45800.read()[0].to_bool())? old_word_buffer_1_7_fu_714.read(): ap_const_lv2_0);
}
void a0_bin_conv::thread_sel_tmp717_fu_29455_p3() {
sel_tmp717_fu_29455_p3 = (!sel_tmp84_reg_51313.read()[0].is_01())? sc_lv<2>(): ((sel_tmp84_reg_51313.read()[0].to_bool())? old_word_buffer_1_4_fu_702.read(): sel_tmp716_fu_29448_p3.read());
}
void a0_bin_conv::thread_sel_tmp718_fu_29462_p3() {
sel_tmp718_fu_29462_p3 = (!sel_tmp85_reg_51319.read()[0].is_01())? sc_lv<2>(): ((sel_tmp85_reg_51319.read()[0].to_bool())? old_word_buffer_1_5_fu_706.read(): sel_tmp717_fu_29455_p3.read());
}
void a0_bin_conv::thread_sel_tmp719_fu_29469_p3() {
sel_tmp719_fu_29469_p3 = (!sel_tmp86_reg_51325.read()[0].is_01())? sc_lv<2>(): ((sel_tmp86_reg_51325.read()[0].to_bool())? old_word_buffer_1_6_fu_710.read(): sel_tmp718_fu_29462_p3.read());
}
void a0_bin_conv::thread_sel_tmp720_fu_29290_p3() {
sel_tmp720_fu_29290_p3 = (!tmp_167_reg_50852.read()[0].is_01())? sc_lv<2>(): ((tmp_167_reg_50852.read()[0].to_bool())? word_buffer_1_0_1_1_fu_25795_p3.read(): word_buffer_1_2_1_fu_25723_p3.read());
}
void a0_bin_conv::thread_sel_tmp721_fu_29304_p3() {
sel_tmp721_fu_29304_p3 = (!tmp_167_reg_50852.read()[0].is_01())? sc_lv<2>(): ((tmp_167_reg_50852.read()[0].to_bool())? word_buffer_1_0_3_1_fu_25782_p3.read(): word_buffer_1_2_3_1_reg_52882.read());
}
void a0_bin_conv::thread_sel_tmp722_fu_29316_p3() {
sel_tmp722_fu_29316_p3 = (!tmp_167_reg_50852.read()[0].is_01())? sc_lv<2>(): ((tmp_167_reg_50852.read()[0].to_bool())? word_buffer_1_0_5_1_fu_25769_p3.read(): word_buffer_1_2_5_1_reg_52848.read());
}
void a0_bin_conv::thread_sel_tmp723_fu_29328_p3() {
sel_tmp723_fu_29328_p3 = (!tmp_167_reg_50852.read()[0].is_01())? sc_lv<2>(): ((tmp_167_reg_50852.read()[0].to_bool())? word_buffer_1_0_7_1_fu_25756_p3.read(): word_buffer_1_2_7_1_reg_52815.read());
}
void a0_bin_conv::thread_sel_tmp724_fu_34920_p2() {
sel_tmp724_fu_34920_p2 = (tmp_1227_reg_45800.read() & last_wrd_not1_fu_34915_p2.read());
}
void a0_bin_conv::thread_sel_tmp725_fu_34925_p2() {
sel_tmp725_fu_34925_p2 = (tmp_167_reg_50852.read() & sel_tmp724_fu_34920_p2.read());
}
void a0_bin_conv::thread_sel_tmp726_fu_34930_p3() {
sel_tmp726_fu_34930_p3 = (!sel_tmp725_fu_34925_p2.read()[0].is_01())? sc_lv<2>(): ((sel_tmp725_fu_34925_p2.read()[0].to_bool())? ap_const_lv2_0: word_buffer_1_2_0_1_reg_55582.read());
}
void a0_bin_conv::thread_sel_tmp727_fu_34937_p2() {
sel_tmp727_fu_34937_p2 = (cond1_reg_50498.read() & sel_tmp724_fu_34920_p2.read());
}
void a0_bin_conv::thread_sel_tmp728_fu_34942_p3() {
sel_tmp728_fu_34942_p3 = (!sel_tmp727_fu_34937_p2.read()[0].is_01())? sc_lv<2>(): ((sel_tmp727_fu_34937_p2.read()[0].to_bool())? word_buffer_1_1_0_reg_54929.read(): sel_tmp726_fu_34930_p3.read());
}
void a0_bin_conv::thread_sel_tmp729_fu_29588_p3() {
sel_tmp729_fu_29588_p3 = (!cond6_reg_50242.read()[0].is_01())? sc_lv<2>(): ((cond6_reg_50242.read()[0].to_bool())? old_word_buffer_1_4_11_fu_1774.read(): old_word_buffer_1_7_11_fu_1882.read());
}
void a0_bin_conv::thread_sel_tmp730_fu_29595_p3() {
sel_tmp730_fu_29595_p3 = (!tmp_168_reg_50922.read()[0].is_01())? sc_lv<2>(): ((tmp_168_reg_50922.read()[0].to_bool())? old_word_buffer_1_5_11_fu_1810.read(): sel_tmp729_fu_29588_p3.read());
}
void a0_bin_conv::thread_sel_tmp731_fu_35111_p3() {
sel_tmp731_fu_35111_p3 = (!cond6_reg_50242.read()[0].is_01())? sc_lv<2>(): ((cond6_reg_50242.read()[0].to_bool())? old_word_buffer_1_4_29_reg_54401.read(): old_word_buffer_1_7_44_reg_54617.read());
}
void a0_bin_conv::thread_sel_tmp732_fu_35116_p3() {
sel_tmp732_fu_35116_p3 = (!tmp_168_reg_50922.read()[0].is_01())? sc_lv<2>(): ((tmp_168_reg_50922.read()[0].to_bool())? old_word_buffer_1_5_29_reg_54462.read(): sel_tmp731_fu_35111_p3.read());
}
void a0_bin_conv::thread_sel_tmp733_fu_29609_p3() {
sel_tmp733_fu_29609_p3 = (!cond6_reg_50242.read()[0].is_01())? sc_lv<2>(): ((cond6_reg_50242.read()[0].to_bool())? old_word_buffer_1_4_13_fu_1782.read(): old_word_buffer_1_7_13_fu_1890.read());
}
void a0_bin_conv::thread_sel_tmp734_fu_29616_p3() {
sel_tmp734_fu_29616_p3 = (!tmp_168_reg_50922.read()[0].is_01())? sc_lv<2>(): ((tmp_168_reg_50922.read()[0].to_bool())? old_word_buffer_1_5_13_fu_1818.read(): sel_tmp733_fu_29609_p3.read());
}
void a0_bin_conv::thread_sel_tmp735_fu_35128_p3() {
sel_tmp735_fu_35128_p3 = (!cond6_reg_50242.read()[0].is_01())? sc_lv<2>(): ((cond6_reg_50242.read()[0].to_bool())? old_word_buffer_1_4_30_reg_54413.read(): old_word_buffer_1_7_46_reg_54641.read());
}
void a0_bin_conv::thread_sel_tmp736_fu_35133_p3() {
sel_tmp736_fu_35133_p3 = (!tmp_168_reg_50922.read()[0].is_01())? sc_lv<2>(): ((tmp_168_reg_50922.read()[0].to_bool())? old_word_buffer_1_5_30_reg_54476.read(): sel_tmp735_fu_35128_p3.read());
}
void a0_bin_conv::thread_sel_tmp737_fu_29630_p3() {
sel_tmp737_fu_29630_p3 = (!cond6_reg_50242.read()[0].is_01())? sc_lv<2>(): ((cond6_reg_50242.read()[0].to_bool())? old_word_buffer_1_4_15_fu_1790.read(): old_word_buffer_1_7_15_fu_1898.read());
}
void a0_bin_conv::thread_sel_tmp738_fu_29637_p3() {
sel_tmp738_fu_29637_p3 = (!tmp_168_reg_50922.read()[0].is_01())? sc_lv<2>(): ((tmp_168_reg_50922.read()[0].to_bool())? old_word_buffer_1_5_15_fu_1826.read(): sel_tmp737_fu_29630_p3.read());
}
void a0_bin_conv::thread_sel_tmp739_fu_35145_p3() {
sel_tmp739_fu_35145_p3 = (!cond6_reg_50242.read()[0].is_01())? sc_lv<2>(): ((cond6_reg_50242.read()[0].to_bool())? old_word_buffer_1_4_31_reg_54425.read(): old_word_buffer_1_7_48_reg_54664.read());
}
void a0_bin_conv::thread_sel_tmp740_fu_35150_p3() {
sel_tmp740_fu_35150_p3 = (!tmp_168_reg_50922.read()[0].is_01())? sc_lv<2>(): ((tmp_168_reg_50922.read()[0].to_bool())? old_word_buffer_1_5_31_reg_54490.read(): sel_tmp739_fu_35145_p3.read());
}
void a0_bin_conv::thread_sel_tmp741_fu_24176_p3() {
sel_tmp741_fu_24176_p3 = (!cond6_reg_50242.read()[0].is_01())? sc_lv<2>(): ((cond6_reg_50242.read()[0].to_bool())? old_word_buffer_1_4_17_fu_1798.read(): old_word_buffer_1_7_17_fu_1906.read());
}
void a0_bin_conv::thread_sel_tmp742_fu_24183_p3() {
sel_tmp742_fu_24183_p3 = (!tmp_168_reg_50922.read()[0].is_01())? sc_lv<2>(): ((tmp_168_reg_50922.read()[0].to_bool())? old_word_buffer_1_5_17_fu_1834.read(): sel_tmp741_fu_24176_p3.read());
}
void a0_bin_conv::thread_sel_tmp743_fu_35162_p3() {
sel_tmp743_fu_35162_p3 = (!cond6_reg_50242.read()[0].is_01())? sc_lv<2>(): ((cond6_reg_50242.read()[0].to_bool())? old_word_buffer_1_4_32_reg_54437.read(): ap_reg_pp0_iter2_old_word_buffer_1_7_42_reg_52212.read());
}
void a0_bin_conv::thread_sel_tmp744_fu_35167_p3() {
sel_tmp744_fu_35167_p3 = (!tmp_168_reg_50922.read()[0].is_01())? sc_lv<2>(): ((tmp_168_reg_50922.read()[0].to_bool())? old_word_buffer_1_5_32_reg_54504.read(): sel_tmp743_fu_35162_p3.read());
}
void a0_bin_conv::thread_sel_tmp745_fu_29651_p3() {
sel_tmp745_fu_29651_p3 = (!lb_3_reg_45835.read()[0].is_01())? sc_lv<2>(): ((lb_3_reg_45835.read()[0].to_bool())? ap_const_lv2_0: old_word_buffer_1_7_fu_714.read());
}
void a0_bin_conv::thread_sel_tmp746_fu_29658_p3() {
sel_tmp746_fu_29658_p3 = (!sel_tmp89_reg_51337.read()[0].is_01())? sc_lv<2>(): ((sel_tmp89_reg_51337.read()[0].to_bool())? old_word_buffer_1_5_fu_706.read(): sel_tmp745_fu_29651_p3.read());
}
void a0_bin_conv::thread_sel_tmp747_fu_29665_p3() {
sel_tmp747_fu_29665_p3 = (!sel_tmp90_reg_51343.read()[0].is_01())? sc_lv<2>(): ((sel_tmp90_reg_51343.read()[0].to_bool())? old_word_buffer_1_6_fu_710.read(): sel_tmp746_fu_29658_p3.read());
}
void a0_bin_conv::thread_sel_tmp748_fu_29483_p3() {
sel_tmp748_fu_29483_p3 = (!tmp_170_reg_51104.read()[0].is_01())? sc_lv<2>(): ((tmp_170_reg_51104.read()[0].to_bool())? word_buffer_1_0_1_1_fu_25795_p3.read(): word_buffer_1_3_1_fu_25697_p3.read());
}
void a0_bin_conv::thread_sel_tmp749_fu_29490_p3() {
sel_tmp749_fu_29490_p3 = (!tmp_167_reg_50852.read()[0].is_01())? sc_lv<2>(): ((tmp_167_reg_50852.read()[0].to_bool())? word_buffer_1_1_1_fu_25730_p3.read(): sel_tmp748_fu_29483_p3.read());
}
void a0_bin_conv::thread_sel_tmp750_fu_29504_p3() {
sel_tmp750_fu_29504_p3 = (!tmp_170_reg_51104.read()[0].is_01())? sc_lv<2>(): ((tmp_170_reg_51104.read()[0].to_bool())? word_buffer_1_0_3_1_fu_25782_p3.read(): word_buffer_1_3_3_1_reg_52785.read());
}
void a0_bin_conv::thread_sel_tmp751_fu_29510_p3() {
sel_tmp751_fu_29510_p3 = (!tmp_167_reg_50852.read()[0].is_01())? sc_lv<2>(): ((tmp_167_reg_50852.read()[0].to_bool())? word_buffer_1_1_3_1_reg_52991.read(): sel_tmp750_fu_29504_p3.read());
}
void a0_bin_conv::thread_sel_tmp752_fu_29522_p3() {
sel_tmp752_fu_29522_p3 = (!tmp_170_reg_51104.read()[0].is_01())? sc_lv<2>(): ((tmp_170_reg_51104.read()[0].to_bool())? word_buffer_1_0_5_1_fu_25769_p3.read(): word_buffer_1_3_5_1_reg_52755.read());
}
void a0_bin_conv::thread_sel_tmp753_fu_29528_p3() {
sel_tmp753_fu_29528_p3 = (!tmp_167_reg_50852.read()[0].is_01())? sc_lv<2>(): ((tmp_167_reg_50852.read()[0].to_bool())? word_buffer_1_1_5_1_reg_52953.read(): sel_tmp752_fu_29522_p3.read());
}
void a0_bin_conv::thread_sel_tmp754_fu_29540_p3() {
sel_tmp754_fu_29540_p3 = (!tmp_170_reg_51104.read()[0].is_01())? sc_lv<2>(): ((tmp_170_reg_51104.read()[0].to_bool())? word_buffer_1_0_7_1_fu_25756_p3.read(): word_buffer_1_3_7_1_reg_52726.read());
}
void a0_bin_conv::thread_sel_tmp755_fu_29546_p3() {
sel_tmp755_fu_29546_p3 = (!tmp_167_reg_50852.read()[0].is_01())? sc_lv<2>(): ((tmp_167_reg_50852.read()[0].to_bool())? word_buffer_1_1_7_1_reg_52916.read(): sel_tmp754_fu_29540_p3.read());
}
void a0_bin_conv::thread_sel_tmp756_fu_35057_p2() {
sel_tmp756_fu_35057_p2 = (brmerge32_fu_35053_p2.read() ^ ap_const_lv1_1);
}
void a0_bin_conv::thread_sel_tmp757_fu_35063_p2() {
sel_tmp757_fu_35063_p2 = (tmp_170_reg_51104.read() & sel_tmp756_fu_35057_p2.read());
}
void a0_bin_conv::thread_sel_tmp758_fu_35068_p3() {
sel_tmp758_fu_35068_p3 = (!sel_tmp757_fu_35063_p2.read()[0].is_01())? sc_lv<2>(): ((sel_tmp757_fu_35063_p2.read()[0].to_bool())? ap_const_lv2_0: word_buffer_1_3_0_reg_54858.read());
}
void a0_bin_conv::thread_sel_tmp759_fu_35075_p2() {
sel_tmp759_fu_35075_p2 = (tmp_167_reg_50852.read() & sel_tmp756_fu_35057_p2.read());
}
void a0_bin_conv::thread_sel_tmp760_fu_35080_p3() {
sel_tmp760_fu_35080_p3 = (!sel_tmp759_fu_35075_p2.read()[0].is_01())? sc_lv<2>(): ((sel_tmp759_fu_35075_p2.read()[0].to_bool())? word_buffer_1_1_0_reg_54929.read(): sel_tmp758_fu_35068_p3.read());
}
void a0_bin_conv::thread_sel_tmp761_fu_35087_p2() {
sel_tmp761_fu_35087_p2 = (cond1_reg_50498.read() & sel_tmp756_fu_35057_p2.read());
}
void a0_bin_conv::thread_sel_tmp762_fu_35092_p3() {
sel_tmp762_fu_35092_p3 = (!sel_tmp761_fu_35087_p2.read()[0].is_01())? sc_lv<2>(): ((sel_tmp761_fu_35087_p2.read()[0].to_bool())? word_buffer_1_2_0_1_reg_55582.read(): sel_tmp760_fu_35080_p3.read());
}
void a0_bin_conv::thread_sel_tmp763_fu_29810_p3() {
sel_tmp763_fu_29810_p3 = (!cond6_reg_50242.read()[0].is_01())? sc_lv<2>(): ((cond6_reg_50242.read()[0].to_bool())? old_word_buffer_1_5_11_fu_1810.read(): old_word_buffer_1_7_11_fu_1882.read());
}
void a0_bin_conv::thread_sel_tmp764_fu_35243_p3() {
sel_tmp764_fu_35243_p3 = (!cond6_reg_50242.read()[0].is_01())? sc_lv<2>(): ((cond6_reg_50242.read()[0].to_bool())? old_word_buffer_1_5_29_reg_54462.read(): old_word_buffer_1_7_44_reg_54617.read());
}
void a0_bin_conv::thread_sel_tmp765_fu_29824_p3() {
sel_tmp765_fu_29824_p3 = (!cond6_reg_50242.read()[0].is_01())? sc_lv<2>(): ((cond6_reg_50242.read()[0].to_bool())? old_word_buffer_1_5_13_fu_1818.read(): old_word_buffer_1_7_13_fu_1890.read());
}
void a0_bin_conv::thread_sel_tmp766_fu_35254_p3() {
sel_tmp766_fu_35254_p3 = (!cond6_reg_50242.read()[0].is_01())? sc_lv<2>(): ((cond6_reg_50242.read()[0].to_bool())? old_word_buffer_1_5_30_reg_54476.read(): old_word_buffer_1_7_46_reg_54641.read());
}
void a0_bin_conv::thread_sel_tmp767_fu_29838_p3() {
sel_tmp767_fu_29838_p3 = (!cond6_reg_50242.read()[0].is_01())? sc_lv<2>(): ((cond6_reg_50242.read()[0].to_bool())? old_word_buffer_1_5_15_fu_1826.read(): old_word_buffer_1_7_15_fu_1898.read());
}
void a0_bin_conv::thread_sel_tmp768_fu_35265_p3() {
sel_tmp768_fu_35265_p3 = (!cond6_reg_50242.read()[0].is_01())? sc_lv<2>(): ((cond6_reg_50242.read()[0].to_bool())? old_word_buffer_1_5_31_reg_54490.read(): old_word_buffer_1_7_48_reg_54664.read());
}
void a0_bin_conv::thread_sel_tmp769_fu_24203_p3() {
sel_tmp769_fu_24203_p3 = (!cond6_reg_50242.read()[0].is_01())? sc_lv<2>(): ((cond6_reg_50242.read()[0].to_bool())? old_word_buffer_1_5_17_fu_1834.read(): old_word_buffer_1_7_17_fu_1906.read());
}
void a0_bin_conv::thread_sel_tmp770_fu_35276_p3() {
sel_tmp770_fu_35276_p3 = (!cond6_reg_50242.read()[0].is_01())? sc_lv<2>(): ((cond6_reg_50242.read()[0].to_bool())? old_word_buffer_1_5_32_reg_54504.read(): ap_reg_pp0_iter2_old_word_buffer_1_7_42_reg_52212.read());
}
void a0_bin_conv::thread_sel_tmp771_fu_29852_p3() {
sel_tmp771_fu_29852_p3 = (!lb_4_reg_45859.read()[0].is_01())? sc_lv<2>(): ((lb_4_reg_45859.read()[0].to_bool())? ap_const_lv2_0: old_word_buffer_1_7_fu_714.read());
}
void a0_bin_conv::thread_sel_tmp772_fu_29859_p3() {
sel_tmp772_fu_29859_p3 = (!sel_tmp93_reg_51355.read()[0].is_01())? sc_lv<2>(): ((sel_tmp93_reg_51355.read()[0].to_bool())? old_word_buffer_1_6_fu_710.read(): sel_tmp771_fu_29852_p3.read());
}
void a0_bin_conv::thread_sel_tmp773_fu_29679_p3() {
sel_tmp773_fu_29679_p3 = (!tmp_171_reg_51180.read()[0].is_01())? sc_lv<2>(): ((tmp_171_reg_51180.read()[0].to_bool())? word_buffer_1_0_1_1_fu_25795_p3.read(): word_buffer_1_4_1_fu_25671_p3.read());
}
void a0_bin_conv::thread_sel_tmp774_fu_29686_p3() {
sel_tmp774_fu_29686_p3 = (!tmp_170_reg_51104.read()[0].is_01())? sc_lv<2>(): ((tmp_170_reg_51104.read()[0].to_bool())? word_buffer_1_1_1_fu_25730_p3.read(): sel_tmp773_fu_29679_p3.read());
}
void a0_bin_conv::thread_sel_tmp775_fu_29693_p3() {
sel_tmp775_fu_29693_p3 = (!tmp_167_reg_50852.read()[0].is_01())? sc_lv<2>(): ((tmp_167_reg_50852.read()[0].to_bool())? word_buffer_1_2_1_fu_25723_p3.read(): sel_tmp774_fu_29686_p3.read());
}
void a0_bin_conv::thread_sel_tmp776_fu_29707_p3() {
sel_tmp776_fu_29707_p3 = (!tmp_171_reg_51180.read()[0].is_01())? sc_lv<2>(): ((tmp_171_reg_51180.read()[0].to_bool())? word_buffer_1_0_3_1_fu_25782_p3.read(): word_buffer_1_4_3_1_reg_52700.read());
}
void a0_bin_conv::thread_sel_tmp777_fu_29713_p3() {
sel_tmp777_fu_29713_p3 = (!tmp_170_reg_51104.read()[0].is_01())? sc_lv<2>(): ((tmp_170_reg_51104.read()[0].to_bool())? word_buffer_1_1_3_1_reg_52991.read(): sel_tmp776_fu_29707_p3.read());
}
void a0_bin_conv::thread_sel_tmp778_fu_29719_p3() {
sel_tmp778_fu_29719_p3 = (!tmp_167_reg_50852.read()[0].is_01())? sc_lv<2>(): ((tmp_167_reg_50852.read()[0].to_bool())? word_buffer_1_2_3_1_reg_52882.read(): sel_tmp777_fu_29713_p3.read());
}
void a0_bin_conv::thread_sel_tmp779_fu_29731_p3() {
sel_tmp779_fu_29731_p3 = (!tmp_171_reg_51180.read()[0].is_01())? sc_lv<2>(): ((tmp_171_reg_51180.read()[0].to_bool())? word_buffer_1_0_5_1_fu_25769_p3.read(): word_buffer_1_4_5_1_reg_52674.read());
}
void a0_bin_conv::thread_sel_tmp780_fu_29737_p3() {
sel_tmp780_fu_29737_p3 = (!tmp_170_reg_51104.read()[0].is_01())? sc_lv<2>(): ((tmp_170_reg_51104.read()[0].to_bool())? word_buffer_1_1_5_1_reg_52953.read(): sel_tmp779_fu_29731_p3.read());
}
void a0_bin_conv::thread_sel_tmp781_fu_29743_p3() {
sel_tmp781_fu_29743_p3 = (!tmp_167_reg_50852.read()[0].is_01())? sc_lv<2>(): ((tmp_167_reg_50852.read()[0].to_bool())? word_buffer_1_2_5_1_reg_52848.read(): sel_tmp780_fu_29737_p3.read());
}
void a0_bin_conv::thread_sel_tmp782_fu_29755_p3() {
sel_tmp782_fu_29755_p3 = (!tmp_171_reg_51180.read()[0].is_01())? sc_lv<2>(): ((tmp_171_reg_51180.read()[0].to_bool())? word_buffer_1_0_7_1_fu_25756_p3.read(): word_buffer_1_4_7_1_reg_52649.read());
}
void a0_bin_conv::thread_sel_tmp783_fu_29761_p3() {
sel_tmp783_fu_29761_p3 = (!tmp_170_reg_51104.read()[0].is_01())? sc_lv<2>(): ((tmp_170_reg_51104.read()[0].to_bool())? word_buffer_1_1_7_1_reg_52916.read(): sel_tmp782_fu_29755_p3.read());
}
void a0_bin_conv::thread_sel_tmp784_fu_29767_p3() {
sel_tmp784_fu_29767_p3 = (!tmp_167_reg_50852.read()[0].is_01())? sc_lv<2>(): ((tmp_167_reg_50852.read()[0].to_bool())? word_buffer_1_2_7_1_reg_52815.read(): sel_tmp783_fu_29761_p3.read());
}
void a0_bin_conv::thread_sel_tmp785_fu_35179_p2() {
sel_tmp785_fu_35179_p2 = (brmerge34_reg_56771.read() ^ ap_const_lv1_1);
}
void a0_bin_conv::thread_sel_tmp786_fu_35184_p2() {
sel_tmp786_fu_35184_p2 = (tmp_171_reg_51180.read() & sel_tmp785_fu_35179_p2.read());
}
void a0_bin_conv::thread_sel_tmp787_fu_35189_p3() {
sel_tmp787_fu_35189_p3 = (!sel_tmp786_fu_35184_p2.read()[0].is_01())? sc_lv<2>(): ((sel_tmp786_fu_35184_p2.read()[0].to_bool())? ap_const_lv2_0: word_buffer_1_4_0_reg_54806.read());
}
void a0_bin_conv::thread_sel_tmp788_fu_35196_p2() {
sel_tmp788_fu_35196_p2 = (tmp_170_reg_51104.read() & sel_tmp785_fu_35179_p2.read());
}
void a0_bin_conv::thread_sel_tmp789_fu_35201_p3() {
sel_tmp789_fu_35201_p3 = (!sel_tmp788_fu_35196_p2.read()[0].is_01())? sc_lv<2>(): ((sel_tmp788_fu_35196_p2.read()[0].to_bool())? word_buffer_1_1_0_reg_54929.read(): sel_tmp787_fu_35189_p3.read());
}
void a0_bin_conv::thread_sel_tmp790_fu_35208_p2() {
sel_tmp790_fu_35208_p2 = (tmp_167_reg_50852.read() & sel_tmp785_fu_35179_p2.read());
}
void a0_bin_conv::thread_sel_tmp791_fu_35213_p3() {
sel_tmp791_fu_35213_p3 = (!sel_tmp790_fu_35208_p2.read()[0].is_01())? sc_lv<2>(): ((sel_tmp790_fu_35208_p2.read()[0].to_bool())? word_buffer_1_2_0_1_reg_55582.read(): sel_tmp789_fu_35201_p3.read());
}
void a0_bin_conv::thread_sel_tmp792_fu_35220_p2() {
sel_tmp792_fu_35220_p2 = (cond1_reg_50498.read() & sel_tmp785_fu_35179_p2.read());
}
void a0_bin_conv::thread_sel_tmp793_fu_35225_p3() {
sel_tmp793_fu_35225_p3 = (!sel_tmp792_fu_35220_p2.read()[0].is_01())? sc_lv<2>(): ((sel_tmp792_fu_35220_p2.read()[0].to_bool())? word_buffer_1_3_0_reg_54858.read(): sel_tmp791_fu_35213_p3.read());
}
void a0_bin_conv::thread_sel_tmp794_fu_29873_p3() {
sel_tmp794_fu_29873_p3 = (!tmp_169_reg_51016.read()[0].is_01())? sc_lv<2>(): ((tmp_169_reg_51016.read()[0].to_bool())? word_buffer_1_0_1_1_fu_25795_p3.read(): word_buffer_1_5_1_fu_25643_p3.read());
}
void a0_bin_conv::thread_sel_tmp795_fu_29880_p3() {
sel_tmp795_fu_29880_p3 = (!tmp_171_reg_51180.read()[0].is_01())? sc_lv<2>(): ((tmp_171_reg_51180.read()[0].to_bool())? word_buffer_1_1_1_fu_25730_p3.read(): sel_tmp794_fu_29873_p3.read());
}
void a0_bin_conv::thread_sel_tmp796_fu_35287_p3() {
sel_tmp796_fu_35287_p3 = (!tmp_170_reg_51104.read()[0].is_01())? sc_lv<2>(): ((tmp_170_reg_51104.read()[0].to_bool())? word_buffer_1_2_1_reg_54904.read(): sel_tmp795_reg_56809.read());
}
void a0_bin_conv::thread_sel_tmp797_fu_35292_p3() {
sel_tmp797_fu_35292_p3 = (!tmp_167_reg_50852.read()[0].is_01())? sc_lv<2>(): ((tmp_167_reg_50852.read()[0].to_bool())? word_buffer_1_3_1_reg_54846.read(): sel_tmp796_fu_35287_p3.read());
}
void a0_bin_conv::thread_sel_tmp798_fu_29887_p3() {
sel_tmp798_fu_29887_p3 = (!tmp_169_reg_51016.read()[0].is_01())? sc_lv<2>(): ((tmp_169_reg_51016.read()[0].to_bool())? word_buffer_1_0_3_1_fu_25782_p3.read(): word_buffer_1_5_3_1_reg_52627.read());
}
void a0_bin_conv::thread_sel_tmp799_fu_29893_p3() {
sel_tmp799_fu_29893_p3 = (!tmp_171_reg_51180.read()[0].is_01())? sc_lv<2>(): ((tmp_171_reg_51180.read()[0].to_bool())? word_buffer_1_1_3_1_reg_52991.read(): sel_tmp798_fu_29887_p3.read());
}
void a0_bin_conv::thread_sel_tmp79_fu_20457_p2() {
sel_tmp79_fu_20457_p2 = (tmp_168_fu_20424_p2.read() & tmp_1225_reg_45756.read());
}
void a0_bin_conv::thread_sel_tmp800_fu_35310_p3() {
sel_tmp800_fu_35310_p3 = (!tmp_170_reg_51104.read()[0].is_01())? sc_lv<2>(): ((tmp_170_reg_51104.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_1_2_3_1_reg_52882.read(): sel_tmp799_reg_56814.read());
}
void a0_bin_conv::thread_sel_tmp801_fu_35315_p3() {
sel_tmp801_fu_35315_p3 = (!tmp_167_reg_50852.read()[0].is_01())? sc_lv<2>(): ((tmp_167_reg_50852.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_1_3_3_1_reg_52785.read(): sel_tmp800_fu_35310_p3.read());
}
void a0_bin_conv::thread_sel_tmp802_fu_29899_p3() {
sel_tmp802_fu_29899_p3 = (!tmp_169_reg_51016.read()[0].is_01())? sc_lv<2>(): ((tmp_169_reg_51016.read()[0].to_bool())? word_buffer_1_0_5_1_fu_25769_p3.read(): word_buffer_1_5_5_1_reg_52605.read());
}
void a0_bin_conv::thread_sel_tmp803_fu_29905_p3() {
sel_tmp803_fu_29905_p3 = (!tmp_171_reg_51180.read()[0].is_01())? sc_lv<2>(): ((tmp_171_reg_51180.read()[0].to_bool())? word_buffer_1_1_5_1_reg_52953.read(): sel_tmp802_fu_29899_p3.read());
}
void a0_bin_conv::thread_sel_tmp804_fu_35333_p3() {
sel_tmp804_fu_35333_p3 = (!tmp_170_reg_51104.read()[0].is_01())? sc_lv<2>(): ((tmp_170_reg_51104.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_1_2_5_1_reg_52848.read(): sel_tmp803_reg_56819.read());
}
void a0_bin_conv::thread_sel_tmp805_fu_35338_p3() {
sel_tmp805_fu_35338_p3 = (!tmp_167_reg_50852.read()[0].is_01())? sc_lv<2>(): ((tmp_167_reg_50852.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_1_3_5_1_reg_52755.read(): sel_tmp804_fu_35333_p3.read());
}
void a0_bin_conv::thread_sel_tmp806_fu_29911_p3() {
sel_tmp806_fu_29911_p3 = (!tmp_169_reg_51016.read()[0].is_01())? sc_lv<2>(): ((tmp_169_reg_51016.read()[0].to_bool())? word_buffer_1_0_7_1_fu_25756_p3.read(): word_buffer_1_5_7_1_reg_52584.read());
}
void a0_bin_conv::thread_sel_tmp807_fu_29917_p3() {
sel_tmp807_fu_29917_p3 = (!tmp_171_reg_51180.read()[0].is_01())? sc_lv<2>(): ((tmp_171_reg_51180.read()[0].to_bool())? word_buffer_1_1_7_1_reg_52916.read(): sel_tmp806_fu_29911_p3.read());
}
void a0_bin_conv::thread_sel_tmp808_fu_35356_p3() {
sel_tmp808_fu_35356_p3 = (!tmp_170_reg_51104.read()[0].is_01())? sc_lv<2>(): ((tmp_170_reg_51104.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_1_2_7_1_reg_52815.read(): sel_tmp807_reg_56824.read());
}
void a0_bin_conv::thread_sel_tmp809_fu_35361_p3() {
sel_tmp809_fu_35361_p3 = (!tmp_167_reg_50852.read()[0].is_01())? sc_lv<2>(): ((tmp_167_reg_50852.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_1_3_7_1_reg_52726.read(): sel_tmp808_fu_35356_p3.read());
}
void a0_bin_conv::thread_sel_tmp80_fu_20462_p2() {
sel_tmp80_fu_20462_p2 = (tmp_169_fu_20430_p2.read() & tmp_1225_reg_45756.read());
}
void a0_bin_conv::thread_sel_tmp810_fu_29927_p2() {
sel_tmp810_fu_29927_p2 = (brmerge36_fu_29923_p2.read() ^ ap_const_lv1_1);
}
void a0_bin_conv::thread_sel_tmp811_fu_29933_p2() {
sel_tmp811_fu_29933_p2 = (tmp_169_reg_51016.read() & sel_tmp810_fu_29927_p2.read());
}
void a0_bin_conv::thread_sel_tmp812_fu_29938_p3() {
sel_tmp812_fu_29938_p3 = (!sel_tmp811_fu_29933_p2.read()[0].is_01())? sc_lv<2>(): ((sel_tmp811_fu_29933_p2.read()[0].to_bool())? ap_const_lv2_0: word_buffer_1_5_0_fu_25650_p3.read());
}
void a0_bin_conv::thread_sel_tmp813_fu_29946_p2() {
sel_tmp813_fu_29946_p2 = (tmp_171_reg_51180.read() & sel_tmp810_fu_29927_p2.read());
}
void a0_bin_conv::thread_sel_tmp814_fu_29951_p3() {
sel_tmp814_fu_29951_p3 = (!sel_tmp813_fu_29946_p2.read()[0].is_01())? sc_lv<2>(): ((sel_tmp813_fu_29946_p2.read()[0].to_bool())? word_buffer_1_1_0_fu_25736_p3.read(): sel_tmp812_fu_29938_p3.read());
}
void a0_bin_conv::thread_sel_tmp815_fu_35379_p2() {
sel_tmp815_fu_35379_p2 = (tmp_170_reg_51104.read() & sel_tmp810_reg_56834.read());
}
void a0_bin_conv::thread_sel_tmp816_fu_35383_p3() {
sel_tmp816_fu_35383_p3 = (!sel_tmp815_fu_35379_p2.read()[0].is_01())? sc_lv<2>(): ((sel_tmp815_fu_35379_p2.read()[0].to_bool())? word_buffer_1_2_0_1_reg_55582.read(): sel_tmp814_reg_56841.read());
}
void a0_bin_conv::thread_sel_tmp817_fu_35389_p2() {
sel_tmp817_fu_35389_p2 = (tmp_167_reg_50852.read() & sel_tmp810_reg_56834.read());
}
void a0_bin_conv::thread_sel_tmp818_fu_35393_p3() {
sel_tmp818_fu_35393_p3 = (!sel_tmp817_fu_35389_p2.read()[0].is_01())? sc_lv<2>(): ((sel_tmp817_fu_35389_p2.read()[0].to_bool())? word_buffer_1_3_0_reg_54858.read(): sel_tmp816_fu_35383_p3.read());
}
void a0_bin_conv::thread_sel_tmp819_fu_35400_p2() {
sel_tmp819_fu_35400_p2 = (cond1_reg_50498.read() & sel_tmp810_reg_56834.read());
}
void a0_bin_conv::thread_sel_tmp81_fu_20467_p2() {
sel_tmp81_fu_20467_p2 = (tmp_171_fu_20442_p2.read() & tmp_1225_reg_45756.read());
}
void a0_bin_conv::thread_sel_tmp820_fu_35404_p3() {
sel_tmp820_fu_35404_p3 = (!sel_tmp819_fu_35400_p2.read()[0].is_01())? sc_lv<2>(): ((sel_tmp819_fu_35400_p2.read()[0].to_bool())? word_buffer_1_4_0_reg_54806.read(): sel_tmp818_fu_35393_p3.read());
}
void a0_bin_conv::thread_sel_tmp821_fu_29995_p3() {
sel_tmp821_fu_29995_p3 = (!tmp_168_reg_50922.read()[0].is_01())? sc_lv<2>(): ((tmp_168_reg_50922.read()[0].to_bool())? word_buffer_1_0_1_1_fu_25795_p3.read(): word_buffer_1_6_1_fu_25615_p3.read());
}
void a0_bin_conv::thread_sel_tmp822_fu_30002_p3() {
sel_tmp822_fu_30002_p3 = (!tmp_169_reg_51016.read()[0].is_01())? sc_lv<2>(): ((tmp_169_reg_51016.read()[0].to_bool())? word_buffer_1_1_1_fu_25730_p3.read(): sel_tmp821_fu_29995_p3.read());
}
void a0_bin_conv::thread_sel_tmp823_fu_35463_p3() {
sel_tmp823_fu_35463_p3 = (!tmp_171_reg_51180.read()[0].is_01())? sc_lv<2>(): ((tmp_171_reg_51180.read()[0].to_bool())? word_buffer_1_2_1_reg_54904.read(): sel_tmp822_reg_56868.read());
}
void a0_bin_conv::thread_sel_tmp824_fu_35468_p3() {
sel_tmp824_fu_35468_p3 = (!tmp_170_reg_51104.read()[0].is_01())? sc_lv<2>(): ((tmp_170_reg_51104.read()[0].to_bool())? word_buffer_1_3_1_reg_54846.read(): sel_tmp823_fu_35463_p3.read());
}
void a0_bin_conv::thread_sel_tmp825_fu_35474_p3() {
sel_tmp825_fu_35474_p3 = (!tmp_167_reg_50852.read()[0].is_01())? sc_lv<2>(): ((tmp_167_reg_50852.read()[0].to_bool())? word_buffer_1_4_1_reg_54795.read(): sel_tmp824_fu_35468_p3.read());
}
void a0_bin_conv::thread_sel_tmp826_fu_30009_p3() {
sel_tmp826_fu_30009_p3 = (!tmp_168_reg_50922.read()[0].is_01())? sc_lv<2>(): ((tmp_168_reg_50922.read()[0].to_bool())? word_buffer_1_0_3_1_fu_25782_p3.read(): word_buffer_1_6_3_1_reg_52566.read());
}
void a0_bin_conv::thread_sel_tmp827_fu_30015_p3() {
sel_tmp827_fu_30015_p3 = (!tmp_169_reg_51016.read()[0].is_01())? sc_lv<2>(): ((tmp_169_reg_51016.read()[0].to_bool())? word_buffer_1_1_3_1_reg_52991.read(): sel_tmp826_fu_30009_p3.read());
}
void a0_bin_conv::thread_sel_tmp828_fu_35493_p3() {
sel_tmp828_fu_35493_p3 = (!tmp_171_reg_51180.read()[0].is_01())? sc_lv<2>(): ((tmp_171_reg_51180.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_1_2_3_1_reg_52882.read(): sel_tmp827_reg_56873.read());
}
void a0_bin_conv::thread_sel_tmp829_fu_35498_p3() {
sel_tmp829_fu_35498_p3 = (!tmp_170_reg_51104.read()[0].is_01())? sc_lv<2>(): ((tmp_170_reg_51104.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_1_3_3_1_reg_52785.read(): sel_tmp828_fu_35493_p3.read());
}
void a0_bin_conv::thread_sel_tmp82_fu_20472_p2() {
sel_tmp82_fu_20472_p2 = (tmp_170_fu_20436_p2.read() & tmp_1225_reg_45756.read());
}
void a0_bin_conv::thread_sel_tmp830_fu_35504_p3() {
sel_tmp830_fu_35504_p3 = (!tmp_167_reg_50852.read()[0].is_01())? sc_lv<2>(): ((tmp_167_reg_50852.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_1_4_3_1_reg_52700.read(): sel_tmp829_fu_35498_p3.read());
}
void a0_bin_conv::thread_sel_tmp831_fu_30021_p3() {
sel_tmp831_fu_30021_p3 = (!tmp_168_reg_50922.read()[0].is_01())? sc_lv<2>(): ((tmp_168_reg_50922.read()[0].to_bool())? word_buffer_1_0_5_1_fu_25769_p3.read(): word_buffer_1_6_5_1_reg_52548.read());
}
void a0_bin_conv::thread_sel_tmp832_fu_30027_p3() {
sel_tmp832_fu_30027_p3 = (!tmp_169_reg_51016.read()[0].is_01())? sc_lv<2>(): ((tmp_169_reg_51016.read()[0].to_bool())? word_buffer_1_1_5_1_reg_52953.read(): sel_tmp831_fu_30021_p3.read());
}
void a0_bin_conv::thread_sel_tmp833_fu_35523_p3() {
sel_tmp833_fu_35523_p3 = (!tmp_171_reg_51180.read()[0].is_01())? sc_lv<2>(): ((tmp_171_reg_51180.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_1_2_5_1_reg_52848.read(): sel_tmp832_reg_56878.read());
}
void a0_bin_conv::thread_sel_tmp834_fu_35528_p3() {
sel_tmp834_fu_35528_p3 = (!tmp_170_reg_51104.read()[0].is_01())? sc_lv<2>(): ((tmp_170_reg_51104.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_1_3_5_1_reg_52755.read(): sel_tmp833_fu_35523_p3.read());
}
void a0_bin_conv::thread_sel_tmp835_fu_35534_p3() {
sel_tmp835_fu_35534_p3 = (!tmp_167_reg_50852.read()[0].is_01())? sc_lv<2>(): ((tmp_167_reg_50852.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_1_4_5_1_reg_52674.read(): sel_tmp834_fu_35528_p3.read());
}
void a0_bin_conv::thread_sel_tmp836_fu_30033_p3() {
sel_tmp836_fu_30033_p3 = (!tmp_168_reg_50922.read()[0].is_01())? sc_lv<2>(): ((tmp_168_reg_50922.read()[0].to_bool())? word_buffer_1_0_7_1_fu_25756_p3.read(): word_buffer_1_6_7_1_reg_52531.read());
}
void a0_bin_conv::thread_sel_tmp837_fu_30039_p3() {
sel_tmp837_fu_30039_p3 = (!tmp_169_reg_51016.read()[0].is_01())? sc_lv<2>(): ((tmp_169_reg_51016.read()[0].to_bool())? word_buffer_1_1_7_1_reg_52916.read(): sel_tmp836_fu_30033_p3.read());
}
void a0_bin_conv::thread_sel_tmp838_fu_35553_p3() {
sel_tmp838_fu_35553_p3 = (!tmp_171_reg_51180.read()[0].is_01())? sc_lv<2>(): ((tmp_171_reg_51180.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_1_2_7_1_reg_52815.read(): sel_tmp837_reg_56883.read());
}
void a0_bin_conv::thread_sel_tmp839_fu_35558_p3() {
sel_tmp839_fu_35558_p3 = (!tmp_170_reg_51104.read()[0].is_01())? sc_lv<2>(): ((tmp_170_reg_51104.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_1_3_7_1_reg_52726.read(): sel_tmp838_fu_35553_p3.read());
}
void a0_bin_conv::thread_sel_tmp83_fu_20477_p2() {
sel_tmp83_fu_20477_p2 = (cond6_fu_20126_p2.read() & tmp_1225_reg_45756.read());
}
void a0_bin_conv::thread_sel_tmp840_fu_35564_p3() {
sel_tmp840_fu_35564_p3 = (!tmp_167_reg_50852.read()[0].is_01())? sc_lv<2>(): ((tmp_167_reg_50852.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_1_4_7_1_reg_52649.read(): sel_tmp839_fu_35558_p3.read());
}
void a0_bin_conv::thread_sel_tmp841_fu_30049_p2() {
sel_tmp841_fu_30049_p2 = (brmerge38_fu_30045_p2.read() ^ ap_const_lv1_1);
}
void a0_bin_conv::thread_sel_tmp842_fu_30055_p2() {
sel_tmp842_fu_30055_p2 = (tmp_168_reg_50922.read() & sel_tmp841_fu_30049_p2.read());
}
void a0_bin_conv::thread_sel_tmp843_fu_30060_p3() {
sel_tmp843_fu_30060_p3 = (!sel_tmp842_fu_30055_p2.read()[0].is_01())? sc_lv<2>(): ((sel_tmp842_fu_30055_p2.read()[0].to_bool())? ap_const_lv2_0: word_buffer_1_6_0_fu_25622_p3.read());
}
void a0_bin_conv::thread_sel_tmp844_fu_30068_p2() {
sel_tmp844_fu_30068_p2 = (tmp_169_reg_51016.read() & sel_tmp841_fu_30049_p2.read());
}
void a0_bin_conv::thread_sel_tmp845_fu_30073_p3() {
sel_tmp845_fu_30073_p3 = (!sel_tmp844_fu_30068_p2.read()[0].is_01())? sc_lv<2>(): ((sel_tmp844_fu_30068_p2.read()[0].to_bool())? word_buffer_1_1_0_fu_25736_p3.read(): sel_tmp843_fu_30060_p3.read());
}
void a0_bin_conv::thread_sel_tmp846_fu_30081_p2() {
sel_tmp846_fu_30081_p2 = (tmp_171_reg_51180.read() & sel_tmp841_fu_30049_p2.read());
}
void a0_bin_conv::thread_sel_tmp847_fu_30086_p3() {
sel_tmp847_fu_30086_p3 = (!sel_tmp846_fu_30081_p2.read()[0].is_01())? sc_lv<2>(): ((sel_tmp846_fu_30081_p2.read()[0].to_bool())? word_buffer_1_2_0_1_fu_26050_p3.read(): sel_tmp845_fu_30073_p3.read());
}
void a0_bin_conv::thread_sel_tmp848_fu_35583_p2() {
sel_tmp848_fu_35583_p2 = (tmp_170_reg_51104.read() & sel_tmp841_reg_56893.read());
}
void a0_bin_conv::thread_sel_tmp849_fu_35587_p3() {
sel_tmp849_fu_35587_p3 = (!sel_tmp848_fu_35583_p2.read()[0].is_01())? sc_lv<2>(): ((sel_tmp848_fu_35583_p2.read()[0].to_bool())? word_buffer_1_3_0_reg_54858.read(): sel_tmp847_reg_56900.read());
}
void a0_bin_conv::thread_sel_tmp84_fu_20482_p2() {
sel_tmp84_fu_20482_p2 = (tmp_168_fu_20424_p2.read() & tmp_1227_reg_45800.read());
}
void a0_bin_conv::thread_sel_tmp850_fu_35593_p2() {
sel_tmp850_fu_35593_p2 = (tmp_167_reg_50852.read() & sel_tmp841_reg_56893.read());
}
void a0_bin_conv::thread_sel_tmp851_fu_35597_p3() {
sel_tmp851_fu_35597_p3 = (!sel_tmp850_fu_35593_p2.read()[0].is_01())? sc_lv<2>(): ((sel_tmp850_fu_35593_p2.read()[0].to_bool())? word_buffer_1_4_0_reg_54806.read(): sel_tmp849_fu_35587_p3.read());
}
void a0_bin_conv::thread_sel_tmp852_fu_35604_p2() {
sel_tmp852_fu_35604_p2 = (cond1_reg_50498.read() & sel_tmp841_reg_56893.read());
}
void a0_bin_conv::thread_sel_tmp853_fu_35608_p3() {
sel_tmp853_fu_35608_p3 = (!sel_tmp852_fu_35604_p2.read()[0].is_01())? sc_lv<2>(): ((sel_tmp852_fu_35604_p2.read()[0].to_bool())? word_buffer_1_5_0_reg_54762.read(): sel_tmp851_fu_35597_p3.read());
}
void a0_bin_conv::thread_sel_tmp854_fu_30265_p3() {
sel_tmp854_fu_30265_p3 = (!tmp_143_reg_50572.read()[0].is_01())? sc_lv<2>(): ((tmp_143_reg_50572.read()[0].to_bool())? old_word_buffer_1_1_11_fu_1666.read(): old_word_buffer_1_7_11_fu_1882.read());
}
void a0_bin_conv::thread_sel_tmp855_fu_30272_p3() {
sel_tmp855_fu_30272_p3 = (!tmp_148_reg_50586.read()[0].is_01())? sc_lv<2>(): ((tmp_148_reg_50586.read()[0].to_bool())? old_word_buffer_1_2_11_fu_1702.read(): sel_tmp854_fu_30265_p3.read());
}
void a0_bin_conv::thread_sel_tmp856_fu_30279_p3() {
sel_tmp856_fu_30279_p3 = (!tmp_149_reg_50600.read()[0].is_01())? sc_lv<2>(): ((tmp_149_reg_50600.read()[0].to_bool())? old_word_buffer_1_3_11_fu_1738.read(): sel_tmp855_fu_30272_p3.read());
}
void a0_bin_conv::thread_sel_tmp857_fu_30286_p3() {
sel_tmp857_fu_30286_p3 = (!tmp_150_reg_50614.read()[0].is_01())? sc_lv<2>(): ((tmp_150_reg_50614.read()[0].to_bool())? old_word_buffer_1_4_11_fu_1774.read(): sel_tmp856_fu_30279_p3.read());
}
void a0_bin_conv::thread_sel_tmp858_fu_30293_p3() {
sel_tmp858_fu_30293_p3 = (!tmp_151_reg_50628.read()[0].is_01())? sc_lv<2>(): ((tmp_151_reg_50628.read()[0].to_bool())? old_word_buffer_1_5_11_fu_1810.read(): sel_tmp857_fu_30286_p3.read());
}
void a0_bin_conv::thread_sel_tmp859_fu_30325_p3() {
sel_tmp859_fu_30325_p3 = (!tmp_143_reg_50572.read()[0].is_01())? sc_lv<2>(): ((tmp_143_reg_50572.read()[0].to_bool())? old_word_buffer_1_1_13_fu_1674.read(): old_word_buffer_1_7_13_fu_1890.read());
}
void a0_bin_conv::thread_sel_tmp85_fu_20487_p2() {
sel_tmp85_fu_20487_p2 = (tmp_169_fu_20430_p2.read() & tmp_1227_reg_45800.read());
}
void a0_bin_conv::thread_sel_tmp860_fu_30332_p3() {
sel_tmp860_fu_30332_p3 = (!tmp_148_reg_50586.read()[0].is_01())? sc_lv<2>(): ((tmp_148_reg_50586.read()[0].to_bool())? old_word_buffer_1_2_13_fu_1710.read(): sel_tmp859_fu_30325_p3.read());
}
void a0_bin_conv::thread_sel_tmp861_fu_30339_p3() {
sel_tmp861_fu_30339_p3 = (!tmp_149_reg_50600.read()[0].is_01())? sc_lv<2>(): ((tmp_149_reg_50600.read()[0].to_bool())? old_word_buffer_1_3_13_fu_1746.read(): sel_tmp860_fu_30332_p3.read());
}
void a0_bin_conv::thread_sel_tmp862_fu_30346_p3() {
sel_tmp862_fu_30346_p3 = (!tmp_150_reg_50614.read()[0].is_01())? sc_lv<2>(): ((tmp_150_reg_50614.read()[0].to_bool())? old_word_buffer_1_4_13_fu_1782.read(): sel_tmp861_fu_30339_p3.read());
}
void a0_bin_conv::thread_sel_tmp863_fu_30353_p3() {
sel_tmp863_fu_30353_p3 = (!tmp_151_reg_50628.read()[0].is_01())? sc_lv<2>(): ((tmp_151_reg_50628.read()[0].to_bool())? old_word_buffer_1_5_13_fu_1818.read(): sel_tmp862_fu_30346_p3.read());
}
void a0_bin_conv::thread_sel_tmp864_fu_30385_p3() {
sel_tmp864_fu_30385_p3 = (!tmp_143_reg_50572.read()[0].is_01())? sc_lv<2>(): ((tmp_143_reg_50572.read()[0].to_bool())? old_word_buffer_1_1_15_fu_1682.read(): old_word_buffer_1_7_15_fu_1898.read());
}
void a0_bin_conv::thread_sel_tmp865_fu_30392_p3() {
sel_tmp865_fu_30392_p3 = (!tmp_148_reg_50586.read()[0].is_01())? sc_lv<2>(): ((tmp_148_reg_50586.read()[0].to_bool())? old_word_buffer_1_2_15_fu_1718.read(): sel_tmp864_fu_30385_p3.read());
}
void a0_bin_conv::thread_sel_tmp866_fu_30399_p3() {
sel_tmp866_fu_30399_p3 = (!tmp_149_reg_50600.read()[0].is_01())? sc_lv<2>(): ((tmp_149_reg_50600.read()[0].to_bool())? old_word_buffer_1_3_15_fu_1754.read(): sel_tmp865_fu_30392_p3.read());
}
void a0_bin_conv::thread_sel_tmp867_fu_30406_p3() {
sel_tmp867_fu_30406_p3 = (!tmp_150_reg_50614.read()[0].is_01())? sc_lv<2>(): ((tmp_150_reg_50614.read()[0].to_bool())? old_word_buffer_1_4_15_fu_1790.read(): sel_tmp866_fu_30399_p3.read());
}
void a0_bin_conv::thread_sel_tmp868_fu_30413_p3() {
sel_tmp868_fu_30413_p3 = (!tmp_151_reg_50628.read()[0].is_01())? sc_lv<2>(): ((tmp_151_reg_50628.read()[0].to_bool())? old_word_buffer_1_5_15_fu_1826.read(): sel_tmp867_fu_30406_p3.read());
}
void a0_bin_conv::thread_sel_tmp869_fu_24256_p3() {
sel_tmp869_fu_24256_p3 = (!tmp_143_reg_50572.read()[0].is_01())? sc_lv<2>(): ((tmp_143_reg_50572.read()[0].to_bool())? old_word_buffer_1_1_17_fu_1690.read(): old_word_buffer_1_7_17_fu_1906.read());
}
void a0_bin_conv::thread_sel_tmp86_fu_20492_p2() {
sel_tmp86_fu_20492_p2 = (tmp_171_fu_20442_p2.read() & tmp_1227_reg_45800.read());
}
void a0_bin_conv::thread_sel_tmp870_fu_24263_p3() {
sel_tmp870_fu_24263_p3 = (!tmp_148_reg_50586.read()[0].is_01())? sc_lv<2>(): ((tmp_148_reg_50586.read()[0].to_bool())? old_word_buffer_1_2_17_fu_1726.read(): sel_tmp869_fu_24256_p3.read());
}
void a0_bin_conv::thread_sel_tmp871_fu_24270_p3() {
sel_tmp871_fu_24270_p3 = (!tmp_149_reg_50600.read()[0].is_01())? sc_lv<2>(): ((tmp_149_reg_50600.read()[0].to_bool())? old_word_buffer_1_3_17_fu_1762.read(): sel_tmp870_fu_24263_p3.read());
}
void a0_bin_conv::thread_sel_tmp872_fu_24277_p3() {
sel_tmp872_fu_24277_p3 = (!tmp_150_reg_50614.read()[0].is_01())? sc_lv<2>(): ((tmp_150_reg_50614.read()[0].to_bool())? old_word_buffer_1_4_17_fu_1798.read(): sel_tmp871_fu_24270_p3.read());
}
void a0_bin_conv::thread_sel_tmp873_fu_24284_p3() {
sel_tmp873_fu_24284_p3 = (!tmp_151_reg_50628.read()[0].is_01())? sc_lv<2>(): ((tmp_151_reg_50628.read()[0].to_bool())? old_word_buffer_1_5_17_fu_1834.read(): sel_tmp872_fu_24277_p3.read());
}
void a0_bin_conv::thread_sel_tmp874_fu_30450_p2() {
sel_tmp874_fu_30450_p2 = (tmp_1225_reg_45756.read() & first_wrd_not2_fu_30445_p2.read());
}
void a0_bin_conv::thread_sel_tmp875_fu_30455_p2() {
sel_tmp875_fu_30455_p2 = (tmp_148_reg_50586.read() & sel_tmp874_fu_30450_p2.read());
}
void a0_bin_conv::thread_sel_tmp876_fu_30460_p3() {
sel_tmp876_fu_30460_p3 = (!sel_tmp875_fu_30455_p2.read()[0].is_01())? sc_lv<2>(): ((sel_tmp875_fu_30455_p2.read()[0].to_bool())? old_word_buffer_1_2_fu_694.read(): old_word_buffer_1_7_fu_714.read());
}
void a0_bin_conv::thread_sel_tmp877_fu_30468_p2() {
sel_tmp877_fu_30468_p2 = (tmp_149_reg_50600.read() & sel_tmp874_fu_30450_p2.read());
}
void a0_bin_conv::thread_sel_tmp878_fu_30473_p3() {
sel_tmp878_fu_30473_p3 = (!sel_tmp877_fu_30468_p2.read()[0].is_01())? sc_lv<2>(): ((sel_tmp877_fu_30468_p2.read()[0].to_bool())? old_word_buffer_1_3_fu_698.read(): sel_tmp876_fu_30460_p3.read());
}
void a0_bin_conv::thread_sel_tmp879_fu_30481_p2() {
sel_tmp879_fu_30481_p2 = (tmp_150_reg_50614.read() & sel_tmp874_fu_30450_p2.read());
}
void a0_bin_conv::thread_sel_tmp87_fu_20497_p2() {
sel_tmp87_fu_20497_p2 = (cond6_fu_20126_p2.read() & tmp_1227_reg_45800.read());
}
void a0_bin_conv::thread_sel_tmp880_fu_30486_p3() {
sel_tmp880_fu_30486_p3 = (!sel_tmp879_fu_30481_p2.read()[0].is_01())? sc_lv<2>(): ((sel_tmp879_fu_30481_p2.read()[0].to_bool())? old_word_buffer_1_4_fu_702.read(): sel_tmp878_fu_30473_p3.read());
}
void a0_bin_conv::thread_sel_tmp881_fu_30494_p2() {
sel_tmp881_fu_30494_p2 = (tmp_151_reg_50628.read() & sel_tmp874_fu_30450_p2.read());
}
void a0_bin_conv::thread_sel_tmp882_fu_30499_p3() {
sel_tmp882_fu_30499_p3 = (!sel_tmp881_fu_30494_p2.read()[0].is_01())? sc_lv<2>(): ((sel_tmp881_fu_30494_p2.read()[0].to_bool())? old_word_buffer_1_5_fu_706.read(): sel_tmp880_fu_30486_p3.read());
}
void a0_bin_conv::thread_sel_tmp883_fu_35873_p2() {
sel_tmp883_fu_35873_p2 = (tmp_152_reg_50642.read() & sel_tmp874_reg_56968.read());
}
void a0_bin_conv::thread_sel_tmp884_fu_35877_p3() {
sel_tmp884_fu_35877_p3 = (!sel_tmp883_fu_35873_p2.read()[0].is_01())? sc_lv<2>(): ((sel_tmp883_fu_35873_p2.read()[0].to_bool())? old_word_buffer_1_6_54_reg_56963.read(): sel_tmp882_reg_56974.read());
}
void a0_bin_conv::thread_sel_tmp885_fu_35883_p2() {
sel_tmp885_fu_35883_p2 = (tmp_143_reg_50572.read() & sel_tmp874_reg_56968.read());
}
void a0_bin_conv::thread_sel_tmp886_fu_35887_p3() {
sel_tmp886_fu_35887_p3 = (!sel_tmp885_fu_35883_p2.read()[0].is_01())? sc_lv<2>(): ((sel_tmp885_fu_35883_p2.read()[0].to_bool())? old_word_buffer_1_1_fu_690.read(): sel_tmp884_fu_35877_p3.read());
}
void a0_bin_conv::thread_sel_tmp887_fu_30522_p3() {
sel_tmp887_fu_30522_p3 = (!tmp_153_reg_50656.read()[0].is_01())? sc_lv<2>(): ((tmp_153_reg_50656.read()[0].to_bool())? old_word_buffer_1_2_11_fu_1702.read(): old_word_buffer_1_7_11_fu_1882.read());
}
void a0_bin_conv::thread_sel_tmp888_fu_30529_p3() {
sel_tmp888_fu_30529_p3 = (!tmp_154_reg_50670.read()[0].is_01())? sc_lv<2>(): ((tmp_154_reg_50670.read()[0].to_bool())? old_word_buffer_1_3_11_fu_1738.read(): sel_tmp887_fu_30522_p3.read());
}
void a0_bin_conv::thread_sel_tmp889_fu_30536_p3() {
sel_tmp889_fu_30536_p3 = (!tmp_155_reg_50684.read()[0].is_01())? sc_lv<2>(): ((tmp_155_reg_50684.read()[0].to_bool())? old_word_buffer_1_4_11_fu_1774.read(): sel_tmp888_fu_30529_p3.read());
}
void a0_bin_conv::thread_sel_tmp88_fu_20502_p2() {
sel_tmp88_fu_20502_p2 = (lb_3_reg_45835.read() ^ ap_const_lv1_1);
}
void a0_bin_conv::thread_sel_tmp890_fu_30543_p3() {
sel_tmp890_fu_30543_p3 = (!tmp_156_reg_50698.read()[0].is_01())? sc_lv<2>(): ((tmp_156_reg_50698.read()[0].to_bool())? old_word_buffer_1_5_11_fu_1810.read(): sel_tmp889_fu_30536_p3.read());
}
void a0_bin_conv::thread_sel_tmp891_fu_30572_p3() {
sel_tmp891_fu_30572_p3 = (!tmp_153_reg_50656.read()[0].is_01())? sc_lv<2>(): ((tmp_153_reg_50656.read()[0].to_bool())? old_word_buffer_1_2_13_fu_1710.read(): old_word_buffer_1_7_13_fu_1890.read());
}
void a0_bin_conv::thread_sel_tmp892_fu_30579_p3() {
sel_tmp892_fu_30579_p3 = (!tmp_154_reg_50670.read()[0].is_01())? sc_lv<2>(): ((tmp_154_reg_50670.read()[0].to_bool())? old_word_buffer_1_3_13_fu_1746.read(): sel_tmp891_fu_30572_p3.read());
}
void a0_bin_conv::thread_sel_tmp893_fu_30586_p3() {
sel_tmp893_fu_30586_p3 = (!tmp_155_reg_50684.read()[0].is_01())? sc_lv<2>(): ((tmp_155_reg_50684.read()[0].to_bool())? old_word_buffer_1_4_13_fu_1782.read(): sel_tmp892_fu_30579_p3.read());
}
void a0_bin_conv::thread_sel_tmp894_fu_30593_p3() {
sel_tmp894_fu_30593_p3 = (!tmp_156_reg_50698.read()[0].is_01())? sc_lv<2>(): ((tmp_156_reg_50698.read()[0].to_bool())? old_word_buffer_1_5_13_fu_1818.read(): sel_tmp893_fu_30586_p3.read());
}
void a0_bin_conv::thread_sel_tmp895_fu_30622_p3() {
sel_tmp895_fu_30622_p3 = (!tmp_153_reg_50656.read()[0].is_01())? sc_lv<2>(): ((tmp_153_reg_50656.read()[0].to_bool())? old_word_buffer_1_2_15_fu_1718.read(): old_word_buffer_1_7_15_fu_1898.read());
}
void a0_bin_conv::thread_sel_tmp896_fu_30629_p3() {
sel_tmp896_fu_30629_p3 = (!tmp_154_reg_50670.read()[0].is_01())? sc_lv<2>(): ((tmp_154_reg_50670.read()[0].to_bool())? old_word_buffer_1_3_15_fu_1754.read(): sel_tmp895_fu_30622_p3.read());
}
void a0_bin_conv::thread_sel_tmp897_fu_30636_p3() {
sel_tmp897_fu_30636_p3 = (!tmp_155_reg_50684.read()[0].is_01())? sc_lv<2>(): ((tmp_155_reg_50684.read()[0].to_bool())? old_word_buffer_1_4_15_fu_1790.read(): sel_tmp896_fu_30629_p3.read());
}
void a0_bin_conv::thread_sel_tmp898_fu_30643_p3() {
sel_tmp898_fu_30643_p3 = (!tmp_156_reg_50698.read()[0].is_01())? sc_lv<2>(): ((tmp_156_reg_50698.read()[0].to_bool())? old_word_buffer_1_5_15_fu_1826.read(): sel_tmp897_fu_30636_p3.read());
}
void a0_bin_conv::thread_sel_tmp899_fu_24313_p3() {
sel_tmp899_fu_24313_p3 = (!tmp_153_reg_50656.read()[0].is_01())? sc_lv<2>(): ((tmp_153_reg_50656.read()[0].to_bool())? old_word_buffer_1_2_17_fu_1726.read(): old_word_buffer_1_7_17_fu_1906.read());
}
void a0_bin_conv::thread_sel_tmp89_fu_20507_p2() {
sel_tmp89_fu_20507_p2 = (tmp_168_fu_20424_p2.read() & sel_tmp88_fu_20502_p2.read());
}
void a0_bin_conv::thread_sel_tmp900_fu_24320_p3() {
sel_tmp900_fu_24320_p3 = (!tmp_154_reg_50670.read()[0].is_01())? sc_lv<2>(): ((tmp_154_reg_50670.read()[0].to_bool())? old_word_buffer_1_3_17_fu_1762.read(): sel_tmp899_fu_24313_p3.read());
}
void a0_bin_conv::thread_sel_tmp901_fu_24327_p3() {
sel_tmp901_fu_24327_p3 = (!tmp_155_reg_50684.read()[0].is_01())? sc_lv<2>(): ((tmp_155_reg_50684.read()[0].to_bool())? old_word_buffer_1_4_17_fu_1798.read(): sel_tmp900_fu_24320_p3.read());
}
void a0_bin_conv::thread_sel_tmp902_fu_24334_p3() {
sel_tmp902_fu_24334_p3 = (!tmp_156_reg_50698.read()[0].is_01())? sc_lv<2>(): ((tmp_156_reg_50698.read()[0].to_bool())? old_word_buffer_1_5_17_fu_1834.read(): sel_tmp901_fu_24327_p3.read());
}
void a0_bin_conv::thread_sel_tmp903_fu_24353_p2() {
sel_tmp903_fu_24353_p2 = (tmp_1227_reg_45800.read() & first_wrd_not3_fu_24348_p2.read());
}
void a0_bin_conv::thread_sel_tmp904_fu_30679_p2() {
sel_tmp904_fu_30679_p2 = (tmp_154_reg_50670.read() & sel_tmp903_reg_53830.read());
}
void a0_bin_conv::thread_sel_tmp905_fu_30683_p3() {
sel_tmp905_fu_30683_p3 = (!sel_tmp904_fu_30679_p2.read()[0].is_01())? sc_lv<2>(): ((sel_tmp904_fu_30679_p2.read()[0].to_bool())? old_word_buffer_1_3_fu_698.read(): old_word_buffer_1_7_fu_714.read());
}
void a0_bin_conv::thread_sel_tmp906_fu_30691_p2() {
sel_tmp906_fu_30691_p2 = (tmp_155_reg_50684.read() & sel_tmp903_reg_53830.read());
}
void a0_bin_conv::thread_sel_tmp907_fu_30695_p3() {
sel_tmp907_fu_30695_p3 = (!sel_tmp906_fu_30691_p2.read()[0].is_01())? sc_lv<2>(): ((sel_tmp906_fu_30691_p2.read()[0].to_bool())? old_word_buffer_1_4_fu_702.read(): sel_tmp905_fu_30683_p3.read());
}
void a0_bin_conv::thread_sel_tmp908_fu_30703_p2() {
sel_tmp908_fu_30703_p2 = (tmp_156_reg_50698.read() & sel_tmp903_reg_53830.read());
}
void a0_bin_conv::thread_sel_tmp909_fu_30707_p3() {
sel_tmp909_fu_30707_p3 = (!sel_tmp908_fu_30703_p2.read()[0].is_01())? sc_lv<2>(): ((sel_tmp908_fu_30703_p2.read()[0].to_bool())? old_word_buffer_1_5_fu_706.read(): sel_tmp907_fu_30695_p3.read());
}
void a0_bin_conv::thread_sel_tmp90_fu_20513_p2() {
sel_tmp90_fu_20513_p2 = (tmp_169_fu_20430_p2.read() & sel_tmp88_fu_20502_p2.read());
}
void a0_bin_conv::thread_sel_tmp910_fu_30715_p2() {
sel_tmp910_fu_30715_p2 = (tmp_157_reg_50712.read() & sel_tmp903_reg_53830.read());
}
void a0_bin_conv::thread_sel_tmp911_fu_30719_p3() {
sel_tmp911_fu_30719_p3 = (!sel_tmp910_fu_30715_p2.read()[0].is_01())? sc_lv<2>(): ((sel_tmp910_fu_30715_p2.read()[0].to_bool())? old_word_buffer_1_6_fu_710.read(): sel_tmp909_fu_30707_p3.read());
}
void a0_bin_conv::thread_sel_tmp912_fu_30727_p2() {
sel_tmp912_fu_30727_p2 = (tmp_153_reg_50656.read() & sel_tmp903_reg_53830.read());
}
void a0_bin_conv::thread_sel_tmp913_fu_30731_p3() {
sel_tmp913_fu_30731_p3 = (!sel_tmp912_fu_30727_p2.read()[0].is_01())? sc_lv<2>(): ((sel_tmp912_fu_30727_p2.read()[0].to_bool())? old_word_buffer_1_2_fu_694.read(): sel_tmp911_fu_30719_p3.read());
}
void a0_bin_conv::thread_sel_tmp914_fu_35958_p3() {
sel_tmp914_fu_35958_p3 = (!sel_tmp95_reg_51373.read()[0].is_01())? sc_lv<2>(): ((sel_tmp95_reg_51373.read()[0].to_bool())? word_buffer_1_1_1_reg_54917.read(): word_buffer_1_2_1_reg_54904.read());
}
void a0_bin_conv::thread_sel_tmp915_fu_35969_p3() {
sel_tmp915_fu_35969_p3 = (!sel_tmp95_reg_51373.read()[0].is_01())? sc_lv<2>(): ((sel_tmp95_reg_51373.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_1_1_2_1_reg_53010.read(): ap_reg_pp0_iter2_word_buffer_1_2_2_1_reg_52899.read());
}
void a0_bin_conv::thread_sel_tmp916_fu_35980_p3() {
sel_tmp916_fu_35980_p3 = (!sel_tmp95_reg_51373.read()[0].is_01())? sc_lv<2>(): ((sel_tmp95_reg_51373.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_1_1_3_1_reg_52991.read(): ap_reg_pp0_iter2_word_buffer_1_2_3_1_reg_52882.read());
}
void a0_bin_conv::thread_sel_tmp917_fu_35991_p3() {
sel_tmp917_fu_35991_p3 = (!sel_tmp95_reg_51373.read()[0].is_01())? sc_lv<2>(): ((sel_tmp95_reg_51373.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_1_1_4_1_reg_52972.read(): ap_reg_pp0_iter2_word_buffer_1_2_4_1_reg_52865.read());
}
void a0_bin_conv::thread_sel_tmp918_fu_36002_p3() {
sel_tmp918_fu_36002_p3 = (!sel_tmp95_reg_51373.read()[0].is_01())? sc_lv<2>(): ((sel_tmp95_reg_51373.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_1_1_5_1_reg_52953.read(): ap_reg_pp0_iter2_word_buffer_1_2_5_1_reg_52848.read());
}
void a0_bin_conv::thread_sel_tmp919_fu_36013_p3() {
sel_tmp919_fu_36013_p3 = (!sel_tmp95_reg_51373.read()[0].is_01())? sc_lv<2>(): ((sel_tmp95_reg_51373.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_1_1_6_1_reg_52934.read(): ap_reg_pp0_iter2_word_buffer_1_2_6_1_reg_52831.read());
}
void a0_bin_conv::thread_sel_tmp91_fu_20519_p2() {
sel_tmp91_fu_20519_p2 = (cond6_fu_20126_p2.read() & sel_tmp88_fu_20502_p2.read());
}
void a0_bin_conv::thread_sel_tmp920_fu_36024_p3() {
sel_tmp920_fu_36024_p3 = (!sel_tmp95_reg_51373.read()[0].is_01())? sc_lv<2>(): ((sel_tmp95_reg_51373.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_1_1_7_1_reg_52916.read(): ap_reg_pp0_iter2_word_buffer_1_2_7_1_reg_52815.read());
}
void a0_bin_conv::thread_sel_tmp921_fu_36035_p3() {
sel_tmp921_fu_36035_p3 = (!sel_tmp95_reg_51373.read()[0].is_01())? sc_lv<2>(): ((sel_tmp95_reg_51373.read()[0].to_bool())? word_buffer_1_2_0_reg_55094.read(): word_buffer_1_3_0_1_reg_54888.read());
}
void a0_bin_conv::thread_sel_tmp922_fu_36046_p3() {
sel_tmp922_fu_36046_p3 = (!tmp_173_reg_51413.read()[0].is_01())? sc_lv<2>(): ((tmp_173_reg_51413.read()[0].to_bool())? ap_const_lv2_0: word_buffer_1_2_0_1_reg_55582.read());
}
void a0_bin_conv::thread_sel_tmp923_fu_30759_p3() {
sel_tmp923_fu_30759_p3 = (!tmp_158_reg_50726.read()[0].is_01())? sc_lv<2>(): ((tmp_158_reg_50726.read()[0].to_bool())? old_word_buffer_1_3_11_fu_1738.read(): old_word_buffer_1_7_11_fu_1882.read());
}
void a0_bin_conv::thread_sel_tmp924_fu_30766_p3() {
sel_tmp924_fu_30766_p3 = (!tmp_159_reg_50740.read()[0].is_01())? sc_lv<2>(): ((tmp_159_reg_50740.read()[0].to_bool())? old_word_buffer_1_4_11_fu_1774.read(): sel_tmp923_fu_30759_p3.read());
}
void a0_bin_conv::thread_sel_tmp925_fu_30773_p3() {
sel_tmp925_fu_30773_p3 = (!tmp_160_reg_50754.read()[0].is_01())? sc_lv<2>(): ((tmp_160_reg_50754.read()[0].to_bool())? old_word_buffer_1_5_11_fu_1810.read(): sel_tmp924_fu_30766_p3.read());
}
void a0_bin_conv::thread_sel_tmp926_fu_30799_p3() {
sel_tmp926_fu_30799_p3 = (!tmp_158_reg_50726.read()[0].is_01())? sc_lv<2>(): ((tmp_158_reg_50726.read()[0].to_bool())? old_word_buffer_1_3_13_fu_1746.read(): old_word_buffer_1_7_13_fu_1890.read());
}
void a0_bin_conv::thread_sel_tmp927_fu_30806_p3() {
sel_tmp927_fu_30806_p3 = (!tmp_159_reg_50740.read()[0].is_01())? sc_lv<2>(): ((tmp_159_reg_50740.read()[0].to_bool())? old_word_buffer_1_4_13_fu_1782.read(): sel_tmp926_fu_30799_p3.read());
}
void a0_bin_conv::thread_sel_tmp928_fu_30813_p3() {
sel_tmp928_fu_30813_p3 = (!tmp_160_reg_50754.read()[0].is_01())? sc_lv<2>(): ((tmp_160_reg_50754.read()[0].to_bool())? old_word_buffer_1_5_13_fu_1818.read(): sel_tmp927_fu_30806_p3.read());
}
void a0_bin_conv::thread_sel_tmp929_fu_30839_p3() {
sel_tmp929_fu_30839_p3 = (!tmp_158_reg_50726.read()[0].is_01())? sc_lv<2>(): ((tmp_158_reg_50726.read()[0].to_bool())? old_word_buffer_1_3_15_fu_1754.read(): old_word_buffer_1_7_15_fu_1898.read());
}
void a0_bin_conv::thread_sel_tmp92_fu_20525_p2() {
sel_tmp92_fu_20525_p2 = (lb_4_reg_45859.read() ^ ap_const_lv1_1);
}
void a0_bin_conv::thread_sel_tmp930_fu_30846_p3() {
sel_tmp930_fu_30846_p3 = (!tmp_159_reg_50740.read()[0].is_01())? sc_lv<2>(): ((tmp_159_reg_50740.read()[0].to_bool())? old_word_buffer_1_4_15_fu_1790.read(): sel_tmp929_fu_30839_p3.read());
}
void a0_bin_conv::thread_sel_tmp931_fu_30853_p3() {
sel_tmp931_fu_30853_p3 = (!tmp_160_reg_50754.read()[0].is_01())? sc_lv<2>(): ((tmp_160_reg_50754.read()[0].to_bool())? old_word_buffer_1_5_15_fu_1826.read(): sel_tmp930_fu_30846_p3.read());
}
void a0_bin_conv::thread_sel_tmp932_fu_24370_p3() {
sel_tmp932_fu_24370_p3 = (!tmp_158_reg_50726.read()[0].is_01())? sc_lv<2>(): ((tmp_158_reg_50726.read()[0].to_bool())? old_word_buffer_1_3_17_fu_1762.read(): old_word_buffer_1_7_17_fu_1906.read());
}
void a0_bin_conv::thread_sel_tmp933_fu_24377_p3() {
sel_tmp933_fu_24377_p3 = (!tmp_159_reg_50740.read()[0].is_01())? sc_lv<2>(): ((tmp_159_reg_50740.read()[0].to_bool())? old_word_buffer_1_4_17_fu_1798.read(): sel_tmp932_fu_24370_p3.read());
}
void a0_bin_conv::thread_sel_tmp934_fu_24384_p3() {
sel_tmp934_fu_24384_p3 = (!tmp_160_reg_50754.read()[0].is_01())? sc_lv<2>(): ((tmp_160_reg_50754.read()[0].to_bool())? old_word_buffer_1_5_17_fu_1834.read(): sel_tmp933_fu_24377_p3.read());
}
void a0_bin_conv::thread_sel_tmp935_fu_30882_p2() {
sel_tmp935_fu_30882_p2 = (brmerge45_reg_53848.read() ^ ap_const_lv1_1);
}
void a0_bin_conv::thread_sel_tmp936_fu_30887_p2() {
sel_tmp936_fu_30887_p2 = (tmp_159_reg_50740.read() & sel_tmp935_fu_30882_p2.read());
}
void a0_bin_conv::thread_sel_tmp937_fu_30892_p3() {
sel_tmp937_fu_30892_p3 = (!sel_tmp936_fu_30887_p2.read()[0].is_01())? sc_lv<2>(): ((sel_tmp936_fu_30887_p2.read()[0].to_bool())? old_word_buffer_1_4_fu_702.read(): old_word_buffer_1_7_fu_714.read());
}
void a0_bin_conv::thread_sel_tmp938_fu_30900_p2() {
sel_tmp938_fu_30900_p2 = (tmp_160_reg_50754.read() & sel_tmp935_fu_30882_p2.read());
}
void a0_bin_conv::thread_sel_tmp939_fu_30905_p3() {
sel_tmp939_fu_30905_p3 = (!sel_tmp938_fu_30900_p2.read()[0].is_01())? sc_lv<2>(): ((sel_tmp938_fu_30900_p2.read()[0].to_bool())? old_word_buffer_1_5_fu_706.read(): sel_tmp937_fu_30892_p3.read());
}
void a0_bin_conv::thread_sel_tmp93_fu_20530_p2() {
sel_tmp93_fu_20530_p2 = (tmp_168_fu_20424_p2.read() & sel_tmp92_fu_20525_p2.read());
}
void a0_bin_conv::thread_sel_tmp940_fu_30913_p2() {
sel_tmp940_fu_30913_p2 = (tmp_161_reg_50768.read() & sel_tmp935_fu_30882_p2.read());
}
void a0_bin_conv::thread_sel_tmp941_fu_30918_p3() {
sel_tmp941_fu_30918_p3 = (!sel_tmp940_fu_30913_p2.read()[0].is_01())? sc_lv<2>(): ((sel_tmp940_fu_30913_p2.read()[0].to_bool())? old_word_buffer_1_6_fu_710.read(): sel_tmp939_fu_30905_p3.read());
}
void a0_bin_conv::thread_sel_tmp942_fu_30926_p2() {
sel_tmp942_fu_30926_p2 = (tmp_158_reg_50726.read() & sel_tmp935_fu_30882_p2.read());
}
void a0_bin_conv::thread_sel_tmp943_fu_30931_p3() {
sel_tmp943_fu_30931_p3 = (!sel_tmp942_fu_30926_p2.read()[0].is_01())? sc_lv<2>(): ((sel_tmp942_fu_30926_p2.read()[0].to_bool())? old_word_buffer_1_3_fu_698.read(): sel_tmp941_fu_30918_p3.read());
}
void a0_bin_conv::thread_sel_tmp944_fu_36062_p3() {
sel_tmp944_fu_36062_p3 = (!sel_tmp99_reg_51425.read()[0].is_01())? sc_lv<2>(): ((sel_tmp99_reg_51425.read()[0].to_bool())? word_buffer_1_1_1_reg_54917.read(): word_buffer_1_3_1_reg_54846.read());
}
void a0_bin_conv::thread_sel_tmp945_fu_36067_p3() {
sel_tmp945_fu_36067_p3 = (!sel_tmp100_reg_51445.read()[0].is_01())? sc_lv<2>(): ((sel_tmp100_reg_51445.read()[0].to_bool())? word_buffer_1_2_1_reg_54904.read(): sel_tmp944_fu_36062_p3.read());
}
void a0_bin_conv::thread_sel_tmp946_fu_36079_p3() {
sel_tmp946_fu_36079_p3 = (!sel_tmp99_reg_51425.read()[0].is_01())? sc_lv<2>(): ((sel_tmp99_reg_51425.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_1_1_2_1_reg_53010.read(): ap_reg_pp0_iter2_word_buffer_1_3_2_1_reg_52800.read());
}
void a0_bin_conv::thread_sel_tmp947_fu_36084_p3() {
sel_tmp947_fu_36084_p3 = (!sel_tmp100_reg_51445.read()[0].is_01())? sc_lv<2>(): ((sel_tmp100_reg_51445.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_1_2_2_1_reg_52899.read(): sel_tmp946_fu_36079_p3.read());
}
void a0_bin_conv::thread_sel_tmp948_fu_36096_p3() {
sel_tmp948_fu_36096_p3 = (!sel_tmp99_reg_51425.read()[0].is_01())? sc_lv<2>(): ((sel_tmp99_reg_51425.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_1_1_3_1_reg_52991.read(): ap_reg_pp0_iter2_word_buffer_1_3_3_1_reg_52785.read());
}
void a0_bin_conv::thread_sel_tmp949_fu_36101_p3() {
sel_tmp949_fu_36101_p3 = (!sel_tmp100_reg_51445.read()[0].is_01())? sc_lv<2>(): ((sel_tmp100_reg_51445.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_1_2_3_1_reg_52882.read(): sel_tmp948_fu_36096_p3.read());
}
void a0_bin_conv::thread_sel_tmp94_fu_20536_p2() {
sel_tmp94_fu_20536_p2 = (cond6_fu_20126_p2.read() & sel_tmp92_fu_20525_p2.read());
}
void a0_bin_conv::thread_sel_tmp950_fu_36113_p3() {
sel_tmp950_fu_36113_p3 = (!sel_tmp99_reg_51425.read()[0].is_01())? sc_lv<2>(): ((sel_tmp99_reg_51425.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_1_1_4_1_reg_52972.read(): ap_reg_pp0_iter2_word_buffer_1_3_4_1_reg_52770.read());
}
void a0_bin_conv::thread_sel_tmp951_fu_36118_p3() {
sel_tmp951_fu_36118_p3 = (!sel_tmp100_reg_51445.read()[0].is_01())? sc_lv<2>(): ((sel_tmp100_reg_51445.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_1_2_4_1_reg_52865.read(): sel_tmp950_fu_36113_p3.read());
}
void a0_bin_conv::thread_sel_tmp952_fu_36130_p3() {
sel_tmp952_fu_36130_p3 = (!sel_tmp99_reg_51425.read()[0].is_01())? sc_lv<2>(): ((sel_tmp99_reg_51425.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_1_1_5_1_reg_52953.read(): ap_reg_pp0_iter2_word_buffer_1_3_5_1_reg_52755.read());
}
void a0_bin_conv::thread_sel_tmp953_fu_36135_p3() {
sel_tmp953_fu_36135_p3 = (!sel_tmp100_reg_51445.read()[0].is_01())? sc_lv<2>(): ((sel_tmp100_reg_51445.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_1_2_5_1_reg_52848.read(): sel_tmp952_fu_36130_p3.read());
}
void a0_bin_conv::thread_sel_tmp954_fu_36147_p3() {
sel_tmp954_fu_36147_p3 = (!sel_tmp99_reg_51425.read()[0].is_01())? sc_lv<2>(): ((sel_tmp99_reg_51425.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_1_1_6_1_reg_52934.read(): ap_reg_pp0_iter2_word_buffer_1_3_6_1_reg_52740.read());
}
void a0_bin_conv::thread_sel_tmp955_fu_36152_p3() {
sel_tmp955_fu_36152_p3 = (!sel_tmp100_reg_51445.read()[0].is_01())? sc_lv<2>(): ((sel_tmp100_reg_51445.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_1_2_6_1_reg_52831.read(): sel_tmp954_fu_36147_p3.read());
}
void a0_bin_conv::thread_sel_tmp956_fu_36164_p3() {
sel_tmp956_fu_36164_p3 = (!sel_tmp99_reg_51425.read()[0].is_01())? sc_lv<2>(): ((sel_tmp99_reg_51425.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_1_1_7_1_reg_52916.read(): ap_reg_pp0_iter2_word_buffer_1_3_7_1_reg_52726.read());
}
void a0_bin_conv::thread_sel_tmp957_fu_36169_p3() {
sel_tmp957_fu_36169_p3 = (!sel_tmp100_reg_51445.read()[0].is_01())? sc_lv<2>(): ((sel_tmp100_reg_51445.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_1_2_7_1_reg_52815.read(): sel_tmp956_fu_36164_p3.read());
}
void a0_bin_conv::thread_sel_tmp958_fu_36181_p3() {
sel_tmp958_fu_36181_p3 = (!sel_tmp99_reg_51425.read()[0].is_01())? sc_lv<2>(): ((sel_tmp99_reg_51425.read()[0].to_bool())? word_buffer_1_2_0_reg_55094.read(): word_buffer_1_4_0_1_reg_54832.read());
}
void a0_bin_conv::thread_sel_tmp959_fu_36186_p3() {
sel_tmp959_fu_36186_p3 = (!sel_tmp100_reg_51445.read()[0].is_01())? sc_lv<2>(): ((sel_tmp100_reg_51445.read()[0].to_bool())? word_buffer_1_3_0_1_reg_54888.read(): sel_tmp958_fu_36181_p3.read());
}
void a0_bin_conv::thread_sel_tmp95_fu_20547_p2() {
sel_tmp95_fu_20547_p2 = (!tmp_1243_fu_20204_p1.read().is_01() || !ap_const_lv3_1.is_01())? sc_lv<1>(): sc_lv<1>(tmp_1243_fu_20204_p1.read() == ap_const_lv3_1);
}
void a0_bin_conv::thread_sel_tmp960_fu_36198_p3() {
sel_tmp960_fu_36198_p3 = (!tmp_174_reg_51465.read()[0].is_01())? sc_lv<2>(): ((tmp_174_reg_51465.read()[0].to_bool())? ap_const_lv2_0: word_buffer_1_3_0_reg_54858.read());
}
void a0_bin_conv::thread_sel_tmp961_fu_36204_p3() {
sel_tmp961_fu_36204_p3 = (!sel_tmp102_reg_51471.read()[0].is_01())? sc_lv<2>(): ((sel_tmp102_reg_51471.read()[0].to_bool())? word_buffer_1_1_0_reg_54929.read(): sel_tmp960_fu_36198_p3.read());
}
void a0_bin_conv::thread_sel_tmp962_fu_30955_p3() {
sel_tmp962_fu_30955_p3 = (!tmp_162_reg_50782.read()[0].is_01())? sc_lv<2>(): ((tmp_162_reg_50782.read()[0].to_bool())? old_word_buffer_1_4_11_fu_1774.read(): old_word_buffer_1_7_11_fu_1882.read());
}
void a0_bin_conv::thread_sel_tmp963_fu_30962_p3() {
sel_tmp963_fu_30962_p3 = (!tmp_163_reg_50796.read()[0].is_01())? sc_lv<2>(): ((tmp_163_reg_50796.read()[0].to_bool())? old_word_buffer_1_5_11_fu_1810.read(): sel_tmp962_fu_30955_p3.read());
}
void a0_bin_conv::thread_sel_tmp964_fu_30985_p3() {
sel_tmp964_fu_30985_p3 = (!tmp_162_reg_50782.read()[0].is_01())? sc_lv<2>(): ((tmp_162_reg_50782.read()[0].to_bool())? old_word_buffer_1_4_13_fu_1782.read(): old_word_buffer_1_7_13_fu_1890.read());
}
void a0_bin_conv::thread_sel_tmp965_fu_30992_p3() {
sel_tmp965_fu_30992_p3 = (!tmp_163_reg_50796.read()[0].is_01())? sc_lv<2>(): ((tmp_163_reg_50796.read()[0].to_bool())? old_word_buffer_1_5_13_fu_1818.read(): sel_tmp964_fu_30985_p3.read());
}
void a0_bin_conv::thread_sel_tmp966_fu_31015_p3() {
sel_tmp966_fu_31015_p3 = (!tmp_162_reg_50782.read()[0].is_01())? sc_lv<2>(): ((tmp_162_reg_50782.read()[0].to_bool())? old_word_buffer_1_4_15_fu_1790.read(): old_word_buffer_1_7_15_fu_1898.read());
}
void a0_bin_conv::thread_sel_tmp967_fu_31022_p3() {
sel_tmp967_fu_31022_p3 = (!tmp_163_reg_50796.read()[0].is_01())? sc_lv<2>(): ((tmp_163_reg_50796.read()[0].to_bool())? old_word_buffer_1_5_15_fu_1826.read(): sel_tmp966_fu_31015_p3.read());
}
void a0_bin_conv::thread_sel_tmp968_fu_24411_p3() {
sel_tmp968_fu_24411_p3 = (!tmp_162_reg_50782.read()[0].is_01())? sc_lv<2>(): ((tmp_162_reg_50782.read()[0].to_bool())? old_word_buffer_1_4_17_fu_1798.read(): old_word_buffer_1_7_17_fu_1906.read());
}
void a0_bin_conv::thread_sel_tmp969_fu_24418_p3() {
sel_tmp969_fu_24418_p3 = (!tmp_163_reg_50796.read()[0].is_01())? sc_lv<2>(): ((tmp_163_reg_50796.read()[0].to_bool())? old_word_buffer_1_5_17_fu_1834.read(): sel_tmp968_fu_24411_p3.read());
}
void a0_bin_conv::thread_sel_tmp96_fu_20553_p2() {
sel_tmp96_fu_20553_p2 = (!tmp_1243_fu_20204_p1.read().is_01() || !ap_const_lv3_0.is_01())? sc_lv<1>(): sc_lv<1>(tmp_1243_fu_20204_p1.read() == ap_const_lv3_0);
}
void a0_bin_conv::thread_sel_tmp970_fu_31052_p2() {
sel_tmp970_fu_31052_p2 = (brmerge47_fu_31048_p2.read() ^ ap_const_lv1_1);
}
void a0_bin_conv::thread_sel_tmp971_fu_31058_p2() {
sel_tmp971_fu_31058_p2 = (tmp_163_reg_50796.read() & sel_tmp970_fu_31052_p2.read());
}
void a0_bin_conv::thread_sel_tmp972_fu_31063_p3() {
sel_tmp972_fu_31063_p3 = (!sel_tmp971_fu_31058_p2.read()[0].is_01())? sc_lv<2>(): ((sel_tmp971_fu_31058_p2.read()[0].to_bool())? old_word_buffer_1_5_fu_706.read(): old_word_buffer_1_7_fu_714.read());
}
void a0_bin_conv::thread_sel_tmp973_fu_31071_p2() {
sel_tmp973_fu_31071_p2 = (tmp_164_reg_50810.read() & sel_tmp970_fu_31052_p2.read());
}
void a0_bin_conv::thread_sel_tmp974_fu_31076_p3() {
sel_tmp974_fu_31076_p3 = (!sel_tmp973_fu_31071_p2.read()[0].is_01())? sc_lv<2>(): ((sel_tmp973_fu_31071_p2.read()[0].to_bool())? old_word_buffer_1_6_fu_710.read(): sel_tmp972_fu_31063_p3.read());
}
void a0_bin_conv::thread_sel_tmp975_fu_31084_p2() {
sel_tmp975_fu_31084_p2 = (tmp_162_reg_50782.read() & sel_tmp970_fu_31052_p2.read());
}
void a0_bin_conv::thread_sel_tmp976_fu_31089_p3() {
sel_tmp976_fu_31089_p3 = (!sel_tmp975_fu_31084_p2.read()[0].is_01())? sc_lv<2>(): ((sel_tmp975_fu_31084_p2.read()[0].to_bool())? old_word_buffer_1_4_fu_702.read(): sel_tmp974_fu_31076_p3.read());
}
void a0_bin_conv::thread_sel_tmp977_fu_36220_p3() {
sel_tmp977_fu_36220_p3 = (!sel_tmp104_reg_51483.read()[0].is_01())? sc_lv<2>(): ((sel_tmp104_reg_51483.read()[0].to_bool())? word_buffer_1_1_1_reg_54917.read(): word_buffer_1_4_1_reg_54795.read());
}
void a0_bin_conv::thread_sel_tmp978_fu_36225_p3() {
sel_tmp978_fu_36225_p3 = (!sel_tmp105_reg_51503.read()[0].is_01())? sc_lv<2>(): ((sel_tmp105_reg_51503.read()[0].to_bool())? word_buffer_1_2_1_reg_54904.read(): sel_tmp977_fu_36220_p3.read());
}
void a0_bin_conv::thread_sel_tmp979_fu_36231_p3() {
sel_tmp979_fu_36231_p3 = (!sel_tmp106_reg_51523.read()[0].is_01())? sc_lv<2>(): ((sel_tmp106_reg_51523.read()[0].to_bool())? word_buffer_1_3_1_reg_54846.read(): sel_tmp978_fu_36225_p3.read());
}
void a0_bin_conv::thread_sel_tmp97_fu_20559_p2() {
sel_tmp97_fu_20559_p2 = (sel_tmp96_fu_20553_p2.read() & sel_tmp88_fu_20502_p2.read());
}
void a0_bin_conv::thread_sel_tmp980_fu_36243_p3() {
sel_tmp980_fu_36243_p3 = (!sel_tmp104_reg_51483.read()[0].is_01())? sc_lv<2>(): ((sel_tmp104_reg_51483.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_1_1_2_1_reg_53010.read(): ap_reg_pp0_iter2_word_buffer_1_4_2_1_reg_52713.read());
}
void a0_bin_conv::thread_sel_tmp981_fu_36248_p3() {
sel_tmp981_fu_36248_p3 = (!sel_tmp105_reg_51503.read()[0].is_01())? sc_lv<2>(): ((sel_tmp105_reg_51503.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_1_2_2_1_reg_52899.read(): sel_tmp980_fu_36243_p3.read());
}
void a0_bin_conv::thread_sel_tmp982_fu_36254_p3() {
sel_tmp982_fu_36254_p3 = (!sel_tmp106_reg_51523.read()[0].is_01())? sc_lv<2>(): ((sel_tmp106_reg_51523.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_1_3_2_1_reg_52800.read(): sel_tmp981_fu_36248_p3.read());
}
void a0_bin_conv::thread_sel_tmp983_fu_36266_p3() {
sel_tmp983_fu_36266_p3 = (!sel_tmp104_reg_51483.read()[0].is_01())? sc_lv<2>(): ((sel_tmp104_reg_51483.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_1_1_3_1_reg_52991.read(): ap_reg_pp0_iter2_word_buffer_1_4_3_1_reg_52700.read());
}
void a0_bin_conv::thread_sel_tmp984_fu_36271_p3() {
sel_tmp984_fu_36271_p3 = (!sel_tmp105_reg_51503.read()[0].is_01())? sc_lv<2>(): ((sel_tmp105_reg_51503.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_1_2_3_1_reg_52882.read(): sel_tmp983_fu_36266_p3.read());
}
void a0_bin_conv::thread_sel_tmp985_fu_36277_p3() {
sel_tmp985_fu_36277_p3 = (!sel_tmp106_reg_51523.read()[0].is_01())? sc_lv<2>(): ((sel_tmp106_reg_51523.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_1_3_3_1_reg_52785.read(): sel_tmp984_fu_36271_p3.read());
}
void a0_bin_conv::thread_sel_tmp986_fu_36289_p3() {
sel_tmp986_fu_36289_p3 = (!sel_tmp104_reg_51483.read()[0].is_01())? sc_lv<2>(): ((sel_tmp104_reg_51483.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_1_1_4_1_reg_52972.read(): ap_reg_pp0_iter2_word_buffer_1_4_4_1_reg_52687.read());
}
void a0_bin_conv::thread_sel_tmp987_fu_36294_p3() {
sel_tmp987_fu_36294_p3 = (!sel_tmp105_reg_51503.read()[0].is_01())? sc_lv<2>(): ((sel_tmp105_reg_51503.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_1_2_4_1_reg_52865.read(): sel_tmp986_fu_36289_p3.read());
}
void a0_bin_conv::thread_sel_tmp988_fu_36300_p3() {
sel_tmp988_fu_36300_p3 = (!sel_tmp106_reg_51523.read()[0].is_01())? sc_lv<2>(): ((sel_tmp106_reg_51523.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_1_3_4_1_reg_52770.read(): sel_tmp987_fu_36294_p3.read());
}
void a0_bin_conv::thread_sel_tmp989_fu_36312_p3() {
sel_tmp989_fu_36312_p3 = (!sel_tmp104_reg_51483.read()[0].is_01())? sc_lv<2>(): ((sel_tmp104_reg_51483.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_1_1_5_1_reg_52953.read(): ap_reg_pp0_iter2_word_buffer_1_4_5_1_reg_52674.read());
}
void a0_bin_conv::thread_sel_tmp98_fu_20570_p2() {
sel_tmp98_fu_20570_p2 = (sel_tmp95_fu_20547_p2.read() & sel_tmp88_fu_20502_p2.read());
}
void a0_bin_conv::thread_sel_tmp990_fu_36317_p3() {
sel_tmp990_fu_36317_p3 = (!sel_tmp105_reg_51503.read()[0].is_01())? sc_lv<2>(): ((sel_tmp105_reg_51503.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_1_2_5_1_reg_52848.read(): sel_tmp989_fu_36312_p3.read());
}
void a0_bin_conv::thread_sel_tmp991_fu_36323_p3() {
sel_tmp991_fu_36323_p3 = (!sel_tmp106_reg_51523.read()[0].is_01())? sc_lv<2>(): ((sel_tmp106_reg_51523.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_1_3_5_1_reg_52755.read(): sel_tmp990_fu_36317_p3.read());
}
void a0_bin_conv::thread_sel_tmp992_fu_36335_p3() {
sel_tmp992_fu_36335_p3 = (!sel_tmp104_reg_51483.read()[0].is_01())? sc_lv<2>(): ((sel_tmp104_reg_51483.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_1_1_6_1_reg_52934.read(): ap_reg_pp0_iter2_word_buffer_1_4_6_1_reg_52661.read());
}
void a0_bin_conv::thread_sel_tmp993_fu_36340_p3() {
sel_tmp993_fu_36340_p3 = (!sel_tmp105_reg_51503.read()[0].is_01())? sc_lv<2>(): ((sel_tmp105_reg_51503.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_1_2_6_1_reg_52831.read(): sel_tmp992_fu_36335_p3.read());
}
void a0_bin_conv::thread_sel_tmp994_fu_36346_p3() {
sel_tmp994_fu_36346_p3 = (!sel_tmp106_reg_51523.read()[0].is_01())? sc_lv<2>(): ((sel_tmp106_reg_51523.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_1_3_6_1_reg_52740.read(): sel_tmp993_fu_36340_p3.read());
}
void a0_bin_conv::thread_sel_tmp995_fu_36358_p3() {
sel_tmp995_fu_36358_p3 = (!sel_tmp104_reg_51483.read()[0].is_01())? sc_lv<2>(): ((sel_tmp104_reg_51483.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_1_1_7_1_reg_52916.read(): ap_reg_pp0_iter2_word_buffer_1_4_7_1_reg_52649.read());
}
void a0_bin_conv::thread_sel_tmp996_fu_36363_p3() {
sel_tmp996_fu_36363_p3 = (!sel_tmp105_reg_51503.read()[0].is_01())? sc_lv<2>(): ((sel_tmp105_reg_51503.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_1_2_7_1_reg_52815.read(): sel_tmp995_fu_36358_p3.read());
}
void a0_bin_conv::thread_sel_tmp997_fu_36369_p3() {
sel_tmp997_fu_36369_p3 = (!sel_tmp106_reg_51523.read()[0].is_01())? sc_lv<2>(): ((sel_tmp106_reg_51523.read()[0].to_bool())? ap_reg_pp0_iter2_word_buffer_1_3_7_1_reg_52726.read(): sel_tmp996_fu_36363_p3.read());
}
void a0_bin_conv::thread_sel_tmp998_fu_36381_p3() {
sel_tmp998_fu_36381_p3 = (!sel_tmp104_reg_51483.read()[0].is_01())? sc_lv<2>(): ((sel_tmp104_reg_51483.read()[0].to_bool())? word_buffer_1_2_0_reg_55094.read(): word_buffer_1_5_0_1_reg_54783.read());
}
void a0_bin_conv::thread_sel_tmp999_fu_36386_p3() {
sel_tmp999_fu_36386_p3 = (!sel_tmp105_reg_51503.read()[0].is_01())? sc_lv<2>(): ((sel_tmp105_reg_51503.read()[0].to_bool())? word_buffer_1_3_0_1_reg_54888.read(): sel_tmp998_fu_36381_p3.read());
}
void a0_bin_conv::thread_sel_tmp99_fu_20576_p2() {
sel_tmp99_fu_20576_p2 = (!r_V_64_0_4_cast_fu_20208_p2.read().is_01() || !ap_const_lv3_1.is_01())? sc_lv<1>(): sc_lv<1>(r_V_64_0_4_cast_fu_20208_p2.read() == ap_const_lv3_1);
}
void a0_bin_conv::thread_sel_tmp_fu_26075_p3() {
sel_tmp_fu_26075_p3 = (!cond6_reg_50242.read()[0].is_01())? sc_lv<2>(): ((cond6_reg_50242.read()[0].to_bool())? old_word_buffer_0_1_11_fu_1382.read(): old_word_buffer_0_7_10_fu_1594.read());
}
void a0_bin_conv::thread_storemerge1_fu_37020_p3() {
storemerge1_fu_37020_p3 = (!ap_reg_pp0_iter2_first_wrd_reg_51897.read()[0].is_01())? sc_lv<2>(): ((ap_reg_pp0_iter2_first_wrd_reg_51897.read()[0].to_bool())? ap_const_lv2_0: old_word_buffer_1_7_43_reg_54610.read());
}
void a0_bin_conv::thread_storemerge2_fu_37032_p3() {
storemerge2_fu_37032_p3 = (!ap_reg_pp0_iter2_first_wrd_reg_51897.read()[0].is_01())? sc_lv<2>(): ((ap_reg_pp0_iter2_first_wrd_reg_51897.read()[0].to_bool())? ap_const_lv2_0: old_word_buffer_1_7_45_reg_54634.read());
}
void a0_bin_conv::thread_storemerge3_fu_37044_p3() {
storemerge3_fu_37044_p3 = (!ap_reg_pp0_iter2_first_wrd_reg_51897.read()[0].is_01())? sc_lv<2>(): ((ap_reg_pp0_iter2_first_wrd_reg_51897.read()[0].to_bool())? ap_const_lv2_0: old_word_buffer_1_7_47_reg_54658.read());
}
void a0_bin_conv::thread_storemerge4_fu_37056_p3() {
storemerge4_fu_37056_p3 = (!ap_reg_pp0_iter2_first_wrd_reg_51897.read()[0].is_01())? sc_lv<2>(): ((ap_reg_pp0_iter2_first_wrd_reg_51897.read()[0].to_bool())? ap_const_lv2_0: ap_reg_pp0_iter2_old_word_buffer_1_7_49_reg_52231.read());
}
void a0_bin_conv::thread_storemerge5_fu_34711_p3() {
storemerge5_fu_34711_p3 = (!ap_reg_pp0_iter2_first_wrd_reg_51897.read()[0].is_01())? sc_lv<2>(): ((ap_reg_pp0_iter2_first_wrd_reg_51897.read()[0].to_bool())? ap_const_lv2_0: old_word_buffer_0_7_42_reg_54206.read());
}
void a0_bin_conv::thread_storemerge6_fu_34723_p3() {
storemerge6_fu_34723_p3 = (!ap_reg_pp0_iter2_first_wrd_reg_51897.read()[0].is_01())? sc_lv<2>(): ((ap_reg_pp0_iter2_first_wrd_reg_51897.read()[0].to_bool())? ap_const_lv2_0: old_word_buffer_0_7_44_reg_54230.read());
}
void a0_bin_conv::thread_storemerge7_fu_34735_p3() {
storemerge7_fu_34735_p3 = (!ap_reg_pp0_iter2_first_wrd_reg_51897.read()[0].is_01())? sc_lv<2>(): ((ap_reg_pp0_iter2_first_wrd_reg_51897.read()[0].to_bool())? ap_const_lv2_0: old_word_buffer_0_7_46_reg_54254.read());
}
void a0_bin_conv::thread_storemerge8_fu_34747_p3() {
storemerge8_fu_34747_p3 = (!ap_reg_pp0_iter2_first_wrd_reg_51897.read()[0].is_01())? sc_lv<2>(): ((ap_reg_pp0_iter2_first_wrd_reg_51897.read()[0].to_bool())? ap_const_lv2_0: ap_reg_pp0_iter2_old_word_buffer_0_7_48_reg_52184.read());
}
void a0_bin_conv::thread_storemerge_phi_fu_6214_p4() {
if (esl_seteq<1,1,1>(ap_condition_10219.read(), ap_const_boolean_1)) {
if (esl_seteq<1,1,1>(ap_const_lv1_1, tmp_130_fu_20930_p2.read())) {
storemerge_phi_fu_6214_p4 = ap_const_lv3_0;
} else if (esl_seteq<1,1,1>(ap_const_lv1_0, tmp_130_fu_20930_p2.read())) {
storemerge_phi_fu_6214_p4 = tmp_135_fu_20936_p2.read();
} else {
storemerge_phi_fu_6214_p4 = ap_phi_precharge_reg_pp0_iter1_storemerge_reg_6211.read();
}
} else {
storemerge_phi_fu_6214_p4 = ap_phi_precharge_reg_pp0_iter1_storemerge_reg_6211.read();
}
}
void a0_bin_conv::thread_t_V_2_phi_fu_6192_p4() {
if ((esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_pp0_stage0.read()) &&
esl_seteq<1,1,1>(ap_const_lv1_0, exitcond1_reg_51888.read()) &&
esl_seteq<1,1,1>(ap_const_logic_1, ap_enable_reg_pp0_iter1.read()) &&
esl_seteq<1,1,1>(ap_block_pp0_stage0.read(), ap_const_boolean_0))) {
t_V_2_phi_fu_6192_p4 = wrd_phase_V_1_reg_52179.read();
} else {
t_V_2_phi_fu_6192_p4 = t_V_2_reg_6188.read();
}
}
void a0_bin_conv::thread_tmp3588_cast_fu_41576_p1() {
tmp3588_cast_fu_41576_p1 = esl_sext<12,6>(tmp669_reg_59109.read());
}
void a0_bin_conv::thread_tmp3589_cast_fu_41586_p1() {
tmp3589_cast_fu_41586_p1 = esl_sext<12,6>(tmp670_reg_59120.read());
}
void a0_bin_conv::thread_tmp3590_cast_fu_41596_p1() {
tmp3590_cast_fu_41596_p1 = esl_sext<12,6>(tmp671_reg_59131.read());
}
void a0_bin_conv::thread_tmp3591_cast_fu_41606_p1() {
tmp3591_cast_fu_41606_p1 = esl_sext<12,6>(tmp672_reg_59142.read());
}
void a0_bin_conv::thread_tmp3592_cast_fu_41616_p1() {
tmp3592_cast_fu_41616_p1 = esl_sext<12,6>(tmp673_reg_59153.read());
}
void a0_bin_conv::thread_tmp3593_cast_fu_41626_p1() {
tmp3593_cast_fu_41626_p1 = esl_sext<12,6>(tmp674_reg_59164.read());
}
void a0_bin_conv::thread_tmp3594_cast_fu_41636_p1() {
tmp3594_cast_fu_41636_p1 = esl_sext<12,6>(tmp675_reg_59175.read());
}
void a0_bin_conv::thread_tmp3595_cast_fu_41646_p1() {
tmp3595_cast_fu_41646_p1 = esl_sext<12,6>(tmp676_reg_59186.read());
}
void a0_bin_conv::thread_tmp3596_cast_fu_41656_p1() {
tmp3596_cast_fu_41656_p1 = esl_sext<12,6>(tmp677_reg_59197.read());
}
void a0_bin_conv::thread_tmp3597_cast_fu_41666_p1() {
tmp3597_cast_fu_41666_p1 = esl_sext<12,6>(tmp678_reg_59208.read());
}
void a0_bin_conv::thread_tmp3598_cast_fu_41676_p1() {
tmp3598_cast_fu_41676_p1 = esl_sext<12,6>(tmp679_reg_59219.read());
}
void a0_bin_conv::thread_tmp3599_cast_fu_41686_p1() {
tmp3599_cast_fu_41686_p1 = esl_sext<12,6>(tmp680_reg_59230.read());
}
void a0_bin_conv::thread_tmp3600_cast_fu_41696_p1() {
tmp3600_cast_fu_41696_p1 = esl_sext<12,6>(tmp681_reg_59241.read());
}
void a0_bin_conv::thread_tmp3601_cast_fu_41706_p1() {
tmp3601_cast_fu_41706_p1 = esl_sext<12,6>(tmp682_reg_59252.read());
}
void a0_bin_conv::thread_tmp3602_cast_fu_41716_p1() {
tmp3602_cast_fu_41716_p1 = esl_sext<12,6>(tmp683_reg_59263.read());
}
void a0_bin_conv::thread_tmp3603_cast_fu_41726_p1() {
tmp3603_cast_fu_41726_p1 = esl_sext<12,6>(tmp684_reg_59274.read());
}
void a0_bin_conv::thread_tmp3604_cast_fu_41736_p1() {
tmp3604_cast_fu_41736_p1 = esl_sext<12,6>(tmp685_reg_59285.read());
}
void a0_bin_conv::thread_tmp3605_cast_fu_41746_p1() {
tmp3605_cast_fu_41746_p1 = esl_sext<12,6>(tmp686_reg_59296.read());
}
void a0_bin_conv::thread_tmp3606_cast_fu_41756_p1() {
tmp3606_cast_fu_41756_p1 = esl_sext<12,6>(tmp687_reg_59307.read());
}
void a0_bin_conv::thread_tmp3607_cast_fu_41766_p1() {
tmp3607_cast_fu_41766_p1 = esl_sext<12,6>(tmp688_reg_59318.read());
}
void a0_bin_conv::thread_tmp3608_cast_fu_41776_p1() {
tmp3608_cast_fu_41776_p1 = esl_sext<12,6>(tmp689_reg_59329.read());
}
void a0_bin_conv::thread_tmp3609_cast_fu_41786_p1() {
tmp3609_cast_fu_41786_p1 = esl_sext<12,6>(tmp690_reg_59340.read());
}
void a0_bin_conv::thread_tmp3610_cast_fu_41796_p1() {
tmp3610_cast_fu_41796_p1 = esl_sext<12,6>(tmp691_reg_59351.read());
}
void a0_bin_conv::thread_tmp3611_cast_fu_41806_p1() {
tmp3611_cast_fu_41806_p1 = esl_sext<12,6>(tmp692_reg_59362.read());
}
void a0_bin_conv::thread_tmp3612_cast_fu_41816_p1() {
tmp3612_cast_fu_41816_p1 = esl_sext<12,6>(tmp693_reg_59373.read());
}
void a0_bin_conv::thread_tmp3613_cast_fu_41826_p1() {
tmp3613_cast_fu_41826_p1 = esl_sext<12,6>(tmp694_reg_59384.read());
}
void a0_bin_conv::thread_tmp3614_cast_fu_41836_p1() {
tmp3614_cast_fu_41836_p1 = esl_sext<12,6>(tmp695_reg_59395.read());
}
void a0_bin_conv::thread_tmp3615_cast_fu_41846_p1() {
tmp3615_cast_fu_41846_p1 = esl_sext<12,6>(tmp696_reg_59406.read());
}
void a0_bin_conv::thread_tmp3616_cast_fu_41856_p1() {
tmp3616_cast_fu_41856_p1 = esl_sext<12,6>(tmp697_reg_59417.read());
}
void a0_bin_conv::thread_tmp3617_cast_fu_41866_p1() {
tmp3617_cast_fu_41866_p1 = esl_sext<12,6>(tmp698_reg_59428.read());
}
void a0_bin_conv::thread_tmp3618_cast_fu_41876_p1() {
tmp3618_cast_fu_41876_p1 = esl_sext<12,6>(tmp699_reg_59439.read());
}
void a0_bin_conv::thread_tmp3619_cast_fu_41886_p1() {
tmp3619_cast_fu_41886_p1 = esl_sext<12,6>(tmp700_reg_59450.read());
}
void a0_bin_conv::thread_tmp3620_cast_fu_41896_p1() {
tmp3620_cast_fu_41896_p1 = esl_sext<12,6>(tmp701_reg_59461.read());
}
void a0_bin_conv::thread_tmp3621_cast_fu_41906_p1() {
tmp3621_cast_fu_41906_p1 = esl_sext<12,6>(tmp702_reg_59472.read());
}
void a0_bin_conv::thread_tmp3622_cast_fu_41916_p1() {
tmp3622_cast_fu_41916_p1 = esl_sext<12,6>(tmp703_reg_59483.read());
}
void a0_bin_conv::thread_tmp3623_cast_fu_41926_p1() {
tmp3623_cast_fu_41926_p1 = esl_sext<12,6>(tmp704_reg_59494.read());
}
void a0_bin_conv::thread_tmp3624_cast_fu_41936_p1() {
tmp3624_cast_fu_41936_p1 = esl_sext<12,6>(tmp705_reg_59505.read());
}
void a0_bin_conv::thread_tmp3625_cast_fu_41946_p1() {
tmp3625_cast_fu_41946_p1 = esl_sext<12,6>(tmp706_reg_59516.read());
}
void a0_bin_conv::thread_tmp3626_cast_fu_41956_p1() {
tmp3626_cast_fu_41956_p1 = esl_sext<12,6>(tmp707_reg_59527.read());
}
void a0_bin_conv::thread_tmp3627_cast_fu_41966_p1() {
tmp3627_cast_fu_41966_p1 = esl_sext<12,6>(tmp708_reg_59538.read());
}
void a0_bin_conv::thread_tmp3628_cast_fu_41976_p1() {
tmp3628_cast_fu_41976_p1 = esl_sext<12,6>(tmp709_reg_59549.read());
}
void a0_bin_conv::thread_tmp3629_cast_fu_41986_p1() {
tmp3629_cast_fu_41986_p1 = esl_sext<12,6>(tmp710_reg_59560.read());
}
void a0_bin_conv::thread_tmp3630_cast_fu_41996_p1() {
tmp3630_cast_fu_41996_p1 = esl_sext<12,6>(tmp711_reg_59571.read());
}
void a0_bin_conv::thread_tmp3631_cast_fu_42006_p1() {
tmp3631_cast_fu_42006_p1 = esl_sext<12,6>(tmp712_reg_59582.read());
}
void a0_bin_conv::thread_tmp3632_cast_fu_42016_p1() {
tmp3632_cast_fu_42016_p1 = esl_sext<12,6>(tmp713_reg_59593.read());
}
void a0_bin_conv::thread_tmp3633_cast_fu_42026_p1() {
tmp3633_cast_fu_42026_p1 = esl_sext<12,6>(tmp714_reg_59604.read());
}
void a0_bin_conv::thread_tmp3634_cast_fu_42036_p1() {
tmp3634_cast_fu_42036_p1 = esl_sext<12,6>(tmp715_reg_59615.read());
}
void a0_bin_conv::thread_tmp3635_cast_fu_42046_p1() {
tmp3635_cast_fu_42046_p1 = esl_sext<12,6>(tmp716_reg_59626.read());
}
void a0_bin_conv::thread_tmp3636_cast_fu_42056_p1() {
tmp3636_cast_fu_42056_p1 = esl_sext<12,6>(tmp717_reg_59637.read());
}
void a0_bin_conv::thread_tmp3637_cast_fu_42066_p1() {
tmp3637_cast_fu_42066_p1 = esl_sext<12,6>(tmp718_reg_59648.read());
}
void a0_bin_conv::thread_tmp3638_cast_fu_42076_p1() {
tmp3638_cast_fu_42076_p1 = esl_sext<12,6>(tmp719_reg_59659.read());
}
void a0_bin_conv::thread_tmp3639_cast_fu_42086_p1() {
tmp3639_cast_fu_42086_p1 = esl_sext<12,6>(tmp720_reg_59670.read());
}
void a0_bin_conv::thread_tmp3640_cast_fu_42096_p1() {
tmp3640_cast_fu_42096_p1 = esl_sext<12,6>(tmp721_reg_59681.read());
}
void a0_bin_conv::thread_tmp3641_cast_fu_42106_p1() {
tmp3641_cast_fu_42106_p1 = esl_sext<12,6>(tmp722_reg_59692.read());
}
void a0_bin_conv::thread_tmp3642_cast_fu_42116_p1() {
tmp3642_cast_fu_42116_p1 = esl_sext<12,6>(tmp723_reg_59703.read());
}
void a0_bin_conv::thread_tmp3643_cast_fu_42126_p1() {
tmp3643_cast_fu_42126_p1 = esl_sext<12,6>(tmp724_reg_59714.read());
}
void a0_bin_conv::thread_tmp3644_cast_fu_42136_p1() {
tmp3644_cast_fu_42136_p1 = esl_sext<12,6>(tmp725_reg_59725.read());
}
void a0_bin_conv::thread_tmp3645_cast_fu_42146_p1() {
tmp3645_cast_fu_42146_p1 = esl_sext<12,6>(tmp726_reg_59736.read());
}
void a0_bin_conv::thread_tmp3646_cast_fu_42156_p1() {
tmp3646_cast_fu_42156_p1 = esl_sext<12,6>(tmp727_reg_59747.read());
}
void a0_bin_conv::thread_tmp3647_cast_fu_42166_p1() {
tmp3647_cast_fu_42166_p1 = esl_sext<12,6>(tmp728_reg_59758.read());
}
void a0_bin_conv::thread_tmp3648_cast_fu_42176_p1() {
tmp3648_cast_fu_42176_p1 = esl_sext<12,6>(tmp729_reg_59769.read());
}
void a0_bin_conv::thread_tmp3649_cast_fu_42186_p1() {
tmp3649_cast_fu_42186_p1 = esl_sext<12,6>(tmp730_reg_59780.read());
}
void a0_bin_conv::thread_tmp3650_cast_fu_42196_p1() {
tmp3650_cast_fu_42196_p1 = esl_sext<12,6>(tmp731_reg_59791.read());
}
void a0_bin_conv::thread_tmp3651_cast_fu_42206_p1() {
tmp3651_cast_fu_42206_p1 = esl_sext<12,6>(tmp732_reg_59802.read());
}
void a0_bin_conv::thread_tmp669_fu_40688_p2() {
tmp669_fu_40688_p2 = (!tmp_361_0_1_cast_fu_40684_p1.read().is_01() || !tmp_361_cast_fu_40680_p1.read().is_01())? sc_lv<6>(): (sc_bigint<6>(tmp_361_0_1_cast_fu_40684_p1.read()) + sc_bigint<6>(tmp_361_cast_fu_40680_p1.read()));
}
void a0_bin_conv::thread_tmp670_fu_40702_p2() {
tmp670_fu_40702_p2 = (!tmp_361_1_1_cast_fu_40698_p1.read().is_01() || !tmp_361_1_cast_fu_40694_p1.read().is_01())? sc_lv<6>(): (sc_bigint<6>(tmp_361_1_1_cast_fu_40698_p1.read()) + sc_bigint<6>(tmp_361_1_cast_fu_40694_p1.read()));
}
void a0_bin_conv::thread_tmp671_fu_40716_p2() {
tmp671_fu_40716_p2 = (!tmp_361_2_1_cast_fu_40712_p1.read().is_01() || !tmp_361_2_cast_fu_40708_p1.read().is_01())? sc_lv<6>(): (sc_bigint<6>(tmp_361_2_1_cast_fu_40712_p1.read()) + sc_bigint<6>(tmp_361_2_cast_fu_40708_p1.read()));
}
void a0_bin_conv::thread_tmp672_fu_40730_p2() {
tmp672_fu_40730_p2 = (!tmp_361_3_1_cast_fu_40726_p1.read().is_01() || !tmp_361_3_cast_fu_40722_p1.read().is_01())? sc_lv<6>(): (sc_bigint<6>(tmp_361_3_1_cast_fu_40726_p1.read()) + sc_bigint<6>(tmp_361_3_cast_fu_40722_p1.read()));
}
void a0_bin_conv::thread_tmp673_fu_40744_p2() {
tmp673_fu_40744_p2 = (!tmp_361_4_1_cast_fu_40740_p1.read().is_01() || !tmp_361_4_cast_fu_40736_p1.read().is_01())? sc_lv<6>(): (sc_bigint<6>(tmp_361_4_1_cast_fu_40740_p1.read()) + sc_bigint<6>(tmp_361_4_cast_fu_40736_p1.read()));
}
void a0_bin_conv::thread_tmp674_fu_40758_p2() {
tmp674_fu_40758_p2 = (!tmp_361_5_1_cast_fu_40754_p1.read().is_01() || !tmp_361_5_cast_fu_40750_p1.read().is_01())? sc_lv<6>(): (sc_bigint<6>(tmp_361_5_1_cast_fu_40754_p1.read()) + sc_bigint<6>(tmp_361_5_cast_fu_40750_p1.read()));
}
void a0_bin_conv::thread_tmp675_fu_40772_p2() {
tmp675_fu_40772_p2 = (!tmp_361_6_1_cast_fu_40768_p1.read().is_01() || !tmp_361_6_cast_fu_40764_p1.read().is_01())? sc_lv<6>(): (sc_bigint<6>(tmp_361_6_1_cast_fu_40768_p1.read()) + sc_bigint<6>(tmp_361_6_cast_fu_40764_p1.read()));
}
void a0_bin_conv::thread_tmp676_fu_40786_p2() {
tmp676_fu_40786_p2 = (!tmp_361_7_1_cast_fu_40782_p1.read().is_01() || !tmp_361_7_cast_fu_40778_p1.read().is_01())? sc_lv<6>(): (sc_bigint<6>(tmp_361_7_1_cast_fu_40782_p1.read()) + sc_bigint<6>(tmp_361_7_cast_fu_40778_p1.read()));
}
void a0_bin_conv::thread_tmp677_fu_40800_p2() {
tmp677_fu_40800_p2 = (!tmp_361_8_1_cast_fu_40796_p1.read().is_01() || !tmp_361_8_cast_fu_40792_p1.read().is_01())? sc_lv<6>(): (sc_bigint<6>(tmp_361_8_1_cast_fu_40796_p1.read()) + sc_bigint<6>(tmp_361_8_cast_fu_40792_p1.read()));
}
void a0_bin_conv::thread_tmp678_fu_40814_p2() {
tmp678_fu_40814_p2 = (!tmp_361_9_1_cast_fu_40810_p1.read().is_01() || !tmp_361_9_cast_fu_40806_p1.read().is_01())? sc_lv<6>(): (sc_bigint<6>(tmp_361_9_1_cast_fu_40810_p1.read()) + sc_bigint<6>(tmp_361_9_cast_fu_40806_p1.read()));
}
void a0_bin_conv::thread_tmp679_fu_40828_p2() {
tmp679_fu_40828_p2 = (!tmp_361_10_1_cast_fu_40824_p1.read().is_01() || !tmp_361_cast_65_fu_40820_p1.read().is_01())? sc_lv<6>(): (sc_bigint<6>(tmp_361_10_1_cast_fu_40824_p1.read()) + sc_bigint<6>(tmp_361_cast_65_fu_40820_p1.read()));
}
void a0_bin_conv::thread_tmp680_fu_40842_p2() {
tmp680_fu_40842_p2 = (!tmp_361_11_1_cast_fu_40838_p1.read().is_01() || !tmp_361_10_cast_fu_40834_p1.read().is_01())? sc_lv<6>(): (sc_bigint<6>(tmp_361_11_1_cast_fu_40838_p1.read()) + sc_bigint<6>(tmp_361_10_cast_fu_40834_p1.read()));
}
void a0_bin_conv::thread_tmp681_fu_40856_p2() {
tmp681_fu_40856_p2 = (!tmp_361_12_1_cast_fu_40852_p1.read().is_01() || !tmp_361_11_cast_fu_40848_p1.read().is_01())? sc_lv<6>(): (sc_bigint<6>(tmp_361_12_1_cast_fu_40852_p1.read()) + sc_bigint<6>(tmp_361_11_cast_fu_40848_p1.read()));
}
void a0_bin_conv::thread_tmp682_fu_40870_p2() {
tmp682_fu_40870_p2 = (!tmp_361_13_1_cast_fu_40866_p1.read().is_01() || !tmp_361_12_cast_fu_40862_p1.read().is_01())? sc_lv<6>(): (sc_bigint<6>(tmp_361_13_1_cast_fu_40866_p1.read()) + sc_bigint<6>(tmp_361_12_cast_fu_40862_p1.read()));
}
void a0_bin_conv::thread_tmp683_fu_40884_p2() {
tmp683_fu_40884_p2 = (!tmp_361_14_1_cast_fu_40880_p1.read().is_01() || !tmp_361_13_cast_fu_40876_p1.read().is_01())? sc_lv<6>(): (sc_bigint<6>(tmp_361_14_1_cast_fu_40880_p1.read()) + sc_bigint<6>(tmp_361_13_cast_fu_40876_p1.read()));
}
void a0_bin_conv::thread_tmp684_fu_40898_p2() {
tmp684_fu_40898_p2 = (!tmp_361_15_1_cast_fu_40894_p1.read().is_01() || !tmp_361_14_cast_fu_40890_p1.read().is_01())? sc_lv<6>(): (sc_bigint<6>(tmp_361_15_1_cast_fu_40894_p1.read()) + sc_bigint<6>(tmp_361_14_cast_fu_40890_p1.read()));
}
void a0_bin_conv::thread_tmp685_fu_40912_p2() {
tmp685_fu_40912_p2 = (!tmp_361_16_1_cast_fu_40908_p1.read().is_01() || !tmp_361_15_cast_fu_40904_p1.read().is_01())? sc_lv<6>(): (sc_bigint<6>(tmp_361_16_1_cast_fu_40908_p1.read()) + sc_bigint<6>(tmp_361_15_cast_fu_40904_p1.read()));
}
void a0_bin_conv::thread_tmp686_fu_40926_p2() {
tmp686_fu_40926_p2 = (!tmp_361_17_1_cast_fu_40922_p1.read().is_01() || !tmp_361_16_cast_fu_40918_p1.read().is_01())? sc_lv<6>(): (sc_bigint<6>(tmp_361_17_1_cast_fu_40922_p1.read()) + sc_bigint<6>(tmp_361_16_cast_fu_40918_p1.read()));
}
void a0_bin_conv::thread_tmp687_fu_40940_p2() {
tmp687_fu_40940_p2 = (!tmp_361_18_1_cast_fu_40936_p1.read().is_01() || !tmp_361_17_cast_fu_40932_p1.read().is_01())? sc_lv<6>(): (sc_bigint<6>(tmp_361_18_1_cast_fu_40936_p1.read()) + sc_bigint<6>(tmp_361_17_cast_fu_40932_p1.read()));
}
void a0_bin_conv::thread_tmp688_fu_40954_p2() {
tmp688_fu_40954_p2 = (!tmp_361_19_1_cast_fu_40950_p1.read().is_01() || !tmp_361_18_cast_fu_40946_p1.read().is_01())? sc_lv<6>(): (sc_bigint<6>(tmp_361_19_1_cast_fu_40950_p1.read()) + sc_bigint<6>(tmp_361_18_cast_fu_40946_p1.read()));
}
void a0_bin_conv::thread_tmp689_fu_40968_p2() {
tmp689_fu_40968_p2 = (!tmp_361_20_1_cast_fu_40964_p1.read().is_01() || !tmp_361_19_cast_fu_40960_p1.read().is_01())? sc_lv<6>(): (sc_bigint<6>(tmp_361_20_1_cast_fu_40964_p1.read()) + sc_bigint<6>(tmp_361_19_cast_fu_40960_p1.read()));
}
void a0_bin_conv::thread_tmp690_fu_40982_p2() {
tmp690_fu_40982_p2 = (!tmp_361_21_1_cast_fu_40978_p1.read().is_01() || !tmp_361_20_cast_fu_40974_p1.read().is_01())? sc_lv<6>(): (sc_bigint<6>(tmp_361_21_1_cast_fu_40978_p1.read()) + sc_bigint<6>(tmp_361_20_cast_fu_40974_p1.read()));
}
void a0_bin_conv::thread_tmp691_fu_40996_p2() {
tmp691_fu_40996_p2 = (!tmp_361_22_1_cast_fu_40992_p1.read().is_01() || !tmp_361_21_cast_fu_40988_p1.read().is_01())? sc_lv<6>(): (sc_bigint<6>(tmp_361_22_1_cast_fu_40992_p1.read()) + sc_bigint<6>(tmp_361_21_cast_fu_40988_p1.read()));
}
void a0_bin_conv::thread_tmp692_fu_41010_p2() {
tmp692_fu_41010_p2 = (!tmp_361_23_1_cast_fu_41006_p1.read().is_01() || !tmp_361_22_cast_fu_41002_p1.read().is_01())? sc_lv<6>(): (sc_bigint<6>(tmp_361_23_1_cast_fu_41006_p1.read()) + sc_bigint<6>(tmp_361_22_cast_fu_41002_p1.read()));
}
void a0_bin_conv::thread_tmp693_fu_41024_p2() {
tmp693_fu_41024_p2 = (!tmp_361_24_1_cast_fu_41020_p1.read().is_01() || !tmp_361_23_cast_fu_41016_p1.read().is_01())? sc_lv<6>(): (sc_bigint<6>(tmp_361_24_1_cast_fu_41020_p1.read()) + sc_bigint<6>(tmp_361_23_cast_fu_41016_p1.read()));
}
void a0_bin_conv::thread_tmp694_fu_41038_p2() {
tmp694_fu_41038_p2 = (!tmp_361_25_1_cast_fu_41034_p1.read().is_01() || !tmp_361_24_cast_fu_41030_p1.read().is_01())? sc_lv<6>(): (sc_bigint<6>(tmp_361_25_1_cast_fu_41034_p1.read()) + sc_bigint<6>(tmp_361_24_cast_fu_41030_p1.read()));
}
void a0_bin_conv::thread_tmp695_fu_41052_p2() {
tmp695_fu_41052_p2 = (!tmp_361_26_1_cast_fu_41048_p1.read().is_01() || !tmp_361_25_cast_fu_41044_p1.read().is_01())? sc_lv<6>(): (sc_bigint<6>(tmp_361_26_1_cast_fu_41048_p1.read()) + sc_bigint<6>(tmp_361_25_cast_fu_41044_p1.read()));
}
void a0_bin_conv::thread_tmp696_fu_41066_p2() {
tmp696_fu_41066_p2 = (!tmp_361_27_1_cast_fu_41062_p1.read().is_01() || !tmp_361_26_cast_fu_41058_p1.read().is_01())? sc_lv<6>(): (sc_bigint<6>(tmp_361_27_1_cast_fu_41062_p1.read()) + sc_bigint<6>(tmp_361_26_cast_fu_41058_p1.read()));
}
void a0_bin_conv::thread_tmp697_fu_41080_p2() {
tmp697_fu_41080_p2 = (!tmp_361_28_1_cast_fu_41076_p1.read().is_01() || !tmp_361_27_cast_fu_41072_p1.read().is_01())? sc_lv<6>(): (sc_bigint<6>(tmp_361_28_1_cast_fu_41076_p1.read()) + sc_bigint<6>(tmp_361_27_cast_fu_41072_p1.read()));
}
void a0_bin_conv::thread_tmp698_fu_41094_p2() {
tmp698_fu_41094_p2 = (!tmp_361_29_1_cast_fu_41090_p1.read().is_01() || !tmp_361_28_cast_fu_41086_p1.read().is_01())? sc_lv<6>(): (sc_bigint<6>(tmp_361_29_1_cast_fu_41090_p1.read()) + sc_bigint<6>(tmp_361_28_cast_fu_41086_p1.read()));
}
void a0_bin_conv::thread_tmp699_fu_41108_p2() {
tmp699_fu_41108_p2 = (!tmp_361_30_1_cast_fu_41104_p1.read().is_01() || !tmp_361_29_cast_fu_41100_p1.read().is_01())? sc_lv<6>(): (sc_bigint<6>(tmp_361_30_1_cast_fu_41104_p1.read()) + sc_bigint<6>(tmp_361_29_cast_fu_41100_p1.read()));
}
void a0_bin_conv::thread_tmp700_fu_41122_p2() {
tmp700_fu_41122_p2 = (!tmp_361_31_1_cast_fu_41118_p1.read().is_01() || !tmp_361_30_cast_fu_41114_p1.read().is_01())? sc_lv<6>(): (sc_bigint<6>(tmp_361_31_1_cast_fu_41118_p1.read()) + sc_bigint<6>(tmp_361_30_cast_fu_41114_p1.read()));
}
void a0_bin_conv::thread_tmp701_fu_41136_p2() {
tmp701_fu_41136_p2 = (!tmp_361_32_1_cast_fu_41132_p1.read().is_01() || !tmp_361_31_cast_fu_41128_p1.read().is_01())? sc_lv<6>(): (sc_bigint<6>(tmp_361_32_1_cast_fu_41132_p1.read()) + sc_bigint<6>(tmp_361_31_cast_fu_41128_p1.read()));
}
void a0_bin_conv::thread_tmp702_fu_41150_p2() {
tmp702_fu_41150_p2 = (!tmp_361_33_1_cast_fu_41146_p1.read().is_01() || !tmp_361_32_cast_fu_41142_p1.read().is_01())? sc_lv<6>(): (sc_bigint<6>(tmp_361_33_1_cast_fu_41146_p1.read()) + sc_bigint<6>(tmp_361_32_cast_fu_41142_p1.read()));
}
void a0_bin_conv::thread_tmp703_fu_41164_p2() {
tmp703_fu_41164_p2 = (!tmp_361_34_1_cast_fu_41160_p1.read().is_01() || !tmp_361_33_cast_fu_41156_p1.read().is_01())? sc_lv<6>(): (sc_bigint<6>(tmp_361_34_1_cast_fu_41160_p1.read()) + sc_bigint<6>(tmp_361_33_cast_fu_41156_p1.read()));
}
void a0_bin_conv::thread_tmp704_fu_41178_p2() {
tmp704_fu_41178_p2 = (!tmp_361_35_1_cast_fu_41174_p1.read().is_01() || !tmp_361_34_cast_fu_41170_p1.read().is_01())? sc_lv<6>(): (sc_bigint<6>(tmp_361_35_1_cast_fu_41174_p1.read()) + sc_bigint<6>(tmp_361_34_cast_fu_41170_p1.read()));
}
void a0_bin_conv::thread_tmp705_fu_41192_p2() {
tmp705_fu_41192_p2 = (!tmp_361_36_1_cast_fu_41188_p1.read().is_01() || !tmp_361_35_cast_fu_41184_p1.read().is_01())? sc_lv<6>(): (sc_bigint<6>(tmp_361_36_1_cast_fu_41188_p1.read()) + sc_bigint<6>(tmp_361_35_cast_fu_41184_p1.read()));
}
void a0_bin_conv::thread_tmp706_fu_41206_p2() {
tmp706_fu_41206_p2 = (!tmp_361_37_1_cast_fu_41202_p1.read().is_01() || !tmp_361_36_cast_fu_41198_p1.read().is_01())? sc_lv<6>(): (sc_bigint<6>(tmp_361_37_1_cast_fu_41202_p1.read()) + sc_bigint<6>(tmp_361_36_cast_fu_41198_p1.read()));
}
void a0_bin_conv::thread_tmp707_fu_41220_p2() {
tmp707_fu_41220_p2 = (!tmp_361_38_1_cast_fu_41216_p1.read().is_01() || !tmp_361_37_cast_fu_41212_p1.read().is_01())? sc_lv<6>(): (sc_bigint<6>(tmp_361_38_1_cast_fu_41216_p1.read()) + sc_bigint<6>(tmp_361_37_cast_fu_41212_p1.read()));
}
void a0_bin_conv::thread_tmp708_fu_41234_p2() {
tmp708_fu_41234_p2 = (!tmp_361_39_1_cast_fu_41230_p1.read().is_01() || !tmp_361_38_cast_fu_41226_p1.read().is_01())? sc_lv<6>(): (sc_bigint<6>(tmp_361_39_1_cast_fu_41230_p1.read()) + sc_bigint<6>(tmp_361_38_cast_fu_41226_p1.read()));
}
void a0_bin_conv::thread_tmp709_fu_41248_p2() {
tmp709_fu_41248_p2 = (!tmp_361_40_1_cast_fu_41244_p1.read().is_01() || !tmp_361_39_cast_fu_41240_p1.read().is_01())? sc_lv<6>(): (sc_bigint<6>(tmp_361_40_1_cast_fu_41244_p1.read()) + sc_bigint<6>(tmp_361_39_cast_fu_41240_p1.read()));
}
void a0_bin_conv::thread_tmp710_fu_41262_p2() {
tmp710_fu_41262_p2 = (!tmp_361_41_1_cast_fu_41258_p1.read().is_01() || !tmp_361_40_cast_fu_41254_p1.read().is_01())? sc_lv<6>(): (sc_bigint<6>(tmp_361_41_1_cast_fu_41258_p1.read()) + sc_bigint<6>(tmp_361_40_cast_fu_41254_p1.read()));
}
void a0_bin_conv::thread_tmp711_fu_41276_p2() {
tmp711_fu_41276_p2 = (!tmp_361_42_1_cast_fu_41272_p1.read().is_01() || !tmp_361_41_cast_fu_41268_p1.read().is_01())? sc_lv<6>(): (sc_bigint<6>(tmp_361_42_1_cast_fu_41272_p1.read()) + sc_bigint<6>(tmp_361_41_cast_fu_41268_p1.read()));
}
void a0_bin_conv::thread_tmp712_fu_41290_p2() {
tmp712_fu_41290_p2 = (!tmp_361_43_1_cast_fu_41286_p1.read().is_01() || !tmp_361_42_cast_fu_41282_p1.read().is_01())? sc_lv<6>(): (sc_bigint<6>(tmp_361_43_1_cast_fu_41286_p1.read()) + sc_bigint<6>(tmp_361_42_cast_fu_41282_p1.read()));
}
void a0_bin_conv::thread_tmp713_fu_41304_p2() {
tmp713_fu_41304_p2 = (!tmp_361_44_1_cast_fu_41300_p1.read().is_01() || !tmp_361_43_cast_fu_41296_p1.read().is_01())? sc_lv<6>(): (sc_bigint<6>(tmp_361_44_1_cast_fu_41300_p1.read()) + sc_bigint<6>(tmp_361_43_cast_fu_41296_p1.read()));
}
void a0_bin_conv::thread_tmp714_fu_41318_p2() {
tmp714_fu_41318_p2 = (!tmp_361_45_1_cast_fu_41314_p1.read().is_01() || !tmp_361_44_cast_fu_41310_p1.read().is_01())? sc_lv<6>(): (sc_bigint<6>(tmp_361_45_1_cast_fu_41314_p1.read()) + sc_bigint<6>(tmp_361_44_cast_fu_41310_p1.read()));
}
void a0_bin_conv::thread_tmp715_fu_41332_p2() {
tmp715_fu_41332_p2 = (!tmp_361_46_1_cast_fu_41328_p1.read().is_01() || !tmp_361_45_cast_fu_41324_p1.read().is_01())? sc_lv<6>(): (sc_bigint<6>(tmp_361_46_1_cast_fu_41328_p1.read()) + sc_bigint<6>(tmp_361_45_cast_fu_41324_p1.read()));
}
void a0_bin_conv::thread_tmp716_fu_41346_p2() {
tmp716_fu_41346_p2 = (!tmp_361_47_1_cast_fu_41342_p1.read().is_01() || !tmp_361_46_cast_fu_41338_p1.read().is_01())? sc_lv<6>(): (sc_bigint<6>(tmp_361_47_1_cast_fu_41342_p1.read()) + sc_bigint<6>(tmp_361_46_cast_fu_41338_p1.read()));
}
void a0_bin_conv::thread_tmp717_fu_41360_p2() {
tmp717_fu_41360_p2 = (!tmp_361_48_1_cast_fu_41356_p1.read().is_01() || !tmp_361_47_cast_fu_41352_p1.read().is_01())? sc_lv<6>(): (sc_bigint<6>(tmp_361_48_1_cast_fu_41356_p1.read()) + sc_bigint<6>(tmp_361_47_cast_fu_41352_p1.read()));
}
void a0_bin_conv::thread_tmp718_fu_41374_p2() {
tmp718_fu_41374_p2 = (!tmp_361_49_1_cast_fu_41370_p1.read().is_01() || !tmp_361_48_cast_fu_41366_p1.read().is_01())? sc_lv<6>(): (sc_bigint<6>(tmp_361_49_1_cast_fu_41370_p1.read()) + sc_bigint<6>(tmp_361_48_cast_fu_41366_p1.read()));
}
void a0_bin_conv::thread_tmp719_fu_41388_p2() {
tmp719_fu_41388_p2 = (!tmp_361_50_1_cast_fu_41384_p1.read().is_01() || !tmp_361_49_cast_fu_41380_p1.read().is_01())? sc_lv<6>(): (sc_bigint<6>(tmp_361_50_1_cast_fu_41384_p1.read()) + sc_bigint<6>(tmp_361_49_cast_fu_41380_p1.read()));
}
void a0_bin_conv::thread_tmp720_fu_41402_p2() {
tmp720_fu_41402_p2 = (!tmp_361_51_1_cast_fu_41398_p1.read().is_01() || !tmp_361_50_cast_fu_41394_p1.read().is_01())? sc_lv<6>(): (sc_bigint<6>(tmp_361_51_1_cast_fu_41398_p1.read()) + sc_bigint<6>(tmp_361_50_cast_fu_41394_p1.read()));
}
void a0_bin_conv::thread_tmp721_fu_41416_p2() {
tmp721_fu_41416_p2 = (!tmp_361_52_1_cast_fu_41412_p1.read().is_01() || !tmp_361_51_cast_fu_41408_p1.read().is_01())? sc_lv<6>(): (sc_bigint<6>(tmp_361_52_1_cast_fu_41412_p1.read()) + sc_bigint<6>(tmp_361_51_cast_fu_41408_p1.read()));
}
void a0_bin_conv::thread_tmp722_fu_41430_p2() {
tmp722_fu_41430_p2 = (!tmp_361_53_1_cast_fu_41426_p1.read().is_01() || !tmp_361_52_cast_fu_41422_p1.read().is_01())? sc_lv<6>(): (sc_bigint<6>(tmp_361_53_1_cast_fu_41426_p1.read()) + sc_bigint<6>(tmp_361_52_cast_fu_41422_p1.read()));
}
void a0_bin_conv::thread_tmp723_fu_41444_p2() {
tmp723_fu_41444_p2 = (!tmp_361_54_1_cast_fu_41440_p1.read().is_01() || !tmp_361_53_cast_fu_41436_p1.read().is_01())? sc_lv<6>(): (sc_bigint<6>(tmp_361_54_1_cast_fu_41440_p1.read()) + sc_bigint<6>(tmp_361_53_cast_fu_41436_p1.read()));
}
void a0_bin_conv::thread_tmp724_fu_41458_p2() {
tmp724_fu_41458_p2 = (!tmp_361_55_1_cast_fu_41454_p1.read().is_01() || !tmp_361_54_cast_fu_41450_p1.read().is_01())? sc_lv<6>(): (sc_bigint<6>(tmp_361_55_1_cast_fu_41454_p1.read()) + sc_bigint<6>(tmp_361_54_cast_fu_41450_p1.read()));
}
void a0_bin_conv::thread_tmp725_fu_41472_p2() {
tmp725_fu_41472_p2 = (!tmp_361_56_1_cast_fu_41468_p1.read().is_01() || !tmp_361_55_cast_fu_41464_p1.read().is_01())? sc_lv<6>(): (sc_bigint<6>(tmp_361_56_1_cast_fu_41468_p1.read()) + sc_bigint<6>(tmp_361_55_cast_fu_41464_p1.read()));
}
void a0_bin_conv::thread_tmp726_fu_41486_p2() {
tmp726_fu_41486_p2 = (!tmp_361_57_1_cast_fu_41482_p1.read().is_01() || !tmp_361_56_cast_fu_41478_p1.read().is_01())? sc_lv<6>(): (sc_bigint<6>(tmp_361_57_1_cast_fu_41482_p1.read()) + sc_bigint<6>(tmp_361_56_cast_fu_41478_p1.read()));
}
void a0_bin_conv::thread_tmp727_fu_41500_p2() {
tmp727_fu_41500_p2 = (!tmp_361_58_1_cast_fu_41496_p1.read().is_01() || !tmp_361_57_cast_fu_41492_p1.read().is_01())? sc_lv<6>(): (sc_bigint<6>(tmp_361_58_1_cast_fu_41496_p1.read()) + sc_bigint<6>(tmp_361_57_cast_fu_41492_p1.read()));
}
void a0_bin_conv::thread_tmp728_fu_41514_p2() {
tmp728_fu_41514_p2 = (!tmp_361_59_1_cast_fu_41510_p1.read().is_01() || !tmp_361_58_cast_fu_41506_p1.read().is_01())? sc_lv<6>(): (sc_bigint<6>(tmp_361_59_1_cast_fu_41510_p1.read()) + sc_bigint<6>(tmp_361_58_cast_fu_41506_p1.read()));
}
void a0_bin_conv::thread_tmp729_fu_41528_p2() {
tmp729_fu_41528_p2 = (!tmp_361_60_1_cast_fu_41524_p1.read().is_01() || !tmp_361_59_cast_fu_41520_p1.read().is_01())? sc_lv<6>(): (sc_bigint<6>(tmp_361_60_1_cast_fu_41524_p1.read()) + sc_bigint<6>(tmp_361_59_cast_fu_41520_p1.read()));
}
void a0_bin_conv::thread_tmp730_fu_41542_p2() {
tmp730_fu_41542_p2 = (!tmp_361_61_1_cast_fu_41538_p1.read().is_01() || !tmp_361_60_cast_fu_41534_p1.read().is_01())? sc_lv<6>(): (sc_bigint<6>(tmp_361_61_1_cast_fu_41538_p1.read()) + sc_bigint<6>(tmp_361_60_cast_fu_41534_p1.read()));
}
void a0_bin_conv::thread_tmp731_fu_41556_p2() {
tmp731_fu_41556_p2 = (!tmp_361_62_1_cast_fu_41552_p1.read().is_01() || !tmp_361_61_cast_fu_41548_p1.read().is_01())? sc_lv<6>(): (sc_bigint<6>(tmp_361_62_1_cast_fu_41552_p1.read()) + sc_bigint<6>(tmp_361_61_cast_fu_41548_p1.read()));
}
void a0_bin_conv::thread_tmp732_fu_41570_p2() {
tmp732_fu_41570_p2 = (!tmp_361_63_1_cast_fu_41566_p1.read().is_01() || !tmp_361_62_cast_fu_41562_p1.read().is_01())? sc_lv<6>(): (sc_bigint<6>(tmp_361_63_1_cast_fu_41566_p1.read()) + sc_bigint<6>(tmp_361_62_cast_fu_41562_p1.read()));
}
void a0_bin_conv::thread_tmp_104_fu_19662_p3() {
tmp_104_fu_19662_p3 = esl_concat<3,1>(log_width_V_fu_19620_p2.read(), ap_const_lv1_0);
}
void a0_bin_conv::thread_tmp_105_fu_19692_p2() {
tmp_105_fu_19692_p2 = (!tmp_113_cast2_fu_19658_p1.read().is_01())? sc_lv<7>(): ap_const_lv7_1 << (unsigned short)tmp_113_cast2_fu_19658_p1.read().to_uint();
}
void a0_bin_conv::thread_tmp_106_fu_19712_p2() {
tmp_106_fu_19712_p2 = (!tmp_117_cast_fu_19708_p1.read().is_01())? sc_lv<4>(): ap_const_lv4_F >> (unsigned short)tmp_117_cast_fu_19708_p1.read().to_uint();
}
void a0_bin_conv::thread_tmp_107_fu_19940_p2() {
tmp_107_fu_19940_p2 = (!p_7_reg_6154.read().is_01() || !ap_const_lv6_20.is_01())? sc_lv<1>(): sc_lv<1>(p_7_reg_6154.read() == ap_const_lv6_20);
}
void a0_bin_conv::thread_tmp_110_fu_20106_p2() {
tmp_110_fu_20106_p2 = (tmp_1231_fu_20038_p1.read() ^ ap_const_lv3_4);
}
void a0_bin_conv::thread_tmp_111_fu_20146_p2() {
tmp_111_fu_20146_p2 = (!ap_const_lv3_0.is_01() || !tmp_1231_fu_20038_p1.read().is_01())? sc_lv<3>(): (sc_biguint<3>(ap_const_lv3_0) - sc_biguint<3>(tmp_1231_fu_20038_p1.read()));
}
void a0_bin_conv::thread_tmp_112_cast_fu_19634_p1() {
tmp_112_cast_fu_19634_p1 = esl_zext<5,3>(tmp_s_fu_19626_p3.read());
}
void a0_bin_conv::thread_tmp_113_cast1_fu_19654_p1() {
tmp_113_cast1_fu_19654_p1 = esl_zext<5,3>(log_width_V_fu_19620_p2.read());
}
void a0_bin_conv::thread_tmp_113_cast2_fu_19658_p1() {
tmp_113_cast2_fu_19658_p1 = esl_zext<7,3>(log_width_V_fu_19620_p2.read());
}
void a0_bin_conv::thread_tmp_113_fu_19952_p1() {
tmp_113_fu_19952_p1 = esl_zext<32,6>(p_7_reg_6154.read());
}
void a0_bin_conv::thread_tmp_114_cast_fu_19670_p1() {
tmp_114_cast_fu_19670_p1 = esl_zext<12,4>(tmp_104_fu_19662_p3.read());
}
void a0_bin_conv::thread_tmp_114_fu_20825_p2() {
tmp_114_fu_20825_p2 = (!lhs_V_fu_20821_p1.read().is_01() || !n_phases_cast_reg_45729.read().is_01())? sc_lv<1>(): (sc_biguint<15>(lhs_V_fu_20821_p1.read()) < sc_biguint<15>(n_phases_cast_reg_45729.read()));
}
void a0_bin_conv::thread_tmp_117_cast_fu_19708_p1() {
tmp_117_cast_fu_19708_p1 = esl_zext<4,3>(grp_fu_19490_p2.read());
}
void a0_bin_conv::thread_tmp_118_fu_42316_p2() {
tmp_118_fu_42316_p2 = (!ap_const_lv3_2.is_01() || !log_slice_V_reg_45699.read().is_01())? sc_lv<3>(): (sc_biguint<3>(ap_const_lv3_2) + sc_biguint<3>(log_slice_V_reg_45699.read()));
}
void a0_bin_conv::thread_tmp_120_fu_45592_p0() {
tmp_120_fu_45592_p0 = (sc_lv<15>) (tmp_120_fu_45592_p00.read());
}
}
| 58.864912 | 239 | 0.765424 | stephenneuendorffer |
3aeb0a71223ede94329dd5d1a3b034dae24f3c54 | 2,101 | cc | C++ | src/contest/misc/Sales.cc | anshika581/competitive-programming-1 | c34fb89820cd7260661daa2283f492b07cd9f8d2 | [
"Apache-2.0",
"MIT"
] | 83 | 2017-08-30T01:20:03.000Z | 2022-02-12T13:50:27.000Z | src/contest/misc/Sales.cc | anshika581/competitive-programming-1 | c34fb89820cd7260661daa2283f492b07cd9f8d2 | [
"Apache-2.0",
"MIT"
] | 1 | 2015-08-20T13:37:59.000Z | 2015-08-26T00:56:39.000Z | src/contest/misc/Sales.cc | anshika581/competitive-programming-1 | c34fb89820cd7260661daa2283f492b07cd9f8d2 | [
"Apache-2.0",
"MIT"
] | 41 | 2017-11-09T06:10:08.000Z | 2022-01-11T14:10:25.000Z | #include <bits/stdc++.h>
using namespace std;
#define SIZE 30000
inline int scan(int &x) {
char c;
while (c = getchar(), c < '0' || c > '9')
;
x = c - '0';
while (c = getchar(), c >= '0' && c <= '9')
x = x * 10 + c - '0';
}
int tree[32768][51];
int B, N, D;
int cost[SIZE + 1], value[SIZE + 1];
int ans[51];
void pushup(int par[], int c[]) {
for (int i = 50; i >= 0; i--) {
for (int j = i; j >= 0; j--) {
if (par[i - j] != -1 && c[j] != -1 && par[i] < par[i - j] + c[j]) {
par[i] = par[i - j] + c[j];
}
}
}
}
void build(int l, int r, int n) {
memset(tree[n], -1, sizeof tree[n]);
tree[n][0] = 0;
if (l == r) {
tree[n][cost[l]] = value[l];
return;
}
int mid = (l + r) >> 1;
build(l, mid, n << 1);
build(mid + 1, r, n << 1 | 1);
pushup(tree[n], tree[n << 1]);
pushup(tree[n], tree[n << 1 | 1]);
}
void update(int x, int n, int l, int r) {
memset(tree[n], -1, sizeof tree[n]);
tree[n][0] = 0;
if (l == x && r == x) {
tree[n][cost[x]] = value[x];
return;
}
int mid = (l + r) >> 1;
if (x <= mid)
update(x, n << 1, l, mid);
else
update(x, n << 1 | 1, mid + 1, r);
pushup(tree[n], tree[n << 1]);
pushup(tree[n], tree[n << 1 | 1]);
}
void query(int l, int r, int n, int x, int y) {
if (x == l && y == r) {
pushup(ans, tree[n]);
return;
}
int mid = (x + y) >> 1;
if (r <= mid)
query(l, r, n << 1, x, mid);
else if (l > mid)
query(l, r, n << 1 | 1, mid + 1, y);
else {
query(l, mid, n << 1, x, mid);
query(mid + 1, r, n << 1 | 1, mid + 1, y);
}
}
int main() {
freopen("in.txt", "r", stdin);
scan(B);
scan(N);
scan(D);
for (int i = 1; i <= N; i++) {
scan(cost[i]);
scan(value[i]);
}
build(1, N, 1);
for (int i = 0; i < D; i++) {
int a, b, x, y;
scan(a);
scan(b);
scan(x);
scan(y);
memset(ans, -1, sizeof ans);
ans[0] = 0;
cost[a] = b;
update(a, 1, 1, N);
query(x, y, 1, 1, N);
int res = 0;
for (int i = 0; i <= B; i++) {
res = max(res, ans[i]);
}
printf("%d\n", res);
}
}
| 20.598039 | 73 | 0.429795 | anshika581 |
3af27fc36d8fb5ab935251d44467991d789b3ef4 | 1,173 | cc | C++ | tests/test_given_get.cc | farnasirim/range-tracker | 8e67ed2c9565fbeabcd69002703abb7b5eab8237 | [
"MIT"
] | null | null | null | tests/test_given_get.cc | farnasirim/range-tracker | 8e67ed2c9565fbeabcd69002703abb7b5eab8237 | [
"MIT"
] | null | null | null | tests/test_given_get.cc | farnasirim/range-tracker | 8e67ed2c9565fbeabcd69002703abb7b5eab8237 | [
"MIT"
] | null | null | null | #include "test_common.h"
TEST_CASE("RangeTracker objects must work correctly on the given get tests",
"[RangeTracker]") {
auto rts = ALL_IMPLEMENTATIONS(int);
std::vector<std::pair<int, int>> empty = {};
for(auto& it: rts) {
it->Add(1, 3);
it->Add(5, 6);
}
std::vector<std::pair<int, int>> existing = {{1, 3}, {5, 6}};
for(auto& it: rts) {
REQUIRE(it->Get(-200, 200) == existing);
REQUIRE(it->Get(1, 2) == subvec(existing, 0, 1));
REQUIRE(it->Get(-1, 1) == empty);
REQUIRE(it->Get(2, 3) == subvec(existing, 0, 1));
REQUIRE(it->Get(5, 6) == subvec(existing, 1, 1));
REQUIRE(it->Get(6, 7) == empty);
}
SECTION("get, scenario 1") {
for(auto& it: rts) {
REQUIRE(it->Get(4, 5) == empty);
}
}
SECTION("get, scenario 2") {
for(auto& it: rts) {
REQUIRE(it->Get(4, 6) == subvec(existing, 1, 1));
}
}
SECTION("get, scenario 3") {
for(auto& it: rts) {
REQUIRE(it->Get(2, 9) == existing);
}
}
}
// i) State [(1, 3), (5, 6)]. Get(4, 5). Returns []
// ii) State [(1, 3), (5, 6)]. Get(4, 6). Returns [(5, 6)]
// iii) State [(1, 3), (5, 6)]. Get(2, 9). Returns [(1, 3), (5, 6)]
| 26.066667 | 76 | 0.524297 | farnasirim |
3af41c50fe748b8e3af751871769b38f1adb345b | 11,595 | cpp | C++ | Submodules/Peano/src/tarch/parallel/Node.cpp | linusseelinger/ExaHyPE-Tsunami | 92a6e14926862e1584ef1e935874c91d252e8112 | [
"BSD-3-Clause"
] | null | null | null | Submodules/Peano/src/tarch/parallel/Node.cpp | linusseelinger/ExaHyPE-Tsunami | 92a6e14926862e1584ef1e935874c91d252e8112 | [
"BSD-3-Clause"
] | null | null | null | Submodules/Peano/src/tarch/parallel/Node.cpp | linusseelinger/ExaHyPE-Tsunami | 92a6e14926862e1584ef1e935874c91d252e8112 | [
"BSD-3-Clause"
] | 1 | 2021-04-08T16:12:18.000Z | 2021-04-08T16:12:18.000Z | #include "tarch/parallel/Node.h"
#include "tarch/Assertions.h"
#include "tarch/services/ServiceRepository.h"
#include <sstream>
#include <cstdlib>
#include "tarch/compiler/CompilerSpecificSettings.h"
#include "tarch/multicore/MulticoreDefinitions.h"
/**
* For the machine name. If it doesn't work, switch it off in the file
* CompilerSpecificSettings.h.
*/
#ifdef CompilerHasUTSName
#include <sys/utsname.h>
#endif
tarch::logging::Log tarch::parallel::Node::_log("tarch::parallel::Node");
bool tarch::parallel::Node::_initIsCalled = false;
namespace {
int tagCounter = 0;
}
void tarch::parallel::Node::releaseTag(int tag) {
if (tag==tagCounter-1) {
tagCounter--;
}
}
int tarch::parallel::Node::reserveFreeTag(const std::string& fullQualifiedMessageName) {
tagCounter++;
// I protect the tag manually (not via log filter), as many tags are actually
// grabbed before most applications initialise their log filters properly.
//
// We may not use isGlobalMaster() as this query checks whether the code is
// properly initialised. Please note rank is -1 as long as MPI is not properly
// initialised, i.e. any tag booking prior to the MPI initialisation is not
// logged properly.
if ( getInstance()._rank==getGlobalMasterRank() ) {
tarch::logging::Log _log("tarch::parallel::Node<static>");
logInfo(
"reserveFreeTag()",
"assigned message " << fullQualifiedMessageName
<< " the free tag " << tagCounter-1
);
}
return tagCounter-1;
}
bool tarch::parallel::Node::isInitialised() const {
return _initIsCalled;
}
void tarch::parallel::Node::ensureThatMessageQueuesAreEmpty( int fromRank, int tag ) {
#ifdef Parallel
int flag;
MPI_Iprobe(fromRank, tag, _communicator, &flag, MPI_STATUS_IGNORE);
if (flag!=0) {
plotMessageQueues();
}
assertion3( flag==0, fromRank, tag, getRank() );
#endif
}
void tarch::parallel::Node::plotMessageQueues() {
#ifdef Parallel
int flag;
MPI_Status status;
MPI_Iprobe(MPI_ANY_SOURCE, MPI_ANY_TAG, _communicator, &flag, &status);
if (flag==0) {
_log.error("plotMessageQueues()", "there are no messages from any sender in MPI queue");
}
else {
logError(
"plotMessageQueues()",
"there is still a message in queue "
" from rank " << status.MPI_SOURCE <<
" with tag " << status.MPI_TAG
);
}
#endif
}
void tarch::parallel::Node::triggerDeadlockTimeOut(
const std::string& className,
const std::string& methodName,
int communicationPartnerRank,
int tag,
int numberOfExpectedMessages,
const std::string& comment
) {
std::ostringstream out;
out << "operation " << className << "::" << methodName << " on node "
<< getRank() << " had to wait more than " << _deadlockTimeOut
<< " seconds for " << numberOfExpectedMessages
<< " message(s) from node " << communicationPartnerRank << " with tag " << tag
<< ". Timeout. " << comment;
_log.error( "triggerDeadlockTimeOut(...)", out.str() );
plotMessageQueues();
exit(DEADLOCK_EXIT_CODE);
}
void tarch::parallel::Node::writeTimeOutWarning(
const std::string& className,
const std::string& methodName,
int communicationPartnerRank,
int tag,
int numberOfExpectedMessages
) {
std::ostringstream out;
out << "operation " << className << "::" << methodName << " on node "
<< getRank() << " had to wait more than " << _timeOutWarning
<< " seconds for " << numberOfExpectedMessages
<< " message(s) from node " << communicationPartnerRank << " with tag " << tag << ". Application "
<< "will terminate after " << _deadlockTimeOut << " seconds because "
<< "of a deadlock";
_log.warning( "writeTimeOutWarning(...)", out.str() );
}
clock_t tarch::parallel::Node::getDeadlockWarningTimeStamp() const {
clock_t result = clock() + _timeOutWarning * CLOCKS_PER_SEC;
assertion4( result>=0, result, clock(), _timeOutWarning, CLOCKS_PER_SEC);
return result;
}
clock_t tarch::parallel::Node::getDeadlockTimeOutTimeStamp() const {
clock_t result = clock() + _deadlockTimeOut * CLOCKS_PER_SEC;
assertion4( result>=0, result, clock(), _timeOutWarning, CLOCKS_PER_SEC);
return result;
}
bool tarch::parallel::Node::isTimeOutDeadlockEnabled() const {
return _areTimeoutsEnabled and _deadlockTimeOut > 0;
}
bool tarch::parallel::Node::isTimeOutWarningEnabled() const {
return _areTimeoutsEnabled and _timeOutWarning > 0;
}
void tarch::parallel::Node::suspendTimeouts( bool timeoutsDisabled ) {
_areTimeoutsEnabled = !timeoutsDisabled;
}
std::string tarch::parallel::MPIReturnValueToString( int result ) {
std::ostringstream out;
#ifdef Parallel
int resultlen;
char* string = new char[MPI_MAX_ERROR_STRING]; // (char *)malloc(MPI_MAX_ERROR_STRING * sizeof(char));
MPI_Error_string(result, string, &resultlen);
int errorclass;
MPI_Error_class(result, &errorclass);
out << "mpi error class: " << errorclass << "="
<< ", mpi error text: " << string;
switch ( errorclass ) {
case MPI_SUCCESS: out << "MPI_SUCCESS [no error]"; break;
case MPI_ERR_BUFFER: out << "MPI_ERR_BUFFER [invalid buffer pointer]"; break;
case MPI_ERR_COUNT: out << "MPI_ERR_COUNT [invalid count argument]"; break;
case MPI_ERR_TYPE: out << "MPI_ERR_TYPE [invalid datatype]"; break;
case MPI_ERR_TAG: out << "MPI_ERR_TAG [invalid tag]"; break;
case MPI_ERR_COMM: out << "MPI_ERR_COMM [invalid communicator]"; break;
case MPI_ERR_RANK: out << "MPI_ERR_RANK [invalid rank]"; break;
case MPI_ERR_REQUEST: out << "MPI_ERR_REQUEST [invalid request handle]"; break;
case MPI_ERR_ROOT: out << "MPI_ERR_ROOT [invalid root argument]"; break;
case MPI_ERR_GROUP: out << "MPI_ERR_GROUP [invalid group]"; break;
case MPI_ERR_OP: out << "MPI_ERR_OP [invalid operation]"; break;
case MPI_ERR_TOPOLOGY: out << "MPI_ERR_TOPOLOGY [invalid topology]"; break;
case MPI_ERR_DIMS: out << "MPI_ERR_DIMS [invalid dimensions]"; break;
case MPI_ERR_ARG: out << "MPI_ERR_ARG [invalid argument]"; break;
case MPI_ERR_UNKNOWN: out << "MPI_ERR_UNKNOWN [unknown error]"; break;
case MPI_ERR_TRUNCATE: out << "MPI_ERR_TRUNCATE [message has been truncated by receiver]"; break;
case MPI_ERR_OTHER: out << "MPI_ERR_OTHER [other unknown error]"; break;
case MPI_ERR_INTERN: out << "MPI_ERR_INTERN [internal mpi error]"; break;
default: out << "unknown"; break;
}
delete[] string;
#else
out << "compiled without -DParallel";
#endif
return out.str();
}
std::string tarch::parallel::MPIStatusToString( const MPI_Status& status ) {
std::ostringstream out;
#ifdef Parallel
out << "status flag:"
<< " MPI_ERROR=" << status.MPI_ERROR
<< " (" << MPIReturnValueToString(status.MPI_ERROR)
<< ") ,MPI_SOURCE=" << status.MPI_SOURCE
<< ",MPI_TAG=" << status.MPI_TAG;
#else
out << "compiled without -DParallel";
#endif
return out.str();
}
#ifdef Parallel
tarch::parallel::Node::Node():
_rank(-1),
_numberOfProcessors(-1),
_communicator( MPI_COMM_WORLD),
_timeOutWarning(0),
_deadlockTimeOut(0),
_areTimeoutsEnabled(true) {
}
#else
tarch::parallel::Node::Node():
_rank(0),
_numberOfProcessors(1),
_communicator(-1),
_timeOutWarning(0),
_deadlockTimeOut(0),
_areTimeoutsEnabled(true) {
}
#endif
#ifdef Parallel
tarch::parallel::Node::Node(const parallel::Node& node):
_rank(-1),
_numberOfProcessors(-1),
_communicator( MPI_COMM_WORLD) {
}
#else
tarch::parallel::Node::Node(const parallel::Node& node):
_rank(0),
_numberOfProcessors(-1),
_communicator(-1) {
}
#endif
tarch::parallel::Node::~Node() {
}
void tarch::parallel::Node::shutdown() {
#ifdef Parallel
assertion( _rank!=-1 );
MPI_Barrier( _communicator );
MPI_Finalize();
_communicator = MPI_COMM_WORLD;
#endif
_rank = -1;
}
int tarch::parallel::Node::getGlobalMasterRank() {
return 0;
}
bool tarch::parallel::Node::isGlobalMaster() const {
#ifdef Parallel
assertion(_initIsCalled);
return getRank() == getGlobalMasterRank();
#else
return true;
#endif
}
void tarch::parallel::Node::logStatus() const {
std::ostringstream statusMessage;
statusMessage << "MPI status:";
#ifdef CompilerHasUTSName
utsname* utsdata = new utsname();
assertion( utsdata!=NULL );
uname(utsdata);
statusMessage << " nodename=" << utsdata->nodename;
delete utsdata;
#else
statusMessage << " nodename=undef";
#endif
statusMessage << ", rank=" << _rank;
statusMessage << ", communicator=" << _communicator;
statusMessage << ", #processors=" << _numberOfProcessors;
_log.info( "logStatus()", statusMessage.str() );
}
bool tarch::parallel::Node::init(int* argc, char*** argv) {
#ifdef Parallel
int result = MPI_SUCCESS;
#if defined( SharedMemoryParallelisation ) && defined( MultipleThreadsMayTriggerMPICalls )
int initThreadProvidedThreadLevelSupport;
result = MPI_Init_thread( argc, argv, MPI_THREAD_MULTIPLE, &initThreadProvidedThreadLevelSupport );
if (initThreadProvidedThreadLevelSupport!=MPI_THREAD_MULTIPLE ) {
std::cerr << "warning: MPI implementation does not support MPI_THREAD_MULTIPLE. Support multithreading level is "
<< initThreadProvidedThreadLevelSupport << " instead of " << MPI_THREAD_MULTIPLE
<< ". Disable MultipleThreadsMayTriggerMPICalls in the compiler-specific settings or via -DnoMultipleThreadsMayTriggerMPICalls."<< std::endl;
exit(-1);
}
#else
result = MPI_Init( argc, argv );
#endif
if (result!=MPI_SUCCESS) {
std::cerr << "init(int*,char***)\t initialisation failed: " + MPIReturnValueToString(result) + " (no logging available yet)";
return false;
}
result = MPI_Comm_size( MPI_COMM_WORLD, &_numberOfProcessors );
if (result!=MPI_SUCCESS) {
std::cerr << "init(int*,char***)\t initialisation failed: " + MPIReturnValueToString(result) + " (no logging available yet)";
return false;
}
result = MPI_Comm_rank( MPI_COMM_WORLD, &_rank );
if (result!=MPI_SUCCESS) {
std::cerr << "init(int*,char***)\t initialisation failed: " + MPIReturnValueToString(result) + " (no logging available yet)";
return false;
}
#endif
_initIsCalled = true;
return true;
}
int tarch::parallel::Node::getRank() const {
#ifdef Parallel
assertion(_initIsCalled);
#endif
return _rank;
}
tarch::parallel::Node& tarch::parallel::Node::getInstance() {
static Node singleton;
return singleton;
}
MPI_Comm tarch::parallel::Node::getCommunicator() const {
assertion(_initIsCalled);
return _communicator;
}
int tarch::parallel::Node::getNumberOfNodes() const {
#ifdef Parallel
assertion(_initIsCalled);
#endif
return _numberOfProcessors;
}
void tarch::parallel::Node::setTimeOutWarning( const clock_t & value ) {
assertion( value>=0 );
_timeOutWarning = value;
}
void tarch::parallel::Node::setDeadlockTimeOut( const clock_t & value ) {
assertion( value>=0 );
_deadlockTimeOut = value;
}
void tarch::parallel::Node::setCommunicator( MPI_Comm communicator ) {
_communicator = communicator;
}
void tarch::parallel::Node::receiveDanglingMessages() {
/*
#ifdef Parallel
int flag;
MPI_Iprobe(MPI_ANY_SOURCE, MPI_ANY_TAG, _communicator, &flag, MPI_STATUS_IGNORE);
if (flag) {
#endif
*/
tarch::services::ServiceRepository::getInstance().receiveDanglingMessages();
/*
#ifdef Parallel
}
#endif
*/
}
| 27.607143 | 155 | 0.681846 | linusseelinger |
3af749b9c4ef66f3153c8bc9dd4d7d3b25dcc599 | 1,635 | cpp | C++ | lib/SDL/src/renderer.cpp | mkschleg/PhysicsEngine | 583c26d4674dcf38cd213d0bd49ddb9b4efe5f09 | [
"MIT"
] | null | null | null | lib/SDL/src/renderer.cpp | mkschleg/PhysicsEngine | 583c26d4674dcf38cd213d0bd49ddb9b4efe5f09 | [
"MIT"
] | null | null | null | lib/SDL/src/renderer.cpp | mkschleg/PhysicsEngine | 583c26d4674dcf38cd213d0bd49ddb9b4efe5f09 | [
"MIT"
] | null | null | null |
#include "renderer.h"
#include <SDL.h>
namespace SDL{
Renderer::Renderer():renderer(nullptr){}
Renderer::Renderer(const Window& window, int index, Uint32 flags){
//SDL_CreateRenderer(SDL_Window *window, int index, Uint32 flags)
renderer.reset(SDL_CreateRenderer(window.window.get(), index, flags), SDL_DestroyRenderer);
if (renderer == nullptr) renderer.reset(SDL_GetRenderer(window.window.get()), SDL_DestroyRenderer);
// if (renderer == nullptr) throw (SDLException("Renderer null __file__ at line __line__"));
}
Renderer::Renderer(Renderer&& rend){
renderer = rend.renderer;
rend.renderer = nullptr;
}
Renderer::Renderer(SDL_Renderer* rend){
renderer.reset(rend, SDL_DestroyRenderer);
}
std::shared_ptr<SDL_Renderer> Renderer::get(){
return renderer;
}
void Renderer::present(){
if(renderer != nullptr) SDL_RenderPresent(renderer.get());
else ; //Throw an error?
}
void Renderer::clear(){
if (renderer != nullptr) SDL_RenderClear(renderer.get());
}
void Renderer::fill(uint8_t r, uint8_t g, uint8_t b, uint8_t a){
//SDL_RenderFillRect(SDL_Renderer *renderer, const SDL_Rect *rect)
uint8_t pr,pg,pb,pa;
SDL_GetRenderDrawColor(renderer.get(), &pr, &pg, &pb, &pa);
SDL_SetRenderDrawColor(renderer.get(), r,g,b, a);
clear();
SDL_SetRenderDrawColor(renderer.get(), pr, pg, pb, pa);
}
void Renderer::operator=(Renderer&& rhs){
if(renderer != nullptr) SDL_DestroyRenderer(renderer.get());
renderer = rhs.renderer;
rhs.renderer = nullptr;
}
SDL_Renderer* Renderer::getRaw(){
return renderer.get();
}
}
| 26.803279 | 103 | 0.686239 | mkschleg |
3af89945eff88b6ae2bf937782fca1f5c2426e02 | 8,141 | cpp | C++ | src/sim-cache/machine.cpp | EverNebula/RISC-V_Simulator | 23dcb6885834ec5f922e0ccf2546a1b0e66aca7b | [
"MIT"
] | null | null | null | src/sim-cache/machine.cpp | EverNebula/RISC-V_Simulator | 23dcb6885834ec5f922e0ccf2546a1b0e66aca7b | [
"MIT"
] | null | null | null | src/sim-cache/machine.cpp | EverNebula/RISC-V_Simulator | 23dcb6885834ec5f922e0ccf2546a1b0e66aca7b | [
"MIT"
] | null | null | null | #include <stdio.h>
#include <string.h>
#include "machine.hpp"
#include "utils.hpp"
#define MAX(a, b) ((a) > (b) ? (a) : (b))
void SingleStepInfo()
{
printf("Single Step Mode Help:\n");
printf("c: continue\n");
printf("r: print all registers\n");
printf("d: dump machine status to file 'status_dump.txt'\n");
printf("p: print page table\n");
printf("m <address/hex> <size/dec>: get data from address\n");
printf("q: quit\n\n");
}
void
Machine::SingleStepDebug()
{
char buf[100], tbuf[100];
while (true)
{
fgets(buf, 100, stdin);
switch (buf[0])
{
case 'c':
return;
case 'r':
PrintReg();
break;
case 'd':
FILE *dump_out;
dump_out = fopen("status_dump.txt", "w");
Status(dump_out);
fclose(dump_out);
break;
case 'p':
PrintPageTable();
break;
case 'm':
uint64_t addr, data;
int size;
sscanf(buf, "%s %llx %d", tbuf, &addr, &size);
printf("%llx %d\n", addr, size);
if (!ReadMem(addr, size, (void*)&data))
{
printf("cannot access that address.\n");
continue;
}
printf("data in %08llx: ", addr);
for (int i = size - 1; i >= 0 ; --i)
{
printf("%02llx ", (data >> (i * 8)) & 0xff);
}
printf("\n");
break;
case 'q':
exit(0);
default:
printf("unknown command.\n");
SingleStepInfo();
}
}
}
Machine::Machine(PRED_TYPE mode)
{
// register initialization
memset(reg, 0, sizeof reg);
// page table initialization
for (int i = 0; i < PhysicalPageNum; ++i)
freePage.push(i);
pte = new PageTableEntry[PhysicalPageNum];
predictor = new Predictor(mode);
cycCount = 0;
cpuCount = 0;
instCount = 0;
runTime = .0;
loadHzdCount = 0;
ctrlHzdCount = 0;
ecallStlCount = 0;
jalrStlCount = 0;
totalBranch = 0;
l1cache = NULL;
l2cache = NULL;
l3cache = NULL;
}
Machine::~Machine()
{
delete mainMem;
delete l1cache;
delete pte;
delete predictor;
}
void Machine::StorageInit(int cacheLevel)
{
// storage initialization
StorageLatency ll;
StorageStats s;
CacheConfig l1c;
s.access_time = 0;
mainMem = new Memory();
mainMem->SetStats(s);
ll.bus_latency = 0;
ll.hit_latency = cfg.GetConfig("MEM_CYC");
mainMem->SetLatency(ll);
if (cacheLevel > 2)
{
l3cache = new Cache("L3 cache", (CACHE_METHOD)cfg.GetConfig("L3C_METHOD"));
l3cache->SetStats(s);
ll.bus_latency = cfg.GetConfig("L3C_BUS_CYC");
ll.hit_latency = cfg.GetConfig("L3C_HIT_CYC");
l3cache->SetLatency(ll);
l1c.size = cfg.GetConfig("L3C_SIZE");
l1c.assoc = cfg.GetConfig("L3C_ASSOC");
l1c.line_size = cfg.GetConfig("L3C_BSIZE"); // Size of cache line
l1c.write_through = (bool)cfg.GetConfig("L3C_WT"); // 0|1 for back|through
l1c.write_allocate = (bool)cfg.GetConfig("L3C_WA"); // 0|1 for no-alc|alc
l3cache->SetConfig(l1c);
l3cache->SetPrefetch(cfg.GetConfig("L3C_PREFETCH"));
l3cache->Allocate();
l3cache->SetLower(mainMem);
}
if (cacheLevel > 1)
{
l2cache = new Cache("L2 cache", (CACHE_METHOD)cfg.GetConfig("L2C_METHOD"));
l2cache->SetStats(s);
ll.bus_latency = cfg.GetConfig("L2C_BUS_CYC");
ll.hit_latency = cfg.GetConfig("L2C_HIT_CYC");
l2cache->SetLatency(ll);
l1c.size = cfg.GetConfig("L2C_SIZE");
l1c.assoc = cfg.GetConfig("L2C_ASSOC");
l1c.line_size = cfg.GetConfig("L2C_BSIZE"); // Size of cache line
l1c.write_through = (bool)cfg.GetConfig("L2C_WT"); // 0|1 for back|through
l1c.write_allocate = (bool)cfg.GetConfig("L2C_WA"); // 0|1 for no-alc|alc
l2cache->SetConfig(l1c);
l2cache->SetPrefetch(cfg.GetConfig("L2C_PREFETCH"));
l2cache->Allocate();
if (cacheLevel > 2)
l2cache->SetLower(l3cache);
else
l2cache->SetLower(mainMem);
}
if (cacheLevel > 0)
{
l1cache = new Cache("L1 cache", (CACHE_METHOD)cfg.GetConfig("L1C_METHOD"));
l1cache->SetStats(s);
ll.bus_latency = cfg.GetConfig("L1C_BUS_CYC");
ll.hit_latency = cfg.GetConfig("L1C_HIT_CYC");
l1cache->SetLatency(ll);
l1c.size = cfg.GetConfig("L1C_SIZE");
l1c.assoc = cfg.GetConfig("L1C_ASSOC");
l1c.line_size = cfg.GetConfig("L1C_BSIZE"); // Size of cache line
l1c.write_through = (bool)cfg.GetConfig("L1C_WT"); // 0|1 for back|through
l1c.write_allocate = (bool)cfg.GetConfig("L1C_WA"); // 0|1 for no-alc|alc
l1cache->SetConfig(l1c);
l1cache->SetPrefetch(cfg.GetConfig("L1C_PREFETCH"));
l1cache->Allocate();
if (cacheLevel > 1)
l1cache->SetLower(l2cache);
else
l1cache->SetLower(mainMem);
}
if (cacheLevel != 0)
topStorage = l1cache;
else
topStorage = mainMem;
}
void
Machine::Run()
{
Timer timer;
runTime = 0;
F_reg.bubble = false;
if(singleStep)
SingleStepInfo();
for ( ; ; )
{
int mxCyc = 1, useCyc;
timer.StepTime();
if ((useCyc = Fetch()) == 0)
{
panic("Fetch error!\n");
}
else
{
vprintf("- Fetch CPU Cyc: %d\n", useCyc);
mxCyc = MAX(mxCyc, useCyc);
}
if ((useCyc = Decode()) == 0)
{
panic("Decode error!\n");
}
else
{
vprintf("- Decode CPU Cyc: %d\n", useCyc);
mxCyc = MAX(mxCyc, useCyc);
}
if ((useCyc = Execute()) == 0)
{
panic("Execute error!\n");
}
else
{
vprintf("- Execute CPU Cyc: %d\n", useCyc);
mxCyc = MAX(mxCyc, useCyc);
}
if ((useCyc = MemoryAccess()) == 0)
{
panic("Memory error!\n");
}
else
{
vprintf("- Memory CPU Cyc: %d\n", useCyc);
mxCyc = MAX(mxCyc, useCyc);
}
if ((useCyc = WriteBack()) == 0)
{
panic("WriteBack error!\n");
}
else
{
vprintf("- WriteBack CPU Cyc: %d\n", useCyc);
mxCyc = MAX(mxCyc, useCyc);
}
UpdatePipeline();
cycCount++;
cpuCount += mxCyc;
runTime += timer.StepTime();
if (debug)
{
PrintReg();
}
if (singleStep)
SingleStepDebug();
}
Status();
}
void
Machine::Status(FILE *fout)
{
bool isnull = fout == NULL;
if (isnull)
{
fout = stdout;
}
fprintf(fout, "\n---------------- Machine ---------------\n");
fprintf(fout, "BASIC STATUS: \n");
fprintf(fout, "- Cycle Count: %d\n", cycCount);
fprintf(fout, "- Inst. Count: %d\n", instCount);
fprintf(fout, "- Run Time: %.4lf\n", runTime);
fprintf(fout, "- Pipeline Cyc CpI: %.2lf\n", (double)cycCount/instCount);
fprintf(fout, "- CPU Cyc CpI: %.2lf\n\n", (double)cpuCount/instCount);
fprintf(fout, "- Pred Strategy: %s\n", predictor->Name());
fprintf(fout, "- Branch Pred Acc: %.2lf%%\t(%d / %d)\n", (double)(totalBranch - ctrlHzdCount)/totalBranch*100,
totalBranch - ctrlHzdCount, totalBranch);
fprintf(fout, "- Load-use Hazard: %d\n", loadHzdCount);
fprintf(fout, "- Ctrl. Hazard: %d * 2\t(cycles)\n", ctrlHzdCount);
fprintf(fout, "- ECALL Stall: %d * 3\t(cycles)\n", ecallStlCount);
fprintf(fout, "- JALR Stall: %d * 2\t(cycles)\n", jalrStlCount);
fprintf(fout, "\nREGISTER FILE: \n");
fprintf(fout, "- Reg. Num %d\n", RegNum);
PrintReg(fout);
fprintf(fout, "----------------------------------------\n");
// cfg.Print(fout);
fprintf(fout, "\n----------------- Cache ----------------\n");
fprintf(fout, "L1 Cache: \n");
if (l1cache)
{
l1cache->Print(fout);
}
else
{
fprintf(fout, " None\n");
}
fprintf(fout, "\nL2 Cache: \n");
if (l2cache)
{
l2cache->Print(fout);
}
else
{
fprintf(fout, " None\n");
}
fprintf(fout, "\nL3 Cache: \n");
if (l3cache)
{
l3cache->Print(fout);
}
else
{
fprintf(fout, " None\n");
}
fprintf(fout, "----------------------------------------\n");
if (isnull)
{
PrintMem(NULL, true);
fout = fopen("status_dump.txt", "w");
}
PrintMem(fout);
if (isnull)
{
printf("memory status dumped to file 'status_dump.txt'.\n");
fclose(fout);
}
else
{
printf("machine status dumped.\n");
}
}
void
Machine::PrintReg(FILE *fout)
{
if (fout == NULL)
fout = stdout;
for (int i = 0; i < RegNum; i += 4)
{
for (int j = 0; j < 4; j++)
fprintf(fout, "[%4s]: 0x%08llx(%10lld) ", i+j>33?"na":reg_str[i+j], reg[i+j], reg[i+j]);
fprintf(fout, "\n");
}
}
| 22.67688 | 113 | 0.585309 | EverNebula |
3afb2a6dc103166391199d28207cef89006d0e50 | 34,597 | cpp | C++ | applications/demosSandbox/sdkDemos/demos/BalancingCharacter.cpp | JernejL/newton-dynamics | 70d9465185d8f1fc2c4fe7718b4537771d04db02 | [
"Zlib"
] | 1 | 2019-12-10T23:26:14.000Z | 2019-12-10T23:26:14.000Z | applications/demosSandbox/sdkDemos/demos/BalancingCharacter.cpp | mikiec84/newton-dynamics | 20693b597e93da6fbda9025cb55cff6d274616b0 | [
"Zlib"
] | null | null | null | applications/demosSandbox/sdkDemos/demos/BalancingCharacter.cpp | mikiec84/newton-dynamics | 20693b597e93da6fbda9025cb55cff6d274616b0 | [
"Zlib"
] | 1 | 2021-11-18T02:12:49.000Z | 2021-11-18T02:12:49.000Z | /* Copyright (c) <2003-2019> <Newton Game Dynamics>
*
* 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
*/
#include "toolbox_stdafx.h"
#include "SkyBox.h"
#include "DemoMesh.h"
#include "DemoCamera.h"
#include "PhysicsUtils.h"
#include "TargaToOpenGl.h"
#include "DemoEntityManager.h"
#include "DebugDisplay.h"
#include "HeightFieldPrimitive.h"
class dBalancingCharacterBoneDefinition
{
public:
enum jointType
{
m_none,
m_ball,
m_0dof,
m_1dof,
m_2dof,
m_3dof,
m_ikEffector,
m_fkEffector,
};
struct dJointLimit
{
dFloat m_minTwistAngle;
dFloat m_maxTwistAngle;
dFloat m_coneAngle;
};
struct dFrameMatrix
{
dFloat m_pitch;
dFloat m_yaw;
dFloat m_roll;
};
char* m_boneName;
jointType m_type;
dFloat m_massFraction;
dJointLimit m_jointLimits;
dFrameMatrix m_frameBasics;
};
static dBalancingCharacterBoneDefinition tredDefinition[] =
{
{ "bone_pelvis", dBalancingCharacterBoneDefinition::m_none, 1.0f },
{ "bone_rightLeg", dBalancingCharacterBoneDefinition::m_3dof, 0.3f, {60.0f, 60.0f, 70.0f}, { 0.0f, 90.0f, 0.0f }},
{ "bone_righCalf", dBalancingCharacterBoneDefinition::m_1dof, 0.2f, {-60.0f, 60.0f, 0.0f}, { 0.0f, 0.0f, 90.0f }},
{ "bone_rightAnkle", dBalancingCharacterBoneDefinition::m_fkEffector, 0.2f, {0.0f, 0.0f, 0.0f}, {-90.0f, 0.0f, 90.0f } },
{ "effector_rightAnkle", dBalancingCharacterBoneDefinition::m_ikEffector},
{ "bone_rightFoot", dBalancingCharacterBoneDefinition::m_3dof, 0.2f, {-30.0f, 30.0f, 0.0f}, { 0.0f, 0.0f, 90.0f }},
{ "bone_leftLeg", dBalancingCharacterBoneDefinition::m_3dof, 0.3f, { 60.0f, 60.0f, 70.0f }, { 0.0f, 90.0f, 0.0f } },
{ "bone_leftCalf", dBalancingCharacterBoneDefinition::m_1dof, 0.2f, {-60.0f, 60.0f, 0.0f }, { 0.0f, 0.0f, 90.0f } },
{ "bone_leftAnkle", dBalancingCharacterBoneDefinition::m_fkEffector, 0.2f,{ 0.0f, 0.0f, 0.0f },{ -90.0f, 0.0f, 90.0f } },
{ "effector_leftAnkle", dBalancingCharacterBoneDefinition::m_ikEffector},
{ "bone_leftFoot", dBalancingCharacterBoneDefinition::m_3dof, 0.2f, { -30.0f, 30.0f, 0.0f }, { 0.0f, 0.0f, 90.0f } },
{ NULL},
};
class dModelDescritor
{
public:
char* m_filename;
dFloat m_mass;
dBalancingCharacterBoneDefinition* m_skeletonDefinition;
};
static dModelDescritor tred = {"tred.ngd", 500.0f, tredDefinition};
class dBalacingCharacterEffector: public dCustomKinematicController
{
public:
dBalacingCharacterEffector(NewtonBody* const body, NewtonBody* const referenceBody, const dMatrix& attachmentMatrixInGlobalSpace, dFloat modelMass)
:dCustomKinematicController(body, attachmentMatrixInGlobalSpace, referenceBody)
,m_origin(GetTargetMatrix())
{
SetSolverModel(1);
SetControlMode(dCustomKinematicController::m_linearAndTwist);
SetMaxAngularFriction(modelMass * 100.0f);
SetMaxLinearFriction(modelMass * 9.8f * 10.0f);
dVector euler0;
dVector euler1;
m_origin.GetEulerAngles(euler0, euler1);
m_pitch = euler0.m_x;
m_yaw = euler0.m_y;
m_roll = euler0.m_z;
}
//void SetMatrix (dFloat x, dFloat y, dFloat z, dFloat pitch, dFloat yaw, dFloat roll)
void SetMatrix(dFloat x, dFloat y, dFloat z, dFloat pitch)
{
dMatrix matrix (dPitchMatrix(m_pitch + pitch) * dYawMatrix(m_yaw) * dRollMatrix(m_roll));
matrix.m_posit = m_origin.TransformVector(dVector (x, y, z, dFloat (1.0f)));
SetTargetMatrix(matrix);
}
dMatrix m_origin;
dFloat m_pitch;
dFloat m_yaw;
dFloat m_roll;
};
class dModelAnimTreeFootBase: public dModelAnimTree
{
public:
dModelAnimTreeFootBase(dModelRootNode* const model, dModelAnimTree* const child, dCustomKinematicController* const footEffector0, dCustomKinematicController* const footEffector1)
:dModelAnimTree(model)
,m_child(child)
,m_rootEffector0(footEffector0)
,m_rootEffector1(footEffector1)
{
}
~dModelAnimTreeFootBase()
{
delete m_child;
}
virtual void Debug(dCustomJoint::dDebugDisplay* const debugContext) const
{
m_child->Debug(debugContext);
}
int GetModelKeyFrames(const dModelKeyFramePose& input, dModelKeyFrame** const output) const
{
int count = 0;
for (dModelKeyFramePose::dListNode* node = input.GetFirst(); node; node = node->GetNext()) {
dModelKeyFrame& transform = node->GetInfo();
if ((transform.m_effector == m_rootEffector0) || (transform.m_effector == m_rootEffector1)) {
output[count] = &transform;
count++;
}
}
return count;
}
dModelAnimTree* m_child;
dCustomKinematicController* m_rootEffector0;
dCustomKinematicController* m_rootEffector1;
};
class dModelAnimTreePoseBalance: public dModelAnimTreeFootBase
{
public:
dModelAnimTreePoseBalance(dModelRootNode* const model, dModelAnimTree* const child, dCustomKinematicController* const footEffector0, dCustomKinematicController* const footEffector1)
:dModelAnimTreeFootBase(model, child, footEffector0, footEffector1)
{
}
virtual void Debug(dCustomJoint::dDebugDisplay* const debugContext) const
{
dMatrix matrix;
NewtonBodyGetMatrix(GetRoot()->GetBody(), &matrix[0][0]);
matrix.m_posit = CalculateCenterOfMass();
debugContext->DrawFrame(matrix);
m_child->Debug(debugContext);
}
/*
bool CalculateUpVector(dVector& upvector, dCustomKinematicController* const effector) const
{
bool ret = false;
NewtonBody* const body0 = effector->GetBody0();
for (NewtonJoint* contactjoint = NewtonBodyGetFirstContactJoint(body0); contactjoint; contactjoint = NewtonBodyGetNextContactJoint(body0, contactjoint)) {
ret = true;
dVector averageNormal(0.0f);
for (void* contact = NewtonContactJointGetFirstContact(contactjoint); contact; contact = NewtonContactJointGetNextContact(contactjoint, contact)) {
NewtonMaterial* const material = NewtonContactGetMaterial(contact);
dVector point(0.0f);
dVector normal(0.0f);
NewtonMaterialGetContactPositionAndNormal(material, body0, &point.m_x, &normal.m_x);
averageNormal += normal;
}
upvector = averageNormal.Normalize();
break;
}
ret = true;
upvector = dVector (0.0f, 1.0f, 0.0f, 0.0f);
upvector = dPitchMatrix(30.0f * dDegreeToRad).RotateVector(upvector);
return ret;
}
*/
dVector CalculateCenterOfMass() const
{
dMatrix matrix;
dVector com(0.0f);
dVector localCom;
dFloat Ixx;
dFloat Iyy;
dFloat Izz;
dFloat mass;
dFloat totalMass = 0.0f;
int stack = 1;
int bodyCount = 0;
const dModelNode* stackBuffer[32];
stackBuffer[0] = GetRoot();
while (stack) {
stack--;
const dModelNode* const root = stackBuffer[stack];
NewtonBody* const body = root->GetBody();
NewtonBodyGetMatrix(body, &matrix[0][0]);
NewtonBodyGetCentreOfMass(body, &localCom[0]);
NewtonBodyGetMass(body, &mass, &Ixx, &Iyy, &Izz);
totalMass += mass;
com += matrix.TransformVector(localCom).Scale(mass);
bodyCount++;
const dModelChildrenList& children = root->GetChildren();
for (const dModelChildrenList::dListNode* node = children.GetFirst(); node; node = node->GetNext()) {
stackBuffer[stack] = node->GetInfo();
stack++;
}
}
com = com.Scale(1.0f / totalMass);
com.m_w = 1.0f;
return com;
}
void GeneratePose(dFloat timestep, dModelKeyFramePose& output)
{
m_child->GeneratePose(timestep, output);
/*
dModelKeyFrame* feetPose[2];
const int count = GetModelKeyFrames(output, &feetPose[0]);
for (int i = 0; i < count; i++) {
dMatrix targetMatrix (m_rootEffector0->GetBodyMatrix());
dVector com (CalculateCenterOfMass());
dVector error (targetMatrix.m_posit - com);
//error.m_x = 0.0f;
error.m_y = 0.0f;
//error.m_z = 0.0f;
targetMatrix.m_posit -= error.Scale (0.35f);
//dTrace (("(%f %f %f) (%f %f %f)\n", com.m_x, com.m_y, com.m_z, targetMatrix.m_posit.m_x, targetMatrix.m_posit.m_y, targetMatrix.m_posit.m_z));
dMatrix rootMatrix;
NewtonBodyGetMatrix (m_rootEffector0->GetBody1(), &rootMatrix[0][0]);
dMatrix effectorMatrix (targetMatrix * rootMatrix.Inverse());
for (dModelKeyFramePose::dListNode* node = output.GetFirst(); node; node = node->GetNext()) {
//dModelKeyFrame& transform = node->GetInfo();
//transform.m_posit = effectorMatrix.m_posit;
//transform.SetMatrix(effectorMatrix);
}
}
*/
}
};
/*
class dModelAnimTreeFootAlignment: public dModelAnimTreeFootBase
{
#define RAY_CAST_LENGHT0 0.125f
#define RAY_CAST_LENGHT1 2.0f
class dFeetRayHitSensor
{
public:
dFeetRayHitSensor(dCustomKinematicController* const effector)
:m_rotation()
,m_footBody(NULL)
,m_ankleBody(NULL)
,m_effector(effector)
{
if (m_effector) {
m_footBody = effector->GetBody0();
NewtonCollision* const box = NewtonBodyGetCollision(m_footBody);
dMatrix matrix;
NewtonBodyGetMatrix(m_footBody, &matrix[0][0]);
dVector worldDir[] = {
{ 1.0f, -1.0f, 1.0, 0.0f },
{ -1.0f, -1.0f, 1.0, 0.0f },
{ -1.0f, -1.0f, -1.0, 0.0f },
{ 1.0f, -1.0f, -1.0, 0.0f }
};
for (int i = 0; i < 4; i++) {
dVector dir = matrix.UnrotateVector(worldDir[i]);
NewtonCollisionSupportVertex(box, &dir[0], &m_sensorHitPoint[i][0]);
m_sensorHitPoint[i].m_w = 0.0f;
}
for (NewtonJoint* joint = NewtonBodyGetFirstJoint(m_footBody); joint; joint = NewtonBodyGetNextJoint(m_footBody, joint)) {
dCustomJoint* const customJoint = (dCustomJoint*)NewtonJointGetUserData(joint);
NewtonBody* const body0 = customJoint->GetBody0();
NewtonBody* const body1 = customJoint->GetBody1();
NewtonBody* const otherBody = (body0 == m_footBody) ? body1 : body0;
if (otherBody != m_footBody) {
m_ankleBody = otherBody;
break;
}
}
}
}
dCustomKinematicController* GetEffector() const
{
return m_effector;
}
void DebugDraw(dCustomJoint::dDebugDisplay* const debugContext) const
{
if (m_effector) {
dMatrix matrix;
NewtonBodyGetMatrix(m_footBody, &matrix[0][0]);
for (int i = 0; i < 4; i++) {
dVector point0(matrix.TransformVector(m_sensorHitPoint[i]));
dVector point1(point0);
point0.m_y += RAY_CAST_LENGHT0;
point1.m_y -= RAY_CAST_LENGHT1;
debugContext->DrawLine(point0, point1);
}
}
}
void AlignMatrix(dModelKeyFrame* const transform, dFloat timestep)
{
dVector upvector;
if (CalculateSupportNormal(upvector)) {
// calculate foot desired matrix
dMatrix rootMatrix;
NewtonBodyGetMatrix(m_effector->GetBody1(), &rootMatrix[0][0]);
dMatrix targetMatrix(dMatrix(transform->m_rotation, transform->m_posit) * rootMatrix);
dFloat cosAngle = upvector.DotProduct3(targetMatrix.m_up);
if (cosAngle < 0.9997f) {
if (cosAngle > 0.87f) {
// align the matrix to the floor contacts.
dVector lateralDir(targetMatrix.m_up.CrossProduct(upvector));
lateralDir = lateralDir.Normalize();
dFloat coneAngle = dAcos(dClamp(cosAngle, dFloat(-1.0f), dFloat(1.0f)));
dMatrix pivotMatrix(m_effector->GetMatrix0().Inverse() * targetMatrix);
dQuaternion rotation(lateralDir, coneAngle);
dMatrix coneRotation(rotation, pivotMatrix.m_posit);
coneRotation.m_posit -= coneRotation.RotateVector(pivotMatrix.m_posit);
targetMatrix = targetMatrix * coneRotation;
// calculate and set new modified effector matrix.
transform->SetMatrix(targetMatrix * rootMatrix.Inverse());
} else {
cosAngle = 0;
}
}
}
}
private:
static unsigned FindFloorPrefilter(const NewtonBody* const body, const NewtonCollision* const collision, void* const userData)
{
dFeetRayHitSensor* const data = (dFeetRayHitSensor*)userData;
return ((data->m_footBody == body) || (data->m_ankleBody == body)) ? 0 : 1;
}
static dFloat FindFloor(const NewtonBody* const body, const NewtonCollision* const shapeHit, const dFloat* const hitContact, const dFloat* const hitNormal, dLong collisionID, void* const userData, dFloat intersectParam)
{
dFeetRayHitSensor* const data = (dFeetRayHitSensor*)userData;
dAssert(body != data->m_footBody);
dAssert(body != data->m_ankleBody);
if (intersectParam < data->m_hitParam) {
data->m_hitParam = intersectParam;
}
return data->m_hitParam;
}
bool CalculateSupportNormal(dVector& upvector)
{
bool ret = false;
dMatrix matrix;
dVector supportPlane[4];
NewtonWorld* const world = NewtonBodyGetWorld(m_footBody);
NewtonBodyGetMatrix(m_footBody, &matrix[0][0]);
int count = 0;
for (int i = 0; i < 4; i++) {
dVector point0(matrix.TransformVector(m_sensorHitPoint[i]));
dVector point1(point0);
m_hitParam = 1.2f;
point0.m_y += RAY_CAST_LENGHT0;
point1.m_y -= RAY_CAST_LENGHT1;
NewtonWorldRayCast(world, &point0[0], &point1[0], FindFloor, this, FindFloorPrefilter, 0);
if (m_hitParam < 1.0f) {
supportPlane[count] = point0 + (point1 - point0).Scale(m_hitParam);
count++;
}
}
if (count >= 3) {
dVector area(0.0f);
dVector e0(supportPlane[1] - supportPlane[0]);
for (int i = 2; i < count; i++) {
dVector e1(supportPlane[i] - supportPlane[0]);
area += e1.CrossProduct(e0);
e0 = e1;
}
ret = true;
upvector = area.Normalize();
//upvector = dPitchMatrix(45.0f * dDegreeToRad).RotateVector(dVector (0, 1.0f, 0.0f, 0.0f));
}
ret = true;
static dFloat angle = 0.0f;
dMatrix xxxx(dPitchMatrix(angle));
angle -= 0.002f;
upvector = xxxx[1];
//upvector = area.Normalize();
//upvector = dPitchMatrix(45.0f * dDegreeToRad).RotateVector(dVector (0, 1.0f, 0.0f, 0.0f));
return ret;
}
dVector m_sensorHitPoint[4];
dQuaternion m_rotation;
NewtonBody* m_footBody;
NewtonBody* m_ankleBody;
dCustomKinematicController* m_effector;
dFloat m_hitParam;
};
public:
dModelAnimTreeFootAlignment(dModelRootNode* const model, dModelAnimTree* const child, dCustomKinematicController* const footEffector0, dCustomKinematicController* const footEffector1)
:dModelAnimTreeFootBase(model, child, footEffector0, footEffector1)
,m_foot0(footEffector0)
,m_foot1(footEffector1)
{
}
virtual void Debug(dCustomJoint::dDebugDisplay* const debugContext) const
{
m_foot0.DebugDraw(debugContext);
m_foot1.DebugDraw(debugContext);
m_child->Debug(debugContext);
}
void GeneratePose(dFloat timestep, dModelKeyFramePose& output)
{
m_child->GeneratePose(timestep, output);
dModelKeyFrame* feetPose[2];
const int count = GetModelKeyFrames(output, &feetPose[0]);
for (int i = 0; i < count; i++) {
dMatrix rootMatrix;
dModelKeyFrame* const transform = feetPose[i];
dCustomKinematicController* const effector = transform->m_effector;
if (effector == m_foot0.GetEffector()) {
m_foot0.AlignMatrix(transform, timestep);
}
if (effector == m_foot1.GetEffector()) {
m_foot1.AlignMatrix(transform, timestep);
}
}
}
dFeetRayHitSensor m_foot0;
dFeetRayHitSensor m_foot1;
};
*/
class dModelAnimTreeAnkleAndFootController: public dModelAnimTree
{
public:
dModelAnimTreeAnkleAndFootController(dModelRootNode* const model, dModelAnimTree* const child, int count, dCustomKinematicController** const effectors)
:dModelAnimTree(model)
,m_child(child)
{
}
~dModelAnimTreeAnkleAndFootController()
{
delete m_child;
}
virtual void Debug(dCustomJoint::dDebugDisplay* const debugContext) const
{
//dMatrix matrix;
//NewtonBodyGetMatrix(GetRoot()->GetBody(), &matrix[0][0]);
//matrix.m_posit = CalculateCenterOfMass();
//debugContext->DrawFrame(matrix);
m_child->Debug(debugContext);
}
/*
bool CalculateUpVector(dVector& upvector, dCustomKinematicController* const effector) const
{
bool ret = false;
NewtonBody* const body0 = effector->GetBody0();
for (NewtonJoint* contactjoint = NewtonBodyGetFirstContactJoint(body0); contactjoint; contactjoint = NewtonBodyGetNextContactJoint(body0, contactjoint)) {
ret = true;
dVector averageNormal(0.0f);
for (void* contact = NewtonContactJointGetFirstContact(contactjoint); contact; contact = NewtonContactJointGetNextContact(contactjoint, contact)) {
NewtonMaterial* const material = NewtonContactGetMaterial(contact);
dVector point(0.0f);
dVector normal(0.0f);
NewtonMaterialGetContactPositionAndNormal(material, body0, &point.m_x, &normal.m_x);
averageNormal += normal;
}
upvector = averageNormal.Normalize();
break;
}
ret = true;
upvector = dVector (0.0f, 1.0f, 0.0f, 0.0f);
upvector = dPitchMatrix(30.0f * dDegreeToRad).RotateVector(upvector);
return ret;
}
*/
void GeneratePose(dFloat timestep, dModelKeyFramePose& output)
{
m_child->GeneratePose(timestep, output);
/*
dModelKeyFrame* feetPose[2];
const int count = GetModelKeyFrames(output, &feetPose[0]);
for (int i = 0; i < count; i++) {
dMatrix targetMatrix (m_rootEffector0->GetBodyMatrix());
dVector com (CalculateCenterOfMass());
dVector error (targetMatrix.m_posit - com);
//error.m_x = 0.0f;
error.m_y = 0.0f;
//error.m_z = 0.0f;
targetMatrix.m_posit -= error.Scale (0.35f);
//dTrace (("(%f %f %f) (%f %f %f)\n", com.m_x, com.m_y, com.m_z, targetMatrix.m_posit.m_x, targetMatrix.m_posit.m_y, targetMatrix.m_posit.m_z));
dMatrix rootMatrix;
NewtonBodyGetMatrix (m_rootEffector0->GetBody1(), &rootMatrix[0][0]);
dMatrix effectorMatrix (targetMatrix * rootMatrix.Inverse());
for (dModelKeyFramePose::dListNode* node = output.GetFirst(); node; node = node->GetNext()) {
//dModelKeyFrame& transform = node->GetInfo();
//transform.m_posit = effectorMatrix.m_posit;
//transform.SetMatrix(effectorMatrix);
}
}
*/
}
dModelAnimTree* m_child;
};
class dBalancingCharacter: public dModelRootNode
{
public:
dBalancingCharacter(NewtonBody* const rootBody)
:dModelRootNode(rootBody, dGetIdentityMatrix())
,m_pose()
,m_animtree(NULL)
{
}
~dBalancingCharacter()
{
if (m_animtree) {
delete m_animtree;
}
}
void SetAllPartsNonCollidable()
{
int stack = 1;
dModelNode* stackBuffer[32];
stackBuffer[0] = this;
void* const aggregate = NewtonCollisionAggregateCreate(NewtonBodyGetWorld(GetBody()));
while (stack) {
stack--;
dModelNode* const root = stackBuffer[stack];
NewtonBody* const body = root->GetBody();
NewtonCollisionAggregateAddBody(aggregate, body);
const dModelChildrenList& children = root->GetChildren();
for (dModelChildrenList::dListNode* node = children.GetFirst(); node; node = node->GetNext()) {
stackBuffer[stack] = node->GetInfo();
stack++;
}
}
NewtonCollisionAggregateSetSelfCollision(aggregate, false);
}
void SetAnimTree(int count, dCustomKinematicController** const effectors)
{
dModelAnimTree* const poseGenerator = new dModelAnimTreePose(this, m_pose);
dModelAnimTree* const feetController = new dModelAnimTreeAnkleAndFootController(this, poseGenerator, count, effectors);
//dModelAnimTreePoseBalance* const poseBalance = new dModelAnimTreePoseBalance(this, poseGenerator, rootEffector0, rootEffector1);
//dModelAnimTree* const footRoll = new dModelAnimTreeFootAlignment(this, poseBalance, rootEffector0, rootEffector1);
//m_animtree = footRoll;
//m_animtree = poseBalance;
m_animtree = feetController;
//m_animtree = poseGenerator;
}
void OnDebug(dCustomJoint::dDebugDisplay* const debugContext)
{
dFloat scale = debugContext->GetScale();
debugContext->SetScale(0.5f);
for (dModelKeyFramePose::dListNode* node = m_pose.GetFirst(); node; node = node->GetNext()) {
const dModelKeyFrame& keyFrame = node->GetInfo();
keyFrame.m_effector->Debug(debugContext);
}
if (m_animtree) {
m_animtree->Debug(debugContext);
}
debugContext->SetScale(scale);
}
void ApplyControls (dFloat timestep, dFloat x, dFloat y, dFloat z, dFloat pitch)
{
m_animtree->GeneratePose(timestep, m_pose);
//for (dModelKeyFramePose::dListNode* node = m_pose.GetFirst(); node; node = node->GetNext()) {
// dModelKeyFrame& transform = node->GetInfo();
// transform.m_effector->SetTargetMatrix(dMatrix(transform.m_rotation, transform.m_posit));
// //dBalacingCharacterEffector* const effector = (dBalacingCharacterEffector*)transform.m_effector;
// //effector->SetMatrix (x, y, z, pitch);
// //break;
//}
//dModelKeyFramePose::dListNode* node = m_pose.GetFirst();
//if (node) {
// dModelKeyFrame& transform = node->GetInfo();
// dBalacingCharacterEffector* const effector = (dBalacingCharacterEffector*)transform.m_effector;
// effector->SetMatrix(x, y, z, pitch);
//}
}
dModelKeyFramePose m_pose;
dModelAnimTree* m_animtree;
};
class dBalancingCharacterManager: public dModelManager
{
public:
dBalancingCharacterManager(DemoEntityManager* const scene)
:dModelManager(scene->GetNewton())
//,m_currentController(NULL)
{
m_pitch = 0.0f;
m_posit_x = 0.0f;
m_posit_y = 0.0f;
m_posit_z = 0.0f;
scene->Set2DDisplayRenderFunction(RenderHelpMenu, NULL, this);
}
~dBalancingCharacterManager()
{
}
static void RenderHelpMenu(DemoEntityManager* const scene, void* const context)
{
dVector color(1.0f, 1.0f, 0.0f, 0.0f);
dBalancingCharacterManager* const me = (dBalancingCharacterManager*)context;
scene->Print(color, "linear degrees of freedom");
ImGui::SliderFloat("pitch", &me->m_pitch, -30.0f, 30.0f);
ImGui::SliderFloat("posit_x", &me->m_posit_x, -1.0f, 1.0f);
ImGui::SliderFloat("posit_y", &me->m_posit_y, -1.0f, 1.0f);
ImGui::SliderFloat("posit_z", &me->m_posit_z, -1.0f, 1.0f);
//
//ImGui::Separator();
//scene->Print(color, "angular degrees of freedom");
//ImGui::SliderFloat("pitch", &me->m_gripper_pitch, -180.0f, 180.0f);
//ImGui::SliderFloat("yaw", &me->m_gripper_yaw, -80.0f, 80.0f);
//ImGui::SliderFloat("roll", &me->m_gripper_roll, -180.0f, 180.0f);
}
static void ClampAngularVelocity(const NewtonBody* body, dFloat timestep, int threadIndex)
{
dVector omega;
NewtonBodyGetOmega(body, &omega[0]);
omega.m_w = 0.0f;
dFloat mag2 = omega.DotProduct3(omega);
if (mag2 > (100.0f * 100.0f)) {
omega = omega.Normalize().Scale(100.0f);
NewtonBodySetOmega(body, &omega[0]);
}
PhysicsApplyGravityForce(body, timestep, threadIndex);
}
NewtonBody* CreateBodyPart(DemoEntity* const bodyPart, const dBalancingCharacterBoneDefinition& definition)
{
NewtonWorld* const world = GetWorld();
NewtonCollision* const shape = bodyPart->CreateCollisionFromchildren(world);
dAssert(shape);
// calculate the boneBody matrix
dMatrix matrix(bodyPart->CalculateGlobalMatrix());
// create the rigid body that will make this boneBody
NewtonBody* const boneBody = NewtonCreateDynamicBody(world, shape, &matrix[0][0]);
// calculate the moment of inertia and the relative center of mass of the solid
//NewtonBodySetMassProperties (boneBody, definition.m_mass, shape);
NewtonBodySetMassProperties(boneBody, definition.m_massFraction, shape);
// save the user data with the boneBody body (usually the visual geometry)
NewtonBodySetUserData(boneBody, bodyPart);
// assign the material for early collision culling
//NewtonBodySetMaterialGroupID(boneBody, m_material);
NewtonBodySetMaterialGroupID(boneBody, 0);
//dVector damping (0.0f);
//NewtonBodySetLinearDamping(boneBody, damping.m_x);
//NewtonBodySetAngularDamping(boneBody, &damping[0]);
// set the bod part force and torque call back to the gravity force, skip the transform callback
//NewtonBodySetForceAndTorqueCallback (boneBody, PhysicsApplyGravityForce);
NewtonBodySetForceAndTorqueCallback(boneBody, ClampAngularVelocity);
// destroy the collision helper shape
NewtonDestroyCollision(shape);
return boneBody;
}
dCustomKinematicController* ConnectEffector(dModelNode* const effectorNode, const dMatrix& effectorMatrix, const dFloat modelMass)
{
//const dModelNode* const referenceNode = effectorNode->GetParent()->GetParent();
//dAssert(referenceNode);
//dCustomJoint* const pivotJoint = FindJoint(referenceNode->GetBody(), referenceNode->GetParent()->GetBody());
//dAssert(pivotJoint);
//Assert(joint->GetBody1() == effectorNode->GetRoot()->GetBody());
//Matrix pivotMatrix(joint->GetMatrix1());
//dBalacingCharacterEffector* const effector = new dBalacingCharacterEffector(effectorNode->GetBody(), effectorNode->GetRoot()->GetBody(), effectorMatrix, modelMass, pivotJoint);
dBalacingCharacterEffector* const effector = new dBalacingCharacterEffector(effectorNode->GetBody(), effectorNode->GetRoot()->GetBody(), effectorMatrix, modelMass);
return effector;
}
dCustomJoint* ConnectLimb(NewtonBody* const bone, NewtonBody* const parent, const dBalancingCharacterBoneDefinition& definition)
{
dMatrix matrix;
NewtonBodyGetMatrix(bone, &matrix[0][0]);
dBalancingCharacterBoneDefinition::dFrameMatrix frameAngle(definition.m_frameBasics);
dMatrix pinAndPivotInGlobalSpace(dPitchMatrix(frameAngle.m_pitch * dDegreeToRad) * dYawMatrix(frameAngle.m_yaw * dDegreeToRad) * dRollMatrix(frameAngle.m_roll * dDegreeToRad));
pinAndPivotInGlobalSpace = pinAndPivotInGlobalSpace * matrix;
dCustomJoint* ret = NULL;
switch (definition.m_type)
{
case dBalancingCharacterBoneDefinition::m_ball:
{
dCustomBallAndSocket* const joint = new dCustomBallAndSocket(pinAndPivotInGlobalSpace, bone, parent);
joint->EnableCone(false);
joint->EnableTwist(false);
ret = joint;
break;
}
case dBalancingCharacterBoneDefinition::m_0dof:
{
dCustomHinge* const joint = new dCustomHinge(pinAndPivotInGlobalSpace, bone, parent);
joint->EnableLimits(true);
joint->SetLimits(0.0f, 0.0f);
ret = joint;
break;
}
case dBalancingCharacterBoneDefinition::m_1dof:
{
dCustomBallAndSocket* const joint = new dCustomBallAndSocket(pinAndPivotInGlobalSpace, bone, parent);
joint->EnableTwist(true);
joint->SetTwistLimits(definition.m_jointLimits.m_minTwistAngle * dDegreeToRad, definition.m_jointLimits.m_maxTwistAngle * dDegreeToRad);
joint->EnableCone(true);
joint->SetConeLimits(0.0f);
ret = joint;
break;
}
case dBalancingCharacterBoneDefinition::m_2dof:
{
dCustomBallAndSocket* const joint = new dCustomBallAndSocket(pinAndPivotInGlobalSpace, bone, parent);
joint->EnableTwist(true);
joint->SetTwistLimits(0.0f, 0.0f);
joint->EnableCone(true);
joint->SetConeLimits(definition.m_jointLimits.m_coneAngle * dDegreeToRad);
ret = joint;
break;
}
case dBalancingCharacterBoneDefinition::m_3dof:
{
dCustomBallAndSocket* const joint = new dCustomBallAndSocket(pinAndPivotInGlobalSpace, bone, parent);
joint->EnableTwist(true);
joint->SetTwistLimits(definition.m_jointLimits.m_minTwistAngle * dDegreeToRad, definition.m_jointLimits.m_maxTwistAngle * dDegreeToRad);
joint->EnableCone(true);
joint->SetConeLimits(definition.m_jointLimits.m_coneAngle * dDegreeToRad);
ret = joint;
break;
}
case dBalancingCharacterBoneDefinition::m_fkEffector:
{
dCustomKinematicController* const effector = new dCustomKinematicController(bone, pinAndPivotInGlobalSpace, parent);
effector->SetSolverModel(1);
effector->SetControlMode(dCustomKinematicController::m_full6dof);
effector->SetMaxAngularFriction(1.0e20f);
effector->SetMaxLinearFriction(1.0e20f);
ret = effector;
break;
}
default:
ret = NULL;
dAssert (0);
}
return ret;
}
void NormalizeMassAndInertia(dModelRootNode* const model, dFloat modelMass) const
{
int stack = 1;
int bodyCount = 0;
NewtonBody* bodyArray[1024];
dModelNode* stackBuffer[32];
stackBuffer[0] = model;
while (stack) {
stack--;
dModelNode* const root = stackBuffer[stack];
bodyArray[bodyCount] = root->GetBody();
bodyCount++;
const dModelChildrenList& children = root->GetChildren();
for (dModelChildrenList::dListNode* node = children.GetFirst(); node; node = node->GetNext()) {
stackBuffer[stack] = node->GetInfo();
stack++;
}
}
dFloat totalMass = 0.0f;
for (int i = 0; i < bodyCount; i++) {
dFloat Ixx;
dFloat Iyy;
dFloat Izz;
dFloat mass;
NewtonBody* const body = bodyArray[i];
NewtonBodyGetMass(body, &mass, &Ixx, &Iyy, &Izz);
totalMass += mass;
}
dFloat massNormalize = modelMass / totalMass;
for (int i = 0; i < bodyCount; i++) {
dFloat Ixx;
dFloat Iyy;
dFloat Izz;
dFloat mass;
NewtonBody* const body = bodyArray[i];
NewtonBodyGetMass(body, &mass, &Ixx, &Iyy, &Izz);
mass *= massNormalize;
Ixx *= massNormalize;
Iyy *= massNormalize;
Izz *= massNormalize;
dFloat minInertia = dMin(Ixx, dMin(Iyy, Izz));
if (minInertia < 10.0f) {
dFloat maxInertia = dMax(dFloat(10.0f), dMax(Ixx, dMax(Iyy, Izz)));
Ixx = maxInertia;
Iyy = maxInertia;
Izz = maxInertia;
}
NewtonBodySetMassMatrix(body, mass, Ixx, Iyy, Izz);
}
}
void CreateKinematicModel(dModelDescritor& descriptor, const dMatrix& location)
{
NewtonWorld* const world = GetWorld();
DemoEntityManager* const scene = (DemoEntityManager*)NewtonWorldGetUserData(world);
DemoEntity* const entityModel = DemoEntity::LoadNGD_mesh(descriptor.m_filename, world, scene->GetShaderCache());
scene->Append(entityModel);
dMatrix matrix0(entityModel->GetCurrentMatrix());
entityModel->ResetMatrix(*scene, matrix0 * location);
// create the root body, do not set the transform call back
NewtonBody* const rootBody = CreateBodyPart(entityModel, descriptor.m_skeletonDefinition[0]);
// make a kinematic controlled model.
dBalancingCharacter* const model = new dBalancingCharacter(rootBody);
// add the model to the manager
AddRoot(model);
// the the model to calculate the local transformation
model->SetTranformMode(true);
// save the controller as the collision user data, for collision culling
//NewtonCollisionSetUserData(NewtonBodyGetCollision(rootBone), controller);
int stackIndex = 0;
dModelNode* parentBones[32];
DemoEntity* childEntities[32];
for (DemoEntity* child = entityModel->GetChild(); child; child = child->GetSibling()) {
parentBones[stackIndex] = model;
childEntities[stackIndex] = child;
stackIndex++;
//dTrace(("name: %s\n", child->GetName().GetStr()));
}
// walk model hierarchic adding all children designed as rigid body bones.
int effectorsCount = 0;
dCustomKinematicController* effectorList[16];
while (stackIndex) {
stackIndex--;
DemoEntity* const entity = childEntities[stackIndex];
dModelNode* parentBone = parentBones[stackIndex];
const char* const name = entity->GetName().GetStr();
dTrace(("name: %s\n", name));
for (int i = 1; descriptor.m_skeletonDefinition[i].m_boneName; i++) {
if (!strcmp(descriptor.m_skeletonDefinition[i].m_boneName, name)) {
NewtonBody* const parentBody = parentBone->GetBody();
if (descriptor.m_skeletonDefinition[i].m_type == dBalancingCharacterBoneDefinition::m_ikEffector) {
dModelKeyFrame effectorPose;
dMatrix effectorMatrix(entity->CalculateGlobalMatrix());
effectorPose.m_effector = ConnectEffector(parentBone, effectorMatrix, descriptor.m_mass);
effectorPose.SetMatrix (effectorPose.m_effector->GetTargetMatrix());
model->m_pose.Append(effectorPose);
effectorList[effectorsCount] = effectorPose.m_effector;
effectorsCount++;
} else {
NewtonBody* const childBody = CreateBodyPart(entity, descriptor.m_skeletonDefinition[i]);
dCustomJoint* const joint = ConnectLimb(childBody, parentBody, descriptor.m_skeletonDefinition[i]);
dMatrix bindMatrix(entity->GetParent()->CalculateGlobalMatrix((DemoEntity*)NewtonBodyGetUserData(parentBody)).Inverse());
dModelNode* const bone = new dModelNode(childBody, bindMatrix, parentBone);
if (joint->IsType(dCustomKinematicController::GetType())) {
dModelKeyFrame effectorPose;
effectorPose.m_effector = (dCustomKinematicController*)joint;
effectorPose.SetMatrix(effectorPose.m_effector->GetTargetMatrix());
model->m_pose.Append(effectorPose);
effectorList[effectorsCount] = effectorPose.m_effector;
effectorsCount++;
}
for (DemoEntity* child = entity->GetChild(); child; child = child->GetSibling()) {
parentBones[stackIndex] = bone;
childEntities[stackIndex] = child;
stackIndex++;
}
}
break;
}
}
}
// set mass distribution by density and volume
NormalizeMassAndInertia(model, descriptor.m_mass);
// make internal part non collidable
model->SetAllPartsNonCollidable();
#if 0
dCustomHinge* const fixToWorld = new dCustomHinge (matrix0 * location, model->GetBody(), NULL);
fixToWorld->EnableLimits(true);
fixToWorld->SetLimits(0.0f, 0.0f);
#endif
// setup the pose generator
model->SetAnimTree(effectorsCount, effectorList);
//m_currentController = robot;
}
virtual void OnDebug(dModelRootNode* const root, dCustomJoint::dDebugDisplay* const debugContext)
{
dBalancingCharacter* const model = (dBalancingCharacter*)root;
model->OnDebug(debugContext);
}
virtual void OnUpdateTransform(const dModelNode* const bone, const dMatrix& localMatrix) const
{
NewtonBody* const body = bone->GetBody();
DemoEntity* const ent = (DemoEntity*)NewtonBodyGetUserData(body);
DemoEntityManager* const scene = (DemoEntityManager*)NewtonWorldGetUserData(NewtonBodyGetWorld(body));
dQuaternion rot(localMatrix);
ent->SetMatrix(*scene, rot, localMatrix.m_posit);
}
virtual void OnPreUpdate(dModelRootNode* const root, dFloat timestep) const
{
dBalancingCharacter* const model = (dBalancingCharacter*)root;
model->ApplyControls (timestep, m_posit_x, m_posit_y, m_posit_z, dDegreeToRad * m_pitch);
}
//dBalancingCharacter* m_currentController;
dFloat32 m_pitch;
dFloat32 m_posit_x;
dFloat32 m_posit_y;
dFloat32 m_posit_z;
};
void BalancingCharacter(DemoEntityManager* const scene)
{
// load the sky box
scene->CreateSkyBox();
CreateLevelMesh(scene, "flatPlane.ngd", true);
dBalancingCharacterManager* const manager = new dBalancingCharacterManager(scene);
NewtonWorld* const world = scene->GetNewton();
int defaultMaterialID = NewtonMaterialGetDefaultGroupID(world);
NewtonMaterialSetDefaultFriction(world, defaultMaterialID, defaultMaterialID, 1.0f, 1.0f);
NewtonMaterialSetDefaultElasticity(world, defaultMaterialID, defaultMaterialID, 0.0f);
dMatrix origin (dYawMatrix(-90.0f * dDegreeToRad));
origin.m_posit.m_y += 1.0f;
manager->CreateKinematicModel(tred, origin);
origin.m_posit.m_x = -8.0f;
origin.m_posit.m_y = 1.0f;
origin.m_posit.m_z = 0.0f;
scene->SetCameraMatrix(dGetIdentityMatrix(), origin.m_posit);
}
| 32.424555 | 221 | 0.724456 | JernejL |
3affc0447276fdbd8f52a61b72a451ed999d9aa8 | 4,458 | cpp | C++ | src/Libs/CodecUtils/ImagePlaneDecoder.cpp | miseri/rtp_plus_plus | 244ddd86f40f15247dd39ae7f9283114c2ef03a2 | [
"BSD-3-Clause"
] | 1 | 2021-07-14T08:15:05.000Z | 2021-07-14T08:15:05.000Z | src/Libs/CodecUtils/ImagePlaneDecoder.cpp | 7956968/rtp_plus_plus | 244ddd86f40f15247dd39ae7f9283114c2ef03a2 | [
"BSD-3-Clause"
] | null | null | null | src/Libs/CodecUtils/ImagePlaneDecoder.cpp | 7956968/rtp_plus_plus | 244ddd86f40f15247dd39ae7f9283114c2ef03a2 | [
"BSD-3-Clause"
] | 2 | 2021-07-14T08:15:02.000Z | 2021-07-14T08:56:10.000Z | /** @file
MODULE : ImagePlaneDecoder
TAG : IPD
FILE NAME : ImagePlaneDecoder.cpp
DESCRIPTION : A base class with the common implementations for a
family of implementations to read sequentially from
a bit stream, decode and inverse quantise each colour
plane in an image. The colour plane info is held in
ColourPlaneDecoding objects. The process is as follows:
// Instantiate.
ImagePlaneDecoder* p = new ImagePlaneDecoderImpl();
p->Create();
p->SetEndOfPlaneMarkerVlc();
p->SetEndOfImageMarkerVlc();
.
.
// Attach utility classes.
p->AttachVectorQuantiser();
.
.
p->AttachBitStreamReader();
.
.
// Use.
p->Decode();
.
.
// Delete.
p->Destroy()
delete p;
REVISION HISTORY :
COPYRIGHT :
RESTRICTIONS :
===========================================================================
*/
#ifdef _WINDOWS
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#include <windows.h>
#else
#include <stdio.h>
#endif
#include <memory.h>
#include <string.h>
#include <stdlib.h>
#include "ImagePlaneDecoder.h"
/*
--------------------------------------------------------------------------
Construction and destruction.
--------------------------------------------------------------------------
*/
ImagePlaneDecoder::ImagePlaneDecoder(void)
{
// Colour plane info.
for(int i = 0; i < IPD_COLOUR_PLANES; i++)
_pColourPlane[i] = NULL;
// References to helper classes not owned by this.
_pVectorQuantiser = NULL;
_pRunVlcDecoder = NULL;
_pVqVlcDecoder = NULL;
_pIntraVlcDecoder = NULL; // For INTRA coded images.
// Bit stream to read the encoded bits from.
_pBitStreamReader = NULL;
_minPelValue = 0; // Default to 6 bit range.
_maxPelValue = 63;
_endOfPlaneMarker = 32;
_endOfImageMarker = 33;
}//end constructor.
ImagePlaneDecoder::~ImagePlaneDecoder(void)
{
Destroy();
}//end destructor.
int ImagePlaneDecoder::Create(cpdType* refLum,
int lumWidth, int lumHeight,
cpdType* refChrU,
cpdType* refChrV,
int chrWidth, int chrHeight,
int vecLumWidth, int vecLumHeight,
int vecChrWidth, int vecChrHeight)
{
// Clear out any old baggage.
Destroy();
// For decoding an array of decoded data objects are required
// for each colour component in a plane. Create the colour
// plane info holders.
for(int colour = 0; colour < IPD_COLOUR_PLANES; colour++)
{
_pColourPlane[colour] = new ColourPlaneDecoding();
if( _pColourPlane[colour] == NULL )
{
Destroy();
return(0);
}//end if !_pColourPlane[colour]...
int created = 1;
switch(colour)
{
case IPD_LUM:
created &= _pColourPlane[colour]->Create( refLum,
lumWidth, lumHeight,
vecLumWidth, vecLumHeight);
break;
case IPD_CHRU:
created &= _pColourPlane[colour]->Create( refChrU,
chrWidth, chrHeight,
vecChrWidth, vecChrHeight);
break;
case IPD_CHRV:
created &= _pColourPlane[colour]->Create( refChrV,
chrWidth, chrHeight,
vecChrWidth, vecChrHeight);
break;
}//end switch colour...
if( !created )
{
Destroy();
return(0);
}//end if !created...
// All colours have the same range.
_pColourPlane[colour]->SetPelValueRange(_minPelValue, _maxPelValue);
}//end for colour...
return(1);
}//end Create.
void ImagePlaneDecoder::Destroy(void)
{
for(int i = 0; i < IPD_COLOUR_PLANES; i++)
{
if(_pColourPlane[i] != NULL)
delete _pColourPlane[i];
_pColourPlane[i] = NULL;
}//end for i...
// References.
_pVectorQuantiser = NULL;
_pRunVlcDecoder = NULL;
_pVqVlcDecoder = NULL;
_pIntraVlcDecoder = NULL;
_pBitStreamReader = NULL;
}//end Destroy.
/*
--------------------------------------------------------------------------
Common utility methods.
--------------------------------------------------------------------------
*/
| 27.182927 | 79 | 0.531629 | miseri |
d700d9c29b98326384634d116c11d53c4d293497 | 8,397 | cpp | C++ | re/sniffer/sniffermodel.cpp | thiesmoeller/SavvyCAN | 326455f255da05a3414b219600246c46bb517592 | [
"MIT"
] | 3 | 2021-01-02T21:54:42.000Z | 2022-01-21T13:29:05.000Z | re/sniffer/sniffermodel.cpp | thiesmoeller/SavvyCAN | 326455f255da05a3414b219600246c46bb517592 | [
"MIT"
] | null | null | null | re/sniffer/sniffermodel.cpp | thiesmoeller/SavvyCAN | 326455f255da05a3414b219600246c46bb517592 | [
"MIT"
] | 1 | 2021-11-02T20:56:08.000Z | 2021-11-02T20:56:08.000Z | #include <QDebug>
#include <Qt>
#include <QApplication>
#include "sniffermodel.h"
#include "snifferwindow.h"
#include "SnifferDelegate.h"
SnifferModel::SnifferModel(QObject *parent)
: QAbstractItemModel(parent),
mFilter(false),
mNeverExpire(false),
mFadeInactive(false),
mMuteNotched(false),
mTimeSequence(0)
{
QColor TextColor = QApplication::palette().color(QPalette::Text);
if (TextColor.red() + TextColor.green() + TextColor.blue() < 200)
{
mDarkMode = false;
}
else mDarkMode = true;
}
SnifferModel::~SnifferModel()
{
qDeleteAll(mMap);
mMap.clear();
mFilters.clear();
}
int SnifferModel::columnCount(const QModelIndex &parent) const
{
return parent.isValid() ? 0 : tc::LAST+1;
}
int SnifferModel::rowCount(const QModelIndex &parent) const
{
const QMap<quint32, SnifferItem*>& map = mFilter ? mFilters : mMap;
return parent.isValid() ? 0 : map.size();
}
QVariant SnifferModel::data(const QModelIndex &index, int role) const
{
if (!index.isValid())
return QVariant();
SnifferItem *item = static_cast<SnifferItem*>(index.internalPointer());
if(!item) QVariant();
int col = index.column();
switch(role)
{
case Qt::DisplayRole:
{
switch(col)
{
case tc::DELTA:
return QString::number(item->getDelta(), 'f');
case tc::ID:
return QString("%1").arg(item->getId(), 5, 16, QLatin1Char(' ')).toUpper();
default:
break;
}
if(tc::DATA_0<=col && col <=tc::DATA_7)
{
int data = item->getData(col-tc::DATA_0);
if(data >= 0)
{
return QString("%1").arg((uint8_t)data, 2, 16, QLatin1Char('0')).toUpper();
}
}
break;
}
case Qt::ForegroundRole:
{
if (!mFadeInactive || col < 2) return QApplication::palette().brush(QPalette::Text);
int v = item->getSeqInterval(col - 2) * 10;
//qDebug() << "mTS: " << mTimeSequence << " gDT(" << (col - 2) << ") " << item->getDataTimestamp(col - 2);
if (v > 225) v = 225;
if (v < 0) v = 0;
if (!mDarkMode) //text defaults to being dark
{
return QBrush(QColor(v,v,v,255));
}
else //text defaults to being light
{
return QBrush(QColor(255-v,255-v,255-v,255));
}
}
case Qt::BackgroundRole:
{
if(tc::ID==col)
{
if(item->elapsed() > 4000)
{
if (!mDarkMode) return QBrush(Qt::red);
return QBrush(QColor(128,0,0));
}
}
else if(tc::DATA_0<=col && col<=tc::DATA_7)
{
dc change = item->dataChange(col-tc::DATA_0);
switch(change)
{
case dc::INC:
if (!mDarkMode) return QBrush(Qt::green);
return QBrush(QColor(0,128,0));
case dc::DEINC:
if (!mDarkMode) return QBrush(Qt::red);
return QBrush(QColor(128,0,0));
default:
return QApplication::palette().brush(QPalette::Base);
}
}
break;
}
}
return QVariant();
}
Qt::ItemFlags SnifferModel::flags(const QModelIndex &index) const
{
if (!index.isValid())
return 0;
return QAbstractItemModel::flags(index);
}
QVariant SnifferModel::headerData(int section, Qt::Orientation orientation, int role) const
{
if (orientation == Qt::Horizontal && role == Qt::DisplayRole)
{
switch(section)
{
case tc::DELTA:
return QString("Delta");
case tc::ID:
return QString("ID");
default:
break;
}
if(tc::DATA_0<=section && section <=tc::DATA_7)
return QString::number(section-tc::DATA_0);
}
return QVariant();
}
QModelIndex SnifferModel::index(int row, int column, const QModelIndex &parent) const
{
if (parent.isValid())
return QModelIndex();
const QMap<quint32, SnifferItem*>& map = mFilter ? mFilters : mMap;
if(column>tc::LAST || row>=map.size())
return QModelIndex();
/* ugly but I can't find best without creating a list to keep indexes */
QMap<quint32, SnifferItem*>::const_iterator iter;
int i;
for(iter = map.begin(), i=0 ; i<row ; ++i, ++iter);
return createIndex(row, column, iter.value());
}
QModelIndex SnifferModel::parent(const QModelIndex &) const
{
return QModelIndex();
}
bool SnifferModel::getNeverExpire()
{
return mNeverExpire;
}
bool SnifferModel::getFadeInactive()
{
return mFadeInactive;
}
bool SnifferModel::getMuteNotched()
{
return mMuteNotched;
}
void SnifferModel::setNeverExpire(bool val)
{
mNeverExpire = val;
}
void SnifferModel::setFadeInactive(bool val)
{
mFadeInactive = val;
}
void SnifferModel::setMuteNotched(bool val)
{
mMuteNotched = val;
}
void SnifferModel::clear()
{
beginResetModel();
qDeleteAll(mMap);
mMap.clear();
mFilters.clear();
mFilter = false;
endResetModel();
}
//Called from window with a timer (currently 200ms)
void SnifferModel::refresh()
{
QMap<quint32, SnifferItem*>::iterator i;
QVector<quint32> toRemove;
SnifferItem* item;
mTimeSequence++;
/* update markers */
for (i = mMap.begin(); i != mMap.end(); ++i)
{
i.value()->updateMarker();
if(i.value()->elapsed()>5000 && !mNeverExpire)
toRemove.append(i.key());
}
if(toRemove.size())
{
beginResetModel();
foreach(quint32 id, toRemove)
{
/* remove element */
item = mMap.take(id);
mFilters.remove(id);
delete item;
/* send notification */
emit idChange(id, false);
}
endResetModel();
}
else
/* refresh data */
dataChanged(createIndex(0, 0),
createIndex(rowCount()-1, columnCount()-1), QVector<int>(Qt::DisplayRole));
}
void SnifferModel::filter(fltType pType, int pId)
{
beginResetModel();
switch(pType)
{
case fltType::NONE:
/* erase everything */
mFilter = true;
mFilters.clear();
break;
case fltType::ADD:
/* add filter to list */
mFilter = true;
mFilters[pId] = mMap[pId];
break;
case fltType::REMOVE:
/* remove filter */
if(!mFilter)
mFilters = mMap;
mFilter = true;
mFilters.remove(pId);
break;
case fltType::ALL:
/* stop filtering */
mFilter = false;
mFilters.clear();
break;
}
endResetModel();
}
/***********************************************/
/********** slots ****************/
/***********************************************/
void SnifferModel::update(CANConnection*, QVector<CANFrame>& pFrames)
{
foreach(const CANFrame& frame, pFrames)
{
if(!mMap.contains(frame.frameId()))
{
int index = std::distance(mMap.begin(), mMap.lowerBound(frame.frameId()));
/* add the frame */
beginInsertRows(QModelIndex(), index, index);
mMap[frame.frameId()] = new SnifferItem(frame, mTimeSequence);
mMap[frame.frameId()]->update(frame, mTimeSequence, mMuteNotched);
endInsertRows();
emit idChange(frame.frameId(), true);
}
else
//updateData
mMap[frame.frameId()]->update(frame, mTimeSequence, mMuteNotched);
}
}
void SnifferModel::notch()
{
QMap<quint32, SnifferItem*>& map = mFilter ? mFilters : mMap;
foreach(SnifferItem* item, map)
item->notch(true);
}
void SnifferModel::unNotch()
{
QMap<quint32, SnifferItem*>& map = mFilter ? mFilters : mMap;
foreach(SnifferItem* item, map)
item->notch(false);
}
| 24.916914 | 118 | 0.524354 | thiesmoeller |
d700fbbcf4e249f05c7453780b3804510a5e7e51 | 35,226 | cpp | C++ | src/vscp/common/vscp_bootdevice_vscp.cpp | nanocortex/vscp | 0b1a51a35a886921179a8112c592547f84c9771a | [
"CC-BY-3.0"
] | null | null | null | src/vscp/common/vscp_bootdevice_vscp.cpp | nanocortex/vscp | 0b1a51a35a886921179a8112c592547f84c9771a | [
"CC-BY-3.0"
] | null | null | null | src/vscp/common/vscp_bootdevice_vscp.cpp | nanocortex/vscp | 0b1a51a35a886921179a8112c592547f84c9771a | [
"CC-BY-3.0"
] | null | null | null | /////////////////////////////////////////////////////////////////////////////
// Name: bootdevice_vscp.cpp
// Purpose:
// Author: Ake Hedman
// Modified by:
// Created: 16/12/2009 22:26:09
// RCS-ID:
// Copyright: (C) 2000-2020
// Ake Hedman, Grodans Paradis AB, <akhe@vscp.org>
// (C) 2012 Dinesh Guleria
// Licence:
// 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 file is part of the VSCP (https://www.vscp.org)
//
// This file 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 file see the file COPYING. If not, write to
// the Free Software Foundation, 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
//
// As a special exception, if other files instantiate templates or use macros
// or inline functions from this file, or you compile this file and link it
// with other works to produce a work based on this file, this file does not
// by itself cause the resulting work to be covered by the GNU General Public
// License. However the source code for this file must still be made available
// in accordance with section (3) of the GNU General Public License.
//
// This exception does not invalidate any other reasons why a work based on
// this file might be covered by the GNU General Public License.
//
// Alternative licenses for VSCP & Friends may be arranged by contacting
// Grodans Paradis AB at info@grodansparadis.com, http://www.grodansparadis.com
///
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma implementation "vscp_bootdevice_vscp.h"
#endif
#ifdef WIN32
#include <winsock2.h>
#endif
#include "vscp_bootdevice_vscp.h"
#include "vscp_bootdevice_vscp_defs.h"
#include <stdio.h>
#define CRC16
#include <crc.h>
CBootDevice_vscp::CBootDevice_vscp(CDllWrapper *pdll,
uint8_t nodeid,
bool bDeviceFound)
: CBootDevice(pdll, nodeid, bDeviceFound)
{
init();
}
CBootDevice_vscp::CBootDevice_vscp(VscpRemoteTcpIf *ptcpip,
cguid &guid,
cguid &ifguid,
bool bDeviceFound)
: CBootDevice(ptcpip, guid, ifguid, bDeviceFound)
{
init();
}
CBootDevice_vscp::~CBootDevice_vscp(void)
{
;
}
///////////////////////////////////////////////////////////////////////////////
// init
//
void
CBootDevice_vscp::init(void)
{
// Create buffers
m_pbufPrg = new unsigned char[BUFFER_SIZE_PROGRAM_COMMON];
m_pAddr = 0;
crcInit();
}
///////////////////////////////////////////////////////////////////////////////
// loadBinaryFile
//
bool
CBootDevice_vscp::loadBinaryFile(const wxString &path, uint16_t type)
{
unsigned long i;
bool rv = false;
#ifdef WIN32
errno_t err;
#else
long err;
#endif
unsigned long fullAddr = 0;
unsigned long highAddr = 0;
unsigned long lowAddr = 0;
unsigned long cntData = 0;
unsigned long recType = 0;
FILE *fs = NULL;
// Init. program memory pointers
m_minFlashAddr = 0xffffffff;
m_maxFlashAddr = 0;
m_totalCntData = 0;
m_bPrgData = false;
m_bFlashMemory = true; // Program memory should be programmed
// Init program memory buffer
if (NULL == m_pbufPrg) return false;
memset(m_pbufPrg, 0xff, BUFFER_SIZE_PROGRAM_COMMON);
#ifdef WIN32
if (0 != (err = fopen_s(&fs, path.char_str(), "r"))) {
return false;
}
#else
if (NULL == (fs = fopen(path.char_str(), "r"))) {
return false;
}
#endif
char szLine[MAX_PATH];
char szData[16];
char *endptr;
bool bRun = true;
while ((true == bRun) && (NULL != fgets(szLine, MAX_PATH, fs))) {
if (':' == szLine[0]) {
// Get data count
memset(szData, 0, 16);
#ifdef WIN32
strncpy_s(szData, 16, (szLine + 1), 2);
#else
strncpy(szData, (szLine + 1), 2);
#endif
cntData = strtoul(szData, &endptr, 16);
m_totalCntData += cntData;
// Get address
memset(szData, 0, 16);
#ifdef WIN32
strncpy_s(szData, 16, (szLine + 3), 4);
#else
strncpy(szData, (szLine + 3), 4);
#endif
lowAddr = strtoul(szData, &endptr, 16);
// Get record type
memset(szData, 0, 16);
#ifdef WIN32
strncpy_s(szData, 16, (szLine + 7), 2);
#else
strncpy(szData, (szLine + 7), 2);
#endif
recType = strtoul(szData, &endptr, 16);
fullAddr = (highAddr * 0xffff) + lowAddr;
// Decode the record type
switch (recType) {
case INTEL_LINETYPE_DATA:
for (i = 0; i < cntData; i++) {
memset(szData, 0, 16);
#ifdef WIN32
strncpy_s(szData, 16, (szLine + ((i * 2) + 9)), 2);
#else
strncpy(szData, (szLine + ((i * 2) + 9)), 2);
#endif
unsigned char val =
(unsigned char)(strtoul(szData, &endptr, 16) & 0xff);
/* In program memory address space? */
if ((fullAddr >= MEMREG_PRG_START_COMMON) &&
(fullAddr <= MEMREG_PRG_END_COMMON)) {
/* Avoid program memory buffer overflow. */
if ((fullAddr - MEMREG_PRG_START_COMMON) <
BUFFER_SIZE_PROGRAM_COMMON) {
// Write into program memory buffer
m_pbufPrg[fullAddr - MEMREG_PRG_START_COMMON] =
val;
m_bPrgData = true;
// Set min flash address
if (fullAddr < m_minFlashAddr)
m_minFlashAddr = fullAddr;
// Set max flash address
if (fullAddr > m_maxFlashAddr)
m_maxFlashAddr = fullAddr;
}
}
++fullAddr;
}
break;
case INTEL_LINETYPE_EOF:
bRun = false; // We are done
rv = true;
break;
case INTEL_LINETYPE_EXTENDED_SEGMENT:
// We don't handle this
break;
case INTEL_LINETYPE_EXTENDED_LINEAR:
memset(szData, 0, 16);
#ifdef WIN32
strncpy_s(szData, 16, (szLine + 9), 4);
#else
strncpy(szData, (szLine + 9), 4);
#endif
highAddr = strtoul(szData, &endptr, 16);
break;
}
}
}
// Flash to program if none read
if (!m_bPrgData) {
m_bFlashMemory = false;
m_minFlashAddr = 0x00000000;
}
fclose(fs);
return rv;
}
///////////////////////////////////////////////////////////////////////////////
// showInfo
//
void
CBootDevice_vscp::showInfo(wxHtmlWindow *phtmlWnd)
{
wxString strInfo;
// Check pointer
if (NULL == phtmlWnd) return;
// Clear HTML
phtmlWnd->SetPage(_(""));
// * * * Flash Memory * * *
phtmlWnd->AppendToPage(_("<b><u>Flash Memory</u></b><br>"));
phtmlWnd->AppendToPage(_("<b>Start :</b><font color=\"#005CB9\">"));
strInfo.Printf(_("0x%08X"), m_minFlashAddr);
phtmlWnd->AppendToPage(strInfo);
phtmlWnd->AppendToPage(_("</font><b> End :</b><font color=\"#005CB9\">"));
strInfo.Printf(_("0x%08X</font><br>"), m_maxFlashAddr);
phtmlWnd->AppendToPage(strInfo);
if (m_bFlashMemory) {
phtmlWnd->AppendToPage(
_("<font color=\"#348017\">Will be programmed</font><br>"));
} else {
phtmlWnd->AppendToPage(
_("<font color=\"#F6358A\">Will not be programmed</font><br>"));
}
phtmlWnd->AppendToPage(_("<br><br>"));
}
///////////////////////////////////////////////////////////////////////////////
// setDeviceInBootMode
//
bool
CBootDevice_vscp::setDeviceInBootMode(void)
{
bool bRun;
uint8_t pageSelectMsb = 0;
uint8_t pageSelectLsb = 0;
uint8_t guid0 = 0;
uint8_t guid3 = 0;
uint8_t guid5 = 0;
uint8_t guid7 = 0;
uint16_t vscpclass;
uint8_t vscptype;
uint8_t priority = 0;
wxBusyCursor busy;
if (USE_DLL_INTERFACE == m_type) {
canalMsg msg, rcvmsg;
time_t tstart, tnow;
memset(msg.data, 0x00, 8);
// Read page register Page select MSB
if (CANAL_ERROR_SUCCESS !=
m_pdll->readLevel1Register(
m_nodeid, 0, VSCP_REG_PAGE_SELECT_MSB, &pageSelectMsb)) {
return false;
}
// Read page register page select lsb
if (CANAL_ERROR_SUCCESS !=
m_pdll->readLevel1Register(
m_nodeid, 0, VSCP_REG_PAGE_SELECT_LSB, &pageSelectLsb)) {
return false;
}
// Read page register GUID0
if (CANAL_ERROR_SUCCESS !=
m_pdll->readLevel1Register(m_nodeid, 0, VSCP_REG_GUID0, &guid0)) {
return false;
}
// Read page register GUID3
if (CANAL_ERROR_SUCCESS !=
m_pdll->readLevel1Register(m_nodeid, 0, VSCP_REG_GUID3, &guid3)) {
return false;
}
// Read page register GUID5
if (CANAL_ERROR_SUCCESS !=
m_pdll->readLevel1Register(m_nodeid, 0, VSCP_REG_GUID5, &guid5)) {
return false;
}
// Read page register GUID7
if (CANAL_ERROR_SUCCESS !=
m_pdll->readLevel1Register(m_nodeid, 0, VSCP_REG_GUID7, &guid7)) {
return false;
}
vscpclass = VSCP_CLASS1_PROTOCOL;
vscptype = VSCP_ENTER_BOOTLODER_MODE;
priority = VSCP_PRIORITY_LOW_COMMON;
// Set device in boot mode
msg.data[0] = m_nodeid; // Nickname to read register from
msg.data[1] =
VSCP_BOOTLOADER_VSCP; // VSCP standard bootloader algorithm
msg.data[2] = guid0;
msg.data[3] = guid3;
msg.data[4] = guid5;
msg.data[5] = guid7;
msg.data[6] = pageSelectMsb;
msg.data[7] = pageSelectLsb;
// Send message
msg.id = ((uint32_t)priority << 26) | ((uint32_t)vscpclass << 16) |
((uint32_t)vscptype << 8) |
m_nodeid; // nodeaddress (our address)
msg.flags = CANAL_IDFLAG_EXTENDED;
msg.sizeData = 8;
if (CANAL_ERROR_SUCCESS == m_pdll->doCmdSend(&msg)) {
bRun = true;
// Get start time
time(&tstart);
while (bRun) {
time(&tnow);
if ((unsigned long)(tnow - tstart) >
BOOT_COMMAND_RESPONSE_TIMEOUT) {
bRun = false;
}
if (m_pdll->doCmdDataAvailable()) {
m_pdll->doCmdReceive(&rcvmsg);
vscpclass = VSCP_CLASS1_PROTOCOL;
vscptype = VSCP_TYPE_PROTOCOL_ACK_BOOT_LOADER;
if ((uint32_t)(rcvmsg.id & 0x01ffffff) ==
(uint32_t)(((uint32_t)vscpclass << 16) |
((uint32_t)vscptype << 8) | m_nodeid)) {
// OK in bootmode - return
m_blockSize = ((uint32_t)rcvmsg.data[0] << 24) |
((uint32_t)rcvmsg.data[1] << 16) |
((uint32_t)rcvmsg.data[2] << 8) |
((uint32_t)rcvmsg.data[3] << 0);
m_numBlocks = ((uint32_t)rcvmsg.data[4] << 24) |
((uint32_t)rcvmsg.data[5] << 16) |
((uint32_t)rcvmsg.data[6] << 8) |
((uint32_t)rcvmsg.data[7] << 0);
return true;
}
}
}
}
} else if (USE_TCPIP_INTERFACE == m_type) {
vscpEventEx event;
time_t tstart, tnow;
// Read page register MSB
if (VSCP_ERROR_SUCCESS !=
m_ptcpip->readLevel2Register(
VSCP_REG_PAGE_SELECT_MSB, 0, &pageSelectMsb, m_ifguid, &m_guid)) {
return false;
}
// Read page register LSB
if (VSCP_ERROR_SUCCESS !=
m_ptcpip->readLevel2Register(
VSCP_REG_PAGE_SELECT_LSB, 0, &pageSelectLsb, m_ifguid, &m_guid)) {
return false;
}
// Read GUID0
if (VSCP_ERROR_SUCCESS !=
m_ptcpip->readLevel2Register(
VSCP_REG_GUID0, 0, &guid0, m_ifguid, &m_guid)) {
return false;
}
// Read GUID3
if (VSCP_ERROR_SUCCESS !=
m_ptcpip->readLevel2Register(
VSCP_REG_GUID3, 0, &guid3, m_ifguid, &m_guid)) {
return false;
}
// Read GUID5
if (VSCP_ERROR_SUCCESS !=
m_ptcpip->readLevel2Register(
VSCP_REG_GUID5, 0, &guid5, m_ifguid, &m_guid)) {
return false;
}
// Read GUID7
if (VSCP_ERROR_SUCCESS !=
m_ptcpip->readLevel2Register(
VSCP_REG_GUID7, 0, &guid7, m_ifguid, &m_guid)) {
return false;
}
// Set device in boot mode
// Send message
event.head = 0;
event.vscp_class = 512; // CLASS2.PROTOCOL1
event.vscp_type =
VSCP_ENTER_BOOTLODER_MODE; // We want to enter bootloader mode
memset(event.GUID, 0, 16); // We use interface GUID
event.sizeData = 16 + 8; // Interface GUID
memset(event.data, 0, sizeof(event.data));
memcpy(event.data, m_ifguid.m_id, 16); // Address node i/f
event.data[16] = m_guid.getLSB(); // Nickname for device
event.data[17] =
VSCP_BOOTLOADER_VSCP; // VSCP standard bootloader algorithm
event.data[18] = guid0;
event.data[19] = guid3;
event.data[20] = guid5;
event.data[21] = guid7;
event.data[22] = pageSelectMsb;
event.data[23] = pageSelectLsb;
if (VSCP_ERROR_SUCCESS == m_ptcpip->doCmdSendEx(&event)) {
bRun = true;
// Get start time
time(&tstart);
while (bRun) {
time(&tnow);
if ((unsigned long)(tnow - tstart) >
BOOT_COMMAND_RESPONSE_TIMEOUT) {
bRun = false;
}
// vscpEventEx rcvmsg;
if (m_ptcpip->doCmdDataAvailable()) {
m_ptcpip->doCmdReceiveEx(&event);
// Check for response --- Type = 13 (0x0D) ACK boot loader
// mode.
if (VSCP_TYPE_PROTOCOL_ACK_BOOT_LOADER == event.vscp_type) {
// OK in bootmode - return
m_blockSize = ((uint32_t)event.data[0] << 24) |
((uint32_t)event.data[1] << 16) |
((uint32_t)event.data[2] << 8) |
((uint32_t)event.data[3] << 0);
m_numBlocks = ((uint32_t)event.data[4] << 24) |
((uint32_t)event.data[5] << 16) |
((uint32_t)event.data[6] << 8) |
((uint32_t)event.data[7] << 0);
return true;
}
}
}
}
}
return false;
}
///////////////////////////////////////////////////////////////////////////////
// doFirmwareLoad
//
bool
CBootDevice_vscp::doFirmwareLoad(void)
{
bool bRun = true;
bool rv = true;
bool flag_crc = true;
wxBusyCursor busy;
m_checksum = 0;
uint32_t progress = 0;
uint32_t addr;
wxString wxStatusStr;
uint32_t nFlashPackets = 0;
// Packet size is always eight byte due to CAN frame limitation
// Flash memory
if (m_bPrgData) {
nFlashPackets = (m_maxFlashAddr - m_minFlashAddr) / 8;
if (0 != ((m_maxFlashAddr - m_minFlashAddr) % 8)) {
nFlashPackets++;
}
}
long nTotalPackets = nFlashPackets;
wxProgressDialog *pDlg =
new wxProgressDialog(_T("Boot loading in progress..."),
_T("---"),
nTotalPackets,
NULL,
wxPD_AUTO_HIDE | wxPD_APP_MODAL | wxPD_CAN_ABORT |
wxPD_ELAPSED_TIME | wxPD_REMAINING_TIME);
// Initialize checksum
addr = m_minFlashAddr;
// * * * flash memory * * *
if (rv && m_bPrgData) {
addr = m_minFlashAddr;
// nFlashPackets = number of 8 byte packets
m_blockNumber = 0;
for (uint32_t blk = 0; ((blk < nFlashPackets) && (true == bRun));
blk++) {
// Start block data transfer
if (0 == (blk % (m_blockSize / 8))) {
if (true != sendVSCPCommandStartBlock(blk * 8 / m_blockSize))
wxMessageBox(_T("start Block error"));
bRun = false;
}
wxStatusStr.Printf(_("Loading flash... %0X"), addr);
if (false == (bRun = pDlg->Update(progress, wxStatusStr))) {
wxMessageBox(_T("Aborted by user."));
rv = false;
bRun = false;
}
if (false == writeFirmwareSector()) {
wxMessageBox(_T("Failed to write flash data to node(s)."));
rv = false;
bRun = false;
}
/* After a complete block, wait for the block data acknowledge. */
if (0 == ((blk + 1) % (m_blockSize / 8))) {
if (USE_DLL_INTERFACE == m_type) {
flag_crc = sendVSCPCommandSeqenceLevel1();
} else if (USE_TCPIP_INTERFACE == m_type) {
flag_crc = sendVSCPCommandSeqenceLevel2();
}
m_blockNumber++;
}
wxMilliSleep(1);
progress++;
addr += 8;
}
}
/*
** All blocks loaded -- now reset the device
*/
if (!sendVSCPBootCommand(
VSCP_TYPE_PROTOCOL_ACTIVATE_NEW_IMAGE)) { // send as Zero as at --
// present AVR bode for
// microcontroller -- does
// not implement this
// method.
// Failure
wxMessageBox(_T(" ACTIVATE_NEW_IMAGE TX fails"));
} else {
}
// Done
progress = nTotalPackets;
pDlg->Update(progress, wxStatusStr);
pDlg->Destroy();
return rv;
}
///////////////////////////////////////////////////////////////////////////////
// writeFirmwareSector
//
bool
CBootDevice_vscp::writeFirmwareSector(void)
{
canalMsg msg;
vscpEventEx event;
bool rv = true;
uint16_t vscpclass = VSCP_CLASS1_PROTOCOL;
uint8_t vscptype = VSCP_TYPE_PROTOCOL_BLOCK_DATA;
uint8_t priority = VSCP_PRIORITY_LOW_COMMON;
// Send event
if (USE_DLL_INTERFACE == m_type) {
// Send message
msg.id = ((uint32_t)priority << 26) | ((uint32_t)vscpclass << 16) |
((uint32_t)vscptype << 8) |
m_nodeid; // nodeaddress (our address)
msg.flags = CANAL_IDFLAG_EXTENDED;
msg.sizeData = 8;
} else if (USE_TCPIP_INTERFACE == m_type) {
event.head = 0;
event.vscp_class = 512; // CLASS2.PROTOCOL1
event.vscp_type = vscptype;
memset(event.GUID, 0, 16); // We use interface GUID
event.sizeData = 16 + 8; // Interface GUID
memcpy(event.data, m_guid.m_id, 16); // Address node
} else {
return false;
}
uint8_t b;
for (int i = 0; i < 8; i++) {
b = m_pbufPrg[m_pAddr];
m_checksum += m_pbufPrg[m_pAddr];
// Write data into frame
if (USE_DLL_INTERFACE == m_type) {
msg.data[i] = b;
} else if (USE_TCPIP_INTERFACE == m_type) {
event.data[16 + i] = b;
} else {
return false;
}
// Update address
m_pAddr++;
}
if (USE_DLL_INTERFACE == m_type) {
m_pdll->doCmdSend(&msg);
} else if (USE_TCPIP_INTERFACE == m_type) {
m_ptcpip->doCmdSendEx(&event);
} else {
rv = false;
}
return rv;
}
///////////////////////////////////////////////////////////////////////////////
// sendVSCPCommandStartBlock
// PageAddress : Page to be programmed
// This command have no ACK
bool
CBootDevice_vscp::sendVSCPCommandStartBlock(uint16_t PageAddress)
{
uint16_t vscpclass = 0;
uint8_t vscptype = 0;
uint8_t priority = 0;
wxBusyCursor busy;
if (USE_DLL_INTERFACE == m_type) {
canalMsg msg;
memset(msg.data, 0x00, 8);
vscpclass = VSCP_CLASS1_PROTOCOL; // Class
vscptype = VSCP_TYPE_PROTOCOL_START_BLOCK; // Start block data transfer.
priority = VSCP_PRIORITY_LOW_COMMON;
// block data transfer
msg.data[0] = 0x00; // Block number MSB
msg.data[1] = 0x00; // Block number
msg.data[2] = (PageAddress & 0xFF00) >> 8; // Block number
msg.data[3] = (PageAddress & 0x00FF); // Block number LSB
// Send message
msg.id = ((uint32_t)priority << 26) | ((uint32_t)vscpclass << 16) |
((uint32_t)vscptype << 8) |
m_nodeid; // nodeaddress (our address)
msg.flags = CANAL_IDFLAG_EXTENDED;
msg.sizeData = 4;
if (CANAL_ERROR_SUCCESS == m_pdll->doCmdSend(&msg)) {
wxMilliSleep(1);
return true;
}
} else if (USE_TCPIP_INTERFACE == m_type) {
// Start block data transfer.
vscpEventEx event;
// Send message
event.head = 0;
event.vscp_class = 512; // CLASS2.PROTOCOL1
event.vscp_type =
VSCP_TYPE_PROTOCOL_START_BLOCK; // We want to Start block data
// transfer.
memset(event.GUID, 0, 16); // We use interface GUID
event.sizeData = 16 + 4; // Interface GUID
memcpy(event.data, m_guid.m_id, 16); // Address node
event.data[16] = 0x00; // Block number MSB
event.data[17] = 0x00; // Block number
event.data[18] = (PageAddress & 0xFF00) >> 8; // Block number
event.data[19] = (PageAddress & 0x00FF); // Block number LSB
if (CANAL_ERROR_SUCCESS == m_ptcpip->doCmdSendEx(&event)) {
wxMilliSleep(1);
return true;
}
}
return false;
}
///////////////////////////////////////////////////////////////////////////////
// sendVSCPBootCommand
// This routine is used to send command from nodes under boot.
// Index tells which Type & class to send.
//
bool
CBootDevice_vscp::sendVSCPBootCommand(uint8_t index)
{
uint16_t vscpclass;
uint8_t vscptype;
// uint8_t nodeid;
uint8_t priority = 0;
if (USE_DLL_INTERFACE == m_type) {
canalMsg msg; // rcvmsg;
// time_t tstart, tnow;
memset(msg.data, 0x00, 8);
if (index == VSCP_TYPE_PROTOCOL_ACTIVATE_NEW_IMAGE) {
uint16_t crc16 = crcFast(&m_pbufPrg[0], m_numBlocks * m_blockSize);
vscpclass = VSCP_CLASS1_PROTOCOL; // Class
vscptype = VSCP_TYPE_PROTOCOL_ACTIVATE_NEW_IMAGE;
priority = VSCP_PRIORITY_LOW_COMMON;
msg.data[0] = (uint8_t)(crc16 >> 8) & 0xff;
msg.data[1] = (uint8_t)(crc16 >> 0) & 0xff;
msg.sizeData = 2;
} else if (index == VSCP_TYPE_PROTOCOL_PROGRAM_BLOCK_DATA) {
vscpclass = VSCP_CLASS1_PROTOCOL; // Class
vscptype = VSCP_TYPE_PROTOCOL_PROGRAM_BLOCK_DATA;
priority = VSCP_PRIORITY_LOW_COMMON;
// block data transfer
msg.data[0] = ((uint8_t)(m_blockNumber >> 24)) & 0xFF;
msg.data[1] = ((uint8_t)(m_blockNumber >> 16)) & 0xFF;
msg.data[2] = ((uint8_t)(m_blockNumber >> 8)) & 0xFF;
msg.data[3] = ((uint8_t)(m_blockNumber >> 0)) & 0xFF;
msg.sizeData = 4;
} else {
return false;
}
// Send message
msg.id = ((uint32_t)priority << 26) | ((uint32_t)vscpclass << 16) |
((uint32_t)vscptype << 8) |
m_nodeid; // nodeaddress (our address)
msg.flags = CANAL_IDFLAG_EXTENDED;
if (CANAL_ERROR_SUCCESS == m_pdll->doCmdSend(&msg)) {
// bRun = true;
wxMilliSleep(1);
return true;
}
} else if (USE_TCPIP_INTERFACE == m_type) {
vscpEventEx event;
// Send message
if (index == VSCP_TYPE_PROTOCOL_ACTIVATE_NEW_IMAGE) {
uint16_t crc16 = crcFast(&m_pbufPrg[0], m_numBlocks * m_blockSize);
event.head = 0;
event.vscp_class = 512; // CLASS2.PROTOCOL1
event.vscp_type =
VSCP_TYPE_PROTOCOL_ACTIVATE_NEW_IMAGE; // Activate new Image
memset(event.GUID, 0, 16); // We use interface GUID
event.sizeData = 16 + 2; // Interface GUID
memcpy(event.data, m_guid.m_id, 16); // Address node
event.data[16] = (uint8_t)(crc16 >> 8) & 0xff;
event.data[17] = (uint8_t)(crc16 >> 0) & 0xff;
} else if (index == VSCP_TYPE_PROTOCOL_PROGRAM_BLOCK_DATA) {
event.head = 0;
event.vscp_class = 512; // CLASS2.PROTOCOL1
event.vscp_type =
VSCP_TYPE_PROTOCOL_PROGRAM_BLOCK_DATA; // Activate new Image
memset(event.GUID, 0, 16); // We use interface GUID
event.sizeData = 16 + 4; // Interface GUID
memcpy(event.data, m_guid.m_id, 16); // Address node
event.data[16] = ((uint8_t)(m_blockNumber >> 24)) & 0xFF;
event.data[17] = ((uint8_t)(m_blockNumber >> 16)) & 0xFF;
event.data[18] = ((uint8_t)(m_blockNumber >> 8)) & 0xFF;
event.data[19] = ((uint8_t)(m_blockNumber >> 0)) & 0xFF;
} else {
return false;
}
if (CANAL_ERROR_SUCCESS == m_ptcpip->doCmdSendEx(&event)) {
wxMilliSleep(1);
return true;
}
}
return false;
}
///////////////////////////////////////////////////////////////////////////////
// sendVSCPCommandSeqenceLevel1
// This routine is used to check ack & send command from nodes under boot.
// check response VSCP_TYPE_PROTOCOL_BLOCK_DATA_ACK --- Check CRC
// send VSCP_TYPE_PROTOCOL_PROGRAM_BLOCK_DATA
// check response VSCP_TYPE_PROTOCOL_PROGRAM_BLOCK_DATA_ACK
//
bool
CBootDevice_vscp::sendVSCPCommandSeqenceLevel1(void)
{
if (!checkResponseLevel1(VSCP_TYPE_PROTOCOL_BLOCK_DATA_ACK)) {
wxMessageBox(_T(" Response PROTOCOL_BLOCK_DATA_ACK fails"));
} else {
if (crc_16_host != crc_16_remote) {
m_pAddr -= m_blockSize;
return false;
}
}
wxMilliSleep(1);
/*
** Send command
*/
if (!sendVSCPBootCommand(VSCP_TYPE_PROTOCOL_PROGRAM_BLOCK_DATA)) {
wxMessageBox(_T(" PROGRAM_BLOCK_DATA TX fails"));
} else {
}
wxMilliSleep(1);
if (!checkResponseLevel1(VSCP_TYPE_PROTOCOL_PROGRAM_BLOCK_DATA_ACK)) {
wxMessageBox(_T(" Response PROGRAM_BLOCK_DATA_ACK fails"));
} else {
}
wxMilliSleep(1);
return true;
}
///////////////////////////////////////////////////////////////////////////////
// sendVSCPCommandSeqenceLevel2
// This routine is used to check ack & send command from nodes under boot.
// check response VSCP_TYPE_PROTOCOL_BLOCK_DATA_ACK
// send VSCP_TYPE_PROTOCOL_PROGRAM_BLOCK_DATA
// check response VSCP_TYPE_PROTOCOL_PROGRAM_BLOCK_DATA_ACK
//
bool
CBootDevice_vscp::sendVSCPCommandSeqenceLevel2(void)
{
// Check response
if (!checkResponseLevel2(VSCP_TYPE_PROTOCOL_BLOCK_DATA_ACK)) {
wxMessageBox(_T(" Response PROTOCOL_BLOCK_DATA_ACK fails"));
} else {
if (crc_16_host != crc_16_remote) {
m_pAddr -= m_blockSize;
return false;
}
}
wxMilliSleep(1);
/*
** Send command
*/
if (!sendVSCPBootCommand(VSCP_TYPE_PROTOCOL_PROGRAM_BLOCK_DATA)) {
// Failure
wxMessageBox(_T(" PROGRAM_BLOCK_DATA TX fails"));
} else {
;
}
wxMilliSleep(1);
// Check response
if (!checkResponseLevel2(
VSCP_TYPE_PROTOCOL_PROGRAM_BLOCK_DATA_ACK)) { // send as Zero as at --
// present AVR bode for
// microcontroller --
// does not implement
// this method.
// Failure
// rv = false;
// TODO Resend the block
wxMessageBox(_T(" Response PROGRAM_BLOCK_DATA_ACK fails"));
} else {
}
return true;
}
///////////////////////////////////////////////////////////////////////////////
// checkResponseLevel1
//
// Type = 20 (0x14) ACK program data block -- for 8 byte packet received
// correctly by AVR bootloader
//
bool
CBootDevice_vscp::checkResponseLevel1(uint8_t index)
{
// canalMsg msg;
// time_t tstart, tnow;
bool rv = false;
uint16_t vscpclass;
uint8_t vscptype;
uint8_t priority = 0;
canalMsg rcvmsg; // msg,
if (NULL == m_pdll) return false;
// Get system time
// time( &tstart );
bool bRun = true;
while (bRun) {
if (m_pdll->doCmdDataAvailable()) {
// if(m_type==0xff)
// wxMessageBox( _T("123456") );
m_pdll->doCmdReceive(&rcvmsg);
if ((int)(rcvmsg.id & 0xff) == m_nodeid) {
// Case -- index = 0 --- not implemented always return true
if (index == 0) {
// Response received from all - return success
rv = true;
bRun = false;
}
// Case -- index = 1
else if (index == VSCP_TYPE_PROTOCOL_BLOCK_DATA_ACK) {
vscpclass = VSCP_CLASS1_PROTOCOL;
vscptype = VSCP_TYPE_PROTOCOL_BLOCK_DATA_ACK;
if ((uint32_t)(rcvmsg.id & 0x01ffffff) ==
(uint32_t)(((uint32_t)vscpclass << 16) |
((uint32_t)vscptype << 8) | m_nodeid)) {
// Calculate CRC in host
crc_16_host = crcFast(&m_pbufPrg[m_pAddr - m_blockSize],
m_blockSize);
// GET CRC in remote node
crc_16_remote = (((uint16_t)rcvmsg.data[0]) << 8) |
(((uint16_t)rcvmsg.data[1]) << 0);
// Response received from all - return success
rv = true;
bRun = false;
}
} else if (index == VSCP_TYPE_PROTOCOL_PROGRAM_BLOCK_DATA_ACK) {
vscpclass = VSCP_CLASS1_PROTOCOL;
vscptype = VSCP_TYPE_PROTOCOL_PROGRAM_BLOCK_DATA_ACK;
if ((uint32_t)(rcvmsg.id & 0x01ffffff) ==
(uint32_t)(((uint32_t)vscpclass << 16) |
((uint32_t)vscptype << 8) | m_nodeid)) {
// Response received from all - return success
rv = true;
bRun = false;
}
}
} // id found
} // received message
}
return rv;
}
///////////////////////////////////////////////////////////////////////////////
// checkResponseLevel2
// Type = 20 (0x14) ACK program data block --
// for 8 byte packet received correctly by bootloader
//
bool
CBootDevice_vscp::checkResponseLevel2(uint8_t index)
{
vscpEventEx event;
// time_t tstart, tnow;
bool rv = false;
if (NULL == m_ptcpip) return false;
bool bRun = true;
while (bRun) {
if (m_ptcpip->doCmdDataAvailable()) {
m_ptcpip->doCmdReceiveEx(&event);
if ((VSCP_CLASS1_PROTOCOL == event.vscp_class) &&
(m_guid.getLSB() == event.GUID[15])) { // correct id
// Case -- index = 0 --- not implemented always return true
if (index == 0) {
// Response received from all - return success
rv = true;
bRun = false;
}
// Case -- index = VSCP_TYPE_PROTOCOL_BLOCK_DATA_ACK
else if (index == VSCP_TYPE_PROTOCOL_BLOCK_DATA_ACK) {
if (event.vscp_type == VSCP_TYPE_PROTOCOL_BLOCK_DATA_ACK) {
// Calculate CRC in host
crc_16_host = crcFast(&m_pbufPrg[m_pAddr - m_blockSize],
m_blockSize);
// GET CRC in remote node
crc_16_remote = (((uint16_t)event.data[0]) << 8) |
(((uint16_t)event.data[1]) << 0);
// Response received from all - return success
rv = true;
bRun = false;
}
}
// Case -- index = VSCP_TYPE_PROTOCOL_PROGRAM_BLOCK_DATA_ACK
else if (index == VSCP_TYPE_PROTOCOL_PROGRAM_BLOCK_DATA_ACK) {
if (event.vscp_type ==
VSCP_TYPE_PROTOCOL_PROGRAM_BLOCK_DATA_ACK) {
// Response received from all - return success
rv = true;
bRun = false;
}
}
} // id
} // received message
}
return rv;
}
| 30.133447 | 80 | 0.505167 | nanocortex |
d701232b2015913583f65b9984f53b0253d634d1 | 23,571 | inl | C++ | include/bit/stl/utilities/detail/variant.inl | bitwizeshift/bit-stl | cec555fbda2ea1b6e126fa719637dde8d3f2ddd3 | [
"MIT"
] | 6 | 2017-03-29T07:20:30.000Z | 2021-12-28T20:17:33.000Z | include/bit/stl/utilities/detail/variant.inl | bitwizeshift/bit-stl | cec555fbda2ea1b6e126fa719637dde8d3f2ddd3 | [
"MIT"
] | 6 | 2017-10-11T02:26:07.000Z | 2018-04-16T03:09:48.000Z | include/bit/stl/utilities/detail/variant.inl | bitwizeshift/bit-stl | cec555fbda2ea1b6e126fa719637dde8d3f2ddd3 | [
"MIT"
] | 1 | 2018-08-27T15:03:47.000Z | 2018-08-27T15:03:47.000Z | #ifndef BIT_STL_UTILITIES_DETAIL_VARIANT_INL
#define BIT_STL_UTILITIES_DETAIL_VARIANT_INL
//----------------------------------------------------------------------------
// Constructors / Assignment
//----------------------------------------------------------------------------
template<typename...Types>
inline constexpr bit::stl::variant<Types...>
::variant( enable_overload_if_t<is_default_constructible,variant_ctor> )
noexcept(std::is_nothrow_default_constructible<T0>::value)
: base_type( in_place_index<0> )
{
}
template<typename...Types>
inline bit::stl::variant<Types...>
::variant( enable_overload_if_t<is_copy_constructible,const variant&> other )
noexcept( bit::stl::conjunction<std::is_nothrow_copy_constructible<Types>...>::value )
{
runtime_emplace( other.index(), other.m_union );
}
template<typename...Types>
inline bit::stl::variant<Types...>
::variant( enable_overload_if_t<is_move_constructible,variant&&> other )
noexcept( bit::stl::conjunction<std::is_nothrow_move_constructible<Types>...>::value )
{
runtime_emplace( other.index(), std::move(other.m_union) );
}
template<typename...Types>
template<typename T, typename>
inline constexpr bit::stl::variant<Types...>::variant( T&& t )
noexcept( std::is_nothrow_constructible<typename bit::stl::variant<Types...>::template T_j<T>,T>::value )
: base_type( in_place_index<detail::conversion_index_v<T,variant>>, std::forward<T>(t) )
{
}
template<typename...Types>
template<typename T, typename...Args, typename>
inline constexpr bit::stl::variant<Types...>
::variant( in_place_type_t<T>, Args&&... args )
: base_type( in_place_index<detail::index_from<T,Types...>::value>, std::forward<Args>(args)... )
{
}
template<typename...Types>
template<typename T, typename U, typename...Args, typename>
inline constexpr bit::stl::variant<Types...>
::variant( in_place_type_t<T>, std::initializer_list<U> il, Args&&... args )
: base_type( in_place_index<detail::index_from<T,Types...>::value>, il, std::forward<Args>(args)... )
{
}
template<typename...Types>
template<std::size_t I, typename...Args, typename>
inline constexpr bit::stl::variant<Types...>
::variant( in_place_index_t<I>, Args&&...args )
: base_type( in_place_index<I>, std::forward<Args>(args)... )
{
}
template<typename...Types>
template<std::size_t I, typename U, typename... Args, typename>
inline constexpr bit::stl::variant<Types...>
::variant( in_place_index_t<I>, std::initializer_list<U> il, Args&&...args )
: base_type( in_place_index<I>, il, std::forward<Args>(args)... )
{
}
//----------------------------------------------------------------------------
template<typename...Types>
inline bit::stl::variant<Types...>&
bit::stl::variant<Types...>::operator=( enable_overload_if_t<is_copy_assignable,const variant&> other )
{
if( other.valueless_by_exception() ) {
base_type::destruct();
} else if( index() == other.index() ) {
runtime_assign( other.index(),other.m_union );
} else {
this->operator=(variant(other));
}
return (*this);
}
//----------------------------------------------------------------------------
template<typename...Types>
inline bit::stl::variant<Types...>&
bit::stl::variant<Types...>::operator=( enable_overload_if_t<is_move_assignable,variant&&> other )
noexcept( bit::stl::conjunction<std::is_nothrow_move_constructible<Types>...,
std::is_nothrow_move_assignable<Types>...>::value)
{
if( other.valueless_by_exception() ) {
base_type::destruct();
} else if( index() == other.index() ) {
runtime_assign( other.index(), std::move(other.m_union) );
} else {
runtime_emplace( other.index(), std::move(other.m_union) );
}
return (*this);
}
//----------------------------------------------------------------------------
template<typename...Types>
template<typename T, typename>
inline bit::stl::variant<Types...>&
bit::stl::variant<Types...>::operator=(T&& t)
noexcept( std::is_nothrow_assignable<typename bit::stl::variant<Types...>::template T_j<T>,T>::value &&
std::is_nothrow_constructible<typename bit::stl::variant<Types...>::template T_j<T>,T>::value )
{
static constexpr auto index = detail::conversion_index<T,variant>::value;
using T_j = variant_alternative_t<index,variant>;
if( index == this->index() ) {
static_assign<index>( std::forward<T>(t) );
} else if (std::is_nothrow_constructible<T_j, T>::value ||
!std::is_nothrow_move_constructible<T_j>::value ) {
emplace<index>( std::forward<T>(t) );
} else {
this->operator=(variant(std::forward<T>(t)));
}
return (*this);
}
//----------------------------------------------------------------------------
// Observers
//----------------------------------------------------------------------------
template<typename...Types>
inline constexpr std::size_t bit::stl::variant<Types...>::index()
const noexcept
{
return base_type::m_index;
}
template<typename...Types>
inline constexpr bool bit::stl::variant<Types...>::valueless_by_exception()
const noexcept
{
return base_type::m_index == variant_npos;
}
//----------------------------------------------------------------------------
// Modifiers
//----------------------------------------------------------------------------
template<typename...Types>
template<typename T, typename...Args, typename>
inline T& bit::stl::variant<Types...>::emplace( Args&&...args )
{
using index = detail::index_from<T,Types...>;
return emplace<index::value>( std::forward<Args>(args)... );
}
template<typename...Types>
template<typename T, typename U, typename...Args, typename>
inline T& bit::stl::variant<Types...>::emplace( std::initializer_list<U> il,
Args&&...args )
{
using index = detail::index_from<T,Types...>;
return emplace<index::value>( il, std::forward<Args>(args)... );
}
template<typename...Types>
template<std::size_t I, typename... Args, typename>
inline bit::stl::variant_alternative_t<I, bit::stl::variant<Types...>>&
bit::stl::variant<Types...>::emplace( Args&&... args )
{
static_assert(I<sizeof...(Types), "");
base_type::destruct();
auto& result = static_emplace<I>( in_place_index<I>, base_type::m_union, std::forward<Args>(args)... );
base_type::m_index = I;
return result;
}
template<typename...Types>
template<std::size_t I, typename U, typename... Args, typename>
inline bit::stl::variant_alternative_t<I, bit::stl::variant<Types...>>&
bit::stl::variant<Types...>::emplace( std::initializer_list<U> il,
Args&&... args )
{
static_assert(I<sizeof...(Types), "");
base_type::destruct();
auto& result = static_emplace<I>( in_place_index<I>, base_type::m_union, il, std::forward<Args>(args)... );
base_type::m_index = I;
return result;
}
template<typename...Types>
inline void bit::stl::variant<Types...>::swap( variant& rhs )
{
// Do nothing if both types are valueless by exception
if( valueless_by_exception() && rhs.valueless_by_exception() ) {
return;
}
// If indices match, call swap
if( index() == rhs.index() ) {
base_type::swap( static_cast<base_type&>(rhs) );
} else {
variant tmp = std::move(*this);
*this = std::move(rhs);
rhs = std::move(tmp);
}
}
template<typename...Types>
template<std::size_t I>
inline constexpr bit::stl::variant_alternative_t<I,bit::stl::variant<Types...>>&
bit::stl::variant<Types...>::get( in_place_index_t<I> )
noexcept
{
return base_type::get( in_place_index<I> );
}
template<typename...Types>
template<std::size_t I>
inline constexpr const bit::stl::variant_alternative_t<I,bit::stl::variant<Types...>>&
bit::stl::variant<Types...>::get( in_place_index_t<I> )
const noexcept
{
return base_type::get( in_place_index<I> );
}
//----------------------------------------------------------------------------
// Private Member Functions
//----------------------------------------------------------------------------
template<typename...Types>
template<typename VariantUnion>
inline void bit::stl::variant<Types...>
::runtime_assign( std::size_t index,
VariantUnion&& source )
{
runtime_assign_impl( index, base_type::m_union, std::forward<VariantUnion>(source) );
}
template<typename...Types>
template<typename VariantUnion>
inline void bit::stl::variant<Types...>
::runtime_assign_impl( std::size_t current,
VariantUnion& dest,
VariantUnion&& source,
std::enable_if_t<detail::variant_union_has_next<std::decay_t<VariantUnion>>::value>* )
{
if( current == 0 ) {
dest.current = std::move(source.current);
return;
}
runtime_assign_impl( current-1, dest.next, std::move(source.next) );
}
template<typename...Types>
template<typename VariantUnion>
inline void bit::stl::variant<Types...>
::runtime_assign_impl( std::size_t current,
VariantUnion& dest,
VariantUnion&& source,
std::enable_if_t<!detail::variant_union_has_next<std::decay_t<VariantUnion>>::value>* )
{
dest.current = std::move(source.current);
}
template<typename...Types>
template<typename VariantUnion>
inline void bit::stl::variant<Types...>
::runtime_assign_impl( std::size_t current,
VariantUnion& dest,
const VariantUnion& source,
std::enable_if_t<detail::variant_union_has_next<std::decay_t<VariantUnion>>::value>* )
{
if( current == 0 ) {
dest.current = source.current;
return;
}
runtime_assign_impl( current-1, dest.next, source.next );
}
template<typename...Types>
template<typename VariantUnion>
inline void bit::stl::variant<Types...>
::runtime_assign_impl( std::size_t current,
VariantUnion& dest,
const VariantUnion& source,
std::enable_if_t<!detail::variant_union_has_next<std::decay_t<VariantUnion>>::value>* )
{
dest.current = source.current;
}
//----------------------------------------------------------------------------
template<typename...Types>
template<std::size_t I, typename T>
inline void bit::stl::variant<Types...>::static_assign( T&& value )
{
static_assign( in_place_index<I>, base_type::m_union, std::forward<T>(value) );
}
template<typename...Types>
template<typename VariantUnion, typename T>
inline void bit::stl::variant<Types...>
::static_assign( in_place_index_t<std::size_t(-1)>, VariantUnion&, T&& )
{
// avoid instantiation issues
}
template<typename...Types>
template<std::size_t I, typename VariantUnion, typename T>
inline void bit::stl::variant<Types...>
::static_assign( in_place_index_t<I>, VariantUnion& dest, T&& value )
{
static_assign( in_place_index<I-1>, dest.next, std::forward<T>(value) );
}
template<typename...Types>
template<typename VariantUnion, typename T>
inline void bit::stl::variant<Types...>
::static_assign( in_place_index_t<0>, VariantUnion& dest, T&& value )
{
dest.current = std::forward<T>(value);
}
//----------------------------------------------------------------------------
template<typename...Types>
template<typename VariantUnion>
inline void bit::stl::variant<Types...>
::runtime_emplace( std::size_t index, VariantUnion&& source )
{
base_type::destruct();
runtime_emplace_impl( index, base_type::m_union, std::forward<VariantUnion>(source) );
base_type::m_index = index;
}
template<typename...Types>
template<typename VariantUnion>
inline void bit::stl::variant<Types...>
::runtime_emplace_impl( std::size_t current,
VariantUnion& dest,
VariantUnion&& source,
std::enable_if_t<detail::variant_union_has_next<std::decay_t<VariantUnion>>::value>* )
{
using type = decltype(dest.current);
if( current == 0 ) {
new (&dest.current) type( std::move(source.current) );
return;
}
runtime_emplace_impl( current-1, dest.next, std::move(source.next) );
}
template<typename...Types>
template<typename VariantUnion>
inline void bit::stl::variant<Types...>
::runtime_emplace_impl( std::size_t current,
VariantUnion& dest,
VariantUnion&& source,
std::enable_if_t<!detail::variant_union_has_next<std::decay_t<VariantUnion>>::value>* )
{
using type = decltype(dest.current);
new (&dest.current) type( std::move(source.current) );
}
template<typename...Types>
template<typename VariantUnion>
inline void bit::stl::variant<Types...>
::runtime_emplace_impl( std::size_t current,
VariantUnion& dest,
const VariantUnion& source,
std::enable_if_t<detail::variant_union_has_next<std::decay_t<VariantUnion>>::value>* )
{
using type = decltype(dest.current);
if( current == 0 ) {
new (&dest.current) type( source.current );
return;
}
runtime_emplace_impl( current-1, dest.next, source.next );
}
template<typename...Types>
template<typename VariantUnion>
inline void bit::stl::variant<Types...>
::runtime_emplace_impl( std::size_t current,
VariantUnion& dest,
const VariantUnion& source,
std::enable_if_t<!detail::variant_union_has_next<std::decay_t<VariantUnion>>::value>* )
{
using type = decltype(dest.current);
new (&dest.current) type( source.current );
}
//----------------------------------------------------------------------------
template<typename...Types>
template<std::size_t I, std::size_t N, typename...Ts, typename...Args,typename>
inline bit::stl::variant_alternative_t<I, bit::stl::variant<Types...>>&
bit::stl::variant<Types...>::static_emplace( in_place_index_t<N>,
union_type<Ts...>& storage,
Args&&...args )
{
return static_emplace<I>( in_place_index<N-1>,
storage.next, std::forward<Args>(args)... );
}
template<typename...Types>
template<std::size_t I, typename...Ts, typename...Args>
inline bit::stl::variant_alternative_t<I, bit::stl::variant<Types...>>&
bit::stl::variant<Types...>::static_emplace( in_place_index_t<0>,
union_type<Ts...>& storage,
Args&&...args )
{
using type = variant_alternative_t<I, variant>;
new (&storage.current) type( std::forward<Args>(args)... );
return storage.current;
}
//-----------------------------------------------------------------------------
// Comparisons
//-----------------------------------------------------------------------------
namespace bit { namespace stl { namespace detail {
template<std::size_t N, typename...Types, typename Compare>
inline constexpr bool variant_compare( in_place_index_t<N>,
const variant<Types...>& lhs,
const variant<Types...>& rhs,
Compare&& compare )
noexcept
{
if( N == lhs.index() ) {
return std::forward<Compare>(compare)( get<N>(lhs), get<N>(rhs) );
}
return variant_compare( in_place_index<(N-1)>, lhs, rhs, std::forward<Compare>(compare) );
}
template<typename...Types, typename Compare>
inline constexpr bool variant_compare( in_place_index_t<0>,
const variant<Types...>& lhs,
const variant<Types...>& rhs,
Compare&& compare )
noexcept
{
return std::forward<Compare>(compare)( get<0>(lhs), get<0>(rhs) );
}
} } } // namespace bit::stl::detail
template<typename...Types>
inline constexpr bool bit::stl::operator==( const variant<Types...>& lhs,
const variant<Types...>& rhs )
noexcept
{
if( lhs.index() != rhs.index() ) return false;
if( lhs.valueless_by_exception() ) return true;
auto tag = in_place_index<(sizeof...(Types)-1)>;
return detail::variant_compare( tag, lhs, rhs, std::equal_to<>{});
}
template<typename...Types>
inline constexpr bool bit::stl::operator!=( const variant<Types...>& lhs,
const variant<Types...>& rhs )
noexcept
{
if( lhs.index() != rhs.index() ) return true;
if( lhs.valueless_by_exception() ) return false;
auto tag = in_place_index<(sizeof...(Types)-1)>;
return detail::variant_compare( tag, lhs, rhs, std::not_equal_to<>{});
}
template<typename...Types>
inline constexpr bool bit::stl::operator<( const variant<Types...>& lhs,
const variant<Types...>& rhs )
noexcept
{
if( rhs.valueless_by_exception() ) return false;
if( lhs.valueless_by_exception() ) return true;
if( lhs.index() < rhs.index() ) return true;
if( lhs.index() > rhs.index() ) return false;
auto tag = in_place_index<(sizeof...(Types)-1)>;
return detail::variant_compare( tag, lhs, rhs, std::less<>{});
}
template<typename...Types>
inline constexpr bool bit::stl::operator>( const variant<Types...>& lhs,
const variant<Types...>& rhs )
noexcept
{
if( lhs.valueless_by_exception() ) return false;
if( rhs.valueless_by_exception() ) return true;
if( lhs.index() > rhs.index() ) return true;
if( lhs.index() < rhs.index() ) return false;
auto tag = in_place_index<(sizeof...(Types)-1)>;
return detail::variant_compare( tag, lhs, rhs, std::greater<>{});
}
template<typename...Types>
inline constexpr bool bit::stl::operator<=( const variant<Types...>& lhs,
const variant<Types...>& rhs )
noexcept
{
if( lhs.valueless_by_exception() ) return true;
if( rhs.valueless_by_exception() ) return false;
if( lhs.index() < rhs.index() ) return true;
if( lhs.index() > rhs.index() ) return false;
auto tag = in_place_index<(sizeof...(Types)-1)>;
return detail::variant_compare( tag, lhs, rhs, std::less_equal<>{});
}
template<typename...Types>
inline constexpr bool bit::stl::operator>=( const variant<Types...>& lhs,
const variant<Types...>& rhs )
noexcept
{
if( rhs.valueless_by_exception() ) return true;
if( lhs.valueless_by_exception() ) return false;
if( lhs.index() > rhs.index() ) return true;
if( lhs.index() < rhs.index() ) return false;
auto tag = in_place_index<(sizeof...(Types)-1)>;
return detail::variant_compare( tag, lhs, rhs, std::greater_equal<>{});
}
//=============================================================================
// 23.7.5 : value access
//=============================================================================
template<typename T, typename...Types>
constexpr bool bit::stl::holds_alternative( const variant<Types...>& v )
noexcept
{
return detail::index_from<T,Types...>::value == v.index();
}
//----------------------------------------------------------------------------
template<std::size_t I, typename...Types>
constexpr bit::stl::variant_alternative_t<I, bit::stl::variant<Types...>>&
bit::stl::get( variant<Types...>& v )
{
static_assert( (I < sizeof...(Types)), "I is not a valid index into the variant" );
if( v.index() != I ) throw bad_variant_access{};
return v.get( in_place_index<I> );
}
template<std::size_t I, typename...Types>
constexpr bit::stl::variant_alternative_t<I, bit::stl::variant<Types...>>&&
bit::stl::get( variant<Types...>&& v )
{
static_assert( (I < sizeof...(Types)), "I is not a valid index into the variant" );
return std::move( get<I>( v ) );
}
template<std::size_t I, typename...Types>
constexpr const bit::stl::variant_alternative_t<I, bit::stl::variant<Types...>>&
bit::stl::get( const variant<Types...>& v )
{
static_assert( (I < sizeof...(Types)), "I is not a valid index into the variant" );
if( v.index() != I ) throw bad_variant_access{};
return v.get( in_place_index<I> );
}
template<std::size_t I, typename...Types>
constexpr const bit::stl::variant_alternative_t<I, bit::stl::variant<Types...>>&&
bit::stl::get( const variant<Types...>&& v )
{
static_assert( (I < sizeof...(Types)), "I is not a valid index into the variant" );
return std::move( get<I>( v ) );
}
//----------------------------------------------------------------------------
template<typename T, typename...Types>
constexpr T& bit::stl::get( variant<Types...>& v )
{
return get<detail::index_from<T,Types...>::value>(v);
}
template<typename T, typename...Types>
constexpr T&& bit::stl::get( variant<Types...>&& v )
{
return get<detail::index_from<T,Types...>::value>(v);
}
template<typename T, typename...Types>
constexpr const T& bit::stl::get( const variant<Types...>& v )
{
return get<detail::index_from<T,Types...>::value>(v);
}
template<typename T, typename...Types>
constexpr const T&& bit::stl::get( const variant<Types...>&& v )
{
return get<detail::index_from<T,Types...>::value>(v);
}
//----------------------------------------------------------------------------
template<std::size_t I, typename...Types>
constexpr std::add_pointer_t<bit::stl::variant_alternative_t<I, bit::stl::variant<Types...>>>
bit::stl::get_if( variant<Types...>* pv )
noexcept
{
static_assert( (I < sizeof...(Types)), "I is not a valid index into the variant" );
if( !pv ) return nullptr;
if( I != pv->index() ) return nullptr;
return &get<I>(*pv);
}
template<std::size_t I, typename...Types>
constexpr std::add_pointer_t<const bit::stl::variant_alternative_t<I, bit::stl::variant<Types...>>>
bit::stl::get_if( const variant<Types...>* pv )
noexcept
{
static_assert( (I < sizeof...(Types)), "I is not a valid index into the variant" );
if( !pv ) return nullptr;
if( I != pv->index() ) return nullptr;
return &get<I>(*pv);
}
template<typename T, typename...Types>
constexpr std::add_pointer_t<T> bit::stl::get_if( variant<Types...>* pv )
noexcept
{
return get_if<detail::index_from<T,Types...>::value>( pv );
}
template<typename T, typename...Types>
constexpr std::add_pointer_t<const T> bit::stl::get_if( const variant<Types...>* pv )
noexcept
{
return get_if<detail::index_from<T,Types...>::value>( pv );
}
//-----------------------------------------------------------------------------
namespace bit { namespace stl { namespace detail {
template<std::size_t N, typename...Types>
inline constexpr hash_t hash_variant_impl( in_place_index_t<N>,
const variant<Types...>& val )
{
if( val.index() == N ) {
return hash_value( get<N>( val ) );
}
return hash_variant_impl( in_place_index<(N-1)>, val );
}
template<typename...Types>
inline constexpr hash_t hash_variant_impl( in_place_index_t<0>,
const variant<Types...>& val )
{
// Must be 0 by here; what else can it be?
assert( val.index() == 0 );
return hash_value( get<0>( val ) );
}
} } } // namespace bit::stl::detail
template<typename...Types>
inline constexpr bit::stl::hash_t bit::stl::hash_value( const variant<Types...>& val )
noexcept
{
if( val.valueless_by_exception() ) return static_cast<hash_t>(0xDEADBEEF);
// hash from last value to first value
return detail::hash_variant_impl( in_place_index<(sizeof...(Types)-1)>, val );
}
#endif /* BIT_STL_UTILITIES_DETAIL_VARIANT_INL */
| 33.386686 | 113 | 0.594841 | bitwizeshift |
d70241a6ac557efbbea202db98443b9d91310893 | 2,086 | cpp | C++ | source/lab2/vector.cpp | Jovvik/methopt-lab-1 | 2c3acaf653c7214a925ed1292b9d1d30a33d2737 | [
"Unlicense"
] | null | null | null | source/lab2/vector.cpp | Jovvik/methopt-lab-1 | 2c3acaf653c7214a925ed1292b9d1d30a33d2737 | [
"Unlicense"
] | null | null | null | source/lab2/vector.cpp | Jovvik/methopt-lab-1 | 2c3acaf653c7214a925ed1292b9d1d30a33d2737 | [
"Unlicense"
] | null | null | null | #include "lab2/vector.h"
#include <cmath>
#include <iterator>
#include <utility>
using namespace lab2;
Vector::Vector(std::istream& is) {
double el;
while (is >> el) {
data.push_back(el);
}
if (size() == 0) {
throw "Vector is empty";
}
}
Vector::Vector(const std::vector<double>& data_) : data(data_) {
if (size() == 0) {
throw "Vector is empty";
}
}
Vector::Vector(std::size_t size,
const std::function<double(std::size_t)>& generator) {
data.reserve(size);
for (std::size_t i = 0; i < size; i++) {
data.push_back(generator(i));
}
}
std::size_t Vector::size() const { return data.size(); }
double Vector::operator[](std::size_t idx) const { return data[idx]; }
double Vector::norm() const { return std::sqrt((*this) * (*this)); }
Vector Vector::operator+(Vector other) const {
if (size() != other.size()) {
throw "Size mismatch";
}
return Vector(size(), [this, &other](std::size_t i) {
return (*this)[i] + other[i];
});
}
Vector Vector::operator-(Vector other) const {
if (size() != other.size()) {
throw "Size mismatch";
}
return Vector(size(), [this, &other](std::size_t i) {
return (*this)[i] - other[i];
});
}
Vector Vector::operator*(double val) const {
std::vector<double> tmp;
return Vector(size(), [this, val](std::size_t i) {
return (*this)[i] * val;
});
}
double Vector::operator*(const Vector& other) const {
if (size() != other.size()) {
throw "Size mismatch";
}
double res = 0;
for (std::size_t i = 0; i < size(); i++) {
res += (*this)[i] * other[i];
}
return res;
}
bool Vector::operator==(const Vector& other) const {
return data == other.data;
}
namespace lab2 {
std::ostream& operator<<(std::ostream& os, const Vector& v) {
for (std::size_t i = 0; i < v.size(); i++) {
os << v[i];
if (i != v.size() - 1) {
os << " ";
}
}
return os;
}
} // namespace lab2
| 23.177778 | 70 | 0.535475 | Jovvik |
d703174c6f95b6a281dd721a3be8b88e1c49c540 | 5,970 | cpp | C++ | specialized_intra_process_comm/src/intra_process_manager.cpp | tier4/specialized_intra_process_comm | f213a6d4e29b8cde0b74abdedf684de7ed8ebff9 | [
"Apache-2.0"
] | 1 | 2021-10-08T05:38:23.000Z | 2021-10-08T05:38:23.000Z | specialized_intra_process_comm/src/intra_process_manager.cpp | tier4/specialized_intra_process_comm | f213a6d4e29b8cde0b74abdedf684de7ed8ebff9 | [
"Apache-2.0"
] | null | null | null | specialized_intra_process_comm/src/intra_process_manager.cpp | tier4/specialized_intra_process_comm | f213a6d4e29b8cde0b74abdedf684de7ed8ebff9 | [
"Apache-2.0"
] | null | null | null | // Copyright 2021 Research Institute of Systems Planning, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include <unordered_map>
#include <memory>
#include <utility>
#include "specialized_intra_process_comm/intra_process_manager.hpp"
namespace feature
{
Counter::Counter()
: count_(0)
{
}
uint64_t Counter::get_incremented_count()
{
std::lock_guard<std::mutex> lock(mutex_);
count_++;
return count_;
}
static std::atomic<uint64_t> _next_unique_id{1};
IntraProcessManager::~IntraProcessManager() {}
uint64_t IntraProcessManager::add_publisher(PublisherBase::SharedPtr publisher)
{
std::unique_lock<std::shared_timed_mutex> lock(mutex_);
auto id = IntraProcessManager::get_next_unique_id();
publishers_[id].publisher = publisher;
publishers_[id].topic_name = publisher->get_topic_name();
publishers_[id].qos = publisher->get_actual_qos().get_rmw_qos_profile();
// Initialize the subscriptions storage for this publisher.
pub_to_subs_[id] = SplittedSubscriptions();
auto topic_name = publishers_[id].topic_name;
auto has_key = sequences_.find(topic_name) != sequences_.end();
if (!has_key) {
sequences_[topic_name] = std::make_shared<feature::Counter>();
}
// create an entry for the publisher id and populate with already existing
// subscriptions
for (auto & pair : subscriptions_) {
if (can_communicate(publishers_[id], pair.second)) {
insert_sub_id_for_pub(pair.first, id, pair.second.use_take_shared_method);
}
}
return id;
}
void IntraProcessManager::insert_sub_id_for_pub(
uint64_t sub_id, uint64_t pub_id, bool use_take_shared_method)
{
if (use_take_shared_method) {
pub_to_subs_[pub_id].take_shared_subscriptions.push_back(sub_id);
} else {
pub_to_subs_[pub_id].take_ownership_subscriptions.push_back(sub_id);
}
}
uint64_t IntraProcessManager::add_subscription(SubscriptionBase::SharedPtr subscription)
{
std::unique_lock<std::shared_timed_mutex> lock(mutex_);
auto id = IntraProcessManager::get_next_unique_id();
subscriptions_[id].subscription = subscription;
subscriptions_[id].topic_name = subscription->get_topic_name();
subscriptions_[id].qos = subscription->get_actual_qos().get_rmw_qos_profile();
subscriptions_[id].use_take_shared_method = subscription->use_take_shared_method();
// adds the subscription id to all the matchable publishers
for (auto & pair : publishers_) {
if (can_communicate(pair.second, subscriptions_[id])) {
insert_sub_id_for_pub(id, pair.first, subscriptions_[id].use_take_shared_method);
}
}
return id;
}
void IntraProcessManager::remove_subscription(uint64_t intra_process_subscription_id)
{
std::unique_lock<std::shared_timed_mutex> lock(mutex_);
subscriptions_.erase(intra_process_subscription_id);
for (auto & pair : pub_to_subs_) {
pair.second.take_shared_subscriptions.erase(
std::remove(
pair.second.take_shared_subscriptions.begin(), pair.second.take_shared_subscriptions.end(),
intra_process_subscription_id),
pair.second.take_shared_subscriptions.end());
pair.second.take_ownership_subscriptions.erase(
std::remove(
pair.second.take_ownership_subscriptions.begin(),
pair.second.take_ownership_subscriptions.end(), intra_process_subscription_id),
pair.second.take_ownership_subscriptions.end());
}
}
void IntraProcessManager::remove_publisher(uint64_t intra_process_publisher_id)
{
std::unique_lock<std::shared_timed_mutex> lock(mutex_);
publishers_.erase(intra_process_publisher_id);
pub_to_subs_.erase(intra_process_publisher_id);
}
uint64_t IntraProcessManager::get_next_unique_id()
{
auto next_id = _next_unique_id.fetch_add(1, std::memory_order_relaxed);
// Check for rollover (we started at 1).
if (0 == next_id) {
// This puts a technical limit on the number of times you can add a publisher or subscriber.
// But even if you could add (and remove) them at 1 kHz (very optimistic rate)
// it would still be a very long time before you could exhaust the pool of id's:
// 2^64 / 1000 times per sec / 60 sec / 60 min / 24 hours / 365 days = 584,942,417 years
// So around 585 million years. Even at 1 GHz, it would take 585 years.
// I think it's safe to avoid trying to handle overflow.
// If we roll over then it's most likely a bug.
// *INDENT-OFF* (prevent uncrustify from making unnecessary indents here)
throw std::overflow_error(
"exhausted the unique id's for publishers and subscribers in this process "
"(congratulations your computer is either extremely fast or extremely old)");
// *INDENT-ON*
}
return next_id;
}
bool IntraProcessManager::can_communicate(PublisherInfo pub_info, SubscriptionInfo sub_info) const
{
// publisher and subscription must be on the same topic
if (strcmp(pub_info.topic_name, sub_info.topic_name) != 0) {
return false;
}
// TODO(alsora): the following checks for qos compatibility should be provided
// by the RMW a reliable subscription can't be connected with a best effort
// publisher
if (
sub_info.qos.reliability == RMW_QOS_POLICY_RELIABILITY_RELIABLE &&
pub_info.qos.reliability == RMW_QOS_POLICY_RELIABILITY_BEST_EFFORT)
{
return false;
}
// a publisher and a subscription with different durability can't communicate
if (sub_info.qos.durability != pub_info.qos.durability) {
return false;
}
return true;
}
} // namespace feature
| 34.114286 | 99 | 0.747906 | tier4 |
d704ea7ea118fbc72defa9be344e0c570724e4cd | 1,424 | hpp | C++ | Versionen/2021_06_15/rmf_ws/install/rmf_traffic_msgs/include/rmf_traffic_msgs/msg/detail/mirror_update__traits.hpp | flitzmo-hso/flitzmo_agv_control_system | 99e8006920c03afbd93e4c7d38b4efff514c7069 | [
"MIT"
] | null | null | null | Versionen/2021_06_15/rmf_ws/install/rmf_traffic_msgs/include/rmf_traffic_msgs/msg/detail/mirror_update__traits.hpp | flitzmo-hso/flitzmo_agv_control_system | 99e8006920c03afbd93e4c7d38b4efff514c7069 | [
"MIT"
] | null | null | null | Versionen/2021_06_15/rmf_ws/install/rmf_traffic_msgs/include/rmf_traffic_msgs/msg/detail/mirror_update__traits.hpp | flitzmo-hso/flitzmo_agv_control_system | 99e8006920c03afbd93e4c7d38b4efff514c7069 | [
"MIT"
] | 2 | 2021-06-21T07:32:09.000Z | 2021-08-17T03:05:38.000Z | // generated from rosidl_generator_cpp/resource/idl__traits.hpp.em
// with input from rmf_traffic_msgs:msg/MirrorUpdate.idl
// generated code does not contain a copyright notice
#ifndef RMF_TRAFFIC_MSGS__MSG__DETAIL__MIRROR_UPDATE__TRAITS_HPP_
#define RMF_TRAFFIC_MSGS__MSG__DETAIL__MIRROR_UPDATE__TRAITS_HPP_
#include "rmf_traffic_msgs/msg/detail/mirror_update__struct.hpp"
#include <rosidl_runtime_cpp/traits.hpp>
#include <stdint.h>
#include <type_traits>
// Include directives for member types
// Member 'patch'
#include "rmf_traffic_msgs/msg/detail/schedule_patch__traits.hpp"
namespace rosidl_generator_traits
{
template<>
inline const char * data_type<rmf_traffic_msgs::msg::MirrorUpdate>()
{
return "rmf_traffic_msgs::msg::MirrorUpdate";
}
template<>
inline const char * name<rmf_traffic_msgs::msg::MirrorUpdate>()
{
return "rmf_traffic_msgs/msg/MirrorUpdate";
}
template<>
struct has_fixed_size<rmf_traffic_msgs::msg::MirrorUpdate>
: std::integral_constant<bool, has_fixed_size<rmf_traffic_msgs::msg::SchedulePatch>::value> {};
template<>
struct has_bounded_size<rmf_traffic_msgs::msg::MirrorUpdate>
: std::integral_constant<bool, has_bounded_size<rmf_traffic_msgs::msg::SchedulePatch>::value> {};
template<>
struct is_message<rmf_traffic_msgs::msg::MirrorUpdate>
: std::true_type {};
} // namespace rosidl_generator_traits
#endif // RMF_TRAFFIC_MSGS__MSG__DETAIL__MIRROR_UPDATE__TRAITS_HPP_
| 30.297872 | 99 | 0.810393 | flitzmo-hso |
d704f817fe2238749665d71df40f0d148620e5f0 | 2,797 | cpp | C++ | SOURCES/graphics/renderer/renderwire.cpp | IsraelyFlightSimulator/Negev-Storm | 86de63e195577339f6e4a94198bedd31833a8be8 | [
"Unlicense"
] | 1 | 2021-02-19T06:06:31.000Z | 2021-02-19T06:06:31.000Z | src/graphics/renderer/renderwire.cpp | markbb1957/FFalconSource | 07b12e2c41a93fa3a95b912a2433a8056de5bc4d | [
"BSD-2-Clause"
] | null | null | null | src/graphics/renderer/renderwire.cpp | markbb1957/FFalconSource | 07b12e2c41a93fa3a95b912a2433a8056de5bc4d | [
"BSD-2-Clause"
] | 2 | 2019-08-20T13:35:13.000Z | 2021-04-24T07:32:04.000Z | /***************************************************************************\
RenderWire.h
Scott Randolph
May 5, 1998
This sub class draws an out the window view in wire frame mode.
\***************************************************************************/
#include "TOD.h"
#include "Tpost.h"
#include "RViewPnt.h"
#include "RenderWire.h"
/***************************************************************************\
Setup the rendering context for this view
\***************************************************************************/
void RenderWire::Setup( ImageBuffer *imageBuffer, RViewPoint *vp )
{
// Call our base classes setup routine
RenderOTW::Setup( imageBuffer, vp );
// Set our drawing properties
// SetSmoothShadingMode( FALSE );
SetObjectTextureState( TRUE ); // Start with object textures ON
SetHazeMode( TRUE ); // Start with hazing turned ON
// Use a black terrain filler
haze_ground_color.r = haze_ground_color.g = haze_ground_color.b = 0.0f;
earth_end_color.r = earth_end_color.g = earth_end_color.b = 0.0f;
// Use a midnight blue sky
sky_color.r = 0.0f;
sky_color.g = 0.0f;
sky_color.b = 0.125f;
haze_sky_color.r = 0.0f;
haze_sky_color.g = 0.0f;
haze_sky_color.b = 0.25f;
// Use only moderate ambient lighting on the objects
lightAmbient = 0.8f;
lightDiffuse = 0.0f;
// Update our colors to account for our changes to the default settings
TimeUpdateCallback( this );
}
/***************************************************************************\
Do end of frame housekeeping
\***************************************************************************/
void RenderWire::StartFrame( void ) {
RenderOTW::StartDraw();
TheColorBank.SetColorMode( ColorBankClass::UnlitMode );
}
#define BLEND_MIN 0.25f
#define BLEND_MAX 0.95f
/***************************************************************************\
Compute the color and texture blend value for a single terrain vertex.
\***************************************************************************/
//void RenderWire::ComputeVertexColor( TerrainVertex *vert, Tpost *post, float distance )
void RenderWire::ComputeVertexColor( TerrainVertex *vert, Tpost *, float distance )
{
// float alpha;
// Set all verts to black
vert->r = 0.0f;
vert->g = 0.0f;
vert->b = 0.0f;
// Blend out the textures in the distance
/* if ( hazed && (distance > blend_start)) {
alpha = (distance - blend_start) / blend_depth;
if (alpha < BLEND_MIN) alpha = BLEND_MIN;
if (alpha > BLEND_MAX) alpha = BLEND_MAX;
vert->a = 1.0f - alpha;
vert->RenderingStateHandle = state_mid;
} else {
vert->a = BLEND_MAX;
if (distance < PERSPECTIVE_RANGE) {
vert->RenderingStateHandle = state_fore;
} else {
vert->RenderingStateHandle = state_near;
}
}*/
}
| 29.755319 | 89 | 0.54916 | IsraelyFlightSimulator |
d7058d32ef9f800fcd6a1f6ca7a3aab13d23b874 | 3,293 | cpp | C++ | wrappers/src/object-store/tests/parser.cpp | datasprings/Realm | 00cbfc26268d2a8559913361e0cd067b1d275df5 | [
"Apache-2.0"
] | 3 | 2016-10-13T17:17:05.000Z | 2017-01-13T20:00:39.000Z | src/object-store/tests/parser.cpp | Osedea/realm-js | b06ee441bd7c2fced07e8e496f265a7578a06d07 | [
"Apache-2.0"
] | null | null | null | src/object-store/tests/parser.cpp | Osedea/realm-js | b06ee441bd7c2fced07e8e496f265a7578a06d07 | [
"Apache-2.0"
] | null | null | null | #include "catch.hpp"
#include "parser/parser.hpp"
#include <vector>
#include <string>
static std::vector<std::string> valid_queries = {
// true/false predicates
"truepredicate",
"falsepredicate",
" TRUEPREDICATE ",
" FALSEPREDICATE ",
"truepredicates = falsepredicates", // keypaths
// characters/strings
"\"\" = ''",
"'azAZ09/ :()[]{}<>,.^@-+=*&~`' = '\\\" \\' \\\\ \\/ \\b \\f \\n \\r \\t \\0'",
"\"azAZ09/\" = \"\\\" \\' \\\\ \\/ \\b \\f \\n \\r \\t \\0\"",
"'\\uffFf' = '\\u0020'",
"'\\u01111' = 'asdf\\u0111asdf'",
// expressions (numbers, bools, keypaths, arguments)
"-1 = 12",
"0 = 001",
"0x0 = -0X398235fcAb",
"10. = -.034",
"10.0 = 5.034",
"true = false",
"truelove = false",
"true = falsey",
"nullified = null",
"_ = a",
"_a = _.aZ",
"a09._br.z = __-__.Z-9",
"$0 = $19",
"$0=$0",
// operators
"0=0",
"0 = 0",
"0 =[c] 0",
"0!=0",
"0 != 0",
"0==0",
"0 == 0",
"0==[c]0",
"0 == [c] 0",
"0>0",
"0 > 0",
"0>=0",
"0 >= 0",
"0<0",
"0 < 0",
"0<=0",
"0 <= 0",
"0 contains 0",
"a CONTAINS[c] b",
"a contains [c] b",
"'a'CONTAINS[c]b",
"0 BeGiNsWiTh 0",
"0 ENDSWITH 0",
"contains contains 'contains'",
"beginswith beginswith 'beginswith'",
"endswith endswith 'endswith'",
"NOT NOT != 'NOT'",
"AND == 'AND' AND OR == 'OR'",
// FIXME - bug
// "truepredicate == 'falsepredicate' && truepredicate",
// atoms/groups
"(0=0)",
"( 0=0 )",
"((0=0))",
"!0=0",
"! 0=0",
"!(0=0)",
"! (0=0)",
"NOT0=0", // keypath NOT0
"NOT0.a=0", // keypath NOT0
"NOT0a.b=0", // keypath NOT0a
"not-1=1",
"not 0=0",
"NOT(0=0)",
"not (0=0)",
"NOT (!0=0)",
// compound
"a==a && a==a",
"a==a || a==a",
"a==a&&a==a||a=a",
"a==a and a==a",
"a==a OR a==a",
"and=='AND'&&'or'=='||'",
"and == or && ORE > GRAND",
"a=1AND NOTb=2",
};
static std::vector<std::string> invalid_queries = {
"predicate",
"'\\a' = ''", // invalid escape
// invalid unicode
"'\\u0' = ''",
// invalid strings
"\"' = ''",
"\" = ''",
"' = ''",
// expressions
"03a = 1",
"1..0 = 1",
"1.0. = 1",
"1-0 = 1",
"0x = 1",
"- = a",
"a..b = a",
"a$a = a",
"{} = $0",
"$-1 = $0",
"$a = $0",
"$ = $",
// operators
"0===>0",
"0 <> 0",
"0 contains1",
"a contains_something",
"endswith 0",
// atoms/groups
"0=0)",
"(0=0",
"(0=0))",
"! =0",
"NOTNOT(0=0)",
"not.a=0",
"(!!0=0)",
"0=0 !",
// compound
"a==a & a==a",
"a==a | a==a",
"a==a &| a==a",
"a==a && OR a==a",
"a==aORa==a",
"a==a ORa==a",
"a==a AND==a",
"a==a ANDa==a",
"a=1ANDNOT b=2",
"truepredicate &&",
"truepredicate & truepredicate",
};
TEST_CASE("valid queries") {
for (auto& query : valid_queries) {
INFO("query: " << query);
CHECK_NOTHROW(realm::parser::parse(query));
}
}
TEST_CASE("invalid queries") {
for (auto& query : invalid_queries) {
INFO("query: " << query);
CHECK_THROWS(realm::parser::parse(query));
}
}
| 19.485207 | 83 | 0.412694 | datasprings |
d705b217a7d5c5f7325bd17f895f39faf6b7f9e4 | 10,739 | cpp | C++ | CODE/Src/HOG.cpp | nrupatunga/Pedestrain-Detection-using-Histogram-of-Oriented-Gradients | c8b4fd153711555a857afde2d0888ed2df01aae9 | [
"MIT"
] | 4 | 2017-05-21T13:14:05.000Z | 2020-04-27T01:51:34.000Z | CODE/Src/HOG.cpp | nrupatunga/Pedestrain-Detection-using-Histogram-of-Oriented-Gradients | c8b4fd153711555a857afde2d0888ed2df01aae9 | [
"MIT"
] | null | null | null | CODE/Src/HOG.cpp | nrupatunga/Pedestrain-Detection-using-Histogram-of-Oriented-Gradients | c8b4fd153711555a857afde2d0888ed2df01aae9 | [
"MIT"
] | 1 | 2019-05-16T02:04:02.000Z | 2019-05-16T02:04:02.000Z | /* The MIT License (MIT)
Copyright (c) [2015] [Nrupatunga]
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. */
#include "HOG.hpp"
HOG::HOG(String &strPosSamples, String &strNegSamples, Size &sizeWin = Size(64, 128))
{
glob(strPosSamples, vecStrPosSamples);
glob(strNegSamples, vecStrNegSamples);
s32NumPosSamples = vecStrPosSamples.size();
s32NumNegSamples = vecStrNegSamples.size();
if (s32NumPosSamples <= 0 || s32NumNegSamples <= 0){
cout << "Invalid Training Sample Path/ Please check if there are any training samples in the given path" << endl;
return;
}
objHog.winSize = sizeWin;
s32NumOfSamples = s32NumPosSamples + s32NumNegSamples;
return;
}
HOG::enumHOGError HOG::getFeatures(String &strFeatureFileName, HOG::enumSVMLib eSVMLib)
{
enumHOGError eHOGError = HOG_NO_ERROR;
Mat sMatInImage;
if (eSVMLib != SVM_LIGHT && eSVMLib != SVM_LIBSVM){
cout << " Invalid SVM library specified";
eSVMLib = SVM_LIBSVM;
}
if (s32NumOfSamples <= 0) {
cout << " ------------------------------------------------------------" << endl;
cout << " Please provide samples to train" << endl << " Refer to the function:: HOG(String &strPosSamples, String &strNegSamples, Size &sizeWin)" << endl;
cout << " ------------------------------------------------------------" << endl;
return HOG_INVALID_ARGUMENTS;
}
ofstream outFeatureFile;
outFeatureFile.open(strFeatureFileName, std::ofstream::trunc);
if (!(outFeatureFile.good() && outFeatureFile.is_open())) {
cout << "File " << strFeatureFileName << " failed to open. Please check the path" << endl;
return HOG_INVALID_ARGUMENTS;
}
#if WRITE_FILE_NAMES
ofstream outFileNames;
outFileNames.open("filenames.txt", std::ofstream::trunc);
#endif
// Remove following line for libsvm which does not support comment
if (eSVMLib == SVM_LIGHT){
outFeatureFile << "# Use this file to train, e.g. SVMlight by issuing $ svm_learn -i 1 -a weights.txt " << strFeatureFileName << endl;
}
cout << " ------------------------------------------------------------" << endl;
cout << " This could take a while, based on the number of training samples " << endl;
cout << " ------------------------------------------------------------" << endl;
cout << " Calculating HOG Features ... " << endl;
vector<float> vecFeature;
for (unsigned long i = 0; i < s32NumOfSamples; i++){
int s32Progress = (i * 100 / s32NumOfSamples);
const String strCurrentFile = (i < s32NumPosSamples) ? vecStrPosSamples.at(i) : vecStrNegSamples.at(i - s32NumPosSamples);
sMatInImage = imread(strCurrentFile);
#if WRITE_FILE_NAMES
outFileNames << strCurrentFile << endl;
#endif
if (sMatInImage.empty()){
cout << "Cannot open file " << strCurrentFile << " Please check the format of the image file" << endl;
break;
}
calculateFeature(sMatInImage, vecFeature, objHog);
Mat sMatHogVis = get_hogdescriptor_visu(sMatInImage, vecFeature, objHog.winSize);
if (vecFeature.empty()){
break;
}
#if 1
outFeatureFile << ((i < s32NumPosSamples) ? "+1" : "-1");
for (int j = 0; j < vecFeature.size(); j++){
int s32Count = j + 1;
outFeatureFile << " " << s32Count << ":" << vecFeature.at(j) << " ";
}
#else
for (int j = 0; j < vecFeature.size(); j++){
int s32Count = j + 1;
outFeatureFile << " " << vecFeature.at(j) << " ";
}
#endif
outFeatureFile << endl;
cout << " Progress :: " << s32Progress << "%\r";
cout.flush();
}
cout << " Progress :: " << "DONE.." << endl;
outFeatureFile.close();
#if WRITE_FILE_NAMES
outFileNames.close();
#endif
sMatInImage.release();
return eHOGError;
}
void HOG::setParameters(Size &sizeWinStride, Size &sizeTrainPadding)
{
if (sizeWinStride.width > 0 && sizeWinStride.height > 0)
winStride = sizeWinStride;
else
cout << "Invalid Window Stride " << endl;
if (sizeTrainPadding.width > 0 && sizeTrainPadding.height > 0)
trainingPadding = sizeTrainPadding;
else
cout << "Invalid Training padding " << endl;
}
void HOG::calculateFeature(const Mat &sMatInput, vector<float> &vecDescriptor, HOGDescriptor &objHog)
{
Size hogWinSize = objHog.winSize;
if (sMatInput.cols != hogWinSize.width || sMatInput.rows != hogWinSize.height){
vecDescriptor.clear();
cout << " ------------------------------------------------------------" << endl;
cout << "Input image dimensions " << sMatInput.cols << "x" << sMatInput.rows << \
" do not match with HOG window size " << hogWinSize.width << "x" << hogWinSize.height << endl;
cout << " ------------------------------------------------------------" << endl;
return;
}
objHog.compute(sMatInput, vecDescriptor, winStride, trainingPadding);
return;
}
//Source code from http://www.juergenwiki.de/work/wiki/doku.php?id=public:hog_descriptor_computation_and_visualization
Mat HOG::get_hogdescriptor_visu(const Mat& color_origImg, vector<float>& descriptorValues, const Size & size)
{
const int DIMX = size.width;
const int DIMY = size.height;
float zoomFac = 3;
Mat visu;
resize(color_origImg, visu, Size((int)(color_origImg.cols*zoomFac), (int)(color_origImg.rows*zoomFac)));
int cellSize = 8;
int gradientBinSize = 9;
float radRangeForOneBin = (float)(CV_PI / (float)gradientBinSize); // dividing 180 into 9 bins, how large (in rad) is one bin?
// prepare data structure: 9 orientation / gradient strenghts for each cell
int cells_in_x_dir = DIMX / cellSize;
int cells_in_y_dir = DIMY / cellSize;
float*** gradientStrengths = new float**[cells_in_y_dir];
int** cellUpdateCounter = new int*[cells_in_y_dir];
for (int y = 0; y<cells_in_y_dir; y++)
{
gradientStrengths[y] = new float*[cells_in_x_dir];
cellUpdateCounter[y] = new int[cells_in_x_dir];
for (int x = 0; x<cells_in_x_dir; x++)
{
gradientStrengths[y][x] = new float[gradientBinSize];
cellUpdateCounter[y][x] = 0;
for (int bin = 0; bin<gradientBinSize; bin++)
gradientStrengths[y][x][bin] = 0.0;
}
}
// nr of blocks = nr of cells - 1
// since there is a new block on each cell (overlapping blocks!) but the last one
int blocks_in_x_dir = cells_in_x_dir - 1;
int blocks_in_y_dir = cells_in_y_dir - 1;
// compute gradient strengths per cell
int descriptorDataIdx = 0;
int cellx = 0;
int celly = 0;
for (int blockx = 0; blockx<blocks_in_x_dir; blockx++)
{
for (int blocky = 0; blocky<blocks_in_y_dir; blocky++)
{
// 4 cells per block ...
for (int cellNr = 0; cellNr<4; cellNr++)
{
// compute corresponding cell nr
cellx = blockx;
celly = blocky;
if (cellNr == 1) celly++;
if (cellNr == 2) cellx++;
if (cellNr == 3)
{
cellx++;
celly++;
}
for (int bin = 0; bin<gradientBinSize; bin++)
{
float gradientStrength = descriptorValues[descriptorDataIdx];
descriptorDataIdx++;
gradientStrengths[celly][cellx][bin] += gradientStrength;
} // for (all bins)
// note: overlapping blocks lead to multiple updates of this sum!
// we therefore keep track how often a cell was updated,
// to compute average gradient strengths
cellUpdateCounter[celly][cellx]++;
} // for (all cells)
} // for (all block x pos)
} // for (all block y pos)
// compute average gradient strengths
for (celly = 0; celly<cells_in_y_dir; celly++)
{
for (cellx = 0; cellx<cells_in_x_dir; cellx++)
{
float NrUpdatesForThisCell = (float)cellUpdateCounter[celly][cellx];
// compute average gradient strenghts for each gradient bin direction
for (int bin = 0; bin<gradientBinSize; bin++)
{
gradientStrengths[celly][cellx][bin] /= NrUpdatesForThisCell;
}
}
}
// draw cells
for (celly = 0; celly<cells_in_y_dir; celly++)
{
for (cellx = 0; cellx<cells_in_x_dir; cellx++)
{
int drawX = cellx * cellSize;
int drawY = celly * cellSize;
int mx = drawX + cellSize / 2;
int my = drawY + cellSize / 2;
rectangle(visu, Point((int)(drawX*zoomFac), (int)(drawY*zoomFac)), Point((int)((drawX + cellSize)*zoomFac), (int)((drawY + cellSize)*zoomFac)), Scalar(100, 100, 100), 1);
// draw in each cell all 9 gradient strengths
for (int bin = 0; bin<gradientBinSize; bin++)
{
float currentGradStrength = gradientStrengths[celly][cellx][bin];
// no line to draw?
if (currentGradStrength == 0)
continue;
float currRad = bin * radRangeForOneBin + radRangeForOneBin / 2;
float dirVecX = cos(currRad);
float dirVecY = sin(currRad);
float maxVecLen = (float)(cellSize / 2.f);
float scale = 2.5; // just a visualization scale, to see the lines better
// compute line coordinates
float x1 = mx - dirVecX * currentGradStrength * maxVecLen * scale;
float y1 = my - dirVecY * currentGradStrength * maxVecLen * scale;
float x2 = mx + dirVecX * currentGradStrength * maxVecLen * scale;
float y2 = my + dirVecY * currentGradStrength * maxVecLen * scale;
// draw gradient visualization
line(visu, Point((int)(x1*zoomFac), (int)(y1*zoomFac)), Point((int)(x2*zoomFac), (int)(y2*zoomFac)), Scalar(0, 255, 0), 1);
} // for (all bins)
} // for (cellx)
} // for (celly)
// don't forget to free memory allocated by helper data structures!
for (int y = 0; y<cells_in_y_dir; y++)
{
for (int x = 0; x<cells_in_x_dir; x++)
{
delete[] gradientStrengths[y][x];
}
delete[] gradientStrengths[y];
delete[] cellUpdateCounter[y];
}
delete[] gradientStrengths;
delete[] cellUpdateCounter;
return visu;
} // get_hogdescriptor_visu | 34.419872 | 174 | 0.642052 | nrupatunga |
d706229cc4d2c6bce330f865844b1d24c679b1d4 | 557 | cpp | C++ | chapter09/ex13_rational/main.cpp | ClassAteam/stroustrup-ppp | ea9e85d4ea9890038eb5611c3bc82734c8706ce7 | [
"MIT"
] | 124 | 2018-06-23T10:16:56.000Z | 2022-03-19T15:16:12.000Z | chapter09/ex13_rational/main.cpp | therootfolder/stroustrup-ppp | b1e936c9a67b9205fdc9712c42496b45200514e2 | [
"MIT"
] | 23 | 2018-02-08T20:57:46.000Z | 2021-10-08T13:58:29.000Z | chapter09/ex13_rational/main.cpp | ClassAteam/stroustrup-ppp | ea9e85d4ea9890038eb5611c3bc82734c8706ce7 | [
"MIT"
] | 65 | 2019-05-27T03:05:56.000Z | 2022-03-26T03:43:05.000Z | #include "rational.h"
#include <iostream>
using std::cout;
using std::cin;
using std::cerr;
int main()
try {
cout << "Enter the integers of two rational numbers:\n";
int a, b, c, d;
cin >> a >> b >> c >> d;
Rational r1{a, b};
Rational r2{c, d};
cout << "Add: " << r1 + r2 << '\n'
<< "Sub: " << r1 - r2 << '\n'
<< "Mul: " << r1 * r2 << '\n'
<< "Div: " << r1 / r2 << '\n';
return 0;
}
catch(std::exception& e) {
cerr << e.what() << '\n';
}
catch(...) {
cerr << "unknown exception" << '\n';
}
| 19.206897 | 60 | 0.452424 | ClassAteam |
d70669f97e158fb120e9984577b26946c5e9734d | 5,552 | cpp | C++ | NaoTHSoccer/Source/Representations/Modeling/GoalModel.cpp | tarsoly/NaoTH | dcd2b67ef6bf9953c81d3e1b26e543b5922b7d52 | [
"ECL-2.0",
"Apache-2.0"
] | 15 | 2015-01-12T10:46:29.000Z | 2022-03-28T05:13:14.000Z | NaoTHSoccer/Source/Representations/Modeling/GoalModel.cpp | tarsoly/NaoTH | dcd2b67ef6bf9953c81d3e1b26e543b5922b7d52 | [
"ECL-2.0",
"Apache-2.0"
] | 2 | 2019-01-20T21:07:50.000Z | 2020-01-22T14:00:28.000Z | NaoTHSoccer/Source/Representations/Modeling/GoalModel.cpp | tarsoly/NaoTH | dcd2b67ef6bf9953c81d3e1b26e543b5922b7d52 | [
"ECL-2.0",
"Apache-2.0"
] | 5 | 2018-02-07T18:18:10.000Z | 2019-10-15T17:01:41.000Z | /**
* @file GoalModel.cpp
*
* @author <a href="mailto:borisov@informatik.hu-berlin.de">Alexander Borisov</a>
* @author <a href="mailto:xu@informatik.hu-berlin.de">Xu, Yuan</a>
* @author <a href="mailto:scheunem@informatik.hu-berlin.de">Marcus Scheunemann</a>
* @author <a href="mailto:mellmann@informatik.hu-berlin.de">Heinrich Mellmann</
* Implementation of class GoalModel
*
*/
#include "GoalModel.h"
GoalModel::Goal GoalModel::getOwnGoal(const CompassDirection& compassDirection, const FieldInfo& fieldInfo) const
{
return getOwnGoal(compassDirection.angle, fieldInfo);
}
GoalModel::Goal GoalModel::getOwnGoal(double angle, const FieldInfo& fieldInfo) const
{
//TODO check this decision, compare with robotPose.rotation
//18.02.2012
//if (fabs(compassDirection.angle) > Math::pi_2 && fabs(goal.calculateCenter().angle()) < Math::pi_2) {
if(fabs(angle + goal.calculateCenter().angle()) > Math::pi_2){
return goal;
} else {
return calculateAnotherGoal(goal, fieldInfo.xLength);
}
}//end getOwnGoal
GoalModel::Goal GoalModel::getOppGoal(const CompassDirection& compassDirection, const FieldInfo& fieldInfo) const
{
return getOppGoal(compassDirection.angle, fieldInfo);
}
GoalModel::Goal GoalModel::getOppGoal(double angle, const FieldInfo& fieldInfo) const
{
//TODO check this decision, compare with robotPose.rotation
//18.02.2012
//if(fabs(goal.calculateCenter().rotate(compassDirection.angle).angle()) < Math::pi_2)
if(fabs(Math::normalize(angle + goal.calculateCenter().angle())) < Math::pi_2)
{
return goal;
} else {
return calculateAnotherGoal(goal, fieldInfo.xLength);
}
}//end getOppGoal
/*
const GoalModel::Goal& GoalModel::getTeamGoal(naoth::GameData::TeamColor teamColor) const
{
switch (teamColor)
{
case GameData::red:
return yellowGoal;
break;
case GameData::blue:
return blueGoal;
break;
default:
ASSERT(false);
}
return blueGoal;
}
GoalModel::Goal& GoalModel::getTeamGoal(naoth::GameData::TeamColor teamColor)
{
switch (teamColor)
{
case GameData::red:
return yellowGoal;
break;
case GameData::blue:
return blueGoal;
break;
default:
ASSERT(false);
}
return blueGoal;
}//end getTeamGoal
*/
void GoalModel::print(std::ostream& stream) const
{
stream<<"== Seen Goal ==\n";
stream<< goal.frameInfoWhenGoalLastSeen;
stream<<"LPost = "<<goal.leftPost<<'\n';
stream<<"RPost = "<<goal.rightPost<<'\n';
/*Goal anotherGoal;
calculateAnotherGoal(goal, anotherGoal, getFieldInfo().xLength);
stream<<"== Calculated Goal ==\n";
stream<<"LPost = "<<anotherGoal.leftPost<<'\n';
stream<<"RPost = "<<anotherGoal.rightPost<<'\n';*/
}//end print
void GoalModel::draw() const
{
//FIELD_DRAWING_CONTEXT;
//PEN("FF0000", 50);
//CIRCLE(goal.leftPost.x, goal.leftPost.y, 50);
//CIRCLE(goal.rightPost.x, goal.rightPost.y, 50);
}//end draw
LocalGoalModel::LocalGoalModel()
:
someGoalWasSeen(false),
opponentGoalIsValid(false),
ownGoalIsValid(false),
seen_angle(0.0)
{
}
GoalModel::Goal GoalModel::calculateAnotherGoal(const GoalModel::Goal& goal, double distance)
{
Vector2<double> normal = goal.rightPost - goal.leftPost;
GoalModel::Goal another;
normal.normalize(distance);
normal.rotateRight();
// swich the posts
another.leftPost = goal.rightPost + normal;
another.rightPost = goal.leftPost + normal;
return another;
}//end calculateAnotherGoal
Pose2D GoalModel::calculatePose(const CompassDirection& compassDirection, const FieldInfo& fieldInfo) const
{
return calculatePose(compassDirection.angle, fieldInfo);
}
Pose2D GoalModel::calculatePose(double angle, const FieldInfo& fieldInfo) const
{
const Vector2<double>& leftOpponentGoalPosition = fieldInfo.opponentGoalPostLeft;
const Vector2<double>& rightOpponentGoalPosition = fieldInfo.opponentGoalPostRight;
Goal modeledOpponentGoal = getOppGoal(angle, fieldInfo);
// TODO: make it nicer with Vector2 operations
double rotation = (modeledOpponentGoal.leftPost-modeledOpponentGoal.rightPost).angle() - Math::pi_2;
rotation = Math::normalize(-rotation);
// TODO: introduce const method Vector2<>.rotate()
Vector2<double> posLeft = leftOpponentGoalPosition - modeledOpponentGoal.leftPost.rotate(rotation);
Vector2<double> posRight = rightOpponentGoalPosition - modeledOpponentGoal.rightPost.rotate(rotation);
Pose2D pose;
pose.translation = (posLeft + posRight)*0.5;
pose.rotation = rotation;
return pose;
}//end calculatePosition
void LocalGoalModel::print(std::ostream& stream) const
{
stream<<"someGoalWasSeen = "<<(someGoalWasSeen?"true":"false")<< std::endl;
stream<<"estimatedCenterOfGoal = " << seen_center << std::endl;
stream<<"estimatedAngleToGoal = " << seen_angle << std::endl;
GoalModel::print(stream);
}//end print
void SelfLocGoalModel::update(const Pose2D& robotPose, const FieldInfo& fieldInfo)
{
//GoalModel::Goal ownGoal = getOwnGoal(compassDirection, fieldInfo);
//GoalModel::Goal oppGoal = getOppGoal(compassDirection, fieldInfo);
// transform the goal posts to the local coordinates according to the robotPose
//ownGoal.leftPost = robotPose/fieldInfo.ownGoalPostLeft;
//ownGoal.rightPost = robotPose/fieldInfo.ownGoalPostRight;
// set the opponent goal regarding my position on the field
goal.leftPost = robotPose/fieldInfo.opponentGoalPostLeft;
goal.rightPost = robotPose/fieldInfo.opponentGoalPostRight;
}//end update
SensingGoalModel::SensingGoalModel()
:
someGoalWasSeen(false),
horizonScan(false)
{
}
| 28.766839 | 113 | 0.732349 | tarsoly |
d70676a2b256150be0471003a9f1361c001d9ea6 | 970 | cpp | C++ | srcs/main.cpp | AlexandreChamard/functionCompositor | 7234cf415e2ac5f6fa4a0823cc444636961c6f60 | [
"MIT"
] | null | null | null | srcs/main.cpp | AlexandreChamard/functionCompositor | 7234cf415e2ac5f6fa4a0823cc444636961c6f60 | [
"MIT"
] | null | null | null | srcs/main.cpp | AlexandreChamard/functionCompositor | 7234cf415e2ac5f6fa4a0823cc444636961c6f60 | [
"MIT"
] | null | null | null |
#include <sstream>
#include "evalexpr.hpp"
void test(std::string const &str) {
auto res = Evalexpr::pExpr(str);
std::cout << "test :\"" << str << "\"" << std::endl;
std::cout << res << std::endl;
if (res.valid()) {
std::cout << "size = " << sizeof(res.f) << std::endl;
std::cout << "exec : " << res() << std::endl;
}
std::cout << std::endl;
}
int main()
{
std::stringstream sstr;
srand(time(nullptr));
sstr << rand() % 10;
for (auto x = 0; x < 4; ++x) {
int op = rand() % 5;
switch (op) {
case 0: sstr << "+"; break;
case 1: sstr << "-"; break;
case 2: sstr << "*"; break;
case 3: sstr << "/"; break;
case 4: sstr << "%"; break;
}
sstr << rand() % 10;
}
test(sstr.str());
test("(34+12)*2-42");
// test("-12");
// test("+12");
// test("+12a");
// test("+");
}
// 75,840 bytes alloués
| 20.208333 | 61 | 0.427835 | AlexandreChamard |
d707944624be9c4dcb972aaae04b20e0adadf28b | 20,448 | cpp | C++ | Source/astcenc_integer_sequence.cpp | mcraiha/astc-encoder | 4a29609782e852e20478098d11eb2c892bba8c61 | [
"Apache-2.0"
] | 1 | 2022-02-15T21:02:20.000Z | 2022-02-15T21:02:20.000Z | Source/astcenc_integer_sequence.cpp | mcraiha/astc-encoder | 4a29609782e852e20478098d11eb2c892bba8c61 | [
"Apache-2.0"
] | null | null | null | Source/astcenc_integer_sequence.cpp | mcraiha/astc-encoder | 4a29609782e852e20478098d11eb2c892bba8c61 | [
"Apache-2.0"
] | null | null | null | // SPDX-License-Identifier: Apache-2.0
// ----------------------------------------------------------------------------
// Copyright 2011-2021 Arm Limited
//
// 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.
// ----------------------------------------------------------------------------
/**
* @brief Functions for encoding/decoding Bounded Integer Sequence Encoding.
*/
#include "astcenc_internal.h"
#include <array>
// unpacked quint triplets <low,middle,high> for each packed-quint value
static const uint8_t quints_of_integer[128][3] = {
{0, 0, 0}, {1, 0, 0}, {2, 0, 0}, {3, 0, 0},
{4, 0, 0}, {0, 4, 0}, {4, 4, 0}, {4, 4, 4},
{0, 1, 0}, {1, 1, 0}, {2, 1, 0}, {3, 1, 0},
{4, 1, 0}, {1, 4, 0}, {4, 4, 1}, {4, 4, 4},
{0, 2, 0}, {1, 2, 0}, {2, 2, 0}, {3, 2, 0},
{4, 2, 0}, {2, 4, 0}, {4, 4, 2}, {4, 4, 4},
{0, 3, 0}, {1, 3, 0}, {2, 3, 0}, {3, 3, 0},
{4, 3, 0}, {3, 4, 0}, {4, 4, 3}, {4, 4, 4},
{0, 0, 1}, {1, 0, 1}, {2, 0, 1}, {3, 0, 1},
{4, 0, 1}, {0, 4, 1}, {4, 0, 4}, {0, 4, 4},
{0, 1, 1}, {1, 1, 1}, {2, 1, 1}, {3, 1, 1},
{4, 1, 1}, {1, 4, 1}, {4, 1, 4}, {1, 4, 4},
{0, 2, 1}, {1, 2, 1}, {2, 2, 1}, {3, 2, 1},
{4, 2, 1}, {2, 4, 1}, {4, 2, 4}, {2, 4, 4},
{0, 3, 1}, {1, 3, 1}, {2, 3, 1}, {3, 3, 1},
{4, 3, 1}, {3, 4, 1}, {4, 3, 4}, {3, 4, 4},
{0, 0, 2}, {1, 0, 2}, {2, 0, 2}, {3, 0, 2},
{4, 0, 2}, {0, 4, 2}, {2, 0, 4}, {3, 0, 4},
{0, 1, 2}, {1, 1, 2}, {2, 1, 2}, {3, 1, 2},
{4, 1, 2}, {1, 4, 2}, {2, 1, 4}, {3, 1, 4},
{0, 2, 2}, {1, 2, 2}, {2, 2, 2}, {3, 2, 2},
{4, 2, 2}, {2, 4, 2}, {2, 2, 4}, {3, 2, 4},
{0, 3, 2}, {1, 3, 2}, {2, 3, 2}, {3, 3, 2},
{4, 3, 2}, {3, 4, 2}, {2, 3, 4}, {3, 3, 4},
{0, 0, 3}, {1, 0, 3}, {2, 0, 3}, {3, 0, 3},
{4, 0, 3}, {0, 4, 3}, {0, 0, 4}, {1, 0, 4},
{0, 1, 3}, {1, 1, 3}, {2, 1, 3}, {3, 1, 3},
{4, 1, 3}, {1, 4, 3}, {0, 1, 4}, {1, 1, 4},
{0, 2, 3}, {1, 2, 3}, {2, 2, 3}, {3, 2, 3},
{4, 2, 3}, {2, 4, 3}, {0, 2, 4}, {1, 2, 4},
{0, 3, 3}, {1, 3, 3}, {2, 3, 3}, {3, 3, 3},
{4, 3, 3}, {3, 4, 3}, {0, 3, 4}, {1, 3, 4}
};
// packed quint-value for every unpacked quint-triplet
// indexed by [high][middle][low]
static const uint8_t integer_of_quints[5][5][5] = {
{
{0, 1, 2, 3, 4},
{8, 9, 10, 11, 12},
{16, 17, 18, 19, 20},
{24, 25, 26, 27, 28},
{5, 13, 21, 29, 6}
},
{
{32, 33, 34, 35, 36},
{40, 41, 42, 43, 44},
{48, 49, 50, 51, 52},
{56, 57, 58, 59, 60},
{37, 45, 53, 61, 14}
},
{
{64, 65, 66, 67, 68},
{72, 73, 74, 75, 76},
{80, 81, 82, 83, 84},
{88, 89, 90, 91, 92},
{69, 77, 85, 93, 22}
},
{
{96, 97, 98, 99, 100},
{104, 105, 106, 107, 108},
{112, 113, 114, 115, 116},
{120, 121, 122, 123, 124},
{101, 109, 117, 125, 30}
},
{
{102, 103, 70, 71, 38},
{110, 111, 78, 79, 46},
{118, 119, 86, 87, 54},
{126, 127, 94, 95, 62},
{39, 47, 55, 63, 31}
}
};
// unpacked trit quintuplets <low,_,_,_,high> for each packed-quint value
static const uint8_t trits_of_integer[256][5] = {
{0, 0, 0, 0, 0}, {1, 0, 0, 0, 0}, {2, 0, 0, 0, 0}, {0, 0, 2, 0, 0},
{0, 1, 0, 0, 0}, {1, 1, 0, 0, 0}, {2, 1, 0, 0, 0}, {1, 0, 2, 0, 0},
{0, 2, 0, 0, 0}, {1, 2, 0, 0, 0}, {2, 2, 0, 0, 0}, {2, 0, 2, 0, 0},
{0, 2, 2, 0, 0}, {1, 2, 2, 0, 0}, {2, 2, 2, 0, 0}, {2, 0, 2, 0, 0},
{0, 0, 1, 0, 0}, {1, 0, 1, 0, 0}, {2, 0, 1, 0, 0}, {0, 1, 2, 0, 0},
{0, 1, 1, 0, 0}, {1, 1, 1, 0, 0}, {2, 1, 1, 0, 0}, {1, 1, 2, 0, 0},
{0, 2, 1, 0, 0}, {1, 2, 1, 0, 0}, {2, 2, 1, 0, 0}, {2, 1, 2, 0, 0},
{0, 0, 0, 2, 2}, {1, 0, 0, 2, 2}, {2, 0, 0, 2, 2}, {0, 0, 2, 2, 2},
{0, 0, 0, 1, 0}, {1, 0, 0, 1, 0}, {2, 0, 0, 1, 0}, {0, 0, 2, 1, 0},
{0, 1, 0, 1, 0}, {1, 1, 0, 1, 0}, {2, 1, 0, 1, 0}, {1, 0, 2, 1, 0},
{0, 2, 0, 1, 0}, {1, 2, 0, 1, 0}, {2, 2, 0, 1, 0}, {2, 0, 2, 1, 0},
{0, 2, 2, 1, 0}, {1, 2, 2, 1, 0}, {2, 2, 2, 1, 0}, {2, 0, 2, 1, 0},
{0, 0, 1, 1, 0}, {1, 0, 1, 1, 0}, {2, 0, 1, 1, 0}, {0, 1, 2, 1, 0},
{0, 1, 1, 1, 0}, {1, 1, 1, 1, 0}, {2, 1, 1, 1, 0}, {1, 1, 2, 1, 0},
{0, 2, 1, 1, 0}, {1, 2, 1, 1, 0}, {2, 2, 1, 1, 0}, {2, 1, 2, 1, 0},
{0, 1, 0, 2, 2}, {1, 1, 0, 2, 2}, {2, 1, 0, 2, 2}, {1, 0, 2, 2, 2},
{0, 0, 0, 2, 0}, {1, 0, 0, 2, 0}, {2, 0, 0, 2, 0}, {0, 0, 2, 2, 0},
{0, 1, 0, 2, 0}, {1, 1, 0, 2, 0}, {2, 1, 0, 2, 0}, {1, 0, 2, 2, 0},
{0, 2, 0, 2, 0}, {1, 2, 0, 2, 0}, {2, 2, 0, 2, 0}, {2, 0, 2, 2, 0},
{0, 2, 2, 2, 0}, {1, 2, 2, 2, 0}, {2, 2, 2, 2, 0}, {2, 0, 2, 2, 0},
{0, 0, 1, 2, 0}, {1, 0, 1, 2, 0}, {2, 0, 1, 2, 0}, {0, 1, 2, 2, 0},
{0, 1, 1, 2, 0}, {1, 1, 1, 2, 0}, {2, 1, 1, 2, 0}, {1, 1, 2, 2, 0},
{0, 2, 1, 2, 0}, {1, 2, 1, 2, 0}, {2, 2, 1, 2, 0}, {2, 1, 2, 2, 0},
{0, 2, 0, 2, 2}, {1, 2, 0, 2, 2}, {2, 2, 0, 2, 2}, {2, 0, 2, 2, 2},
{0, 0, 0, 0, 2}, {1, 0, 0, 0, 2}, {2, 0, 0, 0, 2}, {0, 0, 2, 0, 2},
{0, 1, 0, 0, 2}, {1, 1, 0, 0, 2}, {2, 1, 0, 0, 2}, {1, 0, 2, 0, 2},
{0, 2, 0, 0, 2}, {1, 2, 0, 0, 2}, {2, 2, 0, 0, 2}, {2, 0, 2, 0, 2},
{0, 2, 2, 0, 2}, {1, 2, 2, 0, 2}, {2, 2, 2, 0, 2}, {2, 0, 2, 0, 2},
{0, 0, 1, 0, 2}, {1, 0, 1, 0, 2}, {2, 0, 1, 0, 2}, {0, 1, 2, 0, 2},
{0, 1, 1, 0, 2}, {1, 1, 1, 0, 2}, {2, 1, 1, 0, 2}, {1, 1, 2, 0, 2},
{0, 2, 1, 0, 2}, {1, 2, 1, 0, 2}, {2, 2, 1, 0, 2}, {2, 1, 2, 0, 2},
{0, 2, 2, 2, 2}, {1, 2, 2, 2, 2}, {2, 2, 2, 2, 2}, {2, 0, 2, 2, 2},
{0, 0, 0, 0, 1}, {1, 0, 0, 0, 1}, {2, 0, 0, 0, 1}, {0, 0, 2, 0, 1},
{0, 1, 0, 0, 1}, {1, 1, 0, 0, 1}, {2, 1, 0, 0, 1}, {1, 0, 2, 0, 1},
{0, 2, 0, 0, 1}, {1, 2, 0, 0, 1}, {2, 2, 0, 0, 1}, {2, 0, 2, 0, 1},
{0, 2, 2, 0, 1}, {1, 2, 2, 0, 1}, {2, 2, 2, 0, 1}, {2, 0, 2, 0, 1},
{0, 0, 1, 0, 1}, {1, 0, 1, 0, 1}, {2, 0, 1, 0, 1}, {0, 1, 2, 0, 1},
{0, 1, 1, 0, 1}, {1, 1, 1, 0, 1}, {2, 1, 1, 0, 1}, {1, 1, 2, 0, 1},
{0, 2, 1, 0, 1}, {1, 2, 1, 0, 1}, {2, 2, 1, 0, 1}, {2, 1, 2, 0, 1},
{0, 0, 1, 2, 2}, {1, 0, 1, 2, 2}, {2, 0, 1, 2, 2}, {0, 1, 2, 2, 2},
{0, 0, 0, 1, 1}, {1, 0, 0, 1, 1}, {2, 0, 0, 1, 1}, {0, 0, 2, 1, 1},
{0, 1, 0, 1, 1}, {1, 1, 0, 1, 1}, {2, 1, 0, 1, 1}, {1, 0, 2, 1, 1},
{0, 2, 0, 1, 1}, {1, 2, 0, 1, 1}, {2, 2, 0, 1, 1}, {2, 0, 2, 1, 1},
{0, 2, 2, 1, 1}, {1, 2, 2, 1, 1}, {2, 2, 2, 1, 1}, {2, 0, 2, 1, 1},
{0, 0, 1, 1, 1}, {1, 0, 1, 1, 1}, {2, 0, 1, 1, 1}, {0, 1, 2, 1, 1},
{0, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {2, 1, 1, 1, 1}, {1, 1, 2, 1, 1},
{0, 2, 1, 1, 1}, {1, 2, 1, 1, 1}, {2, 2, 1, 1, 1}, {2, 1, 2, 1, 1},
{0, 1, 1, 2, 2}, {1, 1, 1, 2, 2}, {2, 1, 1, 2, 2}, {1, 1, 2, 2, 2},
{0, 0, 0, 2, 1}, {1, 0, 0, 2, 1}, {2, 0, 0, 2, 1}, {0, 0, 2, 2, 1},
{0, 1, 0, 2, 1}, {1, 1, 0, 2, 1}, {2, 1, 0, 2, 1}, {1, 0, 2, 2, 1},
{0, 2, 0, 2, 1}, {1, 2, 0, 2, 1}, {2, 2, 0, 2, 1}, {2, 0, 2, 2, 1},
{0, 2, 2, 2, 1}, {1, 2, 2, 2, 1}, {2, 2, 2, 2, 1}, {2, 0, 2, 2, 1},
{0, 0, 1, 2, 1}, {1, 0, 1, 2, 1}, {2, 0, 1, 2, 1}, {0, 1, 2, 2, 1},
{0, 1, 1, 2, 1}, {1, 1, 1, 2, 1}, {2, 1, 1, 2, 1}, {1, 1, 2, 2, 1},
{0, 2, 1, 2, 1}, {1, 2, 1, 2, 1}, {2, 2, 1, 2, 1}, {2, 1, 2, 2, 1},
{0, 2, 1, 2, 2}, {1, 2, 1, 2, 2}, {2, 2, 1, 2, 2}, {2, 1, 2, 2, 2},
{0, 0, 0, 1, 2}, {1, 0, 0, 1, 2}, {2, 0, 0, 1, 2}, {0, 0, 2, 1, 2},
{0, 1, 0, 1, 2}, {1, 1, 0, 1, 2}, {2, 1, 0, 1, 2}, {1, 0, 2, 1, 2},
{0, 2, 0, 1, 2}, {1, 2, 0, 1, 2}, {2, 2, 0, 1, 2}, {2, 0, 2, 1, 2},
{0, 2, 2, 1, 2}, {1, 2, 2, 1, 2}, {2, 2, 2, 1, 2}, {2, 0, 2, 1, 2},
{0, 0, 1, 1, 2}, {1, 0, 1, 1, 2}, {2, 0, 1, 1, 2}, {0, 1, 2, 1, 2},
{0, 1, 1, 1, 2}, {1, 1, 1, 1, 2}, {2, 1, 1, 1, 2}, {1, 1, 2, 1, 2},
{0, 2, 1, 1, 2}, {1, 2, 1, 1, 2}, {2, 2, 1, 1, 2}, {2, 1, 2, 1, 2},
{0, 2, 2, 2, 2}, {1, 2, 2, 2, 2}, {2, 2, 2, 2, 2}, {2, 1, 2, 2, 2}
};
// packed trit-value for every unpacked trit-quintuplet
// indexed by [high][][][][low]
static const uint8_t integer_of_trits[3][3][3][3][3] = {
{
{
{
{0, 1, 2},
{4, 5, 6},
{8, 9, 10}
},
{
{16, 17, 18},
{20, 21, 22},
{24, 25, 26}
},
{
{3, 7, 15},
{19, 23, 27},
{12, 13, 14}
}
},
{
{
{32, 33, 34},
{36, 37, 38},
{40, 41, 42}
},
{
{48, 49, 50},
{52, 53, 54},
{56, 57, 58}
},
{
{35, 39, 47},
{51, 55, 59},
{44, 45, 46}
}
},
{
{
{64, 65, 66},
{68, 69, 70},
{72, 73, 74}
},
{
{80, 81, 82},
{84, 85, 86},
{88, 89, 90}
},
{
{67, 71, 79},
{83, 87, 91},
{76, 77, 78}
}
}
},
{
{
{
{128, 129, 130},
{132, 133, 134},
{136, 137, 138}
},
{
{144, 145, 146},
{148, 149, 150},
{152, 153, 154}
},
{
{131, 135, 143},
{147, 151, 155},
{140, 141, 142}
}
},
{
{
{160, 161, 162},
{164, 165, 166},
{168, 169, 170}
},
{
{176, 177, 178},
{180, 181, 182},
{184, 185, 186}
},
{
{163, 167, 175},
{179, 183, 187},
{172, 173, 174}
}
},
{
{
{192, 193, 194},
{196, 197, 198},
{200, 201, 202}
},
{
{208, 209, 210},
{212, 213, 214},
{216, 217, 218}
},
{
{195, 199, 207},
{211, 215, 219},
{204, 205, 206}
}
}
},
{
{
{
{96, 97, 98},
{100, 101, 102},
{104, 105, 106}
},
{
{112, 113, 114},
{116, 117, 118},
{120, 121, 122}
},
{
{99, 103, 111},
{115, 119, 123},
{108, 109, 110}
}
},
{
{
{224, 225, 226},
{228, 229, 230},
{232, 233, 234}
},
{
{240, 241, 242},
{244, 245, 246},
{248, 249, 250}
},
{
{227, 231, 239},
{243, 247, 251},
{236, 237, 238}
}
},
{
{
{28, 29, 30},
{60, 61, 62},
{92, 93, 94}
},
{
{156, 157, 158},
{188, 189, 190},
{220, 221, 222}
},
{
{31, 63, 127},
{159, 191, 255},
{252, 253, 254}
}
}
}
};
/**
* @brief The number of bits, trits, and quints needed for a quant level.
*/
struct btq_count {
/**< The quantization level. */
uint8_t quant;
/**< The number of bits. */
uint8_t bits;
/**< The number of trits. */
uint8_t trits;
/**< The number of quints. */
uint8_t quints;
};
/**
* @brief The table of bits, trits, and quints needed for a quant encode.
*/
static const std::array<btq_count, 21> btq_counts = {{
{ QUANT_2, 1, 0, 0 },
{ QUANT_3, 0, 1, 0 },
{ QUANT_4, 2, 0, 0 },
{ QUANT_5, 0, 0, 1 },
{ QUANT_6, 1, 1, 0 },
{ QUANT_8, 3, 0, 0 },
{ QUANT_10, 1, 0, 1 },
{ QUANT_12, 2, 1, 0 },
{ QUANT_16, 4, 0, 0 },
{ QUANT_20, 2, 0, 1 },
{ QUANT_24, 3, 1, 0 },
{ QUANT_32, 5, 0, 0 },
{ QUANT_40, 3, 0, 1 },
{ QUANT_48, 4, 1, 0 },
{ QUANT_64, 6, 0, 0 },
{ QUANT_80, 4, 0, 1 },
{ QUANT_96, 5, 1, 0 },
{ QUANT_128, 7, 0, 0 },
{ QUANT_160, 5, 0, 1 },
{ QUANT_192, 6, 1, 0 },
{ QUANT_256, 8, 0, 0 }
}};
/**
* @brief The sequence scale, round, and divisors needed to compute sizing.
*
* The length of a quantized sequence in bits is:
* (scale * <sequence_len> + round) / divisor
*/
struct ise_size {
/**< The quantization level. */
uint8_t quant;
/**< The scaling parameter. */
uint8_t scale;
/**< The rounding parameter. */
uint8_t round;
/**< The divisor parameter. */
uint8_t divisor;
};
/**
* @brief The table of scale, round, and divisors needed for quant sizing.
*/
static const std::array<ise_size, 21> ise_sizes = {{
{ QUANT_2, 1, 0, 1 },
{ QUANT_3, 8, 4, 5 },
{ QUANT_4, 2, 0, 1 },
{ QUANT_5, 7, 2, 3 },
{ QUANT_6, 13, 4, 5 },
{ QUANT_8, 3, 0, 1 },
{ QUANT_10, 10, 2, 3 },
{ QUANT_12, 18, 4, 5 },
{ QUANT_16, 4, 0, 1 },
{ QUANT_20, 13, 2, 3 },
{ QUANT_24, 23, 4, 5 },
{ QUANT_32, 5, 0, 1 },
{ QUANT_40, 16, 2, 3 },
{ QUANT_48, 28, 4, 5 },
{ QUANT_64, 6, 0, 1 },
{ QUANT_80, 19, 2, 3 },
{ QUANT_96, 33, 4, 5 },
{ QUANT_128, 7, 0, 1 },
{ QUANT_160, 22, 2, 3 },
{ QUANT_192, 38, 4, 5 },
{ QUANT_256, 8, 0, 1 }
}};
/* See header for documentation. */
int get_ise_sequence_bitcount(
int items,
quant_method quant
) {
// Cope with out-of bounds values - input might be invalid
if (static_cast<size_t>(quant) >= ise_sizes.size())
{
// Arbitrary large number that's more than an ASTC block can hold
return 1024;
}
auto& entry = ise_sizes[quant];
return (entry.scale * items + entry.round) / entry.divisor;
}
// routine to write up to 8 bits
static inline void write_bits(
int value,
int bitcount,
int bitoffset,
uint8_t* ptr
) {
int mask = (1 << bitcount) - 1;
value &= mask;
ptr += bitoffset >> 3;
bitoffset &= 7;
value <<= bitoffset;
mask <<= bitoffset;
mask = ~mask;
ptr[0] &= mask;
ptr[0] |= value;
ptr[1] &= mask >> 8;
ptr[1] |= value >> 8;
}
// routine to read up to 8 bits
static inline int read_bits(
int bitcount,
int bitoffset,
const uint8_t* ptr
) {
int mask = (1 << bitcount) - 1;
ptr += bitoffset >> 3;
bitoffset &= 7;
int value = ptr[0] | (ptr[1] << 8);
value >>= bitoffset;
value &= mask;
return value;
}
void encode_ise(
int quant_level,
int elements,
const uint8_t* input_data,
uint8_t* output_data,
int bit_offset
) {
int bits = btq_counts[quant_level].bits;
int trits = btq_counts[quant_level].trits;
int quints = btq_counts[quant_level].quints;
int mask = (1 << bits) - 1;
// Write out trits and bits
if (trits)
{
int i = 0;
int full_trit_blocks = elements / 5;
for (int j = 0; j < full_trit_blocks; j++)
{
int i4 = input_data[i + 4] >> bits;
int i3 = input_data[i + 3] >> bits;
int i2 = input_data[i + 2] >> bits;
int i1 = input_data[i + 1] >> bits;
int i0 = input_data[i + 0] >> bits;
uint8_t T = integer_of_trits[i4][i3][i2][i1][i0];
// The max size of a trit bit count is 6, so we can always safely
// pack a single MX value with the following 1 or 2 T bits.
uint8_t pack;
// Element 0 + T0 + T1
pack = (input_data[i++] & mask) | (((T >> 0) & 0x3) << bits);
write_bits(pack, bits + 2, bit_offset, output_data);
bit_offset += bits + 2;
// Element 1 + T2 + T3
pack = (input_data[i++] & mask) | (((T >> 2) & 0x3) << bits);
write_bits(pack, bits + 2, bit_offset, output_data);
bit_offset += bits + 2;
// Element 2 + T4
pack = (input_data[i++] & mask) | (((T >> 4) & 0x1) << bits);
write_bits(pack, bits + 1, bit_offset, output_data);
bit_offset += bits + 1;
// Element 3 + T5 + T6
pack = (input_data[i++] & mask) | (((T >> 5) & 0x3) << bits);
write_bits(pack, bits + 2, bit_offset, output_data);
bit_offset += bits + 2;
// Element 4 + T7
pack = (input_data[i++] & mask) | (((T >> 7) & 0x1) << bits);
write_bits(pack, bits + 1, bit_offset, output_data);
bit_offset += bits + 1;
}
// Loop tail for a partial block
if (i != elements)
{
// i4 cannot be present - we know the block is partial
// i0 must be present - we know the block isn't empty
int i4 = 0;
int i3 = i + 3 >= elements ? 0 : input_data[i + 3] >> bits;
int i2 = i + 2 >= elements ? 0 : input_data[i + 2] >> bits;
int i1 = i + 1 >= elements ? 0 : input_data[i + 1] >> bits;
int i0 = input_data[i + 0] >> bits;
uint8_t T = integer_of_trits[i4][i3][i2][i1][i0];
for (int j = 0; i < elements; i++, j++)
{
// Truncated table as this iteration is always partital
static const uint8_t tbits[4] { 2, 2, 1, 2 };
static const uint8_t tshift[4] { 0, 2, 4, 5 };
uint8_t pack = (input_data[i] & mask) |
(((T >> tshift[j]) & ((1 << tbits[j]) - 1)) << bits);
write_bits(pack, bits + tbits[j], bit_offset, output_data);
bit_offset += bits + tbits[j];
}
}
}
// Write out quints and bits
else if (quints)
{
int i = 0;
int full_quint_blocks = elements / 3;
for (int j = 0; j < full_quint_blocks; j++)
{
int i2 = input_data[i + 2] >> bits;
int i1 = input_data[i + 1] >> bits;
int i0 = input_data[i + 0] >> bits;
uint8_t T = integer_of_quints[i2][i1][i0];
// The max size of a quint bit count is 5, so we can always safely
// pack a single M value with the following 2 or 3 T bits.
uint8_t pack;
// Element 0
pack = (input_data[i++] & mask) | (((T >> 0) & 0x7) << bits);
write_bits(pack, bits + 3, bit_offset, output_data);
bit_offset += bits + 3;
// Element 1
pack = (input_data[i++] & mask) | (((T >> 3) & 0x3) << bits);
write_bits(pack, bits + 2, bit_offset, output_data);
bit_offset += bits + 2;
// Element 2
pack = (input_data[i++] & mask) | (((T >> 5) & 0x3) << bits);
write_bits(pack, bits + 2, bit_offset, output_data);
bit_offset += bits + 2;
}
// Loop tail for a partial block
if (i != elements)
{
// i2 cannot be present - we know the block is partial
// i0 must be present - we know the block isn't empty
int i2 = 0;
int i1 = i + 1 >= elements ? 0 : input_data[i + 1] >> bits;
int i0 = input_data[i + 0] >> bits;
uint8_t T = integer_of_quints[i2][i1][i0];
for (int j = 0; i < elements; i++, j++)
{
// Truncated table as this iteration is always partital
static const uint8_t tbits[2] { 3, 2 };
static const uint8_t tshift[2] { 0, 3 };
uint8_t pack = (input_data[i] & mask) |
(((T >> tshift[j]) & ((1 << tbits[j]) - 1)) << bits);
write_bits(pack, bits + tbits[j], bit_offset, output_data);
bit_offset += bits + tbits[j];
}
}
}
// Write out just bits
else
{
promise(elements > 0);
for (int i = 0; i < elements; i++)
{
write_bits(input_data[i], bits, bit_offset, output_data);
bit_offset += bits;
}
}
}
void decode_ise(
int quant_level,
int elements,
const uint8_t* input_data,
uint8_t* output_data,
int bit_offset
) {
// note: due to how the trit/quint-block unpacking is done in this function,
// we may write more temporary results than the number of outputs
// The maximum actual number of results is 64 bit, but we keep 4 additional elements
// of padding.
uint8_t results[68];
uint8_t tq_blocks[22]; // trit-blocks or quint-blocks
int bits = btq_counts[quant_level].bits;
int trits = btq_counts[quant_level].trits;
int quints = btq_counts[quant_level].quints;
int lcounter = 0;
int hcounter = 0;
// trit-blocks or quint-blocks must be zeroed out before we collect them in the loop below.
for (int i = 0; i < 22; i++)
{
tq_blocks[i] = 0;
}
// collect bits for each element, as well as bits for any trit-blocks and quint-blocks.
for (int i = 0; i < elements; i++)
{
results[i] = read_bits(bits, bit_offset, input_data);
bit_offset += bits;
if (trits)
{
static const int bits_to_read[5] { 2, 2, 1, 2, 1 };
static const int block_shift[5] { 0, 2, 4, 5, 7 };
static const int next_lcounter[5] { 1, 2, 3, 4, 0 };
static const int hcounter_incr[5] { 0, 0, 0, 0, 1 };
int tdata = read_bits(bits_to_read[lcounter], bit_offset, input_data);
bit_offset += bits_to_read[lcounter];
tq_blocks[hcounter] |= tdata << block_shift[lcounter];
hcounter += hcounter_incr[lcounter];
lcounter = next_lcounter[lcounter];
}
if (quints)
{
static const int bits_to_read[3] { 3, 2, 2 };
static const int block_shift[3] { 0, 3, 5 };
static const int next_lcounter[3] { 1, 2, 0 };
static const int hcounter_incr[3] { 0, 0, 1 };
int tdata = read_bits(bits_to_read[lcounter], bit_offset, input_data);
bit_offset += bits_to_read[lcounter];
tq_blocks[hcounter] |= tdata << block_shift[lcounter];
hcounter += hcounter_incr[lcounter];
lcounter = next_lcounter[lcounter];
}
}
// unpack trit-blocks or quint-blocks as needed
if (trits)
{
int trit_blocks = (elements + 4) / 5;
for (int i = 0; i < trit_blocks; i++)
{
const uint8_t *tritptr = trits_of_integer[tq_blocks[i]];
results[5 * i ] |= tritptr[0] << bits;
results[5 * i + 1] |= tritptr[1] << bits;
results[5 * i + 2] |= tritptr[2] << bits;
results[5 * i + 3] |= tritptr[3] << bits;
results[5 * i + 4] |= tritptr[4] << bits;
}
}
if (quints)
{
int quint_blocks = (elements + 2) / 3;
for (int i = 0; i < quint_blocks; i++)
{
const uint8_t *quintptr = quints_of_integer[tq_blocks[i]];
results[3 * i ] |= quintptr[0] << bits;
results[3 * i + 1] |= quintptr[1] << bits;
results[3 * i + 2] |= quintptr[2] << bits;
}
}
for (int i = 0; i < elements; i++)
{
output_data[i] = results[i];
}
}
| 28.204138 | 92 | 0.474129 | mcraiha |
d7098cfee77bc78c2092c5dfc3cafce2ecc283be | 7,402 | cpp | C++ | src/mongo/db/pipeline/expression_context.cpp | i80and/mongo | 67f4d6495ad14fe95067f06e0366823887828c0e | [
"Apache-2.0"
] | 1 | 2015-03-18T00:04:06.000Z | 2015-03-18T00:04:06.000Z | src/mongo/db/pipeline/expression_context.cpp | visemet/mongo | 232c772546f26bcb5a5556d859e56002a4135f0b | [
"Apache-2.0"
] | 4 | 2019-02-22T10:05:59.000Z | 2021-03-26T00:20:23.000Z | src/mongo/db/pipeline/expression_context.cpp | visemet/mongo | 232c772546f26bcb5a5556d859e56002a4135f0b | [
"Apache-2.0"
] | 10 | 2018-11-29T07:17:30.000Z | 2022-03-07T01:33:41.000Z | /**
* Copyright (C) 2016 MongoDB Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* As a special exception, the copyright holders give permission to link the
* code of portions of this program with the OpenSSL library under certain
* conditions as described in each individual source file and distribute
* linked combinations including the program with the OpenSSL library. You
* must comply with the GNU Affero General Public License in all respects for
* all of the code used other than as permitted herein. If you modify file(s)
* with this exception, you may extend this exception to your version of the
* file(s), but you are not obligated to do so. If you do not wish to do so,
* delete this exception statement from your version. If you delete this
* exception statement from all source files in the program, then also delete
* it in the license file.
*/
#include "mongo/platform/basic.h"
#include "mongo/db/pipeline/expression_context.h"
#include "mongo/db/pipeline/stub_mongo_process_interface.h"
#include "mongo/db/query/collation/collation_spec.h"
#include "mongo/db/query/collation/collator_factory_interface.h"
namespace mongo {
using boost::intrusive_ptr;
ExpressionContext::ResolvedNamespace::ResolvedNamespace(NamespaceString ns,
std::vector<BSONObj> pipeline)
: ns(std::move(ns)), pipeline(std::move(pipeline)) {}
ExpressionContext::ExpressionContext(OperationContext* opCtx,
const AggregationRequest& request,
std::unique_ptr<CollatorInterface> collator,
std::shared_ptr<MongoProcessInterface> processInterface,
StringMap<ResolvedNamespace> resolvedNamespaces)
: ExpressionContext(opCtx, collator.get()) {
explain = request.getExplain();
comment = request.getComment();
fromMongos = request.isFromMongos();
needsMerge = request.needsMerge();
allowDiskUse = request.shouldAllowDiskUse();
bypassDocumentValidation = request.shouldBypassDocumentValidation();
ns = request.getNamespaceString();
mongoProcessInterface = std::move(processInterface);
collation = request.getCollation();
_ownedCollator = std::move(collator);
_resolvedNamespaces = std::move(resolvedNamespaces);
}
ExpressionContext::ExpressionContext(OperationContext* opCtx, const CollatorInterface* collator)
: opCtx(opCtx),
mongoProcessInterface(std::make_shared<StubMongoProcessInterface>()),
timeZoneDatabase(opCtx && opCtx->getServiceContext()
? TimeZoneDatabase::get(opCtx->getServiceContext())
: nullptr),
variablesParseState(variables.useIdGenerator()),
_collator(collator),
_documentComparator(_collator),
_valueComparator(_collator) {}
ExpressionContext::ExpressionContext(NamespaceString nss,
std::shared_ptr<MongoProcessInterface> processInterface,
const TimeZoneDatabase* tzDb)
: ns(std::move(nss)),
mongoProcessInterface(std::move(processInterface)),
timeZoneDatabase(tzDb),
variablesParseState(variables.useIdGenerator()) {}
void ExpressionContext::checkForInterrupt() {
// This check could be expensive, at least in relative terms, so don't check every time.
if (--_interruptCounter == 0) {
invariant(opCtx);
_interruptCounter = kInterruptCheckPeriod;
opCtx->checkForInterrupt();
}
}
ExpressionContext::CollatorStash::CollatorStash(
const boost::intrusive_ptr<ExpressionContext>& expCtx,
std::unique_ptr<CollatorInterface> newCollator)
: _expCtx(expCtx),
_originalCollation(_expCtx->collation),
_originalCollatorOwned(std::move(_expCtx->_ownedCollator)),
_originalCollatorUnowned(_expCtx->_collator) {
_expCtx->setCollator(std::move(newCollator));
_expCtx->collation =
_expCtx->getCollator() ? _expCtx->getCollator()->getSpec().toBSON().getOwned() : BSONObj();
}
ExpressionContext::CollatorStash::~CollatorStash() {
if (_originalCollatorOwned) {
_expCtx->setCollator(std::move(_originalCollatorOwned));
} else {
_expCtx->setCollator(_originalCollatorUnowned);
if (!_originalCollatorUnowned && _expCtx->_ownedCollator) {
// If the original collation was 'nullptr', we cannot distinguish whether it was owned
// or not. We always set '_ownedCollator' with the stash, so should reset it to null
// here.
_expCtx->_ownedCollator = nullptr;
}
}
_expCtx->collation = _originalCollation;
}
std::unique_ptr<ExpressionContext::CollatorStash> ExpressionContext::temporarilyChangeCollator(
std::unique_ptr<CollatorInterface> newCollator) {
// This constructor of CollatorStash is private, so we can't use make_unique().
return std::unique_ptr<CollatorStash>(new CollatorStash(this, std::move(newCollator)));
}
void ExpressionContext::setCollator(const CollatorInterface* collator) {
_collator = collator;
// Document/Value comparisons must be aware of the collation.
_documentComparator = DocumentComparator(_collator);
_valueComparator = ValueComparator(_collator);
}
intrusive_ptr<ExpressionContext> ExpressionContext::copyWith(
NamespaceString ns,
boost::optional<UUID> uuid,
boost::optional<std::unique_ptr<CollatorInterface>> collator) const {
intrusive_ptr<ExpressionContext> expCtx =
new ExpressionContext(std::move(ns), mongoProcessInterface, timeZoneDatabase);
expCtx->uuid = std::move(uuid);
expCtx->explain = explain;
expCtx->comment = comment;
expCtx->needsMerge = needsMerge;
expCtx->fromMongos = fromMongos;
expCtx->inMongos = inMongos;
expCtx->allowDiskUse = allowDiskUse;
expCtx->bypassDocumentValidation = bypassDocumentValidation;
expCtx->subPipelineDepth = subPipelineDepth;
expCtx->tempDir = tempDir;
expCtx->opCtx = opCtx;
if (collator) {
expCtx->collation =
*collator ? (*collator)->getSpec().toBSON() : CollationSpec::kSimpleSpec;
expCtx->setCollator(std::move(*collator));
} else {
expCtx->collation = collation;
if (_ownedCollator) {
expCtx->setCollator(_ownedCollator->clone());
} else if (_collator) {
expCtx->setCollator(_collator);
}
}
expCtx->_resolvedNamespaces = _resolvedNamespaces;
// Note that we intentionally skip copying the value of '_interruptCounter' because 'expCtx' is
// intended to be used for executing a separate aggregation pipeline.
return expCtx;
}
} // namespace mongo
| 42.297143 | 99 | 0.693461 | i80and |
d70a542567640fbbfc7db0105734f135eeddc7f7 | 18,661 | cpp | C++ | big_vec.cpp | jlinton/x4vecs | 1b91810f1ae8e793005687f0d04a6f0a1ec3ed96 | [
"MIT"
] | 2 | 2015-05-12T02:33:14.000Z | 2016-07-13T13:49:18.000Z | big_vec.cpp | jlinton/x4vecs | 1b91810f1ae8e793005687f0d04a6f0a1ec3ed96 | [
"MIT"
] | null | null | null | big_vec.cpp | jlinton/x4vecs | 1b91810f1ae8e793005687f0d04a6f0a1ec3ed96 | [
"MIT"
] | 1 | 2020-09-04T01:27:24.000Z | 2020-09-04T01:27:24.000Z | // Copyright (c) 2021 Jeremy Linton
//
// big_vec.cpp
// C++ wrapper around the $PLAT_objs.cpp vector to extend its len
//
//Permission is hereby granted, free of charge, to any person obtaining a copy
//of this software and associated documentation files (the "Software"), to deal
//in the Software without restriction, including without limitation the rights
//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
//copies of the Software, and to permit persons to whom the Software is
//furnished to do so, subject to the following conditions:
//The above copyright notice and this permission notice shall be included in
//all copies or substantial portions of the Software.
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
//THE SOFTWARE.
// To build some basic unit tests for this module do:
// g++ -mfloat-abi=softfp -mfpu=neon -g -O3 -std=c++11 big_vec.cpp
// or
// g++ -msse3 -g -O3 -std=c++11 big_vec.cpp
// AVXx8 version
// g++ -mavx -g -O3 -std=c++11 big_vec.cpp
#define NO_MAIN
#ifdef __ARM_NEON__
#include "neon_objs.cpp"
#elif defined(__SSE3__)
#include "sse_objs2.cpp"
#else
#include "portable_objs.cpp"
#endif
// big allocs might need something like -Wl,-z,stack-size=XXXX; ulimit -s XXXXX
// define arbitrary len vector in relation to HW vector class
//
#define VECS ((ELEM_CNT/VEC_CNT)?(ELEM_CNT/VEC_CNT):1)
template<int VEC_CNT, int ELEM_CNT, class VEC_T> class BigVector
{
public:
BigVector():vec() {}; //construct unititalized
BigVector(BigVector *src) { for (int x=0;x<VECS;x++) vec[x]=src->vec[x]; };
BigVector(BigVector &src) { for (int x=0;x<VECS;x++) vec[x]=src.vec[x]; };
BigVector(VEC_T *src,int src_cnt) { VEC_T tmp(0.0); for (int x=0;x<VECS;x++) vec[x]=tmp; for (int x=0;x<src_cnt;x++) vec[x]=src[x]; }; //allows a resize op
//BigVector(double *fill) {VEC_T tmp(fill); for (int x=0;x<VECS;x++) vec[x]=tmp;}
template <typename... Args> BigVector(Args... args) {VEC_T tmp(0.0); for (int x=0;x<VECS;x++) vec[x]=tmp; Set(0, args...); }; // if this aborts, verify vec is properly aligned (32 bytes for x8)
// POD copy construct
// assign
BigVector & operator=(const BigVector &src_prm) { for (int x=0;x<VECS;x++) vec[x]=src_prm.vec[x]; return *this;}
BigVector & operator=(const float src[ELEM_CNT]) { for (int x=0;x<ELEM_CNT;x++) vec[x/VEC_CNT].Set(x-(x/VEC_CNT)*VEC_CNT,src[x]); return *this;};
void Set(int off, float Val) {const int n=off/VEC_CNT; vec[n].Set(off-n*VEC_CNT, Val); }
void Fill(float Val) {VEC_T tmp(Val); for (int x=1;x<VEC_CNT;x++) tmp.Set(x,Val); for (int x=0;x<VECS;x++) vec[x]=tmp;}
template <typename... Args> void Set(int off, float Val, Args... args) { int n=off/VEC_CNT; vec[n].Set(off-n*VEC_CNT, Val); Set(++off,args...); };
// reads
float operator[](int index_prm) const {int n=index_prm/VEC_CNT; return vec[n][index_prm-n*VEC_CNT];};
//BigVector Get(int index_prm);
//void save(float *dst_prm) { };
std::string as_str(const char *format_prm="%05.2f ") { std::string fmt; for (int x=0;x<VEC_CNT;x++) fmt+=format_prm; std::string tmp; for (int x=0;x<VECS;x++) tmp+=vec[x].as_str(fmt.c_str()); return tmp; }
// adds urinary
BigVector & operator+=(const BigVector &src2) { for (int x=0;x<VECS;x++) vec[x]+=src2.vec[x]; return *this;}
BigVector & operator-=(const BigVector &src2) { for (int x=0;x<VECS;x++) vec[x]-=src2.vec[x]; return *this;}
BigVector & operator+=(const float src2) { for (int x=0;x<VECS;x++) vec[x]+=src2; return *this;}
BigVector & operator-=(const float src2) { for (int x=0;x<VECS;x++) vec[x]-=src2;; return *this;}
// adds binary
BigVector const operator+ (const BigVector &src2) { BigVector tmp; for (int x=0;x<VECS;x++) tmp.vec[x]=vec[x]+src2.vec[x]; return tmp;}
BigVector const operator- (const BigVector &src2) { BigVector tmp; for (int x=0;x<VECS;x++) tmp.vec[x]=vec[x]-src2.vec[x]; return tmp;}
BigVector const operator+ (const float src2) { BigVector tmp; for (int x=0;x<VECS;x++) tmp.vec[x]=vec[x]+src2; return tmp;}
BigVector const operator- (const float src2) { BigVector tmp; for (int x=0;x<VECS;x++) tmp.vec[x]=vec[x]-src2; return tmp;}
// muls urinary
BigVector & operator*=(const BigVector &src2) { for (int x=0;x<VECS;x++) vec[x]*src2.vec[x]; return *this;}
BigVector & operator/=(const BigVector &src2) { for (int x=0;x<VECS;x++) vec[x]/src2.vec[x]; return *this;}
BigVector & operator*=(const float src2) { for (int x=0;x<VECS;x++) vec[x]=vec[x]*src2; return *this;}
BigVector & operator/=(const float src2) { for (int x=0;x<VECS;x++) vec[x]=vec[x]/src2; return *this;}
// muls binary
BigVector const operator* (const BigVector &src2) { BigVector tmp; for (int x=0;x<VECS;x++) tmp.vec[x]=vec[x]*src2.vec[x]; return tmp;}
BigVector const operator/ (const BigVector &src2) { BigVector tmp; for (int x=0;x<VECS;x++) tmp.vec[x]=vec[x]/src2.vec[x]; return tmp;}
BigVector const operator* (const float src2) { BigVector tmp; for (int x=0;x<VECS;x++) tmp.vec[x]=vec[x]*src2; return tmp;}
BigVector const operator/ (const float src2) { BigVector tmp; for (int x=0;x<VECS;x++) tmp.vec[x]=vec[x]/src2; return tmp;}
// other manipulations
float ElementSum(void) const { float tmp=0; for (int x=0;x<VECS;x++) tmp+=vec[x].ElementSum(); return tmp; }
float fma(BigVector &src2) {return 0.0;}//implement fma (which requires the underlying vector to do it too)
VEC_T *raw() {return vec;}
int raw_sz() {return VECS;}
private:
VEC_T vec[VECS];
};
// square matrix based on big vecs above
// most of these loops should be expanded with openMP if the matrix sizes get sufficiently large
template<int SIZE, class VEC_T> class MatrixS
{
public:
MatrixS() {} //construct unititalized
MatrixS(float val) { VEC_T tmp; tmp.Fill(val); for (int x=0;x<SIZE;x++) vecs[x]=tmp; }
MatrixS(const MatrixS &orig) {for (int x=0; x<SIZE; x++) vecs[x]=orig.vecs[x]; }
// assign
//BigVector & operator=(const BigVector &src_prm) { for (int x=0;x<VECS;x++) vec[x]=src_prm.vec[x]; }
//BigVector & operator=(const float src[ELEM_CNT]) { for (int x=0;x<ELEM_CNT;x++) vec[x/VEC_CNT].Set(x-(x/VEC_CNT)*VEC_CNT,src[x]);};
void Set(int col, int row, float Val) { vecs[row].Set(col, Val); }
//template <typename... Args> void Set(int off, float Val, Args... args) { int n=off/VEC_CNT; vec[n].Set(off-n*VEC_CNT, Val); Set(++off,args...); };
// reads
VEC_T &operator[](int index_prm) {return vecs[index_prm];};
float Get(int row,int col) {return vecs[row][col];}
//void save(float *dst_prm) { };
std::string as_str(const char *format_prm="%05.2f,") { std::string ret; for (int x=0;x<SIZE;x++) ret+=vecs[x].as_str(format_prm)+";\n"; return ret; }
// adds urinary
MatrixS & operator+=(const MatrixS &src2) { for (int x=0;x<SIZE;x++) vecs[x]+=src2.vec[x]; return *this;}
MatrixS & operator-=(const MatrixS &src2) { for (int x=0;x<SIZE;x++) vecs[x]-=src2.vec[x]; return *this;}
MatrixS & operator+=(const float src2) { for (int x=0;x<SIZE;x++) vecs[x]+=src2; return *this;}
MatrixS & operator-=(const float src2) { for (int x=0;x<SIZE;x++) vecs[x]-=src2;; return *this;}
// muls urinary
MatrixS & operator*=(const MatrixS &src2)
{
MatrixS Trans(src2); //todo heap allocate if matrix is really large (or maybe do something requiring the caller to pre transpose it?, or just use the gather loads..
Trans.Transpose();
for (int x=0; x<SIZE; x++)
{
VEC_T result;
for (int y=0; y<SIZE; y++)
{
float val = (vecs[x] * Trans.vecs[y]).ElementSum();
result.Set(y, val);
}
vecs[x]=result;
}
return *this;
}
MatrixS & operator/=(const MatrixS &src2)
{
MatrixS Trans(src2);
Trans.Transpose();
for (int x=0; x<SIZE; x++)
{
VEC_T result;
for (int y=0; y<SIZE; y++)
{
float val = (vecs[x] / Trans.vecs[y]).ElementSum();
result.Set(y, val);
}
vecs[x]=result;
}
return *this;
}
VEC_T & operator*=(const VEC_T &src2) { VEC_T ret; for (int x=0;x<SIZE;x++) ret.Set(x,(vecs[x]*src2).ElementSum()); return *this;}
VEC_T & operator/=(const VEC_T &src2) { VEC_T ret; for (int x=0;x<SIZE;x++) ret.Set(x,(vecs[x]/src2).ElementSum()); return *this;} //probably should build inverse vec?
MatrixS & operator*=(const float src2) { for (int x=0;x<SIZE;x++) vecs[x]*=src2; return *this;}
MatrixS & operator/=(const float src2) { for (int x=0;x<SIZE;x++) vecs[x]/=src2;; return *this;}
//other ops
void Transpose() { for (int x=1;x<SIZE;x++) for (int y=0;y<x;y++) { float tmp=vecs[x][y]; vecs[x].Set(y,vecs[y][x]); vecs[y].Set(x,tmp); } } //do something smarter?
void det() {
MatrixS ret(0);
for (int i=0;i<SIZE;i++)
{
}
}
// inverse
private:
VEC_T vecs[SIZE];
};
// non square matrix based on big vecs above
// most of these loops should be expanded with openMP if the matrix sizes get sufficiently large
#ifdef __AVX__
template<int SIZE_ROW,int SIZE_COL, class VEC_TR = BigVector<8,SIZE_ROW,SSEx8>, class VEC_TC = BigVector<8,SIZE_COL,SSEx8>> class MatrixST
#else
template<int SIZE_ROW,int SIZE_COL, class VEC_TR = BigVector<4,SIZE_ROW,Vec4>, class VEC_TC = BigVector<4,SIZE_COL,Vec4>> class MatrixST
#endif
{
// typedef BigVector<4,SIZE_ROW,Vec4> VEC_TX;
public:
MatrixST() {} //construct unititalized
MatrixST(float val) { VEC_TR tmp; tmp.Fill(val); for (int y=0;y<SIZE_COL;y++) vecs[y]=tmp; }
MatrixST(const MatrixST &orig) {for (int y=0; y<SIZE_COL; y++) vecs[y]=orig.vecs[y]; }
// assign
//BigVector & operator=(const BigVector &src_prm) { for (int x=0;x<VECS;x++) vec[x]=src_prm.vec[x]; }
//BigVector & operator=(const float src[ELEM_CNT]) { for (int x=0;x<ELEM_CNT;x++) vec[x/VEC_CNT].Set(x-(x/VEC_CNT)*VEC_CNT,src[x]);};
void Set(int col, int row, float Val) { vecs[row].Set(col, Val); }
//template <typename... Args> void Set(int off, float Val, Args... args) { int n=off/VEC_CNT; vec[n].Set(off-n*VEC_CNT, Val); Set(++off,args...); };
// reads
VEC_TR &operator[](int index_prm) {return vecs[index_prm];};
float Get(int col,int row) {return vecs[row][col];}
//void save(float *dst_prm) { };
std::string as_str(const char *format_prm="%05.2f,") { std::string ret; for (int x=0;x<SIZE_COL;x++) ret+=vecs[x].as_str(format_prm)+";\n"; return ret; }
// adds urinary
MatrixST & operator+=(const MatrixST &src2) { for (int y=0;y<SIZE_COL;y++) vecs[y]+=src2.vec[y]; return *this;}
MatrixST & operator-=(const MatrixST &src2) { for (int y=0;y<SIZE_COL;y++) vecs[y]-=src2.vec[y]; return *this;}
MatrixST & operator+=(const float src2) { for (int y=0;y<SIZE_COL;y++) vecs[y]+=src2; return *this;}
MatrixST & operator-=(const float src2) { for (int y=0;y<SIZE_COL;y++) vecs[y]-=src2;; return *this;}
// muls urinary (can't change the dimensions, so this only works when the result doesn't change dimensions)
template<int S2_ROW,int S2_COL, class S2_VR,class S2_VC>
MatrixST<SIZE_ROW, S2_COL, VEC_TR, S2_VC> & operator*=(const MatrixST<S2_ROW, S2_COL, S2_VR, S2_VC> &src2)
{
//MatrixST<SIZE_COL,SIZE_ROW, VEC_TC, VEC_TR> Trans(src2); //todo heap allocate if matrix is really large (or maybe do something requiring the caller to pre transpose it?, or just use the gather loads..
MatrixST<S2_COL, S2_ROW, S2_VC, S2_VR> Trans=src2.Transpose();
for (int x=0; x<SIZE_ROW; x++)
{
VEC_TR result;
for (int y=0; y<S2_COL; y++)
{
float val = (vecs[x] * Trans.vecs[y]).ElementSum();
result.Set(y, val);
}
vecs[x]=result;
}
return *this;
}
// muls binary, because it returns a type it can be used to change the dimensions
template<int S2_ROW,int S2_COL, class S2_VR,class S2_VC>
MatrixST<SIZE_COL, S2_ROW, VEC_TC, S2_VR> operator*(const MatrixST<S2_ROW, S2_COL, S2_VR, S2_VC> &src2)
{
//MatrixST<SIZE_COL,SIZE_ROW, VEC_TC, VEC_TR> Trans(src2); //todo heap allocate if matrix is really large (or maybe do something requiring the caller to pre transpose it?, or just use the gather loads..
MatrixST<S2_COL, S2_ROW, S2_VC, S2_VR> Trans=src2.Transpose();
MatrixST<SIZE_COL, S2_ROW, VEC_TC, S2_VR> ret(0);
for (int x=0; x<SIZE_COL; x++)
{
VEC_TC result;
for (int y=0; y<S2_ROW; y++)
{
float val = (vecs[x] * Trans.vecs[y]).ElementSum();
result.Set(y, val);
}
ret[x]=result;
}
return ret;
}
// version of above with the src pre-transposed
// template<int S2_ROW,int S2_COL, class S2_VR,class S2_VC>
// MatrixST<SIZE_COL, S2_ROW, VEC_TC, S2_VR> MultNoTrans(const MatrixST<S2_ROW, S2_COL, S2_VR, S2_VC> &src2)
VEC_TR & operator*=(const VEC_TR &src2) { VEC_TR ret; for (int y=0;y<SIZE_ROW;y++) ret.Set(y,(vecs[y]*src2).ElementSum()); return *this;}
VEC_TR & operator/=(const VEC_TR &src2) { VEC_TR ret; for (int y=0;y<SIZE_ROW;y++) ret.Set(y,(vecs[y]/src2).ElementSum()); return *this;} //probably should build inverse vec?
MatrixST & operator*=(const float src2) { for (int y=0;y<SIZE_ROW;y++) vecs[y]*=src2; return *this;}
MatrixST & operator/=(const float src2) { for (int y=0;y<SIZE_ROW;y++) vecs[y]/=src2;; return *this;}
//other ops
// must return transposed matrix because m X n becomes n X m
MatrixST<SIZE_COL,SIZE_ROW, VEC_TC, VEC_TR> Transpose() const
{
MatrixST<SIZE_COL,SIZE_ROW, VEC_TC, VEC_TR> ret;
for (int y=0;y<SIZE_ROW;y++)
{
for (int x=0;x<SIZE_COL;x++)
{
ret.Set(x, y, vecs[x][y]);
}
}
return ret; //should be move?!
} //do something smarter?
//void ITranspose() { for (int x=1;x<SIZE;x++) for (int y=0;y<=x;y++) { float tmp=vecs[x][y]; vecs[x].Set(y,1.0/vecs[y][x]); vecs[y].Set(x,1.0/tmp); } } //do something smarter?
MatrixST LU(void)
{
MatrixST U(0),L(0);
if (SIZE_ROW != SIZE_COL)
{
throw "can't deal with non square matrix";
}
for (int i=0;i<SIZE_COL;i++)
{
//U[i][i] = 1.0;
U.Set(i,i,1.0);
}
for (int j=0;j<SIZE_COL;j++)
{
for (int y=j;y<SIZE_COL;y++)
{
float sum = 0;
for (int k=0;k<j;k++)
{
sum += L[y][k] * U[k][j];
}
L.Set(j,y,vecs[y][j]-sum);
//printf("L:\n%s\n", L.as_str().c_str());
}
for (int i=j;i<SIZE_COL;i++)
{
float sum = 0;
for (int k=0;k<j;k++)
{
sum += L[j][k] * U[k][i];
}
if (L[j][j]== 0.0) L.Set(j,j,0.0000001);
U.Set(i,j,(vecs[j][i]-sum)/L[j][j]);
}
}
printf("L:\n%s\n", L.as_str().c_str());
printf("U:\n%s\n", U.as_str().c_str());
return L;
}
float Det(void)
{
MatrixST L=LU();
float det = L[0][0];//*U[0][0];
for (int i=1;i<SIZE_COL;i++)
{
det *= L[i][i];
// det *= U[i][i];
}
printf("Det:%f\n", det);
return det;
}
private:
VEC_TR vecs[SIZE_COL]; //number of rows
};
template<int A,int B,class C,class D,int SA,int SB,class SC,class SD,template<int ,int ,class ,class > class T1, template<int ,int ,class ,class > class T2>void muls(T1<A,B,C,D> &s1, T2<SA,SB,SC,SD> &s)
{
MatrixST<A,SB,C,SD> tmp(0);
printf("new big vec (%d,%d):(%d,%d):\n%s\n", A,B,SA,SB,tmp.as_str().c_str());
}
#ifdef __AVX__
typedef BigVector<8,8,SSEx8> Vec8;
typedef BigVector<8,16,SSEx8> Vec16;
typedef BigVector<8,32,SSEx8> Vec32;
typedef BigVector<8,64,SSEx8> Vec64;
typedef BigVector<8,4096,SSEx8> Vec4k;
#else
typedef BigVector<4,8,Vec4> Vec8;
typedef BigVector<4,16,Vec4> Vec16;
typedef BigVector<4,32,Vec4> Vec32;
typedef BigVector<4,64,Vec4> Vec64;
typedef BigVector<4,4096,Vec4> Vec4k;
#endif
// recursive template calls? sure why not. This breaks the raw() import method (and printing)..
typedef BigVector<64,128,Vec64> Vec128;
#include <memory>
int main(int argv,char *argc[])
{
Vec8 x8vec(0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0);
Vec8 x8vec2;
x8vec2.Fill(1.0);
Vec16 x16vec(0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0);
Vec128 x128vec(0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0);
printf(" big vec %s\n", x8vec.as_str().c_str());
x8vec+=10;
printf("+10 big vec %s\n", x8vec.as_str().c_str());
x8vec/=2;
printf("/2 big vec %s\n", x8vec.as_str().c_str());
x8vec+=x8vec;
printf("*2 big vec %s\n", x8vec.as_str().c_str());
x8vec+=x8vec2;
printf("+1 big vec %s\n", x8vec.as_str().c_str());
printf("\nbig vec %s\n", x16vec.as_str().c_str());
x16vec+=Vec16(x8vec.raw(), x8vec.raw_sz());
printf("big vec %s\n", x16vec.as_str().c_str());
//printf("\nbig vec %s\n", x128vec.as_str().c_str());
//std::unique_ptr<Vec4k> x4kvec=std::make_unique<Vec4096>();
Vec4k *x4kvec=new Vec4k(0.0);
*x4kvec+=6.5;
printf("\nbig vec %s\n", x4kvec->as_str().c_str());
delete x4kvec;
MatrixS<8,Vec8> x8Mat(1);
for (int x=0;x<8;x++) x8Mat.Set(x,x,float(x));
for (int x=0;x<8;x++) x8Mat.Set(0,x,float(x));
printf("\nbig mat:\n%s\n", x8Mat.as_str().c_str());
MatrixS<8,Vec8> x8Mat2(x8Mat);
x8Mat2.Transpose();
printf("big mat:\n%s\n", x8Mat2.as_str().c_str());
x8Mat2*=x8Mat;
printf("big mat:\n%s\n", x8Mat2.as_str().c_str());
/* not computed correctly yet because we want to calc inverse (and det()) first
x8Mat2/=x8Mat;
printf("big mat:\n%s\n", x8Mat2.as_str().c_str());*/
// square version, validate against above.
MatrixST<8,8,Vec8,Vec8> x8nsMat(1);
for (int x=0;x<8;x++) x8nsMat.Set(x,x,float(x));
for (int x=0;x<8;x++) x8nsMat.Set(0,x,float(x));
printf("\nbig matv:\n%s\n", x8nsMat.as_str().c_str());
MatrixST<8,8,Vec8,Vec8> x8nsMat2(x8nsMat.Transpose());
printf("big matv:\n%s\n", x8nsMat2.as_str().c_str());
x8nsMat2*=x8nsMat;
printf("big matv:\n%s\n", x8nsMat2.as_str().c_str());
// nonsquare version (with default prms)
MatrixST<16,8> x8nsMat3(0);
for (int x=0;x<8;x++) { x8nsMat3.Set(x,x,float(x)); x8nsMat3.Set(x+8,x,float(x));}
for (int x=0;x<8;x++) x8nsMat3.Set(0,x,float(x));
printf("big mat:\n%s\n", x8nsMat3.as_str().c_str());
MatrixST<8,16> x8nsMat4(x8nsMat3.Transpose());
// auto x8nsMat4(x8nsMat3.Transpose()); // this works?!!
printf("big mat:\n%s\n", x8nsMat4.as_str().c_str());
auto x8nsMat5 = x8nsMat4 * x8nsMat3;
printf("big mat:\n%s\n", x8nsMat5.as_str().c_str());
auto x8nsMat6 = x8nsMat3 * x8nsMat4;
printf("big mat:\n%s\n", x8nsMat6.as_str().c_str());
//x8nsMat6.LU();
//x8nsMat2.LU();
x8nsMat2.Det();
MatrixST<2,2> x2Mat(1);
printf("small mat:\n%s\n", x2Mat.as_str().c_str());
MatrixST<8,8> x2Mat2(1);
printf("small mat:\n%s\n", x2Mat2.as_str().c_str());
x2Mat2.LU();
// x8nsMat4 *= x8nsMat3; //could one get away with changing the type? lol!
// printf("big mat:\n%s\n", x8nsMat4.as_str().c_str());
// this will eat all your stack! lol
// MatrixST<4096,4096> x8nsMat7(1);
// printf("big mat:\n%s\n", x8nsMat7.as_str().c_str());
// muls(x8nsMat3,x8nsMat2);
}
| 40.567391 | 206 | 0.656664 | jlinton |
d71059c713d55a14cf2ae3f271b4e913c3f0fcce | 1,403 | cpp | C++ | 3rd semester/lab_05/src/List.cpp | kmalski/cpp_labs | 52b0fc84319d6cc57ff7bfdb787aa5eb09edf592 | [
"MIT"
] | 1 | 2020-05-19T17:14:55.000Z | 2020-05-19T17:14:55.000Z | 3rd semester/lab_05/src/List.cpp | kmalski/CPP_Laboratories | 52b0fc84319d6cc57ff7bfdb787aa5eb09edf592 | [
"MIT"
] | null | null | null | 3rd semester/lab_05/src/List.cpp | kmalski/CPP_Laboratories | 52b0fc84319d6cc57ff7bfdb787aa5eb09edf592 | [
"MIT"
] | null | null | null | #include "List.h"
#include <iostream>
Node *prepareNewNode(const int array[][2]) {
Node *tmp = new Node();
for (int i = 0; i < 2; i++) {
for (int j = 0; j < 2; j++) {
tmp->data[i][j] = array[i][j];
}
}
tmp->next = nullptr;
return tmp;
}
void prepare(List *list) {
list->head = nullptr;
list->tail = nullptr;
}
void prepare(List *to, const List *from) {
Node *tmp = from->head;
while(tmp != nullptr) {
add(to, tmp->data);
tmp = tmp->next;
}
}
void add(List *list, int array[][2]) {
if(empty(list)) {
list->head = list->tail = prepareNewNode(array);
} else {
list->tail->next = prepareNewNode(array);
list->tail = list->tail->next;
}
}
bool empty(const List *list) {
return list->head == nullptr;
}
void print(const List *list) {
for(int i = 0; i < 2; i++) {
Node *tmp = list->head;
while(tmp != nullptr) {
for(int j = 0; j < 2; j++) {
std::cout << tmp->data[i][j] << " ";
}
std::cout << " ";
tmp = tmp->next;
}
std::cout << std::endl;
}
}
void clear(List *list) {
Node *tmp = list->head;
Node *toDelete;
while(tmp != nullptr) {
toDelete = tmp;
tmp = tmp->next;
delete toDelete;
}
list->head = list->tail = nullptr;
}
| 20.632353 | 56 | 0.478261 | kmalski |
d711a20407c4abaa06a76558df1e9c0c00f3423c | 3,292 | cxx | C++ | Applications/OverView/Core/vtkSMClientDeliverySource.cxx | matthb2/ParaView-beforekitwareswtichedtogit | e47e57d6ce88444d9e6af9ab29f9db8c23d24cef | [
"BSD-3-Clause"
] | 1 | 2021-07-31T19:38:03.000Z | 2021-07-31T19:38:03.000Z | Applications/OverView/Core/vtkSMClientDeliverySource.cxx | matthb2/ParaView-beforekitwareswtichedtogit | e47e57d6ce88444d9e6af9ab29f9db8c23d24cef | [
"BSD-3-Clause"
] | null | null | null | Applications/OverView/Core/vtkSMClientDeliverySource.cxx | matthb2/ParaView-beforekitwareswtichedtogit | e47e57d6ce88444d9e6af9ab29f9db8c23d24cef | [
"BSD-3-Clause"
] | 2 | 2019-01-22T19:51:40.000Z | 2021-07-31T19:38:05.000Z | /*=========================================================================
Program: ParaView
Module: $RCSfile$
Copyright (c) 2005-2008 Sandia Corporation, Kitware Inc.
All rights reserved.
ParaView is a free software; you can redistribute it and/or modify it
under the terms of the ParaView license version 1.2.
See License_v1.2.txt for the full ParaView license.
A copy of this license can be obtained by contacting
Kitware Inc.
28 Corporate Drive
Clifton Park, NY 12065
USA
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 AUTHORS 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 "vtkSMClientDeliverySource.h"
#include "vtkDataObject.h"
#include "vtkInformation.h"
#include "vtkInformationVector.h"
#include "vtkObjectFactory.h"
vtkCxxRevisionMacro(vtkSMClientDeliverySource, "$Revision$");
vtkStandardNewMacro(vtkSMClientDeliverySource);
// Construct programmable filter with empty execute method.
vtkSMClientDeliverySource::vtkSMClientDeliverySource() :
DeliveryProxy(0)
{
this->SetNumberOfInputPorts(0);
}
vtkSMClientDeliverySource::~vtkSMClientDeliverySource()
{
this->SetDeliveryProxy(0);
}
int vtkSMClientDeliverySource::RequestData(
vtkInformation*,
vtkInformationVector** inputVector,
vtkInformationVector* outputVector)
{
// Just update the delivery proxy and copy it to the output.
this->DeliveryProxy->Update();
vtkDataObject* input = this->DeliveryProxy->GetOutput();
vtkDataObject* output = outputVector->GetInformationObject(0)->
Get(vtkDataObject::DATA_OBJECT());
output->ShallowCopy(input);
return 1;
}
int vtkSMClientDeliverySource::RequestDataObject(
vtkInformation*,
vtkInformationVector**,
vtkInformationVector* outputVector)
{
if (!this->DeliveryProxy)
{
vtkErrorMacro("Delivery proxy must be set before update.");
}
// Make the algorithm's output type match the proxy's output.
this->DeliveryProxy->Update();
vtkDataObject* input = this->DeliveryProxy->GetOutput();
vtkInformation* info = outputVector->GetInformationObject(0);
vtkDataObject* output = info->Get(vtkDataObject::DATA_OBJECT());
if (!output || output->GetDataObjectType() != input->GetDataObjectType())
{
output = input->NewInstance();
output->SetPipelineInformation(info);
output->Delete();
this->GetOutputPortInformation(0)->Set(
vtkDataObject::DATA_EXTENT_TYPE(), output->GetExtentType());
}
return 1;
}
void vtkSMClientDeliverySource::PrintSelf(ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os,indent);
}
| 32.594059 | 75 | 0.725395 | matthb2 |
d7123984c5b1ca771d08102c058dd5492cfa4888 | 24,068 | cpp | C++ | media/bufferpool/1.0/BufferPoolClient.cpp | Dreadwyrm/lhos_frameworks_av | 62c63ccfdf5c79a3ad9be4836f473da9398c671b | [
"Apache-2.0"
] | null | null | null | media/bufferpool/1.0/BufferPoolClient.cpp | Dreadwyrm/lhos_frameworks_av | 62c63ccfdf5c79a3ad9be4836f473da9398c671b | [
"Apache-2.0"
] | null | null | null | media/bufferpool/1.0/BufferPoolClient.cpp | Dreadwyrm/lhos_frameworks_av | 62c63ccfdf5c79a3ad9be4836f473da9398c671b | [
"Apache-2.0"
] | 2 | 2021-07-08T07:42:11.000Z | 2021-07-09T21:56:10.000Z | /*
* Copyright (C) 2018 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#define LOG_TAG "BufferPoolClient"
//#define LOG_NDEBUG 0
#include <thread>
#include <utils/Log.h>
#include "BufferPoolClient.h"
#include "Connection.h"
namespace android {
namespace hardware {
namespace media {
namespace bufferpool {
namespace V1_0 {
namespace implementation {
static constexpr int64_t kReceiveTimeoutUs = 1000000; // 100ms
static constexpr int kPostMaxRetry = 3;
static constexpr int kCacheTtlUs = 1000000; // TODO: tune
class BufferPoolClient::Impl
: public std::enable_shared_from_this<BufferPoolClient::Impl> {
public:
explicit Impl(const sp<Accessor> &accessor);
explicit Impl(const sp<IAccessor> &accessor);
bool isValid() {
return mValid;
}
bool isLocal() {
return mValid && mLocal;
}
ConnectionId getConnectionId() {
return mConnectionId;
}
sp<IAccessor> &getAccessor() {
return mAccessor;
}
bool isActive(int64_t *lastTransactionUs, bool clearCache);
ResultStatus allocate(const std::vector<uint8_t> ¶ms,
native_handle_t **handle,
std::shared_ptr<BufferPoolData> *buffer);
ResultStatus receive(
TransactionId transactionId, BufferId bufferId,
int64_t timestampUs,
native_handle_t **handle, std::shared_ptr<BufferPoolData> *buffer);
void postBufferRelease(BufferId bufferId);
bool postSend(
BufferId bufferId, ConnectionId receiver,
TransactionId *transactionId, int64_t *timestampUs);
private:
bool postReceive(
BufferId bufferId, TransactionId transactionId,
int64_t timestampUs);
bool postReceiveResult(
BufferId bufferId, TransactionId transactionId, bool result, bool *needsSync);
void trySyncFromRemote();
bool syncReleased();
void evictCaches(bool clearCache = false);
ResultStatus allocateBufferHandle(
const std::vector<uint8_t>& params, BufferId *bufferId,
native_handle_t **handle);
ResultStatus fetchBufferHandle(
TransactionId transactionId, BufferId bufferId,
native_handle_t **handle);
struct BlockPoolDataDtor;
struct ClientBuffer;
bool mLocal;
bool mValid;
sp<IAccessor> mAccessor;
sp<Connection> mLocalConnection;
sp<IConnection> mRemoteConnection;
uint32_t mSeqId;
ConnectionId mConnectionId;
int64_t mLastEvictCacheUs;
// CachedBuffers
struct BufferCache {
std::mutex mLock;
bool mCreating;
std::condition_variable mCreateCv;
std::map<BufferId, std::unique_ptr<ClientBuffer>> mBuffers;
int mActive;
int64_t mLastChangeUs;
BufferCache() : mCreating(false), mActive(0), mLastChangeUs(getTimestampNow()) {}
void incActive_l() {
++mActive;
mLastChangeUs = getTimestampNow();
}
void decActive_l() {
--mActive;
mLastChangeUs = getTimestampNow();
}
} mCache;
// FMQ - release notifier
struct {
std::mutex mLock;
// TODO: use only one list?(using one list may dealy sending messages?)
std::list<BufferId> mReleasingIds;
std::list<BufferId> mReleasedIds;
std::unique_ptr<BufferStatusChannel> mStatusChannel;
} mReleasing;
// This lock is held during synchronization from remote side.
// In order to minimize remote calls and locking durtaion, this lock is held
// by best effort approach using try_lock().
std::mutex mRemoteSyncLock;
};
struct BufferPoolClient::Impl::BlockPoolDataDtor {
BlockPoolDataDtor(const std::shared_ptr<BufferPoolClient::Impl> &impl)
: mImpl(impl) {}
void operator()(BufferPoolData *buffer) {
BufferId id = buffer->mId;
delete buffer;
auto impl = mImpl.lock();
if (impl && impl->isValid()) {
impl->postBufferRelease(id);
}
}
const std::weak_ptr<BufferPoolClient::Impl> mImpl;
};
struct BufferPoolClient::Impl::ClientBuffer {
private:
bool mInvalidated; // TODO: implement
int64_t mExpireUs;
bool mHasCache;
ConnectionId mConnectionId;
BufferId mId;
native_handle_t *mHandle;
std::weak_ptr<BufferPoolData> mCache;
void updateExpire() {
mExpireUs = getTimestampNow() + kCacheTtlUs;
}
public:
ClientBuffer(
ConnectionId connectionId, BufferId id, native_handle_t *handle)
: mInvalidated(false), mHasCache(false),
mConnectionId(connectionId), mId(id), mHandle(handle) {
(void)mInvalidated;
mExpireUs = getTimestampNow() + kCacheTtlUs;
}
~ClientBuffer() {
if (mHandle) {
native_handle_close(mHandle);
native_handle_delete(mHandle);
}
}
bool expire() const {
int64_t now = getTimestampNow();
return now >= mExpireUs;
}
bool hasCache() const {
return mHasCache;
}
std::shared_ptr<BufferPoolData> fetchCache(native_handle_t **pHandle) {
if (mHasCache) {
std::shared_ptr<BufferPoolData> cache = mCache.lock();
if (cache) {
*pHandle = mHandle;
}
return cache;
}
return nullptr;
}
std::shared_ptr<BufferPoolData> createCache(
const std::shared_ptr<BufferPoolClient::Impl> &impl,
native_handle_t **pHandle) {
if (!mHasCache) {
// Allocates a raw ptr in order to avoid sending #postBufferRelease
// from deleter, in case of native_handle_clone failure.
BufferPoolData *ptr = new BufferPoolData(mConnectionId, mId);
if (ptr) {
std::shared_ptr<BufferPoolData> cache(ptr, BlockPoolDataDtor(impl));
if (cache) {
mCache = cache;
mHasCache = true;
*pHandle = mHandle;
return cache;
}
}
if (ptr) {
delete ptr;
}
}
return nullptr;
}
bool onCacheRelease() {
if (mHasCache) {
// TODO: verify mCache is not valid;
updateExpire();
mHasCache = false;
return true;
}
return false;
}
};
BufferPoolClient::Impl::Impl(const sp<Accessor> &accessor)
: mLocal(true), mValid(false), mAccessor(accessor), mSeqId(0),
mLastEvictCacheUs(getTimestampNow()) {
const QueueDescriptor *fmqDesc;
ResultStatus status = accessor->connect(
&mLocalConnection, &mConnectionId, &fmqDesc, true);
if (status == ResultStatus::OK) {
mReleasing.mStatusChannel =
std::make_unique<BufferStatusChannel>(*fmqDesc);
mValid = mReleasing.mStatusChannel &&
mReleasing.mStatusChannel->isValid();
}
}
BufferPoolClient::Impl::Impl(const sp<IAccessor> &accessor)
: mLocal(false), mValid(false), mAccessor(accessor), mSeqId(0),
mLastEvictCacheUs(getTimestampNow()) {
bool valid = false;
sp<IConnection>& outConnection = mRemoteConnection;
ConnectionId& id = mConnectionId;
std::unique_ptr<BufferStatusChannel>& outChannel =
mReleasing.mStatusChannel;
Return<void> transResult = accessor->connect(
[&valid, &outConnection, &id, &outChannel]
(ResultStatus status, sp<IConnection> connection,
ConnectionId connectionId, const QueueDescriptor& desc) {
if (status == ResultStatus::OK) {
outConnection = connection;
id = connectionId;
outChannel = std::make_unique<BufferStatusChannel>(desc);
if (outChannel && outChannel->isValid()) {
valid = true;
}
}
});
mValid = transResult.isOk() && valid;
}
bool BufferPoolClient::Impl::isActive(int64_t *lastTransactionUs, bool clearCache) {
bool active = false;
{
std::lock_guard<std::mutex> lock(mCache.mLock);
syncReleased();
evictCaches(clearCache);
*lastTransactionUs = mCache.mLastChangeUs;
active = mCache.mActive > 0;
}
if (mValid && mLocal && mLocalConnection) {
mLocalConnection->cleanUp(clearCache);
return true;
}
return active;
}
ResultStatus BufferPoolClient::Impl::allocate(
const std::vector<uint8_t> ¶ms,
native_handle_t **pHandle,
std::shared_ptr<BufferPoolData> *buffer) {
if (!mLocal || !mLocalConnection || !mValid) {
return ResultStatus::CRITICAL_ERROR;
}
BufferId bufferId;
native_handle_t *handle = nullptr;
buffer->reset();
ResultStatus status = allocateBufferHandle(params, &bufferId, &handle);
if (status == ResultStatus::OK) {
if (handle) {
std::unique_lock<std::mutex> lock(mCache.mLock);
syncReleased();
evictCaches();
auto cacheIt = mCache.mBuffers.find(bufferId);
if (cacheIt != mCache.mBuffers.end()) {
// TODO: verify it is recycled. (not having active ref)
mCache.mBuffers.erase(cacheIt);
}
auto clientBuffer = std::make_unique<ClientBuffer>(
mConnectionId, bufferId, handle);
if (clientBuffer) {
auto result = mCache.mBuffers.insert(std::make_pair(
bufferId, std::move(clientBuffer)));
if (result.second) {
*buffer = result.first->second->createCache(
shared_from_this(), pHandle);
if (*buffer) {
mCache.incActive_l();
}
}
}
}
if (!*buffer) {
ALOGV("client cache creation failure %d: %lld",
handle != nullptr, (long long)mConnectionId);
status = ResultStatus::NO_MEMORY;
postBufferRelease(bufferId);
}
}
return status;
}
ResultStatus BufferPoolClient::Impl::receive(
TransactionId transactionId, BufferId bufferId, int64_t timestampUs,
native_handle_t **pHandle,
std::shared_ptr<BufferPoolData> *buffer) {
if (!mValid) {
return ResultStatus::CRITICAL_ERROR;
}
if (timestampUs != 0) {
timestampUs += kReceiveTimeoutUs;
}
if (!postReceive(bufferId, transactionId, timestampUs)) {
return ResultStatus::CRITICAL_ERROR;
}
ResultStatus status = ResultStatus::CRITICAL_ERROR;
buffer->reset();
while(1) {
std::unique_lock<std::mutex> lock(mCache.mLock);
syncReleased();
evictCaches();
auto cacheIt = mCache.mBuffers.find(bufferId);
if (cacheIt != mCache.mBuffers.end()) {
if (cacheIt->second->hasCache()) {
*buffer = cacheIt->second->fetchCache(pHandle);
if (!*buffer) {
// check transfer time_out
lock.unlock();
std::this_thread::yield();
continue;
}
ALOGV("client receive from reference %lld", (long long)mConnectionId);
break;
} else {
*buffer = cacheIt->second->createCache(shared_from_this(), pHandle);
if (*buffer) {
mCache.incActive_l();
}
ALOGV("client receive from cache %lld", (long long)mConnectionId);
break;
}
} else {
if (!mCache.mCreating) {
mCache.mCreating = true;
lock.unlock();
native_handle_t* handle = nullptr;
status = fetchBufferHandle(transactionId, bufferId, &handle);
lock.lock();
if (status == ResultStatus::OK) {
if (handle) {
auto clientBuffer = std::make_unique<ClientBuffer>(
mConnectionId, bufferId, handle);
if (clientBuffer) {
auto result = mCache.mBuffers.insert(
std::make_pair(bufferId, std::move(
clientBuffer)));
if (result.second) {
*buffer = result.first->second->createCache(
shared_from_this(), pHandle);
if (*buffer) {
mCache.incActive_l();
}
}
}
}
if (!*buffer) {
status = ResultStatus::NO_MEMORY;
}
}
mCache.mCreating = false;
lock.unlock();
mCache.mCreateCv.notify_all();
break;
}
mCache.mCreateCv.wait(lock);
}
}
bool needsSync = false;
bool posted = postReceiveResult(bufferId, transactionId,
*buffer ? true : false, &needsSync);
ALOGV("client receive %lld - %u : %s (%d)", (long long)mConnectionId, bufferId,
*buffer ? "ok" : "fail", posted);
if (mValid && mLocal && mLocalConnection) {
mLocalConnection->cleanUp(false);
}
if (needsSync && mRemoteConnection) {
trySyncFromRemote();
}
if (*buffer) {
if (!posted) {
buffer->reset();
return ResultStatus::CRITICAL_ERROR;
}
return ResultStatus::OK;
}
return status;
}
void BufferPoolClient::Impl::postBufferRelease(BufferId bufferId) {
std::lock_guard<std::mutex> lock(mReleasing.mLock);
mReleasing.mReleasingIds.push_back(bufferId);
mReleasing.mStatusChannel->postBufferRelease(
mConnectionId, mReleasing.mReleasingIds, mReleasing.mReleasedIds);
}
// TODO: revise ad-hoc posting data structure
bool BufferPoolClient::Impl::postSend(
BufferId bufferId, ConnectionId receiver,
TransactionId *transactionId, int64_t *timestampUs) {
bool ret = false;
bool needsSync = false;
{
std::lock_guard<std::mutex> lock(mReleasing.mLock);
*timestampUs = getTimestampNow();
*transactionId = (mConnectionId << 32) | mSeqId++;
// TODO: retry, add timeout, target?
ret = mReleasing.mStatusChannel->postBufferStatusMessage(
*transactionId, bufferId, BufferStatus::TRANSFER_TO, mConnectionId,
receiver, mReleasing.mReleasingIds, mReleasing.mReleasedIds);
needsSync = !mLocal && mReleasing.mStatusChannel->needsSync();
}
if (mValid && mLocal && mLocalConnection) {
mLocalConnection->cleanUp(false);
}
if (needsSync && mRemoteConnection) {
trySyncFromRemote();
}
return ret;
}
bool BufferPoolClient::Impl::postReceive(
BufferId bufferId, TransactionId transactionId, int64_t timestampUs) {
for (int i = 0; i < kPostMaxRetry; ++i) {
std::unique_lock<std::mutex> lock(mReleasing.mLock);
int64_t now = getTimestampNow();
if (timestampUs == 0 || now < timestampUs) {
bool result = mReleasing.mStatusChannel->postBufferStatusMessage(
transactionId, bufferId, BufferStatus::TRANSFER_FROM,
mConnectionId, -1, mReleasing.mReleasingIds,
mReleasing.mReleasedIds);
if (result) {
return true;
}
lock.unlock();
std::this_thread::yield();
} else {
mReleasing.mStatusChannel->postBufferStatusMessage(
transactionId, bufferId, BufferStatus::TRANSFER_TIMEOUT,
mConnectionId, -1, mReleasing.mReleasingIds,
mReleasing.mReleasedIds);
return false;
}
}
return false;
}
bool BufferPoolClient::Impl::postReceiveResult(
BufferId bufferId, TransactionId transactionId, bool result, bool *needsSync) {
std::lock_guard<std::mutex> lock(mReleasing.mLock);
// TODO: retry, add timeout
bool ret = mReleasing.mStatusChannel->postBufferStatusMessage(
transactionId, bufferId,
result ? BufferStatus::TRANSFER_OK : BufferStatus::TRANSFER_ERROR,
mConnectionId, -1, mReleasing.mReleasingIds,
mReleasing.mReleasedIds);
*needsSync = !mLocal && mReleasing.mStatusChannel->needsSync();
return ret;
}
void BufferPoolClient::Impl::trySyncFromRemote() {
if (mRemoteSyncLock.try_lock()) {
bool needsSync = false;
{
std::lock_guard<std::mutex> lock(mReleasing.mLock);
needsSync = mReleasing.mStatusChannel->needsSync();
}
if (needsSync) {
TransactionId transactionId = (mConnectionId << 32);
BufferId bufferId = Connection::SYNC_BUFFERID;
Return<void> transResult = mRemoteConnection->fetch(
transactionId, bufferId,
[]
(ResultStatus outStatus, Buffer outBuffer) {
(void) outStatus;
(void) outBuffer;
});
if(!transResult.isOk()) {
ALOGD("sync from client %lld failed: bufferpool process died.",
(long long)mConnectionId);
}
}
mRemoteSyncLock.unlock();
}
}
// should have mCache.mLock
bool BufferPoolClient::Impl::syncReleased() {
std::lock_guard<std::mutex> lock(mReleasing.mLock);
if (mReleasing.mReleasingIds.size() > 0) {
mReleasing.mStatusChannel->postBufferRelease(
mConnectionId, mReleasing.mReleasingIds,
mReleasing.mReleasedIds);
}
if (mReleasing.mReleasedIds.size() > 0) {
for (BufferId& id: mReleasing.mReleasedIds) {
ALOGV("client release buffer %lld - %u", (long long)mConnectionId, id);
auto found = mCache.mBuffers.find(id);
if (found != mCache.mBuffers.end()) {
if (found->second->onCacheRelease()) {
mCache.decActive_l();
} else {
// should not happen!
ALOGW("client %lld cache release status inconsitent!",
(long long)mConnectionId);
}
} else {
// should not happen!
ALOGW("client %lld cache status inconsitent!", (long long)mConnectionId);
}
}
mReleasing.mReleasedIds.clear();
return true;
}
return false;
}
// should have mCache.mLock
void BufferPoolClient::Impl::evictCaches(bool clearCache) {
int64_t now = getTimestampNow();
if (now >= mLastEvictCacheUs + kCacheTtlUs || clearCache) {
size_t evicted = 0;
for (auto it = mCache.mBuffers.begin(); it != mCache.mBuffers.end();) {
if (!it->second->hasCache() && (it->second->expire() || clearCache)) {
it = mCache.mBuffers.erase(it);
++evicted;
} else {
++it;
}
}
ALOGV("cache count %lld : total %zu, active %d, evicted %zu",
(long long)mConnectionId, mCache.mBuffers.size(), mCache.mActive, evicted);
mLastEvictCacheUs = now;
}
}
ResultStatus BufferPoolClient::Impl::allocateBufferHandle(
const std::vector<uint8_t>& params, BufferId *bufferId,
native_handle_t** handle) {
if (mLocalConnection) {
const native_handle_t* allocHandle = nullptr;
ResultStatus status = mLocalConnection->allocate(
params, bufferId, &allocHandle);
if (status == ResultStatus::OK) {
*handle = native_handle_clone(allocHandle);
}
ALOGV("client allocate result %lld %d : %u clone %p",
(long long)mConnectionId, status == ResultStatus::OK,
*handle ? *bufferId : 0 , *handle);
return status;
}
return ResultStatus::CRITICAL_ERROR;
}
ResultStatus BufferPoolClient::Impl::fetchBufferHandle(
TransactionId transactionId, BufferId bufferId,
native_handle_t **handle) {
sp<IConnection> connection;
if (mLocal) {
connection = mLocalConnection;
} else {
connection = mRemoteConnection;
}
ResultStatus status;
Return<void> transResult = connection->fetch(
transactionId, bufferId,
[&status, &handle]
(ResultStatus outStatus, Buffer outBuffer) {
status = outStatus;
if (status == ResultStatus::OK) {
*handle = native_handle_clone(
outBuffer.buffer.getNativeHandle());
}
});
return transResult.isOk() ? status : ResultStatus::CRITICAL_ERROR;
}
BufferPoolClient::BufferPoolClient(const sp<Accessor> &accessor) {
mImpl = std::make_shared<Impl>(accessor);
}
BufferPoolClient::BufferPoolClient(const sp<IAccessor> &accessor) {
mImpl = std::make_shared<Impl>(accessor);
}
BufferPoolClient::~BufferPoolClient() {
// TODO: how to handle orphaned buffers?
}
bool BufferPoolClient::isValid() {
return mImpl && mImpl->isValid();
}
bool BufferPoolClient::isLocal() {
return mImpl && mImpl->isLocal();
}
bool BufferPoolClient::isActive(int64_t *lastTransactionUs, bool clearCache) {
if (!isValid()) {
*lastTransactionUs = 0;
return false;
}
return mImpl->isActive(lastTransactionUs, clearCache);
}
ConnectionId BufferPoolClient::getConnectionId() {
if (isValid()) {
return mImpl->getConnectionId();
}
return -1;
}
ResultStatus BufferPoolClient::getAccessor(sp<IAccessor> *accessor) {
if (isValid()) {
*accessor = mImpl->getAccessor();
return ResultStatus::OK;
}
return ResultStatus::CRITICAL_ERROR;
}
ResultStatus BufferPoolClient::allocate(
const std::vector<uint8_t> ¶ms,
native_handle_t **handle,
std::shared_ptr<BufferPoolData> *buffer) {
if (isValid()) {
return mImpl->allocate(params, handle, buffer);
}
return ResultStatus::CRITICAL_ERROR;
}
ResultStatus BufferPoolClient::receive(
TransactionId transactionId, BufferId bufferId, int64_t timestampUs,
native_handle_t **handle, std::shared_ptr<BufferPoolData> *buffer) {
if (isValid()) {
return mImpl->receive(transactionId, bufferId, timestampUs, handle, buffer);
}
return ResultStatus::CRITICAL_ERROR;
}
ResultStatus BufferPoolClient::postSend(
ConnectionId receiverId,
const std::shared_ptr<BufferPoolData> &buffer,
TransactionId *transactionId,
int64_t *timestampUs) {
if (isValid()) {
bool result = mImpl->postSend(
buffer->mId, receiverId, transactionId, timestampUs);
return result ? ResultStatus::OK : ResultStatus::CRITICAL_ERROR;
}
return ResultStatus::CRITICAL_ERROR;
}
} // namespace implementation
} // namespace V1_0
} // namespace bufferpool
} // namespace media
} // namespace hardware
} // namespace android
| 33.755961 | 90 | 0.586796 | Dreadwyrm |
d713dc8c43bf2828009f01f1f6874c83dccf151f | 16,642 | cpp | C++ | src/ripple/protocol/impl/Feature.cpp | shichengripple001/rippled | 7c66747d27869f9f3c96617bd4227038f1fa92b8 | [
"ISC"
] | null | null | null | src/ripple/protocol/impl/Feature.cpp | shichengripple001/rippled | 7c66747d27869f9f3c96617bd4227038f1fa92b8 | [
"ISC"
] | null | null | null | src/ripple/protocol/impl/Feature.cpp | shichengripple001/rippled | 7c66747d27869f9f3c96617bd4227038f1fa92b8 | [
"ISC"
] | null | null | null | //------------------------------------------------------------------------------
/*
This file is part of rippled: https://github.com/ripple/rippled
Copyright (c) 2012, 2013 Ripple Labs Inc.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
//==============================================================================
#include <ripple/protocol/Feature.h>
#include <ripple/basics/Slice.h>
#include <ripple/basics/contract.h>
#include <ripple/protocol/digest.h>
#include <boost/container_hash/hash.hpp>
#include <boost/multi_index/hashed_index.hpp>
#include <boost/multi_index/key_extractors.hpp>
#include <boost/multi_index/random_access_index.hpp>
#include <boost/multi_index_container.hpp>
#include <cstring>
namespace ripple {
inline std::size_t
hash_value(ripple::uint256 const& feature)
{
std::size_t seed = 0;
using namespace boost;
for (auto const& n : feature)
hash_combine(seed, n);
return seed;
}
namespace {
enum class Supported : bool { no = false, yes };
// *NOTE*
//
// Features, or Amendments as they are called elsewhere, are enabled on the
// network at some specific time based on Validator voting. Features are
// enabled using run-time conditionals based on the state of the amendment.
// There is value in retaining that conditional code for some time after
// the amendment is enabled to make it simple to replay old transactions.
// However, once an Amendment has been enabled for, say, more than two years
// then retaining that conditional code has less value since it is
// uncommon to replay such old transactions.
//
// Starting in January of 2020 Amendment conditionals from before January
// 2018 are being removed. So replaying any ledger from before January
// 2018 needs to happen on an older version of the server code. There's
// a log message in Application.cpp that warns about replaying old ledgers.
//
// At some point in the future someone may wish to remove Amendment
// conditional code for Amendments that were enabled after January 2018.
// When that happens then the log message in Application.cpp should be
// updated.
class FeatureCollections
{
struct Feature
{
std::string name;
uint256 feature;
Feature() = delete;
explicit Feature(std::string const& name_, uint256 const& feature_)
: name(name_), feature(feature_)
{
}
// These structs are used by the `features` multi_index_container to
// provide access to the features collection by size_t index, string
// name, and uint256 feature identifier
struct byIndex
{
};
struct byName
{
};
struct byFeature
{
};
};
// Intermediate types to help with readability
template <class tag, typename Type, Type Feature::*PtrToMember>
using feature_hashed_unique = boost::multi_index::hashed_unique<
boost::multi_index::tag<tag>,
boost::multi_index::member<Feature, Type, PtrToMember>>;
// Intermediate types to help with readability
using feature_indexing = boost::multi_index::indexed_by<
boost::multi_index::random_access<
boost::multi_index::tag<Feature::byIndex>>,
feature_hashed_unique<Feature::byFeature, uint256, &Feature::feature>,
feature_hashed_unique<Feature::byName, std::string, &Feature::name>>;
// This multi_index_container provides access to the features collection by
// name, index, and uint256 feature identifier
boost::multi_index::multi_index_container<Feature, feature_indexing>
features;
std::map<std::string, DefaultVote> supported;
std::size_t upVotes = 0;
std::size_t downVotes = 0;
mutable std::atomic<bool> readOnly = false;
// These helper functions provide access to the features collection by name,
// index, and uint256 feature identifier, so the details of
// multi_index_container can be hidden
Feature const&
getByIndex(size_t i) const
{
if (i >= features.size())
LogicError("Invalid FeatureBitset index");
const auto& sequence = features.get<Feature::byIndex>();
return sequence[i];
}
size_t
getIndex(Feature const& feature) const
{
const auto& sequence = features.get<Feature::byIndex>();
auto const it_to = sequence.iterator_to(feature);
return it_to - sequence.begin();
}
Feature const*
getByFeature(uint256 const& feature) const
{
const auto& feature_index = features.get<Feature::byFeature>();
auto const feature_it = feature_index.find(feature);
return feature_it == feature_index.end() ? nullptr : &*feature_it;
}
Feature const*
getByName(std::string const& name) const
{
const auto& name_index = features.get<Feature::byName>();
auto const name_it = name_index.find(name);
return name_it == name_index.end() ? nullptr : &*name_it;
}
public:
FeatureCollections();
std::optional<uint256>
getRegisteredFeature(std::string const& name) const;
uint256
registerFeature(
std::string const& name,
Supported support,
DefaultVote vote);
/** Tell FeatureCollections when registration is complete. */
bool
registrationIsDone();
std::size_t
featureToBitsetIndex(uint256 const& f) const;
uint256 const&
bitsetIndexToFeature(size_t i) const;
std::string
featureToName(uint256 const& f) const;
/** Amendments that this server supports.
Whether they are enabled depends on the Rules defined in the validated
ledger */
std::map<std::string, DefaultVote> const&
supportedAmendments() const
{
return supported;
}
/** Amendments that this server WON'T vote for by default. */
std::size_t
numDownVotedAmendments() const
{
return downVotes;
}
/** Amendments that this server WILL vote for by default. */
std::size_t
numUpVotedAmendments() const
{
return upVotes;
}
};
//------------------------------------------------------------------------------
FeatureCollections::FeatureCollections()
{
features.reserve(ripple::detail::numFeatures);
}
std::optional<uint256>
FeatureCollections::getRegisteredFeature(std::string const& name) const
{
assert(readOnly);
Feature const* feature = getByName(name);
if (feature)
return feature->feature;
return std::nullopt;
}
void
check(bool condition, const char* logicErrorMessage)
{
if (!condition)
LogicError(logicErrorMessage);
}
uint256
FeatureCollections::registerFeature(
std::string const& name,
Supported support,
DefaultVote vote)
{
check(!readOnly, "Attempting to register a feature after startup.");
check(
support == Supported::yes || vote == DefaultVote::no,
"Invalid feature parameters. Must be supported to be up-voted.");
Feature const* i = getByName(name);
if (!i)
{
// If this check fails, and you just added a feature, increase the
// numFeatures value in Feature.h
check(
features.size() < detail::numFeatures,
"More features defined than allocated. Adjust numFeatures in "
"Feature.h.");
auto const f = sha512Half(Slice(name.data(), name.size()));
features.emplace_back(name, f);
if (support == Supported::yes)
{
supported.emplace(name, vote);
if (vote == DefaultVote::yes)
++upVotes;
else
++downVotes;
}
check(
upVotes + downVotes == supported.size(),
"Feature counting logic broke");
check(
supported.size() <= features.size(),
"More supported features than defined features");
return f;
}
else
// Each feature should only be registered once
LogicError("Duplicate feature registration");
}
/** Tell FeatureCollections when registration is complete. */
bool
FeatureCollections::registrationIsDone()
{
readOnly = true;
return true;
}
size_t
FeatureCollections::featureToBitsetIndex(uint256 const& f) const
{
assert(readOnly);
Feature const* feature = getByFeature(f);
if (!feature)
LogicError("Invalid Feature ID");
return getIndex(*feature);
}
uint256 const&
FeatureCollections::bitsetIndexToFeature(size_t i) const
{
assert(readOnly);
Feature const& feature = getByIndex(i);
return feature.feature;
}
std::string
FeatureCollections::featureToName(uint256 const& f) const
{
assert(readOnly);
Feature const* feature = getByFeature(f);
return feature ? feature->name : to_string(f);
}
static FeatureCollections featureCollections;
} // namespace
/** Amendments that this server supports.
Whether they are enabled depends on the Rules defined in the validated
ledger */
std::map<std::string, DefaultVote> const&
detail::supportedAmendments()
{
return featureCollections.supportedAmendments();
}
/** Amendments that this server won't vote for by default. */
std::size_t
detail::numDownVotedAmendments()
{
return featureCollections.numDownVotedAmendments();
}
/** Amendments that this server will vote for by default. */
std::size_t
detail::numUpVotedAmendments()
{
return featureCollections.numUpVotedAmendments();
}
//------------------------------------------------------------------------------
std::optional<uint256>
getRegisteredFeature(std::string const& name)
{
return featureCollections.getRegisteredFeature(name);
}
uint256
registerFeature(std::string const& name, Supported support, DefaultVote vote)
{
return featureCollections.registerFeature(name, support, vote);
}
// Retired features are in the ledger and have no code controlled by the
// feature. They need to be supported, but do not need to be voted on.
uint256
retireFeature(std::string const& name)
{
return registerFeature(name, Supported::yes, DefaultVote::no);
}
/** Tell FeatureCollections when registration is complete. */
bool
registrationIsDone()
{
return featureCollections.registrationIsDone();
}
size_t
featureToBitsetIndex(uint256 const& f)
{
return featureCollections.featureToBitsetIndex(f);
}
uint256
bitsetIndexToFeature(size_t i)
{
return featureCollections.bitsetIndexToFeature(i);
}
std::string
featureToName(uint256 const& f)
{
return featureCollections.featureToName(f);
}
#pragma push_macro("REGISTER_FEATURE")
#undef REGISTER_FEATURE
/**
Takes the name of a feature, whether it's supported, and the default vote. Will
register the feature, and create a variable whose name is "feature" plus the
feature name.
*/
#define REGISTER_FEATURE(fName, supported, defaultvote) \
uint256 const feature##fName = \
registerFeature(#fName, supported, defaultvote)
#pragma push_macro("REGISTER_FIX")
#undef REGISTER_FIX
/**
Takes the name of a feature, whether it's supported, and the default vote. Will
register the feature, and create a variable whose name is the unmodified feature
name.
*/
#define REGISTER_FIX(fName, supported, defaultvote) \
uint256 const fName = registerFeature(#fName, supported, defaultvote)
// clang-format off
// All known amendments must be registered either here or below with the
// "retired" amendments
REGISTER_FEATURE(OwnerPaysFee, Supported::no, DefaultVote::no);
REGISTER_FEATURE(Flow, Supported::yes, DefaultVote::yes);
REGISTER_FEATURE(FlowCross, Supported::yes, DefaultVote::yes);
REGISTER_FEATURE(CryptoConditionsSuite, Supported::yes, DefaultVote::no);
REGISTER_FIX (fix1513, Supported::yes, DefaultVote::yes);
REGISTER_FEATURE(DepositAuth, Supported::yes, DefaultVote::yes);
REGISTER_FEATURE(Checks, Supported::yes, DefaultVote::yes);
REGISTER_FIX (fix1571, Supported::yes, DefaultVote::yes);
REGISTER_FIX (fix1543, Supported::yes, DefaultVote::yes);
REGISTER_FIX (fix1623, Supported::yes, DefaultVote::yes);
REGISTER_FEATURE(DepositPreauth, Supported::yes, DefaultVote::yes);
// Use liquidity from strands that consume max offers, but mark as dry
REGISTER_FIX (fix1515, Supported::yes, DefaultVote::yes);
REGISTER_FIX (fix1578, Supported::yes, DefaultVote::yes);
REGISTER_FEATURE(MultiSignReserve, Supported::yes, DefaultVote::yes);
REGISTER_FIX (fixTakerDryOfferRemoval, Supported::yes, DefaultVote::yes);
REGISTER_FIX (fixMasterKeyAsRegularKey, Supported::yes, DefaultVote::yes);
REGISTER_FIX (fixCheckThreading, Supported::yes, DefaultVote::yes);
REGISTER_FIX (fixPayChanRecipientOwnerDir, Supported::yes, DefaultVote::yes);
REGISTER_FEATURE(DeletableAccounts, Supported::yes, DefaultVote::yes);
// fixQualityUpperBound should be activated before FlowCross
REGISTER_FIX (fixQualityUpperBound, Supported::yes, DefaultVote::yes);
REGISTER_FEATURE(RequireFullyCanonicalSig, Supported::yes, DefaultVote::yes);
// fix1781: XRPEndpointSteps should be included in the circular payment check
REGISTER_FIX (fix1781, Supported::yes, DefaultVote::yes);
REGISTER_FEATURE(HardenedValidations, Supported::yes, DefaultVote::yes);
REGISTER_FIX (fixAmendmentMajorityCalc, Supported::yes, DefaultVote::yes);
REGISTER_FEATURE(NegativeUNL, Supported::yes, DefaultVote::no);
REGISTER_FEATURE(TicketBatch, Supported::yes, DefaultVote::yes);
REGISTER_FEATURE(FlowSortStrands, Supported::yes, DefaultVote::yes);
REGISTER_FIX (fixSTAmountCanonicalize, Supported::yes, DefaultVote::yes);
REGISTER_FIX (fixRmSmallIncreasedQOffers, Supported::yes, DefaultVote::yes);
REGISTER_FEATURE(CheckCashMakesTrustLine, Supported::yes, DefaultVote::no);
REGISTER_FEATURE(NonFungibleTokensV1, Supported::yes, DefaultVote::no);
// The following amendments have been active for at least two years. Their
// pre-amendment code has been removed and the identifiers are deprecated.
// All known amendments and amendments that may appear in a validated
// ledger must be registered either here or above with the "active" amendments
[[deprecated("The referenced amendment has been retired"), maybe_unused]]
uint256 const
retiredMultiSign = retireFeature("MultiSign"),
retiredTrustSetAuth = retireFeature("TrustSetAuth"),
retiredFeeEscalation = retireFeature("FeeEscalation"),
retiredPayChan = retireFeature("PayChan"),
retiredCryptoConditions = retireFeature("CryptoConditions"),
retiredTickSize = retireFeature("TickSize"),
retiredFix1368 = retireFeature("fix1368"),
retiredEscrow = retireFeature("Escrow"),
retiredFix1373 = retireFeature("fix1373"),
retiredEnforceInvariants = retireFeature("EnforceInvariants"),
retiredSortedDirectories = retireFeature("SortedDirectories"),
retiredFix1201 = retireFeature("fix1201"),
retiredFix1512 = retireFeature("fix1512"),
retiredFix1523 = retireFeature("fix1523"),
retiredFix1528 = retireFeature("fix1528");
// clang-format on
#undef REGISTER_FIX
#pragma pop_macro("REGISTER_FIX")
#undef REGISTER_FEATURE
#pragma pop_macro("REGISTER_FEATURE")
// All of the features should now be registered, since variables in a cpp file
// are initialized from top to bottom.
//
// Use initialization of one final static variable to set
// featureCollections::readOnly.
[[maybe_unused]] static const bool readOnlySet =
featureCollections.registrationIsDone();
} // namespace ripple
| 34.598753 | 82 | 0.678584 | shichengripple001 |
d714c2251c0a9280b80fdb45f976501109465eef | 21,022 | cpp | C++ | third_party/omr/compiler/x/amd64/codegen/OMRTreeEvaluator.cpp | xiacijie/omr-wala-linkage | a1aff7aef9ed131a45555451abde4615a04412c1 | [
"Apache-2.0"
] | null | null | null | third_party/omr/compiler/x/amd64/codegen/OMRTreeEvaluator.cpp | xiacijie/omr-wala-linkage | a1aff7aef9ed131a45555451abde4615a04412c1 | [
"Apache-2.0"
] | null | null | null | third_party/omr/compiler/x/amd64/codegen/OMRTreeEvaluator.cpp | xiacijie/omr-wala-linkage | a1aff7aef9ed131a45555451abde4615a04412c1 | [
"Apache-2.0"
] | null | null | null | /*******************************************************************************
* Copyright (c) 2000, 2019 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
* distribution and is available at http://eclipse.org/legal/epl-2.0
* or the Apache License, Version 2.0 which accompanies this distribution
* and is available at https://www.apache.org/licenses/LICENSE-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the
* Eclipse Public License, v. 2.0 are satisfied: GNU General Public License,
* version 2 with the GNU Classpath Exception [1] and GNU General Public
* License, version 2 with the OpenJDK Assembly Exception [2].
*
* [1] https://www.gnu.org/software/classpath/license.html
* [2] http://openjdk.java.net/legal/assembly-exception.html
*
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception
*******************************************************************************/
#include "codegen/OMRTreeEvaluator.hpp"
#include <stddef.h>
#include <stdint.h>
#include "codegen/CodeGenerator.hpp"
#include "codegen/FrontEnd.hpp"
#include "codegen/LiveRegister.hpp"
#include "codegen/Machine.hpp"
#include "codegen/MemoryReference.hpp"
#include "codegen/RealRegister.hpp"
#include "codegen/Register.hpp"
#include "codegen/RegisterConstants.hpp"
#include "codegen/RegisterDependency.hpp"
#include "codegen/TreeEvaluator.hpp"
#include "compile/Compilation.hpp"
#include "env/CompilerEnv.hpp"
#include "env/TRMemory.hpp"
#include "il/DataTypes.hpp"
#include "il/ILOpCodes.hpp"
#include "il/ILOps.hpp"
#include "il/Node.hpp"
#include "il/Node_inlines.hpp"
#include "il/Symbol.hpp"
#include "il/SymbolReference.hpp"
#include "il/symbol/LabelSymbol.hpp"
#include "infra/Assert.hpp"
#include "infra/List.hpp"
#include "ras/Debug.hpp"
#include "x/codegen/ConstantDataSnippet.hpp"
#include "x/codegen/OutlinedInstructions.hpp"
#include "x/codegen/X86Evaluator.hpp"
#include "x/codegen/X86Instruction.hpp"
#include "x/codegen/X86Ops.hpp"
TR::Register *OMR::X86::AMD64::TreeEvaluator::aconstEvaluator(TR::Node *node, TR::CodeGenerator *cg)
{
TR::Register *targetRegister = TR::TreeEvaluator::loadConstant(node, node->getLongInt(), TR_RematerializableAddress, cg);
node->setRegister(targetRegister);
return targetRegister;
}
TR::Register *OMR::X86::AMD64::TreeEvaluator::lconstEvaluator(TR::Node *node, TR::CodeGenerator *cg)
{
TR::Register *targetRegister = TR::TreeEvaluator::loadConstant(node, node->getLongInt(), TR_RematerializableLong, cg);
node->setRegister(targetRegister);
return targetRegister;
}
// TODO:AMD64: Could this be combined with istoreEvaluator without too much ugliness?
TR::Register *OMR::X86::AMD64::TreeEvaluator::lstoreEvaluator(TR::Node *node, TR::CodeGenerator *cg)
{
TR::Node *valueChild;
TR::Compilation* comp = cg->comp();
if (node->getOpCode().isIndirect())
valueChild = node->getSecondChild();
else
valueChild = node->getFirstChild();
// Handle special cases
//
if (valueChild->getRegister() == NULL &&
valueChild->getReferenceCount() == 1)
{
// Special case storing a double value into long variable
//
if (valueChild->getOpCodeValue() == TR::dbits2l &&
!valueChild->normalizeNanValues())
{
if (node->getOpCode().isIndirect())
{
node->setChild(1, valueChild->getFirstChild());
TR::Node::recreate(node, TR::dstorei);
TR::TreeEvaluator::floatingPointStoreEvaluator(node, cg);
node->setChild(1, valueChild);
TR::Node::recreate(node, TR::lstorei);
}
else
{
node->setChild(0, valueChild->getFirstChild());
TR::Node::recreate(node, TR::dstore);
TR::TreeEvaluator::floatingPointStoreEvaluator(node, cg);
node->setChild(0, valueChild);
TR::Node::recreate(node, TR::lstore);
}
cg->decReferenceCount(valueChild);
return NULL;
}
}
return TR::TreeEvaluator::integerStoreEvaluator(node, cg);
}
// also handles ilload
TR::Register *OMR::X86::AMD64::TreeEvaluator::lloadEvaluator(TR::Node *node, TR::CodeGenerator *cg)
{
TR::MemoryReference *sourceMR = generateX86MemoryReference(node, cg);
TR::Register *reg = TR::TreeEvaluator::loadMemory(node, sourceMR, TR_RematerializableLong, node->getOpCode().isIndirect(), cg);
reg->setMemRef(sourceMR);
node->setRegister(reg);
sourceMR->decNodeReferenceCounts(cg);
return reg;
}
TR::Register *OMR::X86::AMD64::TreeEvaluator::landEvaluator(TR::Node *node, TR::CodeGenerator *cg)
{
return TR::TreeEvaluator::logicalEvaluator(node, _logicalOpPackage[landOpPackage], cg);
}
TR::Register *OMR::X86::AMD64::TreeEvaluator::lorEvaluator(TR::Node *node, TR::CodeGenerator *cg)
{
return TR::TreeEvaluator::logicalEvaluator(node, _logicalOpPackage[lorOpPackage], cg);
}
TR::Register *OMR::X86::AMD64::TreeEvaluator::lxorEvaluator(TR::Node *node, TR::CodeGenerator *cg)
{
return TR::TreeEvaluator::logicalEvaluator(node, _logicalOpPackage[lxorOpPackage], cg);
}
TR::Register *OMR::X86::AMD64::TreeEvaluator::i2lEvaluator(TR::Node *node, TR::CodeGenerator *cg)
{
TR::Compilation *comp = cg->comp();
if (node->getFirstChild()->getOpCode().isLoadConst())
{
TR::Register *targetRegister = cg->allocateRegister();
generateRegImmInstruction(MOV8RegImm4, node, targetRegister, node->getFirstChild()->getInt(), cg);
node->setRegister(targetRegister);
cg->decReferenceCount(node->getFirstChild());
return targetRegister;
}
else
{
// In theory, because iRegStore has chosen to disregard needsSignExtension,
// we must disregard skipSignExtension here for correctness.
//
// However, in fact, it is actually safe to obey skipSignExtension so
// long as the optimizer only uses it on nodes known to be non-negative
// when the i2l occurs. We do already have isNonNegative for that
// purpose, but it may not always be set by the optimizer if a node known
// to be non-negative at one point in a block is commoned up above the
// BNDCHK or branch that determines the node's non-negativity. The
// codegen does set the flag during tree evaluation, but the
// skipSignExtension flag is set by the optimizer with more global
// knowledge than the tree evaluator, so we will trust it.
//
TR_X86OpCodes regMemOpCode,regRegOpCode;
if( node->isNonNegative()
|| (node->skipSignExtension() && performTransformation(comp, "TREE EVALUATION: skipping sign extension on node %s despite lack of isNonNegative\n", comp->getDebug()->getName(node))))
{
// We prefer these plain (zero-extending) opcodes because the analyser can often eliminate them
//
regMemOpCode = L4RegMem;
regRegOpCode = MOVZXReg8Reg4;
}
else
{
regMemOpCode = MOVSXReg8Mem4;
regRegOpCode = MOVSXReg8Reg4;
}
return TR::TreeEvaluator::conversionAnalyser(node, regMemOpCode, regRegOpCode, cg);
}
}
TR::Register *OMR::X86::AMD64::TreeEvaluator::l2iEvaluator(TR::Node *node, TR::CodeGenerator *cg)
{
TR::Node *child = node->getFirstChild();
TR::Register *reg = cg->evaluate(child);
if (child->getReferenceCount() > 1)
{
// This catches two scenarios:
//
// 1) A longClobberEvaluate (or any other register-clobbering logic) on
// the l2i node could see a refcount of 1, and hence won't make a copy.
// If child's refcount is more than 1, we do in fact need a copy, so we'd
// better do it here.
//
// 2) If the child is commoned, and the l2i node is also commoned, then
// we may end up with a situation where the last evaluation of the child
// is a clobberEvaluate. By that time, the child's refcount would be 1,
// so no copy is made, and the register would be clobbered. Therefore,
// the l2i node can't return that same register, or else the other uses
// of the node will end up getting the clobbered value.
//
// Note that case 2 is conservative, in that it presumes that the child's
// register will be clobbered by another node. If this does not occur,
// then the copy we're about to make is unnecessary.
//
TR::Register *childReg = reg;
reg = cg->allocateRegister();
// to support signExtension in GRA, need to preserve upper word
// in this move
generateRegRegInstruction(MOV8RegReg, node, reg, childReg, cg);
}
node->setRegister(reg);
cg->decReferenceCount(child);
if (cg->enableRegisterInterferences() && node->getOpCode().getSize() == 1)
cg->getLiveRegisters(TR_GPR)->setByteRegisterAssociation(node->getRegister());
return reg;
}
TR::Register *OMR::X86::AMD64::TreeEvaluator::iu2lEvaluator(TR::Node *node, TR::CodeGenerator *cg)
{
if (node->getFirstChild()->getOpCode().isLoadConst())
{
TR::Register *targetRegister = cg->allocateRegister();
generateRegImmInstruction(MOV4RegImm4, node, targetRegister, node->getFirstChild()->getInt(), cg); // implicitly zero extended
node->setRegister(targetRegister);
cg->decReferenceCount(node->getFirstChild());
return targetRegister;
}
else
return TR::TreeEvaluator::conversionAnalyser(node, L4RegMem, MOVZXReg8Reg4, cg); // This zero-extends on AMD64
}
TR::Register *OMR::X86::AMD64::TreeEvaluator::b2lEvaluator(TR::Node *node, TR::CodeGenerator *cg)
{
return TR::TreeEvaluator::conversionAnalyser(node, MOVSXReg8Mem1, MOVSXReg8Reg1, cg);
}
TR::Register *OMR::X86::AMD64::TreeEvaluator::bu2lEvaluator(TR::Node *node, TR::CodeGenerator *cg)
{
return TR::TreeEvaluator::conversionAnalyser(node, MOVZXReg8Mem1, MOVZXReg8Reg1, cg);
}
TR::Register *OMR::X86::AMD64::TreeEvaluator::s2lEvaluator(TR::Node *node, TR::CodeGenerator *cg)
{
return TR::TreeEvaluator::conversionAnalyser(node, MOVSXReg8Mem2, MOVSXReg8Reg2, cg);
}
TR::Register *OMR::X86::AMD64::TreeEvaluator::su2lEvaluator(TR::Node *node, TR::CodeGenerator *cg)
{
return TR::TreeEvaluator::conversionAnalyser(node, MOVZXReg8Mem2, MOVZXReg8Reg2, cg);
}
TR::Register *OMR::X86::AMD64::TreeEvaluator::c2lEvaluator(TR::Node *node, TR::CodeGenerator *cg)
{
return TR::TreeEvaluator::conversionAnalyser(node, MOVZXReg8Mem2, MOVZXReg8Reg2, cg);
}
TR::Register *OMR::X86::AMD64::TreeEvaluator::lcmpEvaluator(TR::Node *node, TR::CodeGenerator *cg)
{
TR::Node *firstChild = node->getFirstChild();
TR::Node *secondChild = node->getSecondChild();
TR::Register *leftRegister = cg->evaluate(firstChild);
TR::Register *rightRegister = cg->evaluate(secondChild);
// Compare left and right operands, all finished with the operands after this.
generateRegRegInstruction(CMP8RegReg, node, leftRegister, rightRegister, cg);
cg->decReferenceCount(firstChild);
cg->decReferenceCount(secondChild);
TR::Register *isLessThanReg = cg->allocateRegister();
TR::Register *isNotEqualReg = cg->allocateRegister();
cg->getLiveRegisters(TR_GPR)->setByteRegisterAssociation(isLessThanReg);
cg->getLiveRegisters(TR_GPR)->setByteRegisterAssociation(isNotEqualReg);
// The state of things in each possible case after each instruction:
// left < right left = right left > right
// Processor flags: NE=1 LT=1 NE=0 LT=0 NE=1 LT=0
generateRegInstruction(SETL1Reg, node, isLessThanReg, cg);
// isLessThanReg: 00000001 00000000 00000000
generateRegInstruction(SETNE1Reg, node, isNotEqualReg, cg);
// isNotEqualReg: 00000001 00000000 00000001
generateRegInstruction(NEG1Reg, node, isLessThanReg, cg);
// isLessThanReg: 11111111 00000000 00000000
generateRegRegInstruction(OR1RegReg, node, isNotEqualReg, isLessThanReg, cg);
// isNotEqualReg: 11111111 00000000 00000001
generateRegRegInstruction(MOVSXReg4Reg1, node, isNotEqualReg, isNotEqualReg, cg);
node->setRegister(isNotEqualReg);
cg->stopUsingRegister(isLessThanReg);
return isNotEqualReg;
}
static TR::Register *l2fd(TR::Node *node, TR::RealRegister *target, TR_X86OpCodes opRegMem8, TR_X86OpCodes opRegReg8, TR::CodeGenerator *cg)
{
TR::Node *child = node->getFirstChild();
TR::MemoryReference *tempMR;
TR_ASSERT(cg->useSSEForSinglePrecision(), "assertion failure");
if (child->getRegister() == NULL &&
child->getReferenceCount() == 1 &&
child->getOpCode().isLoadVar())
{
tempMR = generateX86MemoryReference(child, cg);
generateRegMemInstruction(opRegMem8, node, target, tempMR, cg);
tempMR->decNodeReferenceCounts(cg);
}
else
{
TR::Register *intReg = cg->evaluate(child);
generateRegRegInstruction(opRegReg8, node, target, intReg, cg);
cg->decReferenceCount(child);
}
node->setRegister(target);
return target;
}
TR::Register *OMR::X86::AMD64::TreeEvaluator::l2fEvaluator(TR::Node *node, TR::CodeGenerator *cg)
{
return l2fd(node, toRealRegister(cg->allocateSinglePrecisionRegister(TR_FPR)), CVTSI2SSRegMem8, CVTSI2SSRegReg8, cg);
}
TR::Register *OMR::X86::AMD64::TreeEvaluator::l2dEvaluator(TR::Node *node, TR::CodeGenerator *cg)
{
return l2fd(node, toRealRegister(cg->allocateRegister(TR_FPR)), CVTSI2SDRegMem8, CVTSI2SDRegReg8, cg);
}
TR::Register *OMR::X86::AMD64::TreeEvaluator::lbits2dEvaluator(TR::Node *node, TR::CodeGenerator *cg)
{
// TODO:AMD64: Peepholing
TR::Node *child = node->getFirstChild();
TR::Register *sreg = cg->evaluate(child);
TR::Register *treg = cg->allocateRegister(TR_FPR);
generateRegRegInstruction(MOVQRegReg8, node, treg, sreg, cg);
node->setRegister(treg);
cg->decReferenceCount(child);
return treg;
}
TR::Register *OMR::X86::AMD64::TreeEvaluator::dbits2lEvaluator(TR::Node *node, TR::CodeGenerator *cg)
{
// TODO:AMD64: Peepholing
TR::Node *child = node->getFirstChild();
TR::Register *sreg = cg->evaluate(child);
TR::Register *treg = cg->allocateRegister(TR_GPR);
generateRegRegInstruction(MOVQReg8Reg, node, treg, sreg, cg);
if (node->normalizeNanValues())
{
static char *disableFastNormalizeNaNs = feGetEnv("TR_disableFastNormalizeNaNs");
if (disableFastNormalizeNaNs)
{
// This one is not clever, but it is simple, and it's based directly
// on the IA32 version which is known to work, so is safer.
//
TR::RegisterDependencyConditions *deps = generateRegisterDependencyConditions((uint8_t)0, (uint8_t)1, cg);
deps->addPostCondition(treg, TR::RealRegister::NoReg, cg);
TR::MemoryReference* nan1MR = generateX86MemoryReference(cg->findOrCreate8ByteConstant(node, DOUBLE_NAN_1_LOW), cg);
TR::MemoryReference* nan2MR = generateX86MemoryReference(cg->findOrCreate8ByteConstant(node, DOUBLE_NAN_2_LOW), cg);
TR::LabelSymbol *startLabel = TR::LabelSymbol::create(cg->trHeapMemory(),cg);
TR::LabelSymbol *normalizeLabel = TR::LabelSymbol::create(cg->trHeapMemory(),cg);
TR::LabelSymbol *endLabel = TR::LabelSymbol::create(cg->trHeapMemory(),cg);
startLabel->setStartInternalControlFlow();
endLabel ->setEndInternalControlFlow();
generateLabelInstruction( LABEL, node, startLabel, cg);
generateRegMemInstruction( CMP8RegMem, node, treg, nan1MR, cg);
generateLabelInstruction( JGE4, node, normalizeLabel, cg);
generateRegMemInstruction( CMP8RegMem, node, treg, nan2MR, cg);
generateLabelInstruction( JB4, node, endLabel, cg);
generateLabelInstruction( LABEL, node, normalizeLabel, cg);
generateRegImm64Instruction( MOV8RegImm64, node, treg, DOUBLE_NAN, cg);
generateLabelInstruction( LABEL, node, endLabel, deps, cg);
}
else
{
// A bunch of bookkeeping
//
uint64_t nanDetector = DOUBLE_NAN_2_LOW;
TR::RegisterDependencyConditions *internalControlFlowDeps = generateRegisterDependencyConditions((uint8_t)0, (uint8_t)1, cg);
internalControlFlowDeps->addPostCondition(treg, TR::RealRegister::NoReg, cg);
TR::RegisterDependencyConditions *helperDeps = generateRegisterDependencyConditions((uint8_t)1, (uint8_t)1, cg);
helperDeps->addPreCondition( treg, TR::RealRegister::eax, cg);
helperDeps->addPostCondition(treg, TR::RealRegister::eax, cg);
TR::MemoryReference* nanDetectorMR = generateX86MemoryReference(cg->findOrCreate8ByteConstant(node, nanDetector), cg);
TR::LabelSymbol *startLabel = TR::LabelSymbol::create(cg->trHeapMemory(),cg);
TR::LabelSymbol *slowPathLabel = TR::LabelSymbol::create(cg->trHeapMemory(),cg);
TR::LabelSymbol *normalizeLabel = TR::LabelSymbol::create(cg->trHeapMemory(),cg);
TR::LabelSymbol *endLabel = TR::LabelSymbol::create(cg->trHeapMemory(),cg);
startLabel->setStartInternalControlFlow();
endLabel ->setEndInternalControlFlow();
// Fast path: if subtracting nanDetector leaves CF=0 or OF=1, then it
// must be a NaN.
//
generateLabelInstruction( LABEL, node, startLabel, cg);
generateRegMemInstruction( CMP8RegMem, node, treg, nanDetectorMR, cg);
generateLabelInstruction( JAE4, node, slowPathLabel, cg);
generateLabelInstruction( JO4, node, slowPathLabel, cg);
// Slow path
//
{
TR_OutlinedInstructionsGenerator og(slowPathLabel, node, cg);
generateRegImm64Instruction(MOV8RegImm64, node, treg, DOUBLE_NAN, cg);
generateLabelInstruction(JMP4, node, endLabel, cg);
}
// Merge point
//
generateLabelInstruction(LABEL, node, endLabel, internalControlFlowDeps, cg);
}
}
node->setRegister(treg);
cg->decReferenceCount(child);
return treg;
}
TR::Register *OMR::X86::AMD64::TreeEvaluator::awrtbarEvaluator(TR::Node *node, TR::CodeGenerator *cg)
{
// The wrtbar IL op represents a store with side effects.
// Currently we don't use the side effect node. So just evaluate it and decrement the reference count.
TR::Node *sideEffectNode = node->getSecondChild();
cg->evaluate(sideEffectNode);
cg->decReferenceCount(sideEffectNode);
// Delegate the evaluation of the remaining children and the store operation to the storeEvaluator.
return TR::TreeEvaluator::lstoreEvaluator(node, cg);
}
TR::Register *OMR::X86::AMD64::TreeEvaluator::awrtbariEvaluator(TR::Node *node, TR::CodeGenerator *cg)
{
// The wrtbar IL op represents a store with side effects.
// Currently we don't use the side effect node. So just evaluate it and decrement the reference count.
TR::Node *sideEffectNode = node->getThirdChild();
cg->evaluate(sideEffectNode);
cg->decReferenceCount(sideEffectNode);
// Delegate the evaluation of the remaining children and the store operation to the storeEvaluator.
return TR::TreeEvaluator::lstoreEvaluator(node, cg);
}
TR::Register *
OMR::X86::AMD64::TreeEvaluator::dwrtbarEvaluator(TR::Node *node, TR::CodeGenerator *cg)
{
// The wrtbar IL op represents a store with side effects.
// Currently we don't use the side effect node. So just evaluate it and decrement the reference count.
TR::Node *sideEffectNode = node->getSecondChild();
cg->evaluate(sideEffectNode);
cg->decReferenceCount(sideEffectNode);
// Delegate the evaluation of the remaining children and the store operation to the storeEvaluator.
return TR::TreeEvaluator::floatingPointStoreEvaluator(node, cg);
}
TR::Register *
OMR::X86::AMD64::TreeEvaluator::dwrtbariEvaluator(TR::Node *node, TR::CodeGenerator *cg)
{
// The wrtbar IL op represents a store with side effects.
// Currently we don't use the side effect node. So just evaluate it and decrement the reference count.
TR::Node *sideEffectNode = node->getThirdChild();
cg->evaluate(sideEffectNode);
cg->decReferenceCount(sideEffectNode);
// Delegate the evaluation of the remaining children and the store operation to the storeEvaluator.
return TR::TreeEvaluator::floatingPointStoreEvaluator(node, cg);
}
| 42.989775 | 191 | 0.678004 | xiacijie |
d7155c2cfe2603c3147c8afb64c2f3f056f2e349 | 486 | hpp | C++ | examples/boids3d/lightsource.hpp | patrick-oliveira/abcg | 729c5f2fcc860ff527d44bcfd91e331f8fa44f04 | [
"MIT"
] | null | null | null | examples/boids3d/lightsource.hpp | patrick-oliveira/abcg | 729c5f2fcc860ff527d44bcfd91e331f8fa44f04 | [
"MIT"
] | null | null | null | examples/boids3d/lightsource.hpp | patrick-oliveira/abcg | 729c5f2fcc860ff527d44bcfd91e331f8fa44f04 | [
"MIT"
] | null | null | null | #ifndef LIGHTSOURCE_HPP_
#define LIGHTSOURCE_HPP_
#include <glm/vec3.hpp>
#include "abcg.hpp"
#include <glm/vec3.hpp>
#include "boids.hpp"
class OpenGLWindow;
class Boids;
class LightSource {
public:
void update(float deltaTime);
private:
friend OpenGLWindow;
friend Boids;
float scale{0.10f};
float rotationAngle{1.00f};
glm::vec3 lightSourcePosition;
void setupLightSource();
};
#endif | 17.357143 | 39 | 0.623457 | patrick-oliveira |
d71574925a78477b2d29a37d5681e6b54443d587 | 1,066 | cpp | C++ | Piensa en C++/Vol1/C03/Menu.cpp | Gabroide/TextAdvenure | d2fc9b2ef21d66a17b9b716975087093c592abbc | [
"MIT"
] | null | null | null | Piensa en C++/Vol1/C03/Menu.cpp | Gabroide/TextAdvenure | d2fc9b2ef21d66a17b9b716975087093c592abbc | [
"MIT"
] | null | null | null | Piensa en C++/Vol1/C03/Menu.cpp | Gabroide/TextAdvenure | d2fc9b2ef21d66a17b9b716975087093c592abbc | [
"MIT"
] | null | null | null | //: C03:Menu.cpp
// Simple menu program demostrating
#include <iostream>
using namespace std;
int main()
{
char c;
while(true)
{
cout << "MAIN MENU: " << endl;
cout << "l: left, r: right, q: quit -> ";
cin >> c;
if(c == 'q')
break; // Out of "while(1)"
if(c == 'l')
{
cout << "LEFT MENU: " <<endl;
cout << "select a or b: ";
cin >> c;
if(c == 'a')
{
cout << "you chose 'a'" << endl;
continue; // Back to main menu
}
if(c == 'b')
{
cout << "you chose 'b'" << endl;
continue;
}
else
{
cout << "you didn't choose a or b!" << endl;
continue;
}
}
if(c == 'r')
{
cout << "RIGHT MENU: " << endl;
cout << "select c or d: ";
cin >> c;
if(c == 'c')
{
cout << "you chose 'c'" << endl;
continue;
}
if(c == 'd')
{
cout << "you chise 'd'" << endl;
continue;
}
else
{
cout << "you didn's choose c or d!" << endl;
continue;
}
}
else
cout << "you ust tyoe l or r or q!" << endl;
}
cout << "quitting menu..." << endl;
}///:~
| 16.4 | 48 | 0.454034 | Gabroide |
d71ad630401b00c0a2231611eae30719b376fbd1 | 9,460 | cpp | C++ | test/InputValidationTest.cpp | LuckyCode7/bowling | 9d00f5b2509a975143b73ef9460cd047f0bd3136 | [
"MIT"
] | null | null | null | test/InputValidationTest.cpp | LuckyCode7/bowling | 9d00f5b2509a975143b73ef9460cd047f0bd3136 | [
"MIT"
] | 33 | 2018-08-27T20:12:23.000Z | 2018-09-17T09:12:26.000Z | test/InputValidationTest.cpp | LuckyCode7/bowling | 9d00f5b2509a975143b73ef9460cd047f0bd3136 | [
"MIT"
] | 2 | 2018-08-28T12:05:55.000Z | 2018-08-30T14:45:14.000Z | #include <../inc/InputValidation.hpp>
#include <gtest/gtest.h>
struct InputValidationTest : public ::testing::Test
{
};
TEST_F(InputValidationTest,
check_if_substring_from_object_input_will_be_correct)
{
// GIVEN
InputValidation input("Player:x|--|4/|x|");
// WHEN call gestSubstring method
// THEN
ASSERT_EQ("x|--|4/|x|", input.getSubstring());
}
TEST_F(InputValidationTest, expect_false_when_there_is_no_players_name)
{
// GIVEN
InputValidation input(":x|");
// WHEN call checkInputData method
// THEN
EXPECT_FALSE(input.checkInputData());
}
TEST_F(InputValidationTest, expect_true_when_players_name_is_correct)
{
// GIVEN
InputValidation input("Mike:x|");
// WHEN call checkInputData method
// THEN
EXPECT_TRUE(input.checkInputData());
}
TEST_F(InputValidationTest, expect_true_when_there_are_two_sticks_around_x)
{
// GIVEN
InputValidation input("Mike:|x|");
// WHEN call checkInputData method
// THEN
EXPECT_FALSE(input.checkInputData());
}
TEST_F(InputValidationTest, expect_false_when_miss_is_before_strike)
{
// GIVEN
InputValidation input("Mike:-x|");
// WHEN call checkInputData method
// THEN
EXPECT_FALSE(input.checkInputData());
}
TEST_F(InputValidationTest, expect_false_when_there_is_no_stick_after_two_signs)
{
// GIVEN
InputValidation input("Mike:x|--");
// WHEN call checkInputData method
// THEN
EXPECT_FALSE(input.checkInputData());
}
TEST_F(InputValidationTest, expect_true_when_there_are_is_stick_after_two_signs)
{
// GIVEN
InputValidation input("Mike:X|--|");
// WHEN call checkInputData method
// THEN
EXPECT_TRUE(input.checkInputData());
}
TEST_F(InputValidationTest, expect_true_when_before_miss_is_correct_number)
{
// GIVEN
InputValidation input("Mike:x|5-|");
// WHEN call checkInputData method
// THEN
EXPECT_TRUE(input.checkInputData());
}
TEST_F(InputValidationTest, expect_false_when_after_stirke_is_miss)
{
// GIVEN
InputValidation input("Mike:x|x-|");
// WHEN call checkInputData method
// THEN
EXPECT_FALSE(input.checkInputData());
}
TEST_F(InputValidationTest, expect_false_when_spare_is_the_first_sign)
{
// GIVEN
InputValidation input("Mike:x|/-|");
// WHEN call checkInputData method
// THEN
EXPECT_FALSE(input.checkInputData());
}
TEST_F(InputValidationTest, expect_false_when_two_sticks_are_too_early)
{
// GIVEN
InputValidation input("Mike:x||-|");
// WHEN call checkInputData method
// THEN
EXPECT_FALSE(input.checkInputData());
}
TEST_F(InputValidationTest, expect_true_when_spare_is_after_miss)
{
// GIVEN
InputValidation input("Mike:x|6-|-/|");
// WHEN call checkInputData method
// THEN
EXPECT_TRUE(input.checkInputData());
}
TEST_F(InputValidationTest, expect_false_when_there_is_number_less_then_one)
{
// GIVEN
InputValidation input("Mike:x|0-|-/|");
// WHEN call checkInputData method
// THEN
EXPECT_FALSE(input.checkInputData());
}
TEST_F(InputValidationTest, expect_false_when_there_is_undefined_sign)
{
// GIVEN
InputValidation input("Mike:x|k-|-/|");
// WHEN call checkInputData method
// THEN
EXPECT_FALSE(input.checkInputData());
}
TEST_F(InputValidationTest, expect_false_when_spare_is_after_strike)
{
// GIVEN
InputValidation input("Mike:x|--|x/|");
// WHEN call checkInputData method
// THEN
EXPECT_FALSE(input.checkInputData());
}
TEST_F(InputValidationTest, epect_false_when_spare_is_the_first_sign_in_frame)
{
// GIVEN
InputValidation input("Mike:x|--|//|");
// WHEN call checkInputData method
// THEN
EXPECT_FALSE(input.checkInputData());
}
TEST_F(InputValidationTest,
expect_true_when_spare_is_after_number_less_then_ten)
{
// GIVEN
InputValidation input("Mike:x|--|9/|");
// WHEN call checkInputData method
// THEN
EXPECT_TRUE(input.checkInputData());
}
TEST_F(InputValidationTest,
expect_false_when_sum_of_numbers_is_bigger_then_nine)
{
// GIVEN
InputValidation input("Mike:x|--|9/|x|-3|19|");
// WHEN call checkInputData method
// THEN
EXPECT_FALSE(input.checkInputData());
}
TEST_F(InputValidationTest, expect_true_when_sum_of_numbers_is_less_then_nine)
{
// GIVEN
InputValidation input("Mike:x|--|9/|X|-3|18|");
// WHEN call checkInputData method
// THEN
EXPECT_TRUE(input.checkInputData());
}
TEST_F(InputValidationTest,
expect_false_when_there_are_two_sticks_in_incorrect_place)
{
// GIVEN
InputValidation input("Mike:x|--|9/|X|-3|18|x|-3||");
// WHEN call checkInputData method
// THEN
EXPECT_FALSE(input.checkInputData());
}
TEST_F(InputValidationTest,
expect_false_when_there_are_no_two_sticks_in_correct_place)
{
// GIVEN
InputValidation input("Mike:x|--|9/|x|-3|18|x|-3|5/|--|");
// WHEN call checkInputData method
// THEN
EXPECT_FALSE(input.checkInputData());
}
TEST_F(InputValidationTest,
expect_true_when_there_are_two_sticks_in_correct_place)
{
// GIVEN
InputValidation input("Mike:x|--|9/|x|-3|18|x|-3|5/|--||");
// WHEN call checkInputData method
// THEN
EXPECT_TRUE(input.checkInputData());
}
TEST_F(InputValidationTest, expect_true_when_spare_is_before_two_sticks)
{
// GIVEN
InputValidation input("Mike:x|--|9/|x|-3|18|x|-3|5/|-/||");
// WHEN call checkInputData method
// THEN
EXPECT_TRUE(input.checkInputData());
}
TEST_F(InputValidationTest,
expect_true_when_there_is_strike_after_two_sticks_and_spare)
{
// GIVEN
InputValidation input("Mike:x|--|9/|x|-3|18|x|-3|5/|-/||x");
// WHEN call checkInputData method
// THEN
EXPECT_TRUE(input.checkInputData());
}
TEST_F(InputValidationTest,
expect_true_when_there_is_one_miss_after_two_sticks_and_spare)
{
// GIVEN
InputValidation input("Mike:x|--|9/|x|-3|18|x|-3|5/|-/||-");
// WHEN call checkInputData method
// THEN
EXPECT_TRUE(input.checkInputData());
}
TEST_F(InputValidationTest,
expect_true_when_there_is_number_after_two_sticks_and_spare)
{
// GIVEN
InputValidation input("Mike:x|--|9/|x|-3|18|x|-3|5/|-/||9");
// WHEN call checkInputData method
// THEN
EXPECT_TRUE(input.checkInputData());
}
TEST_F(InputValidationTest,
expect_false_when_there_is_spare_after_two_sticks_and_spare)
{
// GIVEN
InputValidation input("Mike:x|--|9/|x|-3|18|x|-3|5/|-/||/");
// WHEN call checkInputData method
// THEN
EXPECT_FALSE(input.checkInputData());
}
TEST_F(InputValidationTest,
expect_false_when_there_is_too_many_signs_after_two_sticks_and_spare)
{
// GIVEN
InputValidation input("Mike:x|--|9/|x|-3|18|x|-3|5/|-/||5/");
// WHEN call checkInputData method
// THEN
EXPECT_FALSE(input.checkInputData());
}
TEST_F(InputValidationTest,
expect_true_when_there_is_strike_after_two_sticks_and_strike)
{
// GIVEN
InputValidation input("Mike:x|--|9/|x|-3|18|x|-3|5/|x||x");
// WHEN call checkInputData method
// THEN
EXPECT_TRUE(input.checkInputData());
}
TEST_F(InputValidationTest,
expect_true_when_there_are_two_miss_after_two_sticks_and_strike)
{
// GIVEN
InputValidation input("Mike:x|--|9/|x|-3|18|x|-3|5/|x||--");
// WHEN call checkInputData method
// THEN
EXPECT_TRUE(input.checkInputData());
}
TEST_F(
InputValidationTest,
expect_true_when_there_are_2_numbers_which_sum_is_less_then_9_after_two_sticks_and_strike)
{
// GIVEN
InputValidation input("Mike:x|--|9/|x|-3|18|x|-3|5/|x||17");
// WHEN call checkInputData method
// THEN
EXPECT_TRUE(input.checkInputData());
}
TEST_F(InputValidationTest,
expect_false_when_there_is_spare_after_two_sticks_and_strike)
{
// GIVEN
InputValidation input("Mike:x|--|9/|x|-3|18|x|-3|5/|x||/6");
// WHEN call checkInputData method
// THEN
EXPECT_FALSE(input.checkInputData());
}
TEST_F(InputValidationTest,
expect_false_when_there_are_too_many_signs_after_strike)
{
// GIVEN
InputValidation input("Mike:x|--|9/|x|-3|18|x|-3|5/|x||123");
// WHEN call checkInputData method
// THEN
EXPECT_FALSE(input.checkInputData());
}
TEST_F(InputValidationTest, expect_true_when_the_game_is_in_progress)
{
// GIVEN
InputValidation input("Mike:x|--|3");
// WHEN call checkInputData method
// THEN
EXPECT_TRUE(input.checkInputData());
}
TEST_F(InputValidationTest, expect_false_when_there_is_no_stick_after_strike)
{
// GIVEN
InputValidation input("Mike:x|--|x");
// WHEN call checkInputData method
// THEN
EXPECT_FALSE(input.checkInputData());
}
TEST_F(InputValidationTest, expect_false_when_there_is_only_spare_after_stick)
{
// GIVEN
InputValidation input("Mike:x|--|/");
// WHEN call checkInputData method
// THEN
EXPECT_FALSE(input.checkInputData());
}
TEST_F(InputValidationTest, expect_true_when_the_game_is_not_finished)
{
// GIVEN
InputValidation input("Mike:x|--|9/|x|-3|18|x|-3|5/|x||");
// WHEN call checkInputData method
// THEN
EXPECT_TRUE(input.checkInputData());
}
TEST_F(InputValidationTest, check_if_player_name_is_correct)
{
// GIVEN
InputValidation input("Mike:x|--|9/|x|-3|18|x|-3|5/|x||/");
// WHEN call checkInputData method
// THEN
ASSERT_EQ(input.getPlayerName(), "Mike");
}
| 25.846995 | 94 | 0.700106 | LuckyCode7 |
d71e0641b1f72560cd25a27397e1cfe929c84946 | 6,566 | cpp | C++ | src/org/apache/poi/ss/formula/FormulaRenderer.cpp | pebble2015/cpoi | 6dcc0c5e13e3e722b4ef9fd0baffbf62bf71ead6 | [
"Apache-2.0"
] | null | null | null | src/org/apache/poi/ss/formula/FormulaRenderer.cpp | pebble2015/cpoi | 6dcc0c5e13e3e722b4ef9fd0baffbf62bf71ead6 | [
"Apache-2.0"
] | null | null | null | src/org/apache/poi/ss/formula/FormulaRenderer.cpp | pebble2015/cpoi | 6dcc0c5e13e3e722b4ef9fd0baffbf62bf71ead6 | [
"Apache-2.0"
] | null | null | null | // Generated from /POI/java/org/apache/poi/ss/formula/FormulaRenderer.java
#include <org/apache/poi/ss/formula/FormulaRenderer.hpp>
#include <java/io/Serializable.hpp>
#include <java/lang/ArrayStoreException.hpp>
#include <java/lang/CharSequence.hpp>
#include <java/lang/ClassCastException.hpp>
#include <java/lang/Comparable.hpp>
#include <java/lang/IllegalArgumentException.hpp>
#include <java/lang/IllegalStateException.hpp>
#include <java/lang/NullPointerException.hpp>
#include <java/lang/Object.hpp>
#include <java/lang/RuntimeException.hpp>
#include <java/lang/String.hpp>
#include <java/lang/StringBuilder.hpp>
#include <java/util/Stack.hpp>
#include <org/apache/poi/ss/formula/WorkbookDependentFormula.hpp>
#include <org/apache/poi/ss/formula/ptg/AttrPtg.hpp>
#include <org/apache/poi/ss/formula/ptg/MemAreaPtg.hpp>
#include <org/apache/poi/ss/formula/ptg/MemErrPtg.hpp>
#include <org/apache/poi/ss/formula/ptg/MemFuncPtg.hpp>
#include <org/apache/poi/ss/formula/ptg/OperationPtg.hpp>
#include <org/apache/poi/ss/formula/ptg/ParenthesisPtg.hpp>
#include <org/apache/poi/ss/formula/ptg/Ptg.hpp>
#include <SubArray.hpp>
#include <ObjectArray.hpp>
template<typename ComponentType, typename... Bases> struct SubArray;
namespace java
{
namespace io
{
typedef ::SubArray< ::java::io::Serializable, ::java::lang::ObjectArray > SerializableArray;
} // io
namespace lang
{
typedef ::SubArray< ::java::lang::CharSequence, ObjectArray > CharSequenceArray;
typedef ::SubArray< ::java::lang::Comparable, ObjectArray > ComparableArray;
typedef ::SubArray< ::java::lang::String, ObjectArray, ::java::io::SerializableArray, ComparableArray, CharSequenceArray > StringArray;
} // lang
} // java
namespace poi
{
namespace ss
{
namespace formula
{
namespace ptg
{
typedef ::SubArray< ::poi::ss::formula::ptg::Ptg, ::java::lang::ObjectArray > PtgArray;
} // ptg
} // formula
} // ss
} // poi
template<typename T, typename U>
static T java_cast(U* u)
{
if(!u) return static_cast<T>(nullptr);
auto t = dynamic_cast<T>(u);
if(!t) throw new ::java::lang::ClassCastException();
return t;
}
template<typename T>
static T* npc(T* t)
{
if(!t) throw new ::java::lang::NullPointerException();
return t;
}
poi::ss::formula::FormulaRenderer::FormulaRenderer(const ::default_init_tag&)
: super(*static_cast< ::default_init_tag* >(0))
{
clinit();
}
poi::ss::formula::FormulaRenderer::FormulaRenderer()
: FormulaRenderer(*static_cast< ::default_init_tag* >(0))
{
ctor();
}
java::lang::String* poi::ss::formula::FormulaRenderer::toFormulaString(FormulaRenderingWorkbook* book, ::poi::ss::formula::ptg::PtgArray* ptgs)
{
clinit();
if(ptgs == nullptr || npc(ptgs)->length == 0) {
throw new ::java::lang::IllegalArgumentException(u"ptgs must not be null"_j);
}
auto stack = new ::java::util::Stack();
for(auto ptg : *npc(ptgs)) {
if(dynamic_cast< ::poi::ss::formula::ptg::MemAreaPtg* >(ptg) != nullptr || dynamic_cast< ::poi::ss::formula::ptg::MemFuncPtg* >(ptg) != nullptr || dynamic_cast< ::poi::ss::formula::ptg::MemErrPtg* >(ptg) != nullptr) {
continue;
}
if(dynamic_cast< ::poi::ss::formula::ptg::ParenthesisPtg* >(ptg) != nullptr) {
auto contents = java_cast< ::java::lang::String* >(npc(stack)->pop());
npc(stack)->push(::java::lang::StringBuilder().append(u"("_j)->append(contents)
->append(u")"_j)->toString());
continue;
}
if(dynamic_cast< ::poi::ss::formula::ptg::AttrPtg* >(ptg) != nullptr) {
auto attrPtg = (java_cast< ::poi::ss::formula::ptg::AttrPtg* >(ptg));
if(npc(attrPtg)->isOptimizedIf() || npc(attrPtg)->isOptimizedChoose() || npc(attrPtg)->isSkip()) {
continue;
}
if(npc(attrPtg)->isSpace()) {
continue;
}
if(npc(attrPtg)->isSemiVolatile()) {
continue;
}
if(npc(attrPtg)->isSum()) {
auto operands = getOperands(stack, npc(attrPtg)->getNumberOfOperands());
npc(stack)->push(npc(attrPtg)->toFormulaString(operands));
continue;
}
throw new ::java::lang::RuntimeException(::java::lang::StringBuilder().append(u"Unexpected tAttr: "_j)->append(static_cast< ::java::lang::Object* >(attrPtg))->toString());
}
if(dynamic_cast< WorkbookDependentFormula* >(ptg) != nullptr) {
auto optg = java_cast< WorkbookDependentFormula* >(ptg);
npc(stack)->push(npc(optg)->toFormulaString(book));
continue;
}
if(!(dynamic_cast< ::poi::ss::formula::ptg::OperationPtg* >(ptg) != nullptr)) {
npc(stack)->push(npc(ptg)->toFormulaString());
continue;
}
auto o = java_cast< ::poi::ss::formula::ptg::OperationPtg* >(ptg);
auto operands = getOperands(stack, npc(o)->getNumberOfOperands());
npc(stack)->push(npc(o)->toFormulaString(operands));
}
if(npc(stack)->isEmpty()) {
throw new ::java::lang::IllegalStateException(u"Stack underflow"_j);
}
auto result = java_cast< ::java::lang::String* >(npc(stack)->pop());
if(!npc(stack)->isEmpty()) {
throw new ::java::lang::IllegalStateException(u"too much stuff left on the stack"_j);
}
return result;
}
java::lang::StringArray* poi::ss::formula::FormulaRenderer::getOperands(::java::util::Stack* stack, int32_t nOperands)
{
clinit();
auto operands = new ::java::lang::StringArray(nOperands);
for (auto j = nOperands - int32_t(1); j >= 0; j--) {
if(npc(stack)->isEmpty()) {
auto msg = ::java::lang::StringBuilder().append(u"Too few arguments supplied to operation. Expected ("_j)->append(nOperands)
->append(u") operands but got ("_j)
->append((nOperands - j - int32_t(1)))
->append(u")"_j)->toString();
throw new ::java::lang::IllegalStateException(msg);
}
operands->set(j, java_cast< ::java::lang::String* >(npc(stack)->pop()));
}
return operands;
}
extern java::lang::Class *class_(const char16_t *c, int n);
java::lang::Class* poi::ss::formula::FormulaRenderer::class_()
{
static ::java::lang::Class* c = ::class_(u"org.apache.poi.ss.formula.FormulaRenderer", 41);
return c;
}
java::lang::Class* poi::ss::formula::FormulaRenderer::getClass0()
{
return class_();
}
| 37.735632 | 225 | 0.630064 | pebble2015 |