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
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
2a04f476927a2787f725f277f6e2177e7981b46d
| 772
|
hpp
|
C++
|
include/networking/Event.hpp
|
icebreakersentertainment/ice_engine
|
52a8313bc266c053366bdf554b5dc27a54ddcb25
|
[
"MIT"
] | null | null | null |
include/networking/Event.hpp
|
icebreakersentertainment/ice_engine
|
52a8313bc266c053366bdf554b5dc27a54ddcb25
|
[
"MIT"
] | null | null | null |
include/networking/Event.hpp
|
icebreakersentertainment/ice_engine
|
52a8313bc266c053366bdf554b5dc27a54ddcb25
|
[
"MIT"
] | 1
|
2019-06-11T03:41:48.000Z
|
2019-06-11T03:41:48.000Z
|
#ifndef NETWORK_EVENT_H_
#define NETWORK_EVENT_H_
#include <vector>
#include "Types.hpp"
#include "ClientHandle.hpp"
#include "ServerHandle.hpp"
#include "RemoteConnectionHandle.hpp"
namespace ice_engine
{
namespace networking
{
enum EventType
{
UNKNOWN = 0,
SERVERDISCONNECT,
CLIENTDISCONNECT,
SERVERCONNECT,
SERVERCONNECTFAILED,
CLIENTCONNECT,
SERVERMESSAGE,
CLIENTMESSAGE
};
struct GenericEvent
{
uint32 type;
uint32 timestamp;
ServerHandle serverHandle;
ClientHandle clientHandle;
RemoteConnectionHandle remoteConnectionHandle;
};
struct ConnectEvent : public GenericEvent
{
};
struct DisconnectEvent : public GenericEvent
{
};
struct MessageEvent : public GenericEvent
{
std::vector<uint8> message;
};
}
}
#endif /* NETWORK_EVENT_H_ */
| 13.310345
| 47
| 0.774611
|
icebreakersentertainment
|
2a05993080fc16187d08ec6cef2e7ff66e2d0ac3
| 4,031
|
cpp
|
C++
|
test/test_client.cpp
|
lichuan/fly
|
7927f819f74997314fb526c5d8ab4d88ea593b91
|
[
"Apache-2.0"
] | 60
|
2015-06-23T12:36:33.000Z
|
2022-03-09T01:27:14.000Z
|
test/test_client.cpp
|
lichuan/fly
|
7927f819f74997314fb526c5d8ab4d88ea593b91
|
[
"Apache-2.0"
] | 1
|
2021-12-21T11:23:04.000Z
|
2021-12-21T11:23:04.000Z
|
test/test_client.cpp
|
lichuan/fly
|
7927f819f74997314fb526c5d8ab4d88ea593b91
|
[
"Apache-2.0"
] | 30
|
2015-08-03T07:22:04.000Z
|
2022-01-13T08:49:48.000Z
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* _______ _ *
* ( ____ \ ( \ |\ /| *
* | ( \/ | ( ( \ / ) *
* | (__ | | \ (_) / *
* | __) | | \ / *
* | ( | | ) ( *
* | ) | (____/\ | | *
* |/ (_______/ \_/ *
* *
* *
* fly is an awesome c++11 network library. *
* *
* @author: lichuan *
* @qq: 308831759 *
* @email: 308831759@qq.com *
* @github: https://github.com/lichuan/fly *
* @date: 2015-06-10 13:34:21 *
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include <unistd.h>
#include "fly/init.hpp"
#include "fly/net/client.hpp"
#include "fly/base/logger.hpp"
using namespace std::placeholders;
using fly::net::Json;
class Test_Client : public fly::base::Singleton<Test_Client>
{
public:
bool init(std::shared_ptr<fly::net::Connection<Json>> connection)
{
rapidjson::Document doc;
doc.SetObject();
rapidjson::Document::AllocatorType &allocator = doc.GetAllocator();
doc.AddMember("msg_type", 9922, allocator);
doc.AddMember("msg_cmd", 2223333, allocator);
connection->send(doc);
return true;
}
void dispatch(std::unique_ptr<fly::net::Message<Json>> connection)
{
CONSOLE_LOG_INFO("disaptch message");
}
void close(std::shared_ptr<fly::net::Connection<Json>> connection)
{
CONSOLE_LOG_INFO("close connection from %s:%d", connection->peer_addr().m_host.c_str(), connection->peer_addr().m_port);
}
void be_closed(std::shared_ptr<fly::net::Connection<Json>> connection)
{
CONSOLE_LOG_INFO("connection from %s:%d be closed", connection->peer_addr().m_host.c_str(), connection->peer_addr().m_port);
}
void main()
{
//init library
fly::init();
//init logger
fly::base::Logger::instance()->init(fly::base::DEBUG, "client", "./log/");
std::shared_ptr<fly::net::Poller<Json>> poller(new fly::net::Poller<Json>(4));
poller->start();
int i = 1;
while(i-- > 0)
{
std::unique_ptr<fly::net::Client<Json>> client(new fly::net::Client<Json>(fly::net::Addr("127.0.0.1", 8088),
std::bind(&Test_Client::init, this, _1),
std::bind(&Test_Client::dispatch, this, _1),
std::bind(&Test_Client::close, this, _1),
std::bind(&Test_Client::be_closed, this, _1),
poller));
if(client->connect(1000))
{
CONSOLE_LOG_INFO("connect to server ok");
}
else
{
CONSOLE_LOG_INFO("connect to server failed");
}
}
poller->wait();
}
};
int main()
{
Test_Client::instance()->main();
}
| 41.556701
| 132
| 0.354999
|
lichuan
|
2a0e0b31f8896732621146f8c97e7bdbbad7ea87
| 5,637
|
hpp
|
C++
|
nvidia_flex/common/helpers.hpp
|
bluekyu/rpcpp_samples
|
dab4d21229e9793434d727b2ed8e4c5088c17218
|
[
"MIT"
] | 4
|
2018-09-15T20:30:38.000Z
|
2022-02-13T19:41:00.000Z
|
nvidia_flex/common/helpers.hpp
|
bluekyu/rpcpp_samples
|
dab4d21229e9793434d727b2ed8e4c5088c17218
|
[
"MIT"
] | 4
|
2017-09-05T15:18:40.000Z
|
2018-08-27T01:15:46.000Z
|
nvidia_flex/common/helpers.hpp
|
bluekyu/rpcpp_samples
|
dab4d21229e9793434d727b2ed8e4c5088c17218
|
[
"MIT"
] | null | null | null |
// This code contains NVIDIA Confidential Information and is disclosed to you
// under a form of NVIDIA software license agreement provided separately to you.
//
// Notice
// NVIDIA Corporation and its licensors retain all intellectual property and
// proprietary rights in and to this software and related documentation and
// any modifications thereto. Any use, reproduction, disclosure, or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA Corporation is strictly prohibited.
//
// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
//
// Information and code furnished is believed to be accurate and reliable.
// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
// information or for any infringement of patents or other rights of third parties that may
// result from its use. No license is granted by implication or otherwise under any patent
// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
// This code supersedes and replaces all information previously supplied.
// NVIDIA Corporation products are not authorized for use as critical
// components in life support devices or systems without express written approval of
// NVIDIA Corporation.
//
// Copyright (c) 2013-2017 NVIDIA Corporation. All rights reserved.
#pragma once
#include <rpflex/plugin.hpp>
#include <rpflex/flex_buffer.hpp>
#include "maths.hpp"
struct Emitter
{
Emitter() : mSpeed(0.0f), mEnabled(false), mLeftOver(0.0f), mWidth(8) {}
LVecBase3 mPos;
LVecBase3 mDir;
LVecBase3 mRight;
float mSpeed;
bool mEnabled;
float mLeftOver;
int mWidth;
};
void CreateParticleGrid(rpflex::FlexBuffer& buffer, const LVecBase3& lower, int dimx, int dimy, int dimz, float radius,
const LVecBase3& velocity, float invMass, bool rigid, float rigidStiffness, int phase, float jitter=0.005f)
{
if (rigid && buffer.rigid_indices.empty())
buffer.rigid_offsets.push_back(0);
for (int x = 0; x < dimx; ++x)
{
for (int y = 0; y < dimy; ++y)
{
for (int z=0; z < dimz; ++z)
{
if (rigid)
buffer.rigid_indices.push_back(int(buffer.positions.size()));
LVecBase3 position = lower + LVecBase3(float(x), float(y), float(z))*radius + RandomUnitVector()*jitter;
buffer.positions.push_back(LVecBase4(position, invMass));
buffer.velocities.push_back(velocity);
buffer.phases.push_back(phase);
}
}
}
if (rigid)
{
buffer.rigid_coefficients.push_back(rigidStiffness);
buffer.rigid_offsets.push_back(int(buffer.rigid_indices.size()));
}
}
void UpdateEmitters(rpflex::Plugin& rpflex_plugin, Emitter& emitter)
{
const auto& flex_params = rpflex_plugin.get_flex_params();
auto& buffer = rpflex_plugin.get_flex_buffer();
NodePath cam = rpcore::Globals::base->get_cam();
LVecBase3 spinned_cam = cam.get_hpr(rpcore::Globals::render) + LVecBase3(15, 0, 0);
LQuaternion rot;
rot.set_hpr(spinned_cam);
LMatrix4 mat;
rot.extract_to_matrix(mat);
const LVecBase3 forward((LVecBase4(0, 1, 0, 0) * mat).get_xyz());
const LVecBase3 right(forward.cross(LVecBase3(0.0f, 0.0f, 1.0f)).normalized());
emitter.mDir = (forward + LVecBase3(0.0, 0.0f, 0.4f)).normalized();
emitter.mRight = right;
emitter.mPos = cam.get_pos(rpcore::Globals::render) + forward*1.f + LVecBase3(0.0f, 0.0f, 0.2f) + right*0.65f;
// process emitters
int activeCount = NvFlexGetActiveCount(rpflex_plugin.get_flex_solver());
float r;
int phase;
if (flex_params.fluid)
{
r = flex_params.fluidRestDistance;
phase = NvFlexMakePhase(0, eNvFlexPhaseSelfCollide | eNvFlexPhaseFluid);
}
else
{
r = flex_params.solidRestDistance;
phase = NvFlexMakePhase(0, eNvFlexPhaseSelfCollide);
}
float numParticles = (emitter.mSpeed / r) * (1/60.0f);
// whole number to emit
int n = int(numParticles + emitter.mLeftOver);
if (n)
emitter.mLeftOver = (numParticles + emitter.mLeftOver) - n;
else
emitter.mLeftOver += numParticles;
// create a grid of particles (n particles thick)
for (int k = 0; k < n; ++k)
{
int emitterWidth = emitter.mWidth;
int numParticles = emitterWidth*emitterWidth;
for (int i = 0; i < numParticles; ++i)
{
float x = float(i%emitterWidth) - float(emitterWidth/2);
float y = float((i / emitterWidth) % emitterWidth) - float(emitterWidth/2);
if ((x*x + y*y) <= (emitterWidth / 2)*(emitterWidth / 2))
{
LVecBase3 up = emitter.mDir.cross(emitter.mRight).normalized();
LVecBase3 offset = r*(emitter.mRight*x + up*y) + float(k)*emitter.mDir*r;
if (activeCount < buffer.positions.size())
{
buffer.positions[activeCount] = LVecBase4f(emitter.mPos + offset, 1.0f);
buffer.velocities[activeCount] = emitter.mDir*emitter.mSpeed;
buffer.phases[activeCount] = phase;
buffer.active_indices.push_back(activeCount);
activeCount++;
}
}
}
}
}
| 35.904459
| 120
| 0.659038
|
bluekyu
|
2a0f6d0725d97dc1332a8ce9872eb32a43402f73
| 33,384
|
cpp
|
C++
|
lipton-tarjan.cpp
|
jeffythedragonslayer/lipton-tarjan
|
d6f43395ca9d5a459c61cd55ccac6ed6295bc1dd
|
[
"BSL-1.0"
] | 8
|
2017-05-20T11:20:39.000Z
|
2020-11-10T15:50:33.000Z
|
lipton-tarjan.cpp
|
jeffythedragonslayer/lipton-tarjan
|
d6f43395ca9d5a459c61cd55ccac6ed6295bc1dd
|
[
"BSL-1.0"
] | 14
|
2017-12-02T06:35:48.000Z
|
2020-04-12T19:58:56.000Z
|
lipton-tarjan.cpp
|
jeffythedragonslayer/lipton-tarjan
|
d6f43395ca9d5a459c61cd55ccac6ed6295bc1dd
|
[
"BSL-1.0"
] | 3
|
2017-04-19T16:37:32.000Z
|
2022-03-19T04:29:33.000Z
|
//=======================================================================
// Copyright 2015 - 2020 Jeff Linahan
//
// 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)
//=======================================================================
#include "lipton-tarjan.h"
#include "theorem4.h"
#include "lemmas.h"
#include "strutil.h"
#include "BFSVert.h"
#include "BFSVisitorData.h"
#include "BFSVisitor.h"
#include "EmbedStruct.h"
#include "ScanVisitor.h"
#include "graphutil.h"
#include <boost/lexical_cast.hpp>
#include <boost/graph/graph_concepts.hpp>
#include <boost/graph/planar_canonical_ordering.hpp>
#include <boost/graph/is_straight_line_drawing.hpp>
#include <boost/graph/boyer_myrvold_planar_test.hpp>
#include <boost/graph/make_biconnected_planar.hpp>
#include <boost/graph/make_maximal_planar.hpp>
#include <boost/graph/connected_components.hpp>
#include <boost/graph/copy.hpp>
#include <boost/graph/breadth_first_search.hpp>
#include <boost/pending/indirect_cmp.hpp>
#include <boost/range/irange.hpp>
#include <boost/bimap.hpp>
#include <boost/config.hpp>
#include <iostream>
#include <algorithm>
#include <utility>
#include <csignal>
#include <iterator>
using namespace std;
using namespace boost;
// Step 10: construct_vertex_partition
// Time: O(n)
//
// Use the fundamental cycle found in Step 9 and the levels found in Step 4 (l1_and_k) to construct a satisfactory vertex partition as described in the proof of Lemma 3
// Extend this partition from the connected component chosen in Step 2 to the entire graph as described in the proof of Theorem 4.
Partition construct_vertex_partition(GraphCR g_orig, Graph& g_shrunk, vector<uint> const& L, uint l[3], BFSVisitorData const& vis_data_orig, BFSVisitorData const& vis_data_shrunken, vector<vertex_t> const& fundamental_cycle)
{
vertex_map idx;
associative_property_map<vertex_map> vertid_to_component(idx);
uint num_components = connected_components(g_orig, vertid_to_component);
//BOOST_ASSERT(1 == num_components);
uint n = num_vertices(g_orig);
uint n_biggest_comp = vis_data_orig.verts.size(); // if num_components > 1 then num_vertices(g_orig) will not be what we want
//cout << "n_biggest: " << n_biggest_comp << '\n';
cout << "\n------------ 10 - Construct Vertex Partition --------------\n";
cout << "g_orig:\n";
print_graph(g_orig);
cout << "l0: " << l[0] << '\n';
cout << "l1: " << l[1] << '\n';
cout << "l2: " << l[2] << '\n';
uint r = vis_data_orig.num_levels;
cout << "r max distance: " << r << '\n';
Partition biggest_comp_p = lemma3(g_orig, L, l[1], l[2], r, vis_data_orig, vis_data_shrunken, fundamental_cycle, &g_shrunk);
biggest_comp_p.verify_edges(g_orig);
biggest_comp_p.verify_sizes_lemma3(L, l[1], l[2]);
if( 1 == num_components ){
if( biggest_comp_p.verify_sizes(g_orig) && biggest_comp_p.verify_edges(g_orig) ) return biggest_comp_p;
return theorem4_connected(g_orig, L, l, r, &g_shrunk, &vis_data_shrunken);
}
//associative_property_map<vertex_map> const& vertid_to_component, vector<uint> const& num_verts_per_component)
vector<uint> num_verts_per_component(num_components, 0);
VertIter vit, vjt;
for( tie(vit, vjt) = vertices(g_orig); vit != vjt; ++vit ){
++num_verts_per_component[vertid_to_component[*vit]];
}
// somehow the two Partitions need to be stiched together
cout << "biggest comp p:\n";
biggest_comp_p.print(&g_orig);
Partition extended_p = theorem4_disconnected(g_orig, n, num_components, vertid_to_component, num_verts_per_component, biggest_comp_p);
return extended_p; // TODO replace this with extended_p
}
// Locate the triangle (vi, y, wi) which has (vi, wi) as a boundary edge and lies inside the (vi, wi) cycle.
// one of the vertices in the set neighbors_vw is y. Maybe it's .begin(), so we use is_edge_inside_outside_or_on_cycle to test if it is.j
vertex_t findy(vertex_t vi, set<vertex_t> const& neighbors_vw, vector<vertex_t> const& cycle, GraphCR g_shrunk, EmbedStruct const& em, decltype(get(vertex_index, const_cast<Graph&>(g_shrunk))) prop_map)
{
for( vertex_t y_candidate : neighbors_vw ){
pair<edge_t, bool> vi_cy = edge(vi, y_candidate, g_shrunk);
BOOST_ASSERT(vi_cy.second);
edge_t e = vi_cy.first;
InsideOutOn insideout = is_edge_inside_outside_or_on_cycle(e, vi, cycle, g_shrunk, em.em);
if( INSIDE == insideout ){
return y_candidate;
}
}
/*pair<edge_t, bool> maybe_y = edge(vi, *neighbors_vw.begin(), g_shrunk);
BOOST_ASSERT(maybe_y.second); // I'm assuming the bool means that the edge_t exists? Boost Graph docs don't say
cout << "maybe_y: " << to_string(maybe_y.first, g_shrunk) << '\n';
cout << "cycle:\n";
print_cycle(cycle, g_shrunk);
vertex_t common_vert_on_cycle = find(STLALL(cycle), *neighbors_vw.begin()) == cycle.end() ?
*neighbors_vw.rbegin() :
*neighbors_vw.begin() ;
cout << "common vert on cycle: " << prop_map[common_vert_on_cycle] << '\n';
BOOST_ASSERT(find(STLALL(cycle), common_vert_on_cycle) != cycle.end());
InsideOutOn insideout = is_edge_inside_outside_or_on_cycle(maybe_y.first, common_vert_on_cycle, cycle, g_shrunk, em.em);
BOOST_ASSERT(insideout != ON);
vertex_t y = (insideout == INSIDE) ? *neighbors_vw.begin() : *neighbors_vw.rbegin();*/
// We now have the (vi, y, wi) triangle
BOOST_ASSERT(0);
}
// Step 9: Improve Separator
// Time: O(n)
//
// Let (vi, wi) be the nontree edge whose cycle is the current candidate to complete the separator.
// If the cost inside the cycle exceeds 2/3, find a better cycle by the following method.
// Locate the triangle (vi, y, wi) which has (vi, wi) as a boundary edge and lies inside the (vi, wi) cycle.
// If either (vi, y) or (y, wi) is a tree edge, let (vi+1, wi+1) be the nontree edge among (vi, y) and (y, wi).
// Compute the cost inside the (vi+1, wi+1) cycle from the cost inside the (vi, wi) cycle and the cost of vi, y and wi.
// If neither (vi, y) nor (y, wi) is a tree edge, determine the tree path from y to the (vi, wi) cycle by following parent pointers from y.
// Let z be the vertex on the (vi, wi) cycle reached during this search. Compute the total cost of all vertices except z on this tree path.
// Scan the tree edges inside the (y, wi) cycle, alternately scanning an edge in one cycle and an edge in the other cycle.
// Stop scanning when all edges inside one of the cycles have been scanned. Compute the cost inside this cycle by summing the associated costs of all scanned edges.
// Use this cost, the cost inside the (vi, wi) cycle, and the cost on the tree path from y to z to compute the cost inside the other cycle.
// Let (vi+1, wi+1) be the edge among (vi, y) and (y, wi) whose cycle has more cost inside it.
// Repeat Step 9 until finding a cycle whose inside has cost not exceeding 2/3.
Partition improve_separator(GraphCR g_orig, Graph& g_shrunk, CycleCost& cc, edge_t completer_candidate_edge, BFSVisitorData const& vis_data_orig,
BFSVisitorData const& vis_data_shrunken, vector<vertex_t> cycle, EmbedStruct const& em, bool cost_swapped, vector<uint> const& L, uint l[3])
{
cout << "---------------------------- 9 - Improve Separator -----------\n";
print_graph(g_shrunk);
auto prop_map = get(vertex_index, g_shrunk); // writing to this property map has side effects in the graph
cout << "cycle: ";
for( uint i = 0; i < cycle.size(); ++i ) cout << prop_map[cycle[i]] << ' ';
cout << '\n';
uint n_orig = num_vertices(g_orig);
uint n = num_vertices(g_shrunk);
cout << "n_orig: " << n_orig << ", n: " << n << '\n';
while( cc.inside > 2.*n/3 ){
cout << "nontree completer candidate edge: " << to_string(completer_candidate_edge, g_shrunk) << '\n';
cout << "cost inside: " << cc.inside << '\n';
cout << "cost outide: " << cc.outside << '\n';
cout << "looking for a better cycle\n";
// Let (vi, wi) be the nontree edge whose cycle is the current candidate to complete the separator
vertex_t vi = source(completer_candidate_edge, g_shrunk);
vertex_t wi = target(completer_candidate_edge, g_shrunk);
BOOST_ASSERT(!vis_data_shrunken.is_tree_edge(completer_candidate_edge));
cout << " vi: " << prop_map[vi] << '\n';
cout << " wi: " << prop_map[wi] << '\n';
set<vertex_t> neighbors_of_v = get_neighbors(vi, g_shrunk);
set<vertex_t> neighbors_of_w = get_neighbors(wi, g_shrunk);
set<vertex_t> neighbors_vw = get_intersection(neighbors_of_v, neighbors_of_w);
for( auto& ne : neighbors_vw ){
cout << "neighbor: " << ne << " prop_map: " << prop_map[ne] << '\n';
}
cout << " neighbors_vw_begin : " << prop_map[*neighbors_vw.begin()] << '\n';
cout << " neighbors_vw_rbegin: " << prop_map[*neighbors_vw.rbegin()] << '\n';
vertex_t y = findy(vi, neighbors_vw, cycle, g_shrunk, em, prop_map);
cout << " y: " << prop_map[y] << '\n';
pair<edge_t, bool> viy_e = edge(vi, y, g_shrunk); BOOST_ASSERT(viy_e.second); edge_t viy = viy_e.first;
pair<edge_t, bool> ywi_e = edge(y, wi, g_shrunk); BOOST_ASSERT(ywi_e.second); edge_t ywi = ywi_e.first;
edge_t next_edge;
// if either (vi, y) or (y, wi) is a tree edge,
if ( vis_data_shrunken.is_tree_edge(viy) || vis_data_shrunken.is_tree_edge(ywi) ){
// determine the tree path from y to the (vi, wi) cycle by following parent pointers from y.
cout << " at least one tree edge\n";
next_edge = vis_data_shrunken.is_tree_edge(viy) ? ywi : viy;
BOOST_ASSERT(!vis_data_shrunken.is_tree_edge(next_edge));
// Compute the cost inside the (vi+1 wi+1) cycle from the cost inside the (vi, wi) cycle and the cost of vi, y, and wi. See Fig 4.
uint cost[4] = {vis_data_shrunken.verts.find(vi)->second.descendant_cost,
vis_data_shrunken.verts.find(y )->second.descendant_cost,
vis_data_shrunken.verts.find(wi)->second.descendant_cost,
cc.inside};
vector<vertex_t> new_cycle = vis_data_shrunken.get_cycle(source(next_edge, g_shrunk), target(next_edge, g_shrunk));
cc = compute_cycle_cost(new_cycle, g_shrunk, vis_data_shrunken, em); // !! CHEATED !!
if( cost_swapped ) swap(cc.outside, cc.inside);
} else {
// Determine the tree path from y to the (vi, wi) cycle by following parents of y.
cout << " neither are tree edges\n";
vector<vertex_t> y_parents = vis_data_shrunken.ancestors(y);
for( vertex_t vp : y_parents ){
cout << "y parent: " << prop_map[vp] << '\n';
}
uint i = 0;
while( !on_cycle(y_parents.at(i), cycle, g_shrunk) ){
cout << "yparents[" << i << "]: " << y_parents[i] << " propmap: " << prop_map[y_parents[i]] << '\n';
++i;
}
cout << "yparents[" << i << "]: " << y_parents.at(i) << " propmap: " << prop_map[y_parents[i]] << '\n';
// Let z be the vertex on the (vi, wi) cycle reached during the search.
cout << "i: " << i << '\n';
vertex_t z = y_parents.at(i);
cout << "z: " << prop_map[z] << '\n';
BOOST_ASSERT(on_cycle(z, cycle, g_shrunk));
cout << " z: " << prop_map[z] << '\n';
y_parents.erase(y_parents.begin()+i, y_parents.end());
BOOST_ASSERT(y_parents.size() == i);
// Compute the total cost af all vertices except z on this tree path.
uint path_cost = y_parents.size() - 1;
cout << " y-to-z-minus-z cost: " << path_cost << '\n';
// Scan the tree edges inside the (y, wi) cycle, alternately scanning an edge in one cycle and an edge in the other cycle.
// Stop scanning when all edges inside one of the cycles have been scanned. Compute the cost inside this cycle by summing the associated costs of all scanned edges.
// Use this cost, the cost inside the (vi, wi) cycle, and the cost on the tree path from y to z to compute the cost inside the other cycle.
vector<vertex_t> cycle1 = vis_data_shrunken.get_cycle(vi, y);
vector<vertex_t> cycle2 = vis_data_shrunken.get_cycle(y, wi);
CycleCost cost1 = compute_cycle_cost(cycle1, g_shrunk, vis_data_shrunken, em);
CycleCost cost2 = compute_cycle_cost(cycle2, g_shrunk, vis_data_shrunken, em);
if( cost_swapped ){
swap(cost1.inside, cost1.outside);
swap(cost2.inside, cost2.outside);
}
// Let (vi+1, wi+1) be the edge among (vi, y) and (i, wi) whose cycle has more cost inside it.
if( cost1.inside > cost2.inside ){ next_edge = edge(vi, y, g_shrunk).first; cc = cost1; cycle = cycle1;}
else { next_edge = edge(y, wi, g_shrunk).first; cc = cost2; cycle = cycle2;}
}
completer_candidate_edge = next_edge;
}
cout << "found fundamental cycle with inside cost " << cc.inside << " which is less than 2/3\n";
print_cycle(cycle, g_shrunk);
//BOOST_ASSERT(assert_verts(g_copy, vis_data_copy)); // disabled because it doesn't support connected components
//BOOST_ASSERT(vis_data_orig.assert_data());
//BOOST_ASSERT(vis_data_shrunken.assert_data());
return construct_vertex_partition(g_orig, g_shrunk, L, l, vis_data_orig, vis_data_shrunken, cycle); // step 10
}
// Step 8: locate_cycle
// Time: O(n)
//
// Choose any nontree edge (v1, w1).
// Locate the corresponding cycle by following parent pointers from v1 and w1.
// Compute the cost on each side of this cycle by scanning the tree edges incident on either side of the cycle and summing their associated costs.
// If (v, w) is a tree edge with v on the cycle and w not on the cycle, the cost associated with (v,w) is the descendant cost of w if v is the parent of w,
// and the cost of all vertices minus the descendant cost of v if w is the parent of v.
// Determine which side of the cycle has greater cost and call it the "inside"
Partition locate_cycle(GraphCR g_orig, Graph& g_shrunk, BFSVisitorData const& vis_data_orig, BFSVisitorData const& vis_data_shrunken, vector<uint> const& L, uint l[3])
{
//BOOST_ASSERT(vis_data_orig.assert_data()); //BOOST_ASSERT(assert_verts(g_copy, vis_data_copy)); // disabled because it doesn't support connected components
//BOOST_ASSERT(vis_data_shrunken.assert_data()); //BOOST_ASSERT(assert_verts(g_copy, vis_data_copy)); // disabled because it doesn't support connected components
uint n = num_vertices(g_orig);
cout << "----------------------- 8 - Locate Cycle -----------------\n";
print_graph(g_shrunk);
edge_t completer_candidate_edge;
try {
completer_candidate_edge = vis_data_shrunken.arbitrary_nontree_edge(g_shrunk);
} catch (NoNontreeEdgeException const& e){
vector<vertex_t> cycle;
CycleCost cc;
cc.inside = 0;
cc.outside = n; // force Step 9 to exit without going through any iterations
bool cost_swapped = false;
EmbedStruct em(&g_shrunk);
return improve_separator(g_orig, g_shrunk, cc, completer_candidate_edge, vis_data_orig, vis_data_shrunken, cycle, em, cost_swapped, L, l); // step 9
}
vertex_t v1 = source(completer_candidate_edge, g_shrunk);
vertex_t w1 = target(completer_candidate_edge, g_shrunk);
cout << "ancestors v1...\n";
vector<vertex_t> parents_v = vis_data_shrunken.ancestors(v1);
cout << "ancestors v2...\n";
vector<vertex_t> parents_w = vis_data_shrunken.ancestors(w1);
vertex_t common_ancestor = get_common_ancestor(parents_v, parents_w);
cout << "common ancestor: " << common_ancestor << '\n';
vector<vertex_t> cycle = vis_data_shrunken.get_cycle(v1, w1, common_ancestor);
EmbedStruct em(&g_shrunk);
CycleCost cc = compute_cycle_cost(cycle, g_shrunk, vis_data_shrunken, em);
bool cost_swapped;
if( cc.outside > cc.inside ){
swap(cc.outside, cc.inside);
cost_swapped = true;
cout << "!!!!!! cost swapped !!!!!!!!\n";
} else cost_swapped = false;
cout << "total inside cost: " << cc.inside << '\n';
cout << "total outside cost: " << cc.outside << '\n';
return improve_separator(g_orig, g_shrunk, cc, completer_candidate_edge, vis_data_orig, vis_data_shrunken, cycle, em, cost_swapped, L, l); // step 9
}
// Step 7: new_bfs_and_make_max_planar
// Time: O(n)
//
// Construct a breadth-first spanning tree rooted at x in the new (shrunken) graph.
// (This can be done by modifying the breadth-first spanning tree constructed in Step 3 bfs_and_levels.)
// Record, for each vertex v, the parent of v in the tree, and the total cost of all descendants of v includiing v itself.
// Make all faces of the new graph into triangles by scanning the boundary of each face and adding (nontree) edges as necessary.
Partition new_bfs_and_make_max_planar(GraphCR g_orig, Graph& g_shrunk, BFSVisitorData const& vis_data_orig, vertex_t x, vector<uint> const& L, uint l[3])
{
cout << "-------------------- 7 - New BFS and Make Max Planar -----\n";
cout << "g_orig:\n";
print_graph(g_orig);
print_graph_addresses(g_orig);
cout << "g_shrunk:\n";
print_graph(g_shrunk);
print_graph_addresses(g_shrunk);
//reset_vertex_indices(g_shrunk);
//reset_edge_index(g_shrunk);
BFSVisitorData shrunken_vis_data(&g_shrunk, x);
//vis_data.reset(&g_shrunk);
shrunken_vis_data.root = x;
++shrunken_vis_data.verts[shrunken_vis_data.root].descendant_cost;
uint n = num_vertices(g_shrunk);
cout << "n: " << n << '\n';
cout << "null vertex: " << Graph::null_vertex() << '\n';
BFSVisitor visit = BFSVisitor(shrunken_vis_data);
auto bvs = boost::visitor(visit);
cout << "g_shrunk:\n";
print_graph(g_shrunk);
// workaround for https://github.com/boostorg/graph/issues/195
VertIter vit, vjt;
tie(vit, vjt) = vertices(g_shrunk);
for( VertIter next = vit; vit != vjt; ++vit){
if( 0 == in_degree(*vit, g_shrunk) + out_degree(*vit, g_shrunk) ){
add_edge(*vit, *vit, g_shrunk);
}
}
cout << "g_shrunk with workaround:\n";
print_graph(g_shrunk);
BOOST_ASSERT(vertex_exists(shrunken_vis_data.root, g_shrunk));
breadth_first_search(g_shrunk, shrunken_vis_data.root, bvs);
make_max_planar(g_shrunk);
//reset_vertex_indices(g_shrunk);
reset_edge_index(g_shrunk);
print_graph(g_shrunk);
return locate_cycle(g_orig, g_shrunk, vis_data_orig, shrunken_vis_data, L, l); // step 8
}
// Step 6: Shrinktree
// Time: big-theta(n)
//
// Delete all vertices on level l2 and above.
// Construct a new vertex x to represent all vertices on levels 0 through l0.
// Construct a boolean table with one entry per vertex.
// Initialize to true the entry for each vertex on levels 0 through l0 and
// initialize to false the entry for each vertex on levels l0 + 1 through l2 - 1.
// The vertices on levels 0 through l0 correspond to a subtree of the breadth-first spanning tree
// generated in Step 3 (bfs_and_levels).
// Scan the edges incident to this tree clockwise around the tree.
// When scanning an edge(v, w) with v in the tree, check the table entry for w.
// If it is true, delete edge(v, w).
// If it is false, change it to true, construct an edge(x,w) and delete edge(v,w).
// The result of this step is a planar representation of the shrunken graph to which Lemma 2 is to be applied.
//const uint X_VERT_UINT = 9999;
vector<vertex_t> shrinktree_deletel2andabove(Graph& g, uint l[3], BFSVisitorData const& vis_data_copy, vertex_t x)
{
cout << "l[0]: " << l[0] << '\n';
cout << "l[1]: " << l[1] << '\n';
cout << "l[2]: " << l[2] << '\n';
vector<vertex_t> replaced_verts;
VertIter vit, vjt;
tie(vit, vjt) = vertices(g);
for( VertIter next = vit; vit != vjt; vit = next ){
++next;
if( *vit == x ) continue; // don't delete x
if( !vis_data_copy.verts.contains(*vit) ) continue; // *vit is in a different connected component
uint level = vis_data_copy.verts.find(*vit)->second.level;
if( level >= l[2] ){
kill_vertex(*vit, g);
}
if( level <= l[0] ){
replaced_verts.push_back(*vit);
}
}
return replaced_verts;
}
Partition shrinktree(GraphCR g_orig, Graph& g_copy, BFSVisitorData const& vis_data_orig, BFSVisitorData const& vis_data_copy, vector<uint> const& L, uint l[3])
{
Graph& g_shrunk = g_copy;
cout << "---------------------------- 6 - Shrinktree -------------\n";
print_graph(g_copy);
cout << "n: " << num_vertices(g_shrunk) << '\n';
// delete all vertices on level l2 and above
vertex_t x = add_vertex(g_shrunk);
BFSVisitorData vis_data_addx(vis_data_copy);
vis_data_addx.root = x;
vis_data_addx.verts[x].level = 0;
vis_data_addx.verts[x].parent = Graph::null_vertex();
vis_data_addx.verts[x].descendant_cost = -1;
BOOST_ASSERT(vertex_exists(x, g_shrunk));
//BOOST_ASSERT(assert_verts(g_copy, vis_data_addx)); //BOOST_ASSERT(assert_verts(g_copy, vis_data_copy)); // disabled because it doesn't support connected components
vector<vertex_t> replaced_verts = shrinktree_deletel2andabove(g_shrunk, l, vis_data_addx, x);
BOOST_ASSERT(vertex_exists(x, g_shrunk));
//BOOST_ASSERT(assert_verts(g_copy, vis_data_addx)); //BOOST_ASSERT(assert_verts(g_copy, vis_data_copy)); // disabled because it doesn't support connected components
//prop_map[x] = X_VERT_UINT;
map<vertex_t, bool> table; // x will not be in this table
VertIter vit, vjt;
for( tie(vit, vjt) = vertices(g_shrunk); vit != vjt; ++vit ){
if( *vit == x ) continue; // the new x isn't in visdata, std::map::find() will fail
if( !vis_data_addx.verts.contains(*vit) ) continue; // *vit may be in a different connected component
uint level = vis_data_addx.verts.find(*vit)->second.level;
table[*vit] = level <= l[0];
}
BOOST_ASSERT(vertex_exists(x, g_shrunk));
//BOOST_ASSERT(assert_verts(g_copy, vis_data_addx)); //BOOST_ASSERT(assert_verts(g_copy, vis_data_copy)); // disabled because it doesn't support connected components
cout << "g_shrunk:\n";
print_graph(g_shrunk);
reset_vertex_indices(g_shrunk);
//reset_vertex_indices(g_shrunk);
//reset_edge_index(g_shrunk);
EmbedStruct em = ctor_workaround(&g_shrunk);
BOOST_ASSERT(test_planar_workaround(em.em, &g_shrunk));
//BOOST_ASSERT(assert_verts(g_copy, vis_data_addx)); //BOOST_ASSERT(assert_verts(g_copy, vis_data_copy)); // disabled because it doesn't support connected components
VertIter vei, vend;
for( tie(vei, vend) = vertices(g_orig); vei != vend; ++vei ){
vertex_t v = *vei;
if( !vis_data_orig.verts.contains(v) ){
cerr << "lipton-tarjan.cpp: ignoring bad vertex : " << v << '\n';
continue;
}
}
ScanVisitor svis(&table, &g_shrunk, x, l[0]);
svis.scan_nonsubtree_edges_clockwise(*vertices(g_shrunk).first, g_shrunk, em.em, vis_data_addx);
svis.finish();
BOOST_ASSERT(vertex_exists(x, g_shrunk));
cout << "deleting all vertices x has replaced\n"; for( vertex_t& v : replaced_verts ) {cout << "killing " << v << '\n'; kill_vertex(v, g_shrunk); }// delete all vertices x has replaced
reset_vertex_indices(g_shrunk);
BOOST_ASSERT(vertex_exists(x, g_shrunk));
cout << "g_shrunk:\n";
print_graph(g_shrunk);
uint n2 = num_vertices(g_shrunk);
cout << "shrunken size: " << n2 << '\n';
auto prop_map = get(vertex_index, g_shrunk);
cout << "x prop_map: " << prop_map[x] << '\n';
cout << "x : " << x << '\n';
return new_bfs_and_make_max_planar(g_orig, g_shrunk, vis_data_orig, x, L, l); // step 7
}
// Step 5: find_more_levels
// Time: O(n)
//
// Find the highest level l0 <= l1 such that L(l0) + 2(l1 - l0) <= 2*sqrt(k).
// Find the lowest level l2 >= l1 + 1 such that L(l2) + 2(l2-l1-1) <= 2*sqrt(n-k)
Partition find_more_levels(GraphCR g_orig, Graph& g_copy, uint k, uint l[3], vector<uint> const& L, BFSVisitorData const& vis_data_orig, BFSVisitorData const& vis_data_copy)
{
//BOOST_ASSERT(assert_verts(g_copy, vis_data_copy)); // disabled because it doesn't support connected components
cout << "---------------------------- 5 - Find More Levels -------\n";
//print_graph(g_copy);
float sq = 2 * sqrt(k);
float snk = 2 * sqrt(num_vertices(g_copy) - k);
cout << "sq: " << sq << '\n';
cout << "snk: " << snk << '\n';
cout << "L size: " << L.size() << '\n';
l[0] = l[1];
cout << "l[0]: " << l[0] << '\n';
while( l[0] < L.size() ){
float val = L.at(l[0]) + 2*(l[1] - l[0]);
if( val <= sq ) break;
--l[0];
}
cout << "l0: " << l[0] << " highest level <= l1\n";
l[2] = l[1] + 1;
cout << "l[2]" << l[2] << '\n';
while( l[2] < L.size() ){
float val = L.at(l[2]) + 2*(l[2] - l[1] - 1);
if( val <= snk ) break;
++l[2];
}
cout << "l2: " << l[2] << " lowest level >= l1 + 1\n";
return shrinktree(g_orig, g_copy, vis_data_orig, vis_data_copy, L, l); // step 6
}
// Step 4: l1_and_k
// Time: O(n)
//
// Find the level l1 such that the total cost of levels 0 through l1 - 1 does not exceed 1/2,
// but the total cost of levels 0 through l1 does exceed 1/2.
// Let k be the number of vertices in levels 0 through l1
Partition l1_and_k(GraphCR g_orig, Graph& g_copy, vector<uint> const& L, BFSVisitorData const& vis_data_orig, BFSVisitorData const& vis_data_copy)
{
//BOOST_ASSERT(assert_verts(g_copy, vis_data_copy)); // disabled because it doesn't support connected components
cout << "---------------------------- 4 - l1 and k ------------\n";
uint k = L[0];
uint l[3];
uint n = num_vertices(g_copy);
l[1] = 0;
while( k <= n/2 ){
uint indx = ++l[1];
uint lsize = L.size();
if( indx >= lsize ) break;
k += L.at(indx);
}
cout << "k: " << k << " # of verts in levels 0 thru l1\n";
cout << "l1: " << l[1] << " total cost of levels 0 thru l1 barely exceeds 1/2\n";
BOOST_ASSERT(k <= n);
return find_more_levels(g_orig, g_copy, k, l, L, vis_data_orig, vis_data_copy); // step 5
}
// Step 3: bfs_and_levels
// Time: O(n)
//
// Find a breadth-first spanning tree of the most costly component.
// Compute the level of each vertex and the number of vertices L(l) in each level l.
Partition bfs_and_levels(GraphCR g_orig, Graph& g_copy)
{
cout << "---------------------------- 3 - BFS and Levels ------------\n";
BFSVisitorData vis_data_copy(&g_copy, *vertices(g_copy).first);
breadth_first_search(g_copy, vis_data_copy.root, boost::visitor(BFSVisitor(vis_data_copy)));
BFSVisitorData vis_data_orig(&g_orig, *vertices(g_orig).first);
breadth_first_search(g_orig, vis_data_orig.root, boost::visitor(BFSVisitor(vis_data_orig)));
// disabled because they don't support multiple connected components
//BOOST_ASSERT(assert_verts(g_orig, vis_data_orig));
//BOOST_ASSERT(assert_verts(g_copy, vis_data_copy));
vector<uint> L(vis_data_copy.num_levels + 1, 0);
cout << "L levels: " << L.size() << '\n';
for( auto& d : vis_data_copy.verts ){
cout << "level: " << d.second.level << '\n';
++L[d.second.level];
}
VertIter vit, vjt;
for( tie(vit, vjt) = vertices(g_copy); vit != vjt; ++vit ){
if( vis_data_copy.verts.contains(*vit) ) cout << "level/cost of vert " << *vit << ": " << vis_data_copy.verts[*vit].level << '\n';
}
for( uint i = 0; i < L.size(); ++i ){
cout << "L[" << i << "]: " << L[i] << '\n';
}
return l1_and_k(g_orig, g_copy, L, vis_data_orig, vis_data_copy); // step 4
}
// Step 2: find_connected_components
// Time: O(n)
//
// Find the connected components of G and determine the cost of each one.
// If none has cost exceeding 2/3, construct the partition as described in the proof of Theorem 4.
// If some component has cost exceeding 2/3, go to Step 3.
Partition find_connected_components(GraphCR g_orig, Graph& g_copy)
{
uint n = num_vertices(g_copy);
//cout << "---------------------------- 2 - Find Connected Components --------\n";
vertex_map idx;
associative_property_map<vertex_map> vertid_to_component(idx);
VertIter vit, vjt;
tie(vit, vjt) = vertices(g_copy);
for( uint i = 0; vit != vjt; ++vit, ++i ){
//cout << "checking vertex number: " << i << ' ' << *vit << '\n';
put(vertid_to_component, *vit, i);
}
uint num_components = connected_components(g_copy, vertid_to_component);
//cout << "# of connected components: " << num_components << '\n';
vector<uint> num_verts_per_component(num_components, 0);
for( tie(vit, vjt) = vertices(g_copy); vit != vjt; ++vit ){
++num_verts_per_component[vertid_to_component[*vit]];
}
uint biggest_component_index = 0;
uint biggest_size = 0;
bool bigger_than_two_thirds = false;
for( uint i = 0; i < num_components; ++i ){
if( 3*num_verts_per_component[i] > 2*num_vertices(g_copy) ){
//cout << "component " << i << " is bigger than two thirds of the entire graph\n";
bigger_than_two_thirds = true;
}
if( num_verts_per_component[i] > biggest_size ){
biggest_size = num_verts_per_component[i];
biggest_component_index = i;
}
}
if( !bigger_than_two_thirds ){
cout << "exiting early through theorem 4 - no component has cost exceeding two thirds\n";
// connected graphs can never get here because they would have a single component with total cost > 2/3
Partition defp;
return theorem4_disconnected(g_copy, n, num_components, vertid_to_component, num_verts_per_component, defp);
}
cout << "index of biggest component: " << biggest_component_index << '\n';
return bfs_and_levels(g_orig, g_copy); // step 3
}
// Step 1: check_planarity
// Time: big-theta(n)
//
// Find a planar embedding of G and construct a representation for it of the kind described above.
Partition lipton_tarjan_separator(GraphCR g_orig)
{
Graph g_copy(g_orig);
//cout << "@#$original g:\n";
print_graph(g_orig);
//cout << "@#$g_copy:\n";
//print_graph2(g_copy);
/*auto prop_map = get(vertex_index, g_copy);
VertIter vi, vend;
for( tie(vi, vend) = vertices(g_copy); vi != vend; ++vi ){
cout << "vert#: " << prop_map[*vi] << '\n';
}*/
/*cout << "---------------------------- 0 - Printing Edges -------------------\n";
cout << "edges of g:\n";*/
//cout << "edges of g_copy:\n" << std::endl;
cout << "---------------------------- 1 - Check Planarity ------------\n";
EmbedStruct em(&g_copy);
if( !em.test_planar() ) throw NotPlanarException();
return find_connected_components(g_orig, g_copy);
}
| 49.311669
| 224
| 0.603672
|
jeffythedragonslayer
|
2a11bad50ddeed1c4d00966be02e838f549793ce
| 9,417
|
cpp
|
C++
|
Meteorites.Tests/GoldSolverTests.cpp
|
m-krivov/MeteoriteSimulator
|
a60cdef30ffff0bfab11ee8db799b41b3cdee452
|
[
"MIT"
] | null | null | null |
Meteorites.Tests/GoldSolverTests.cpp
|
m-krivov/MeteoriteSimulator
|
a60cdef30ffff0bfab11ee8db799b41b3cdee452
|
[
"MIT"
] | null | null | null |
Meteorites.Tests/GoldSolverTests.cpp
|
m-krivov/MeteoriteSimulator
|
a60cdef30ffff0bfab11ee8db799b41b3cdee452
|
[
"MIT"
] | null | null | null |
#include "TestDefs.h"
#include "Meteorites.CpuSolvers/GoldSolver.h"
TEST_CLASS(GoldSolverTests)
{
public:
TEST_METHOD(Vacuum_VerticalSpeed)
{
GoldSolver solver(GoldSolver::ONE_STEP_ADAMS);
solver.Configure(dt_sim, 3600.0f);
Case problem(1.0f, 0.0f, 2000.0f, 0.0f, 0.0f,
1.0f, 0.5f, 1000.0f, (real)std::_Pi / 2);
FakeFunctional f;
BufferingFormatter fmt(0.1f);
solver.Solve(problem, f, fmt);
decltype(auto) log = ExtractLogPtrs<1>(fmt)[0];
decltype(auto) last_record = log->records[log->records.size() - 1];
Assert::IsTrue(std::abs(last_record.M - problem.M0()) < (real)1e-3);
auto a = -Constants::g() / 2.0;
auto b = -problem.V0();
auto c = problem.h0() - last_record.h;
auto d = b * b - 4 * a * c;
auto t = (-b - std::sqrt(d)) / (2 * a);
Assert::IsTrue(std::abs(last_record.t - t) < 1e-2f);
Assert::IsTrue(std::abs(last_record.V - (problem.V0() + Constants::g() * t)) < 1e-1f);
}
TEST_METHOD(Vacuum_HorizontalSpeed)
{
GoldSolver solver(GoldSolver::ONE_STEP_ADAMS);
solver.Configure(dt_sim, 3600.0f);
Case problem(1.0f, 0.0f, 2000.0f, 0.0f, 0.0f,
1.0f, 2.5f, 500.0f, 0.0f);
FakeFunctional f;
BufferingFormatter fmt(0.1f);
solver.Solve(problem, f, fmt);
decltype(auto) log = ExtractLogPtrs<1>(fmt)[0];
decltype(auto) last_record = log->records[log->records.size() - 1];
Assert::IsTrue(std::abs(last_record.M - problem.M0()) < (real)1e-3);
auto a = -Constants::g() / 2.0;
auto b = 0.0f;
auto c = problem.h0() - last_record.h;
auto d = b * b - 4 * a * c;
auto t = (-b - std::sqrt(d)) / (2 * a);
auto dist = problem.V0() * std::cos(problem.Gamma0()) * t;
Assert::IsTrue(std::abs(last_record.t - t) < 1e-2f);
Assert::IsTrue(std::abs(last_record.V - Constants::g() * t) < 1e-1f);
Assert::IsTrue(std::abs(last_record.l - dist) < 2e-1f);
}
TEST_METHOD(Atmosphere_BrakingForce)
{
GoldSolver solver(GoldSolver::ONE_STEP_ADAMS);
solver.Configure(dt_sim, 3600.0f);
FakeFunctional f;
BufferingFormatter fmt(0.0f);
for (auto Cd : { 0.0f, 0.5f, 1.0f, 1.5f, 2.0f })
{
Case problem(1.0f, 0.0f, 2000.0f, Cd, 0.0f,
1.0f, 50.0f, 500.0f, -(real)std::_Pi / 4);
solver.Solve(problem, f, fmt);
}
decltype(auto) logs = ExtractLogPtrs<5>(fmt);
std::array<std::pair<real, real>, 5> peaks;
for (size_t i = 0; i < logs.size(); i++)
{
decltype(auto) records = logs[i]->records;
auto peak = std::make_pair(records[0].h, records[0].t);
bool peak_reached = false;
for (size_t j = 1; j < records.size(); j++)
{
if (!peak_reached)
{
if (records[j].h < peak.first)
{ peak_reached = true; }
else
{ peak = std::make_pair(records[j].h, records[j].t); }
}
else
{ Assert::IsTrue(records[j].h < peak.first); }
} // for j
peaks[i] = peak;
} // for i
for (size_t i = 1; i < peaks.size(); i++)
{
Assert::IsTrue(peaks[i - 1].first > peaks[i].first * 1.005f);
Assert::IsTrue(peaks[i - 1].second > peaks[i].second * 1.005f);
}
}
TEST_METHOD(Atmosphere_LiftingForce)
{
GoldSolver solver(GoldSolver::ONE_STEP_ADAMS);
solver.Configure(dt_sim, 3600.0f);
FakeFunctional f;
BufferingFormatter fmt(0.0f);
for (auto Cl : { 0.0f, 0.05f, 0.1f, 0.15f })
{
Case problem(1.0f, 0.0f, 2000.0f, 0.0f, Cl,
1.0f, 100.0f, 500.0f, 0.0f);
solver.Solve(problem, f, fmt);
}
decltype(auto) logs = ExtractLogPtrs<4>(fmt);
for (size_t i = 0; i < logs.size() - 1; i++)
{
Assert::IsTrue(logs[i]->reason == IResultFormatter::Reason::Collided);
Assert::IsTrue(logs[i + 1]->reason == IResultFormatter::Reason::Collided);
Assert::IsTrue(logs[i]->records.size() > 1000);
for (size_t j = 1000; j < logs[i]->records.size(); j++)
{
if (j >= logs[i + 1]->records.size()) { break; }
Assert::IsTrue(logs[i + 1]->records[j].h > logs[i]->records[j].h * 1.001f);
} // for j
} // for i
}
TEST_METHOD(Atmosphere_HeatExchange)
{
GoldSolver solver(GoldSolver::ONE_STEP_ADAMS);
solver.Configure(dt_sim, 3600.0f);
FakeFunctional f;
BufferingFormatter fmt(0.0f);
for (auto coeffs : { std::make_pair(1e6f, 0.3f),
std::make_pair(2e6f, 0.2f),
std::make_pair(3e6f, 0.1f) })
{
Case problem(coeffs.first, coeffs.second, 2000.0f, 0.0f, 0.0f,
10.0f, 100.0f, 2000.0f, 0.0f);
solver.Solve(problem, f, fmt);
}
decltype(auto) logs = ExtractLogPtrs<3>(fmt);
for (size_t i = 0; i < logs.size(); i++)
{
decltype(auto) records = logs[i]->records;
for (size_t j = 1; j < records.size(); j++)
{ Assert::IsTrue(records[j - 1].M > records[j].M); }
} // for i
auto n = std::min(logs[0]->records.size(), logs[1]->records.size());
n = std::min(n, logs[2]->records.size());
Assert::IsTrue(n > 1000);
for (size_t i = 1000; i < n; i++)
{
Assert::IsTrue(logs[1]->records[i].M > logs[0]->records[i].M * 1.0001f);
Assert::IsTrue(logs[2]->records[i].M > logs[1]->records[i].M * 1.0001f);
}
}
TEST_METHOD(Method_TwoThreeSteps)
{
GoldSolver one_step(GoldSolver::ONE_STEP_ADAMS),
two_step(GoldSolver::TWO_STEP_ADAMS),
three_step(GoldSolver::THREE_STEP_ADAMS);
for (auto solver : { &one_step, &two_step, &three_step })
{ solver->Configure(dt_sim, 3600.0f); }
FakeFunctional f;
std::vector<Case> problems;
problems.emplace_back(Case(1e6f, 0.35f, 3500.0f, 1.1f, 0.1f,
10.0f, 14e3f, 60e3f, 0.0f));
problems.emplace_back(Case(0.5e6f, 0.5f, 2000.0f, 1.5f, 0.05f,
5.0f, 10e3f, 55e3f, (real)std::_Pi / 9));
for (auto &problem : problems)
{
BufferingFormatter fmt(0.01f);
for (auto solver : { &one_step, &two_step, &three_step })
{ solver->Solve(problem, f, fmt); }
auto logs = ExtractLogPtrs<3>(fmt);
auto n = std::min(logs[0]->records.size(),
logs[1]->records.size());
n = std::min(n, logs[2]->records.size());
for (size_t i = 0; i < n; i++)
{
AreAlmostEqual(logs[0]->records[i].gamma,
logs[1]->records[i].gamma,
logs[2]->records[i].gamma, 1e-2f);
AreAlmostEqual(logs[0]->records[i].h,
logs[1]->records[i].h,
logs[2]->records[i].h, 1e1f);
AreAlmostEqual(logs[0]->records[i].M,
logs[1]->records[i].M,
logs[2]->records[i].M, 1e-1f);
AreAlmostEqual(logs[0]->records[i].V,
logs[1]->records[i].V,
logs[2]->records[i].V, 1e1f);
} // for j
} // for problem
}
TEST_METHOD(Method_Precision)
{
GoldSolver solver(GoldSolver::ONE_STEP_ADAMS);
Case problem(0.5e6f, 0.1f, 4000.0f, 1.0f, 0.01f,
25.0f, 5e3f, 30e3f, (real)std::_Pi / 4);
FakeFunctional f;
BufferingFormatter fmt(0.01f);
for (auto dt : { 1e-3f, 1e-4f, 1e-5f })
{
solver.Configure(dt, 3600.0f);
solver.Solve(problem, f, fmt);
}
auto logs = ExtractLogPtrs<3>(fmt);
auto n = std::min(logs[0]->records.size(),
logs[1]->records.size());
n = std::min(n, logs[2]->records.size());
for (size_t i = 0; i < n; i++)
{
AreAlmostEqual(logs[0]->records[i].gamma,
logs[1]->records[i].gamma,
logs[2]->records[i].gamma, 1e-2f);
AreAlmostEqual(logs[0]->records[i].h,
logs[1]->records[i].h,
logs[2]->records[i].h, 1e1f);
AreAlmostEqual(logs[0]->records[i].M,
logs[1]->records[i].M,
logs[2]->records[i].M, 1e-1f);
AreAlmostEqual(logs[0]->records[i].V,
logs[1]->records[i].V,
logs[2]->records[i].V, 1e1f);
} // for j
}
private:
template <size_t N>
static decltype(auto) ExtractLogPtrs(const BufferingFormatter &fmt)
{
decltype(auto) logs = fmt.Logs();
Assert::AreEqual(logs.size(), N);
std::array<const BufferingFormatter::Log *, N> res;
for (size_t i = 0; i < logs.size(); i++)
{
decltype(auto) log = logs[i];
Assert::IsFalse(log.records.empty());
Assert::IsTrue(log.reason != IResultFormatter::Reason::NA);
res[i] = &log;
}
return res;
}
void AreAlmostEqual(real val1, real val2, real val3, real eps)
{
Assert::IsTrue(std::abs(val1 - val2) <= eps);
Assert::IsTrue(std::abs(val1 - val3) <= eps);
Assert::IsTrue(std::abs(val2 - val3) <= eps);
}
real dt_sim = (real)1e-3;
};
| 35.007435
| 92
| 0.520442
|
m-krivov
|
2a135182bcd849349aba93fed5d88b57833f0d87
| 21,399
|
cpp
|
C++
|
src/core/graph/internal/GraphInternal.cpp
|
alexbatashev/athena
|
eafbb1e16ed0b273a63a20128ebd4882829aa2db
|
[
"MIT"
] | 2
|
2020-07-16T06:42:27.000Z
|
2020-07-16T06:42:28.000Z
|
src/core/graph/internal/GraphInternal.cpp
|
PolarAI/polarai-framework
|
c5fd886732afe787a06ebf6fb05fc38069257457
|
[
"MIT"
] | null | null | null |
src/core/graph/internal/GraphInternal.cpp
|
PolarAI/polarai-framework
|
c5fd886732afe787a06ebf6fb05fc38069257457
|
[
"MIT"
] | null | null | null |
//===----------------------------------------------------------------------===//
// Copyright (c) 2020 PolarAI. All rights reserved.
//
// Licensed under MIT license.
//
// 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 <polarai/core/graph/internal/GraphInternal.hpp>
#include <polarai/core/node/internal/NodeInternal.hpp>
#include <polarai/loaders/internal/ConstantLoaderInternal.hpp>
#include <polarai/loaders/internal/DummyLoaderInternal.hpp>
#include <polarai/operation/AddOperation.hpp>
#include <polarai/operation/MulOperation.hpp>
#include <polarai/operation/internal/AddOperationInternal.hpp>
#include <polarai/operation/internal/MulOperationInternal.hpp>
#include <queue>
namespace polarai::core::internal {
GraphInternal::GraphInternal(utils::WeakPtr<ContextInternal> context,
utils::Index publicGraphIndex, utils::String name)
: Entity(std::move(context), publicGraphIndex, std::move(name)),
mTopology{}, mTraversal{}, mInputNodeIndexes{}, mInputsCount{},
mOutputsCount{} {}
template <typename Queue, typename Storage>
void initQueue(Queue& queue, const Storage& storage) {
for (auto inputNodeIndex : storage) {
queue.push(inputNodeIndex);
}
}
template <typename Map, typename Getter>
size_t safetyIncrementMapValue(Map& map, utils::Index index, Getter& getter) {
auto it = map.find(index);
if (it != map.end()) {
getter(map, index)++;
} else {
getter(map, index) = 1;
}
return getter(map, index);
}
void GraphInternal::connect(utils::Index startNode, utils::Index endNode,
EdgeMark edgeMark) {
mTopology.emplace_back(startNode, endNode, edgeMark);
auto getter = [](std::unordered_map<utils::Index, size_t>& map,
utils::Index index) -> size_t& { return map[index]; };
safetyIncrementMapValue(mInputsCount, endNode, getter);
safetyIncrementMapValue(mOutputsCount, startNode, getter);
}
std::tuple<std::vector<TensorInternal*>, std::unordered_map<int64_t, utils::Index>>
getOperationArgIndexes(utils::SharedPtr<ContextInternal>& context,
const NodeState& nodeState) {
std::vector<TensorInternal*> operationArgs{};
std::unordered_map<int64_t, utils::Index> mapMarkToLocalTensorIndex{};
operationArgs.reserve(nodeState.input.size());
size_t index = 0;
for (auto& inputDependence : nodeState.input) {
mapMarkToLocalTensorIndex[inputDependence.mark] = index;
operationArgs.push_back(
context->getPtr<AbstractNodeInternal>(inputDependence.nodeIndex)
->getTensorPtr());
++index;
}
return std::make_tuple(operationArgs, mapMarkToLocalTensorIndex);
}
void GraphInternal::setUpTensors() const {
auto contextInternal = mContext.lock();
for (auto& cluster : mTraversal.getClusters()) {
for (auto& nodeState : cluster.content) {
auto [args, mapMarkToLocalTensorIndex] = getOperationArgIndexes(contextInternal, nodeState);
auto node =
contextInternal->getPtr<AbstractNodeInternal>(nodeState.nodeIndex);
if (node->getTensorIndex() != 0) {
continue;
}
if (std::find(mInputNodeIndexes.begin(), mInputNodeIndexes.end(),
node->getPublicIndex()) != mInputNodeIndexes.end()) {
continue;
} else if (node->getType() == NodeType::DEFAULT) {
auto funcNode = static_cast<NodeInternal*>(node);
auto tensorIndex = funcNode->getOperationPtr()->createResultTensor(
mContext.lock(), mapMarkToLocalTensorIndex, args);
funcNode->setTensorIndex(tensorIndex);
} else if (node->getType() == NodeType::OUTPUT) {
#ifdef DEBUG
if (args.size() != 1) {
utils::FatalError(utils::ATH_ASSERT,
"Error while setUpTensors() is working. Number "
"arguments coming to output node doesn't equal 1.");
}
#endif
node->setTensorIndex(args[0]->getPublicIndex());
}
}
}
}
void GraphInternal::initInputNodeStates(
std::unordered_map<utils::Index, NodeState>& isPartOfWayToUnfrozenFlags)
const {
auto context = mContext.lock();
for (auto& indexInputNode : mInputNodeIndexes) {
auto& abstractNode = context->getRef<AbstractNodeInternal>(indexInputNode);
if (abstractNode.getType() == NodeType::INPUT) {
auto& inputNode = static_cast<InputNodeInternal&>(abstractNode);
isPartOfWayToUnfrozenFlags[indexInputNode] =
NodeState{inputNode.isFrozen()};
} else {
isPartOfWayToUnfrozenFlags[indexInputNode] = NodeState{true};
}
}
}
void GraphInternal::bypassDependenceOfCurrentNodeState(
const NodeState& currentNodeState, size_t currentClusterIndex,
size_t currentNodeStateIndex,
std::unordered_map<utils::Index, NodeState>& nodeStates,
std::unordered_map<utils::Index, NodeStateIndex>& traversedNodeStates) {
for (auto& dependence : currentNodeState.input) {
auto nodeIndex = dependence.nodeIndex;
std::vector<Dependency>* outputs{};
if (nodeStates.find(nodeIndex) != nodeStates.end()) {
outputs = &nodeStates.at(nodeIndex).output;
} else {
auto index = traversedNodeStates.at(nodeIndex);
outputs = &mTraversal.clusters()[index.clusterIndex]
.content[index.nodeStateIndex]
.output;
}
for (auto& output : *outputs) {
if (output.nodeIndex == currentNodeState.nodeIndex) {
output.clusterIndex = currentClusterIndex;
output.nodeStateIndex = currentNodeStateIndex;
}
}
}
for (auto& dependence : currentNodeState.output) {
auto nodeIndex = dependence.nodeIndex;
std::vector<Dependency>* inputs{};
if (nodeStates.find(nodeIndex) != nodeStates.end()) {
inputs = &nodeStates.at(nodeIndex).input;
} else {
auto index = traversedNodeStates.at(nodeIndex);
inputs = &mTraversal.clusters()[index.clusterIndex]
.content[index.nodeStateIndex]
.input;
}
for (auto& input : *inputs) {
if (input.nodeIndex == currentNodeState.nodeIndex) {
input.clusterIndex = currentClusterIndex;
input.nodeStateIndex = currentNodeStateIndex;
}
}
}
}
const Traversal& GraphInternal::traverse() {
if (mTraversal.isValidTraversal()) {
return mTraversal;
}
std::sort(mTopology.begin(), mTopology.end());
std::queue<utils::Index> currentQueue, newQueue;
initQueue(currentQueue, mInputNodeIndexes);
std::unordered_map<utils::Index, NodeState> nodeStates;
std::unordered_map<utils::Index, NodeStateIndex> traversedNodeStates;
initInputNodeStates(nodeStates);
while (true) {
Cluster cluster{0};
while (!currentQueue.empty()) {
size_t startNodeIndex = currentQueue.front();
currentQueue.pop();
Edge target(startNodeIndex, 0, 0);
auto edgeIterator =
std::lower_bound(mTopology.begin(), mTopology.end(), target);
while (edgeIterator != mTopology.end() &&
edgeIterator->startNodeIndex == startNodeIndex) {
auto endNodeIndex = edgeIterator->endNodeIndex;
auto getter = [](std::unordered_map<utils::Index, NodeState>& map,
utils::Index index) -> size_t& {
return map[index].inputsCount;
};
auto resInputsCount =
safetyIncrementMapValue(nodeStates, endNodeIndex, getter);
auto targetInputCount = mInputsCount.at(endNodeIndex);
if (resInputsCount == targetInputCount) {
newQueue.push(endNodeIndex);
} else if (resInputsCount > targetInputCount) {
utils::FatalError(utils::ATH_FATAL_OTHER,
"traverse() in Graph: ", this,
". Graph has cycle(s)");
}
nodeStates[startNodeIndex].output.emplace_back(endNodeIndex,
edgeIterator->mark);
nodeStates[endNodeIndex].input.emplace_back(startNodeIndex,
edgeIterator->mark);
nodeStates[endNodeIndex].isWayToFrozen =
nodeStates[endNodeIndex].isWayToFrozen &&
nodeStates[startNodeIndex].isWayToFrozen;
++edgeIterator;
}
auto& processedState = nodeStates[startNodeIndex];
cluster.content.emplace_back(startNodeIndex, processedState.inputsCount,
processedState.isWayToFrozen,
std::move(processedState.input),
std::move(processedState.output));
traversedNodeStates[startNodeIndex] = NodeStateIndex{
mTraversal.clusters().size(), cluster.content.size() - 1};
nodeStates.erase(startNodeIndex);
++cluster.nodeCount;
auto& currentNodeState = cluster.content.back();
bypassDependenceOfCurrentNodeState(
currentNodeState, mTraversal.clusters().size(),
cluster.content.size() - 1, nodeStates, traversedNodeStates);
}
if (cluster.nodeCount > 0) {
mTraversal.clusters().emplace_back(std::move(cluster));
}
std::swap(currentQueue, newQueue);
if (currentQueue.empty()) {
break;
}
}
mTraversal.validTraversalFlag() = true;
setUpTensors();
return mTraversal;
}
utils::Index
GraphInternal::createInitialGradientNode(GraphInternal& gradientGraph, const NodeState* nodeStatePtr) const {
auto context = mContext.lock();
auto& node = context->getRef<AbstractNodeInternal>(nodeStatePtr->nodeIndex);
auto tensor = node.getTensorPtr();
auto loaderIndex = context->create<loaders::internal::ConstantLoaderInternal>(
context, context->getNextPublicIndex(), 1.0);
auto resultNodeIndex = context->create<InputNodeInternal>(
context, context->getNextPublicIndex(), tensor->getShape(),
tensor->getDataType(), true, loaderIndex,
(std::string("InitialNode_") +
std::to_string(context->getNextPublicIndex()))
.data());
gradientGraph.mInputNodeIndexes.emplace_back(resultNodeIndex);
return resultNodeIndex;
}
void GraphInternal::mergeEdges(const std::vector<core::internal::Edge>& edges) {
for (auto& edge : edges) {
connect(edge.startNodeIndex, edge.endNodeIndex, edge.mark);
}
}
utils::Index GraphInternal::accumulateOutputNodes(
GraphInternal& gradient, const NodeState* nodeStatePtr,
const std::unordered_map<const NodeState*, utils::Index>&
mapNodeStateToFinalGradientIndex) const {
#ifdef DEBUG
if (nodeStatePtr->output.size() == 0) {
utils::FatalError(utils::ATH_ASSERT,
"Error while accumulateOutputNodes() is working. Output "
"of node state contains 0 states.");
}
#endif
auto context = mContext.lock();
auto addOperationIndex =
context->create<operation::internal::AddOperationInternal>(
context, context->getNextPublicIndex(),
(std::string("AddOperation_") +
std::to_string(context->getNextPublicIndex()))
.data());
auto& shape =
context->getRef<AbstractNodeInternal>(nodeStatePtr->nodeIndex)
.getTensorPtr()
->getShape();
auto zeroLoaderIndex =
context->create<loaders::internal::ConstantLoaderInternal>(
context, context->getNextPublicIndex(), 0.0,
(std::string("ZeroLoaderIndex_") +
std::to_string(context->getNextPublicIndex()))
.data());
auto finalGradientIndex = gradient.create<InputNodeInternal>(
shape, DataType::FLOAT, true, zeroLoaderIndex,
(std::string("ZeroInputNode_") +
std::to_string(context->getNextPublicIndex()))
.data());
for (size_t indexOutputDependence = 0;
indexOutputDependence < nodeStatePtr->output.size();
++indexOutputDependence) {
auto& dependence = nodeStatePtr->output[indexOutputDependence];
auto resNodeStatePtr = &mTraversal.getClusters()[dependence.clusterIndex]
.content[dependence.nodeStateIndex];
auto& abstractNode =
context->getRef<AbstractNodeInternal>(dependence.nodeIndex);
if (abstractNode.getType() == NodeType::DEFAULT) {
auto& node = static_cast<NodeInternal&>(abstractNode);
auto operationPtr = node.getOperationPtr();
auto [newFinalGradientIndex, edges, newInputNodes] =
operationPtr->genDerivative(
nodeStatePtr, resNodeStatePtr, indexOutputDependence,
mapNodeStateToFinalGradientIndex.at(resNodeStatePtr));
auto addNodeIndex = context->create<core::internal::NodeInternal>(
context, context->getNextPublicIndex(), addOperationIndex,
(std::string("AddNodeLinker_") +
std::to_string(context->getNextPublicIndex()))
.data());
gradient.connect(newFinalGradientIndex, addNodeIndex,
operation::AddOperation::LEFT);
gradient.connect(finalGradientIndex, addNodeIndex,
operation::AddOperation::RIGHT);
finalGradientIndex = addNodeIndex;
gradient.mergeEdges(edges);
for (auto newInputNodeIndex : newInputNodes) {
gradient.mInputNodeIndexes.emplace_back(newInputNodeIndex);
}
} else {
// TODO error
}
}
return finalGradientIndex;
}
std::tuple<utils::Index, std::unordered_map<utils::Index, utils::Index>>
GraphInternal::createGradientGraph(utils::Index targetNodeIndex) const {
auto context = mContext.lock();
auto& targetNode = context->getRef<AbstractNodeInternal>(targetNodeIndex);
if (targetNode.getType() != NodeType::DEFAULT) {
utils::FatalError(utils::ATH_BAD_ACCESS, "Target node isn't a functional node.");
return {};
}
auto gradientGraphIndex = context->create<GraphInternal>(
mContext, context->getNextPublicIndex(),
(std::string("GradientGraph_") +
std::to_string(context->getNextPublicIndex()))
.data());
auto& gradientGraph = context->getRef<GraphInternal>(gradientGraphIndex);
std::unordered_map<const NodeState*, utils::Index>
mapNodeStateToFinalGradientIndex;
std::unordered_map<utils::Index, utils::Index> inputNodeChangers;
if (mTraversal.getClusters().size() <= 1) {
return {};
}
utils::Index gradientFinalNodeIndex = 0;
bool targetNodeFound = false;
size_t indexCluster = mTraversal.getClusters().size() - 1;
auto& clusterCollection = mTraversal.getClusters();
for (auto rClusterIterator = clusterCollection.rbegin(); rClusterIterator != clusterCollection.rend(); ++rClusterIterator) {
auto& cluster = *rClusterIterator;
for (const auto& nodeState : cluster.content) {
if (!targetNodeFound) {
if (nodeState.nodeIndex == targetNodeIndex) {
targetNodeFound = true;
gradientFinalNodeIndex = createInitialGradientNode(gradientGraph, &nodeState);
mapNodeStateToFinalGradientIndex[&nodeState] = gradientFinalNodeIndex;
}
} else {
if (nodeState.isWayToFrozen) {
continue;
}
auto nodeStatePtr = &nodeState;
gradientFinalNodeIndex = accumulateOutputNodes(
gradientGraph, nodeStatePtr, mapNodeStateToFinalGradientIndex);
mapNodeStateToFinalGradientIndex[nodeStatePtr] = gradientFinalNodeIndex;
if (indexCluster == 0) {
auto& inputNode = context->getRef<InputNodeInternal>(nodeState.nodeIndex);
if (!inputNode.isFrozen()) {
inputNodeChangers[inputNode.getPublicIndex()] = gradientFinalNodeIndex;
}
}
}
}
--indexCluster;
}
gradientGraph.traverse();
return std::make_tuple(gradientGraphIndex, inputNodeChangers);
}
utils::Index GraphInternal::createWeightChangingGraph(
const std::unordered_map<utils::Index, utils::Index>& mapInputNodes) {
auto context = mContext.lock();
auto weightChangingGraphIndex = context->create<GraphInternal>(
mContext, context->getNextPublicIndex(),
(std::string("WeightChangingGraph_") +
std::to_string(context->getNextPublicIndex()))
.data());
auto& weightChangingGraph =
context->getRef<GraphInternal>(weightChangingGraphIndex);
auto learningRateLoaderIndex =
context->create<loaders::internal::ConstantLoaderInternal>(
context, context->getNextPublicIndex(), -0.01,
(std::string("LearningRateLoader_") +
std::to_string(context->getNextPublicIndex()))
.data()); // TODO give runtime args to graph
auto dummyLoader =
context->create<loaders::internal::DummyLoaderInternal>(
context, context->getNextPublicIndex(),
(std::string("DummyLoader_") +
std::to_string(context->getNextPublicIndex()))
.data());
auto multiplyOperation =
context->create<operation::internal::MulOperationInternal>(
context, context->getNextPublicIndex(),
(std::string("MultiplyOperation_") +
std::to_string(context->getNextPublicIndex()))
.data());
auto addOperation =
context->create<operation::internal::AddOperationInternal>(
context, context->getNextPublicIndex(),
(std::string("AddOperation_") +
std::to_string(context->getNextPublicIndex()))
.data());
for (auto& edge : mapInputNodes) { /// grad - second, initial graph - first
auto gradientFinalNodeIndex = edge.second;
auto sourceGraphInputNodeIndex = edge.first;
auto& sourceGraphInputNode =
context->getRef<internal::AbstractNodeInternal>(
sourceGraphInputNodeIndex);
auto& gradientFinalNode =
context->getRef<internal::AbstractNodeInternal>(gradientFinalNodeIndex);
auto& gradientShape = gradientFinalNode.getTensorPtr()->getShape();
auto gradientDataType = gradientFinalNode.getTensorPtr()->getDataType();
auto dummyNodeIndex = context->create<InputNodeInternal>(context, context->getNextPublicIndex(), gradientShape, gradientDataType, true, dummyLoader, (std::string("DummyNodeGradValueHolder_") +
std::to_string(context->getNextPublicIndex()))
.data());
auto& dummyNode = context->getRef<AbstractNodeInternal>(dummyNodeIndex);
dummyNode.setTensorIndex(gradientFinalNode.getTensorIndex());
auto learningRateHolderNodeIndex = context->create<InputNodeInternal>(
context, context->getNextPublicIndex(), gradientShape, gradientDataType,
true, learningRateLoaderIndex,
(std::string("LearningRateHolderNode_") +
std::to_string(context->getNextPublicIndex()))
.data());
weightChangingGraph.mInputNodeIndexes.emplace_back(dummyNodeIndex);
weightChangingGraph.mInputNodeIndexes.emplace_back(learningRateHolderNodeIndex);
auto multiplyNodeIndex = context->create<NodeInternal>(
context, context->getNextPublicIndex(), multiplyOperation,
(std::string("LearningRateMultiplyNode_") +
std::to_string(context->getNextPublicIndex()))
.data());
weightChangingGraph.connect(dummyNodeIndex, multiplyNodeIndex,
operation::MulOperation::LEFT);
weightChangingGraph.connect(learningRateHolderNodeIndex, multiplyNodeIndex,
operation::MulOperation::RIGHT);
auto sourceGraphInputNodeHolderIndex = context->create<InputNodeInternal>(
context, context->getNextPublicIndex(), gradientShape, gradientDataType,
true, dummyLoader,
(std::string("SourceHolderNode_") +
std::to_string(context->getNextPublicIndex()))
.data());
auto& sourceGraphInputNodeHolder = context->getRef<AbstractNodeInternal>(sourceGraphInputNodeHolderIndex);
sourceGraphInputNodeHolder.setTensorIndex(sourceGraphInputNode.getTensorIndex());
weightChangingGraph.mInputNodeIndexes.emplace_back(sourceGraphInputNodeHolderIndex);
auto addNodeIndex = context->create<NodeInternal>(
context, context->getNextPublicIndex(), addOperation,
(std::string("SourceNodeChanger_") +
std::to_string(context->getNextPublicIndex()))
.data());
auto& addNode = context->getRef<NodeInternal>(addNodeIndex);
addNode.setTensorIndex(sourceGraphInputNode.getTensorIndex());
weightChangingGraph.connect(multiplyNodeIndex, addNodeIndex,
operation::AddOperation::LEFT);
weightChangingGraph.connect(sourceGraphInputNodeHolderIndex,
addNodeIndex,
operation::AddOperation::RIGHT);
}
weightChangingGraph.traverse();
return weightChangingGraphIndex;
}
std::tuple<utils::Index, utils::Index> GraphInternal::getGradient(utils::Index targetNodeIndex) {
traverse();
auto [gradientCalculatingGraphIndex, mapInputNodes] = createGradientGraph(targetNodeIndex);
auto weightChangingGraphIndex = createWeightChangingGraph(mapInputNodes);
return std::make_tuple(gradientCalculatingGraphIndex,
weightChangingGraphIndex);
}
} // namespace polarai::core::internal
| 44.030864
| 196
| 0.672415
|
alexbatashev
|
2a1618ac5fa12b27203eae430a3b0626a1072042
| 14,232
|
cpp
|
C++
|
data/frameProcessor/src/HexitecThresholdPlugin.cpp
|
stfc-aeg/hexitec-detector
|
c535cd212b39a809990fbec91bf503723f6ad787
|
[
"Apache-2.0"
] | 1
|
2020-10-22T07:50:41.000Z
|
2020-10-22T07:50:41.000Z
|
data/frameProcessor/src/HexitecThresholdPlugin.cpp
|
stfc-aeg/hexitec-detector
|
c535cd212b39a809990fbec91bf503723f6ad787
|
[
"Apache-2.0"
] | 68
|
2020-10-19T08:16:02.000Z
|
2022-03-12T00:55:16.000Z
|
data/frameProcessor/src/HexitecThresholdPlugin.cpp
|
stfc-aeg/hexitec-detector
|
c535cd212b39a809990fbec91bf503723f6ad787
|
[
"Apache-2.0"
] | null | null | null |
/*
* HexitecThresholdPlugin.cpp
*
* Created on: 11 Jul 2018
* Author: Christian Angelsen
*/
#include <HexitecThresholdPlugin.h>
#include "version.h"
namespace FrameProcessor
{
const std::string HexitecThresholdPlugin::CONFIG_THRESHOLD_MODE = "threshold_mode";
const std::string HexitecThresholdPlugin::CONFIG_THRESHOLD_VALUE = "threshold_value";
const std::string HexitecThresholdPlugin::CONFIG_THRESHOLD_FILE = "threshold_filename";
const std::string HexitecThresholdPlugin::CONFIG_SENSORS_LAYOUT = "sensors_layout";
/**
* The constructor sets up logging used within the class.
*/
HexitecThresholdPlugin::HexitecThresholdPlugin() :
image_width_(Hexitec::pixel_columns_per_sensor),
image_height_(Hexitec::pixel_rows_per_sensor),
image_pixels_(image_width_ * image_height_),
threshold_filename_("")
{
// Setup logging for the class
logger_ = Logger::getLogger("FP.HexitecThresholdPlugin");
logger_->setLevel(Level::getAll());
LOG4CXX_TRACE(logger_, "HexitecThresholdPlugin version " <<
this->get_version_long() << " loaded.");
thresholds_status_ = false;
threshold_value_ = 0;
threshold_per_pixel_ = (uint16_t *) calloc(image_pixels_, sizeof(uint16_t));
/// Set threshold mode to none (initially; 0=none, 1=value, 2=file)
threshold_mode_ = (ThresholdMode)0;
sensors_layout_str_ = Hexitec::default_sensors_layout_map;
parse_sensors_layout_map(sensors_layout_str_);
}
/**
* Destructor.
*/
HexitecThresholdPlugin::~HexitecThresholdPlugin()
{
LOG4CXX_TRACE(logger_, "HexitecThresholdPlugin destructor.");
free(threshold_per_pixel_);
threshold_per_pixel_ = NULL;
}
int HexitecThresholdPlugin::get_version_major()
{
return ODIN_DATA_VERSION_MAJOR;
}
int HexitecThresholdPlugin::get_version_minor()
{
return ODIN_DATA_VERSION_MINOR;
}
int HexitecThresholdPlugin::get_version_patch()
{
return ODIN_DATA_VERSION_PATCH;
}
std::string HexitecThresholdPlugin::get_version_short()
{
return ODIN_DATA_VERSION_STR_SHORT;
}
std::string HexitecThresholdPlugin::get_version_long()
{
return ODIN_DATA_VERSION_STR;
}
/**
* Configure the Hexitec plugin. This receives an IpcMessage which should be processed
* to configure the plugin, and any response can be added to the reply IpcMessage. This
* plugin supports the following configuration parameters:
*
* - sensors_layout_str_ <=> sensors_layout
* - max_frames_received_ <=> max_frames_received
* - threshold_mode_ <=> threshold_mode
* - threshold_value_ <=> threshold_value
* - threshold_filename_ <=> threshold_file
*
* \param[in] config - Reference to the configuration IpcMessage object.
* \param[in] reply - Reference to the reply IpcMessage object.
*/
void HexitecThresholdPlugin::configure(OdinData::IpcMessage& config, OdinData::IpcMessage& reply)
{
if (config.has_param(HexitecThresholdPlugin::CONFIG_SENSORS_LAYOUT))
{
sensors_layout_str_= config.get_param<std::string>(HexitecThresholdPlugin::CONFIG_SENSORS_LAYOUT);
parse_sensors_layout_map(sensors_layout_str_);
}
// Parsing sensors may update width, height
if (image_width_ * image_height_ != image_pixels_)
{
image_pixels_ = image_width_ * image_height_;
reset_threshold_values();
}
if (config.has_param(HexitecThresholdPlugin::CONFIG_THRESHOLD_MODE))
{
std::string threshold_mode = config.get_param<std::string>(
HexitecThresholdPlugin::CONFIG_THRESHOLD_MODE);
if (threshold_mode.compare(std::string("none")) == 0)
{
threshold_mode_ = (ThresholdMode)0;
LOG4CXX_TRACE(logger_, "User selected threshold mode: none");
}
else if (threshold_mode.compare(std::string("value")) == 0)
{
threshold_mode_ = (ThresholdMode)1;
LOG4CXX_TRACE(logger_, "User selected threshold mode: value");
}
else if (threshold_mode.compare(std::string("filename")) == 0)
{
threshold_mode_ = (ThresholdMode)2;
LOG4CXX_TRACE(logger_, "User selected threshold mode: filename");
}
}
if (config.has_param(HexitecThresholdPlugin::CONFIG_THRESHOLD_VALUE))
{
threshold_value_ = config.get_param<int>(
HexitecThresholdPlugin::CONFIG_THRESHOLD_VALUE);
LOG4CXX_TRACE(logger_, "Setting threshold value to: " << threshold_value_);
}
if (config.has_param(HexitecThresholdPlugin::CONFIG_THRESHOLD_FILE))
{
threshold_filename_ = config.get_param<std::string>(
HexitecThresholdPlugin::CONFIG_THRESHOLD_FILE);
// Update threshold filename if filename mode selected
if (!threshold_filename_.empty())
{
LOG4CXX_TRACE(logger_, "Setting thresholds from file: " << threshold_filename_);
if (set_threshold_per_pixel(threshold_filename_.c_str()))
{
LOG4CXX_TRACE(logger_, "Read thresholds from file successfully");
}
else
{
LOG4CXX_ERROR(logger_, "Failed to read thresholds from file")
}
}
}
}
void HexitecThresholdPlugin::requestConfiguration(OdinData::IpcMessage& reply)
{
// Return the configuration of the process plugin
std::string base_str = get_name() + "/";
reply.set_param(base_str + HexitecThresholdPlugin::CONFIG_SENSORS_LAYOUT, sensors_layout_str_);
int mode = int(threshold_mode_);
std::string mode_str = determineThresholdMode(mode);
reply.set_param(base_str + HexitecThresholdPlugin::CONFIG_THRESHOLD_MODE, mode_str);
reply.set_param(base_str + HexitecThresholdPlugin::CONFIG_THRESHOLD_VALUE, threshold_value_);
reply.set_param(base_str + HexitecThresholdPlugin::CONFIG_THRESHOLD_FILE, threshold_filename_);
}
/**
* Collate status information for the plugin. The status is added to the status IpcMessage object.
*
* \param[in] status - Reference to an IpcMessage value to store the status.
*/
void HexitecThresholdPlugin::status(OdinData::IpcMessage& status)
{
// Record the plugin's status items
LOG4CXX_DEBUG(logger_, "Status requested for HexitecThresholdPlugin");
status.set_param(get_name() + "/sensors_layout", sensors_layout_str_);
int mode = int(threshold_mode_);
std::string mode_str = determineThresholdMode(mode);
status.set_param(get_name() + "/threshold_mode", mode_str);
status.set_param(get_name() + "/threshold_value", threshold_value_);
status.set_param(get_name() + "/threshold_filename", threshold_filename_);
}
/**
* Convert threshold mode (enumerated integer) into string
*/
std::string HexitecThresholdPlugin::determineThresholdMode(int mode)
{
std::string mode_str = "";
switch(mode)
{
case 0:
mode_str = "none";
break;
case 1:
mode_str = "value";
break;
case 2:
mode_str = "filename";
break;
}
return mode_str;
}
/**
* Reset process plugin statistics
*/
bool HexitecThresholdPlugin::reset_statistics(void)
{
// Nowt to reset..?
return true;
}
/**
* Perform processing on the frame. Apply selected threshold mode.
*
* \param[in] frame - Pointer to a Frame object.
*/
void HexitecThresholdPlugin::process_frame(boost::shared_ptr<Frame> frame)
{
// Obtain a pointer to the start of the data in the frame
const void* data_ptr = static_cast<const void*>(
static_cast<const char*>(frame->get_data_ptr()));
// Check datasets name
FrameMetaData &incoming_frame_meta = frame->meta_data();
const std::string& dataset = incoming_frame_meta.get_dataset_name();
if (dataset.compare(std::string("raw_frames")) == 0)
{
LOG4CXX_TRACE(logger_, "Pushing " << dataset << " dataset, frame number: "
<< frame->get_frame_number());
this->push(frame);
}
else if (dataset.compare(std::string("processed_frames")) == 0)
{
try
{
// Define pointer to the input image data
void* input_ptr = static_cast<void *>(
static_cast<char *>(const_cast<void *>(data_ptr)));
// Execute selected method of applying threshold(s) (none, value, or file)
switch (threshold_mode_)
{
case 0:
// No threshold processing
break;
case 1:
process_threshold_value(static_cast<float *>(input_ptr));
LOG4CXX_TRACE(logger_, "Applying threshold value to frame.");
break;
case 2:
process_threshold_file(static_cast<float *>(input_ptr));
LOG4CXX_TRACE(logger_, "Applying thresholds from file to frame.");
break;
}
LOG4CXX_TRACE(logger_, "Pushing " << dataset <<
" dataset, frame number: " << frame->get_frame_number());
this->push(frame);
}
catch (const std::exception& e)
{
LOG4CXX_ERROR(logger_, "HexitecThresholdPlugin failed: " << e.what());
}
}
else
{
LOG4CXX_ERROR(logger_, "Unknown dataset encountered: " << dataset);
}
}
/**
* Zero all pixels below threshold_value_.
*
* \param[in] in - Pointer to the image data.
*
*/
void HexitecThresholdPlugin::process_threshold_value(float *in)
{
for (int i=0; i < image_pixels_; i++)
{
// Clear pixel if it doesn't meet the threshold:
if (in[i] < threshold_value_)
{
in[i] = 0;
}
}
}
/**
* Zero each pixel not meeting its corresponding pixel threshold.
*
* \param[in] in - Pointer to the image data.
*
*/
void HexitecThresholdPlugin::process_threshold_file(float *in)
{
for (int i=0; i < image_pixels_; i++)
{
// Clear pixel if it doesn't meet the threshold:
if (in[i] < threshold_per_pixel_[i])
{
in[i] = 0;
}
}
}
/**
* Set each pixel threshold from the values by the provided file.
*
* \param[in] threshold_filename - the filename containing threshold values.
*
* \return bool indicating whether reading file was successful
*/
bool HexitecThresholdPlugin::set_threshold_per_pixel(const char *threshold_filename)
{
uint16_t defaultValue = 0;
thresholds_status_ = get_data(threshold_filename, defaultValue);
return thresholds_status_;
}
/**
* Set each pixel threshold from the values by the provided file.
*
* \param[in] threshold_filename - the filename containing threshold values.
* \param[in] default_value - Default value if there's any issues reading the file
*
* \return bool indicating whether reading file was successful
*/
bool HexitecThresholdPlugin::get_data(const char *filename, uint16_t default_value)
{
int index = 0, thresholdFromFile = 0;
bool success = false;
/// Count number of floats in file:
std::ifstream file(filename);
int file_values = std::distance(std::istream_iterator<double>(file),
std::istream_iterator<double>());
file.close();
if (image_pixels_ != file_values)
{
LOG4CXX_ERROR(logger_, "Expected " << image_pixels_ << " values but read " <<
file_values << " values from file: " << filename);
LOG4CXX_WARN(logger_, "Using default values instead");
for (int val = 0; val < image_pixels_; val ++)
{
threshold_per_pixel_[val] = default_value;
}
return success;
}
std::ifstream inFile(filename);
std::string line;
while(std::getline(inFile, line))
{
std::stringstream ss(line);
while( ss >> thresholdFromFile )
{
threshold_per_pixel_[index] = thresholdFromFile;
index++;
}
}
inFile.close();
success = true;
return success;
}
/**
* Parse the number of sensors map configuration string.
*
* This method parses a configuration string containing number of sensors mapping information,
* which is expected to be of the format "NxN" e.g, 2x2. The map's saved in a member variable.
*
* \param[in] sensors_layout_str - string of number of sensors configured
* \return number of valid map entries parsed from string
*/
std::size_t HexitecThresholdPlugin::parse_sensors_layout_map(const std::string sensors_layout_str)
{
// Clear the current map
sensors_layout_.clear();
// Define entry and port:idx delimiters
const std::string entry_delimiter("x");
// Vector to hold entries split from map
std::vector<std::string> map_entries;
// Split into entries
boost::split(map_entries, sensors_layout_str, boost::is_any_of(entry_delimiter));
// If a valid entry is found, save into the map
if (map_entries.size() == 2) {
int sensor_rows = static_cast<int>(strtol(map_entries[0].c_str(), NULL, 10));
int sensor_columns = static_cast<int>(strtol(map_entries[1].c_str(), NULL, 10));
sensors_layout_[0] = Hexitec::HexitecSensorLayoutMapEntry(sensor_rows, sensor_columns);
}
image_width_ = sensors_layout_[0].sensor_columns_ * Hexitec::pixel_columns_per_sensor;
image_height_ = sensors_layout_[0].sensor_rows_ * Hexitec::pixel_rows_per_sensor;
// Return the number of valid entries parsed
return sensors_layout_.size();
}
/**
* Reset array used to store threshold values.
*
* This method is called when the number of sensors is changed,
* to prevent accessing unassigned memory
*/
void HexitecThresholdPlugin::reset_threshold_values()
{
free(threshold_per_pixel_);
threshold_per_pixel_ = (uint16_t *) calloc(image_pixels_, sizeof(uint16_t));
}
} /* namespace FrameProcessor */
| 32.944444
| 105
| 0.649592
|
stfc-aeg
|
2a1a7e7a18142c1ee49b0eebc9c9a2ee771762d3
| 490
|
cpp
|
C++
|
src/1663/1663-Smallest-String-With-A-Given-Numeric-Value-UnitTest.cpp
|
coldnew/leetcode-solutions
|
3bc7943f8341397840ecd34aefc5af6e52b09b4e
|
[
"Unlicense"
] | 2
|
2022-03-10T17:06:18.000Z
|
2022-03-11T08:52:00.000Z
|
src/1663/1663-Smallest-String-With-A-Given-Numeric-Value-UnitTest.cpp
|
coldnew/leetcode-solutions
|
3bc7943f8341397840ecd34aefc5af6e52b09b4e
|
[
"Unlicense"
] | null | null | null |
src/1663/1663-Smallest-String-With-A-Given-Numeric-Value-UnitTest.cpp
|
coldnew/leetcode-solutions
|
3bc7943f8341397840ecd34aefc5af6e52b09b4e
|
[
"Unlicense"
] | null | null | null |
#include <gtest/gtest.h>
#include "1663-Smallest-String-With-A-Given-Numeric-Value.cpp"
#define LEETCODE_TEST(SolutionX) \
TEST(SmallestStringWithAGivenNumericValueTest, SolutionX) { \
SolutionX s; \
EXPECT_EQ("aay", s.getSmallestString(3, 27)); \
EXPECT_EQ("aaszz", s.getSmallestString(5, 73)); \
}
LEETCODE_TEST(Solution1)
LEETCODE_TEST(Solution2)
LEETCODE_TEST(Solution3)
| 32.666667
| 63
| 0.597959
|
coldnew
|
2a1af715d88b1579c055abb7b170f46cd05b265d
| 893
|
cpp
|
C++
|
src/WebSocketProto/WebSocketProto.cpp
|
yottaawesome/bits-test
|
3ce1d08b0f86161b11d50e50f04170c624c27bcd
|
[
"MIT"
] | 1
|
2020-11-29T19:06:20.000Z
|
2020-11-29T19:06:20.000Z
|
src/WebSocketProto/WebSocketProto.cpp
|
yottaawesome/bits-test
|
3ce1d08b0f86161b11d50e50f04170c624c27bcd
|
[
"MIT"
] | 1
|
2020-12-12T21:35:45.000Z
|
2020-12-12T21:35:45.000Z
|
src/WebSocketProto/WebSocketProto.cpp
|
yottaawesome/bits-test
|
3ce1d08b0f86161b11d50e50f04170c624c27bcd
|
[
"MIT"
] | null | null | null |
#define _SILENCE_ALL_CXX20_DEPRECATION_WARNINGS 1
#include <vector>
#include <Windows.h>
#include "WinHttp.hpp"
#include "testmessage.pb.h"
#pragma comment(lib, "winhttp.lib")
int main(int argc, char** args)
{
TestMessage ts;
ts.set_sometext("poop");
WinHttp::WinHttpWebSocket ws(L"https://127.0.0.1", 51935, true);
ws.Connect();
//ws.Receive(receivedBuffer);
std::vector<char> buffer;
buffer.resize(256);
if (ts.SerializeToArray(&buffer[0], buffer.size()))
std::cout << "OK" << std::endl;
//std::string msg(buffer.begin(), buffer.end());
//buffer.shrink_to_fit();
//ws.SendString("Hoohee");
ws.SendBuffer(buffer);
std::string receivedBuffer;
ws.Receive(receivedBuffer);
TestMessage ts2;
ts2.ParseFromArray(&receivedBuffer[0], receivedBuffer.size());
std::cout << ts2.sometext() << std::endl;
return 0;
}
| 24.135135
| 68
| 0.655095
|
yottaawesome
|
2a1d93449690fe46cc10bdc1c70c04897ee65cd5
| 351
|
hpp
|
C++
|
include/Client/Vector.hpp
|
semper24/R-Type
|
b91184d656ffcec39b0a43e7a42c1a1ecd236c9b
|
[
"MIT"
] | null | null | null |
include/Client/Vector.hpp
|
semper24/R-Type
|
b91184d656ffcec39b0a43e7a42c1a1ecd236c9b
|
[
"MIT"
] | null | null | null |
include/Client/Vector.hpp
|
semper24/R-Type
|
b91184d656ffcec39b0a43e7a42c1a1ecd236c9b
|
[
"MIT"
] | null | null | null |
/*
** EPITECH PROJECT, 2019
** OOP_arcade_2019
** File description:
** Vector.hpp
*/
#ifndef _VECTOR_HPP_
# define _VECTOR_HPP_
struct posVector {
posVector() = default;
posVector(const posVector& other) = default;
posVector& operator=(const posVector& other) = default;
~posVector() = default;
float x;
float y;
};
#endif
| 15.954545
| 59
| 0.669516
|
semper24
|
2a204353dfa4eebda8b2d6a97be2c9cffc287f6f
| 1,331
|
cpp
|
C++
|
linux/Chess/Player.cpp
|
bricsi0000000000000/Chess
|
f1d93153bc7d2f25a117cdc81c69ac23b6407f87
|
[
"MIT"
] | null | null | null |
linux/Chess/Player.cpp
|
bricsi0000000000000/Chess
|
f1d93153bc7d2f25a117cdc81c69ac23b6407f87
|
[
"MIT"
] | null | null | null |
linux/Chess/Player.cpp
|
bricsi0000000000000/Chess
|
f1d93153bc7d2f25a117cdc81c69ac23b6407f87
|
[
"MIT"
] | null | null | null |
#include "Player.h"
Player::Player(std::string name, Color color, bool is_bot) : name(name), points(0), color(color), is_bot(is_bot) {}
std::string Player::GetName() {
return name;
}
int Player::GetPoints() {
return points;
}
void Player::AddPoints(int point) {
points += point;
}
Color Player::GetColor() {
return color;
}
std::vector<std::shared_ptr<Piece>> Player::GetOffPieces() {
return off_pieces;
}
void Player::AddOffPiece(std::shared_ptr<Piece> piece) {
off_pieces.push_back(piece);
}
void Player::RemoveOffPiece(std::shared_ptr<Piece> piece) {
for (int i = 0; i < off_pieces.size(); i++) {
if (off_pieces[i]->GetPosition()->x == piece->GetPosition()->x && off_pieces[i]->GetPosition()->y == piece->GetPosition()->y) {
off_pieces.erase(off_pieces.begin() + i);
}
}
}
void Player::ClearOffPieces() {
off_pieces.clear();
}
bool Player::IsBot() {
return is_bot;
}
std::string Player::GetStepFrom() {
return step_from;
}
std::string Player::GetStepTo() {
return step_to;
}
void Player::SetStepFrom(std::string position) {
step_from = position;
}
void Player::SetStepTo(std::string position) {
step_to = position;
}
std::shared_ptr<Piece> Player::GetStepPiece() {
return step_piece;
}
void Player::SetStepPiece(std::shared_ptr<Piece> piece) {
step_piece = piece;
}
| 19.573529
| 131
| 0.676935
|
bricsi0000000000000
|
2a20c70f99f9eb70be02ee9758619655be7e7d70
| 14,820
|
cpp
|
C++
|
sources/Engine/Modules/Graphics/OpenGL/GLGraphicsContext.cpp
|
n-paukov/swengine
|
ca7441f238e8834efff5d2b61b079627824bf3e4
|
[
"MIT"
] | 22
|
2017-07-26T17:42:56.000Z
|
2022-03-21T22:12:52.000Z
|
sources/Engine/Modules/Graphics/OpenGL/GLGraphicsContext.cpp
|
n-paukov/swengine
|
ca7441f238e8834efff5d2b61b079627824bf3e4
|
[
"MIT"
] | 50
|
2017-08-02T19:37:48.000Z
|
2020-07-24T21:10:38.000Z
|
sources/Engine/Modules/Graphics/OpenGL/GLGraphicsContext.cpp
|
n-paukov/swengine
|
ca7441f238e8834efff5d2b61b079627824bf3e4
|
[
"MIT"
] | 4
|
2018-08-20T08:12:48.000Z
|
2020-07-19T14:10:05.000Z
|
#include "precompiled.h"
#pragma hdrstop
#include "GLGraphicsContext.h"
#include <spdlog/spdlog.h>
#include "Modules/Graphics/GraphicsSystem/FrameStats.h"
#include "Exceptions/exceptions.h"
#include "options.h"
GLGraphicsContext::GLGraphicsContext(SDL_Window* window)
: m_window(window)
{
spdlog::info("Creating OpenGL context");
m_sdlGLContext.m_glContext = SDL_GL_CreateContext(m_window);
if (m_sdlGLContext.m_glContext == nullptr) {
THROW_EXCEPTION(EngineRuntimeException, std::string(SDL_GetError()));
}
if (gl3wInit()) {
THROW_EXCEPTION(EngineRuntimeException, "Failed to initialize OpenGL");
}
if (!gl3wIsSupported(4, 5)) {
THROW_EXCEPTION(EngineRuntimeException, "Failed to load OpenGL functions");
}
glEnable(GL_DEBUG_OUTPUT);
glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB);
glDebugMessageCallback(reinterpret_cast<GLDEBUGPROCARB>(&debugOutputCallback), this);
int bufferWidth, bufferHeight;
SDL_GetWindowSize(m_window, &bufferWidth, &bufferHeight);
m_defaultFramebuffer = std::unique_ptr<GLFramebuffer>(new GLFramebuffer(bufferWidth, bufferHeight));
m_ndcTexturedQuad = std::make_unique<GLGeometryStore>(
std::vector<VertexPos3Norm3UV>{
{{-1.0f, 1.0f, 1.0f}, glm::vec3(), {0.0f, 1.0f}},
{{-1.0f, -1.0f, 1.0f}, glm::vec3(), {0.0f, 0.0f}},
{{1.0f, 1.0f, 1.0f}, glm::vec3(), {1.0f, 1.0f}},
{{1.0f, -1.0f, 1.0f}, glm::vec3(), {1.0f, 0.0f}},
}, std::vector<std::uint16_t>{0, 2, 1, 1, 2, 3});
int framebufferWidth = bufferWidth;
int framebufferHeight = bufferHeight;
std::shared_ptr<GLTexture> mrtAlbedo = std::make_shared<GLTexture>(GLTextureType::Texture2D,
framebufferWidth,
framebufferHeight,
GLTextureInternalFormat::RGBA8);
std::shared_ptr<GLTexture> mrtNormals = std::make_shared<GLTexture>(GLTextureType::Texture2D,
framebufferWidth,
framebufferHeight,
GLTextureInternalFormat::RGB16F);
std::shared_ptr<GLTexture> mrtPositions = std::make_shared<GLTexture>(GLTextureType::Texture2D,
framebufferWidth,
framebufferHeight,
GLTextureInternalFormat::RGB32F);
std::shared_ptr<GLTexture> depthStencil = std::make_shared<GLTexture>(GLTextureType::Texture2D,
framebufferWidth,
framebufferHeight,
GLTextureInternalFormat::Depth24Stencil8);
m_deferredFramebuffer = std::make_unique<GLFramebuffer>(framebufferWidth,
framebufferHeight,
std::vector{mrtAlbedo, mrtNormals, mrtPositions},
depthStencil);
std::shared_ptr<GLTexture> forwardAlbedo = std::make_shared<GLTexture>(GLTextureType::Texture2D,
framebufferWidth,
framebufferHeight,
GLTextureInternalFormat::RGBA8);
m_forwardFramebuffer = std::make_unique<GLFramebuffer>(framebufferWidth, framebufferHeight,
std::vector{forwardAlbedo}, depthStencil);
m_sceneTransformationBuffer = std::make_unique<GLUniformBuffer<SceneTransformation>>();
m_sceneTransformationBuffer->attachToBindingEntry(0);
m_guiTransformationBuffer = std::make_unique<GLUniformBuffer<GUITransformation>>();
m_guiTransformationBuffer->attachToBindingEntry(1);
spdlog::info("OpenGL context is created");
}
GLGraphicsContext::~GLGraphicsContext()
{
}
void GLGraphicsContext::swapBuffers()
{
SDL_GL_SwapWindow(m_window);
}
void GLGraphicsContext::setDepthTestMode(DepthTestMode mode)
{
switch (mode) {
case DepthTestMode::Disabled:
glDisable(GL_DEPTH_TEST);
break;
case DepthTestMode::LessOrEqual:
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);
break;
case DepthTestMode::Less:
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LESS);
break;
case DepthTestMode::NotEqual:
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_NOTEQUAL);
default:
break;
}
applyContextChange();
}
void GLGraphicsContext::setFaceCullingMode(FaceCullingMode mode)
{
switch (mode) {
case FaceCullingMode::Disabled:
glDisable(GL_CULL_FACE);
break;
case FaceCullingMode::Back:
glEnable(GL_CULL_FACE);
glCullFace(GL_BACK);
break;
case FaceCullingMode::Front:
glEnable(GL_CULL_FACE);
glCullFace(GL_FRONT);
break;
default:
break;
}
applyContextChange();
}
void GLGraphicsContext::setPolygonFillingMode(PolygonFillingMode mode)
{
switch (mode) {
case PolygonFillingMode::Fill:
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
break;
case PolygonFillingMode::Wireframe:
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
break;
default:
break;
}
applyContextChange();
}
void GLGraphicsContext::setBlendingMode(BlendingMode mode)
{
switch (mode) {
case BlendingMode::Disabled:
glDisable(GL_BLEND);
break;
case BlendingMode::Alpha_OneMinusAlpha:
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
break;
default:
break;
}
applyContextChange();
}
void GLGraphicsContext::setDepthWritingMode(DepthWritingMode mode)
{
switch (mode) {
case DepthWritingMode::Disabled:
glDepthMask(GL_FALSE);
break;
case DepthWritingMode::Enabled:
glDepthMask(GL_TRUE);
break;
default:
break;
}
applyContextChange();
}
GLGeometryStore& GLGraphicsContext::getNDCTexturedQuad() const
{
return *m_ndcTexturedQuad.get();
}
void GLGraphicsContext::applyContextChange()
{
resetMaterial();
}
void GLGraphicsContext::resetMaterial()
{
m_currentMaterial = nullptr;
}
void APIENTRY GLGraphicsContext::debugOutputCallback(GLenum source,
GLenum type,
GLuint id,
GLenum severity,
GLsizei length,
const GLchar* message,
GLvoid* userParam)
{
ARG_UNUSED(source);
ARG_UNUSED(length);
ARG_UNUSED(userParam);
// Skip some debug information from GPU
if constexpr (!LOG_GPU_ADDITIONAL_DEBUG_INFO_MESSAGES) {
if (id == 131185) {
return;
}
}
std::string debugMessage = "[OpenGL] ";
switch (type) {
case GL_DEBUG_TYPE_ERROR:
debugMessage += "error";
break;
case GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR:
debugMessage += "deprecated behavior";
break;
case GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR:
debugMessage += "undefined behavior";
break;
case GL_DEBUG_TYPE_PORTABILITY:
debugMessage += "portability";
break;
case GL_DEBUG_TYPE_PERFORMANCE:
debugMessage += "performance";
break;
case GL_DEBUG_TYPE_OTHER:
debugMessage += "common";
break;
default:
debugMessage += fmt::format("Unknown ({})", type);
break;
}
debugMessage += " (" + std::to_string(id) + ", ";
switch (severity) {
case GL_DEBUG_SEVERITY_LOW:
debugMessage += "low";
break;
case GL_DEBUG_SEVERITY_MEDIUM:
debugMessage += "medium";
break;
case GL_DEBUG_SEVERITY_HIGH:
debugMessage += "high";
break;
default:
debugMessage += fmt::format("Unknown ({})", severity);
break;
}
debugMessage += ") " + std::string(message);
//GLGraphicsContext* context = static_cast<GLGraphicsContext*>(userParam);
switch (type) {
case GL_DEBUG_TYPE_ERROR:
case GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR:
case GL_DEBUG_TYPE_PORTABILITY:
spdlog::error(debugMessage);
break;
case GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR:
case GL_DEBUG_TYPE_PERFORMANCE:
spdlog::warn(debugMessage);
break;
case GL_DEBUG_TYPE_OTHER:
spdlog::debug(debugMessage);
break;
default:
spdlog::debug(debugMessage);
break;
}
}
void GLGraphicsContext::setupScissorsTest(ScissorsTestMode mode)
{
switch (mode) {
case ScissorsTestMode::Disabled:
glDisable(GL_SCISSOR_TEST);
break;
case ScissorsTestMode::Enabled:
glEnable(GL_SCISSOR_TEST);
break;
default:
break;
}
applyContextChange();
}
void GLGraphicsContext::setupGraphicsScene(std::shared_ptr<GraphicsScene> graphicsScene)
{
m_graphicsScene = std::move(graphicsScene);
}
void GLGraphicsContext::scheduleRenderTask(const RenderTask& task)
{
m_renderingQueues[static_cast<size_t>(task.material->getRenderingStage())].push_back(task);
}
void GLGraphicsContext::executeRenderTasks()
{
// TODO: get rid of buffers clearing and copying as possible
// For example, use depth swap trick to avoid depth buffer clearing
// Setup scene state uniform buffers
std::shared_ptr<Camera> activeCamera = m_graphicsScene->getActiveCamera();
if (activeCamera) {
m_sceneTransformationBuffer->getBufferData().view = m_graphicsScene->getActiveCamera()->getViewMatrix();
m_sceneTransformationBuffer->getBufferData().projection = m_graphicsScene->getActiveCamera()->getProjectionMatrix();
}
else {
m_sceneTransformationBuffer->getBufferData().view = glm::identity<glm::mat4>();
m_sceneTransformationBuffer->getBufferData().projection = glm::identity<glm::mat4>();
}
m_sceneTransformationBuffer->synchronizeWithGpu();
m_guiTransformationBuffer->getBufferData().projection = m_guiProjectionMatrix;
m_guiTransformationBuffer->synchronizeWithGpu();
// Render current frame
glDisable(GL_SCISSOR_TEST);
glDepthMask(GL_TRUE);
m_deferredFramebuffer->clearColor({0.0f, 0.0f, 0.0f, 0.0f}, 0);
m_deferredFramebuffer->clearColor({0.0f, 0.0f, 0.0f, 0.0f}, 1);
m_deferredFramebuffer->clearColor({0.0f, 0.0f, 0.0f, 0.0f}, 2);
m_deferredFramebuffer->clearDepthStencil(1.0f, 0);
glBindFramebuffer(GL_FRAMEBUFFER, m_deferredFramebuffer->getGLHandle());
executeRenderingStageQueue(RenderingStage::Deferred);
GLShadersPipeline* accumulationPipeline = &m_deferredAccumulationMaterial->getShadersPipeline();
GLShader* accumulationFragmentShader = accumulationPipeline->getShader(ShaderType::Fragment);
const GLFramebuffer& deferredFramebuffer = *m_deferredFramebuffer;
accumulationFragmentShader->setParameter("gBuffer.albedo",
*deferredFramebuffer.getColorComponent(0), 0);
accumulationFragmentShader->setParameter("gBuffer.normals",
*deferredFramebuffer.getColorComponent(1), 1);
accumulationFragmentShader->setParameter("gBuffer.positions",
*deferredFramebuffer.getColorComponent(2), 2);
glDisable(GL_SCISSOR_TEST);
glBindFramebuffer(GL_FRAMEBUFFER, m_forwardFramebuffer->getGLHandle());
glBindProgramPipeline(accumulationPipeline->m_programPipeline);
applyGpuState(m_deferredAccumulationMaterial->getGpuStateParameters());
m_deferredAccumulationMaterial->getGLParametersBinder()->bindParameters(*accumulationPipeline);
getNDCTexturedQuad().drawRange(0, 6, GL_TRIANGLES);
executeRenderingStageQueue(RenderingStage::Forward);
executeRenderingStageQueue(RenderingStage::ForwardDebug);
executeRenderingStageQueue(RenderingStage::ForwardEnvironment);
executeRenderingStageQueue(RenderingStage::PostProcess);
executeRenderingStageQueue(RenderingStage::GUI);
// m_defaultFramebuffer->clearColor({0.0f, 0.0f, 0.0f, 1.0f});
// m_defaultFramebuffer->clearDepthStencil(0.0f, 0);
glDisable(GL_SCISSOR_TEST);
m_forwardFramebuffer->copyColor(*m_defaultFramebuffer);
m_forwardFramebuffer->copyDepthStencil(*m_defaultFramebuffer);
}
void GLGraphicsContext::setupDeferredAccumulationMaterial(std::shared_ptr<GLShadersPipeline> pipeline)
{
GpuStateParameters gpuState;
gpuState.setBlendingMode(BlendingMode::Disabled);
gpuState.setDepthTestMode(DepthTestMode::NotEqual);
gpuState.setDepthWritingMode(DepthWritingMode::Disabled);
gpuState.setFaceCullingMode(FaceCullingMode::Disabled);
gpuState.setPolygonFillingMode(PolygonFillingMode::Fill);
m_deferredAccumulationMaterial = std::make_unique<GLMaterial>(RenderingStage::Deferred,
std::move(pipeline),
gpuState,
std::make_unique<ShadingParametersGenericSet>());
}
void GLGraphicsContext::applyGpuState(const GpuStateParameters& gpuState)
{
setBlendingMode(gpuState.getBlendingMode());
setDepthTestMode(gpuState.getDepthTestMode());
setFaceCullingMode(gpuState.getFaceCullingMode());
setPolygonFillingMode(gpuState.getPolygonFillingMode());
setDepthWritingMode(gpuState.getDepthWritingMode());
setupScissorsTest(gpuState.getScissorsTestMode());
}
void GLGraphicsContext::executeRenderingStageQueue(RenderingStage stage)
{
auto& queue = m_renderingQueues[static_cast<size_t>(stage)];
if (queue.empty()) {
return;
}
applyGpuState(queue.begin()->material->getGpuStateParameters());
for (const auto& renderingTask : queue) {
GLShadersPipeline& shadersPipeline = renderingTask.material->getShadersPipeline();
glBindProgramPipeline(shadersPipeline.m_programPipeline);
const auto& shadingParametersBinder = renderingTask.material->getGLParametersBinder();
GLShader* vertexShader = shadersPipeline.getShader(ShaderType::Vertex);
if (&shadersPipeline != m_currentShadersPipeline) {
m_currentShadersPipeline = &shadersPipeline;
}
if (renderingTask.matrixPalette != nullptr && vertexShader->hasParameter("animation.palette[0]")) {
vertexShader->setArrayParameter("animation.palette",
renderingTask.matrixPalette, renderingTask.mesh->getSkeleton()->getBonesCount());
}
shadingParametersBinder->bindParameters(shadersPipeline);
if (vertexShader->hasParameter("transform.local")) {
vertexShader->setParameter("transform.local", *renderingTask.transform);
}
if (renderingTask.material->getGpuStateParameters().getScissorsTestMode() == ScissorsTestMode::Enabled) {
glScissor(renderingTask.scissorsRect.getOriginX(),
m_defaultFramebuffer->getHeight() - renderingTask.scissorsRect.getOriginY()
- renderingTask.scissorsRect.getHeight(),
renderingTask.scissorsRect.getWidth(), renderingTask.scissorsRect.getHeight());
}
renderingTask.mesh->getGeometryStore()->drawRange(
renderingTask.mesh->getSubMeshIndicesOffset(renderingTask.subMeshIndex),
renderingTask.mesh->getSubMeshIndicesCount(renderingTask.subMeshIndex),
renderingTask.primitivesType);
}
m_renderingQueues[static_cast<size_t>(stage)].clear();
}
int GLGraphicsContext::getViewportWidth() const
{
return m_defaultFramebuffer->getWidth();
}
int GLGraphicsContext::getViewportHeight() const
{
return m_defaultFramebuffer->getHeight();
}
void GLGraphicsContext::setGUIProjectionMatrix(const glm::mat4& projection)
{
m_guiProjectionMatrix = projection;
}
const glm::mat4& GLGraphicsContext::getGUIProjectionMatrix() const
{
return m_guiProjectionMatrix;
}
void GLGraphicsContext::unloadResources()
{
m_deferredAccumulationMaterial.reset();
m_defaultFramebuffer.reset();
m_ndcTexturedQuad.reset();
m_deferredFramebuffer.reset();
m_forwardFramebuffer.reset();
m_deferredAccumulationMaterial.reset();
m_sceneTransformationBuffer.reset();
m_guiTransformationBuffer.reset();
}
SDLGLContext::~SDLGLContext()
{
SDL_GL_DeleteContext(m_glContext);
}
| 28.33652
| 120
| 0.741768
|
n-paukov
|
2a24a509d120560b682941d047a102f04ba1a6af
| 3,705
|
cxx
|
C++
|
CPP/cgal3d.cxx
|
amit112amit/learning-cgal
|
a00b2a559cc9bd38fd041873353423f13406cb01
|
[
"MIT"
] | 2
|
2019-06-01T06:55:57.000Z
|
2019-12-18T15:54:13.000Z
|
CPP/cgal3d.cxx
|
amit112amit/learning-cgal
|
a00b2a559cc9bd38fd041873353423f13406cb01
|
[
"MIT"
] | null | null | null |
CPP/cgal3d.cxx
|
amit112amit/learning-cgal
|
a00b2a559cc9bd38fd041873353423f13406cb01
|
[
"MIT"
] | null | null | null |
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Delaunay_triangulation_3.h>
#include <CGAL/Triangulation_vertex_base_with_info_3.h>
#include <Eigen/Dense>
#include <vtkPolyDataReader.h>
#include <vtkPolyDataWriter.h>
#include <vtkPolyData.h>
#include <vtkCellArray.h>
#include <vtkDoubleArray.h>
#include <vtkSmartPointer.h>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Triangulation_vertex_base_with_info_3<unsigned,K> Vb;
typedef CGAL::Triangulation_data_structure_3<Vb> Tds;
typedef Tds::Vertex_handle Vertex_handle;
typedef Tds::Cell_handle Cell_handle;
typedef CGAL::Delaunay_triangulation_3<K, Tds> Delaunay;
typedef Delaunay::Point Point;
typedef Eigen::Vector3d Vector3d;
typedef Eigen::VectorXd VectorXd;
typedef Eigen::Matrix3d Matrix3d;
typedef Eigen::Matrix3Xd Matrix3Xd;
typedef Eigen::Map<Matrix3Xd> Map3Xd;
int main(){
clock_t t1;
t1 = clock();
for(auto i=0; i < 10000; ++i){
vtkNew<vtkPolyDataReader> reader;
reader->SetFileName("Bad.vtk");
reader->Update();
auto poly = reader->GetOutput();
auto N = poly->GetNumberOfPoints();
auto pts = static_cast<double_t*>(poly->GetPoints()->GetData()->GetVoidPointer(0));
Map3Xd points(pts,3,N);
// Project points to unit sphere
points.colwise().normalize();
// Reset the center of the sphere to origin by translating
Vector3d center = points.rowwise().mean();
points = points.colwise() - center;
// Rotate all points so that the point in 0th column is along z-axis
Vector3d c = points.col(0);
double_t cos_t = c(2);
double_t sin_t = std::sqrt( 1 - cos_t*cos_t );
Vector3d axis;
axis << c(1), -c(0), 0.;
Matrix3d rotMat, axis_cross, outer;
axis_cross << 0. , -axis(2), axis(1),
axis(2), 0., -axis(0),
-axis(1), axis(0), 0.;
outer.noalias() = axis*axis.transpose();
rotMat = cos_t*Matrix3d::Identity() + sin_t*axis_cross +
(1-cos_t)*outer;
Matrix3Xd rPts(3,N);
rPts = rotMat*points; // The points on a sphere rotated
points = rPts;
std::vector<std::pair<Point,unsigned>> spherePoints;
spherePoints.push_back(std::make_pair(Point(0.,0.,0.),N));
for( auto i=0; i < N; ++i){
spherePoints.push_back( std::make_pair(Point(points(0,i),
points(1,i),
points(2,i)),
i));
}
// Calculate the convex hull
Delaunay T(spherePoints.begin(),spherePoints.end());
// To extract the surface
std::vector<Cell_handle> cells;
T.tds().incident_cells( T.infinite_vertex(),
std::back_inserter(cells) );
// Write to a vtk file
vtkNew<vtkCellArray> triangles;
for( auto c : cells ){
auto infv = c->index(T.infinite_vertex());
//triangles->InsertNextCell(3);
for( auto j=0; j < 4; ++j){
if (j == infv)
continue;
triangles->InsertCellPoint(c->vertex(j)->info());
}
}
poly->SetPolys(triangles);
vtkNew<vtkPolyDataWriter> writer;
writer->SetFileName("Mesh.vtk");
writer->SetInputData(poly);
writer->Write();
}
float diff(static_cast<float>(clock()) - static_cast<float>(t1));
std::cout << "Time elapsed : " << diff / CLOCKS_PER_SEC
<< " seconds" << std::endl;
return 0;
}
| 36.323529
| 91
| 0.588394
|
amit112amit
|
2a264dbac30dca8a07343598e64714d01853f644
| 2,516
|
cpp
|
C++
|
Sources/Core/cpp/NdxDataStorage/IndexStorage_test.cpp
|
elzin/SentimentAnalysisService
|
41fba2ef49746473535196e89a5e49250439fd83
|
[
"MIT"
] | 2
|
2021-07-07T19:39:11.000Z
|
2021-12-02T15:54:15.000Z
|
Sources/Core/cpp/NdxDataStorage/IndexStorage_test.cpp
|
elzin/SentimentAnalysisService
|
41fba2ef49746473535196e89a5e49250439fd83
|
[
"MIT"
] | null | null | null |
Sources/Core/cpp/NdxDataStorage/IndexStorage_test.cpp
|
elzin/SentimentAnalysisService
|
41fba2ef49746473535196e89a5e49250439fd83
|
[
"MIT"
] | 1
|
2021-12-01T17:48:20.000Z
|
2021-12-01T17:48:20.000Z
|
#include "StdAfx.h"
#ifdef _SS_UNITTESTS
#include ".\indexstorage_test.h"
#include ".\test_const.h"
#include ".\console.h"
#include ".\index_storage.h"
#include ".\data_storages_factory.h"
CPPUNIT_TEST_SUITE_REGISTRATION(SS::UnitTests::NdxSE::NdxDataStorage::CIndexStorage_test);
typedef HRESULT (*CREATE_INSTANCE)(const GUID* pGuid, void** ppBase);
namespace SS
{
namespace UnitTests
{
namespace NdxSE
{
namespace NdxDataStorage
{
using namespace SS::Core::NdxSE::NdxDataStorage;
using namespace SS::Interface::Core::NdxSE::NdxDataStorage;
//--------------------------------------------------------------------//
void CIndexStorage_test::Test(void)
{
CPPUNIT_ASSERT(CreateLoadManager());
CDataStorageFactory* pDataStorageFactory=new CDataStorageFactory();
pDataStorageFactory->SetLoadManager(m_pLoadManager);
wchar_t path[MAX_PATH];
::GetCurrentDirectoryW(MAX_PATH, (LPWSTR)path);
wcscat(path, L"\\UT\\");
INdxStorage* pNdxStorage=pDataStorageFactory->CreateNdxStorage();
pNdxStorage->Create(L"index_str", L".ndx");
SNdxLevelInfo NdxLevelInfo;
NdxLevelInfo.m_ucLevelNumber=0;
NdxLevelInfo.m_IndexCoordinateType=SNdxLevelInfo::ictSentenceAbsNumber;
NdxLevelInfo.m_eControlType=SNdxLevelInfo::lctUndefined;
NdxLevelInfo.m_eControlByType=SNdxLevelInfo::lctUndefined;
pNdxStorage->AddLevelInfo(&NdxLevelInfo);
NdxLevelInfo.m_ucLevelNumber++;
pNdxStorage->AddLevelInfo(&NdxLevelInfo);
NdxLevelInfo.m_ucLevelNumber++;
pNdxStorage->AddLevelInfo(&NdxLevelInfo);
NdxLevelInfo.m_ucLevelNumber++;
pNdxStorage->AddLevelInfo(&NdxLevelInfo);
pNdxStorage->Open(path);
pNdxStorage->Close();
pNdxStorage->Release();
delete pDataStorageFactory;
DeleteLoadManager();
}
bool CIndexStorage_test::CreateLoadManager(void)
{
m_pLoadManager=NULL;
wchar_t path[MAX_PATH];
::GetCurrentDirectoryW(MAX_PATH, (LPWSTR)path);
wcscat(path, L"\\LoadManager.dll");
m_hLoadManager=::LoadLibraryW(path);
CREATE_INSTANCE pCreateInstance=(CREATE_INSTANCE)GetProcAddress(m_hLoadManager, "CreateInstance");
if(pCreateInstance==NULL){
wprintf(L"LoadManager entry point not found, error %u\n", GetLastError());
return 0;
}
const GUID Guid=CLSID_LoadManager;
(*pCreateInstance)(&Guid, (void**)&m_pLoadManager);
return m_pLoadManager?true:false;
}
void CIndexStorage_test::DeleteLoadManager(void)
{
if(m_pLoadManager) delete m_pLoadManager;
::FreeLibrary(m_hLoadManager);
}
//--------------------------------------------------------------------//
}
}
}
}
#endif //_SS_UNITTESTS
| 23.514019
| 99
| 0.736089
|
elzin
|
2a26cb3bbb819a3fe4e2ef314cb4739c7b0cc715
| 9,142
|
cpp
|
C++
|
Source/AccelByteUe4Sdk/Private/Api/AccelByteItemApi.cpp
|
leowind/accelbyte-unreal-sdk-plugin
|
73a7bf289abbba8141767eb16005aaf8293f8a63
|
[
"MIT"
] | null | null | null |
Source/AccelByteUe4Sdk/Private/Api/AccelByteItemApi.cpp
|
leowind/accelbyte-unreal-sdk-plugin
|
73a7bf289abbba8141767eb16005aaf8293f8a63
|
[
"MIT"
] | null | null | null |
Source/AccelByteUe4Sdk/Private/Api/AccelByteItemApi.cpp
|
leowind/accelbyte-unreal-sdk-plugin
|
73a7bf289abbba8141767eb16005aaf8293f8a63
|
[
"MIT"
] | null | null | null |
// Copyright (c) 2018 - 2019 AccelByte Inc. All Rights Reserved.
// This is licensed software from AccelByte Inc, for limitations
// and restrictions contact your company contract manager.
#include "Api/AccelByteItemApi.h"
#include "Core/AccelByteError.h"
#include "JsonUtilities.h"
#include "Core/AccelByteRegistry.h"
#include "Core/AccelByteReport.h"
#include "Core/AccelByteHttpRetryScheduler.h"
#include "Core/AccelByteSettings.h"
namespace AccelByte
{
namespace Api
{
Item::Item(const AccelByte::Credentials& Credentials, const AccelByte::Settings& Settings) : Credentials(Credentials), Settings(Settings){}
Item::~Item(){}
FString EAccelByteItemTypeToString(const EAccelByteItemType& EnumValue) {
const UEnum* EnumPtr = FindObject<UEnum>(ANY_PACKAGE, TEXT("EAccelByteItemType"), true);
if (!EnumPtr) return "Invalid";
return EnumPtr->GetNameStringByValue((int64)EnumValue);
}
FString EAccelByteItemStatusToString(const EAccelByteItemStatus& EnumValue) {
const UEnum* EnumPtr = FindObject<UEnum>(ANY_PACKAGE, TEXT("EAccelByteItemStatus"), true);
if (!EnumPtr) return "Invalid";
return EnumPtr->GetNameStringByValue((int64)EnumValue);
}
FString EAccelByteAppTypeToString(const EAccelByteAppType& EnumValue)
{
const UEnum* EnumPtr = FindObject<UEnum>(ANY_PACKAGE, TEXT("EAccelByteAppType"), true);
if (!EnumPtr) return "Invalid";
return EnumPtr->GetNameStringByValue((int64)EnumValue);
}
void Item::GetItemById(const FString& ItemId, const FString& Language, const FString& Region, const THandler<FAccelByteModelsPopulatedItemInfo>& OnSuccess, const FErrorHandler& OnError)
{
FReport::Log(FString(__FUNCTION__));
FString Authorization = FString::Printf(TEXT("Bearer %s"), *Credentials.GetAccessToken());
FString Url = FString::Printf(TEXT("%s/public/namespaces/%s/items/%s/locale"), *Settings.PlatformServerUrl, *Credentials.GetNamespace(), *ItemId);
if (!Region.IsEmpty() || !Language.IsEmpty())
{
Url.Append(FString::Printf(TEXT("?")));
if (!Region.IsEmpty())
{
Url.Append(FString::Printf(TEXT("region=%s"), *Region));
if (!Language.IsEmpty())
{
Url.Append(FString::Printf(TEXT("&language=%s"), *Language));
}
}
else if (!Language.IsEmpty())
{
Url.Append(FString::Printf(TEXT("language=%s"), *Language));
}
}
FString Verb = TEXT("GET");
FString ContentType = TEXT("application/json");
FString Accept = TEXT("application/json");
FString Content;
FHttpRequestPtr Request = FHttpModule::Get().CreateRequest();
Request->SetURL(Url);
Request->SetHeader(TEXT("Authorization"), Authorization);
Request->SetVerb(Verb);
Request->SetHeader(TEXT("Content-Type"), ContentType);
Request->SetHeader(TEXT("Accept"), Accept);
Request->SetContentAsString(Content);
FRegistry::HttpRetryScheduler.ProcessRequest(Request, CreateHttpResultHandler(OnSuccess, OnError), FPlatformTime::Seconds());
}
void Item::GetItemByAppId(const FString& AppId, const FString& Language, const FString& Region, const THandler<FAccelByteModelsItemInfo>& OnSuccess, const FErrorHandler& OnError)
{
FReport::Log(FString(__FUNCTION__));
FString Authorization = FString::Printf(TEXT("Bearer %s"), *Credentials.GetAccessToken());
FString Url = FString::Printf(TEXT("%s/public/namespaces/%s/items/byAppId?appId=%s"), *Settings.PlatformServerUrl, *Settings.PublisherNamespace, *AppId);
if (!Region.IsEmpty() || !Language.IsEmpty())
{
Url.Append(FString::Printf(TEXT("&")));
if (!Region.IsEmpty())
{
Url.Append(FString::Printf(TEXT("region=%s"), *Region));
if (!Language.IsEmpty())
{
Url.Append(FString::Printf(TEXT("&language=%s"), *Language));
}
}
else if (!Language.IsEmpty())
{
Url.Append(FString::Printf(TEXT("language=%s"), *Language));
}
}
FString Verb = TEXT("GET");
FString ContentType = TEXT("application/json");
FString Accept = TEXT("application/json");
FString Content;
FHttpRequestPtr Request = FHttpModule::Get().CreateRequest();
Request->SetURL(Url);
Request->SetVerb(Verb);
Request->SetHeader(TEXT("Content-Type"), ContentType);
Request->SetHeader(TEXT("Accept"), Accept);
Request->SetContentAsString(Content);
FRegistry::HttpRetryScheduler.ProcessRequest(Request, CreateHttpResultHandler(OnSuccess, OnError), FPlatformTime::Seconds());
}
void Item::GetItemsByCriteria(const FAccelByteModelsItemCriteria& ItemCriteria, const int32& Offset, const int32& Limit, const THandler<FAccelByteModelsItemPagingSlicedResult>& OnSuccess, const FErrorHandler& OnError)
{
FReport::Log(FString(__FUNCTION__));
FString Authorization = FString::Printf(TEXT("Bearer %s"), *Credentials.GetAccessToken());
FString Url = FString::Printf(TEXT("%s/public/namespaces/%s/items/byCriteria"), *Settings.PlatformServerUrl, *Settings.Namespace);
bool bIsNotFirst = false;
if (!ItemCriteria.CategoryPath.IsEmpty())
{
bIsNotFirst = true; Url.Append("?");
Url.Append(FString::Printf(TEXT("categoryPath=%s"), *FGenericPlatformHttp::UrlEncode(ItemCriteria.CategoryPath)));
}
if (!ItemCriteria.Region.IsEmpty())
{
if (bIsNotFirst)
{
Url.Append("&");
}
else
{
bIsNotFirst = true; Url.Append("?");
}
Url.Append(FString::Printf(TEXT("region=%s"), *ItemCriteria.Region));
}
if (!ItemCriteria.Language.IsEmpty())
{
if (bIsNotFirst)
{
Url.Append("&");
}
else
{
bIsNotFirst = true; Url.Append("?");
}
Url.Append(FString::Printf(TEXT("language=%s"), *ItemCriteria.Language));
}
if (ItemCriteria.ItemType != EAccelByteItemType::NONE)
{
if (bIsNotFirst)
{
Url.Append("&");
}
else
{
bIsNotFirst = true; Url.Append("?");
}
Url.Append(FString::Printf(TEXT("itemType=%s"), *EAccelByteItemTypeToString(ItemCriteria.ItemType)));
}
if (ItemCriteria.AppType != EAccelByteAppType::NONE)
{
if (bIsNotFirst)
{
Url.Append("&");
}
else
{
bIsNotFirst = true; Url.Append("?");
}
Url.Append(FString::Printf(TEXT("appType=%s"), *EAccelByteAppTypeToString(ItemCriteria.AppType)));
}
if (ItemCriteria.Tags.Num() > 0)
{
if (bIsNotFirst)
{
Url.Append("&");
}
else
{
bIsNotFirst = true; Url.Append("?");
}
for (int i = 0; i < ItemCriteria.Tags.Num(); i++)
{
Url.Append((i == 0) ? TEXT("tags=") : TEXT(",")).Append(ItemCriteria.Tags[i]);
}
}
if (ItemCriteria.Features.Num() > 0)
{
if (bIsNotFirst)
{
Url.Append("&");
}
else
{
bIsNotFirst = true; Url.Append("?");
}
for (int i = 0; i < ItemCriteria.Features.Num(); i++)
{
Url.Append((i == 0) ? TEXT("features=") : TEXT(",")).Append(ItemCriteria.Features[i]);
}
}
if (Offset > 0)
{
if (bIsNotFirst)
{
Url.Append("&");
}
else
{
bIsNotFirst = true; Url.Append("?");
}
Url.Append(FString::Printf(TEXT("offset=%d"), Offset));
}
if (Limit > 0)
{
if (bIsNotFirst)
{
Url.Append("&");
}
else
{
bIsNotFirst = true; Url.Append("?");
}
Url.Append(FString::Printf(TEXT("limit=%d"), Limit));
}
FString Verb = TEXT("GET");
FString ContentType = TEXT("application/json");
FString Accept = TEXT("application/json");
FString Content = TEXT("");
FHttpRequestPtr Request = FHttpModule::Get().CreateRequest();
Request->SetURL(Url);
Request->SetHeader(TEXT("Authorization"), Authorization);
Request->SetVerb(Verb);
Request->SetHeader(TEXT("Content-Type"), ContentType);
Request->SetHeader(TEXT("Accept"), Accept);
Request->SetContentAsString(Content);
FRegistry::HttpRetryScheduler.ProcessRequest(Request, CreateHttpResultHandler(OnSuccess, OnError), FPlatformTime::Seconds());
}
void Item::SearchItem(const FString& Language, const FString& Keyword, const int32& Offset, const int32& Limit, const FString& Region, const THandler<FAccelByteModelsItemPagingSlicedResult>& OnSuccess, const FErrorHandler& OnError)
{
FReport::Log(FString(__FUNCTION__));
FString Authorization = FString::Printf(TEXT("Bearer %s"), *Credentials.GetAccessToken());
FString Url = FString::Printf(TEXT("%s/public/namespaces/%s/items/search?language=%s&keyword=%s"), *Settings.PlatformServerUrl, *Settings.Namespace, *Language, *FGenericPlatformHttp::UrlEncode(Keyword));
if (!Region.IsEmpty())
{
Url.Append(FString::Printf(TEXT("®ion=%s"), *Region));
}
if (Offset > 0)
{
Url.Append(FString::Printf(TEXT("&offset=%d"), Offset));
}
if (Limit > 0)
{
Url.Append(FString::Printf(TEXT("&limit=%d"), Limit));
}
FString Verb = TEXT("GET");
FString ContentType = TEXT("application/json");
FString Accept = TEXT("application/json");
FString Content = TEXT("");
FHttpRequestPtr Request = FHttpModule::Get().CreateRequest();
Request->SetURL(Url);
Request->SetHeader(TEXT("Authorization"), Authorization);
Request->SetVerb(Verb);
Request->SetHeader(TEXT("Content-Type"), ContentType);
Request->SetHeader(TEXT("Accept"), Accept);
Request->SetContentAsString(Content);
FRegistry::HttpRetryScheduler.ProcessRequest(Request, CreateHttpResultHandler(OnSuccess, OnError), FPlatformTime::Seconds());
}
} // Namespace Api
} // Namespace AccelByte
| 32.077193
| 231
| 0.692299
|
leowind
|
2a2830f9a0a3381e9c4086c616eda4a5038e5e74
| 27,285
|
cpp
|
C++
|
moos-ivp/ivp/src/uFldNodeComms/FldNodeComms.cpp
|
EasternEdgeRobotics/2018
|
24df2fe56fa6d172ba3c34c1a97f249dbd796787
|
[
"MIT"
] | null | null | null |
moos-ivp/ivp/src/uFldNodeComms/FldNodeComms.cpp
|
EasternEdgeRobotics/2018
|
24df2fe56fa6d172ba3c34c1a97f249dbd796787
|
[
"MIT"
] | null | null | null |
moos-ivp/ivp/src/uFldNodeComms/FldNodeComms.cpp
|
EasternEdgeRobotics/2018
|
24df2fe56fa6d172ba3c34c1a97f249dbd796787
|
[
"MIT"
] | null | null | null |
/*****************************************************************/
/* NAME: Michael Benjamin */
/* ORGN: Dept of Mechanical Eng / CSAIL, MIT Cambridge MA */
/* FILE: FldNodeComms.cpp */
/* DATE: Dec 4th 2011 */
/* */
/* This file is part of MOOS-IvP */
/* */
/* MOOS-IvP is free software: you can redistribute it and/or */
/* modify it under the terms of the GNU General Public License */
/* as published by the Free Software Foundation, either version */
/* 3 of the License, or (at your option) any later version. */
/* */
/* MOOS-IvP 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 MOOS-IvP. If not, see */
/* <http://www.gnu.org/licenses/>. */
/*****************************************************************/
#include <cmath>
#include <set>
#include <iterator>
#include "FldNodeComms.h"
#include "MBUtils.h"
#include "NodeRecordUtils.h"
#include "NodeMessageUtils.h"
#include "XYCommsPulse.h"
#include "ColorParse.h"
using namespace std;
//---------------------------------------------------------
// Constructor
FldNodeComms::FldNodeComms()
{
// The default range within which reports are sent between nodes
m_comms_range = 100;
// A range with which node reports are sent between nodes regardless
// of other criteria (in the spirit of collision avoidance).
m_critical_range = 30;
m_default_stealth = 1.0;
m_default_earange = 1.0;
m_min_stealth = 0.1;
m_max_earange = 10.0;
m_stale_time = 5.0;
m_min_msg_interval = 30.0;
m_max_msg_length = 1000; // zero means unlimited length
m_drop_pct = 0; // percentage of messages that should be dropped
srand((int)time(0));// seed the random number generator
m_verbose = false;
m_debug = false;
m_pulse_duration = 10; // zero means no pulses posted.
m_view_node_rpt_pulses = true;
// If true then comms between vehicles only happens if they are
// part of the same group. (unless range is within critical).
m_apply_groups = false;
m_total_reports_rcvd = 0;
m_total_reports_sent = 0;
m_total_messages_rcvd = 0;
m_total_messages_sent = 0;
m_blk_msg_invalid = 0;
m_blk_msg_toostale = 0;
m_blk_msg_tooquick = 0;
m_blk_msg_toolong = 0;
m_blk_msg_toofar = 0;
}
//---------------------------------------------------------
// Procedure: OnNewMail
bool FldNodeComms::OnNewMail(MOOSMSG_LIST &NewMail)
{
AppCastingMOOSApp::OnNewMail(NewMail);
MOOSMSG_LIST::iterator p;
for(p=NewMail.begin(); p!=NewMail.end(); p++) {
CMOOSMsg &msg = *p;
string key = msg.GetKey();
string sval = msg.GetString();
bool handled = false;
string whynot;
if((key == "NODE_REPORT") || (key == "NODE_REPORT_LOCAL"))
handled = handleMailNodeReport(sval, whynot);
else if(key == "NODE_MESSAGE")
handled = handleMailNodeMessage(sval);
else if(key == "UNC_STEALTH")
handled = handleStealth(sval);
else if(key == "UNC_VIEW_NODE_RPT_PULSES")
handled = setBooleanOnString(m_view_node_rpt_pulses, sval);
else if(key == "UNC_EARANGE")
handled = handleEarange(sval);
if(!handled) {
string warning = "Unhandled Mail: " + key;
if(whynot != "")
warning += " " + whynot;
reportRunWarning(warning);
}
}
return(true);
}
//---------------------------------------------------------
// Procedure: OnConnectToServer
bool FldNodeComms::OnConnectToServer()
{
registerVariables();
return(true);
}
//---------------------------------------------------------
// Procedure: Iterate()
bool FldNodeComms::Iterate()
{
AppCastingMOOSApp::Iterate();
map<string, bool>::iterator p;
for(p=m_map_newrecord.begin(); p!=m_map_newrecord.end(); p++) {
string uname = p->first;
bool newinfo = p->second;
if(newinfo)
distributeNodeReportInfo(uname);
}
map<string, bool>::iterator p2;
for(p2=m_map_newmessage.begin(); p2!=m_map_newmessage.end(); p2++) {
string src_name = p2->first;
bool newinfo = p2->second;
// If the message has changed, consider sending it out
if(newinfo)
distributeNodeMessageInfo(src_name);
}
m_map_newrecord.clear();
m_map_newmessage.clear();
m_map_message.clear();
m_map_record.clear();
AppCastingMOOSApp::PostReport();
return(true);
}
//---------------------------------------------------------
// Procedure: OnStartUp()
// Happens before connection is open
bool FldNodeComms::OnStartUp()
{
AppCastingMOOSApp::OnStartUp();
STRING_LIST sParams;
m_MissionReader.EnableVerbatimQuoting(false);
if(!m_MissionReader.GetConfiguration(GetAppName(), sParams))
reportConfigWarning("No config block found for " + GetAppName());
STRING_LIST::iterator p;
for(p=sParams.begin(); p!=sParams.end(); p++) {
string orig = *p;
string line = *p;
string param = toupper(biteStringX(line, '='));
string value = line;
bool handled = false;
if((param == "COMMS_RANGE") && isNumber(value)) {
// A negative comms range means all comms goes through
// A zero comms range means nothing goes through
m_comms_range = atof(value.c_str());
handled = true;
}
else if((param == "CRITICAL_RANGE") && isNumber(value)) {
m_critical_range = atof(value.c_str());
handled = true;
}
else if((param == "STALE_TIME") && isNumber(value)) {
// A negative stale time means staleness never applies
m_stale_time = atof(value.c_str());
handled = true;
}
else if((param == "MIN_MSG_INTERVAL") && isNumber(value)) {
m_min_msg_interval = atof(value.c_str());
handled = true;
}
else if((param == "MAX_MSG_LENGTH") && isNumber(value)) {
m_max_msg_length = atoi(value.c_str());
handled = true;
}
else if(param == "STEALTH")
handled = handleStealth(value);
else if(param == "EARANGE")
handled = handleEarange(value);
else if(param == "GROUPS")
handled = setBooleanOnString(m_apply_groups, value);
else if(param == "VERBOSE")
handled = setBooleanOnString(m_verbose, value);
else if(param == "VIEW_NODE_RPT_PULSES")
handled = setBooleanOnString(m_view_node_rpt_pulses, value);
else if(param == "DEBUG")
handled = setBooleanOnString(m_debug, value);
else if(param == "DROP_PERCENTAGE")
handled = setPosDoubleOnString(m_drop_pct, value);
if(!handled)
reportUnhandledConfigWarning(orig);
}
registerVariables();
return(true);
}
//------------------------------------------------------------
// Procedure: registerVariables
void FldNodeComms::registerVariables()
{
AppCastingMOOSApp::RegisterVariables();
Register("NODE_REPORT", 0);
Register("NODE_REPORT_LOCAL", 0);
Register("NODE_MESSAGE", 0);
Register("UNC_STEALTH", 0);
Register("UNC_EARANGE", 0);
Register("UNC_VIEW_NODE_RPT_PULSES", 0);
}
//------------------------------------------------------------
// Procedure: handleMailNodeReport
bool FldNodeComms::handleMailNodeReport(const string& str, string& whynot)
{
NodeRecord new_record = string2NodeRecord(str);
if(!new_record.valid("x,y,name", whynot))
return(false);
string upp_name = toupper(new_record.getName());
string grp_name = toupper(new_record.getGroup());
m_map_record[upp_name] = new_record;
m_map_newrecord[upp_name] = true;
m_map_time_nreport[upp_name] = m_curr_time;
m_map_vgroup[upp_name] = grp_name;
unsigned int vindex_size = m_map_vindex.size();
if(m_map_vindex.count(upp_name) == 0)
m_map_vindex[upp_name] = vindex_size;
if(m_map_reports_rcvd.count(upp_name) == 0)
m_map_reports_rcvd[upp_name] = 1;
else
m_map_reports_rcvd[upp_name]++;
m_total_reports_rcvd++;
return(true);
}
//------------------------------------------------------------
// Procedure: handleMailNodeMessage
// Example: NODE_MESSAGE = src_node=henry,dest_node=ike,
// var_name=FOO, string_val=bar
bool FldNodeComms::handleMailNodeMessage(const string& msg)
{
NodeMessage new_message = string2NodeMessage(msg);
// #1 List of "last" messages store solely for user debug
// viewing at the console window.
m_last_messages.push_back(msg);
if(m_last_messages.size() > 5)
m_last_messages.pop_front();
// #2 Check that the message is valid
if(!new_message.valid())
return(false);
string upp_src_node = toupper(new_message.getSourceNode());
m_map_message[upp_src_node].push_back(new_message);
m_map_newmessage[upp_src_node] = true;
unsigned int vindex_size = m_map_vindex.size();
if(m_map_vindex.count(upp_src_node) == 0)
m_map_vindex[upp_src_node] = vindex_size;
if(m_map_messages_rcvd.count(upp_src_node) == 0)
m_map_messages_rcvd[upp_src_node] = 1;
else
m_map_messages_rcvd[upp_src_node]++;
m_total_messages_rcvd++;
reportEvent("Msg rec'd: " + msg);
return(true);
}
//------------------------------------------------------------
// Procedure: handleStealth
// Example: vname=alpha,stealth=0.4"
// Note: Max value is 1.0. Min value set by m_min_stealth
bool FldNodeComms::handleStealth(const string& str)
{
string vname, stealth;
vector<string> svector = parseString(str, ',');
unsigned int i, vsize = svector.size();
for(i=0; i<vsize; i++) {
string param = tolower(biteStringX(svector[i], '='));
string value = svector[i];
if(param == "vname")
vname = toupper(value);
else if(param == "stealth")
stealth = value;
}
if(!isNumber(stealth))
return(false);
double dbl_stealth = atof(stealth.c_str());
if(dbl_stealth < m_min_stealth)
dbl_stealth = m_min_stealth;
if(dbl_stealth > 1)
dbl_stealth = 1;
m_map_stealth[vname] = dbl_stealth;
return(true);
}
//------------------------------------------------------------
// Procedure: handleEarange
// Example: vname=alpha,earange=0.5
// Note: Min value is 1.0. Max value set by m_max_earange
bool FldNodeComms::handleEarange(const string& str)
{
string vname, earange;
vector<string> svector = parseString(str, ',');
unsigned int i, vsize = svector.size();
for(i=0; i<vsize; i++) {
string param = tolower(biteStringX(svector[i], '='));
string value = svector[i];
if(param == "vname")
vname = toupper(value);
else if((param == "earange") || (param == "earrange"))
earange = value;
}
if(!isNumber(earange))
return(false);
double dbl_earange = atof(earange.c_str());
if(dbl_earange > m_max_earange)
dbl_earange = m_max_earange;
if(dbl_earange < 1)
dbl_earange = 1;
m_map_earange[vname] = dbl_earange;
return(true);
}
//------------------------------------------------------------
// Procedure: distributeNodeReportInfo
// Purpose: Post the node report for vehicle <uname> to all
// other vehicles as NODE_REPORT_VNAME where <uname>
// is not equal to VNAME (no need to report to self).
// Notes: Inter-vehicle node reports must pass certain criteria
// based on inter-vehicle range, group, and the respective
// stealth and earange of the senting and receiving nodes.
void FldNodeComms::distributeNodeReportInfo(const string& uname)
{
// First check if the latest record for the given vehicle is valid.
NodeRecord record = m_map_record[uname];
if(!record.valid())
return;
// We'll need the same node report sent out to all vehicles.
string node_report = record.getSpec();
map<string, NodeRecord>::iterator p;
for(p=m_map_record.begin(); p!=m_map_record.end(); p++) {
string vname = p->first;
// Criteria #1: vehicles different
if(vname == uname)
continue;
if(m_verbose)
cout << uname << "--->" << vname << ": " << endl;
bool msg_send = true;
// Criteria #2: receiving vehicle has been heard from recently.
// Freshness is enforced to disallow messages to a vehicle that may in
// fact be much farther away than a stale node report would indicate
double vname_time_since_update = m_curr_time - m_map_time_nreport[vname];
if(vname_time_since_update > m_stale_time)
msg_send = false;
// Criteria #3: the range between vehicles is not too large.
if(msg_send && !meetsRangeThresh(uname, vname))
msg_send = false;
// Criteria #4: if groups considered, check for same group
if(msg_send && m_apply_groups) {
if(m_verbose) {
cout << " uname group:" << m_map_vgroup[uname] << endl;
cout << " vname group:" << m_map_vgroup[vname] << endl;
}
if(m_map_vgroup[uname] != m_map_vgroup[vname])
msg_send = false;
}
// Criteria #5: randomly drop messages, to probabilistically let
// all but drop percentage through
if(msg_send && meetsDropPercentage())
msg_send = false;
// Extra Criteria: If otherwise not sending, check to see if nodes
// are within "critical" range. If so send report regardless of
// anything else - in the spirit of safety!
if(!msg_send && meetsCriticalRangeThresh(uname, vname))
msg_send = true;
if(msg_send) {
string moos_var = "NODE_REPORT_" + vname;
Notify(moos_var, node_report);
if(m_view_node_rpt_pulses)
postViewCommsPulse(uname, vname);
m_total_reports_sent++;
m_map_reports_sent[vname]++;
}
if(m_verbose) {
if(msg_send)
cout << "NODE_REPORT Sent!" << endl;
else
cout << "NODE_REPORT Held!" << endl;
}
}
}
//------------------------------------------------------------
// Procedure: distributeNodeMessageInfo
// Note: Mod Sep 20th, 2015 (mikerb) to allow uFldNodeComms to
// keep all messages received since the previous Iteration.
// Previously messages sent together in time, and all
// received in one iteration here, would drop all but the
// latest message.
void FldNodeComms::distributeNodeMessageInfo(const string& src_name)
{
if(m_map_message.count(src_name) == 0)
return;
for(unsigned int i=0; i<m_map_message[src_name].size(); i++) {
double elapsed = m_curr_time - m_map_time_nmessage[src_name];
if(elapsed >= m_min_msg_interval) {
NodeMessage message = m_map_message[src_name][i];
distributeNodeMessageInfo(src_name, message);
m_map_time_nmessage[src_name] = m_curr_time;
}
else
m_blk_msg_tooquick++;
}
}
//------------------------------------------------------------
// Procedure: distributeNodeMessageInfo
// Purpose: Post the node message for vehicle <uname> to the
// recipients specified in the message.
// Notes: The recipient may be specified by the name of the recipient
// node, or the vehicle/node group. Group membership is
// determined by nodes reporting their group membership as
// part of their node report.
// Notes: Inter-vehicle node reports must pass certain criteria
// based on inter-vehicle range, group, and the respective
// stealth and earange of the senting and receiving nodes.
void FldNodeComms::distributeNodeMessageInfo(string src_name,
NodeMessage message)
{
// First check if the latest message for the given vehicle is valid.
if(!message.valid()) {
m_blk_msg_invalid++;
return;
}
// If max_msg_length is limited (nonzero), check length of this msg
if((m_max_msg_length > 0) && (message.length() > m_max_msg_length)) {
m_blk_msg_toolong++;
return;
}
// Begin determining the list of destinations
set<string> dest_names;
string dest_name = toupper(message.getDestNode());
string dest_group = toupper(message.getDestGroup());
// If destination name(s) given add each one in the colon-separated list
vector<string> svector = parseString(dest_name, ':');
for(unsigned int i=0; i<svector.size(); i++) {
string a_destination_name = stripBlankEnds(svector[i]);
dest_names.insert(a_destination_name);
}
// If a group name is specified, add all vehicles in that group to
// the list of destinations for this message.
if((dest_group != "") || (dest_name == "ALL")) {
map<string, string>::iterator p;
for(p=m_map_vgroup.begin(); p!=m_map_vgroup.end(); p++) {
string vname = p->first;
string group = toupper(p->second);
if((dest_group == group) || (dest_group == "ALL") || (dest_name=="ALL"))
dest_names.insert(vname);
}
}
// End determining the list of destinations
// Begin handling all the destinations
set<string>::iterator p;
for(p=dest_names.begin(); p!=dest_names.end(); p++) {
string a_dest_name = *p;
if(m_debug)
cout << src_name << "--->" << a_dest_name << ": " << endl;
bool msg_send = true;
// Criteria #1: vehicles different
if(a_dest_name == src_name)
msg_send = false;
// Criteria #2: receiving vehicle has been heard from recently.
// Freshness is enforced to disallow messages to a vehicle that may in
// fact be much farther away than a stale node report would indicate
// 2a - check if receiving vehicle has never been heard from
if(msg_send && (m_map_time_nreport.count(a_dest_name) == 0))
msg_send = false;
// 2b - receiving vehicle has not been heard from recently
if(msg_send) {
double dest_name_time_since_nreport = m_curr_time;
dest_name_time_since_nreport -= m_map_time_nreport[a_dest_name];
if(dest_name_time_since_nreport > m_stale_time) {
m_blk_msg_toostale++;
msg_send = false;
}
}
// Criteria #3: the range between vehicles is not too large.
if(msg_send && !meetsRangeThresh(src_name, a_dest_name)) {
m_blk_msg_toofar++;
msg_send = false;
}
// Criteria #4: randomly drop messages, to probabilistically let
// all but drop percentage through
if(msg_send && meetsDropPercentage())
msg_send = false;
if(msg_send) {
string moos_var = "NODE_MESSAGE_" + a_dest_name;
string node_message = message.getSpec();
Notify(moos_var, node_message);
postViewCommsPulse(src_name, a_dest_name, "white", 0.6);
m_total_messages_sent++;
m_map_messages_sent[a_dest_name]++;
}
}
}
//------------------------------------------------------------
// Procedure: meetsRangeThresh
// Purpose: Determine if Vehicle2 should hear the node report
// of Vehicle1, given the raw range, earange and
// stealth factors.
bool FldNodeComms::meetsRangeThresh(const string& uname1,
const string& uname2)
{
NodeRecord record1 = m_map_record[uname1];
NodeRecord record2 = m_map_record[uname2];
if(!record1.valid() || !record2.valid())
return(false);
double x1 = record1.getX();
double y1 = record1.getY();
double x2 = record2.getX();
double y2 = record2.getY();
double range = hypot((x1-x2), (y1-y2));
// See if source vehicle has a modified stealth value
double stealth = 1.0;
if(m_map_stealth.count(uname1))
stealth = m_map_stealth[uname1];
// See if receiving vehicle has a modified earange value
double earange = 1.0;
if(m_map_earange.count(uname2))
earange = m_map_earange[uname2];
// Compute the comms range threshold from baseline plus
// stealth and earange factors.
double comms_range = m_comms_range * stealth * earange;
if(m_verbose) {
cout << termColor("blue") << " raw_range:" << range << endl;
cout << " mod_rng:" << doubleToString(comms_range);
cout << " stealth:" << doubleToString(stealth);
cout << " earange:" << doubleToString(earange);
cout << " def_rng:" << doubleToString(m_comms_range);
cout << termColor() << endl;
}
if(range > comms_range)
return(false);
return(true);
}
//------------------------------------------------------------
// Procedure: meetsCriticalRangeThresh()
// Purpose: Determine if Vehicle2 should hear the node report
// of Vehicle1, given the raw range and critical range.
bool FldNodeComms::meetsCriticalRangeThresh(const string& uname1,
const string& uname2)
{
NodeRecord record1 = m_map_record[uname1];
NodeRecord record2 = m_map_record[uname2];
if(!record1.valid() || !record2.valid())
return(false);
double x1 = record1.getX();
double y1 = record1.getY();
double x2 = record2.getX();
double y2 = record2.getY();
double range = hypot((x1-x2), (y1-y2));
if(range <= m_critical_range)
return(true);
return(false);
}
//------------------------------------------------------------
// Procedure: meetsDropPercentage()
// Purpose: Determine if message should be dropped based on
// drop percentage (returning true means drop)
bool FldNodeComms::meetsDropPercentage()
{
// if drop percentage > 0, randomly drop messages,
// to probabilistically let the all but drop percentage through
if(m_drop_pct > 0) {
// generate random number between 0 and 100:
size_t rand_nr = rand() % 100;
// drop message if random number is within drop percentage range
// probabilistically we should thus drop the percentage amount
if(rand_nr < m_drop_pct)
return(true); // drop msg
}
return(false);
}
//------------------------------------------------------------
// Procedure: postViewCommsPulse()
void FldNodeComms::postViewCommsPulse(const string& uname1,
const string& uname2,
const string& pcolor,
double fill_opaqueness)
{
if(m_pulse_duration <= 0)
return;
if(uname1 == uname2)
return;
NodeRecord record1 = m_map_record[uname1];
NodeRecord record2 = m_map_record[uname2];
double x1 = record1.getX();
double y1 = record1.getY();
double x2 = record2.getX();
double y2 = record2.getY();
XYCommsPulse pulse(x1, y1, x2, y2);
string label = uname1 + "2" + uname2;
if(pcolor != "auto")
label += pcolor;
pulse.set_duration(m_pulse_duration);
pulse.set_label(label);
pulse.set_time(m_curr_time);
pulse.set_beam_width(7);
pulse.set_fill(fill_opaqueness);
#if 0
if(m_verbose)
cout << "Pulse: From: " << uname1 << " TO: " << uname2 << endl;
#endif
string pulse_color = pcolor;
if(pcolor == "auto") {
unsigned int color_index = m_map_vindex[uname1];
if(color_index == 0)
pulse_color = "orange";
else if(color_index == 1)
pulse_color = "green";
else if(color_index == 2)
pulse_color = "blue";
else if(color_index == 3)
pulse_color = "red";
else
pulse_color = "purple";
}
pulse.set_color("fill", pulse_color);
string pulse_spec = pulse.get_spec();
Notify("VIEW_COMMS_PULSE", pulse_spec);
}
//------------------------------------------------------------
// Procedure: buildReport
// Note: A virtual function of AppCastingMOOSApp superclass, conditionally
// invoked if either a terminal or appcast report is needed.
bool FldNodeComms::buildReport()
{
m_msgs << "Configuration: " << endl;
m_msgs << " Comms Range: " << doubleToStringX(m_comms_range) << endl;
m_msgs << " Critical Range: " << doubleToStringX(m_critical_range) << endl;
m_msgs << " Max Message Len: " << doubleToStringX(m_max_msg_length) << endl;
m_msgs << " Min Message Int: " << doubleToStringX(m_min_msg_interval) << endl;
m_msgs << " Apply Group: " << boolToString(m_apply_groups) << endl;
m_msgs << endl;
m_msgs << "Node Report Summary" << endl;
m_msgs << "======================================" << endl;
m_msgs << " Total Received: " << m_total_reports_rcvd << endl;
map<string, unsigned int>::iterator p;
for(p=m_map_reports_rcvd.begin(); p!=m_map_reports_rcvd.end(); p++) {
string vname = p->first;
unsigned int total = p->second;
string pad_vname = padString(vname, 20);
m_msgs << " " << pad_vname << ": " << total;
double elapsed_time = m_curr_time - m_map_time_nreport[vname];
string stime = "(" + doubleToString(elapsed_time,1) + ")";
stime = padString(stime,12);
m_msgs << stime << endl;
}
m_msgs << " ------------------ " << endl;
m_msgs << " Total Sent: " << m_total_reports_sent << endl;
map<string, unsigned int>::iterator p2;
for(p2=m_map_reports_sent.begin(); p2!=m_map_reports_sent.end(); p2++) {
string vname = p2->first;
unsigned int total = p2->second;
vname = padString(vname, 20);
m_msgs << " " << vname << ": " << total << endl;
}
m_msgs << endl;
m_msgs << "Node Message Summary" << endl;
m_msgs << "======================================" << endl;
m_msgs << " Total Msgs Received: " << m_total_messages_rcvd << endl;
map<string, unsigned int>::iterator q;
for(q=m_map_messages_rcvd.begin(); q!=m_map_messages_rcvd.end(); q++) {
string vname = q->first;
unsigned int total = q->second;
string pad_vname = padString(vname, 20);
m_msgs << " " << pad_vname << ": " << total;
double elapsed_time = m_curr_time - m_map_time_nmessage[vname];
string stime = "(" + doubleToString(elapsed_time,1) + ")";
stime = padString(stime,12);
m_msgs << stime << endl;
}
m_msgs << " ------------------ " << endl;
m_msgs << " Total Sent: " << m_total_messages_sent << endl;
map<string, unsigned int>::iterator q2;
for(q2=m_map_messages_sent.begin(); q2!=m_map_messages_sent.end(); q2++) {
string vname = q2->first;
unsigned int total = q2->second;
vname = padString(vname, 20);
m_msgs << " " << vname << ": " << total << endl;
}
unsigned int total_blk_msgs = m_blk_msg_invalid + m_blk_msg_toostale +
m_blk_msg_tooquick + m_blk_msg_toolong + m_blk_msg_toofar;
string blk_msg_invalid = uintToString(m_blk_msg_invalid);
string blk_msg_toostale = uintToString(m_blk_msg_toostale);
string blk_msg_tooquick = uintToString(m_blk_msg_tooquick);
string blk_msg_toolong = uintToString(m_blk_msg_toolong);
string blk_msg_toofar = uintToString(m_blk_msg_toofar);
m_msgs << " ------------------ " << endl;
m_msgs << " Total Blocked Msgs: " << total_blk_msgs << endl;
m_msgs << " Invalid: " << blk_msg_invalid << endl;
m_msgs << " Stale Receiver: " << blk_msg_toostale << endl;
m_msgs << " Too Recent: " << blk_msg_tooquick<< endl;
m_msgs << " Msg Too Long: " << blk_msg_toolong << endl;
m_msgs << " Range Too Far: " << blk_msg_toofar << endl << endl;
return(true);
}
| 32.024648
| 82
| 0.613597
|
EasternEdgeRobotics
|
2a291633e0c1a8ff7405ad7c78b4b4df634f1948
| 3,738
|
cpp
|
C++
|
qtserver/components/transforms.cpp
|
jimfinnis/stumpy2
|
4011e42b7082f847396816b1b5aee46d7ce93b2b
|
[
"MIT"
] | null | null | null |
qtserver/components/transforms.cpp
|
jimfinnis/stumpy2
|
4011e42b7082f847396816b1b5aee46d7ce93b2b
|
[
"MIT"
] | 1
|
2016-05-18T12:03:16.000Z
|
2016-10-01T19:05:26.000Z
|
qtserver/components/transforms.cpp
|
jimfinnis/stumpy2
|
4011e42b7082f847396816b1b5aee46d7ce93b2b
|
[
"MIT"
] | null | null | null |
/**
* @file
* Simple transform components.
*
*
*/
#include "engine/engine.h"
#include "serverbase/model.h"
/// base class for all transforms which sets up common parameters
class SimpleTransformComponentType : public ComponentType {
public:
SimpleTransformComponentType(const char *name) : ComponentType(name,"transforms") {}
virtual void init() {
setInput(0,tFlow,"flow");
setInput(1,tFloat,"mod");
setOutput(0,tFlow,"flow");
setP();
}
protected:
virtual void setP(){
setParams(
pX = new FloatParameter("x",-100,100,0),
pY = new FloatParameter("y",-100,100,0),
pZ = new FloatParameter("z",-100,100,0),
pModX = new FloatParameter("mod x",-10,10,0),
pModY = new FloatParameter("mod y",-10,10,0),
pModZ = new FloatParameter("mod z",-10,10,0),
NULL);
}
FloatParameter *pX,*pY,*pZ,*pModX,*pModY,*pModZ;
};
class MoveComponent : public SimpleTransformComponentType {
public:
MoveComponent() : SimpleTransformComponentType("move") {}
virtual void run(ComponentInstance *ci,UNUSED int out){
Component *c = ci->component;
float mod = tFloat->getInput(ci,1);
MatrixStack *ms = StateManager::getInstance()->getx();
ms->push();
Matrix m=Matrix::IDENTITY;
m.setTranslation(
pX->get(c) + mod*pModX->get(c),
pY->get(c) + mod*pModY->get(c),
pZ->get(c) + mod*pModZ->get(c));
ms->mul(&m);
tFlow->getInput(ci,0);
ms->pop();
}
};
class ScaleComponent : public SimpleTransformComponentType {
public:
ScaleComponent() : SimpleTransformComponentType("scale") {}
virtual void setP(){
setParams(
pX = new FloatParameter("x",-100,100,1),
pY = new FloatParameter("y",-100,100,1),
pZ = new FloatParameter("z",-100,100,1),
pModX = new FloatParameter("mod x",-10,10,0),
pModY = new FloatParameter("mod y",-10,10,0),
pModZ = new FloatParameter("mod z",-10,10,0),
NULL);
}
virtual void run(ComponentInstance *ci,UNUSED int out){
Component *c = ci->component;
float mod = tFloat->getInput(ci,1);
MatrixStack *ms = StateManager::getInstance()->getx();
ms->push();
Matrix m=Matrix::IDENTITY;
m.setScale(
pX->get(c) + mod*pModX->get(c),
pY->get(c) + mod*pModY->get(c),
pZ->get(c) + mod*pModZ->get(c));
ms->mul(&m);
tFlow->getInput(ci,0);
ms->pop();
}
};
class RotateComponent : public SimpleTransformComponentType {
public:
RotateComponent() : SimpleTransformComponentType("rotate") {}
virtual void run(ComponentInstance *ci,UNUSED int out){
Component *c = ci->component;
float mod = tFloat->getInput(ci,1);
float rotx = pX->get(c) + mod*pModX->get(c);
float roty = pY->get(c) + mod*pModY->get(c);
float rotz = pZ->get(c) + mod*pModZ->get(c);
MatrixStack *ms = StateManager::getInstance()->getx();
ms->push();
Matrix m;
m.setTranslation(0,0,0);
m.makeRotate(rotx,roty,rotz,Matrix::ROT_YXZ);
ms->mul(&m);
tFlow->getInput(ci,0);
ms->pop();
}
};
static RotateComponent rreg;
static ScaleComponent sreg;
static MoveComponent mreg;
| 29.433071
| 88
| 0.52702
|
jimfinnis
|
2a29441c759c4e99f4f66784107318ede2d083dd
| 4,005
|
cpp
|
C++
|
GTraining/Map_v_UnorderedMap.cpp
|
tzaffi/cpp
|
43d99e70d8fa712f90ea0f6147774e4e0f2b11da
|
[
"MIT"
] | null | null | null |
GTraining/Map_v_UnorderedMap.cpp
|
tzaffi/cpp
|
43d99e70d8fa712f90ea0f6147774e4e0f2b11da
|
[
"MIT"
] | null | null | null |
GTraining/Map_v_UnorderedMap.cpp
|
tzaffi/cpp
|
43d99e70d8fa712f90ea0f6147774e4e0f2b11da
|
[
"MIT"
] | null | null | null |
//
// Created by zeph on 11/25/16.
//
/*
* In the interview prep at coogle, Sam Greenfiled pointed out that
* o map's basic operations run in O(log n) since it's backed by a BST
* while
* o unordered_map's is a true hash table with O(1) operations
*
* Let's test this theory out.
*/
#include <iostream>
#include <map>
#include <unordered_map>
#include <cassert>
#include "../helpers/coutFriends.cpp"
using namespace std;
using namespace std::chrono;
using hires = std::chrono::high_resolution_clock;
vector<int> makeRandomVector (size_t N) {
vector<int> randVect(N);
generate(randVect.begin(), randVect.end(), [](){return rand();});
return randVect;
}
template <typename M>
long long int populateMap (const vector<int> &v, M &table) {
chrono::steady_clock::time_point t1 = chrono::steady_clock::now();
for(auto x: v){
table[x] = x;
}
chrono::steady_clock::time_point t2 = chrono::steady_clock::now();
auto duration = duration_cast<chrono::microseconds>(t2 - t1 ).count();
return duration;
}
template <typename M>
long long int retrieveAllFromMap (const vector<int> &v, const M &table) {
chrono::steady_clock::time_point t1 = chrono::steady_clock::now();
for(auto x: v){
assert(table.count(x) == 1);
}
chrono::steady_clock::time_point t2 = chrono::steady_clock::now();
auto duration = duration_cast<chrono::microseconds>(t2 - t1 ).count();
return duration;
}
template <typename M>
long long int retrieveNonExistingFromMap (const vector<int> &v, const M &table) {
chrono::steady_clock::time_point t1 = chrono::steady_clock::now();
for(auto x: v){
assert(table.count(837497) == 0);
}
chrono::steady_clock::time_point t2 = chrono::steady_clock::now();
auto duration = duration_cast<chrono::microseconds>(t2 - t1 ).count();
return duration;
}
void runExperiment (size_t N) {
cout << "\n************************\n" << "Experiment with size N = " << N << endl;
cout << "************************\n" << endl;
vector<int> randVect{makeRandomVector(N)};
//cout << "randVect = \n" << randVect << endl << endl;
map<int, int> tableBST;
long long int duration1a = populateMap(randVect, tableBST);
cout << duration1a << " microseconds to populate Map with " << randVect.size() << " elements\n";
unordered_map<int, int> tableHash;
long long int duration1b = populateMap(randVect, tableHash);
cout << duration1b << " microseconds for Unordered_Map with " << randVect.size() << " elements\n";
long long int duration2a = retrieveAllFromMap(randVect, tableBST);
cout << duration2a << " microseconds to find all " << randVect.size() << " existing elements in Map\n";
long long int duration2b = retrieveAllFromMap(randVect, tableHash);
cout << duration2b << " microseconds to find all " << randVect.size() << " existing elements in Unordered_Map\n";
long long int duration3a = retrieveNonExistingFromMap(randVect, tableBST);
cout << duration3a << " microseconds to find all " << randVect.size() << " NON-existing elements in Map\n";
long long int duration3b = retrieveNonExistingFromMap(randVect, tableHash);
cout << duration3b << " microseconds to find all " << randVect.size() << " NON-existing elements in Unordered_Map\n";
cout << "----------SUMMARY----------\n";
string u("UNDEFINED");
cout << "Map is " << (duration1b ? to_string(duration1a / double(duration1b)) : u) << "X slower than unordered_map for population\n";
cout << "Map is " << (duration3b ? to_string(duration2a / double(duration2b)) : u) << "X slower than unordered_map for retrieval existing\n";
cout << "Map is " << (duration3b ? to_string(duration3a / double(duration3b)) : u) << "X slower than unordered_map for retrieval NON-existing\n";
}
int main (int argc, char* argv[])
{
std::srand((unsigned int)std::time(0));
for(size_t N = 1; N <= 10000000; N*=10) {
runExperiment(N);
}
return 0;
}
| 36.743119
| 149
| 0.653433
|
tzaffi
|
2a2aee399852bfcadf84621b8ed8c3ba630b1f54
| 153
|
hh
|
C++
|
CppPool/cpp_d07m/ex04/Destination.hh
|
667MARTIN/Epitech
|
81095d8e7d54e9abd95541ee3dfcc3bc85d5cf0e
|
[
"MIT"
] | 40
|
2018-01-28T14:23:27.000Z
|
2022-03-05T15:57:47.000Z
|
CppPool/cpp_d07m/ex04/Destination.hh
|
667MARTIN/Epitech
|
81095d8e7d54e9abd95541ee3dfcc3bc85d5cf0e
|
[
"MIT"
] | 1
|
2021-10-05T09:03:51.000Z
|
2021-10-05T09:03:51.000Z
|
CppPool/cpp_d07m/ex04/Destination.hh
|
667MARTIN/Epitech
|
81095d8e7d54e9abd95541ee3dfcc3bc85d5cf0e
|
[
"MIT"
] | 73
|
2019-01-07T18:47:00.000Z
|
2022-03-31T08:48:38.000Z
|
#ifndef _DESTINATION_
#define _DESTINATION_
enum Destination
{
EARTH,
VULCAN,
ROMULUS,
REMUS,
UNICOMPLEX,
JUPITER,
BABEL
};
#endif
| 10.2
| 22
| 0.673203
|
667MARTIN
|
2a313450a43c796fc2aaa13024b20d247cc1f511
| 228,084
|
cpp
|
C++
|
src/3rdparty/pythonqt/generated_cpp_50/com_trolltech_qt_webkit/com_trolltech_qt_webkit0.cpp
|
aliakseis/FVD
|
8d549834fcf9e8fdd5ebecdcaf9410074876b2ed
|
[
"MIT"
] | null | null | null |
src/3rdparty/pythonqt/generated_cpp_50/com_trolltech_qt_webkit/com_trolltech_qt_webkit0.cpp
|
aliakseis/FVD
|
8d549834fcf9e8fdd5ebecdcaf9410074876b2ed
|
[
"MIT"
] | null | null | null |
src/3rdparty/pythonqt/generated_cpp_50/com_trolltech_qt_webkit/com_trolltech_qt_webkit0.cpp
|
aliakseis/FVD
|
8d549834fcf9e8fdd5ebecdcaf9410074876b2ed
|
[
"MIT"
] | null | null | null |
#include "com_trolltech_qt_webkit0.h"
#include <PythonQtConversion.h>
#include <PythonQtMethodInfo.h>
#include <PythonQtSignalReceiver.h>
#include <QGraphicsScene>
#include <QVariant>
#include <qaction.h>
#include <qbackingstore.h>
#include <qbitmap.h>
#include <qbytearray.h>
#include <qcoreevent.h>
#include <qcursor.h>
#include <qdatastream.h>
#include <qdatetime.h>
#include <qevent.h>
#include <qfont.h>
#include <qgraphicseffect.h>
#include <qgraphicsitem.h>
#include <qgraphicslayout.h>
#include <qgraphicsproxywidget.h>
#include <qgraphicssceneevent.h>
#include <qgraphicswidget.h>
#include <qicon.h>
#include <qkeysequence.h>
#include <qlayout.h>
#include <qlist.h>
#include <qlocale.h>
#include <qmargins.h>
#include <qmenu.h>
#include <qmetaobject.h>
#include <qnetworkaccessmanager.h>
#include <qnetworkreply.h>
#include <qnetworkrequest.h>
#include <qobject.h>
#include <qpaintdevice.h>
#include <qpaintengine.h>
#include <qpainter.h>
#include <qpainterpath.h>
#include <qpalette.h>
#include <qpixmap.h>
#include <qpoint.h>
#include <qprinter.h>
#include <qrect.h>
#include <qregion.h>
#include <qsize.h>
#include <qsizepolicy.h>
#include <qstringlist.h>
#include <qstyle.h>
#include <qstyleoption.h>
#include <qundostack.h>
#include <qurl.h>
#include <qwebdatabase.h>
#include <qwebelement.h>
#include <qwebframe.h>
#include <qwebhistory.h>
#include <qwebhistoryinterface.h>
#include <qwebpage.h>
#include <qwebpluginfactory.h>
#include <qwebsecurityorigin.h>
#include <qwebsettings.h>
#include <qwebview.h>
#include <qwidget.h>
#include <qwindow.h>
PythonQtShell_QGraphicsWebView::~PythonQtShell_QGraphicsWebView() {
PythonQtPrivate* priv = PythonQt::priv();
if (priv) { priv->shellClassDeleted(this); }
}
void PythonQtShell_QGraphicsWebView::changeEvent(QEvent* event0)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("changeEvent");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&event0};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QGraphicsWebView::changeEvent(event0);
}
void PythonQtShell_QGraphicsWebView::childEvent(QChildEvent* arg__1)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("childEvent");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QChildEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QGraphicsWebView::childEvent(arg__1);
}
void PythonQtShell_QGraphicsWebView::closeEvent(QCloseEvent* event0)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("closeEvent");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QCloseEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&event0};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QGraphicsWebView::closeEvent(event0);
}
void PythonQtShell_QGraphicsWebView::contextMenuEvent(QGraphicsSceneContextMenuEvent* arg__1)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("contextMenuEvent");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QGraphicsSceneContextMenuEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QGraphicsWebView::contextMenuEvent(arg__1);
}
void PythonQtShell_QGraphicsWebView::customEvent(QEvent* arg__1)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("customEvent");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QGraphicsWebView::customEvent(arg__1);
}
void PythonQtShell_QGraphicsWebView::dragEnterEvent(QGraphicsSceneDragDropEvent* arg__1)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("dragEnterEvent");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QGraphicsSceneDragDropEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QGraphicsWebView::dragEnterEvent(arg__1);
}
void PythonQtShell_QGraphicsWebView::dragLeaveEvent(QGraphicsSceneDragDropEvent* arg__1)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("dragLeaveEvent");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QGraphicsSceneDragDropEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QGraphicsWebView::dragLeaveEvent(arg__1);
}
void PythonQtShell_QGraphicsWebView::dragMoveEvent(QGraphicsSceneDragDropEvent* arg__1)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("dragMoveEvent");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QGraphicsSceneDragDropEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QGraphicsWebView::dragMoveEvent(arg__1);
}
void PythonQtShell_QGraphicsWebView::dropEvent(QGraphicsSceneDragDropEvent* arg__1)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("dropEvent");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QGraphicsSceneDragDropEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QGraphicsWebView::dropEvent(arg__1);
}
bool PythonQtShell_QGraphicsWebView::event(QEvent* arg__1)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("event");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"bool" , "QEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
bool returnValue;
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) {
args[0] = PythonQtConv::ConvertPythonToQt(methodInfo->parameters().at(0), result, false, NULL, &returnValue);
if (args[0]!=&returnValue) {
if (args[0]==NULL) {
PythonQt::priv()->handleVirtualOverloadReturnError("event", methodInfo, result);
} else {
returnValue = *((bool*)args[0]);
}
}
}
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return returnValue;
} else {
PyErr_Clear();
}
}
return QGraphicsWebView::event(arg__1);
}
bool PythonQtShell_QGraphicsWebView::eventFilter(QObject* arg__1, QEvent* arg__2)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("eventFilter");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"bool" , "QObject*" , "QEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(3, argumentList);
bool returnValue;
void* args[3] = {NULL, (void*)&arg__1, (void*)&arg__2};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) {
args[0] = PythonQtConv::ConvertPythonToQt(methodInfo->parameters().at(0), result, false, NULL, &returnValue);
if (args[0]!=&returnValue) {
if (args[0]==NULL) {
PythonQt::priv()->handleVirtualOverloadReturnError("eventFilter", methodInfo, result);
} else {
returnValue = *((bool*)args[0]);
}
}
}
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return returnValue;
} else {
PyErr_Clear();
}
}
return QGraphicsWebView::eventFilter(arg__1, arg__2);
}
void PythonQtShell_QGraphicsWebView::focusInEvent(QFocusEvent* arg__1)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("focusInEvent");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QFocusEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QGraphicsWebView::focusInEvent(arg__1);
}
bool PythonQtShell_QGraphicsWebView::focusNextPrevChild(bool next0)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("focusNextPrevChild");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"bool" , "bool"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
bool returnValue;
void* args[2] = {NULL, (void*)&next0};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) {
args[0] = PythonQtConv::ConvertPythonToQt(methodInfo->parameters().at(0), result, false, NULL, &returnValue);
if (args[0]!=&returnValue) {
if (args[0]==NULL) {
PythonQt::priv()->handleVirtualOverloadReturnError("focusNextPrevChild", methodInfo, result);
} else {
returnValue = *((bool*)args[0]);
}
}
}
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return returnValue;
} else {
PyErr_Clear();
}
}
return QGraphicsWebView::focusNextPrevChild(next0);
}
void PythonQtShell_QGraphicsWebView::focusOutEvent(QFocusEvent* arg__1)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("focusOutEvent");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QFocusEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QGraphicsWebView::focusOutEvent(arg__1);
}
void PythonQtShell_QGraphicsWebView::getContentsMargins(qreal* left0, qreal* top1, qreal* right2, qreal* bottom3) const
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("getContentsMargins");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "qreal*" , "qreal*" , "qreal*" , "qreal*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(5, argumentList);
void* args[5] = {NULL, (void*)&left0, (void*)&top1, (void*)&right2, (void*)&bottom3};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QGraphicsWebView::getContentsMargins(left0, top1, right2, bottom3);
}
void PythonQtShell_QGraphicsWebView::grabKeyboardEvent(QEvent* event0)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("grabKeyboardEvent");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&event0};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QGraphicsWebView::grabKeyboardEvent(event0);
}
void PythonQtShell_QGraphicsWebView::grabMouseEvent(QEvent* event0)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("grabMouseEvent");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&event0};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QGraphicsWebView::grabMouseEvent(event0);
}
void PythonQtShell_QGraphicsWebView::hideEvent(QHideEvent* event0)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("hideEvent");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QHideEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&event0};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QGraphicsWebView::hideEvent(event0);
}
void PythonQtShell_QGraphicsWebView::hoverLeaveEvent(QGraphicsSceneHoverEvent* arg__1)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("hoverLeaveEvent");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QGraphicsSceneHoverEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QGraphicsWebView::hoverLeaveEvent(arg__1);
}
void PythonQtShell_QGraphicsWebView::hoverMoveEvent(QGraphicsSceneHoverEvent* arg__1)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("hoverMoveEvent");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QGraphicsSceneHoverEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QGraphicsWebView::hoverMoveEvent(arg__1);
}
void PythonQtShell_QGraphicsWebView::initStyleOption(QStyleOption* option0) const
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("initStyleOption");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QStyleOption*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&option0};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QGraphicsWebView::initStyleOption(option0);
}
void PythonQtShell_QGraphicsWebView::inputMethodEvent(QInputMethodEvent* arg__1)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("inputMethodEvent");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QInputMethodEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QGraphicsWebView::inputMethodEvent(arg__1);
}
QVariant PythonQtShell_QGraphicsWebView::inputMethodQuery(Qt::InputMethodQuery query0) const
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("inputMethodQuery");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"QVariant" , "Qt::InputMethodQuery"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
QVariant returnValue;
void* args[2] = {NULL, (void*)&query0};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) {
args[0] = PythonQtConv::ConvertPythonToQt(methodInfo->parameters().at(0), result, false, NULL, &returnValue);
if (args[0]!=&returnValue) {
if (args[0]==NULL) {
PythonQt::priv()->handleVirtualOverloadReturnError("inputMethodQuery", methodInfo, result);
} else {
returnValue = *((QVariant*)args[0]);
}
}
}
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return returnValue;
} else {
PyErr_Clear();
}
}
return QGraphicsWebView::inputMethodQuery(query0);
}
QVariant PythonQtShell_QGraphicsWebView::itemChange(QGraphicsItem::GraphicsItemChange change0, const QVariant& value1)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("itemChange");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"QVariant" , "QGraphicsItem::GraphicsItemChange" , "const QVariant&"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(3, argumentList);
QVariant returnValue;
void* args[3] = {NULL, (void*)&change0, (void*)&value1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) {
args[0] = PythonQtConv::ConvertPythonToQt(methodInfo->parameters().at(0), result, false, NULL, &returnValue);
if (args[0]!=&returnValue) {
if (args[0]==NULL) {
PythonQt::priv()->handleVirtualOverloadReturnError("itemChange", methodInfo, result);
} else {
returnValue = *((QVariant*)args[0]);
}
}
}
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
if (change0 == QGraphicsItem::ItemParentChange || change0 == QGraphicsItem::ItemSceneChange) {
returnValue = value1;
}
return returnValue;
} else {
PyErr_Clear();
}
}
return QGraphicsWebView::itemChange(change0, value1);
}
void PythonQtShell_QGraphicsWebView::keyPressEvent(QKeyEvent* arg__1)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("keyPressEvent");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QKeyEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QGraphicsWebView::keyPressEvent(arg__1);
}
void PythonQtShell_QGraphicsWebView::keyReleaseEvent(QKeyEvent* arg__1)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("keyReleaseEvent");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QKeyEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QGraphicsWebView::keyReleaseEvent(arg__1);
}
void PythonQtShell_QGraphicsWebView::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* arg__1)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("mouseDoubleClickEvent");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QGraphicsSceneMouseEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QGraphicsWebView::mouseDoubleClickEvent(arg__1);
}
void PythonQtShell_QGraphicsWebView::mouseMoveEvent(QGraphicsSceneMouseEvent* arg__1)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("mouseMoveEvent");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QGraphicsSceneMouseEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QGraphicsWebView::mouseMoveEvent(arg__1);
}
void PythonQtShell_QGraphicsWebView::mousePressEvent(QGraphicsSceneMouseEvent* arg__1)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("mousePressEvent");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QGraphicsSceneMouseEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QGraphicsWebView::mousePressEvent(arg__1);
}
void PythonQtShell_QGraphicsWebView::mouseReleaseEvent(QGraphicsSceneMouseEvent* arg__1)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("mouseReleaseEvent");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QGraphicsSceneMouseEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QGraphicsWebView::mouseReleaseEvent(arg__1);
}
void PythonQtShell_QGraphicsWebView::moveEvent(QGraphicsSceneMoveEvent* event0)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("moveEvent");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QGraphicsSceneMoveEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&event0};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QGraphicsWebView::moveEvent(event0);
}
void PythonQtShell_QGraphicsWebView::paint(QPainter* arg__1, const QStyleOptionGraphicsItem* options1, QWidget* widget2)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("paint");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QPainter*" , "const QStyleOptionGraphicsItem*" , "QWidget*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(4, argumentList);
void* args[4] = {NULL, (void*)&arg__1, (void*)&options1, (void*)&widget2};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QGraphicsWebView::paint(arg__1, options1, widget2);
}
void PythonQtShell_QGraphicsWebView::paintWindowFrame(QPainter* painter0, const QStyleOptionGraphicsItem* option1, QWidget* widget2)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("paintWindowFrame");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QPainter*" , "const QStyleOptionGraphicsItem*" , "QWidget*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(4, argumentList);
void* args[4] = {NULL, (void*)&painter0, (void*)&option1, (void*)&widget2};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QGraphicsWebView::paintWindowFrame(painter0, option1, widget2);
}
void PythonQtShell_QGraphicsWebView::polishEvent()
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("polishEvent");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={""};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(1, argumentList);
void* args[1] = {NULL};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QGraphicsWebView::polishEvent();
}
QVariant PythonQtShell_QGraphicsWebView::propertyChange(const QString& propertyName0, const QVariant& value1)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("propertyChange");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"QVariant" , "const QString&" , "const QVariant&"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(3, argumentList);
QVariant returnValue;
void* args[3] = {NULL, (void*)&propertyName0, (void*)&value1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) {
args[0] = PythonQtConv::ConvertPythonToQt(methodInfo->parameters().at(0), result, false, NULL, &returnValue);
if (args[0]!=&returnValue) {
if (args[0]==NULL) {
PythonQt::priv()->handleVirtualOverloadReturnError("propertyChange", methodInfo, result);
} else {
returnValue = *((QVariant*)args[0]);
}
}
}
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return returnValue;
} else {
PyErr_Clear();
}
}
return QGraphicsWebView::propertyChange(propertyName0, value1);
}
void PythonQtShell_QGraphicsWebView::resizeEvent(QGraphicsSceneResizeEvent* event0)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("resizeEvent");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QGraphicsSceneResizeEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&event0};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QGraphicsWebView::resizeEvent(event0);
}
bool PythonQtShell_QGraphicsWebView::sceneEvent(QEvent* arg__1)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("sceneEvent");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"bool" , "QEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
bool returnValue;
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) {
args[0] = PythonQtConv::ConvertPythonToQt(methodInfo->parameters().at(0), result, false, NULL, &returnValue);
if (args[0]!=&returnValue) {
if (args[0]==NULL) {
PythonQt::priv()->handleVirtualOverloadReturnError("sceneEvent", methodInfo, result);
} else {
returnValue = *((bool*)args[0]);
}
}
}
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return returnValue;
} else {
PyErr_Clear();
}
}
return QGraphicsWebView::sceneEvent(arg__1);
}
void PythonQtShell_QGraphicsWebView::setGeometry(const QRectF& rect0)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("setGeometry");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "const QRectF&"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&rect0};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QGraphicsWebView::setGeometry(rect0);
}
void PythonQtShell_QGraphicsWebView::showEvent(QShowEvent* event0)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("showEvent");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QShowEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&event0};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QGraphicsWebView::showEvent(event0);
}
QSizeF PythonQtShell_QGraphicsWebView::sizeHint(Qt::SizeHint which0, const QSizeF& constraint1) const
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("sizeHint");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"QSizeF" , "Qt::SizeHint" , "const QSizeF&"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(3, argumentList);
QSizeF returnValue;
void* args[3] = {NULL, (void*)&which0, (void*)&constraint1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) {
args[0] = PythonQtConv::ConvertPythonToQt(methodInfo->parameters().at(0), result, false, NULL, &returnValue);
if (args[0]!=&returnValue) {
if (args[0]==NULL) {
PythonQt::priv()->handleVirtualOverloadReturnError("sizeHint", methodInfo, result);
} else {
returnValue = *((QSizeF*)args[0]);
}
}
}
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return returnValue;
} else {
PyErr_Clear();
}
}
return QGraphicsWebView::sizeHint(which0, constraint1);
}
void PythonQtShell_QGraphicsWebView::timerEvent(QTimerEvent* arg__1)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("timerEvent");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QTimerEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QGraphicsWebView::timerEvent(arg__1);
}
void PythonQtShell_QGraphicsWebView::ungrabKeyboardEvent(QEvent* event0)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("ungrabKeyboardEvent");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&event0};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QGraphicsWebView::ungrabKeyboardEvent(event0);
}
void PythonQtShell_QGraphicsWebView::ungrabMouseEvent(QEvent* event0)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("ungrabMouseEvent");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&event0};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QGraphicsWebView::ungrabMouseEvent(event0);
}
void PythonQtShell_QGraphicsWebView::updateGeometry()
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("updateGeometry");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={""};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(1, argumentList);
void* args[1] = {NULL};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QGraphicsWebView::updateGeometry();
}
void PythonQtShell_QGraphicsWebView::wheelEvent(QGraphicsSceneWheelEvent* arg__1)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("wheelEvent");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QGraphicsSceneWheelEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QGraphicsWebView::wheelEvent(arg__1);
}
bool PythonQtShell_QGraphicsWebView::windowFrameEvent(QEvent* e0)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("windowFrameEvent");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"bool" , "QEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
bool returnValue;
void* args[2] = {NULL, (void*)&e0};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) {
args[0] = PythonQtConv::ConvertPythonToQt(methodInfo->parameters().at(0), result, false, NULL, &returnValue);
if (args[0]!=&returnValue) {
if (args[0]==NULL) {
PythonQt::priv()->handleVirtualOverloadReturnError("windowFrameEvent", methodInfo, result);
} else {
returnValue = *((bool*)args[0]);
}
}
}
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return returnValue;
} else {
PyErr_Clear();
}
}
return QGraphicsWebView::windowFrameEvent(e0);
}
Qt::WindowFrameSection PythonQtShell_QGraphicsWebView::windowFrameSectionAt(const QPointF& pos0) const
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("windowFrameSectionAt");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"Qt::WindowFrameSection" , "const QPointF&"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
Qt::WindowFrameSection returnValue;
void* args[2] = {NULL, (void*)&pos0};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) {
args[0] = PythonQtConv::ConvertPythonToQt(methodInfo->parameters().at(0), result, false, NULL, &returnValue);
if (args[0]!=&returnValue) {
if (args[0]==NULL) {
PythonQt::priv()->handleVirtualOverloadReturnError("windowFrameSectionAt", methodInfo, result);
} else {
returnValue = *((Qt::WindowFrameSection*)args[0]);
}
}
}
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return returnValue;
} else {
PyErr_Clear();
}
}
return QGraphicsWebView::windowFrameSectionAt(pos0);
}
QGraphicsWebView* PythonQtWrapper_QGraphicsWebView::new_QGraphicsWebView(QGraphicsItem* parent)
{
return new PythonQtShell_QGraphicsWebView(parent); }
void PythonQtWrapper_QGraphicsWebView::contextMenuEvent(QGraphicsWebView* theWrappedObject, QGraphicsSceneContextMenuEvent* arg__1)
{
( ((PythonQtPublicPromoter_QGraphicsWebView*)theWrappedObject)->promoted_contextMenuEvent(arg__1));
}
void PythonQtWrapper_QGraphicsWebView::dragEnterEvent(QGraphicsWebView* theWrappedObject, QGraphicsSceneDragDropEvent* arg__1)
{
( ((PythonQtPublicPromoter_QGraphicsWebView*)theWrappedObject)->promoted_dragEnterEvent(arg__1));
}
void PythonQtWrapper_QGraphicsWebView::dragLeaveEvent(QGraphicsWebView* theWrappedObject, QGraphicsSceneDragDropEvent* arg__1)
{
( ((PythonQtPublicPromoter_QGraphicsWebView*)theWrappedObject)->promoted_dragLeaveEvent(arg__1));
}
void PythonQtWrapper_QGraphicsWebView::dragMoveEvent(QGraphicsWebView* theWrappedObject, QGraphicsSceneDragDropEvent* arg__1)
{
( ((PythonQtPublicPromoter_QGraphicsWebView*)theWrappedObject)->promoted_dragMoveEvent(arg__1));
}
void PythonQtWrapper_QGraphicsWebView::dropEvent(QGraphicsWebView* theWrappedObject, QGraphicsSceneDragDropEvent* arg__1)
{
( ((PythonQtPublicPromoter_QGraphicsWebView*)theWrappedObject)->promoted_dropEvent(arg__1));
}
bool PythonQtWrapper_QGraphicsWebView::event(QGraphicsWebView* theWrappedObject, QEvent* arg__1)
{
return ( ((PythonQtPublicPromoter_QGraphicsWebView*)theWrappedObject)->promoted_event(arg__1));
}
bool PythonQtWrapper_QGraphicsWebView::findText(QGraphicsWebView* theWrappedObject, const QString& subString, QWebPage::FindFlags options)
{
return ( theWrappedObject->findText(subString, options));
}
void PythonQtWrapper_QGraphicsWebView::focusInEvent(QGraphicsWebView* theWrappedObject, QFocusEvent* arg__1)
{
( ((PythonQtPublicPromoter_QGraphicsWebView*)theWrappedObject)->promoted_focusInEvent(arg__1));
}
bool PythonQtWrapper_QGraphicsWebView::focusNextPrevChild(QGraphicsWebView* theWrappedObject, bool next)
{
return ( ((PythonQtPublicPromoter_QGraphicsWebView*)theWrappedObject)->promoted_focusNextPrevChild(next));
}
void PythonQtWrapper_QGraphicsWebView::focusOutEvent(QGraphicsWebView* theWrappedObject, QFocusEvent* arg__1)
{
( ((PythonQtPublicPromoter_QGraphicsWebView*)theWrappedObject)->promoted_focusOutEvent(arg__1));
}
QWebHistory* PythonQtWrapper_QGraphicsWebView::history(QGraphicsWebView* theWrappedObject) const
{
return ( theWrappedObject->history());
}
void PythonQtWrapper_QGraphicsWebView::hoverLeaveEvent(QGraphicsWebView* theWrappedObject, QGraphicsSceneHoverEvent* arg__1)
{
( ((PythonQtPublicPromoter_QGraphicsWebView*)theWrappedObject)->promoted_hoverLeaveEvent(arg__1));
}
void PythonQtWrapper_QGraphicsWebView::hoverMoveEvent(QGraphicsWebView* theWrappedObject, QGraphicsSceneHoverEvent* arg__1)
{
( ((PythonQtPublicPromoter_QGraphicsWebView*)theWrappedObject)->promoted_hoverMoveEvent(arg__1));
}
QIcon PythonQtWrapper_QGraphicsWebView::icon(QGraphicsWebView* theWrappedObject) const
{
return ( theWrappedObject->icon());
}
void PythonQtWrapper_QGraphicsWebView::inputMethodEvent(QGraphicsWebView* theWrappedObject, QInputMethodEvent* arg__1)
{
( ((PythonQtPublicPromoter_QGraphicsWebView*)theWrappedObject)->promoted_inputMethodEvent(arg__1));
}
QVariant PythonQtWrapper_QGraphicsWebView::inputMethodQuery(QGraphicsWebView* theWrappedObject, Qt::InputMethodQuery query) const
{
return ( ((PythonQtPublicPromoter_QGraphicsWebView*)theWrappedObject)->promoted_inputMethodQuery(query));
}
bool PythonQtWrapper_QGraphicsWebView::isModified(QGraphicsWebView* theWrappedObject) const
{
return ( theWrappedObject->isModified());
}
bool PythonQtWrapper_QGraphicsWebView::isTiledBackingStoreFrozen(QGraphicsWebView* theWrappedObject) const
{
return ( theWrappedObject->isTiledBackingStoreFrozen());
}
QVariant PythonQtWrapper_QGraphicsWebView::itemChange(QGraphicsWebView* theWrappedObject, QGraphicsItem::GraphicsItemChange change, const QVariant& value)
{
return ( ((PythonQtPublicPromoter_QGraphicsWebView*)theWrappedObject)->promoted_itemChange(change, value));
}
void PythonQtWrapper_QGraphicsWebView::keyPressEvent(QGraphicsWebView* theWrappedObject, QKeyEvent* arg__1)
{
( ((PythonQtPublicPromoter_QGraphicsWebView*)theWrappedObject)->promoted_keyPressEvent(arg__1));
}
void PythonQtWrapper_QGraphicsWebView::keyReleaseEvent(QGraphicsWebView* theWrappedObject, QKeyEvent* arg__1)
{
( ((PythonQtPublicPromoter_QGraphicsWebView*)theWrappedObject)->promoted_keyReleaseEvent(arg__1));
}
void PythonQtWrapper_QGraphicsWebView::load(QGraphicsWebView* theWrappedObject, const QNetworkRequest& request, QNetworkAccessManager::Operation operation, const QByteArray& body)
{
( theWrappedObject->load(request, operation, body));
}
void PythonQtWrapper_QGraphicsWebView::load(QGraphicsWebView* theWrappedObject, const QUrl& url)
{
( theWrappedObject->load(url));
}
void PythonQtWrapper_QGraphicsWebView::mouseDoubleClickEvent(QGraphicsWebView* theWrappedObject, QGraphicsSceneMouseEvent* arg__1)
{
( ((PythonQtPublicPromoter_QGraphicsWebView*)theWrappedObject)->promoted_mouseDoubleClickEvent(arg__1));
}
void PythonQtWrapper_QGraphicsWebView::mouseMoveEvent(QGraphicsWebView* theWrappedObject, QGraphicsSceneMouseEvent* arg__1)
{
( ((PythonQtPublicPromoter_QGraphicsWebView*)theWrappedObject)->promoted_mouseMoveEvent(arg__1));
}
void PythonQtWrapper_QGraphicsWebView::mousePressEvent(QGraphicsWebView* theWrappedObject, QGraphicsSceneMouseEvent* arg__1)
{
( ((PythonQtPublicPromoter_QGraphicsWebView*)theWrappedObject)->promoted_mousePressEvent(arg__1));
}
void PythonQtWrapper_QGraphicsWebView::mouseReleaseEvent(QGraphicsWebView* theWrappedObject, QGraphicsSceneMouseEvent* arg__1)
{
( ((PythonQtPublicPromoter_QGraphicsWebView*)theWrappedObject)->promoted_mouseReleaseEvent(arg__1));
}
QWebPage* PythonQtWrapper_QGraphicsWebView::page(QGraphicsWebView* theWrappedObject) const
{
return ( theWrappedObject->page());
}
QAction* PythonQtWrapper_QGraphicsWebView::pageAction(QGraphicsWebView* theWrappedObject, QWebPage::WebAction action) const
{
return ( theWrappedObject->pageAction(action));
}
void PythonQtWrapper_QGraphicsWebView::paint(QGraphicsWebView* theWrappedObject, QPainter* arg__1, const QStyleOptionGraphicsItem* options, QWidget* widget)
{
( ((PythonQtPublicPromoter_QGraphicsWebView*)theWrappedObject)->promoted_paint(arg__1, options, widget));
}
QPainter::RenderHints PythonQtWrapper_QGraphicsWebView::renderHints(QGraphicsWebView* theWrappedObject) const
{
return ( theWrappedObject->renderHints());
}
bool PythonQtWrapper_QGraphicsWebView::resizesToContents(QGraphicsWebView* theWrappedObject) const
{
return ( theWrappedObject->resizesToContents());
}
bool PythonQtWrapper_QGraphicsWebView::sceneEvent(QGraphicsWebView* theWrappedObject, QEvent* arg__1)
{
return ( ((PythonQtPublicPromoter_QGraphicsWebView*)theWrappedObject)->promoted_sceneEvent(arg__1));
}
void PythonQtWrapper_QGraphicsWebView::setContent(QGraphicsWebView* theWrappedObject, const QByteArray& data, const QString& mimeType, const QUrl& baseUrl)
{
( theWrappedObject->setContent(data, mimeType, baseUrl));
}
void PythonQtWrapper_QGraphicsWebView::setGeometry(QGraphicsWebView* theWrappedObject, const QRectF& rect)
{
( ((PythonQtPublicPromoter_QGraphicsWebView*)theWrappedObject)->promoted_setGeometry(rect));
}
void PythonQtWrapper_QGraphicsWebView::setHtml(QGraphicsWebView* theWrappedObject, const QString& html, const QUrl& baseUrl)
{
( theWrappedObject->setHtml(html, baseUrl));
}
void PythonQtWrapper_QGraphicsWebView::setPage(QGraphicsWebView* theWrappedObject, QWebPage* arg__1)
{
( theWrappedObject->setPage(arg__1));
}
void PythonQtWrapper_QGraphicsWebView::setRenderHint(QGraphicsWebView* theWrappedObject, QPainter::RenderHint arg__1, bool enabled)
{
( theWrappedObject->setRenderHint(arg__1, enabled));
}
void PythonQtWrapper_QGraphicsWebView::setRenderHints(QGraphicsWebView* theWrappedObject, QPainter::RenderHints arg__1)
{
( theWrappedObject->setRenderHints(arg__1));
}
void PythonQtWrapper_QGraphicsWebView::setResizesToContents(QGraphicsWebView* theWrappedObject, bool enabled)
{
( theWrappedObject->setResizesToContents(enabled));
}
void PythonQtWrapper_QGraphicsWebView::setTiledBackingStoreFrozen(QGraphicsWebView* theWrappedObject, bool frozen)
{
( theWrappedObject->setTiledBackingStoreFrozen(frozen));
}
void PythonQtWrapper_QGraphicsWebView::setUrl(QGraphicsWebView* theWrappedObject, const QUrl& arg__1)
{
( theWrappedObject->setUrl(arg__1));
}
void PythonQtWrapper_QGraphicsWebView::setZoomFactor(QGraphicsWebView* theWrappedObject, qreal arg__1)
{
( theWrappedObject->setZoomFactor(arg__1));
}
QWebSettings* PythonQtWrapper_QGraphicsWebView::settings(QGraphicsWebView* theWrappedObject) const
{
return ( theWrappedObject->settings());
}
QSizeF PythonQtWrapper_QGraphicsWebView::sizeHint(QGraphicsWebView* theWrappedObject, Qt::SizeHint which, const QSizeF& constraint) const
{
return ( ((PythonQtPublicPromoter_QGraphicsWebView*)theWrappedObject)->promoted_sizeHint(which, constraint));
}
QString PythonQtWrapper_QGraphicsWebView::title(QGraphicsWebView* theWrappedObject) const
{
return ( theWrappedObject->title());
}
void PythonQtWrapper_QGraphicsWebView::triggerPageAction(QGraphicsWebView* theWrappedObject, QWebPage::WebAction action, bool checked)
{
( theWrappedObject->triggerPageAction(action, checked));
}
void PythonQtWrapper_QGraphicsWebView::updateGeometry(QGraphicsWebView* theWrappedObject)
{
( ((PythonQtPublicPromoter_QGraphicsWebView*)theWrappedObject)->promoted_updateGeometry());
}
QUrl PythonQtWrapper_QGraphicsWebView::url(QGraphicsWebView* theWrappedObject) const
{
return ( theWrappedObject->url());
}
void PythonQtWrapper_QGraphicsWebView::wheelEvent(QGraphicsWebView* theWrappedObject, QGraphicsSceneWheelEvent* arg__1)
{
( ((PythonQtPublicPromoter_QGraphicsWebView*)theWrappedObject)->promoted_wheelEvent(arg__1));
}
qreal PythonQtWrapper_QGraphicsWebView::zoomFactor(QGraphicsWebView* theWrappedObject) const
{
return ( theWrappedObject->zoomFactor());
}
QWebDatabase* PythonQtWrapper_QWebDatabase::new_QWebDatabase(const QWebDatabase& other)
{
return new QWebDatabase(other); }
QString PythonQtWrapper_QWebDatabase::displayName(QWebDatabase* theWrappedObject) const
{
return ( theWrappedObject->displayName());
}
qint64 PythonQtWrapper_QWebDatabase::expectedSize(QWebDatabase* theWrappedObject) const
{
return ( theWrappedObject->expectedSize());
}
QString PythonQtWrapper_QWebDatabase::fileName(QWebDatabase* theWrappedObject) const
{
return ( theWrappedObject->fileName());
}
QString PythonQtWrapper_QWebDatabase::name(QWebDatabase* theWrappedObject) const
{
return ( theWrappedObject->name());
}
QWebDatabase* PythonQtWrapper_QWebDatabase::operator_assign(QWebDatabase* theWrappedObject, const QWebDatabase& other)
{
return &( (*theWrappedObject)= other);
}
QWebSecurityOrigin PythonQtWrapper_QWebDatabase::origin(QWebDatabase* theWrappedObject) const
{
return ( theWrappedObject->origin());
}
void PythonQtWrapper_QWebDatabase::static_QWebDatabase_removeAllDatabases()
{
(QWebDatabase::removeAllDatabases());
}
void PythonQtWrapper_QWebDatabase::static_QWebDatabase_removeDatabase(const QWebDatabase& arg__1)
{
(QWebDatabase::removeDatabase(arg__1));
}
qint64 PythonQtWrapper_QWebDatabase::size(QWebDatabase* theWrappedObject) const
{
return ( theWrappedObject->size());
}
QWebElement* PythonQtWrapper_QWebElement::new_QWebElement()
{
return new QWebElement(); }
QWebElement* PythonQtWrapper_QWebElement::new_QWebElement(const QWebElement& arg__1)
{
return new QWebElement(arg__1); }
void PythonQtWrapper_QWebElement::addClass(QWebElement* theWrappedObject, const QString& name)
{
( theWrappedObject->addClass(name));
}
void PythonQtWrapper_QWebElement::appendInside(QWebElement* theWrappedObject, const QString& markup)
{
( theWrappedObject->appendInside(markup));
}
void PythonQtWrapper_QWebElement::appendInside(QWebElement* theWrappedObject, const QWebElement& element)
{
( theWrappedObject->appendInside(element));
}
void PythonQtWrapper_QWebElement::appendOutside(QWebElement* theWrappedObject, const QString& markup)
{
( theWrappedObject->appendOutside(markup));
}
void PythonQtWrapper_QWebElement::appendOutside(QWebElement* theWrappedObject, const QWebElement& element)
{
( theWrappedObject->appendOutside(element));
}
QString PythonQtWrapper_QWebElement::attribute(QWebElement* theWrappedObject, const QString& name, const QString& defaultValue) const
{
return ( theWrappedObject->attribute(name, defaultValue));
}
QString PythonQtWrapper_QWebElement::attributeNS(QWebElement* theWrappedObject, const QString& namespaceUri, const QString& name, const QString& defaultValue) const
{
return ( theWrappedObject->attributeNS(namespaceUri, name, defaultValue));
}
QStringList PythonQtWrapper_QWebElement::attributeNames(QWebElement* theWrappedObject, const QString& namespaceUri) const
{
return ( theWrappedObject->attributeNames(namespaceUri));
}
QStringList PythonQtWrapper_QWebElement::classes(QWebElement* theWrappedObject) const
{
return ( theWrappedObject->classes());
}
QWebElement PythonQtWrapper_QWebElement::clone(QWebElement* theWrappedObject) const
{
return ( theWrappedObject->clone());
}
QWebElement PythonQtWrapper_QWebElement::document(QWebElement* theWrappedObject) const
{
return ( theWrappedObject->document());
}
void PythonQtWrapper_QWebElement::encloseContentsWith(QWebElement* theWrappedObject, const QString& markup)
{
( theWrappedObject->encloseContentsWith(markup));
}
void PythonQtWrapper_QWebElement::encloseContentsWith(QWebElement* theWrappedObject, const QWebElement& element)
{
( theWrappedObject->encloseContentsWith(element));
}
void PythonQtWrapper_QWebElement::encloseWith(QWebElement* theWrappedObject, const QString& markup)
{
( theWrappedObject->encloseWith(markup));
}
void PythonQtWrapper_QWebElement::encloseWith(QWebElement* theWrappedObject, const QWebElement& element)
{
( theWrappedObject->encloseWith(element));
}
QVariant PythonQtWrapper_QWebElement::evaluateJavaScript(QWebElement* theWrappedObject, const QString& scriptSource)
{
return ( theWrappedObject->evaluateJavaScript(scriptSource));
}
QWebElementCollection PythonQtWrapper_QWebElement::findAll(QWebElement* theWrappedObject, const QString& selectorQuery) const
{
return ( theWrappedObject->findAll(selectorQuery));
}
QWebElement PythonQtWrapper_QWebElement::findFirst(QWebElement* theWrappedObject, const QString& selectorQuery) const
{
return ( theWrappedObject->findFirst(selectorQuery));
}
QWebElement PythonQtWrapper_QWebElement::firstChild(QWebElement* theWrappedObject) const
{
return ( theWrappedObject->firstChild());
}
QRect PythonQtWrapper_QWebElement::geometry(QWebElement* theWrappedObject) const
{
return ( theWrappedObject->geometry());
}
bool PythonQtWrapper_QWebElement::hasAttribute(QWebElement* theWrappedObject, const QString& name) const
{
return ( theWrappedObject->hasAttribute(name));
}
bool PythonQtWrapper_QWebElement::hasAttributeNS(QWebElement* theWrappedObject, const QString& namespaceUri, const QString& name) const
{
return ( theWrappedObject->hasAttributeNS(namespaceUri, name));
}
bool PythonQtWrapper_QWebElement::hasAttributes(QWebElement* theWrappedObject) const
{
return ( theWrappedObject->hasAttributes());
}
bool PythonQtWrapper_QWebElement::hasClass(QWebElement* theWrappedObject, const QString& name) const
{
return ( theWrappedObject->hasClass(name));
}
bool PythonQtWrapper_QWebElement::hasFocus(QWebElement* theWrappedObject) const
{
return ( theWrappedObject->hasFocus());
}
bool PythonQtWrapper_QWebElement::isNull(QWebElement* theWrappedObject) const
{
return ( theWrappedObject->isNull());
}
QWebElement PythonQtWrapper_QWebElement::lastChild(QWebElement* theWrappedObject) const
{
return ( theWrappedObject->lastChild());
}
QString PythonQtWrapper_QWebElement::localName(QWebElement* theWrappedObject) const
{
return ( theWrappedObject->localName());
}
QString PythonQtWrapper_QWebElement::namespaceUri(QWebElement* theWrappedObject) const
{
return ( theWrappedObject->namespaceUri());
}
QWebElement PythonQtWrapper_QWebElement::nextSibling(QWebElement* theWrappedObject) const
{
return ( theWrappedObject->nextSibling());
}
bool PythonQtWrapper_QWebElement::__ne__(QWebElement* theWrappedObject, const QWebElement& o) const
{
return ( (*theWrappedObject)!= o);
}
QWebElement* PythonQtWrapper_QWebElement::operator_assign(QWebElement* theWrappedObject, const QWebElement& arg__1)
{
return &( (*theWrappedObject)= arg__1);
}
bool PythonQtWrapper_QWebElement::__eq__(QWebElement* theWrappedObject, const QWebElement& o) const
{
return ( (*theWrappedObject)== o);
}
QWebElement PythonQtWrapper_QWebElement::parent(QWebElement* theWrappedObject) const
{
return ( theWrappedObject->parent());
}
QString PythonQtWrapper_QWebElement::prefix(QWebElement* theWrappedObject) const
{
return ( theWrappedObject->prefix());
}
void PythonQtWrapper_QWebElement::prependInside(QWebElement* theWrappedObject, const QString& markup)
{
( theWrappedObject->prependInside(markup));
}
void PythonQtWrapper_QWebElement::prependInside(QWebElement* theWrappedObject, const QWebElement& element)
{
( theWrappedObject->prependInside(element));
}
void PythonQtWrapper_QWebElement::prependOutside(QWebElement* theWrappedObject, const QString& markup)
{
( theWrappedObject->prependOutside(markup));
}
void PythonQtWrapper_QWebElement::prependOutside(QWebElement* theWrappedObject, const QWebElement& element)
{
( theWrappedObject->prependOutside(element));
}
QWebElement PythonQtWrapper_QWebElement::previousSibling(QWebElement* theWrappedObject) const
{
return ( theWrappedObject->previousSibling());
}
void PythonQtWrapper_QWebElement::removeAllChildren(QWebElement* theWrappedObject)
{
( theWrappedObject->removeAllChildren());
}
void PythonQtWrapper_QWebElement::removeAttribute(QWebElement* theWrappedObject, const QString& name)
{
( theWrappedObject->removeAttribute(name));
}
void PythonQtWrapper_QWebElement::removeAttributeNS(QWebElement* theWrappedObject, const QString& namespaceUri, const QString& name)
{
( theWrappedObject->removeAttributeNS(namespaceUri, name));
}
void PythonQtWrapper_QWebElement::removeClass(QWebElement* theWrappedObject, const QString& name)
{
( theWrappedObject->removeClass(name));
}
void PythonQtWrapper_QWebElement::removeFromDocument(QWebElement* theWrappedObject)
{
( theWrappedObject->removeFromDocument());
}
void PythonQtWrapper_QWebElement::render(QWebElement* theWrappedObject, QPainter* painter)
{
( theWrappedObject->render(painter));
}
void PythonQtWrapper_QWebElement::render(QWebElement* theWrappedObject, QPainter* painter, const QRect& clipRect)
{
( theWrappedObject->render(painter, clipRect));
}
void PythonQtWrapper_QWebElement::replace(QWebElement* theWrappedObject, const QString& markup)
{
( theWrappedObject->replace(markup));
}
void PythonQtWrapper_QWebElement::replace(QWebElement* theWrappedObject, const QWebElement& element)
{
( theWrappedObject->replace(element));
}
void PythonQtWrapper_QWebElement::setAttribute(QWebElement* theWrappedObject, const QString& name, const QString& value)
{
( theWrappedObject->setAttribute(name, value));
}
void PythonQtWrapper_QWebElement::setAttributeNS(QWebElement* theWrappedObject, const QString& namespaceUri, const QString& name, const QString& value)
{
( theWrappedObject->setAttributeNS(namespaceUri, name, value));
}
void PythonQtWrapper_QWebElement::setFocus(QWebElement* theWrappedObject)
{
( theWrappedObject->setFocus());
}
void PythonQtWrapper_QWebElement::setInnerXml(QWebElement* theWrappedObject, const QString& markup)
{
( theWrappedObject->setInnerXml(markup));
}
void PythonQtWrapper_QWebElement::setOuterXml(QWebElement* theWrappedObject, const QString& markup)
{
( theWrappedObject->setOuterXml(markup));
}
void PythonQtWrapper_QWebElement::setPlainText(QWebElement* theWrappedObject, const QString& text)
{
( theWrappedObject->setPlainText(text));
}
void PythonQtWrapper_QWebElement::setStyleProperty(QWebElement* theWrappedObject, const QString& name, const QString& value)
{
( theWrappedObject->setStyleProperty(name, value));
}
QString PythonQtWrapper_QWebElement::styleProperty(QWebElement* theWrappedObject, const QString& name, QWebElement::StyleResolveStrategy strategy) const
{
return ( theWrappedObject->styleProperty(name, strategy));
}
QString PythonQtWrapper_QWebElement::tagName(QWebElement* theWrappedObject) const
{
return ( theWrappedObject->tagName());
}
QWebElement* PythonQtWrapper_QWebElement::takeFromDocument(QWebElement* theWrappedObject)
{
return &( theWrappedObject->takeFromDocument());
}
QString PythonQtWrapper_QWebElement::toInnerXml(QWebElement* theWrappedObject) const
{
return ( theWrappedObject->toInnerXml());
}
QString PythonQtWrapper_QWebElement::toOuterXml(QWebElement* theWrappedObject) const
{
return ( theWrappedObject->toOuterXml());
}
QString PythonQtWrapper_QWebElement::toPlainText(QWebElement* theWrappedObject) const
{
return ( theWrappedObject->toPlainText());
}
void PythonQtWrapper_QWebElement::toggleClass(QWebElement* theWrappedObject, const QString& name)
{
( theWrappedObject->toggleClass(name));
}
QWebFrame* PythonQtWrapper_QWebElement::webFrame(QWebElement* theWrappedObject) const
{
return ( theWrappedObject->webFrame());
}
QWebElementCollection* PythonQtWrapper_QWebElementCollection::new_QWebElementCollection()
{
return new QWebElementCollection(); }
QWebElementCollection* PythonQtWrapper_QWebElementCollection::new_QWebElementCollection(const QWebElement& contextElement, const QString& query)
{
return new QWebElementCollection(contextElement, query); }
QWebElementCollection* PythonQtWrapper_QWebElementCollection::new_QWebElementCollection(const QWebElementCollection& arg__1)
{
return new QWebElementCollection(arg__1); }
void PythonQtWrapper_QWebElementCollection::append(QWebElementCollection* theWrappedObject, const QWebElementCollection& collection)
{
( theWrappedObject->append(collection));
}
QWebElement PythonQtWrapper_QWebElementCollection::at(QWebElementCollection* theWrappedObject, int i) const
{
return ( theWrappedObject->at(i));
}
int PythonQtWrapper_QWebElementCollection::count(QWebElementCollection* theWrappedObject) const
{
return ( theWrappedObject->count());
}
QWebElement PythonQtWrapper_QWebElementCollection::first(QWebElementCollection* theWrappedObject) const
{
return ( theWrappedObject->first());
}
QWebElement PythonQtWrapper_QWebElementCollection::last(QWebElementCollection* theWrappedObject) const
{
return ( theWrappedObject->last());
}
QWebElementCollection PythonQtWrapper_QWebElementCollection::__add__(QWebElementCollection* theWrappedObject, const QWebElementCollection& other) const
{
return ( (*theWrappedObject)+ other);
}
QWebElementCollection* PythonQtWrapper_QWebElementCollection::__iadd__(QWebElementCollection* theWrappedObject, const QWebElementCollection& other)
{
return &( (*theWrappedObject)+= other);
}
QWebElementCollection* PythonQtWrapper_QWebElementCollection::operator_assign(QWebElementCollection* theWrappedObject, const QWebElementCollection& arg__1)
{
return &( (*theWrappedObject)= arg__1);
}
QWebElement PythonQtWrapper_QWebElementCollection::operator_subscript(QWebElementCollection* theWrappedObject, int i) const
{
return ( (*theWrappedObject)[i]);
}
QList<QWebElement > PythonQtWrapper_QWebElementCollection::toList(QWebElementCollection* theWrappedObject) const
{
return ( theWrappedObject->toList());
}
void PythonQtWrapper_QWebFrame::addToJavaScriptWindowObject(QWebFrame* theWrappedObject, const QString& name, QObject* object, QWebFrame::ValueOwnership ownership)
{
( theWrappedObject->addToJavaScriptWindowObject(name, object, ownership));
}
QUrl PythonQtWrapper_QWebFrame::baseUrl(QWebFrame* theWrappedObject) const
{
return ( theWrappedObject->baseUrl());
}
QList<QWebFrame* > PythonQtWrapper_QWebFrame::childFrames(QWebFrame* theWrappedObject) const
{
return ( theWrappedObject->childFrames());
}
QSize PythonQtWrapper_QWebFrame::contentsSize(QWebFrame* theWrappedObject) const
{
return ( theWrappedObject->contentsSize());
}
QWebElement PythonQtWrapper_QWebFrame::documentElement(QWebFrame* theWrappedObject) const
{
return ( theWrappedObject->documentElement());
}
QWebElementCollection PythonQtWrapper_QWebFrame::findAllElements(QWebFrame* theWrappedObject, const QString& selectorQuery) const
{
return ( theWrappedObject->findAllElements(selectorQuery));
}
QWebElement PythonQtWrapper_QWebFrame::findFirstElement(QWebFrame* theWrappedObject, const QString& selectorQuery) const
{
return ( theWrappedObject->findFirstElement(selectorQuery));
}
QString PythonQtWrapper_QWebFrame::frameName(QWebFrame* theWrappedObject) const
{
return ( theWrappedObject->frameName());
}
QRect PythonQtWrapper_QWebFrame::geometry(QWebFrame* theWrappedObject) const
{
return ( theWrappedObject->geometry());
}
bool PythonQtWrapper_QWebFrame::hasFocus(QWebFrame* theWrappedObject) const
{
return ( theWrappedObject->hasFocus());
}
QWebHitTestResult PythonQtWrapper_QWebFrame::hitTestContent(QWebFrame* theWrappedObject, const QPoint& pos) const
{
return ( theWrappedObject->hitTestContent(pos));
}
QIcon PythonQtWrapper_QWebFrame::icon(QWebFrame* theWrappedObject) const
{
return ( theWrappedObject->icon());
}
void PythonQtWrapper_QWebFrame::load(QWebFrame* theWrappedObject, const QNetworkRequest& request, QNetworkAccessManager::Operation operation, const QByteArray& body)
{
( theWrappedObject->load(request, operation, body));
}
void PythonQtWrapper_QWebFrame::load(QWebFrame* theWrappedObject, const QUrl& url)
{
( theWrappedObject->load(url));
}
QMultiMap<QString , QString > PythonQtWrapper_QWebFrame::metaData(QWebFrame* theWrappedObject) const
{
return ( theWrappedObject->metaData());
}
QWebPage* PythonQtWrapper_QWebFrame::page(QWebFrame* theWrappedObject) const
{
return ( theWrappedObject->page());
}
QWebFrame* PythonQtWrapper_QWebFrame::parentFrame(QWebFrame* theWrappedObject) const
{
return ( theWrappedObject->parentFrame());
}
QPoint PythonQtWrapper_QWebFrame::pos(QWebFrame* theWrappedObject) const
{
return ( theWrappedObject->pos());
}
void PythonQtWrapper_QWebFrame::render(QWebFrame* theWrappedObject, QPainter* arg__1, QWebFrame::RenderLayers layer, const QRegion& clip)
{
( theWrappedObject->render(arg__1, layer, clip));
}
void PythonQtWrapper_QWebFrame::render(QWebFrame* theWrappedObject, QPainter* arg__1, const QRegion& clip)
{
( theWrappedObject->render(arg__1, clip));
}
QUrl PythonQtWrapper_QWebFrame::requestedUrl(QWebFrame* theWrappedObject) const
{
return ( theWrappedObject->requestedUrl());
}
void PythonQtWrapper_QWebFrame::scroll(QWebFrame* theWrappedObject, int arg__1, int arg__2)
{
( theWrappedObject->scroll(arg__1, arg__2));
}
QRect PythonQtWrapper_QWebFrame::scrollBarGeometry(QWebFrame* theWrappedObject, Qt::Orientation orientation) const
{
return ( theWrappedObject->scrollBarGeometry(orientation));
}
int PythonQtWrapper_QWebFrame::scrollBarMaximum(QWebFrame* theWrappedObject, Qt::Orientation orientation) const
{
return ( theWrappedObject->scrollBarMaximum(orientation));
}
int PythonQtWrapper_QWebFrame::scrollBarMinimum(QWebFrame* theWrappedObject, Qt::Orientation orientation) const
{
return ( theWrappedObject->scrollBarMinimum(orientation));
}
Qt::ScrollBarPolicy PythonQtWrapper_QWebFrame::scrollBarPolicy(QWebFrame* theWrappedObject, Qt::Orientation orientation) const
{
return ( theWrappedObject->scrollBarPolicy(orientation));
}
int PythonQtWrapper_QWebFrame::scrollBarValue(QWebFrame* theWrappedObject, Qt::Orientation orientation) const
{
return ( theWrappedObject->scrollBarValue(orientation));
}
QPoint PythonQtWrapper_QWebFrame::scrollPosition(QWebFrame* theWrappedObject) const
{
return ( theWrappedObject->scrollPosition());
}
void PythonQtWrapper_QWebFrame::scrollToAnchor(QWebFrame* theWrappedObject, const QString& anchor)
{
( theWrappedObject->scrollToAnchor(anchor));
}
QWebSecurityOrigin PythonQtWrapper_QWebFrame::securityOrigin(QWebFrame* theWrappedObject) const
{
return ( theWrappedObject->securityOrigin());
}
void PythonQtWrapper_QWebFrame::setContent(QWebFrame* theWrappedObject, const QByteArray& data, const QString& mimeType, const QUrl& baseUrl)
{
( theWrappedObject->setContent(data, mimeType, baseUrl));
}
void PythonQtWrapper_QWebFrame::setFocus(QWebFrame* theWrappedObject)
{
( theWrappedObject->setFocus());
}
void PythonQtWrapper_QWebFrame::setHtml(QWebFrame* theWrappedObject, const QString& html, const QUrl& baseUrl)
{
( theWrappedObject->setHtml(html, baseUrl));
}
void PythonQtWrapper_QWebFrame::setScrollBarPolicy(QWebFrame* theWrappedObject, Qt::Orientation orientation, Qt::ScrollBarPolicy policy)
{
( theWrappedObject->setScrollBarPolicy(orientation, policy));
}
void PythonQtWrapper_QWebFrame::setScrollBarValue(QWebFrame* theWrappedObject, Qt::Orientation orientation, int value)
{
( theWrappedObject->setScrollBarValue(orientation, value));
}
void PythonQtWrapper_QWebFrame::setScrollPosition(QWebFrame* theWrappedObject, const QPoint& pos)
{
( theWrappedObject->setScrollPosition(pos));
}
void PythonQtWrapper_QWebFrame::setTextSizeMultiplier(QWebFrame* theWrappedObject, qreal factor)
{
( theWrappedObject->setTextSizeMultiplier(factor));
}
void PythonQtWrapper_QWebFrame::setUrl(QWebFrame* theWrappedObject, const QUrl& url)
{
( theWrappedObject->setUrl(url));
}
void PythonQtWrapper_QWebFrame::setZoomFactor(QWebFrame* theWrappedObject, qreal factor)
{
( theWrappedObject->setZoomFactor(factor));
}
qreal PythonQtWrapper_QWebFrame::textSizeMultiplier(QWebFrame* theWrappedObject) const
{
return ( theWrappedObject->textSizeMultiplier());
}
QString PythonQtWrapper_QWebFrame::title(QWebFrame* theWrappedObject) const
{
return ( theWrappedObject->title());
}
QString PythonQtWrapper_QWebFrame::toHtml(QWebFrame* theWrappedObject) const
{
return ( theWrappedObject->toHtml());
}
QString PythonQtWrapper_QWebFrame::toPlainText(QWebFrame* theWrappedObject) const
{
return ( theWrappedObject->toPlainText());
}
QUrl PythonQtWrapper_QWebFrame::url(QWebFrame* theWrappedObject) const
{
return ( theWrappedObject->url());
}
qreal PythonQtWrapper_QWebFrame::zoomFactor(QWebFrame* theWrappedObject) const
{
return ( theWrappedObject->zoomFactor());
}
void PythonQtWrapper_QWebHistory::back(QWebHistory* theWrappedObject)
{
( theWrappedObject->back());
}
QWebHistoryItem PythonQtWrapper_QWebHistory::backItem(QWebHistory* theWrappedObject) const
{
return ( theWrappedObject->backItem());
}
QList<QWebHistoryItem > PythonQtWrapper_QWebHistory::backItems(QWebHistory* theWrappedObject, int maxItems) const
{
return ( theWrappedObject->backItems(maxItems));
}
bool PythonQtWrapper_QWebHistory::canGoBack(QWebHistory* theWrappedObject) const
{
return ( theWrappedObject->canGoBack());
}
bool PythonQtWrapper_QWebHistory::canGoForward(QWebHistory* theWrappedObject) const
{
return ( theWrappedObject->canGoForward());
}
void PythonQtWrapper_QWebHistory::clear(QWebHistory* theWrappedObject)
{
( theWrappedObject->clear());
}
int PythonQtWrapper_QWebHistory::count(QWebHistory* theWrappedObject) const
{
return ( theWrappedObject->count());
}
QWebHistoryItem PythonQtWrapper_QWebHistory::currentItem(QWebHistory* theWrappedObject) const
{
return ( theWrappedObject->currentItem());
}
int PythonQtWrapper_QWebHistory::currentItemIndex(QWebHistory* theWrappedObject) const
{
return ( theWrappedObject->currentItemIndex());
}
void PythonQtWrapper_QWebHistory::forward(QWebHistory* theWrappedObject)
{
( theWrappedObject->forward());
}
QWebHistoryItem PythonQtWrapper_QWebHistory::forwardItem(QWebHistory* theWrappedObject) const
{
return ( theWrappedObject->forwardItem());
}
QList<QWebHistoryItem > PythonQtWrapper_QWebHistory::forwardItems(QWebHistory* theWrappedObject, int maxItems) const
{
return ( theWrappedObject->forwardItems(maxItems));
}
void PythonQtWrapper_QWebHistory::goToItem(QWebHistory* theWrappedObject, const QWebHistoryItem& item)
{
( theWrappedObject->goToItem(item));
}
QWebHistoryItem PythonQtWrapper_QWebHistory::itemAt(QWebHistory* theWrappedObject, int i) const
{
return ( theWrappedObject->itemAt(i));
}
QList<QWebHistoryItem > PythonQtWrapper_QWebHistory::items(QWebHistory* theWrappedObject) const
{
return ( theWrappedObject->items());
}
int PythonQtWrapper_QWebHistory::maximumItemCount(QWebHistory* theWrappedObject) const
{
return ( theWrappedObject->maximumItemCount());
}
void PythonQtWrapper_QWebHistory::writeTo(QWebHistory* theWrappedObject, QDataStream& stream)
{
stream << (*theWrappedObject);
}
void PythonQtWrapper_QWebHistory::readFrom(QWebHistory* theWrappedObject, QDataStream& stream)
{
stream >> (*theWrappedObject);
}
void PythonQtWrapper_QWebHistory::setMaximumItemCount(QWebHistory* theWrappedObject, int count)
{
( theWrappedObject->setMaximumItemCount(count));
}
PythonQtShell_QWebHistoryInterface::~PythonQtShell_QWebHistoryInterface() {
PythonQtPrivate* priv = PythonQt::priv();
if (priv) { priv->shellClassDeleted(this); }
}
void PythonQtShell_QWebHistoryInterface::addHistoryEntry(const QString& url0)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("addHistoryEntry");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "const QString&"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&url0};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
}
void PythonQtShell_QWebHistoryInterface::childEvent(QChildEvent* arg__1)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("childEvent");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QChildEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QWebHistoryInterface::childEvent(arg__1);
}
void PythonQtShell_QWebHistoryInterface::customEvent(QEvent* arg__1)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("customEvent");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QWebHistoryInterface::customEvent(arg__1);
}
bool PythonQtShell_QWebHistoryInterface::event(QEvent* arg__1)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("event");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"bool" , "QEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
bool returnValue;
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) {
args[0] = PythonQtConv::ConvertPythonToQt(methodInfo->parameters().at(0), result, false, NULL, &returnValue);
if (args[0]!=&returnValue) {
if (args[0]==NULL) {
PythonQt::priv()->handleVirtualOverloadReturnError("event", methodInfo, result);
} else {
returnValue = *((bool*)args[0]);
}
}
}
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return returnValue;
} else {
PyErr_Clear();
}
}
return QWebHistoryInterface::event(arg__1);
}
bool PythonQtShell_QWebHistoryInterface::eventFilter(QObject* arg__1, QEvent* arg__2)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("eventFilter");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"bool" , "QObject*" , "QEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(3, argumentList);
bool returnValue;
void* args[3] = {NULL, (void*)&arg__1, (void*)&arg__2};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) {
args[0] = PythonQtConv::ConvertPythonToQt(methodInfo->parameters().at(0), result, false, NULL, &returnValue);
if (args[0]!=&returnValue) {
if (args[0]==NULL) {
PythonQt::priv()->handleVirtualOverloadReturnError("eventFilter", methodInfo, result);
} else {
returnValue = *((bool*)args[0]);
}
}
}
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return returnValue;
} else {
PyErr_Clear();
}
}
return QWebHistoryInterface::eventFilter(arg__1, arg__2);
}
bool PythonQtShell_QWebHistoryInterface::historyContains(const QString& url0) const
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("historyContains");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"bool" , "const QString&"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
bool returnValue;
void* args[2] = {NULL, (void*)&url0};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) {
args[0] = PythonQtConv::ConvertPythonToQt(methodInfo->parameters().at(0), result, false, NULL, &returnValue);
if (args[0]!=&returnValue) {
if (args[0]==NULL) {
PythonQt::priv()->handleVirtualOverloadReturnError("historyContains", methodInfo, result);
} else {
returnValue = *((bool*)args[0]);
}
}
}
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return returnValue;
} else {
PyErr_Clear();
}
}
return bool();
}
void PythonQtShell_QWebHistoryInterface::timerEvent(QTimerEvent* arg__1)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("timerEvent");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QTimerEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QWebHistoryInterface::timerEvent(arg__1);
}
QWebHistoryInterface* PythonQtWrapper_QWebHistoryInterface::new_QWebHistoryInterface(QObject* parent)
{
return new PythonQtShell_QWebHistoryInterface(parent); }
void PythonQtWrapper_QWebHistoryInterface::addHistoryEntry(QWebHistoryInterface* theWrappedObject, const QString& url)
{
( ((PythonQtPublicPromoter_QWebHistoryInterface*)theWrappedObject)->promoted_addHistoryEntry(url));
}
QWebHistoryInterface* PythonQtWrapper_QWebHistoryInterface::static_QWebHistoryInterface_defaultInterface()
{
return (QWebHistoryInterface::defaultInterface());
}
bool PythonQtWrapper_QWebHistoryInterface::historyContains(QWebHistoryInterface* theWrappedObject, const QString& url) const
{
return ( ((PythonQtPublicPromoter_QWebHistoryInterface*)theWrappedObject)->promoted_historyContains(url));
}
void PythonQtWrapper_QWebHistoryInterface::static_QWebHistoryInterface_setDefaultInterface(QWebHistoryInterface* defaultInterface)
{
(QWebHistoryInterface::setDefaultInterface(defaultInterface));
}
QWebHistoryItem* PythonQtWrapper_QWebHistoryItem::new_QWebHistoryItem(const QWebHistoryItem& other)
{
return new QWebHistoryItem(other); }
QIcon PythonQtWrapper_QWebHistoryItem::icon(QWebHistoryItem* theWrappedObject) const
{
return ( theWrappedObject->icon());
}
bool PythonQtWrapper_QWebHistoryItem::isValid(QWebHistoryItem* theWrappedObject) const
{
return ( theWrappedObject->isValid());
}
QDateTime PythonQtWrapper_QWebHistoryItem::lastVisited(QWebHistoryItem* theWrappedObject) const
{
return ( theWrappedObject->lastVisited());
}
QUrl PythonQtWrapper_QWebHistoryItem::originalUrl(QWebHistoryItem* theWrappedObject) const
{
return ( theWrappedObject->originalUrl());
}
void PythonQtWrapper_QWebHistoryItem::setUserData(QWebHistoryItem* theWrappedObject, const QVariant& userData)
{
( theWrappedObject->setUserData(userData));
}
QString PythonQtWrapper_QWebHistoryItem::title(QWebHistoryItem* theWrappedObject) const
{
return ( theWrappedObject->title());
}
QUrl PythonQtWrapper_QWebHistoryItem::url(QWebHistoryItem* theWrappedObject) const
{
return ( theWrappedObject->url());
}
QVariant PythonQtWrapper_QWebHistoryItem::userData(QWebHistoryItem* theWrappedObject) const
{
return ( theWrappedObject->userData());
}
QWebHitTestResult* PythonQtWrapper_QWebHitTestResult::new_QWebHitTestResult()
{
return new QWebHitTestResult(); }
QWebHitTestResult* PythonQtWrapper_QWebHitTestResult::new_QWebHitTestResult(const QWebHitTestResult& other)
{
return new QWebHitTestResult(other); }
QString PythonQtWrapper_QWebHitTestResult::alternateText(QWebHitTestResult* theWrappedObject) const
{
return ( theWrappedObject->alternateText());
}
QRect PythonQtWrapper_QWebHitTestResult::boundingRect(QWebHitTestResult* theWrappedObject) const
{
return ( theWrappedObject->boundingRect());
}
QWebElement PythonQtWrapper_QWebHitTestResult::element(QWebHitTestResult* theWrappedObject) const
{
return ( theWrappedObject->element());
}
QWebElement PythonQtWrapper_QWebHitTestResult::enclosingBlockElement(QWebHitTestResult* theWrappedObject) const
{
return ( theWrappedObject->enclosingBlockElement());
}
QWebFrame* PythonQtWrapper_QWebHitTestResult::frame(QWebHitTestResult* theWrappedObject) const
{
return ( theWrappedObject->frame());
}
QUrl PythonQtWrapper_QWebHitTestResult::imageUrl(QWebHitTestResult* theWrappedObject) const
{
return ( theWrappedObject->imageUrl());
}
bool PythonQtWrapper_QWebHitTestResult::isContentEditable(QWebHitTestResult* theWrappedObject) const
{
return ( theWrappedObject->isContentEditable());
}
bool PythonQtWrapper_QWebHitTestResult::isContentSelected(QWebHitTestResult* theWrappedObject) const
{
return ( theWrappedObject->isContentSelected());
}
bool PythonQtWrapper_QWebHitTestResult::isNull(QWebHitTestResult* theWrappedObject) const
{
return ( theWrappedObject->isNull());
}
QWebElement PythonQtWrapper_QWebHitTestResult::linkElement(QWebHitTestResult* theWrappedObject) const
{
return ( theWrappedObject->linkElement());
}
QWebFrame* PythonQtWrapper_QWebHitTestResult::linkTargetFrame(QWebHitTestResult* theWrappedObject) const
{
return ( theWrappedObject->linkTargetFrame());
}
QString PythonQtWrapper_QWebHitTestResult::linkText(QWebHitTestResult* theWrappedObject) const
{
return ( theWrappedObject->linkText());
}
QUrl PythonQtWrapper_QWebHitTestResult::linkTitle(QWebHitTestResult* theWrappedObject) const
{
return ( theWrappedObject->linkTitle());
}
QUrl PythonQtWrapper_QWebHitTestResult::linkUrl(QWebHitTestResult* theWrappedObject) const
{
return ( theWrappedObject->linkUrl());
}
QPixmap PythonQtWrapper_QWebHitTestResult::pixmap(QWebHitTestResult* theWrappedObject) const
{
return ( theWrappedObject->pixmap());
}
QPoint PythonQtWrapper_QWebHitTestResult::pos(QWebHitTestResult* theWrappedObject) const
{
return ( theWrappedObject->pos());
}
QString PythonQtWrapper_QWebHitTestResult::title(QWebHitTestResult* theWrappedObject) const
{
return ( theWrappedObject->title());
}
PythonQtShell_QWebInspector::~PythonQtShell_QWebInspector() {
PythonQtPrivate* priv = PythonQt::priv();
if (priv) { priv->shellClassDeleted(this); }
}
void PythonQtShell_QWebInspector::actionEvent(QActionEvent* arg__1)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("actionEvent");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QActionEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QWebInspector::actionEvent(arg__1);
}
void PythonQtShell_QWebInspector::changeEvent(QEvent* arg__1)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("changeEvent");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QWebInspector::changeEvent(arg__1);
}
void PythonQtShell_QWebInspector::childEvent(QChildEvent* arg__1)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("childEvent");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QChildEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QWebInspector::childEvent(arg__1);
}
void PythonQtShell_QWebInspector::closeEvent(QCloseEvent* event0)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("closeEvent");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QCloseEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&event0};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QWebInspector::closeEvent(event0);
}
void PythonQtShell_QWebInspector::contextMenuEvent(QContextMenuEvent* arg__1)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("contextMenuEvent");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QContextMenuEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QWebInspector::contextMenuEvent(arg__1);
}
void PythonQtShell_QWebInspector::customEvent(QEvent* arg__1)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("customEvent");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QWebInspector::customEvent(arg__1);
}
int PythonQtShell_QWebInspector::devType() const
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("devType");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"int"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(1, argumentList);
int returnValue;
void* args[1] = {NULL};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) {
args[0] = PythonQtConv::ConvertPythonToQt(methodInfo->parameters().at(0), result, false, NULL, &returnValue);
if (args[0]!=&returnValue) {
if (args[0]==NULL) {
PythonQt::priv()->handleVirtualOverloadReturnError("devType", methodInfo, result);
} else {
returnValue = *((int*)args[0]);
}
}
}
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return returnValue;
} else {
PyErr_Clear();
}
}
return QWebInspector::devType();
}
void PythonQtShell_QWebInspector::dragEnterEvent(QDragEnterEvent* arg__1)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("dragEnterEvent");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QDragEnterEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QWebInspector::dragEnterEvent(arg__1);
}
void PythonQtShell_QWebInspector::dragLeaveEvent(QDragLeaveEvent* arg__1)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("dragLeaveEvent");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QDragLeaveEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QWebInspector::dragLeaveEvent(arg__1);
}
void PythonQtShell_QWebInspector::dragMoveEvent(QDragMoveEvent* arg__1)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("dragMoveEvent");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QDragMoveEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QWebInspector::dragMoveEvent(arg__1);
}
void PythonQtShell_QWebInspector::dropEvent(QDropEvent* arg__1)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("dropEvent");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QDropEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QWebInspector::dropEvent(arg__1);
}
void PythonQtShell_QWebInspector::enterEvent(QEvent* arg__1)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("enterEvent");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QWebInspector::enterEvent(arg__1);
}
bool PythonQtShell_QWebInspector::event(QEvent* arg__1)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("event");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"bool" , "QEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
bool returnValue;
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) {
args[0] = PythonQtConv::ConvertPythonToQt(methodInfo->parameters().at(0), result, false, NULL, &returnValue);
if (args[0]!=&returnValue) {
if (args[0]==NULL) {
PythonQt::priv()->handleVirtualOverloadReturnError("event", methodInfo, result);
} else {
returnValue = *((bool*)args[0]);
}
}
}
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return returnValue;
} else {
PyErr_Clear();
}
}
return QWebInspector::event(arg__1);
}
bool PythonQtShell_QWebInspector::eventFilter(QObject* arg__1, QEvent* arg__2)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("eventFilter");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"bool" , "QObject*" , "QEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(3, argumentList);
bool returnValue;
void* args[3] = {NULL, (void*)&arg__1, (void*)&arg__2};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) {
args[0] = PythonQtConv::ConvertPythonToQt(methodInfo->parameters().at(0), result, false, NULL, &returnValue);
if (args[0]!=&returnValue) {
if (args[0]==NULL) {
PythonQt::priv()->handleVirtualOverloadReturnError("eventFilter", methodInfo, result);
} else {
returnValue = *((bool*)args[0]);
}
}
}
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return returnValue;
} else {
PyErr_Clear();
}
}
return QWebInspector::eventFilter(arg__1, arg__2);
}
void PythonQtShell_QWebInspector::focusInEvent(QFocusEvent* arg__1)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("focusInEvent");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QFocusEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QWebInspector::focusInEvent(arg__1);
}
bool PythonQtShell_QWebInspector::focusNextPrevChild(bool next0)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("focusNextPrevChild");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"bool" , "bool"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
bool returnValue;
void* args[2] = {NULL, (void*)&next0};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) {
args[0] = PythonQtConv::ConvertPythonToQt(methodInfo->parameters().at(0), result, false, NULL, &returnValue);
if (args[0]!=&returnValue) {
if (args[0]==NULL) {
PythonQt::priv()->handleVirtualOverloadReturnError("focusNextPrevChild", methodInfo, result);
} else {
returnValue = *((bool*)args[0]);
}
}
}
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return returnValue;
} else {
PyErr_Clear();
}
}
return QWebInspector::focusNextPrevChild(next0);
}
void PythonQtShell_QWebInspector::focusOutEvent(QFocusEvent* arg__1)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("focusOutEvent");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QFocusEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QWebInspector::focusOutEvent(arg__1);
}
bool PythonQtShell_QWebInspector::hasHeightForWidth() const
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("hasHeightForWidth");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"bool"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(1, argumentList);
bool returnValue;
void* args[1] = {NULL};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) {
args[0] = PythonQtConv::ConvertPythonToQt(methodInfo->parameters().at(0), result, false, NULL, &returnValue);
if (args[0]!=&returnValue) {
if (args[0]==NULL) {
PythonQt::priv()->handleVirtualOverloadReturnError("hasHeightForWidth", methodInfo, result);
} else {
returnValue = *((bool*)args[0]);
}
}
}
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return returnValue;
} else {
PyErr_Clear();
}
}
return QWebInspector::hasHeightForWidth();
}
int PythonQtShell_QWebInspector::heightForWidth(int arg__1) const
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("heightForWidth");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"int" , "int"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
int returnValue;
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) {
args[0] = PythonQtConv::ConvertPythonToQt(methodInfo->parameters().at(0), result, false, NULL, &returnValue);
if (args[0]!=&returnValue) {
if (args[0]==NULL) {
PythonQt::priv()->handleVirtualOverloadReturnError("heightForWidth", methodInfo, result);
} else {
returnValue = *((int*)args[0]);
}
}
}
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return returnValue;
} else {
PyErr_Clear();
}
}
return QWebInspector::heightForWidth(arg__1);
}
void PythonQtShell_QWebInspector::hideEvent(QHideEvent* event0)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("hideEvent");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QHideEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&event0};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QWebInspector::hideEvent(event0);
}
void PythonQtShell_QWebInspector::initPainter(QPainter* painter0) const
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("initPainter");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QPainter*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&painter0};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QWebInspector::initPainter(painter0);
}
void PythonQtShell_QWebInspector::inputMethodEvent(QInputMethodEvent* arg__1)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("inputMethodEvent");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QInputMethodEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QWebInspector::inputMethodEvent(arg__1);
}
QVariant PythonQtShell_QWebInspector::inputMethodQuery(Qt::InputMethodQuery arg__1) const
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("inputMethodQuery");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"QVariant" , "Qt::InputMethodQuery"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
QVariant returnValue;
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) {
args[0] = PythonQtConv::ConvertPythonToQt(methodInfo->parameters().at(0), result, false, NULL, &returnValue);
if (args[0]!=&returnValue) {
if (args[0]==NULL) {
PythonQt::priv()->handleVirtualOverloadReturnError("inputMethodQuery", methodInfo, result);
} else {
returnValue = *((QVariant*)args[0]);
}
}
}
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return returnValue;
} else {
PyErr_Clear();
}
}
return QWebInspector::inputMethodQuery(arg__1);
}
void PythonQtShell_QWebInspector::keyPressEvent(QKeyEvent* arg__1)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("keyPressEvent");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QKeyEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QWebInspector::keyPressEvent(arg__1);
}
void PythonQtShell_QWebInspector::keyReleaseEvent(QKeyEvent* arg__1)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("keyReleaseEvent");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QKeyEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QWebInspector::keyReleaseEvent(arg__1);
}
void PythonQtShell_QWebInspector::leaveEvent(QEvent* arg__1)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("leaveEvent");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QWebInspector::leaveEvent(arg__1);
}
int PythonQtShell_QWebInspector::metric(QPaintDevice::PaintDeviceMetric arg__1) const
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("metric");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"int" , "QPaintDevice::PaintDeviceMetric"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
int returnValue;
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) {
args[0] = PythonQtConv::ConvertPythonToQt(methodInfo->parameters().at(0), result, false, NULL, &returnValue);
if (args[0]!=&returnValue) {
if (args[0]==NULL) {
PythonQt::priv()->handleVirtualOverloadReturnError("metric", methodInfo, result);
} else {
returnValue = *((int*)args[0]);
}
}
}
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return returnValue;
} else {
PyErr_Clear();
}
}
return QWebInspector::metric(arg__1);
}
QSize PythonQtShell_QWebInspector::minimumSizeHint() const
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("getMinimumSizeHint");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"QSize"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(1, argumentList);
QSize returnValue;
void* args[1] = {NULL};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) {
args[0] = PythonQtConv::ConvertPythonToQt(methodInfo->parameters().at(0), result, false, NULL, &returnValue);
if (args[0]!=&returnValue) {
if (args[0]==NULL) {
PythonQt::priv()->handleVirtualOverloadReturnError("getMinimumSizeHint", methodInfo, result);
} else {
returnValue = *((QSize*)args[0]);
}
}
}
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return returnValue;
} else {
PyErr_Clear();
}
}
return QWebInspector::minimumSizeHint();
}
void PythonQtShell_QWebInspector::mouseDoubleClickEvent(QMouseEvent* arg__1)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("mouseDoubleClickEvent");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QMouseEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QWebInspector::mouseDoubleClickEvent(arg__1);
}
void PythonQtShell_QWebInspector::mouseMoveEvent(QMouseEvent* arg__1)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("mouseMoveEvent");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QMouseEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QWebInspector::mouseMoveEvent(arg__1);
}
void PythonQtShell_QWebInspector::mousePressEvent(QMouseEvent* arg__1)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("mousePressEvent");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QMouseEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QWebInspector::mousePressEvent(arg__1);
}
void PythonQtShell_QWebInspector::mouseReleaseEvent(QMouseEvent* arg__1)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("mouseReleaseEvent");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QMouseEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QWebInspector::mouseReleaseEvent(arg__1);
}
void PythonQtShell_QWebInspector::moveEvent(QMoveEvent* arg__1)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("moveEvent");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QMoveEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QWebInspector::moveEvent(arg__1);
}
bool PythonQtShell_QWebInspector::nativeEvent(const QByteArray& eventType0, void* message1, long* result2)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("nativeEvent");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"bool" , "const QByteArray&" , "void*" , "long*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(4, argumentList);
bool returnValue;
void* args[4] = {NULL, (void*)&eventType0, (void*)&message1, (void*)&result2};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) {
args[0] = PythonQtConv::ConvertPythonToQt(methodInfo->parameters().at(0), result, false, NULL, &returnValue);
if (args[0]!=&returnValue) {
if (args[0]==NULL) {
PythonQt::priv()->handleVirtualOverloadReturnError("nativeEvent", methodInfo, result);
} else {
returnValue = *((bool*)args[0]);
}
}
}
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return returnValue;
} else {
PyErr_Clear();
}
}
return QWebInspector::nativeEvent(eventType0, message1, result2);
}
QPaintEngine* PythonQtShell_QWebInspector::paintEngine() const
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("paintEngine");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"QPaintEngine*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(1, argumentList);
QPaintEngine* returnValue;
void* args[1] = {NULL};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) {
args[0] = PythonQtConv::ConvertPythonToQt(methodInfo->parameters().at(0), result, false, NULL, &returnValue);
if (args[0]!=&returnValue) {
if (args[0]==NULL) {
PythonQt::priv()->handleVirtualOverloadReturnError("paintEngine", methodInfo, result);
} else {
returnValue = *((QPaintEngine**)args[0]);
}
}
}
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return returnValue;
} else {
PyErr_Clear();
}
}
return QWebInspector::paintEngine();
}
void PythonQtShell_QWebInspector::paintEvent(QPaintEvent* arg__1)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("paintEvent");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QPaintEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QWebInspector::paintEvent(arg__1);
}
QPaintDevice* PythonQtShell_QWebInspector::redirected(QPoint* offset0) const
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("redirected");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"QPaintDevice*" , "QPoint*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
QPaintDevice* returnValue;
void* args[2] = {NULL, (void*)&offset0};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) {
args[0] = PythonQtConv::ConvertPythonToQt(methodInfo->parameters().at(0), result, false, NULL, &returnValue);
if (args[0]!=&returnValue) {
if (args[0]==NULL) {
PythonQt::priv()->handleVirtualOverloadReturnError("redirected", methodInfo, result);
} else {
returnValue = *((QPaintDevice**)args[0]);
}
}
}
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return returnValue;
} else {
PyErr_Clear();
}
}
return QWebInspector::redirected(offset0);
}
void PythonQtShell_QWebInspector::resizeEvent(QResizeEvent* event0)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("resizeEvent");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QResizeEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&event0};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QWebInspector::resizeEvent(event0);
}
QPainter* PythonQtShell_QWebInspector::sharedPainter() const
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("sharedPainter");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"QPainter*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(1, argumentList);
QPainter* returnValue;
void* args[1] = {NULL};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) {
args[0] = PythonQtConv::ConvertPythonToQt(methodInfo->parameters().at(0), result, false, NULL, &returnValue);
if (args[0]!=&returnValue) {
if (args[0]==NULL) {
PythonQt::priv()->handleVirtualOverloadReturnError("sharedPainter", methodInfo, result);
} else {
returnValue = *((QPainter**)args[0]);
}
}
}
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return returnValue;
} else {
PyErr_Clear();
}
}
return QWebInspector::sharedPainter();
}
void PythonQtShell_QWebInspector::showEvent(QShowEvent* event0)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("showEvent");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QShowEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&event0};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QWebInspector::showEvent(event0);
}
void PythonQtShell_QWebInspector::tabletEvent(QTabletEvent* arg__1)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("tabletEvent");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QTabletEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QWebInspector::tabletEvent(arg__1);
}
void PythonQtShell_QWebInspector::timerEvent(QTimerEvent* arg__1)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("timerEvent");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QTimerEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QWebInspector::timerEvent(arg__1);
}
void PythonQtShell_QWebInspector::wheelEvent(QWheelEvent* arg__1)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("wheelEvent");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QWheelEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QWebInspector::wheelEvent(arg__1);
}
QWebInspector* PythonQtWrapper_QWebInspector::new_QWebInspector(QWidget* parent)
{
return new PythonQtShell_QWebInspector(parent); }
void PythonQtWrapper_QWebInspector::closeEvent(QWebInspector* theWrappedObject, QCloseEvent* event)
{
( ((PythonQtPublicPromoter_QWebInspector*)theWrappedObject)->promoted_closeEvent(event));
}
bool PythonQtWrapper_QWebInspector::event(QWebInspector* theWrappedObject, QEvent* arg__1)
{
return ( ((PythonQtPublicPromoter_QWebInspector*)theWrappedObject)->promoted_event(arg__1));
}
void PythonQtWrapper_QWebInspector::hideEvent(QWebInspector* theWrappedObject, QHideEvent* event)
{
( ((PythonQtPublicPromoter_QWebInspector*)theWrappedObject)->promoted_hideEvent(event));
}
QWebPage* PythonQtWrapper_QWebInspector::page(QWebInspector* theWrappedObject) const
{
return ( theWrappedObject->page());
}
void PythonQtWrapper_QWebInspector::resizeEvent(QWebInspector* theWrappedObject, QResizeEvent* event)
{
( ((PythonQtPublicPromoter_QWebInspector*)theWrappedObject)->promoted_resizeEvent(event));
}
void PythonQtWrapper_QWebInspector::setPage(QWebInspector* theWrappedObject, QWebPage* page)
{
( theWrappedObject->setPage(page));
}
void PythonQtWrapper_QWebInspector::showEvent(QWebInspector* theWrappedObject, QShowEvent* event)
{
( ((PythonQtPublicPromoter_QWebInspector*)theWrappedObject)->promoted_showEvent(event));
}
QSize PythonQtWrapper_QWebInspector::sizeHint(QWebInspector* theWrappedObject) const
{
return ( theWrappedObject->sizeHint());
}
PythonQtShell_QWebPage::~PythonQtShell_QWebPage() {
PythonQtPrivate* priv = PythonQt::priv();
if (priv) { priv->shellClassDeleted(this); }
}
bool PythonQtShell_QWebPage::acceptNavigationRequest(QWebFrame* frame0, const QNetworkRequest& request1, QWebPage::NavigationType type2)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("acceptNavigationRequest");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"bool" , "QWebFrame*" , "const QNetworkRequest&" , "QWebPage::NavigationType"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(4, argumentList);
bool returnValue;
void* args[4] = {NULL, (void*)&frame0, (void*)&request1, (void*)&type2};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) {
args[0] = PythonQtConv::ConvertPythonToQt(methodInfo->parameters().at(0), result, false, NULL, &returnValue);
if (args[0]!=&returnValue) {
if (args[0]==NULL) {
PythonQt::priv()->handleVirtualOverloadReturnError("acceptNavigationRequest", methodInfo, result);
} else {
returnValue = *((bool*)args[0]);
}
}
}
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return returnValue;
} else {
PyErr_Clear();
}
}
return QWebPage::acceptNavigationRequest(frame0, request1, type2);
}
void PythonQtShell_QWebPage::childEvent(QChildEvent* arg__1)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("childEvent");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QChildEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QWebPage::childEvent(arg__1);
}
QString PythonQtShell_QWebPage::chooseFile(QWebFrame* originatingFrame0, const QString& oldFile1)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("chooseFile");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"QString" , "QWebFrame*" , "const QString&"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(3, argumentList);
QString returnValue;
void* args[3] = {NULL, (void*)&originatingFrame0, (void*)&oldFile1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) {
args[0] = PythonQtConv::ConvertPythonToQt(methodInfo->parameters().at(0), result, false, NULL, &returnValue);
if (args[0]!=&returnValue) {
if (args[0]==NULL) {
PythonQt::priv()->handleVirtualOverloadReturnError("chooseFile", methodInfo, result);
} else {
returnValue = *((QString*)args[0]);
}
}
}
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return returnValue;
} else {
PyErr_Clear();
}
}
return QWebPage::chooseFile(originatingFrame0, oldFile1);
}
QObject* PythonQtShell_QWebPage::createPlugin(const QString& classid0, const QUrl& url1, const QStringList& paramNames2, const QStringList& paramValues3)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("createPlugin");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"QObject*" , "const QString&" , "const QUrl&" , "const QStringList&" , "const QStringList&"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(5, argumentList);
QObject* returnValue;
void* args[5] = {NULL, (void*)&classid0, (void*)&url1, (void*)¶mNames2, (void*)¶mValues3};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) {
args[0] = PythonQtConv::ConvertPythonToQt(methodInfo->parameters().at(0), result, false, NULL, &returnValue);
if (args[0]!=&returnValue) {
if (args[0]==NULL) {
PythonQt::priv()->handleVirtualOverloadReturnError("createPlugin", methodInfo, result);
} else {
returnValue = *((QObject**)args[0]);
}
}
}
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return returnValue;
} else {
PyErr_Clear();
}
}
return QWebPage::createPlugin(classid0, url1, paramNames2, paramValues3);
}
QWebPage* PythonQtShell_QWebPage::createWindow(QWebPage::WebWindowType type0)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("createWindow");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"QWebPage*" , "QWebPage::WebWindowType"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
QWebPage* returnValue;
void* args[2] = {NULL, (void*)&type0};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) {
args[0] = PythonQtConv::ConvertPythonToQt(methodInfo->parameters().at(0), result, false, NULL, &returnValue);
if (args[0]!=&returnValue) {
if (args[0]==NULL) {
PythonQt::priv()->handleVirtualOverloadReturnError("createWindow", methodInfo, result);
} else {
returnValue = *((QWebPage**)args[0]);
}
}
}
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return returnValue;
} else {
PyErr_Clear();
}
}
return QWebPage::createWindow(type0);
}
void PythonQtShell_QWebPage::customEvent(QEvent* arg__1)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("customEvent");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QWebPage::customEvent(arg__1);
}
bool PythonQtShell_QWebPage::event(QEvent* arg__1)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("event");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"bool" , "QEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
bool returnValue;
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) {
args[0] = PythonQtConv::ConvertPythonToQt(methodInfo->parameters().at(0), result, false, NULL, &returnValue);
if (args[0]!=&returnValue) {
if (args[0]==NULL) {
PythonQt::priv()->handleVirtualOverloadReturnError("event", methodInfo, result);
} else {
returnValue = *((bool*)args[0]);
}
}
}
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return returnValue;
} else {
PyErr_Clear();
}
}
return QWebPage::event(arg__1);
}
bool PythonQtShell_QWebPage::eventFilter(QObject* arg__1, QEvent* arg__2)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("eventFilter");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"bool" , "QObject*" , "QEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(3, argumentList);
bool returnValue;
void* args[3] = {NULL, (void*)&arg__1, (void*)&arg__2};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) {
args[0] = PythonQtConv::ConvertPythonToQt(methodInfo->parameters().at(0), result, false, NULL, &returnValue);
if (args[0]!=&returnValue) {
if (args[0]==NULL) {
PythonQt::priv()->handleVirtualOverloadReturnError("eventFilter", methodInfo, result);
} else {
returnValue = *((bool*)args[0]);
}
}
}
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return returnValue;
} else {
PyErr_Clear();
}
}
return QWebPage::eventFilter(arg__1, arg__2);
}
bool PythonQtShell_QWebPage::extension(QWebPage::Extension extension0, const QWebPage::ExtensionOption* option1, QWebPage::ExtensionReturn* output2)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("extension");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"bool" , "QWebPage::Extension" , "const QWebPage::ExtensionOption*" , "QWebPage::ExtensionReturn*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(4, argumentList);
bool returnValue;
void* args[4] = {NULL, (void*)&extension0, (void*)&option1, (void*)&output2};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) {
args[0] = PythonQtConv::ConvertPythonToQt(methodInfo->parameters().at(0), result, false, NULL, &returnValue);
if (args[0]!=&returnValue) {
if (args[0]==NULL) {
PythonQt::priv()->handleVirtualOverloadReturnError("extension", methodInfo, result);
} else {
returnValue = *((bool*)args[0]);
}
}
}
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return returnValue;
} else {
PyErr_Clear();
}
}
return QWebPage::extension(extension0, option1, output2);
}
void PythonQtShell_QWebPage::javaScriptAlert(QWebFrame* originatingFrame0, const QString& msg1)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("javaScriptAlert");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QWebFrame*" , "const QString&"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(3, argumentList);
void* args[3] = {NULL, (void*)&originatingFrame0, (void*)&msg1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QWebPage::javaScriptAlert(originatingFrame0, msg1);
}
bool PythonQtShell_QWebPage::javaScriptConfirm(QWebFrame* originatingFrame0, const QString& msg1)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("javaScriptConfirm");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"bool" , "QWebFrame*" , "const QString&"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(3, argumentList);
bool returnValue;
void* args[3] = {NULL, (void*)&originatingFrame0, (void*)&msg1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) {
args[0] = PythonQtConv::ConvertPythonToQt(methodInfo->parameters().at(0), result, false, NULL, &returnValue);
if (args[0]!=&returnValue) {
if (args[0]==NULL) {
PythonQt::priv()->handleVirtualOverloadReturnError("javaScriptConfirm", methodInfo, result);
} else {
returnValue = *((bool*)args[0]);
}
}
}
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return returnValue;
} else {
PyErr_Clear();
}
}
return QWebPage::javaScriptConfirm(originatingFrame0, msg1);
}
void PythonQtShell_QWebPage::javaScriptConsoleMessage(const QString& message0, int lineNumber1, const QString& sourceID2)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("javaScriptConsoleMessage");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "const QString&" , "int" , "const QString&"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(4, argumentList);
void* args[4] = {NULL, (void*)&message0, (void*)&lineNumber1, (void*)&sourceID2};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QWebPage::javaScriptConsoleMessage(message0, lineNumber1, sourceID2);
}
bool PythonQtShell_QWebPage::javaScriptPrompt(QWebFrame* originatingFrame0, const QString& msg1, const QString& defaultValue2, QString* result3)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("javaScriptPrompt");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"bool" , "QWebFrame*" , "const QString&" , "const QString&" , "QString*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(5, argumentList);
bool returnValue;
void* args[5] = {NULL, (void*)&originatingFrame0, (void*)&msg1, (void*)&defaultValue2, (void*)&result3};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) {
args[0] = PythonQtConv::ConvertPythonToQt(methodInfo->parameters().at(0), result, false, NULL, &returnValue);
if (args[0]!=&returnValue) {
if (args[0]==NULL) {
PythonQt::priv()->handleVirtualOverloadReturnError("javaScriptPrompt", methodInfo, result);
} else {
returnValue = *((bool*)args[0]);
}
}
}
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return returnValue;
} else {
PyErr_Clear();
}
}
return QWebPage::javaScriptPrompt(originatingFrame0, msg1, defaultValue2, result3);
}
bool PythonQtShell_QWebPage::shouldInterruptJavaScript()
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("shouldInterruptJavaScript");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"bool"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(1, argumentList);
bool returnValue;
void* args[1] = {NULL};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) {
args[0] = PythonQtConv::ConvertPythonToQt(methodInfo->parameters().at(0), result, false, NULL, &returnValue);
if (args[0]!=&returnValue) {
if (args[0]==NULL) {
PythonQt::priv()->handleVirtualOverloadReturnError("shouldInterruptJavaScript", methodInfo, result);
} else {
returnValue = *((bool*)args[0]);
}
}
}
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return returnValue;
} else {
PyErr_Clear();
}
}
return QWebPage::shouldInterruptJavaScript();
}
bool PythonQtShell_QWebPage::supportsExtension(QWebPage::Extension extension0) const
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("supportsExtension");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"bool" , "QWebPage::Extension"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
bool returnValue;
void* args[2] = {NULL, (void*)&extension0};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) {
args[0] = PythonQtConv::ConvertPythonToQt(methodInfo->parameters().at(0), result, false, NULL, &returnValue);
if (args[0]!=&returnValue) {
if (args[0]==NULL) {
PythonQt::priv()->handleVirtualOverloadReturnError("supportsExtension", methodInfo, result);
} else {
returnValue = *((bool*)args[0]);
}
}
}
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return returnValue;
} else {
PyErr_Clear();
}
}
return QWebPage::supportsExtension(extension0);
}
void PythonQtShell_QWebPage::timerEvent(QTimerEvent* arg__1)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("timerEvent");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QTimerEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QWebPage::timerEvent(arg__1);
}
void PythonQtShell_QWebPage::triggerAction(QWebPage::WebAction action0, bool checked1)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("triggerAction");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QWebPage::WebAction" , "bool"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(3, argumentList);
void* args[3] = {NULL, (void*)&action0, (void*)&checked1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QWebPage::triggerAction(action0, checked1);
}
QString PythonQtShell_QWebPage::userAgentForUrl(const QUrl& url0) const
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("userAgentForUrl");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"QString" , "const QUrl&"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
QString returnValue;
void* args[2] = {NULL, (void*)&url0};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) {
args[0] = PythonQtConv::ConvertPythonToQt(methodInfo->parameters().at(0), result, false, NULL, &returnValue);
if (args[0]!=&returnValue) {
if (args[0]==NULL) {
PythonQt::priv()->handleVirtualOverloadReturnError("userAgentForUrl", methodInfo, result);
} else {
returnValue = *((QString*)args[0]);
}
}
}
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return returnValue;
} else {
PyErr_Clear();
}
}
return QWebPage::userAgentForUrl(url0);
}
QWebPage* PythonQtWrapper_QWebPage::new_QWebPage(QObject* parent)
{
return new PythonQtShell_QWebPage(parent); }
bool PythonQtWrapper_QWebPage::acceptNavigationRequest(QWebPage* theWrappedObject, QWebFrame* frame, const QNetworkRequest& request, QWebPage::NavigationType type)
{
return ( ((PythonQtPublicPromoter_QWebPage*)theWrappedObject)->promoted_acceptNavigationRequest(frame, request, type));
}
QAction* PythonQtWrapper_QWebPage::action(QWebPage* theWrappedObject, QWebPage::WebAction action) const
{
return ( theWrappedObject->action(action));
}
quint64 PythonQtWrapper_QWebPage::bytesReceived(QWebPage* theWrappedObject) const
{
return ( theWrappedObject->bytesReceived());
}
QString PythonQtWrapper_QWebPage::chooseFile(QWebPage* theWrappedObject, QWebFrame* originatingFrame, const QString& oldFile)
{
return ( ((PythonQtPublicPromoter_QWebPage*)theWrappedObject)->promoted_chooseFile(originatingFrame, oldFile));
}
QObject* PythonQtWrapper_QWebPage::createPlugin(QWebPage* theWrappedObject, const QString& classid, const QUrl& url, const QStringList& paramNames, const QStringList& paramValues)
{
return ( ((PythonQtPublicPromoter_QWebPage*)theWrappedObject)->promoted_createPlugin(classid, url, paramNames, paramValues));
}
QMenu* PythonQtWrapper_QWebPage::createStandardContextMenu(QWebPage* theWrappedObject)
{
return ( theWrappedObject->createStandardContextMenu());
}
QWebPage* PythonQtWrapper_QWebPage::createWindow(QWebPage* theWrappedObject, QWebPage::WebWindowType type)
{
return ( ((PythonQtPublicPromoter_QWebPage*)theWrappedObject)->promoted_createWindow(type));
}
QWebFrame* PythonQtWrapper_QWebPage::currentFrame(QWebPage* theWrappedObject) const
{
return ( theWrappedObject->currentFrame());
}
bool PythonQtWrapper_QWebPage::event(QWebPage* theWrappedObject, QEvent* arg__1)
{
return ( ((PythonQtPublicPromoter_QWebPage*)theWrappedObject)->promoted_event(arg__1));
}
bool PythonQtWrapper_QWebPage::extension(QWebPage* theWrappedObject, QWebPage::Extension extension, const QWebPage::ExtensionOption* option, QWebPage::ExtensionReturn* output)
{
return ( ((PythonQtPublicPromoter_QWebPage*)theWrappedObject)->promoted_extension(extension, option, output));
}
bool PythonQtWrapper_QWebPage::findText(QWebPage* theWrappedObject, const QString& subString, QWebPage::FindFlags options)
{
return ( theWrappedObject->findText(subString, options));
}
bool PythonQtWrapper_QWebPage::focusNextPrevChild(QWebPage* theWrappedObject, bool next)
{
return ( theWrappedObject->focusNextPrevChild(next));
}
bool PythonQtWrapper_QWebPage::forwardUnsupportedContent(QWebPage* theWrappedObject) const
{
return ( theWrappedObject->forwardUnsupportedContent());
}
QWebFrame* PythonQtWrapper_QWebPage::frameAt(QWebPage* theWrappedObject, const QPoint& pos) const
{
return ( theWrappedObject->frameAt(pos));
}
bool PythonQtWrapper_QWebPage::hasSelection(QWebPage* theWrappedObject) const
{
return ( theWrappedObject->hasSelection());
}
QWebHistory* PythonQtWrapper_QWebPage::history(QWebPage* theWrappedObject) const
{
return ( theWrappedObject->history());
}
QVariant PythonQtWrapper_QWebPage::inputMethodQuery(QWebPage* theWrappedObject, Qt::InputMethodQuery property) const
{
return ( theWrappedObject->inputMethodQuery(property));
}
bool PythonQtWrapper_QWebPage::isContentEditable(QWebPage* theWrappedObject) const
{
return ( theWrappedObject->isContentEditable());
}
bool PythonQtWrapper_QWebPage::isModified(QWebPage* theWrappedObject) const
{
return ( theWrappedObject->isModified());
}
void PythonQtWrapper_QWebPage::javaScriptAlert(QWebPage* theWrappedObject, QWebFrame* originatingFrame, const QString& msg)
{
( ((PythonQtPublicPromoter_QWebPage*)theWrappedObject)->promoted_javaScriptAlert(originatingFrame, msg));
}
bool PythonQtWrapper_QWebPage::javaScriptConfirm(QWebPage* theWrappedObject, QWebFrame* originatingFrame, const QString& msg)
{
return ( ((PythonQtPublicPromoter_QWebPage*)theWrappedObject)->promoted_javaScriptConfirm(originatingFrame, msg));
}
void PythonQtWrapper_QWebPage::javaScriptConsoleMessage(QWebPage* theWrappedObject, const QString& message, int lineNumber, const QString& sourceID)
{
( ((PythonQtPublicPromoter_QWebPage*)theWrappedObject)->promoted_javaScriptConsoleMessage(message, lineNumber, sourceID));
}
bool PythonQtWrapper_QWebPage::javaScriptPrompt(QWebPage* theWrappedObject, QWebFrame* originatingFrame, const QString& msg, const QString& defaultValue, QString* result)
{
return ( ((PythonQtPublicPromoter_QWebPage*)theWrappedObject)->promoted_javaScriptPrompt(originatingFrame, msg, defaultValue, result));
}
QWebPage::LinkDelegationPolicy PythonQtWrapper_QWebPage::linkDelegationPolicy(QWebPage* theWrappedObject) const
{
return ( theWrappedObject->linkDelegationPolicy());
}
QWebFrame* PythonQtWrapper_QWebPage::mainFrame(QWebPage* theWrappedObject) const
{
return ( theWrappedObject->mainFrame());
}
QNetworkAccessManager* PythonQtWrapper_QWebPage::networkAccessManager(QWebPage* theWrappedObject) const
{
return ( theWrappedObject->networkAccessManager());
}
QPalette PythonQtWrapper_QWebPage::palette(QWebPage* theWrappedObject) const
{
return ( theWrappedObject->palette());
}
QWebPluginFactory* PythonQtWrapper_QWebPage::pluginFactory(QWebPage* theWrappedObject) const
{
return ( theWrappedObject->pluginFactory());
}
QSize PythonQtWrapper_QWebPage::preferredContentsSize(QWebPage* theWrappedObject) const
{
return ( theWrappedObject->preferredContentsSize());
}
QString PythonQtWrapper_QWebPage::selectedHtml(QWebPage* theWrappedObject) const
{
return ( theWrappedObject->selectedHtml());
}
QString PythonQtWrapper_QWebPage::selectedText(QWebPage* theWrappedObject) const
{
return ( theWrappedObject->selectedText());
}
void PythonQtWrapper_QWebPage::setActualVisibleContentRect(QWebPage* theWrappedObject, const QRect& rect) const
{
( theWrappedObject->setActualVisibleContentRect(rect));
}
void PythonQtWrapper_QWebPage::setContentEditable(QWebPage* theWrappedObject, bool editable)
{
( theWrappedObject->setContentEditable(editable));
}
void PythonQtWrapper_QWebPage::setFeaturePermission(QWebPage* theWrappedObject, QWebFrame* frame, QWebPage::Feature feature, QWebPage::PermissionPolicy policy)
{
( theWrappedObject->setFeaturePermission(frame, feature, policy));
}
void PythonQtWrapper_QWebPage::setForwardUnsupportedContent(QWebPage* theWrappedObject, bool forward)
{
( theWrappedObject->setForwardUnsupportedContent(forward));
}
void PythonQtWrapper_QWebPage::setLinkDelegationPolicy(QWebPage* theWrappedObject, QWebPage::LinkDelegationPolicy policy)
{
( theWrappedObject->setLinkDelegationPolicy(policy));
}
void PythonQtWrapper_QWebPage::setNetworkAccessManager(QWebPage* theWrappedObject, QNetworkAccessManager* manager)
{
( theWrappedObject->setNetworkAccessManager(manager));
}
void PythonQtWrapper_QWebPage::setPalette(QWebPage* theWrappedObject, const QPalette& palette)
{
( theWrappedObject->setPalette(palette));
}
void PythonQtWrapper_QWebPage::setPluginFactory(QWebPage* theWrappedObject, QWebPluginFactory* factory)
{
( theWrappedObject->setPluginFactory(factory));
}
void PythonQtWrapper_QWebPage::setPreferredContentsSize(QWebPage* theWrappedObject, const QSize& size) const
{
( theWrappedObject->setPreferredContentsSize(size));
}
void PythonQtWrapper_QWebPage::setView(QWebPage* theWrappedObject, QWidget* view)
{
( theWrappedObject->setView(view));
}
void PythonQtWrapper_QWebPage::setViewportSize(QWebPage* theWrappedObject, const QSize& size) const
{
( theWrappedObject->setViewportSize(size));
}
QWebSettings* PythonQtWrapper_QWebPage::settings(QWebPage* theWrappedObject) const
{
return ( theWrappedObject->settings());
}
bool PythonQtWrapper_QWebPage::shouldInterruptJavaScript(QWebPage* theWrappedObject)
{
return ( ((PythonQtPublicPromoter_QWebPage*)theWrappedObject)->promoted_shouldInterruptJavaScript());
}
QStringList PythonQtWrapper_QWebPage::supportedContentTypes(QWebPage* theWrappedObject) const
{
return ( theWrappedObject->supportedContentTypes());
}
bool PythonQtWrapper_QWebPage::supportsContentType(QWebPage* theWrappedObject, const QString& mimeType) const
{
return ( theWrappedObject->supportsContentType(mimeType));
}
bool PythonQtWrapper_QWebPage::supportsExtension(QWebPage* theWrappedObject, QWebPage::Extension extension) const
{
return ( ((PythonQtPublicPromoter_QWebPage*)theWrappedObject)->promoted_supportsExtension(extension));
}
bool PythonQtWrapper_QWebPage::swallowContextMenuEvent(QWebPage* theWrappedObject, QContextMenuEvent* event)
{
return ( theWrappedObject->swallowContextMenuEvent(event));
}
quint64 PythonQtWrapper_QWebPage::totalBytes(QWebPage* theWrappedObject) const
{
return ( theWrappedObject->totalBytes());
}
void PythonQtWrapper_QWebPage::triggerAction(QWebPage* theWrappedObject, QWebPage::WebAction action, bool checked)
{
( ((PythonQtPublicPromoter_QWebPage*)theWrappedObject)->promoted_triggerAction(action, checked));
}
QUndoStack* PythonQtWrapper_QWebPage::undoStack(QWebPage* theWrappedObject) const
{
return ( theWrappedObject->undoStack());
}
void PythonQtWrapper_QWebPage::updatePositionDependentActions(QWebPage* theWrappedObject, const QPoint& pos)
{
( theWrappedObject->updatePositionDependentActions(pos));
}
QString PythonQtWrapper_QWebPage::userAgentForUrl(QWebPage* theWrappedObject, const QUrl& url) const
{
return ( ((PythonQtPublicPromoter_QWebPage*)theWrappedObject)->promoted_userAgentForUrl(url));
}
QWidget* PythonQtWrapper_QWebPage::view(QWebPage* theWrappedObject) const
{
return ( theWrappedObject->view());
}
QSize PythonQtWrapper_QWebPage::viewportSize(QWebPage* theWrappedObject) const
{
return ( theWrappedObject->viewportSize());
}
PythonQtShell_QWebPage__ChooseMultipleFilesExtensionOption::~PythonQtShell_QWebPage__ChooseMultipleFilesExtensionOption() {
PythonQtPrivate* priv = PythonQt::priv();
if (priv) { priv->shellClassDeleted(this); }
}
QWebPage::ChooseMultipleFilesExtensionOption* PythonQtWrapper_QWebPage__ChooseMultipleFilesExtensionOption::new_QWebPage__ChooseMultipleFilesExtensionOption()
{
return new PythonQtShell_QWebPage__ChooseMultipleFilesExtensionOption(); }
PythonQtShell_QWebPage__ChooseMultipleFilesExtensionReturn::~PythonQtShell_QWebPage__ChooseMultipleFilesExtensionReturn() {
PythonQtPrivate* priv = PythonQt::priv();
if (priv) { priv->shellClassDeleted(this); }
}
QWebPage::ChooseMultipleFilesExtensionReturn* PythonQtWrapper_QWebPage__ChooseMultipleFilesExtensionReturn::new_QWebPage__ChooseMultipleFilesExtensionReturn()
{
return new PythonQtShell_QWebPage__ChooseMultipleFilesExtensionReturn(); }
PythonQtShell_QWebPage__ErrorPageExtensionOption::~PythonQtShell_QWebPage__ErrorPageExtensionOption() {
PythonQtPrivate* priv = PythonQt::priv();
if (priv) { priv->shellClassDeleted(this); }
}
QWebPage::ErrorPageExtensionOption* PythonQtWrapper_QWebPage__ErrorPageExtensionOption::new_QWebPage__ErrorPageExtensionOption()
{
return new PythonQtShell_QWebPage__ErrorPageExtensionOption(); }
PythonQtShell_QWebPage__ErrorPageExtensionReturn::~PythonQtShell_QWebPage__ErrorPageExtensionReturn() {
PythonQtPrivate* priv = PythonQt::priv();
if (priv) { priv->shellClassDeleted(this); }
}
QWebPage::ErrorPageExtensionReturn* PythonQtWrapper_QWebPage__ErrorPageExtensionReturn::new_QWebPage__ErrorPageExtensionReturn()
{
return new PythonQtShell_QWebPage__ErrorPageExtensionReturn(); }
PythonQtShell_QWebPage__ExtensionOption::~PythonQtShell_QWebPage__ExtensionOption() {
PythonQtPrivate* priv = PythonQt::priv();
if (priv) { priv->shellClassDeleted(this); }
}
QWebPage::ExtensionOption* PythonQtWrapper_QWebPage__ExtensionOption::new_QWebPage__ExtensionOption()
{
return new PythonQtShell_QWebPage__ExtensionOption(); }
PythonQtShell_QWebPage__ExtensionReturn::~PythonQtShell_QWebPage__ExtensionReturn() {
PythonQtPrivate* priv = PythonQt::priv();
if (priv) { priv->shellClassDeleted(this); }
}
QWebPage::ExtensionReturn* PythonQtWrapper_QWebPage__ExtensionReturn::new_QWebPage__ExtensionReturn()
{
return new PythonQtShell_QWebPage__ExtensionReturn(); }
PythonQtShell_QWebPluginFactory::~PythonQtShell_QWebPluginFactory() {
PythonQtPrivate* priv = PythonQt::priv();
if (priv) { priv->shellClassDeleted(this); }
}
void PythonQtShell_QWebPluginFactory::childEvent(QChildEvent* arg__1)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("childEvent");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QChildEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QWebPluginFactory::childEvent(arg__1);
}
QObject* PythonQtShell_QWebPluginFactory::create(const QString& mimeType0, const QUrl& arg__2, const QStringList& argumentNames2, const QStringList& argumentValues3) const
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("create");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"QObject*" , "const QString&" , "const QUrl&" , "const QStringList&" , "const QStringList&"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(5, argumentList);
QObject* returnValue;
void* args[5] = {NULL, (void*)&mimeType0, (void*)&arg__2, (void*)&argumentNames2, (void*)&argumentValues3};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) {
args[0] = PythonQtConv::ConvertPythonToQt(methodInfo->parameters().at(0), result, false, NULL, &returnValue);
if (args[0]!=&returnValue) {
if (args[0]==NULL) {
PythonQt::priv()->handleVirtualOverloadReturnError("create", methodInfo, result);
} else {
returnValue = *((QObject**)args[0]);
}
}
}
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return returnValue;
} else {
PyErr_Clear();
}
}
return 0;
}
void PythonQtShell_QWebPluginFactory::customEvent(QEvent* arg__1)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("customEvent");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QWebPluginFactory::customEvent(arg__1);
}
bool PythonQtShell_QWebPluginFactory::event(QEvent* arg__1)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("event");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"bool" , "QEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
bool returnValue;
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) {
args[0] = PythonQtConv::ConvertPythonToQt(methodInfo->parameters().at(0), result, false, NULL, &returnValue);
if (args[0]!=&returnValue) {
if (args[0]==NULL) {
PythonQt::priv()->handleVirtualOverloadReturnError("event", methodInfo, result);
} else {
returnValue = *((bool*)args[0]);
}
}
}
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return returnValue;
} else {
PyErr_Clear();
}
}
return QWebPluginFactory::event(arg__1);
}
bool PythonQtShell_QWebPluginFactory::eventFilter(QObject* arg__1, QEvent* arg__2)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("eventFilter");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"bool" , "QObject*" , "QEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(3, argumentList);
bool returnValue;
void* args[3] = {NULL, (void*)&arg__1, (void*)&arg__2};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) {
args[0] = PythonQtConv::ConvertPythonToQt(methodInfo->parameters().at(0), result, false, NULL, &returnValue);
if (args[0]!=&returnValue) {
if (args[0]==NULL) {
PythonQt::priv()->handleVirtualOverloadReturnError("eventFilter", methodInfo, result);
} else {
returnValue = *((bool*)args[0]);
}
}
}
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return returnValue;
} else {
PyErr_Clear();
}
}
return QWebPluginFactory::eventFilter(arg__1, arg__2);
}
bool PythonQtShell_QWebPluginFactory::extension(QWebPluginFactory::Extension extension0, const QWebPluginFactory::ExtensionOption* option1, QWebPluginFactory::ExtensionReturn* output2)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("extension");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"bool" , "QWebPluginFactory::Extension" , "const QWebPluginFactory::ExtensionOption*" , "QWebPluginFactory::ExtensionReturn*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(4, argumentList);
bool returnValue;
void* args[4] = {NULL, (void*)&extension0, (void*)&option1, (void*)&output2};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) {
args[0] = PythonQtConv::ConvertPythonToQt(methodInfo->parameters().at(0), result, false, NULL, &returnValue);
if (args[0]!=&returnValue) {
if (args[0]==NULL) {
PythonQt::priv()->handleVirtualOverloadReturnError("extension", methodInfo, result);
} else {
returnValue = *((bool*)args[0]);
}
}
}
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return returnValue;
} else {
PyErr_Clear();
}
}
return QWebPluginFactory::extension(extension0, option1, output2);
}
QList<QWebPluginFactory::Plugin > PythonQtShell_QWebPluginFactory::plugins() const
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("plugins");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"QList<QWebPluginFactory::Plugin >"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(1, argumentList);
QList<QWebPluginFactory::Plugin > returnValue;
void* args[1] = {NULL};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) {
args[0] = PythonQtConv::ConvertPythonToQt(methodInfo->parameters().at(0), result, false, NULL, &returnValue);
if (args[0]!=&returnValue) {
if (args[0]==NULL) {
PythonQt::priv()->handleVirtualOverloadReturnError("plugins", methodInfo, result);
} else {
returnValue = *((QList<QWebPluginFactory::Plugin >*)args[0]);
}
}
}
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return returnValue;
} else {
PyErr_Clear();
}
}
return QList<QWebPluginFactory::Plugin >();
}
void PythonQtShell_QWebPluginFactory::refreshPlugins()
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("refreshPlugins");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={""};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(1, argumentList);
void* args[1] = {NULL};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QWebPluginFactory::refreshPlugins();
}
bool PythonQtShell_QWebPluginFactory::supportsExtension(QWebPluginFactory::Extension extension0) const
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("supportsExtension");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"bool" , "QWebPluginFactory::Extension"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
bool returnValue;
void* args[2] = {NULL, (void*)&extension0};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) {
args[0] = PythonQtConv::ConvertPythonToQt(methodInfo->parameters().at(0), result, false, NULL, &returnValue);
if (args[0]!=&returnValue) {
if (args[0]==NULL) {
PythonQt::priv()->handleVirtualOverloadReturnError("supportsExtension", methodInfo, result);
} else {
returnValue = *((bool*)args[0]);
}
}
}
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return returnValue;
} else {
PyErr_Clear();
}
}
return QWebPluginFactory::supportsExtension(extension0);
}
void PythonQtShell_QWebPluginFactory::timerEvent(QTimerEvent* arg__1)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("timerEvent");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QTimerEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QWebPluginFactory::timerEvent(arg__1);
}
QWebPluginFactory* PythonQtWrapper_QWebPluginFactory::new_QWebPluginFactory(QObject* parent)
{
return new PythonQtShell_QWebPluginFactory(parent); }
QObject* PythonQtWrapper_QWebPluginFactory::create(QWebPluginFactory* theWrappedObject, const QString& mimeType, const QUrl& arg__2, const QStringList& argumentNames, const QStringList& argumentValues) const
{
return ( ((PythonQtPublicPromoter_QWebPluginFactory*)theWrappedObject)->promoted_create(mimeType, arg__2, argumentNames, argumentValues));
}
bool PythonQtWrapper_QWebPluginFactory::extension(QWebPluginFactory* theWrappedObject, QWebPluginFactory::Extension extension, const QWebPluginFactory::ExtensionOption* option, QWebPluginFactory::ExtensionReturn* output)
{
return ( ((PythonQtPublicPromoter_QWebPluginFactory*)theWrappedObject)->promoted_extension(extension, option, output));
}
QList<QWebPluginFactory::Plugin > PythonQtWrapper_QWebPluginFactory::plugins(QWebPluginFactory* theWrappedObject) const
{
return ( ((PythonQtPublicPromoter_QWebPluginFactory*)theWrappedObject)->promoted_plugins());
}
void PythonQtWrapper_QWebPluginFactory::refreshPlugins(QWebPluginFactory* theWrappedObject)
{
( ((PythonQtPublicPromoter_QWebPluginFactory*)theWrappedObject)->promoted_refreshPlugins());
}
bool PythonQtWrapper_QWebPluginFactory::supportsExtension(QWebPluginFactory* theWrappedObject, QWebPluginFactory::Extension extension) const
{
return ( ((PythonQtPublicPromoter_QWebPluginFactory*)theWrappedObject)->promoted_supportsExtension(extension));
}
PythonQtShell_QWebPluginFactory__ExtensionOption::~PythonQtShell_QWebPluginFactory__ExtensionOption() {
PythonQtPrivate* priv = PythonQt::priv();
if (priv) { priv->shellClassDeleted(this); }
}
QWebPluginFactory::ExtensionOption* PythonQtWrapper_QWebPluginFactory__ExtensionOption::new_QWebPluginFactory__ExtensionOption()
{
return new PythonQtShell_QWebPluginFactory__ExtensionOption(); }
PythonQtShell_QWebPluginFactory__ExtensionReturn::~PythonQtShell_QWebPluginFactory__ExtensionReturn() {
PythonQtPrivate* priv = PythonQt::priv();
if (priv) { priv->shellClassDeleted(this); }
}
QWebPluginFactory::ExtensionReturn* PythonQtWrapper_QWebPluginFactory__ExtensionReturn::new_QWebPluginFactory__ExtensionReturn()
{
return new PythonQtShell_QWebPluginFactory__ExtensionReturn(); }
PythonQtShell_QWebPluginFactory__MimeType::~PythonQtShell_QWebPluginFactory__MimeType() {
PythonQtPrivate* priv = PythonQt::priv();
if (priv) { priv->shellClassDeleted(this); }
}
QWebPluginFactory::MimeType* PythonQtWrapper_QWebPluginFactory__MimeType::new_QWebPluginFactory__MimeType()
{
return new PythonQtShell_QWebPluginFactory__MimeType(); }
bool PythonQtWrapper_QWebPluginFactory__MimeType::__ne__(QWebPluginFactory::MimeType* theWrappedObject, const QWebPluginFactory::MimeType& other) const
{
return ( (*theWrappedObject)!= other);
}
bool PythonQtWrapper_QWebPluginFactory__MimeType::__eq__(QWebPluginFactory::MimeType* theWrappedObject, const QWebPluginFactory::MimeType& other) const
{
return ( (*theWrappedObject)== other);
}
PythonQtShell_QWebPluginFactory__Plugin::~PythonQtShell_QWebPluginFactory__Plugin() {
PythonQtPrivate* priv = PythonQt::priv();
if (priv) { priv->shellClassDeleted(this); }
}
QWebPluginFactory::Plugin* PythonQtWrapper_QWebPluginFactory__Plugin::new_QWebPluginFactory__Plugin()
{
return new PythonQtShell_QWebPluginFactory__Plugin(); }
QWebSecurityOrigin* PythonQtWrapper_QWebSecurityOrigin::new_QWebSecurityOrigin(const QWebSecurityOrigin& other)
{
return new QWebSecurityOrigin(other); }
void PythonQtWrapper_QWebSecurityOrigin::static_QWebSecurityOrigin_addLocalScheme(const QString& scheme)
{
(QWebSecurityOrigin::addLocalScheme(scheme));
}
QList<QWebSecurityOrigin > PythonQtWrapper_QWebSecurityOrigin::static_QWebSecurityOrigin_allOrigins()
{
return (QWebSecurityOrigin::allOrigins());
}
qint64 PythonQtWrapper_QWebSecurityOrigin::databaseQuota(QWebSecurityOrigin* theWrappedObject) const
{
return ( theWrappedObject->databaseQuota());
}
qint64 PythonQtWrapper_QWebSecurityOrigin::databaseUsage(QWebSecurityOrigin* theWrappedObject) const
{
return ( theWrappedObject->databaseUsage());
}
QList<QWebDatabase > PythonQtWrapper_QWebSecurityOrigin::databases(QWebSecurityOrigin* theWrappedObject) const
{
return ( theWrappedObject->databases());
}
QString PythonQtWrapper_QWebSecurityOrigin::host(QWebSecurityOrigin* theWrappedObject) const
{
return ( theWrappedObject->host());
}
QStringList PythonQtWrapper_QWebSecurityOrigin::static_QWebSecurityOrigin_localSchemes()
{
return (QWebSecurityOrigin::localSchemes());
}
QWebSecurityOrigin* PythonQtWrapper_QWebSecurityOrigin::operator_assign(QWebSecurityOrigin* theWrappedObject, const QWebSecurityOrigin& other)
{
return &( (*theWrappedObject)= other);
}
int PythonQtWrapper_QWebSecurityOrigin::port(QWebSecurityOrigin* theWrappedObject) const
{
return ( theWrappedObject->port());
}
void PythonQtWrapper_QWebSecurityOrigin::static_QWebSecurityOrigin_removeLocalScheme(const QString& scheme)
{
(QWebSecurityOrigin::removeLocalScheme(scheme));
}
QString PythonQtWrapper_QWebSecurityOrigin::scheme(QWebSecurityOrigin* theWrappedObject) const
{
return ( theWrappedObject->scheme());
}
void PythonQtWrapper_QWebSecurityOrigin::setApplicationCacheQuota(QWebSecurityOrigin* theWrappedObject, qint64 quota)
{
( theWrappedObject->setApplicationCacheQuota(quota));
}
void PythonQtWrapper_QWebSecurityOrigin::setDatabaseQuota(QWebSecurityOrigin* theWrappedObject, qint64 quota)
{
( theWrappedObject->setDatabaseQuota(quota));
}
void PythonQtWrapper_QWebSettings::static_QWebSettings_clearIconDatabase()
{
(QWebSettings::clearIconDatabase());
}
void PythonQtWrapper_QWebSettings::static_QWebSettings_clearMemoryCaches()
{
(QWebSettings::clearMemoryCaches());
}
QString PythonQtWrapper_QWebSettings::defaultTextEncoding(QWebSettings* theWrappedObject) const
{
return ( theWrappedObject->defaultTextEncoding());
}
void PythonQtWrapper_QWebSettings::static_QWebSettings_enablePersistentStorage(const QString& path)
{
(QWebSettings::enablePersistentStorage(path));
}
QString PythonQtWrapper_QWebSettings::fontFamily(QWebSettings* theWrappedObject, QWebSettings::FontFamily which) const
{
return ( theWrappedObject->fontFamily(which));
}
int PythonQtWrapper_QWebSettings::fontSize(QWebSettings* theWrappedObject, QWebSettings::FontSize type) const
{
return ( theWrappedObject->fontSize(type));
}
QWebSettings* PythonQtWrapper_QWebSettings::static_QWebSettings_globalSettings()
{
return (QWebSettings::globalSettings());
}
QString PythonQtWrapper_QWebSettings::static_QWebSettings_iconDatabasePath()
{
return (QWebSettings::iconDatabasePath());
}
QIcon PythonQtWrapper_QWebSettings::static_QWebSettings_iconForUrl(const QUrl& url)
{
return (QWebSettings::iconForUrl(url));
}
QString PythonQtWrapper_QWebSettings::localStoragePath(QWebSettings* theWrappedObject) const
{
return ( theWrappedObject->localStoragePath());
}
int PythonQtWrapper_QWebSettings::static_QWebSettings_maximumPagesInCache()
{
return (QWebSettings::maximumPagesInCache());
}
qint64 PythonQtWrapper_QWebSettings::static_QWebSettings_offlineStorageDefaultQuota()
{
return (QWebSettings::offlineStorageDefaultQuota());
}
QString PythonQtWrapper_QWebSettings::static_QWebSettings_offlineStoragePath()
{
return (QWebSettings::offlineStoragePath());
}
QString PythonQtWrapper_QWebSettings::static_QWebSettings_offlineWebApplicationCachePath()
{
return (QWebSettings::offlineWebApplicationCachePath());
}
qint64 PythonQtWrapper_QWebSettings::static_QWebSettings_offlineWebApplicationCacheQuota()
{
return (QWebSettings::offlineWebApplicationCacheQuota());
}
void PythonQtWrapper_QWebSettings::resetAttribute(QWebSettings* theWrappedObject, QWebSettings::WebAttribute attr)
{
( theWrappedObject->resetAttribute(attr));
}
void PythonQtWrapper_QWebSettings::resetFontFamily(QWebSettings* theWrappedObject, QWebSettings::FontFamily which)
{
( theWrappedObject->resetFontFamily(which));
}
void PythonQtWrapper_QWebSettings::resetFontSize(QWebSettings* theWrappedObject, QWebSettings::FontSize type)
{
( theWrappedObject->resetFontSize(type));
}
void PythonQtWrapper_QWebSettings::setAttribute(QWebSettings* theWrappedObject, QWebSettings::WebAttribute attr, bool on)
{
( theWrappedObject->setAttribute(attr, on));
}
void PythonQtWrapper_QWebSettings::setDefaultTextEncoding(QWebSettings* theWrappedObject, const QString& encoding)
{
( theWrappedObject->setDefaultTextEncoding(encoding));
}
void PythonQtWrapper_QWebSettings::setFontFamily(QWebSettings* theWrappedObject, QWebSettings::FontFamily which, const QString& family)
{
( theWrappedObject->setFontFamily(which, family));
}
void PythonQtWrapper_QWebSettings::setFontSize(QWebSettings* theWrappedObject, QWebSettings::FontSize type, int size)
{
( theWrappedObject->setFontSize(type, size));
}
void PythonQtWrapper_QWebSettings::static_QWebSettings_setIconDatabasePath(const QString& location)
{
(QWebSettings::setIconDatabasePath(location));
}
void PythonQtWrapper_QWebSettings::setLocalStoragePath(QWebSettings* theWrappedObject, const QString& path)
{
( theWrappedObject->setLocalStoragePath(path));
}
void PythonQtWrapper_QWebSettings::static_QWebSettings_setMaximumPagesInCache(int pages)
{
(QWebSettings::setMaximumPagesInCache(pages));
}
void PythonQtWrapper_QWebSettings::static_QWebSettings_setObjectCacheCapacities(int cacheMinDeadCapacity, int cacheMaxDead, int totalCapacity)
{
(QWebSettings::setObjectCacheCapacities(cacheMinDeadCapacity, cacheMaxDead, totalCapacity));
}
void PythonQtWrapper_QWebSettings::static_QWebSettings_setOfflineStorageDefaultQuota(qint64 maximumSize)
{
(QWebSettings::setOfflineStorageDefaultQuota(maximumSize));
}
void PythonQtWrapper_QWebSettings::static_QWebSettings_setOfflineStoragePath(const QString& path)
{
(QWebSettings::setOfflineStoragePath(path));
}
void PythonQtWrapper_QWebSettings::static_QWebSettings_setOfflineWebApplicationCachePath(const QString& path)
{
(QWebSettings::setOfflineWebApplicationCachePath(path));
}
void PythonQtWrapper_QWebSettings::static_QWebSettings_setOfflineWebApplicationCacheQuota(qint64 maximumSize)
{
(QWebSettings::setOfflineWebApplicationCacheQuota(maximumSize));
}
void PythonQtWrapper_QWebSettings::setThirdPartyCookiePolicy(QWebSettings* theWrappedObject, QWebSettings::ThirdPartyCookiePolicy arg__1)
{
( theWrappedObject->setThirdPartyCookiePolicy(arg__1));
}
void PythonQtWrapper_QWebSettings::setUserStyleSheetUrl(QWebSettings* theWrappedObject, const QUrl& location)
{
( theWrappedObject->setUserStyleSheetUrl(location));
}
void PythonQtWrapper_QWebSettings::static_QWebSettings_setWebGraphic(QWebSettings::WebGraphic type, const QPixmap& graphic)
{
(QWebSettings::setWebGraphic(type, graphic));
}
bool PythonQtWrapper_QWebSettings::testAttribute(QWebSettings* theWrappedObject, QWebSettings::WebAttribute attr) const
{
return ( theWrappedObject->testAttribute(attr));
}
QWebSettings::ThirdPartyCookiePolicy PythonQtWrapper_QWebSettings::thirdPartyCookiePolicy(QWebSettings* theWrappedObject) const
{
return ( theWrappedObject->thirdPartyCookiePolicy());
}
QUrl PythonQtWrapper_QWebSettings::userStyleSheetUrl(QWebSettings* theWrappedObject) const
{
return ( theWrappedObject->userStyleSheetUrl());
}
QPixmap PythonQtWrapper_QWebSettings::static_QWebSettings_webGraphic(QWebSettings::WebGraphic type)
{
return (QWebSettings::webGraphic(type));
}
PythonQtShell_QWebView::~PythonQtShell_QWebView() {
PythonQtPrivate* priv = PythonQt::priv();
if (priv) { priv->shellClassDeleted(this); }
}
void PythonQtShell_QWebView::actionEvent(QActionEvent* arg__1)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("actionEvent");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QActionEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QWebView::actionEvent(arg__1);
}
void PythonQtShell_QWebView::changeEvent(QEvent* arg__1)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("changeEvent");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QWebView::changeEvent(arg__1);
}
void PythonQtShell_QWebView::childEvent(QChildEvent* arg__1)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("childEvent");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QChildEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QWebView::childEvent(arg__1);
}
void PythonQtShell_QWebView::closeEvent(QCloseEvent* arg__1)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("closeEvent");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QCloseEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QWebView::closeEvent(arg__1);
}
void PythonQtShell_QWebView::contextMenuEvent(QContextMenuEvent* arg__1)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("contextMenuEvent");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QContextMenuEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QWebView::contextMenuEvent(arg__1);
}
QWebView* PythonQtShell_QWebView::createWindow(QWebPage::WebWindowType type0)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("createWindow");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"QWebView*" , "QWebPage::WebWindowType"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
QWebView* returnValue;
void* args[2] = {NULL, (void*)&type0};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) {
args[0] = PythonQtConv::ConvertPythonToQt(methodInfo->parameters().at(0), result, false, NULL, &returnValue);
if (args[0]!=&returnValue) {
if (args[0]==NULL) {
PythonQt::priv()->handleVirtualOverloadReturnError("createWindow", methodInfo, result);
} else {
returnValue = *((QWebView**)args[0]);
}
}
}
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return returnValue;
} else {
PyErr_Clear();
}
}
return QWebView::createWindow(type0);
}
void PythonQtShell_QWebView::customEvent(QEvent* arg__1)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("customEvent");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QWebView::customEvent(arg__1);
}
int PythonQtShell_QWebView::devType() const
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("devType");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"int"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(1, argumentList);
int returnValue;
void* args[1] = {NULL};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) {
args[0] = PythonQtConv::ConvertPythonToQt(methodInfo->parameters().at(0), result, false, NULL, &returnValue);
if (args[0]!=&returnValue) {
if (args[0]==NULL) {
PythonQt::priv()->handleVirtualOverloadReturnError("devType", methodInfo, result);
} else {
returnValue = *((int*)args[0]);
}
}
}
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return returnValue;
} else {
PyErr_Clear();
}
}
return QWebView::devType();
}
void PythonQtShell_QWebView::dragEnterEvent(QDragEnterEvent* arg__1)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("dragEnterEvent");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QDragEnterEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QWebView::dragEnterEvent(arg__1);
}
void PythonQtShell_QWebView::dragLeaveEvent(QDragLeaveEvent* arg__1)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("dragLeaveEvent");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QDragLeaveEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QWebView::dragLeaveEvent(arg__1);
}
void PythonQtShell_QWebView::dragMoveEvent(QDragMoveEvent* arg__1)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("dragMoveEvent");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QDragMoveEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QWebView::dragMoveEvent(arg__1);
}
void PythonQtShell_QWebView::dropEvent(QDropEvent* arg__1)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("dropEvent");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QDropEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QWebView::dropEvent(arg__1);
}
void PythonQtShell_QWebView::enterEvent(QEvent* arg__1)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("enterEvent");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QWebView::enterEvent(arg__1);
}
bool PythonQtShell_QWebView::event(QEvent* arg__1)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("event");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"bool" , "QEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
bool returnValue;
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) {
args[0] = PythonQtConv::ConvertPythonToQt(methodInfo->parameters().at(0), result, false, NULL, &returnValue);
if (args[0]!=&returnValue) {
if (args[0]==NULL) {
PythonQt::priv()->handleVirtualOverloadReturnError("event", methodInfo, result);
} else {
returnValue = *((bool*)args[0]);
}
}
}
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return returnValue;
} else {
PyErr_Clear();
}
}
return QWebView::event(arg__1);
}
bool PythonQtShell_QWebView::eventFilter(QObject* arg__1, QEvent* arg__2)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("eventFilter");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"bool" , "QObject*" , "QEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(3, argumentList);
bool returnValue;
void* args[3] = {NULL, (void*)&arg__1, (void*)&arg__2};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) {
args[0] = PythonQtConv::ConvertPythonToQt(methodInfo->parameters().at(0), result, false, NULL, &returnValue);
if (args[0]!=&returnValue) {
if (args[0]==NULL) {
PythonQt::priv()->handleVirtualOverloadReturnError("eventFilter", methodInfo, result);
} else {
returnValue = *((bool*)args[0]);
}
}
}
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return returnValue;
} else {
PyErr_Clear();
}
}
return QWebView::eventFilter(arg__1, arg__2);
}
void PythonQtShell_QWebView::focusInEvent(QFocusEvent* arg__1)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("focusInEvent");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QFocusEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QWebView::focusInEvent(arg__1);
}
bool PythonQtShell_QWebView::focusNextPrevChild(bool next0)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("focusNextPrevChild");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"bool" , "bool"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
bool returnValue;
void* args[2] = {NULL, (void*)&next0};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) {
args[0] = PythonQtConv::ConvertPythonToQt(methodInfo->parameters().at(0), result, false, NULL, &returnValue);
if (args[0]!=&returnValue) {
if (args[0]==NULL) {
PythonQt::priv()->handleVirtualOverloadReturnError("focusNextPrevChild", methodInfo, result);
} else {
returnValue = *((bool*)args[0]);
}
}
}
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return returnValue;
} else {
PyErr_Clear();
}
}
return QWebView::focusNextPrevChild(next0);
}
void PythonQtShell_QWebView::focusOutEvent(QFocusEvent* arg__1)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("focusOutEvent");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QFocusEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QWebView::focusOutEvent(arg__1);
}
bool PythonQtShell_QWebView::hasHeightForWidth() const
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("hasHeightForWidth");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"bool"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(1, argumentList);
bool returnValue;
void* args[1] = {NULL};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) {
args[0] = PythonQtConv::ConvertPythonToQt(methodInfo->parameters().at(0), result, false, NULL, &returnValue);
if (args[0]!=&returnValue) {
if (args[0]==NULL) {
PythonQt::priv()->handleVirtualOverloadReturnError("hasHeightForWidth", methodInfo, result);
} else {
returnValue = *((bool*)args[0]);
}
}
}
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return returnValue;
} else {
PyErr_Clear();
}
}
return QWebView::hasHeightForWidth();
}
int PythonQtShell_QWebView::heightForWidth(int arg__1) const
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("heightForWidth");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"int" , "int"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
int returnValue;
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) {
args[0] = PythonQtConv::ConvertPythonToQt(methodInfo->parameters().at(0), result, false, NULL, &returnValue);
if (args[0]!=&returnValue) {
if (args[0]==NULL) {
PythonQt::priv()->handleVirtualOverloadReturnError("heightForWidth", methodInfo, result);
} else {
returnValue = *((int*)args[0]);
}
}
}
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return returnValue;
} else {
PyErr_Clear();
}
}
return QWebView::heightForWidth(arg__1);
}
void PythonQtShell_QWebView::hideEvent(QHideEvent* arg__1)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("hideEvent");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QHideEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QWebView::hideEvent(arg__1);
}
void PythonQtShell_QWebView::initPainter(QPainter* painter0) const
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("initPainter");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QPainter*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&painter0};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QWebView::initPainter(painter0);
}
void PythonQtShell_QWebView::inputMethodEvent(QInputMethodEvent* arg__1)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("inputMethodEvent");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QInputMethodEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QWebView::inputMethodEvent(arg__1);
}
QVariant PythonQtShell_QWebView::inputMethodQuery(Qt::InputMethodQuery property0) const
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("inputMethodQuery");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"QVariant" , "Qt::InputMethodQuery"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
QVariant returnValue;
void* args[2] = {NULL, (void*)&property0};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) {
args[0] = PythonQtConv::ConvertPythonToQt(methodInfo->parameters().at(0), result, false, NULL, &returnValue);
if (args[0]!=&returnValue) {
if (args[0]==NULL) {
PythonQt::priv()->handleVirtualOverloadReturnError("inputMethodQuery", methodInfo, result);
} else {
returnValue = *((QVariant*)args[0]);
}
}
}
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return returnValue;
} else {
PyErr_Clear();
}
}
return QWebView::inputMethodQuery(property0);
}
void PythonQtShell_QWebView::keyPressEvent(QKeyEvent* arg__1)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("keyPressEvent");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QKeyEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QWebView::keyPressEvent(arg__1);
}
void PythonQtShell_QWebView::keyReleaseEvent(QKeyEvent* arg__1)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("keyReleaseEvent");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QKeyEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QWebView::keyReleaseEvent(arg__1);
}
void PythonQtShell_QWebView::leaveEvent(QEvent* arg__1)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("leaveEvent");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QWebView::leaveEvent(arg__1);
}
int PythonQtShell_QWebView::metric(QPaintDevice::PaintDeviceMetric arg__1) const
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("metric");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"int" , "QPaintDevice::PaintDeviceMetric"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
int returnValue;
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) {
args[0] = PythonQtConv::ConvertPythonToQt(methodInfo->parameters().at(0), result, false, NULL, &returnValue);
if (args[0]!=&returnValue) {
if (args[0]==NULL) {
PythonQt::priv()->handleVirtualOverloadReturnError("metric", methodInfo, result);
} else {
returnValue = *((int*)args[0]);
}
}
}
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return returnValue;
} else {
PyErr_Clear();
}
}
return QWebView::metric(arg__1);
}
QSize PythonQtShell_QWebView::minimumSizeHint() const
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("getMinimumSizeHint");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"QSize"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(1, argumentList);
QSize returnValue;
void* args[1] = {NULL};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) {
args[0] = PythonQtConv::ConvertPythonToQt(methodInfo->parameters().at(0), result, false, NULL, &returnValue);
if (args[0]!=&returnValue) {
if (args[0]==NULL) {
PythonQt::priv()->handleVirtualOverloadReturnError("getMinimumSizeHint", methodInfo, result);
} else {
returnValue = *((QSize*)args[0]);
}
}
}
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return returnValue;
} else {
PyErr_Clear();
}
}
return QWebView::minimumSizeHint();
}
void PythonQtShell_QWebView::mouseDoubleClickEvent(QMouseEvent* arg__1)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("mouseDoubleClickEvent");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QMouseEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QWebView::mouseDoubleClickEvent(arg__1);
}
void PythonQtShell_QWebView::mouseMoveEvent(QMouseEvent* arg__1)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("mouseMoveEvent");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QMouseEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QWebView::mouseMoveEvent(arg__1);
}
void PythonQtShell_QWebView::mousePressEvent(QMouseEvent* arg__1)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("mousePressEvent");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QMouseEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QWebView::mousePressEvent(arg__1);
}
void PythonQtShell_QWebView::mouseReleaseEvent(QMouseEvent* arg__1)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("mouseReleaseEvent");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QMouseEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QWebView::mouseReleaseEvent(arg__1);
}
void PythonQtShell_QWebView::moveEvent(QMoveEvent* arg__1)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("moveEvent");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QMoveEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QWebView::moveEvent(arg__1);
}
bool PythonQtShell_QWebView::nativeEvent(const QByteArray& eventType0, void* message1, long* result2)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("nativeEvent");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"bool" , "const QByteArray&" , "void*" , "long*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(4, argumentList);
bool returnValue;
void* args[4] = {NULL, (void*)&eventType0, (void*)&message1, (void*)&result2};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) {
args[0] = PythonQtConv::ConvertPythonToQt(methodInfo->parameters().at(0), result, false, NULL, &returnValue);
if (args[0]!=&returnValue) {
if (args[0]==NULL) {
PythonQt::priv()->handleVirtualOverloadReturnError("nativeEvent", methodInfo, result);
} else {
returnValue = *((bool*)args[0]);
}
}
}
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return returnValue;
} else {
PyErr_Clear();
}
}
return QWebView::nativeEvent(eventType0, message1, result2);
}
QPaintEngine* PythonQtShell_QWebView::paintEngine() const
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("paintEngine");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"QPaintEngine*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(1, argumentList);
QPaintEngine* returnValue;
void* args[1] = {NULL};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) {
args[0] = PythonQtConv::ConvertPythonToQt(methodInfo->parameters().at(0), result, false, NULL, &returnValue);
if (args[0]!=&returnValue) {
if (args[0]==NULL) {
PythonQt::priv()->handleVirtualOverloadReturnError("paintEngine", methodInfo, result);
} else {
returnValue = *((QPaintEngine**)args[0]);
}
}
}
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return returnValue;
} else {
PyErr_Clear();
}
}
return QWebView::paintEngine();
}
void PythonQtShell_QWebView::paintEvent(QPaintEvent* arg__1)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("paintEvent");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QPaintEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QWebView::paintEvent(arg__1);
}
QPaintDevice* PythonQtShell_QWebView::redirected(QPoint* offset0) const
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("redirected");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"QPaintDevice*" , "QPoint*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
QPaintDevice* returnValue;
void* args[2] = {NULL, (void*)&offset0};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) {
args[0] = PythonQtConv::ConvertPythonToQt(methodInfo->parameters().at(0), result, false, NULL, &returnValue);
if (args[0]!=&returnValue) {
if (args[0]==NULL) {
PythonQt::priv()->handleVirtualOverloadReturnError("redirected", methodInfo, result);
} else {
returnValue = *((QPaintDevice**)args[0]);
}
}
}
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return returnValue;
} else {
PyErr_Clear();
}
}
return QWebView::redirected(offset0);
}
void PythonQtShell_QWebView::resizeEvent(QResizeEvent* arg__1)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("resizeEvent");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QResizeEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QWebView::resizeEvent(arg__1);
}
QPainter* PythonQtShell_QWebView::sharedPainter() const
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("sharedPainter");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"QPainter*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(1, argumentList);
QPainter* returnValue;
void* args[1] = {NULL};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) {
args[0] = PythonQtConv::ConvertPythonToQt(methodInfo->parameters().at(0), result, false, NULL, &returnValue);
if (args[0]!=&returnValue) {
if (args[0]==NULL) {
PythonQt::priv()->handleVirtualOverloadReturnError("sharedPainter", methodInfo, result);
} else {
returnValue = *((QPainter**)args[0]);
}
}
}
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return returnValue;
} else {
PyErr_Clear();
}
}
return QWebView::sharedPainter();
}
void PythonQtShell_QWebView::showEvent(QShowEvent* arg__1)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("showEvent");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QShowEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QWebView::showEvent(arg__1);
}
void PythonQtShell_QWebView::tabletEvent(QTabletEvent* arg__1)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("tabletEvent");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QTabletEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QWebView::tabletEvent(arg__1);
}
void PythonQtShell_QWebView::timerEvent(QTimerEvent* arg__1)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("timerEvent");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QTimerEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QWebView::timerEvent(arg__1);
}
void PythonQtShell_QWebView::wheelEvent(QWheelEvent* arg__1)
{
if (_wrapper && (((PyObject*)_wrapper)->ob_refcnt > 0)) {
static PyObject* name = PyString_FromString("wheelEvent");
PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);
if (obj) {
static const char* argumentList[] ={"" , "QWheelEvent*"};
static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList);
void* args[2] = {NULL, (void*)&arg__1};
PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true);
if (result) { Py_DECREF(result); }
Py_DECREF(obj);
return;
} else {
PyErr_Clear();
}
}
QWebView::wheelEvent(arg__1);
}
QWebView* PythonQtWrapper_QWebView::new_QWebView(QWidget* parent)
{
return new PythonQtShell_QWebView(parent); }
void PythonQtWrapper_QWebView::changeEvent(QWebView* theWrappedObject, QEvent* arg__1)
{
( ((PythonQtPublicPromoter_QWebView*)theWrappedObject)->promoted_changeEvent(arg__1));
}
void PythonQtWrapper_QWebView::contextMenuEvent(QWebView* theWrappedObject, QContextMenuEvent* arg__1)
{
( ((PythonQtPublicPromoter_QWebView*)theWrappedObject)->promoted_contextMenuEvent(arg__1));
}
QWebView* PythonQtWrapper_QWebView::createWindow(QWebView* theWrappedObject, QWebPage::WebWindowType type)
{
return ( ((PythonQtPublicPromoter_QWebView*)theWrappedObject)->promoted_createWindow(type));
}
void PythonQtWrapper_QWebView::dragEnterEvent(QWebView* theWrappedObject, QDragEnterEvent* arg__1)
{
( ((PythonQtPublicPromoter_QWebView*)theWrappedObject)->promoted_dragEnterEvent(arg__1));
}
void PythonQtWrapper_QWebView::dragLeaveEvent(QWebView* theWrappedObject, QDragLeaveEvent* arg__1)
{
( ((PythonQtPublicPromoter_QWebView*)theWrappedObject)->promoted_dragLeaveEvent(arg__1));
}
void PythonQtWrapper_QWebView::dragMoveEvent(QWebView* theWrappedObject, QDragMoveEvent* arg__1)
{
( ((PythonQtPublicPromoter_QWebView*)theWrappedObject)->promoted_dragMoveEvent(arg__1));
}
void PythonQtWrapper_QWebView::dropEvent(QWebView* theWrappedObject, QDropEvent* arg__1)
{
( ((PythonQtPublicPromoter_QWebView*)theWrappedObject)->promoted_dropEvent(arg__1));
}
bool PythonQtWrapper_QWebView::event(QWebView* theWrappedObject, QEvent* arg__1)
{
return ( ((PythonQtPublicPromoter_QWebView*)theWrappedObject)->promoted_event(arg__1));
}
bool PythonQtWrapper_QWebView::findText(QWebView* theWrappedObject, const QString& subString, QWebPage::FindFlags options)
{
return ( theWrappedObject->findText(subString, options));
}
void PythonQtWrapper_QWebView::focusInEvent(QWebView* theWrappedObject, QFocusEvent* arg__1)
{
( ((PythonQtPublicPromoter_QWebView*)theWrappedObject)->promoted_focusInEvent(arg__1));
}
bool PythonQtWrapper_QWebView::focusNextPrevChild(QWebView* theWrappedObject, bool next)
{
return ( ((PythonQtPublicPromoter_QWebView*)theWrappedObject)->promoted_focusNextPrevChild(next));
}
void PythonQtWrapper_QWebView::focusOutEvent(QWebView* theWrappedObject, QFocusEvent* arg__1)
{
( ((PythonQtPublicPromoter_QWebView*)theWrappedObject)->promoted_focusOutEvent(arg__1));
}
bool PythonQtWrapper_QWebView::hasSelection(QWebView* theWrappedObject) const
{
return ( theWrappedObject->hasSelection());
}
QWebHistory* PythonQtWrapper_QWebView::history(QWebView* theWrappedObject) const
{
return ( theWrappedObject->history());
}
QIcon PythonQtWrapper_QWebView::icon(QWebView* theWrappedObject) const
{
return ( theWrappedObject->icon());
}
void PythonQtWrapper_QWebView::inputMethodEvent(QWebView* theWrappedObject, QInputMethodEvent* arg__1)
{
( ((PythonQtPublicPromoter_QWebView*)theWrappedObject)->promoted_inputMethodEvent(arg__1));
}
QVariant PythonQtWrapper_QWebView::inputMethodQuery(QWebView* theWrappedObject, Qt::InputMethodQuery property) const
{
return ( ((PythonQtPublicPromoter_QWebView*)theWrappedObject)->promoted_inputMethodQuery(property));
}
bool PythonQtWrapper_QWebView::isModified(QWebView* theWrappedObject) const
{
return ( theWrappedObject->isModified());
}
void PythonQtWrapper_QWebView::keyPressEvent(QWebView* theWrappedObject, QKeyEvent* arg__1)
{
( ((PythonQtPublicPromoter_QWebView*)theWrappedObject)->promoted_keyPressEvent(arg__1));
}
void PythonQtWrapper_QWebView::keyReleaseEvent(QWebView* theWrappedObject, QKeyEvent* arg__1)
{
( ((PythonQtPublicPromoter_QWebView*)theWrappedObject)->promoted_keyReleaseEvent(arg__1));
}
void PythonQtWrapper_QWebView::load(QWebView* theWrappedObject, const QNetworkRequest& request, QNetworkAccessManager::Operation operation, const QByteArray& body)
{
( theWrappedObject->load(request, operation, body));
}
void PythonQtWrapper_QWebView::load(QWebView* theWrappedObject, const QUrl& url)
{
( theWrappedObject->load(url));
}
void PythonQtWrapper_QWebView::mouseDoubleClickEvent(QWebView* theWrappedObject, QMouseEvent* arg__1)
{
( ((PythonQtPublicPromoter_QWebView*)theWrappedObject)->promoted_mouseDoubleClickEvent(arg__1));
}
void PythonQtWrapper_QWebView::mouseMoveEvent(QWebView* theWrappedObject, QMouseEvent* arg__1)
{
( ((PythonQtPublicPromoter_QWebView*)theWrappedObject)->promoted_mouseMoveEvent(arg__1));
}
void PythonQtWrapper_QWebView::mousePressEvent(QWebView* theWrappedObject, QMouseEvent* arg__1)
{
( ((PythonQtPublicPromoter_QWebView*)theWrappedObject)->promoted_mousePressEvent(arg__1));
}
void PythonQtWrapper_QWebView::mouseReleaseEvent(QWebView* theWrappedObject, QMouseEvent* arg__1)
{
( ((PythonQtPublicPromoter_QWebView*)theWrappedObject)->promoted_mouseReleaseEvent(arg__1));
}
QWebPage* PythonQtWrapper_QWebView::page(QWebView* theWrappedObject) const
{
return ( theWrappedObject->page());
}
QAction* PythonQtWrapper_QWebView::pageAction(QWebView* theWrappedObject, QWebPage::WebAction action) const
{
return ( theWrappedObject->pageAction(action));
}
void PythonQtWrapper_QWebView::paintEvent(QWebView* theWrappedObject, QPaintEvent* arg__1)
{
( ((PythonQtPublicPromoter_QWebView*)theWrappedObject)->promoted_paintEvent(arg__1));
}
QPainter::RenderHints PythonQtWrapper_QWebView::renderHints(QWebView* theWrappedObject) const
{
return ( theWrappedObject->renderHints());
}
void PythonQtWrapper_QWebView::resizeEvent(QWebView* theWrappedObject, QResizeEvent* arg__1)
{
( ((PythonQtPublicPromoter_QWebView*)theWrappedObject)->promoted_resizeEvent(arg__1));
}
QString PythonQtWrapper_QWebView::selectedHtml(QWebView* theWrappedObject) const
{
return ( theWrappedObject->selectedHtml());
}
QString PythonQtWrapper_QWebView::selectedText(QWebView* theWrappedObject) const
{
return ( theWrappedObject->selectedText());
}
void PythonQtWrapper_QWebView::setContent(QWebView* theWrappedObject, const QByteArray& data, const QString& mimeType, const QUrl& baseUrl)
{
( theWrappedObject->setContent(data, mimeType, baseUrl));
}
void PythonQtWrapper_QWebView::setHtml(QWebView* theWrappedObject, const QString& html, const QUrl& baseUrl)
{
( theWrappedObject->setHtml(html, baseUrl));
}
void PythonQtWrapper_QWebView::setPage(QWebView* theWrappedObject, QWebPage* page)
{
( theWrappedObject->setPage(page));
}
void PythonQtWrapper_QWebView::setRenderHint(QWebView* theWrappedObject, QPainter::RenderHint hint, bool enabled)
{
( theWrappedObject->setRenderHint(hint, enabled));
}
void PythonQtWrapper_QWebView::setRenderHints(QWebView* theWrappedObject, QPainter::RenderHints hints)
{
( theWrappedObject->setRenderHints(hints));
}
void PythonQtWrapper_QWebView::setTextSizeMultiplier(QWebView* theWrappedObject, qreal factor)
{
( theWrappedObject->setTextSizeMultiplier(factor));
}
void PythonQtWrapper_QWebView::setUrl(QWebView* theWrappedObject, const QUrl& url)
{
( theWrappedObject->setUrl(url));
}
void PythonQtWrapper_QWebView::setZoomFactor(QWebView* theWrappedObject, qreal factor)
{
( theWrappedObject->setZoomFactor(factor));
}
QWebSettings* PythonQtWrapper_QWebView::settings(QWebView* theWrappedObject) const
{
return ( theWrappedObject->settings());
}
QSize PythonQtWrapper_QWebView::sizeHint(QWebView* theWrappedObject) const
{
return ( theWrappedObject->sizeHint());
}
qreal PythonQtWrapper_QWebView::textSizeMultiplier(QWebView* theWrappedObject) const
{
return ( theWrappedObject->textSizeMultiplier());
}
QString PythonQtWrapper_QWebView::title(QWebView* theWrappedObject) const
{
return ( theWrappedObject->title());
}
void PythonQtWrapper_QWebView::triggerPageAction(QWebView* theWrappedObject, QWebPage::WebAction action, bool checked)
{
( theWrappedObject->triggerPageAction(action, checked));
}
QUrl PythonQtWrapper_QWebView::url(QWebView* theWrappedObject) const
{
return ( theWrappedObject->url());
}
void PythonQtWrapper_QWebView::wheelEvent(QWebView* theWrappedObject, QWheelEvent* arg__1)
{
( ((PythonQtPublicPromoter_QWebView*)theWrappedObject)->promoted_wheelEvent(arg__1));
}
qreal PythonQtWrapper_QWebView::zoomFactor(QWebView* theWrappedObject) const
{
return ( theWrappedObject->zoomFactor());
}
| 37.305201
| 224
| 0.728346
|
aliakseis
|
2a31ebfddbe4dcd9bedd2ece45c27c9f8017a430
| 9,013
|
cpp
|
C++
|
SRTI_Source/v2_C++_Sim_Wrapper_Source/simulations/Array/string_sim.cpp
|
ICoR-code/SRTI
|
1261f24e5fee6df587e926b107173cacd2cf3126
|
[
"Apache-2.0"
] | 4
|
2020-10-09T20:19:53.000Z
|
2022-01-29T06:24:31.000Z
|
SRTI_Source/v2_C++_Sim_Wrapper_Source/simulations/Array/string_sim.cpp
|
hlynka-a/SRTI
|
1261f24e5fee6df587e926b107173cacd2cf3126
|
[
"Apache-2.0"
] | 4
|
2020-07-07T20:42:24.000Z
|
2022-03-25T18:52:23.000Z
|
SRTI_Source/v2_C++_Sim_Wrapper_Source/simulations/Array/string_sim.cpp
|
ICoR-code/SRTI
|
1261f24e5fee6df587e926b107173cacd2cf3126
|
[
"Apache-2.0"
] | 2
|
2020-10-09T20:17:02.000Z
|
2021-03-24T06:40:57.000Z
|
#include <vector>
#include <iostream>
#include <type_traits>
#include "string_sim.hpp"
using namespace std;
namespace rj = rapidjson;
StringSim::StringSim() {
input.insert(pair <string, rj::Value> ("Double", rj::Value()));
output.insert(pair <string, rj::Value> ("String", rj::Value(rj::kObjectType)));
output.at("String").AddMember("array", rj::Value(rj::kArrayType), doc.GetAllocator());
history_size.insert(pair <string, int> ("String", 1));
history.insert(pair <string, vector<rj::Value> >
("String", vector<rj::Value>(1))
);
}
StringSim::~StringSim() {
}
rj::Value & StringSim::getMessage(string message_name) {
assert(!output.at(message_name).IsNull());
return output.at(message_name);
}
void StringSim::setMessage(string message_name, rj::Value &value) {
input.at(message_name) = value;
}
void StringSim::setMessage(string message_name, string &message) {
doc.Parse(message.c_str());
input.at(message_name) = doc.GetObject();
}
void StringSim::updateHistory() {
rj::Document::AllocatorType &a = doc.GetAllocator();
for (auto &value: history) {
auto &messages = value.second;
if (messages.size() > 0) {
for (int i = messages.size() - 1; i >= 1; --i) {
messages[i] = messages[i - 1];
}
// Deep Copy
messages[0].CopyFrom(output.at(value.first), a);
}
}
}
void StringSim::simulate() {
// Using []
// string ***alphabet;
// size_t *size = new size_t[3]();
//
// getArray(history.at("String")[0]["array"], alphabet, size);
//
// double ***value;
// getArray(input.at("Double")["array"], value, size);
//
// for (size_t i = 0; i < size[0]; ++i) {
// for (size_t j = 0; j < size[1]; ++j) {
// for (size_t k = 0; k < size[2]; ++k) {
// char ch = value[i][j][k];
// assert(ch == alphabet[i][j][k][0] + 1);
// ++alphabet[i][j][k][0];
// }
// }
// }
//
// setArray(output.at("String")["array"], alphabet, size);
//
// for (size_t i = 0; i < size[0]; ++i) {
// for (size_t j = 0; j < size[1]; ++j) {
// delete[] alphabet[i][j];
// delete[] value[i][j];
// }
// delete[] alphabet[i];
// delete[] value[i];
// }
//
// delete[] size;
// delete[] alphabet;
// delete[] value;
// Using vector
vector<vector<vector<string> > > alphabet;
getVector(history.at("String")[0]["array"], alphabet);
vector<vector<vector<double> > > value;
getVector(input.at("Double")["array"], value);
for (size_t i = 0; i < value.size(); ++i) {
for (size_t j = 0; j < value[0].size(); ++j) {
for (size_t k = 0; k < value[0][0].size(); ++k) {
char ch = value[i][j][k];
assert(ch == alphabet[i][j][k][0] + 1);
++alphabet[i][j][k][0];
}
}
}
setVector(output.at("String")["array"], alphabet);
updateHistory();
}
void StringSim::generateInitialMessage() {
// Using []
// string alphabet[2][1][1] = {{{"A"}}, {{"a"}}};
// size_t size[] = {2, 1, 1};
// setArray(output.at("String")["array"], alphabet, size);
// Using vector
vector<vector<vector<string> > > alphabet {{{"A"}}, {{"a"}}};
setVector(output.at("String")["array"], alphabet);
updateHistory();
}
int StringSim::get(const rj::Value &value, const int ref) {
return value.GetInt();
}
unsigned StringSim::get(const rj::Value &value, const unsigned ref) {
return value.GetUint();
}
int64_t StringSim::get(const rj::Value &value, const int64_t ref) {
return value.GetInt64();
}
uint64_t StringSim::get(const rj::Value &value, const uint64_t ref) {
return value.GetUint64();
}
double StringSim::get(const rj::Value &value, const double ref) {
return value.GetDouble();
}
bool StringSim::get(const rj::Value &value, const bool ref) {
return value.GetBool();
}
string StringSim::get(const rj::Value &value, const string ref) {
return value.GetString();
}
const char *StringSim::get(const rj::Value &value, const char *ref) {
return value.GetString();
}
void StringSim::pushBack(rj::Value &array, const int value) {
auto &a = doc.GetAllocator();
array.PushBack(value, a);
}
void StringSim::pushBack(rj::Value &array, const unsigned value) {
auto &a = doc.GetAllocator();
array.PushBack(value, a);
}
void StringSim::pushBack(rj::Value &array, const int64_t value) {
auto &a = doc.GetAllocator();
array.PushBack(value, a);
}
void StringSim::pushBack(rj::Value &array, const uint64_t value) {
auto &a = doc.GetAllocator();
array.PushBack(value, a);
}
void StringSim::pushBack(rj::Value &array, const double value) {
auto &a = doc.GetAllocator();
array.PushBack(value, a);
}
void StringSim::pushBack(rj::Value &array, const bool value) {
auto &a = doc.GetAllocator();
array.PushBack(value, a);
}
void StringSim::pushBack(rj::Value &array, const string &str) {
rj::Value value;
auto &a = doc.GetAllocator();
value.SetString(str.c_str(), str.size(), a);
array.PushBack(value, a);
}
void StringSim::pushBack(rj::Value &array, const char *str) {
rj::Value value;
auto &a = doc.GetAllocator();
value.SetString(str, strlen(str), a);
array.PushBack(value, a);
}
template <typename T>
size_t StringSim::get1DArray(const rj::Value &value, T* &array) {
assert(value.IsArray());
array = new T[value.Size()];
T ref = T();
for (size_t i = 0; i < value.Size(); ++i) {
array[i] = get(value[i], ref);
}
return value.Size();
}
template <typename T>
void StringSim::getArray(const rj::Value &value, T* &array, size_t* const &size, typename enable_if<!is_pointer<T>::value && !is_array<T>::value>::type*) {
assert(value.IsArray());
array = new T[value.Size()];
T ref = T();
for (size_t i = 0; i < value.Size(); ++i) {
array[i] = get(value[i], ref);
}
*size = value.Size();
}
template <typename T,
typename enable_if<(is_pointer<T>::value || is_array<T>::value), int>::type = 0>
void StringSim::getArray(const rj::Value &value, T* &array, size_t* const &size) {
assert(value.IsArray());
array = new T[value.Size()];
for (size_t i = 0; i < value.Size(); ++i) {
getArray(value[i], array[i], size + 1);
}
*size = value.Size();
}
template <typename T>
vector<T> StringSim::get1DVector(const rj::Value &value, const T ref) {
assert(value.IsArray());
vector<T> vec;
for (auto &v: value.GetArray()) {
vec.push_back(get(v, ref));
}
return vec;
}
template <typename T>
void StringSim::getVector(const rj::Value &value, vector<T> &vec) {
assert(value.IsArray());
T ref = T();
for (auto &v: value.GetArray()) {
vec.push_back(get(v, ref));
}
}
template <typename T>
void StringSim::getVector(const rj::Value &value, vector<vector<T> > &vec) {
assert(value.IsArray());
for (auto &v: value.GetArray()) {
vector<T> element;
getVector(v, element);
vec.push_back(element);
}
}
template <typename T>
void StringSim::set1DArray(rj::Value &value, const T * const array, const size_t size) {
auto &a = doc.GetAllocator();
value.SetArray();
for (size_t i = 0; i < size; ++i) {
pushBack(value, array[i]);
}
}
template <typename T>
void StringSim::setArray(rj::Value &value, const T * const array, const size_t * const size, typename enable_if<!is_pointer<T>::value && !is_array<T>::value>::type*) {
value.SetArray();
for (size_t i = 0; i < *size; ++i) {
pushBack(value, array[i]);
}
}
template <typename T,
typename enable_if<(is_pointer<T>::value || is_array<T>::value), int>::type = 0>
void StringSim::setArray(rj::Value &value, const T * const array, const size_t * const size) {
auto &a = doc.GetAllocator();
value.SetArray();
for (size_t i = 0; i < *size; ++i) {
rj::Value element(rj::kArrayType);
setArray(element, array[i], size + 1);
value.PushBack(element, a);
}
}
template <typename T>
void StringSim::set1DVector(rj::Value &value, const vector<T> &vec) {
auto &a = doc.GetAllocator();
value.SetArray();
for (size_t i = 0; i < vec.size(); ++i) {
pushBack(value,vec[i]);
}
}
template <typename T>
void StringSim::setVector(rj::Value &value, const vector<T> &vec) {
auto &a = doc.GetAllocator();
value.SetArray();
for (size_t i = 0; i < vec.size(); ++i) {
pushBack(value, vec[i]);
}
}
template <typename T>
void StringSim::setVector(rj::Value &value, const vector<vector<T> > &vec) {
auto &a = doc.GetAllocator();
value.SetArray();
for (size_t i = 0; i < vec.size(); ++i) {
rj::Value element(rj::kArrayType);
setVector(element, vec[i]);
value.PushBack(element, a);
}
}
| 26.508824
| 167
| 0.582159
|
ICoR-code
|
2a31ff4194392d7dcf31835486fdf10f91d81e13
| 15,956
|
cpp
|
C++
|
tests/MetadataEngine/tst_metadataenginetest.cpp
|
DatabasesWorks/passiflora-symphytum-configurable-fields
|
6128d0391fe33438250efad4398d65c5982b005b
|
[
"BSD-2-Clause"
] | 374
|
2015-01-03T17:25:16.000Z
|
2022-03-04T07:58:07.000Z
|
tests/MetadataEngine/tst_metadataenginetest.cpp
|
DatabasesWorks/symphytum-configurable-fields
|
187b72e9ff758bd207a415cb3fc9e2d97889996c
|
[
"BSD-2-Clause"
] | 133
|
2015-01-03T17:28:29.000Z
|
2020-09-22T11:44:14.000Z
|
tests/MetadataEngine/tst_metadataenginetest.cpp
|
DatabasesWorks/symphytum-configurable-fields
|
187b72e9ff758bd207a415cb3fc9e2d97889996c
|
[
"BSD-2-Clause"
] | 78
|
2015-01-19T13:26:07.000Z
|
2022-03-21T00:02:55.000Z
|
#include <QString>
#include <QtTest>
#include <QSqlQuery>
#include "../../components/metadataengine.h"
#include "../../components/databasemanager.h"
class MetadataEngineTest : public QObject
{
Q_OBJECT
public:
MetadataEngineTest();
~MetadataEngineTest();
private Q_SLOTS:
void testCollectionId();
void testCollectionName();
void testFieldName();
void testFieldCount();
void testFieldType();
void testFieldPos();
void testFieldSize();
void testFieldProperty();
void testCreateModel();
void testCreateCollection();
void testDeleteCollection();
void testCreateField();
void testDeleteField();
void testModifyField();
void testFileMetadata();
private:
MetadataEngine *m_metadataEngine;
DatabaseManager *m_databaseManager;
};
MetadataEngineTest::MetadataEngineTest()
{
m_metadataEngine = &MetadataEngine::getInstance();
m_databaseManager = &DatabaseManager::getInstance();
}
MetadataEngineTest::~MetadataEngineTest()
{
m_metadataEngine = 0;
m_databaseManager = 0;
}
void MetadataEngineTest::testCollectionId()
{
int originalId = -1;
int newId = 99;
originalId = m_metadataEngine->getCurrentCollectionId();
QVERIFY2((originalId != -1),
"Get collection ID not working");
m_metadataEngine->setCurrentCollectionId(newId);
QVERIFY2((newId == m_metadataEngine->getCurrentCollectionId()),
"Set collection ID not working");
//set original back
m_metadataEngine->setCurrentCollectionId(originalId);
}
void MetadataEngineTest::testCollectionName()
{
//this is the same string from database manager where the default
//collection name is defined for example data
QString defaultCollectionName = "Customers";
QString currentCollectionName = m_metadataEngine->getCurrentCollectionName();
QVERIFY2((defaultCollectionName == currentCollectionName),
"Get collection name not working");
QString getCollectionName = m_metadataEngine->getCollectionName(
m_metadataEngine->getCurrentCollectionId());
QVERIFY(defaultCollectionName == getCollectionName);
}
void MetadataEngineTest::testFieldName()
{
QString originalName, newName, exampleName;
int id, column;
exampleName = "Age"; //from database manager example data
newName = "Weight";
column = 3; //age column from example data
id = m_metadataEngine->getCurrentCollectionId();
originalName = m_metadataEngine->getFieldName(column);
QVERIFY(originalName == exampleName);
QVERIFY(originalName == m_metadataEngine->getFieldName(column, id));
QVERIFY("_invalid_column_name_" == m_metadataEngine->getFieldName(column, 9999));
m_metadataEngine->setFieldName(column, newName);
QVERIFY(newName == m_metadataEngine->getFieldName(column));
m_metadataEngine->setFieldName(column, newName, id);
QVERIFY(newName == m_metadataEngine->getFieldName(column, id));
m_metadataEngine->setFieldName(column, "invalid", 9999);
QVERIFY(newName == m_metadataEngine->getFieldName(column, id));
//set back to original name
m_metadataEngine->setFieldName(column, originalName);
}
void MetadataEngineTest::testFieldCount()
{
int exampleFieldCount = 4; //field count from exmple data
int id = m_metadataEngine->getCurrentCollectionId();
QVERIFY(exampleFieldCount == m_metadataEngine->getFieldCount());
QVERIFY(exampleFieldCount == m_metadataEngine->getFieldCount(id));
QVERIFY(0 == m_metadataEngine->getFieldCount(9999));
}
void MetadataEngineTest::testFieldType()
{
//from example data
MetadataEngine::FieldType exampleFieldType = MetadataEngine::NumericType;
int column = 3;
int id = m_metadataEngine->getCurrentCollectionId();
QString columnName = "Age";
QVERIFY(exampleFieldType == m_metadataEngine->getFieldType(column, id));
QVERIFY(exampleFieldType == m_metadataEngine->getFieldType(column));
QVERIFY(exampleFieldType == m_metadataEngine->getFieldType(columnName, id));
QVERIFY(exampleFieldType == m_metadataEngine->getFieldType(columnName));
}
void MetadataEngineTest::testFieldPos()
{
//from example data
int column = 3;
int id = m_metadataEngine->getCurrentCollectionId();
QString columnName = "Age";
int x, y;
bool ok = m_metadataEngine->getFieldCoordinate(column, x, y, id);
QVERIFY(ok == false);
m_metadataEngine->setFieldCoordinate(column, 1, 2);
ok = m_metadataEngine->getFieldCoordinate(column, x, y, id);
QVERIFY(ok == true);
QVERIFY((x == 1) && (y == 2));
m_metadataEngine->setFieldCoordinate(column, -1, -1);
ok = m_metadataEngine->getFieldCoordinate(column, x, y, id);
QVERIFY(ok == false);
}
void MetadataEngineTest::testFieldSize()
{
//from example data
int column = 3;
int id = m_metadataEngine->getCurrentCollectionId();
QString columnName = "Age";
int w, h;
m_metadataEngine->getFieldFormLayoutSize(column, w, h, 9999);
QVERIFY((w == -1) && (h == -1));
m_metadataEngine->setFieldFormLayoutSize(column, 1, 2);
m_metadataEngine->getFieldFormLayoutSize(column, w, h, id);
QVERIFY((w == 1) && (h == 2));
m_metadataEngine->setFieldFormLayoutSize(column, 1, 1);
}
void MetadataEngineTest::testFieldProperty()
{
//from example data
int column = 3;
int id = m_metadataEngine->getCurrentCollectionId();
QString columnName = "Age";
QString testProperty = "key:value;key2:value2a,value2b;";
QVERIFY(
m_metadataEngine->getFieldProperties(MetadataEngine::DisplayProperty, column)
.isEmpty()); //FIXME: err
m_metadataEngine->setFieldProperties(MetadataEngine::DisplayProperty, column,
testProperty);
QVERIFY(
m_metadataEngine->getFieldProperties(MetadataEngine::DisplayProperty, column)
== testProperty);
//reset
m_metadataEngine->setFieldProperties(MetadataEngine::DisplayProperty, column,
"");
}
void MetadataEngineTest::testCreateModel()
{
//model without init
QAbstractItemModel *model = m_metadataEngine->createModel(
MetadataEngine::StandardCollection);
QVERIFY(model != 0);
QVERIFY(model->columnCount() == 0);
//model with init
int id = m_metadataEngine->getCurrentCollectionId();
int exampleFieldCount = m_metadataEngine->getFieldCount();
QAbstractItemModel *model2 = m_metadataEngine->createModel(
MetadataEngine::StandardCollection, id);
QVERIFY(model2 != 0);
QVERIFY(model2->columnCount() == exampleFieldCount);
}
void MetadataEngineTest::testCreateCollection()
{
int id = -1;
QString tableName;
QString metadataTableName;
//simulate new entry in collection list
QSqlQuery query(m_databaseManager->getDatabase());
query.exec("INSERT INTO \"collections\" (\"name\") VALUES (\"Test\")");
//create tables and metadata
int cid = m_metadataEngine->createNewCollection();
//get id
query.exec("SELECT _id FROM collections WHERE name='Test'");
if (query.next()) {
id = query.value(0).toInt();
}
QVERIFY(id > 0);
QVERIFY(id == cid);
//get table names
query.exec("SELECT table_name FROM collections WHERE name='Test'");
if (query.next()) {
tableName = query.value(0).toString();
metadataTableName = tableName + "_metadata";
}
QVERIFY(!tableName.isEmpty());
//check if tables exist
query.exec(QString("SELECT name FROM sqlite_master WHERE type='table'"
" AND name='%1'").arg(tableName));
bool a = query.next();
QVERIFY(a);
QVERIFY(!query.value(0).toString().isEmpty());
query.exec(QString("SELECT name FROM sqlite_master WHERE type='table'"
" AND name='%1'").arg(metadataTableName));
bool b = query.next();
QVERIFY(b);
QVERIFY(!query.value(0).toString().isEmpty());
}
void MetadataEngineTest::testDeleteCollection()
{
int id = -1;
QString tableName;
QString metadataTableName;
QSqlQuery query(m_databaseManager->getDatabase());
//get id
query.exec("SELECT _id FROM collections WHERE name='Test'");
if (query.next()) {
id = query.value(0).toInt();
}
QVERIFY(id > 0);
query.clear(); //release query otherwise delete will fail
//create tables and metadata
m_metadataEngine->deleteCollection(id);
//get table names
query.exec("SELECT table_name FROM collections WHERE name='Test'");
if (query.next()) {
tableName = query.value(0).toString();
metadataTableName = tableName + "_metadata";
}
QVERIFY(!tableName.isEmpty());
//check if tables exist
query.exec(QString("SELECT name FROM sqlite_master WHERE type='table'"
" AND name='%1'").arg(tableName));
QVERIFY(!query.next());
query.exec(QString("SELECT name FROM sqlite_master WHERE type='table'"
" AND name='%1'").arg(metadataTableName));
QVERIFY(!query.next());
//remove collection from collections list
query.exec(QString("DELETE FROM collections WHERE _id=%1").arg(id));
}
void MetadataEngineTest::testCreateField()
{
QSqlQuery query(m_databaseManager->getDatabase());
QString fieldName("Test Field");
MetadataEngine::FieldType type = MetadataEngine::NumericType;
QString displayProperties = "prop:1;";
QString editProperties = "prop:1;";
QString triggerProperties = "prop:1;";
int fieldId = m_metadataEngine->createField(fieldName,
type,
displayProperties,
editProperties,
triggerProperties);
QVERIFY(fieldId != 0); //0 should be _id column
QVERIFY(fieldId == (m_metadataEngine->getFieldCount() - 1));
QVERIFY(fieldName == m_metadataEngine->getFieldName(fieldId));
QVERIFY(type == m_metadataEngine->getFieldType(fieldId));
QVERIFY(displayProperties ==
m_metadataEngine->getFieldProperties(MetadataEngine::DisplayProperty,
fieldId));
QVERIFY(editProperties ==
m_metadataEngine->getFieldProperties(MetadataEngine::EditProperty,
fieldId));
QVERIFY(triggerProperties ==
m_metadataEngine->getFieldProperties(MetadataEngine::TriggerProperty,
fieldId));
}
void MetadataEngineTest::testDeleteField()
{
QString fieldName2 = "Test2";
MetadataEngine::FieldType type2 = MetadataEngine::NumericType;
int fieldId2 = m_metadataEngine->createField(fieldName2,
type2,
"",
"",
"");
QString fieldName("Test Field");
int fieldId = 4; //hard coded I know :P
int fieldCount = m_metadataEngine->getFieldCount();
//delete Test Field
m_metadataEngine->deleteField(fieldId);
QVERIFY(m_metadataEngine->getFieldCount() == (fieldCount - 1));
QVERIFY(fieldName2 == m_metadataEngine->getFieldName(fieldId));
QVERIFY(m_metadataEngine->getFieldProperties(MetadataEngine::DisplayProperty,
fieldId).isEmpty());
QVERIFY(m_metadataEngine->getFieldProperties(MetadataEngine::EditProperty,
fieldId).isEmpty());
QVERIFY(m_metadataEngine->getFieldProperties(MetadataEngine::TriggerProperty,
fieldId).isEmpty());
//delete Test2
m_metadataEngine->deleteField(fieldId);
QVERIFY(m_metadataEngine->getFieldCount() == (fieldCount - 2));
QVERIFY("_invalid_column_name_" == m_metadataEngine->getFieldName(fieldId));
QVERIFY(m_metadataEngine->getFieldProperties(MetadataEngine::DisplayProperty,
fieldId).isEmpty());
QVERIFY(m_metadataEngine->getFieldProperties(MetadataEngine::EditProperty,
fieldId).isEmpty());
QVERIFY(m_metadataEngine->getFieldProperties(MetadataEngine::TriggerProperty,
fieldId).isEmpty());
}
void MetadataEngineTest::testModifyField()
{
QString fieldName("Test Field");
QString fieldName2("Test Mod Field");
MetadataEngine::FieldType type = MetadataEngine::NumericType;
QString displayProperties = "prop:1;";
QString editProperties = "prop:1;";
QString triggerProperties = "prop:1;";
QString displayProperties2 = "prop:2;";
QString editProperties2 = "prop:2;";
QString triggerProperties2 = "prop:2;";
int fieldId = m_metadataEngine->createField(fieldName,
type,
displayProperties,
editProperties,
triggerProperties);
//modify
m_metadataEngine->modifyField(fieldId, fieldName2,
displayProperties2,
editProperties2,
triggerProperties2);
//verify
QVERIFY(fieldName2 == m_metadataEngine->getFieldName(fieldId));
QVERIFY(displayProperties2 ==
m_metadataEngine->getFieldProperties(MetadataEngine::DisplayProperty,
fieldId));
QVERIFY(editProperties2 ==
m_metadataEngine->getFieldProperties(MetadataEngine::EditProperty,
fieldId));
QVERIFY(triggerProperties2 ==
m_metadataEngine->getFieldProperties(MetadataEngine::TriggerProperty,
fieldId));
//delete
m_metadataEngine->deleteField(fieldId);
}
void MetadataEngineTest::testFileMetadata()
{
QString fileName = "testFileName.txt";
QString hashName = "md5HashName.txt";
//add
int id = m_metadataEngine->addContentFile(fileName, hashName);
QVERIFY(id != 0);
//get id
QVERIFY(id == m_metadataEngine->getContentFileId(hashName));
//get
QString qFileName;
QString qHashName;
QDateTime qFileAddedDate;
bool s = m_metadataEngine->getContentFile(id, qFileName,
qHashName, qFileAddedDate);
QVERIFY(s);
QVERIFY(qFileName == fileName);
QVERIFY(qHashName == hashName);
QVERIFY(qFileAddedDate.isValid());
//update
QString a = "New name.txt";
QString b = "new_hash_md5.txt";
QDateTime c = QDateTime(QDate(1990,6,28));
m_metadataEngine->updateContentFile(id, a, b, c);
s = m_metadataEngine->getContentFile(id, qFileName,
qHashName, qFileAddedDate);
QVERIFY(s);
QVERIFY(qFileName == a);
QVERIFY(qHashName == b);
QVERIFY(qFileAddedDate == c);
//remove
m_metadataEngine->removeContentFile(id);
s = m_metadataEngine->getContentFile(id, qFileName,
qHashName, qFileAddedDate);
QVERIFY(!s);
//get all files
int x = m_metadataEngine->addContentFile(fileName, hashName);
int y = m_metadataEngine->addContentFile(a, b);
QHash<int,QString> map = m_metadataEngine->getAllContentFiles();
m_metadataEngine->removeContentFile(x);
m_metadataEngine->removeContentFile(y);
QVERIFY(map.size() == 2);
QVERIFY(map.value(x) == hashName);
QVERIFY(map.value(y) == b);
}
QTEST_APPLESS_MAIN(MetadataEngineTest)
#include "tst_metadataenginetest.moc"
| 34.686957
| 85
| 0.635435
|
DatabasesWorks
|
2a340eedb70e93dbac2193f8b0125757e80a0feb
| 4,051
|
cpp
|
C++
|
sdk/core/azure-core/test/ut/http.cpp
|
JasonYang-MSFT/azure-sdk-for-cpp
|
c0faea5f90c0d78f088f8c049353a2ee66ba3930
|
[
"MIT"
] | null | null | null |
sdk/core/azure-core/test/ut/http.cpp
|
JasonYang-MSFT/azure-sdk-for-cpp
|
c0faea5f90c0d78f088f8c049353a2ee66ba3930
|
[
"MIT"
] | 1
|
2021-02-23T00:43:57.000Z
|
2021-02-23T00:49:17.000Z
|
sdk/core/azure-core/test/ut/http.cpp
|
JasonYang-MSFT/azure-sdk-for-cpp
|
c0faea5f90c0d78f088f8c049353a2ee66ba3930
|
[
"MIT"
] | null | null | null |
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: MIT
#include "gtest/gtest.h"
#include <http/http.hpp>
#include <string>
#include <vector>
using namespace Azure::Core;
TEST(Http_Request, getters)
{
Http::HttpMethod httpMethod = Http::HttpMethod::Get;
std::string url = "http://test.url.com";
Http::Request req(httpMethod, url);
// EXPECT_PRED works better than just EQ because it will print values in log
EXPECT_PRED2(
[](Http::HttpMethod a, Http::HttpMethod b) { return a == b; }, req.GetMethod(), httpMethod);
EXPECT_PRED2([](std::string a, std::string b) { return a == b; }, req.GetEncodedUrl(), url);
EXPECT_NO_THROW(req.AddHeader("Name", "value"));
EXPECT_NO_THROW(req.AddHeader("naME2", "value2"));
auto headers = req.GetHeaders();
// Headers should be lower-cased
EXPECT_TRUE(headers.count("name"));
EXPECT_TRUE(headers.count("name2"));
EXPECT_FALSE(headers.count("newHeader"));
auto value = headers.find("name");
EXPECT_PRED2([](std::string a, std::string b) { return a == b; }, value->second, "value");
auto value2 = headers.find("name2");
EXPECT_PRED2([](std::string a, std::string b) { return a == b; }, value2->second, "value2");
// now add to retry headers
req.StartRetry();
// same headers first, then one new
EXPECT_NO_THROW(req.AddHeader("namE", "retryValue"));
EXPECT_NO_THROW(req.AddHeader("HEADER-to-Lower-123", "retryValue2"));
EXPECT_NO_THROW(req.AddHeader("newHeader", "new"));
headers = req.GetHeaders();
EXPECT_TRUE(headers.count("name"));
EXPECT_TRUE(headers.count("header-to-lower-123"));
EXPECT_TRUE(headers.count("newheader"));
value = headers.find("name");
EXPECT_PRED2([](std::string a, std::string b) { return a == b; }, value->second, "retryValue");
value2 = headers.find("header-to-lower-123");
EXPECT_PRED2([](std::string a, std::string b) { return a == b; }, value2->second, "retryValue2");
auto value3 = headers.find("newheader");
EXPECT_PRED2([](std::string a, std::string b) { return a == b; }, value3->second, "new");
}
TEST(Http_Request, query_parameter)
{
Http::HttpMethod httpMethod = Http::HttpMethod::Put;
std::string url = "http://test.com";
Http::Request req(httpMethod, url);
EXPECT_NO_THROW(req.AddQueryParameter("query", "value"));
EXPECT_PRED2(
[](std::string a, std::string b) { return a == b; },
req.GetEncodedUrl(),
url + "?query=value");
std::string url_with_query = "http://test.com?query=1";
Http::Request req_with_query(httpMethod, url_with_query);
// ignore if adding same query parameter key that is already in url
EXPECT_NO_THROW(req_with_query.AddQueryParameter("query", "value"));
EXPECT_PRED2(
[](std::string a, std::string b) { return a == b; },
req_with_query.GetEncodedUrl(),
url_with_query);
// retry query params testing
req.StartRetry();
// same query parameter should override previous
EXPECT_NO_THROW(req.AddQueryParameter("query", "retryValue"));
EXPECT_PRED2(
[](std::string a, std::string b) { return a == b; },
req.GetEncodedUrl(),
url + "?query=retryValue");
}
TEST(Http_Request, add_path)
{
Http::HttpMethod httpMethod = Http::HttpMethod::Post;
std::string url = "http://test.com";
Http::Request req(httpMethod, url);
EXPECT_NO_THROW(req.AppendPath("path"));
EXPECT_PRED2(
[](std::string a, std::string b) { return a == b; }, req.GetEncodedUrl(), url + "/path");
EXPECT_NO_THROW(req.AddQueryParameter("query", "value"));
EXPECT_PRED2(
[](std::string a, std::string b) { return a == b; },
req.GetEncodedUrl(),
url + "/path?query=value");
EXPECT_NO_THROW(req.AppendPath("path2"));
EXPECT_PRED2(
[](std::string a, std::string b) { return a == b; },
req.GetEncodedUrl(),
url + "/path/path2?query=value");
EXPECT_NO_THROW(req.AppendPath("path3"));
EXPECT_PRED2(
[](std::string a, std::string b) { return a == b; },
req.GetEncodedUrl(),
url + "/path/path2/path3?query=value");
}
| 34.042017
| 99
| 0.662552
|
JasonYang-MSFT
|
2a35ba2c64c78650b483bb976d85e5603b77018b
| 258
|
cpp
|
C++
|
Cpp_primer_5th/code_part9/prog9_34.cpp
|
Links789/Cpp_primer_5th
|
18a60b75c358a79fdf006f8cb978c9be6e6aedd5
|
[
"MIT"
] | null | null | null |
Cpp_primer_5th/code_part9/prog9_34.cpp
|
Links789/Cpp_primer_5th
|
18a60b75c358a79fdf006f8cb978c9be6e6aedd5
|
[
"MIT"
] | null | null | null |
Cpp_primer_5th/code_part9/prog9_34.cpp
|
Links789/Cpp_primer_5th
|
18a60b75c358a79fdf006f8cb978c9be6e6aedd5
|
[
"MIT"
] | null | null | null |
#include <iostream>
#include <vector>
using namespace std;
int main(){
vector<int> vi{1,2,3,4,5};
auto iter = vi.begin();
while(iter != vi.end() ){ //endless loo
iter = vi.insert(iter, *iter);
cout << *iter << endl;
}
++iter;
return 0;
}
| 14.333333
| 40
| 0.581395
|
Links789
|
2a3664d0d70d55544f209d77704c0f9a57ddff24
| 1,116
|
cpp
|
C++
|
mp/src/old/cl_dll/vgui_consolepanel.cpp
|
MaartenS11/Team-Fortress-Invasion
|
f36b96d27f834d94e0db2d2a9470b05b42e9b460
|
[
"Unlicense"
] | 1
|
2021-03-20T14:27:45.000Z
|
2021-03-20T14:27:45.000Z
|
mp/src/old/cl_dll/vgui_consolepanel.cpp
|
MaartenS11/Team-Fortress-Invasion
|
f36b96d27f834d94e0db2d2a9470b05b42e9b460
|
[
"Unlicense"
] | null | null | null |
mp/src/old/cl_dll/vgui_consolepanel.cpp
|
MaartenS11/Team-Fortress-Invasion
|
f36b96d27f834d94e0db2d2a9470b05b42e9b460
|
[
"Unlicense"
] | null | null | null |
//======== (C) Copyright 1999, 2000 Valve, L.L.C. All rights reserved. ========
//
// The copyright to the contents herein is the property of Valve, L.L.C.
// The contents may be used and/or copied only with the written permission of
// Valve, L.L.C., or in accordance with the terms and conditions stipulated in
// the agreement/contract under which the contents have been supplied.
//
// Purpose:
//
// $Workfile: $
// $Date: $
//
//-----------------------------------------------------------------------------
// $Log: $
//
// $NoKeywords: $
//=============================================================================
#include "cbase.h"
#include "iconsole.h"
class CConPanel;
class CConsole : public IConsole
{
private:
CConPanel *conPanel;
public:
CConsole( void )
{
conPanel = NULL;
}
void Create( vgui::VPANEL parent )
{
/*
conPanel = new CConPanel( parent );
*/
}
void Destroy( void )
{
/*
if ( conPanel )
{
conPanel->SetParent( (vgui::Panel *)NULL );
delete conPanel;
}
*/
}
};
static CConsole g_Console;
IConsole *console = ( IConsole * )&g_Console;
| 20.666667
| 79
| 0.543011
|
MaartenS11
|
2a3b854022134ea7d90ee72dcb8b39a2cad1e4a5
| 11,860
|
cpp
|
C++
|
src/native_extensions/process_manager_win.cpp
|
devcxx/zephyros
|
3ba2c63c5d11bfab66b896e8e09287e222f645a2
|
[
"Unlicense",
"MIT"
] | null | null | null |
src/native_extensions/process_manager_win.cpp
|
devcxx/zephyros
|
3ba2c63c5d11bfab66b896e8e09287e222f645a2
|
[
"Unlicense",
"MIT"
] | null | null | null |
src/native_extensions/process_manager_win.cpp
|
devcxx/zephyros
|
3ba2c63c5d11bfab66b896e8e09287e222f645a2
|
[
"Unlicense",
"MIT"
] | null | null | null |
/*******************************************************************************
* Copyright (c) 2015-2017 Vanamco AG, http://www.vanamco.com
*
* The MIT License (MIT)
* 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.
*
* Contributors:
* Matthias Christen, Vanamco AG
*******************************************************************************/
#include <tchar.h>
#include <Shlwapi.h>
#include <algorithm>
#include "lib/CrashRpt/CrashRpt.h"
#include "base/app.h"
#include "base/cef/client_handler.h"
#include "base/cef/extension_handler.h"
#include "util/string_util.h"
#include "native_extensions/os_util.h"
#include "native_extensions/process_manager.h"
//////////////////////////////////////////////////////////////////////////
// Constants
#define BUF_SIZE 8192
//////////////////////////////////////////////////////////////////////////
// Worker Thread Functions
extern CefRefPtr<Zephyros::ClientHandler> g_handler;
DWORD WINAPI ReadOutput(LPVOID param)
{
// install exception handlers for this thread
//const TCHAR* szCrashReportingURL = Zephyros::GetCrashReportingURL();
//if (szCrashReportingURL != NULL && szCrashReportingURL[0] != TCHAR('\0'))
// crInstallToCurrentThread2(0);
Zephyros::PipeData* p = (Zephyros::PipeData*) param;
DWORD numBytesRead;
DWORD numBytesAvail;
char buf[BUF_SIZE + 1];
for ( ; ; )
{
PeekNamedPipe(p->hndRead, NULL, 0, NULL, &numBytesAvail, NULL);
if (numBytesAvail == 0 && p->isTerminated)
break;
// read stdout of the process and process the output
ReadFile(p->hndRead, buf, BUF_SIZE, &numBytesRead, NULL);
if (numBytesRead > 0)
{
Zephyros::StreamDataEntry entry;
entry.type = p->type;
int nWcLen = MultiByteToWideChar(CP_UTF8, 0, (LPCCH) buf, numBytesRead, NULL, 0);
TCHAR* bufWc = new TCHAR[nWcLen + 1];
MultiByteToWideChar(CP_UTF8, 0, (LPCCH) buf, numBytesRead, bufWc, nWcLen);
bufWc[nWcLen] = 0;
entry.text = String(bufWc, bufWc + nWcLen);
EnterCriticalSection(&(p->pData->cs));
p->pData->stream.push_back(entry);
LeaveCriticalSection(&(p->pData->cs));
}
}
CloseHandle(p->hndRead);
CloseHandle(p->hndWrite);
// unset exception handlers before exiting the thread
//crUninstallFromCurrentThread();
return 0;
}
DWORD WINAPI WaitForProcessProc(LPVOID param)
{
Zephyros::ProcessManager* pMgr = (Zephyros::ProcessManager*) param;
DWORD dwExitCode = 0;
// wait until the process has terminated
WaitForSingleObject(pMgr->m_procInfo.hProcess, INFINITE);
GetExitCodeProcess(pMgr->m_procInfo.hProcess, &dwExitCode);
// wait until the reading threads have termiated
pMgr->m_in.isTerminated = true;
pMgr->m_out.isTerminated = true;
pMgr->m_err.isTerminated = true;
HANDLE handles[] = { pMgr->m_hReadOutThread, pMgr->m_hReadErrThread };
WaitForMultipleObjects(2, handles, TRUE, 1000);
CloseHandle(pMgr->m_procInfo.hProcess);
CloseHandle(pMgr->m_procInfo.hThread);
// return the result and clean up
pMgr->FireCallback((int) dwExitCode);
delete pMgr;
return 0;
}
//////////////////////////////////////////////////////////////////////////
// ProcessManager Implementation
namespace Zephyros {
ProcessManager::ProcessManager(CallbackId callbackId, String strExePath, std::vector<String> vecArgs, String strCWD, Error& err)
: m_callbackId(callbackId),
m_strExePath(strExePath),
m_vecArgs(vecArgs),
m_strCWD(strCWD),
m_error(&err)
{
InitializeCriticalSection(&m_data.cs);
if (m_strCWD == TEXT("~"))
m_strCWD = OSUtil::GetHomeDirectory();
}
ProcessManager::~ProcessManager()
{
DeleteCriticalSection(&m_data.cs);
}
bool ProcessManager::Start()
{
m_data.stream.clear();
m_in.isTerminated = false;
m_out.isTerminated = false;
m_err.isTerminated = false;
m_in.type = TYPE_STDIN;
m_out.type = TYPE_STDOUT;
m_err.type = TYPE_STDERR;
m_in.pData = &m_data;
m_out.pData = &m_data;
m_err.pData = &m_data;
if (ProcessManager::CreateProcess(m_strExePath, m_vecArgs, m_strCWD, NULL, &m_procInfo,
&m_in.hndRead, &m_in.hndWrite, &m_out.hndRead, &m_out.hndWrite, &m_err.hndRead, &m_err.hndWrite))
{
m_hReadOutThread = CreateThread(NULL, 0, ReadOutput, &m_out, 0, NULL);
m_hReadErrThread = CreateThread(NULL, 0, ReadOutput, &m_err, 0, NULL);
CreateThread(NULL, 0, WaitForProcessProc, this, 0, NULL);
return true;
}
// creating the process failed
m_error->FromLastError();
delete this;
return false;
}
void ProcessManager::FireCallback(int exitCode)
{
JavaScript::Array args = JavaScript::CreateArray();
JavaScript::Array stream = JavaScript::CreateArray();
int i = 0;
for (StreamDataEntry e : m_data.stream)
{
JavaScript::Object streamEntry = JavaScript::CreateObject();
streamEntry->SetInt(TEXT("fd"), e.type);
streamEntry->SetString(TEXT("text"), e.text);
stream->SetDictionary(i++, streamEntry);
}
args->SetNull(0);
args->SetInt(1, exitCode);
args->SetList(2, stream);
g_handler->GetClientExtensionHandler()->InvokeCallback(m_callbackId, args);
}
bool ProcessManager::CreateProcess(
String strExePath,
std::vector<String> vecArgs,
String strCWD,
LPVOID lpEnv,
PROCESS_INFORMATION* pProcInfo,
HANDLE* phStdinRead, HANDLE* phStdinWrite,
HANDLE* phStdoutRead, HANDLE* phStdoutWrite,
HANDLE* phStderrRead, HANDLE* phStderrWrite)
{
// create pipes
SECURITY_ATTRIBUTES sa;
sa.nLength = sizeof(SECURITY_ATTRIBUTES);
sa.bInheritHandle = TRUE;
sa.lpSecurityDescriptor = NULL;
HANDLE h1, h2, h3, h4;
if (phStdinRead == NULL)
phStdinRead = &h1;
if (phStdinWrite == NULL)
phStdinWrite = &h2;
if (phStdoutRead == NULL)
phStdoutRead = &h3;
if (phStdoutWrite == NULL)
phStdoutWrite = &h4;
if (phStderrRead == NULL)
phStderrRead = phStdoutRead;
if (phStderrWrite == NULL || phStderrRead == phStdoutRead)
phStderrWrite = phStdoutWrite;
CreatePipe(phStdinRead, phStdinWrite, &sa, 0);
SetHandleInformation(*phStdinWrite, HANDLE_FLAG_INHERIT, 0);
CreatePipe(phStdoutRead, phStdoutWrite, &sa, 0);
SetHandleInformation(*phStdoutRead, HANDLE_FLAG_INHERIT, 0);
if (phStderrRead != phStdoutRead)
{
CreatePipe(phStderrRead, phStderrWrite, &sa, 0);
SetHandleInformation(*phStderrRead, HANDLE_FLAG_INHERIT, 0);
}
// set up members of the PROCESS_INFORMATION structure
ZeroMemory(pProcInfo, sizeof(PROCESS_INFORMATION));
// set up members of the STARTUPINFO structure
// this structure specifies the STDIN and STDOUT handles for redirection
STARTUPINFO startupInfo;
ZeroMemory(&startupInfo, sizeof(STARTUPINFO));
startupInfo.cb = sizeof(STARTUPINFO);
startupInfo.hStdInput = *phStdinRead;
startupInfo.hStdOutput = *phStdoutWrite;
startupInfo.hStdError = *phStderrWrite;
startupInfo.wShowWindow = SW_HIDE;
startupInfo.dwFlags |= STARTF_USESHOWWINDOW | STARTF_USESTDHANDLES;
// prepare the command line
String cmdLine;
size_t pos = strExePath.find_last_of(TEXT('.'));
String extension = pos == String::npos ? TEXT("") : ToLower(strExePath.substr(pos));
bool usesComSpec = false;
if (extension != TEXT(".exe"))
{
// if this is no exe file, use "cmd.exe /C <file> <args>"
String cmd = ProcessManager::GetEnvVar(TEXT("ComSpec"));
bool hasSpaces = strExePath.find(TEXT(" ")) != String::npos;
cmdLine = cmd + TEXT(" /C \"");
if (hasSpaces)
cmdLine.append(TEXT("\""));
cmdLine.append(strExePath);
if (hasSpaces)
cmdLine.append(TEXT("\""));
strExePath = cmd;
usesComSpec = true;
}
else
{
// resolve the path if needed
if (strExePath.find(TEXT(":\\")) == String::npos)
ProcessManager::FindInPath(strExePath);
cmdLine = TEXT("\"") + strExePath + TEXT("\"");
}
// all arguments are wrapped in quotes, and quotes are escaped with double quotes
// escape '\"' by '\\""'
for (String arg : vecArgs)
{
bool hasSpacesOrQuotationMarks = (arg.find(TEXT(" ")) != String::npos) || (arg.find(TEXT("\"")) != String::npos);
if (hasSpacesOrQuotationMarks)
{
cmdLine.append(TEXT(" \""));
cmdLine.append(StringReplace(StringReplace(arg, TEXT("\""), TEXT("\"\"")), TEXT("\\\"\""), TEXT("\\\\\"\"")));
cmdLine.append(TEXT("\""));
}
else
{
cmdLine.append(TEXT(" "));
cmdLine.append(arg);
}
}
if (usesComSpec)
cmdLine.append(TEXT("\""));
#ifndef NDEBUG
App::Log(cmdLine);
#endif
// start the child process
TCHAR* szCmdLine = new TCHAR[cmdLine.length() + 1];
_tcscpy(szCmdLine, cmdLine.c_str());
BOOL bSuccess = ::CreateProcess(
strExePath.c_str(),
szCmdLine,
NULL,
NULL,
TRUE,
0,
lpEnv,
strCWD == TEXT("") ? NULL : strCWD.c_str(),
&startupInfo,
pProcInfo
);
delete[] szCmdLine;
if (!bSuccess)
App::ShowErrorMessage();
return bSuccess == TRUE;
}
void ProcessManager::FindInPath(String& strFile)
{
bool HasExtension = strFile.find(TEXT(".")) != String::npos;
StringStream ssPath(ProcessManager::GetEnvVar(TEXT("PATH")));
String path;
while (std::getline(ssPath, path, TEXT(';')))
{
String strFileWithPath = path;
if (path.at(path.length() - 1) != TEXT('\\'))
strFileWithPath += TEXT("\\");
strFileWithPath += strFile;
if (HasExtension && PathFileExists(strFileWithPath.c_str()))
{
strFile = strFileWithPath;
break;
}
String strFileWithPathAndExtension = strFileWithPath + TEXT(".exe");
if (PathFileExists(strFileWithPathAndExtension.c_str()))
{
strFile = strFileWithPathAndExtension;
break;
}
strFileWithPathAndExtension = strFileWithPath + TEXT(".bat");
if (PathFileExists(strFileWithPathAndExtension.c_str()))
{
strFile = strFileWithPathAndExtension;
break;
}
}
}
String ProcessManager::GetEnvVar(LPCTSTR strVarName)
{
DWORD dwLen = GetEnvironmentVariable(strVarName, NULL, 0);
TCHAR* pBuf = new TCHAR[dwLen + 1];
GetEnvironmentVariable(strVarName, pBuf, dwLen);
String str(pBuf);
delete[] pBuf;
return str;
}
} // namespace Zephyros
| 30.101523
| 128
| 0.626391
|
devcxx
|
2a3cc5850d3a481d73bb75f09bc6c57020260f4a
| 614
|
hpp
|
C++
|
AdenitaCoreSE/include/SEDSDNACreatorEditorDescriptor.hpp
|
edellano/Adenita-SAMSON-Edition-Win-
|
6df8d21572ef40fe3fc49165dfaa1d4318352a69
|
[
"BSD-3-Clause"
] | 2
|
2020-09-07T20:48:43.000Z
|
2021-09-03T05:49:59.000Z
|
AdenitaCoreSE/include/SEDSDNACreatorEditorDescriptor.hpp
|
edellano/Adenita-SAMSON-Edition-Linux
|
a7e267e5dd37e0073f4d1e3e603c5fb1c69a350a
|
[
"BSD-3-Clause"
] | 6
|
2020-04-05T18:39:28.000Z
|
2022-01-11T14:28:55.000Z
|
AdenitaCoreSE/include/SEDSDNACreatorEditorDescriptor.hpp
|
edellano/Adenita-SAMSON-Edition-Linux
|
a7e267e5dd37e0073f4d1e3e603c5fb1c69a350a
|
[
"BSD-3-Clause"
] | 2
|
2021-07-13T12:58:13.000Z
|
2022-01-11T13:52:00.000Z
|
/// \headerfile SBProxy.hpp "SBProxy.hpp"
#include "SBProxy.hpp"
/// \headerfile SEDSDNACreatorEditor.hpp "SEDSDNACreatorEditor.hpp"
#include "SEDSDNACreatorEditor.hpp"
// Class descriptor
// SAMSON Element generator pro tip: complete this descriptor to expose this class to SAMSON and other SAMSON Elements
SB_CLASS_BEGIN(SEDSDNACreatorEditor);
SB_CLASS_TYPE(SBCClass::Editor);
SB_CLASS_DESCRIPTION("DNA Creator : Add ssDNA and dsDNA");
SB_FACTORY_BEGIN;
SB_CONSTRUCTOR_0(SEDSDNACreatorEditor);
SB_FACTORY_END;
SB_INTERFACE_BEGIN;
SB_INTERFACE_END;
SB_CLASS_END(SEDSDNACreatorEditor);
| 21.172414
| 118
| 0.788274
|
edellano
|
2a3f1d0fb7dadf387ed900ab643d6f0132c964ad
| 4,771
|
cpp
|
C++
|
src/Prop.cpp
|
fauresystems/ArduinoProps
|
b6b94208f5d31e600ed5f4c6ccd45f8bedc46a52
|
[
"MIT"
] | null | null | null |
src/Prop.cpp
|
fauresystems/ArduinoProps
|
b6b94208f5d31e600ed5f4c6ccd45f8bedc46a52
|
[
"MIT"
] | null | null | null |
src/Prop.cpp
|
fauresystems/ArduinoProps
|
b6b94208f5d31e600ed5f4c6ccd45f8bedc46a52
|
[
"MIT"
] | null | null | null |
/*
Name: Prop.cpp
Author: Faure Systems <dev at faure dot systems>
Editor: https://github.com/fauresystems
License: MIT License (c) Faure Systems <dev at faure dot systems>
Base class to make prop sketch for Escape Room 2.0 (connected).
*/
#include "Prop.h"
#if defined(__AVR__)
#include <avr/wdt.h>
#endif
void PropCallback::run(char* topic, byte* payload, unsigned int len)
{
if (len)
{
char* p = (char*)malloc(len + 1);
memcpy(p, payload, len);
p[len] = '\0';
if (String(p) == "@PING")
client->publish(outbox, "PONG");
else
Prop::onInboxMessageReceived(p);
free(p);
}
}
void PropMessageReceived::run(String a)
{
client->publish(outbox, String("OMIT " + a).c_str());
}
Prop::Prop(const char* client_id, const char* in_box, const char* out_box, const char* broker, const int port)
{
clientId = client_id;
inbox = in_box;
outbox = out_box;
_nextReconAttempt = 0;
_dataSentCount = 0;
_maximumSilentPeriod = 30; // 30 seconds
_payloadMax = MQTT_MAX_PACKET_SIZE - (1 + 2 + strlen(Prop::outbox));
_brokerIpAddress.fromString(broker);
_client.setServer(_brokerIpAddress, port);
PropCallback::client = &_client;
PropCallback::outbox = outbox;
_client.setCallback(PropCallback::run);
PropMessageReceived::client = &_client;
PropMessageReceived::outbox = outbox;
_sendDataAction.reset(400); // check data changes every 400 milliseconds
}
void Prop::addData(PropData* d)
{
_dataTable.Add(d);
}
void Prop::loop()
{
if (_client.connected())
{
_client.loop();
}
else if (millis() > _nextReconAttempt)
{
_nextReconAttempt += 5000L;
if (_client.connect(clientId, outbox, 2, true, "DISCONNECTED"))
{
_client.publish(outbox, "CONNECTED", true);
_client.subscribe(inbox, 1); // max QoS is 1 for PubSubClient subsciption
_nextReconAttempt = 0L;
}
}
if (_sendDataAction.tick()) checkDataChanges(); // send data changes if any
}
void Prop::checkDataChanges()
{
if (_dataSentCount) {
sendDataChanges();
} else {
sendAllData();
}
++_dataSentCount;
// don't be silent to long
if (_dataSentCount > (_maximumSilentPeriod * 1000 / _sendDataAction.getInterval())) _dataSentCount = 0;
}
void Prop::resetMcu()
{
#if defined(ARDUINO_ARCH_SAMD) || defined(ARDUINO_ARCH_STM32)
NVIC_SystemReset();
#elif defined(ARDUINO_ARCH_AVR) || defined(__AVR__)
wdt_enable(WDTO_15MS);
while (true);
#endif
}
void Prop::sendAllData()
{
String data("DATA "), str;
for (int i = 0; i < _dataTable.Count(); i++) {
str = _dataTable[i]->fetch();
send(&data, &str);
}
if (data.length() > 5) {
_client.publish(outbox, data.c_str());
}
}
void Prop::sendDataChanges()
{
String data("DATA "), str;
for (int i = 0; i < _dataTable.Count(); i++) {
str = _dataTable[i]->fetchChange();
send(&data, &str);
}
if (data.length() > 5) {
_client.publish(outbox, data.c_str());
}
}
void Prop::send(String* d, String* s)
{
if (d->length() + s->length() <= _payloadMax) {
*d += *s;
} else if (s->length() > _payloadMax + 5) {
sendMesg(u8"Data ignored, loo larged to be sent");
} else if (d->length() + s->length() > _payloadMax) {
_client.publish(outbox, d->c_str());
*d = "DATA " + *s;
}
}
void Prop::sendData(String data) {
if (data.length() > 5) {
_client.publish(outbox, String("DATA " + data).c_str());
}
}
void Prop::sendDone(String action) {
_client.publish(outbox, String("DONE " + action).c_str());
}
void Prop::sendMesg(String mesg) {
if (mesg.length() > 5) {
_client.publish(outbox, String("MESG " + mesg).c_str());
}
}
void Prop::sendMesg(String mesg, char *topic) {
if (mesg.length() > 5) {
_client.publish(topic, String("MESG " + mesg).c_str());
}
}
void Prop::sendOmit(String action) {
_client.publish(outbox, String("OMIT " + action).c_str());
}
void Prop::sendOver(String challenge) {
_client.publish(outbox, String("OVER " + challenge).c_str());
}
void Prop::sendProg(String program) {
_client.publish(outbox, String("PROG " + program).c_str());
}
void Prop::sendRequ(String request) {
_client.publish(outbox, String("REQU " + request).c_str());
}
void Prop::sendRequ(String action, char* topic) {
_client.publish(topic, String("REQU " + action).c_str());
}
void Prop::resetIntervals(const int changes, const int silent)
{
_nextReconAttempt = 0;
_dataSentCount = 0;
_maximumSilentPeriod = silent; // seconds
_sendDataAction.reset(changes); // milliseconds
}
PubSubClient *PropCallback::client;
const char *PropCallback::outbox;
PubSubClient *PropMessageReceived::client;
const char *PropMessageReceived::outbox;
void (*Prop::onInboxMessageReceived)(String) = PropMessageReceived::run;
| 23.502463
| 110
| 0.656466
|
fauresystems
|
2a3f479e43bd5d826b012ae081234b5767e0c106
| 881
|
cpp
|
C++
|
src/c_handshake.cpp
|
DreamHacks/dd3d
|
4665cc6e55b415c48385c6b6279bb3fd5f8e4bc9
|
[
"MIT"
] | null | null | null |
src/c_handshake.cpp
|
DreamHacks/dd3d
|
4665cc6e55b415c48385c6b6279bb3fd5f8e4bc9
|
[
"MIT"
] | null | null | null |
src/c_handshake.cpp
|
DreamHacks/dd3d
|
4665cc6e55b415c48385c6b6279bb3fd5f8e4bc9
|
[
"MIT"
] | 5
|
2017-07-09T12:03:19.000Z
|
2022-02-09T09:37:36.000Z
|
#include "dd3d.h"
#include "connection.h"
#include "crypt.h"
#include "m_user.h"
#include "log.h"
#include "c_handshake.h"
bool c_handshake_handler(void* message, uint32_t message_size) {
bool rv = false;
if (message_size == 4 + RSA_SIZE) {
uint8_t key[RSA_SIZE];
int key_size = crypt_rsa_private_decrypt(utils_poniter_calc<uint8_t*>(message, 4), RSA_SIZE, key);
if (16 == key_size) {
char reply_data[32 + RSA_SIZE];
if (m_user_create_session(reply_data, key)) {
utils_xxtea_encrypt((uint8_t*)reply_data, 32, key);
key_size = crypt_rsa_private_encrypt(key, 16, utils_poniter_calc<uint8_t*>(reply_data, 32));
if (key_size != -1) {
connection_reply(reply_data, 32 + RSA_SIZE);
return true;
}
} else
syslog(LOG_ERR, "[ERROR]create session failed.\n");
} else {
syslog(LOG_ERR, "[ERROR]handshake failed.\n");
}
}
return rv;
}
| 28.419355
| 100
| 0.687855
|
DreamHacks
|
2a41e6153124ff7b2dd9a1452eb623b5b2378c4c
| 5,715
|
cpp
|
C++
|
applications/physbam/physbam-lib/Public_Library/PhysBAM_Solids/PhysBAM_Deformables/Collisions_And_Interactions/TRIANGLE_COLLISIONS_POINT_FACE_VISITOR.cpp
|
schinmayee/nimbus
|
170cd15e24a7a88243a6ea80aabadc0fc0e6e177
|
[
"BSD-3-Clause"
] | 20
|
2017-07-03T19:09:09.000Z
|
2021-09-10T02:53:56.000Z
|
applications/physbam/physbam-lib/Public_Library/PhysBAM_Solids/PhysBAM_Deformables/Collisions_And_Interactions/TRIANGLE_COLLISIONS_POINT_FACE_VISITOR.cpp
|
schinmayee/nimbus
|
170cd15e24a7a88243a6ea80aabadc0fc0e6e177
|
[
"BSD-3-Clause"
] | null | null | null |
applications/physbam/physbam-lib/Public_Library/PhysBAM_Solids/PhysBAM_Deformables/Collisions_And_Interactions/TRIANGLE_COLLISIONS_POINT_FACE_VISITOR.cpp
|
schinmayee/nimbus
|
170cd15e24a7a88243a6ea80aabadc0fc0e6e177
|
[
"BSD-3-Clause"
] | 9
|
2017-09-17T02:05:06.000Z
|
2020-01-31T00:12:01.000Z
|
//#####################################################################
// Copyright 2002-2007, Robert Bridson, Ronald Fedkiw, Eran Guendelman, Geoffrey Irving, Nipun Kwatra, Neil Molino, Andrew Selle, Jonathan Su, Joseph Teran.
// This file is part of PhysBAM whose distribution is governed by the license contained in the accompanying file PHYSBAM_COPYRIGHT.txt.
//#####################################################################
// Class TRIANGLE_COLLISIONS_POINT_FACE_VISITOR
//#####################################################################
#include <PhysBAM_Tools/Arrays/INDIRECT_ARRAY.h>
#include <PhysBAM_Tools/Arrays_Computations/SUMMATIONS.h>
#include <PhysBAM_Tools/Math_Tools/RANGE.h>
#include <PhysBAM_Geometry/Spatial_Acceleration/BOX_HIERARCHY_DEFINITION.h>
#include <PhysBAM_Solids/PhysBAM_Deformables/Collisions_And_Interactions/STRUCTURE_INTERACTION_GEOMETRY.h>
#include <PhysBAM_Solids/PhysBAM_Deformables/Collisions_And_Interactions/TRIANGLE_COLLISIONS_POINT_FACE_VISITOR.h>
#include <PhysBAM_Solids/PhysBAM_Deformables/Collisions_And_Interactions/TRIANGLE_REPULSIONS_AND_COLLISIONS_GEOMETRY.h>
#include <PhysBAM_Solids/PhysBAM_Deformables/Deformable_Objects/DEFORMABLE_BODY_COLLECTION.h>
#include <PhysBAM_Solids/PhysBAM_Deformables/Parallel_Computation/MPI_SOLIDS.h>
#include <PhysBAM_Solids/PhysBAM_Deformables/Particles/PARTICLES.h>
using namespace PhysBAM;
//#####################################################################
// Constructor
//#####################################################################
template<class TV> TRIANGLE_COLLISIONS_POINT_FACE_VISITOR<TV>::
TRIANGLE_COLLISIONS_POINT_FACE_VISITOR(ARRAY<VECTOR<int,d+1> >& pairs_internal,ARRAY<VECTOR<int,d+1> >& pairs_external,
const STRUCTURE_INTERACTION_GEOMETRY<TV>& particle_structure,const STRUCTURE_INTERACTION_GEOMETRY<TV>& face_structure,
const TRIANGLE_REPULSIONS_AND_COLLISIONS_GEOMETRY<TV>& geometry,const T collision_thickness,MPI_SOLIDS<TV>* mpi_solids)
:pairs_internal(pairs_internal),pairs_external(pairs_external),particle_active_indices(particle_structure.collision_particles.active_indices),
faces(face_structure.Face_Mesh_Object()->mesh.elements),X(geometry.deformable_body_collection.particles.X),
X_self_collision_free(geometry.X_self_collision_free),
collision_thickness(collision_thickness),point_box_modified(particle_structure.point_modified),face_box_modified(face_structure.Face_Modified()),
intersecting_point_face_pairs(geometry.intersecting_point_face_pairs),mpi_solids(mpi_solids)
{}
//#####################################################################
// Destructor
//#####################################################################
template<class TV> TRIANGLE_COLLISIONS_POINT_FACE_VISITOR<TV>::
~TRIANGLE_COLLISIONS_POINT_FACE_VISITOR()
{}
//#####################################################################
// Function Store
//#####################################################################
template<class TV> void TRIANGLE_COLLISIONS_POINT_FACE_VISITOR<TV>::
Store(const int point_index,const int face_index)
{
const VECTOR<int,d>& face_nodes=faces(face_index);int p=particle_active_indices(point_index);
if(face_nodes.Contains(p)) return;
TV dX_average=(T).5*(X(p)-X_self_collision_free(p)+ARRAYS_COMPUTATIONS::Average(X.Subset(face_nodes))-ARRAYS_COMPUTATIONS::Average(X_self_collision_free.Subset(face_nodes)));
RANGE<TV> box1=RANGE<TV>::Bounding_Box(X_self_collision_free(p)+dX_average,X(p));
RANGE<TV> box2=RANGE<TV>::Bounding_Box(X_self_collision_free.Subset(face_nodes))+dX_average;box2.Enlarge_Nonempty_Box_To_Include_Points(X.Subset(face_nodes));
if(!box1.Intersection(box2,collision_thickness)) return;
VECTOR<int,d+1> nodes=face_nodes.Insert(p,1);
if(intersecting_point_face_pairs.Size() && intersecting_point_face_pairs.Contains(nodes)) return;
if (mpi_solids){
VECTOR<PARTITION_ID,d+1> processors(mpi_solids->partition_id_from_particle_index.Subset(nodes));
int i; for(i=1;i<=d;i++) if (processors(i)!=processors(d+1)) {pairs_external.Append(nodes);return;}
pairs_internal.Append(nodes);}
else pairs_internal.Append(nodes);
}
//####################################################################
#define INSTANTIATION_HELPER(T,d) \
template struct TRIANGLE_COLLISIONS_POINT_FACE_VISITOR<VECTOR<T,d> >; \
template void BOX_HIERARCHY<VECTOR<T,d> >::Intersection_List<TRIANGLE_COLLISIONS_POINT_FACE_VISITOR<VECTOR<T,d> >,ZERO>(BOX_HIERARCHY<VECTOR<T,d> > const&, \
TRIANGLE_COLLISIONS_POINT_FACE_VISITOR<VECTOR<T,d> >&,ZERO) const; \
template void BOX_HIERARCHY<VECTOR<T,d> >::Intersection_List<BOX_VISITOR_MPI<TRIANGLE_COLLISIONS_POINT_FACE_VISITOR<VECTOR<T,d> > >,ZERO>( \
BOX_HIERARCHY<VECTOR<T,d> > const&,BOX_VISITOR_MPI<TRIANGLE_COLLISIONS_POINT_FACE_VISITOR<VECTOR<T,d> > >&,ZERO) const; \
template void BOX_HIERARCHY<VECTOR<T,d> >::Intersection_List<BOX_VISITOR_MPI<TRIANGLE_COLLISIONS_POINT_FACE_VISITOR<VECTOR<T,d> > >,T>(BOX_HIERARCHY<VECTOR<T,d> > const&, \
BOX_VISITOR_MPI<TRIANGLE_COLLISIONS_POINT_FACE_VISITOR<VECTOR<T,d> > >&,T) const; \
template void BOX_HIERARCHY<VECTOR<T,d> >::Intersection_List<TRIANGLE_COLLISIONS_POINT_FACE_VISITOR<VECTOR<T,d> >,T>(BOX_HIERARCHY<VECTOR<T,d> > const&, \
TRIANGLE_COLLISIONS_POINT_FACE_VISITOR<VECTOR<T,d> >&,T) const;
template struct TRIANGLE_COLLISIONS_POINT_FACE_VISITOR<VECTOR<float,1> >;
INSTANTIATION_HELPER(float,2);
INSTANTIATION_HELPER(float,3);
#ifndef COMPILE_WITHOUT_DOUBLE_SUPPORT
template struct TRIANGLE_COLLISIONS_POINT_FACE_VISITOR<VECTOR<double,1> >;
INSTANTIATION_HELPER(double,2);
INSTANTIATION_HELPER(double,3);
#endif
| 73.269231
| 178
| 0.712511
|
schinmayee
|
2a45f8f0806cb2aa41ad4988c5b187d4881018d1
| 1,300
|
hpp
|
C++
|
libs/core/include/fcppt/math/matrix/has_dim.hpp
|
pmiddend/fcppt
|
9f437acbb10258e6df6982a550213a05815eb2be
|
[
"BSL-1.0"
] | null | null | null |
libs/core/include/fcppt/math/matrix/has_dim.hpp
|
pmiddend/fcppt
|
9f437acbb10258e6df6982a550213a05815eb2be
|
[
"BSL-1.0"
] | null | null | null |
libs/core/include/fcppt/math/matrix/has_dim.hpp
|
pmiddend/fcppt
|
9f437acbb10258e6df6982a550213a05815eb2be
|
[
"BSL-1.0"
] | null | null | null |
// Copyright Carl Philipp Reh 2009 - 2018.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef FCPPT_MATH_MATRIX_HAS_DIM_HPP_INCLUDED
#define FCPPT_MATH_MATRIX_HAS_DIM_HPP_INCLUDED
#include <fcppt/math/size_type.hpp>
#include <fcppt/math/detail/dim_matches.hpp>
#include <fcppt/math/matrix/object_fwd.hpp>
#include <fcppt/config/external_begin.hpp>
#include <type_traits>
#include <fcppt/config/external_end.hpp>
namespace fcppt
{
namespace math
{
namespace matrix
{
/**
\brief Metafunction to check if a static matrix has the specified dimensions
\ingroup fcpptmathmatrix
\tparam Matrix A fcppt::math::matrix::object type
\tparam R The static row count
\tparam C The static column count
*/
template<
typename Matrix,
fcppt::math::size_type R,
fcppt::math::size_type C
>
struct has_dim;
template<
typename T,
fcppt::math::size_type R,
fcppt::math::size_type C,
typename S,
fcppt::math::size_type DR,
fcppt::math::size_type DC
>
struct has_dim<
fcppt::math::matrix::object<
T,
R,
C,
S
>,
DR,
DC
>
:
std::conjunction<
fcppt::math::detail::dim_matches<
DR,
R
>,
fcppt::math::detail::dim_matches<
DC,
C
>
>
{
};
}
}
}
#endif
| 16.25
| 76
| 0.719231
|
pmiddend
|
2a4634de99fe9c2e51c1b7786e27d524d5bf7fe6
| 6,482
|
cpp
|
C++
|
test/stream.cpp
|
jspaaks/cuda-wrapper
|
66262b819d55814d35cdb88a7eb9ab3b67fadaf0
|
[
"BSD-3-Clause"
] | null | null | null |
test/stream.cpp
|
jspaaks/cuda-wrapper
|
66262b819d55814d35cdb88a7eb9ab3b67fadaf0
|
[
"BSD-3-Clause"
] | null | null | null |
test/stream.cpp
|
jspaaks/cuda-wrapper
|
66262b819d55814d35cdb88a7eb9ab3b67fadaf0
|
[
"BSD-3-Clause"
] | null | null | null |
/*
* Copyright (C) 2020 Jaslo Ziska
*
* This file is part of cuda-wrapper.
*
* This software may be modified and distributed under the terms of the
* 3-clause BSD license. See accompanying file LICENSE for details.
*/
#define BOOST_TEST_MODULE stream
#include <boost/test/unit_test.hpp>
#include <algorithm>
#include <functional>
#include <random>
#include <cmath>
#include <cuda_wrapper/cuda_wrapper.hpp>
#include "test.hpp"
static const size_t BLOCKS = 4096;
static const size_t THREADS = 128;
extern cuda::function<void (double const*, double const*, double*)> kernel_add;
/*
* Both vectors with input numbers and the results are copied asynchronously.
* In addition both kernels are launched asynchronously.
*/
BOOST_AUTO_TEST_CASE(normal) {
using cuda::memory::device::vector;
namespace host = cuda::memory::host;
// create second function object from kernel_add
cuda::function<void (double const*, double const*, double*)> kernel_add2 = kernel_add;
// create two streams (both with default flags)
cuda::stream s1, s2(CU_STREAM_DEFAULT);
// streams should both be empty
BOOST_CHECK(s1.query() == true);
BOOST_CHECK(s2.query() == true);
cuda::config dim(BLOCKS, THREADS);
host::vector<double> h_a(BLOCKS * THREADS);
host::vector<double> h_b(h_a.size());
host::vector<double> h_c(h_a.size());
host::vector<double> h_d(h_a.size());
vector<double> d_a(h_a.size());
vector<double> d_b(h_a.size());
vector<double> d_c(h_a.size());
vector<double> d_d(h_a.size());
// create random number generator
std::default_random_engine gen;
std::uniform_real_distribution<double> rand(0, 1);
// generate random numbers
std::generate(h_a.begin(), h_a.end(), std::bind(rand, std::ref(gen)));
std::generate(h_b.begin(), h_b.end(), std::bind(rand, std::ref(gen)));
// copy data from host to device
// both vectors are copied asynchronously in two different streams
// copy the first vector in stream s1
cuda::copy_async(h_a.begin(), h_a.end(), d_a.begin(), s1);
// stream s1 should now be busy
BOOST_CHECK(s1.query() == false);
// copy the second vector in stream s2
cuda::copy_async(h_b.begin(), h_b.end(), d_b.begin(), s2);
// both streams should be busy
BOOST_CHECK(s1.query() == false);
BOOST_CHECK(s2.query() == false);
// wait for both copies to be complete
s1.synchronize();
s2.synchronize();
// both streams should be empty
BOOST_CHECK(s1.query() == true);
BOOST_CHECK(s2.query() == true);
// configure kernels (with two different streams)
kernel_add.configure(dim.grid, dim.block, s1);
kernel_add2.configure(dim.grid, dim.block, s2);
// launch kernel (in stream s1)
kernel_add(d_a, d_b, d_c);
// stream s1 should now be busy
BOOST_CHECK(s1.query() == false);
// launch kernel (in stream s2)
kernel_add2(d_a, d_b, d_d);
// both streams should now be busy
BOOST_CHECK(s1.query() == false);
BOOST_CHECK(s2.query() == false);
// calculate the result on the host
std::vector<double> result(h_a.size());
std::transform(h_a.begin(), h_a.end(), h_b.begin(), result.begin(), std::plus<double>());
// wait for kernels to finish (if they haven't already)
s1.synchronize();
s2.synchronize();
// both streams should be empty
BOOST_CHECK(s1.query() == true);
BOOST_CHECK(s2.query() == true);
// copy back result from device to host in stream s1
cuda::copy_async(d_c.begin(), d_c.end(), h_c.begin(), s1);
// stream s1 should now be busy
BOOST_CHECK(s1.query() == false);
// copy back result from device to host in stream s2
cuda::copy_async(d_d.begin(), d_d.end(), h_d.begin(), s2);
// both streams should now be busy
BOOST_CHECK(s1.query() == false);
BOOST_CHECK(s2.query() == false);
// wait for asynchronous copy to be finished
s1.synchronize();
s2.synchronize();
// both streams should now be empty
BOOST_CHECK(s1.query() == true);
BOOST_CHECK(s2.query() == true);
// check results
BOOST_CHECK_EQUAL_COLLECTIONS(result.begin(), result.end(), h_c.begin(), h_c.end());
BOOST_CHECK_EQUAL_COLLECTIONS(result.begin(), result.end(), h_d.begin(), h_d.end());
}
BOOST_AUTO_TEST_CASE(attach)
{
// create second function object from kernel_add
cuda::function<void (double const*, double const*, double*)> kernel_add2 = kernel_add;
// create two streams
cuda::stream s1;
cuda::stream s2;
// streams should both be empty
BOOST_CHECK(s1.query() == true);
BOOST_CHECK(s2.query() == true);
cuda::config dim(BLOCKS, THREADS);
// create vectors with managed memory
cuda::vector<double> a(BLOCKS * THREADS);
cuda::vector<double> b(a.size());
cuda::vector<double> c(a.size());
cuda::vector<double> d(a.size());
// attach data to stream s1
// a is not attached because it will be accessed by both streams s1 and s2
s1.attach(b.data());
s1.attach(c.data());
// attach data to stream s2
s2.attach(d.data());
// create random number generator
std::default_random_engine gen;
std::uniform_real_distribution<double> rand(0, 1);
// generate random numbers
std::generate(a.begin(), a.end(), std::bind(rand, std::ref(gen)));
std::generate(b.begin(), b.end(), std::bind(rand, std::ref(gen)));
// configure kernels (with two different streams)
kernel_add.configure(dim.grid, dim.block, s1);
kernel_add2.configure(dim.grid, dim.block, s2);
// launch kernel (in stream s1)
kernel_add(a, b, c);
// stream s1 should now be busy
BOOST_CHECK(s1.query() == false);
// launch kernel (in stream s2)
kernel_add2(a, b, d);
// both streams should now be busy
BOOST_CHECK(s1.query() == false);
BOOST_CHECK(s2.query() == false);
// calculate the results on the host
std::vector<double> result(a.size());
std::transform(a.begin(), a.end(), b.begin(), result.begin(), std::plus<double>());
// wait for kernels to finish (if they haven't already)
s1.synchronize();
s2.synchronize();
// both streams should be empty
BOOST_CHECK(s1.query() == true);
BOOST_CHECK(s2.query() == true);
// check results
BOOST_CHECK_EQUAL_COLLECTIONS(result.begin(), result.end(), c.begin(), c.end());
BOOST_CHECK_EQUAL_COLLECTIONS(result.begin(), result.end(), d.begin(), d.end());
}
| 30.28972
| 93
| 0.655199
|
jspaaks
|
2a46e9dac0560f9dbb529cb6ed9db8b91bb34790
| 44,789
|
cpp
|
C++
|
src/AM/CatalogInstance.cpp
|
fsaintjacques/cstore
|
3300a81c359c4a48e13ad397e3eb09384f57ccd7
|
[
"BSD-2-Clause"
] | 14
|
2016-07-11T04:08:09.000Z
|
2022-03-11T05:56:59.000Z
|
src/AM/CatalogInstance.cpp
|
ibrarahmad/cstore
|
3300a81c359c4a48e13ad397e3eb09384f57ccd7
|
[
"BSD-2-Clause"
] | null | null | null |
src/AM/CatalogInstance.cpp
|
ibrarahmad/cstore
|
3300a81c359c4a48e13ad397e3eb09384f57ccd7
|
[
"BSD-2-Clause"
] | 13
|
2016-06-01T10:41:15.000Z
|
2022-01-06T09:01:15.000Z
|
/* Copyright (c) 2005, Regents of Massachusetts Institute of Technology,
* Brandeis University, Brown University, and University of Massachusetts
* Boston. 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 Massachusetts Institute of Technology,
* Brandeis University, Brown University, or University of
* Massachusetts Boston 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 <iostream>
#include "CatalogInstance.h"
#include "CatalogInstanceBDB.h"
const string CatalogInstance::PROJECTIONS[ /*25*/ ]
= { "lineitem", "orders", "customers", "typetest",
"Q1_projection", "Q2_projection", "Q3_projection",
"Q4_projection", "Q5_projection", "Q6_projection", "Q7_projection",
"D1.data", "D1.shipdate", "D1.suppkey", "D2.data", "D3.data",
"D3.custkey", "D4.data", "D5.data", "D6.data", "D7.data",
"D9.data", "D8_projection", "D10_projection",
"MO_D6.data" };
const string CatalogInstance::TYPE_NAMES[ /*5*/ ]
= { "", "INTEGER", "FLOAT", "STRING", "STAR" };
const string CatalogInstance::COMPRESSION_NAMES[ /*7*/ ]
= { "", "COMPRESSION_TYPE1", "COMPRESSION_TYPE1A",
"COMPRESSION_TYPE2", "COMPRESSION_TYPE3",
"COMPRESSION_TYPE3A", "COMPRESSION_TYPE4" };
using namespace std;
CatalogInstance* CatalogInstance::catalog = NULL;
bool CatalogInstance::gottenCat = false;
DbEnv* CatalogInstance::dbEnv = NULL;
vector<AM*> *CatalogInstance::allocatedAMs = new vector<AM*>();
vector<Node*> *CatalogInstance::allocatedNodes = new vector<Node*>();
string MetaColumn::toString()
{
string mcs = "";
mcs += ("\tColumn: " + _name + ( isSorted() ? " is sorted " : " is NOT sorted" ) + " compression: " + CatalogInstance::COMPRESSION_NAMES[ _compression ] + " dataType: " + CatalogInstance::TYPE_NAMES[_dataType] + " indexes " + ( _numIndexes == 2 ? "2" : "1" ) + " fileName " + _fileName + " filenamWOS " + _fileNameWos + "\n");
return mcs;
}
MetaColumn::MetaColumn( string colName, int dataType, int compType,
int colNum, bool isSK )
{
_name = colName; //string(colName.c_str());
_compression = compType;
_dataType = dataType;
_columnNumber = colNum;
//_fileName = colName + "_mini.dat";
_fileName = colName;
_rosFileName = colName + "_full.ros";
//_fileNameWos = colName + "_full.wos";
_colPosition = colNum;
_isSortKey = isSK;
if ( _compression == COMPRESSION_TYPE2 ||
_compression == COMPRESSION_TYPE4 )
_sorted = false;
else
_sorted = true;
if ( _sorted )
_numIndexes = 2;
else
_numIndexes = 1;
}
void MetaColumn::setColCount( int cc )
{
_colCount = cc;
}
bool MetaProjection::appendTuple( char *tuple )
{
empty = false;
// curr_wos_page doubles up as page counter
int curr_offset = tuple_size*wos_tuple_count -
(WOS_PAGE_SIZE / tuple_size)*curr_wos_page * tuple_size;
//cout << " space " << tuple_size*wos_tuple_count << " WOS PAGE blah " << (WOS_PAGE_SIZE / tuple_size)*curr_wos_page << endl;
if ( curr_offset > WOS_PAGE_SIZE - tuple_size ) // spill into new page
{
curr_wos_page++;
/*if ( _col )
{
for ( int i = 0; i < num_fields+1; i++ )
wos_col_data[ i ].push_back( (char*)malloc( WOS_PAGE_SIZE ) );
}
else*/
wos_data.push_back( (char*)malloc( WOS_PAGE_SIZE ) ); //new char( WOS_PAGE_SIZE ) );
//new_page_counter++;
curr_offset = 0;
}
//else
{
//memcpy( fudge+ curr_offset, tuple, 4 );
/*if ( _col )
for ( int i = 0; i < num_fields+1; i++ )
{
//cout << " TRYING FOR i = " << i << endl;
memcpy( (char*)(wos_col_data[i][ curr_wos_page ])+curr_offset, tuple+i*sizeof(int), tuple_size );
}
else*/
memcpy( (char*)(wos_data[ curr_wos_page ])+curr_offset, tuple, tuple_size );
}
//char *blah = new char[ 100 ];
//char *bleh = new char[ 4 ];
//memcpy( bleh, &wos_tuple_count, 4 );
// update indices on timestamp and sort key
// current version will assume that first column (second value) is the skey
PageWriter::placeRecord( _db_storage_key, tuple, sizeof(int),
(char*)&wos_tuple_count, sizeof(int) );
PageWriter::placeRecord( _db_sort_key, tuple+sizeof(int), sizeof(int),
(char*)&wos_tuple_count, sizeof(int) );
wos_tuple_count++;
int z;
memcpy(&z, tuple+sizeof(int), sizeof(int) );
//cout << " second value " << z << " Placed " << wos_tuple_count << "th tuple " << " page is " << curr_wos_page << " offset " << curr_offset << " page size " << WOS_PAGE_SIZE << endl<< endl;
return true;
}
void MetaColumn::setColPosition( int cp )
{
_colPosition = cp;
}
/*
MetaColumn::MetaColumn( char *col, int dataType, int compType )
{w w
cout << "This constructor is active " << endl;
string s(col);
//_name = s;
MetaColumn::MetaColumn( s, dataType, compType );
//cout << " Ended constructor " << endl << " name? " << _name << " s? " << s << " col " << col << endl << endl;
}
*/
MetaColumn::~MetaColumn()
{
}
string MetaColumn::getName()
{
return _name;
}
bool MetaColumn::isSorted()
{
return _sorted;
}
int MetaColumn::getIndex()
{
return _columnNumber;
}
int MetaColumn::getEncodingType()
{
return _compression;
}
int MetaColumn::getDataType()
{
return _dataType;
}
MetaProjection::MetaProjection( string projName )
{
//cout << " MetaProjection " << _name << " created " << endl;
_name = RUNTIME_DATA + projName;
columnCounter = 0;
_primaryColumn = NULL;
// Moving shared BDB items.
// This is shared stuff for different WOS cursors.
// ROS BDB files are a separate issue!
_db_storage_key = new Db( NULL, 0 );
_db_sort_key = new Db( NULL, 0 );
// Sort key is not guaranteed to be unique. StorageKey has to be.
_db_sort_key->set_flags( DB_DUP );
// assume integers
_db_storage_key->set_bt_compare( ROSAM::compare_int );
_db_storage_key->set_error_stream( &cout );
// do not assume integers on sort key because key is multiple
// fields mended together.
// Actually, we do assume that sort key is now an integer
// but that will change, so segment should ask the catalog and
// decide on this here.
_db_sort_key->set_bt_compare( ROSAM::compare_int );
_db_sort_key->set_error_stream( &cout );
_db_storage_key->set_cachesize( 0, SMALL_CACHE_SIZE, 1 ); // 5Mb cache
//this is very much an open question. There is certainly no need
// to use a large page because we're only indexing storagekey to
// position. Data is stored outside of BDB.
_db_storage_key->set_pagesize( 4096 );
_db_sort_key->set_cachesize( 0, SMALL_CACHE_SIZE, 1 ); // 5Mb cache
_db_sort_key->set_pagesize( 4096 );
string store_k = (_name + ".storage_key");
if ( (_db_storage_key->open( NULL, (store_k.c_str()),NULL,
DB_BTREE, DB_CREATE, 0664) != 0 ))
cerr << "Failed to open table " << (store_k) << endl;
string sort_k = (_name + ".sort_key");
if ((_db_sort_key->open( NULL, (sort_k.c_str()), NULL,
DB_BTREE, DB_CREATE, 0664) != 0 ) )
cerr << "Failed to open table " << (sort_k) << endl;
}
ROSAM *MetaColumn::getROSAM()
{
// ROSAM
cout << " Create and return a ROSAM " << _fileName << " indexes " << _numIndexes << endl;
ROSAM *rosam = new ROSAM( _fileName+
(_fileName.rfind( ".ros" ) == string::npos ? ".ros" : ""),
_numIndexes);
CatalogInstance::allocatedAMs->push_back( rosam );
return ( rosam );
}
WOSAM *MetaColumn::getWOSAM()
{
// maybe can use _numIndices, but not about to check.
//
cout << " Parameters are (PLEASE check): total columns " << _colCount << " field " << _colPosition << endl;
WOSAM *wosam = new WOSAM( _fileNameWos, 2, _colCount, _colPosition );
CatalogInstance::allocatedAMs->push_back( wosam );
return (wosam);
}
MetaProjection::~MetaProjection()
{
for ( map<string, MetaColumn*>::iterator iter = _columns.begin();
iter != _columns.end(); iter++ )
delete iter->second;
}
void MetaProjection::addColumn( MetaColumn *mc )
{
/*
assert ( _columns.find( mc->getName() ) ==
_columns.end() );
*/
if ( !_primaryColumn )
_primaryColumn = mc;
// This assumes that columns are added in the order of
// the schema!
columnPosition = columnCounter;
columnCounter++;
_columns[ mc->getName() ] = mc;
_columnNameInOrder.push_back(mc->getName());
}
vector<string> *MetaProjection::getAllColumns()
{
vector<string> *cols = new vector<string>();
for ( map<string, MetaColumn*>::iterator iter = _columns.begin();
iter != _columns.end(); iter++ ){
cols->push_back( (iter->second)->getName() );
}
return cols;
}
vector<string> *MetaProjection::getAllColumnsInOrder()
{
vector<string> *cols = new vector<string>;
for (int i=0; i<(int) _columnNameInOrder.size(); i++)
{
cols->push_back(_columnNameInOrder[i]);
}
return cols;
}
vector<string> *MetaProjection::getSortOrderColumns()
{
vector<string> *cols = new vector<string>();
/*
for ( map<string, MetaColumn*>::iterator iter = _columns.begin();
iter != _columns.end(); iter++ )
{
if ( (iter->second)->isSortKey() )
cols->push_back( (iter->second)->getName() );
}
*/
for (int i=0; i<(int) _columnNameInOrder.size(); i++)
{
if ( _columns[_columnNameInOrder[i]]->isSortKey() )
cols->push_back(_columnNameInOrder[i]);
}
return cols;
}
MetaColumn* MetaProjection::getColumn( string name )
{
// This is inefficient and should change.
// column count is set every time getColumn is called.
//_columns[ name ]->setColCount( columnCounter );
// Again, hacky. But will only do this once on a get:
/* if ( !wos_data.size() )
{
int num_fields = columnCounter;
tuple_size = (num_fields+1)*sizeof(int);
//cout << "CatalogInstance:: Temporary message, col count is? " << num_fields << endl;
wos_data.push_back( (char*)malloc( WOS_PAGE_SIZE ) );
// Load pre-existing WOS.
// opening file for reading fails miserably if the file
// does not exist. So instead of non-existing file will
// make an empty one by touch.
system( ("touch " + _name + ".wos.TUPLES").c_str() );
FILE *wosfd = fopen((_name + ".wos.TUPLES").c_str(), "r");
char tuple[ (num_fields+1)*sizeof(int) ];
int counter = 0;
while (fread(tuple, 1, (num_fields+1)*sizeof(int), wosfd))
{
//cout << " READ TUPLE from file, count " << a << " REATD " << b << endl;
appendTuple( tuple );
counter++;
}
//if ( counter > 0 )
cout << " Loaded " << counter << " tuples from " + _name << endl;
}
*/
return _columns[ name ];
}
string MetaProjection::getPrimaryColumnName()
{
return _primaryColumn->getName();
}
string MetaProjection::getName()
{
return _name;
}
string MetaProjection::toString()
{
cout << " To String in MetaProjection " << endl;
//_name = NULL;
cout << " NAME " << _name << endl;
string mps = ("Projection: " + _name + ":\n\n");
for ( map<string, MetaColumn*>::iterator iter = _columns.begin();
iter != _columns.end(); iter++ )
mps += iter->second->toString();
return (mps + "\n");
}
CatalogInstance::CatalogInstance()
{
//original constructor loads projections/columns from static arrays
//now replaced with method getCatalogInstanceFromBDB()
//+
cout << "\tloading catalog from BDB files..." << endl;
this->loadCatalogFromBDB();
//-
//this->loadCatalog();
}
void CatalogInstance::loadCatalogFromBDB()
{
string bdbProjection = RUNTIME_DATA + CSTORE_SYSTABLE_PROJECTION;
PROJECTION_REC projRec;
BDBFile* f1 = new BDBFile(bdbProjection);
int rtrnCode = f1->open();
if (rtrnCode != 0) throw UnexpectedException("CatalogInstance: open projection file error");
void* v = f1->readFirstRec(&projRec.projectionID, sizeof(projRec.projectionID));
while (v != NULL) {
memcpy(&projRec, v, sizeof(PROJECTION_REC));
/*
cout.fill(' ');
cout.width(25);
cout.setf(ios_base::left , ios_base::adjustfield);
cout.setf(ios_base::dec, ios_base::basefield);
cout << projRec.projectionName
<< projRec.projectionID
<< projRec.tableID
<< projRec.primaryColumnID << endl;
*/
string sProj = projRec.projectionName;
_projections[ sProj ] = new MetaProjection( sProj );
v = f1->readNextRec();
}
int totProjection = f1->getRecordCount();
//----- loading column -----
COLUMN_REC colRec;
string bdbColumn = RUNTIME_DATA + CSTORE_SYSTABLE_COLUMN;
BDBFile* f2 = new BDBFile(bdbColumn, true);
//secondary index
string bdbColumnAK = RUNTIME_DATA + CSTORE_SYSTABLE_COLUMN_AK;
BDBFile* f3 = new BDBFile(bdbColumnAK, false);
rtrnCode = f2->dbHandle->associate(NULL, f3->dbHandle, altKeyCallBackProjectionID, 0);
if (rtrnCode != 0) throw UnexpectedException("CatalogInstance: associate error");
rtrnCode = f2->open();
if (rtrnCode != 0) throw UnexpectedException("CatalogInstance: open column file error");
rtrnCode = f3->open();
if (rtrnCode != 0) throw UnexpectedException("CatalogInstance: open column file error");
for (int i = 1; i <= totProjection; ++i) {
//cout << "\n\nread column(s) with projectionID " << i << endl;
int* pI = &i;
v = f3->readRec(pI, sizeof(int));
while (v != NULL) {
memcpy(&colRec, v, sizeof(COLUMN_REC));
/*
cout.fill(' ');
cout.width(25);
cout.setf(ios_base::left, ios_base::adjustfield);
cout.setf(ios_base::dec, ios_base::basefield);
cout << colRec.columnName;
cout << colRec.columnID;
cout << colRec.projectionID;
cout << colRec.dataType;
cout << colRec.compressionType;
cout << colRec.isStorageKey << endl;
*/
//get projection name
void* vdata = f1->readRec(pI, sizeof(projRec.projectionID));
if (vdata != NULL) {
memcpy(&projRec, vdata, sizeof(PROJECTION_REC));
} else {
throw UnexpectedException("CatalogInstance: read projection name error");
}
string s = projRec.projectionName;
//adding column to the container
_projections[ s ]->addColumn ( new MetaColumn(
colRec.columnName,
colRec.dataType,
colRec.compressionType,
colRec.columnID,
colRec.isStorageKey) );
v = f3->readNextRec(pI, sizeof(int));
}
}
//WOSManager* wm = new WOSManager( string(D6_DATA_WOS)+string(".dummy.dummy"), 2, 8 );
WOSManager* wm = new WOSManager( string(D6_DATA_WOS), 2, 8 );
//WOSManager* wm = new WOSManager( "RuntimeData/D10_dummy.wos", 2, 8 );
_wosManagers[ wm->getFileName() ] = wm;
_wosManagers[ "D6.data" ] = wm;
_wosManagers[ "Q1_projection" ] = wm;
_wosManagers[ "Q1_l_shipdate" ] = wm; // This is a slight naming hack
// a getWOS call that comes for Q1_l_shipdate column will return same
// as D6_DATA_WOS, because it is the same. Naming should be general
// most likely, the calling code should be fixed to substitute the
// projection name (?)
_wosManagers[ "Q1_l_shipdate" ] = wm;
_wosManagers[ "Q1_l_suppkey" ] = wm;
_wosManagers[ "Q1_l_orderkey" ] = wm;
_wosManagers[ "Q1_l_partkey" ] = wm;
_wosManagers[ "Q1_l_linenumber" ] = wm;
_wosManagers[ "Q1_l_quantity" ] = wm;
_wosManagers[ "Q1_l_extendedprice" ] = wm;
_wosManagers[ "Q1_l_returnflag" ] = wm;
_wosManagers[ "D6_l_shipdate" ] = wm;
_wosManagers[ "Q2_projection" ] = wm;
_wosManagers[ "Q2_l_suppkey" ] = wm;
_wosManagers[ "Q2_l_shipdate" ] = wm;
_wosManagers[ "Q2_l_orderkey" ] = wm;
_wosManagers[ "Q2_l_partkey" ] = wm;
_wosManagers[ "Q2_l_linenumber" ] = wm;
_wosManagers[ "Q2_l_quantity" ] = wm;
_wosManagers[ "Q2_l_extendedprice" ] = wm;
_wosManagers[ "Q2_l_returnflag" ] = wm;
_wosManagers[ "Q3_l_suppkey" ] = wm;
_wosManagers[ "Q3_l_shipdate" ] = wm;
_wosManagers[ "Q3_l_orderkey" ] = wm;
_wosManagers[ "Q3_l_partkey" ] = wm;
_wosManagers[ "Q3_l_linenumber" ] = wm;
_wosManagers[ "Q3_l_quantity" ] = wm;
_wosManagers[ "Q3_l_extendedprice" ] = wm;
_wosManagers[ "Q3_l_returnflag" ] = wm;
_wosManagers[ "D6_l_suppkey" ] = wm;
_wosManagers[ "D6_l_shipdate" ] = wm;
/*
D7.data.ros/wos:
(o_orderdate, l_suppkey, l_shipdate | o_orderdate, l_suppkey)
~= D2 from paper
*/
wm = new WOSManager( (string(D7_DATA_WOS)), 2, 3 );
_wosManagers[ wm->getFileName() ] = wm;
_wosManagers[ "D7.data" ] = wm;
_wosManagers[ "Q4_o_orderdate" ] = wm;
_wosManagers[ "Q5_o_orderdate" ] = wm;
_wosManagers[ "Q6_o_orderdate" ] = wm;
_wosManagers[ "Q4_l_shipdate" ] = wm;
_wosManagers[ "Q5_l_shipdate" ] = wm;
_wosManagers[ "Q6_l_shipdate" ] = wm;
_wosManagers[ "Q5_l_suppkey" ] = wm;
_wosManagers[ "Q6_l_suppkey" ] = wm;
wm = new WOSManager( D9_DATA_WOS, 2, 3 );
_wosManagers[ wm->getFileName() ] = wm;
_wosManagers[ "D9.data" ] = wm;
_wosManagers[ "Q7_c_nationkey" ] = wm;
_wosManagers[ "Q7_l_returnflag" ] = wm;
_wosManagers[ "Q7_l_extendedprice" ] = wm;
//wm = new WOSManager( "RuntimeData/D8_dummy.wos", 2, 8 );
wm = new WOSManager( D8_DATA_WOS, 2, 3 );
_wosManagers[ wm->getFileName() ] = wm;
_wosManagers[ "D8_projection" ] = wm;
_wosManagers[ "D8_orderdate" ] = wm;
_wosManagers[ "D8_custkey" ] = wm;
//wm = new WOSManager( "RuntimeData/D10_dummy.wos", 2, 2 );
wm = new WOSManager( D10_DATA_WOS, 2, 2 );
_wosManagers[ wm->getFileName() ] = wm;
_wosManagers[ "D10_projection" ] = wm;
_wosManagers[ "D10_nationkey" ] = wm;
_wosManagers[ "D10_custkey" ] = wm;
wm = new WOSManager( RUNTIME_DATA "MO_D6.data.wos", 2, 8 );
_wosManagers[ wm->getFileName() ] = wm;
_wosManagers[ "MO_D6.data" ] = wm;
_wosManagers[ "MO_D6_l_suppkey" ] = wm;
_wosManagers[ "MO_D6_l_shipdate" ] = wm;
_wosManagers[ "MO_D6_l_orderkey" ] = wm;
_wosManagers[ "MO_D6_l_partkey" ] = wm;
_wosManagers[ "MO_D6_l_linenumber"] = wm;
_wosManagers[ "MO_D6_l_returnflag" ] = wm;
_wosManagers[ "MO_D6_l_extendedprice"] = wm;
_wosManagers[ "MO_D6_l_quantity" ] = wm;
vector<string> *vec = NULL;
v = f1->readFirstRec(projRec.projectionName, sizeof(projRec.projectionName));
while (v != NULL) {
memcpy(&projRec, v, sizeof(PROJECTION_REC));
string s = projRec.projectionName;
vec = _projections[ s ]->getAllColumns();
for ( vector<string>::iterator iter = vec->begin(); iter != vec->end(); iter++ )
{
_allColumns[ (*iter) ] = _projections[ s ]->getColumn( (*iter) );
}
delete vec;
v = f1->readNextRec();
}
f1->close();
f3->close();
f2->close();
delete f1;
delete f2;
delete f3;
}
//original constructor load catalog from static arrays
void CatalogInstance::loadCatalog()
{
for ( unsigned int i = 0; i < sizeof( PROJECTIONS )/sizeof( string ); i ++ )
{
//cout << " PROJE " << PROJECTIONS[i] << endl;
_projections[ PROJECTIONS[i] ] = new MetaProjection( PROJECTIONS[i] );
}
_projections[ "lineitem" ]->addColumn
( new MetaColumn( "l_shipdate", TYPE_INTEGER, COMPRESSION_TYPE1, 1, true) );
_projections[ "lineitem" ]->addColumn
( new MetaColumn( "l_orderkey", TYPE_INTEGER, COMPRESSION_TYPE4, 2, false ) );
_projections[ "lineitem" ]->addColumn
( new MetaColumn( "l_returnflag", TYPE_STRING, COMPRESSION_TYPE4, 3, false ) );
_projections[ "lineitem" ]->addColumn
( new MetaColumn( "l_extendedprice", TYPE_INTEGER, COMPRESSION_TYPE4, 4, false ) );
_projections[ "lineitem" ]->addColumn
( new MetaColumn( "l_suppkey", TYPE_INTEGER, COMPRESSION_TYPE4, 5, false ) );
_projections[ "orders" ]->addColumn
( new MetaColumn( "o_orderdate", TYPE_INTEGER, COMPRESSION_TYPE1, 1, true) );
_projections[ "orders" ]->addColumn
( new MetaColumn( "o_orderkey", TYPE_INTEGER, COMPRESSION_TYPE4, 2, false ) );
_projections[ "orders" ]->addColumn
( new MetaColumn( "o_custkey", TYPE_INTEGER, COMPRESSION_TYPE4, 3, false ) );
_projections[ "customers" ]->addColumn
( new MetaColumn( "c_nationkey", TYPE_INTEGER, COMPRESSION_TYPE1, 1, true ) );
_projections[ "customers" ]->addColumn
( new MetaColumn( "c_custkey", TYPE_INTEGER, COMPRESSION_TYPE4, 2,false ) );
_projections[ "typetest" ]->addColumn
( new MetaColumn( "t_int", TYPE_INTEGER, COMPRESSION_TYPE4, 1, true ));
_projections[ "typetest" ]->addColumn
( new MetaColumn( "t_float", TYPE_FLOAT, COMPRESSION_TYPE4, 2, false ));
_projections[ "typetest" ]->addColumn
( new MetaColumn( "t_string", TYPE_STRING, COMPRESSION_TYPE4, 3, false ) );
_projections[ "Q1_projection" ]->addColumn
( new MetaColumn( "Q1_l_shipdate", TYPE_INTEGER, COMPRESSION_TYPE1, 1, true ) );
_projections["Q1_projection"]->addColumn
( new MetaColumn( "Q1_l_suppkey", TYPE_INTEGER, COMPRESSION_TYPE4,2, true ) );
_projections["Q1_projection"]->addColumn
( new MetaColumn( "Q1_l_orderkey", TYPE_INTEGER, COMPRESSION_TYPE4,3, false ) );
_projections["Q1_projection"]->addColumn
( new MetaColumn( "Q1_l_partkey", TYPE_INTEGER, COMPRESSION_TYPE4,4, false ) );
_projections["Q1_projection"]->addColumn
( new MetaColumn( "Q1_l_linenumber", TYPE_INTEGER, COMPRESSION_TYPE4,5, false ) );
_projections["Q1_projection"]->addColumn
( new MetaColumn( "Q1_l_quantity", TYPE_INTEGER, COMPRESSION_TYPE4,6, false ) );
_projections["Q1_projection"]->addColumn
( new MetaColumn( "Q1_l_extendedprice",TYPE_INTEGER, COMPRESSION_TYPE4,7, false ));
_projections["Q1_projection"]->addColumn
( new MetaColumn( "Q1_l_returnflag", TYPE_STRING, COMPRESSION_TYPE4,8, false ) );
_projections["Q2_projection"]->addColumn
( new MetaColumn("Q2_l_shipdate", TYPE_INTEGER, COMPRESSION_TYPE1, 1, true ) );
_projections["Q2_projection"]->addColumn
( new MetaColumn("Q2_l_suppkey", TYPE_INTEGER, COMPRESSION_TYPE4, 2, false ) );
_projections["Q2_projection"]->addColumn
( new MetaColumn( "Q2_l_orderkey", TYPE_INTEGER, COMPRESSION_TYPE4,3, false ) );
_projections["Q2_projection"]->addColumn
( new MetaColumn( "Q2_l_partkey", TYPE_INTEGER, COMPRESSION_TYPE4,4, false ) );
_projections["Q2_projection"]->addColumn
( new MetaColumn( "Q2_l_linenumber", TYPE_INTEGER, COMPRESSION_TYPE4,5, false ) );
_projections["Q2_projection"]->addColumn
( new MetaColumn( "Q2_l_quantity", TYPE_INTEGER, COMPRESSION_TYPE4,6, false ) );
_projections["Q2_projection"]->addColumn
( new MetaColumn( "Q2_l_extendedprice",TYPE_INTEGER, COMPRESSION_TYPE4,7, false ));
_projections["Q2_projection"]->addColumn
( new MetaColumn( "Q2_l_returnflag", TYPE_STRING, COMPRESSION_TYPE4,8, false ) );
_projections["Q3_projection"]->addColumn
( new MetaColumn("Q3_l_shipdate", TYPE_INTEGER, COMPRESSION_TYPE1,1, true) );
_projections["Q3_projection"]->addColumn
( new MetaColumn("Q3_l_suppkey", TYPE_INTEGER, COMPRESSION_TYPE4,2, true ) );
_projections["Q3_projection"]->addColumn
( new MetaColumn( "Q3_l_orderkey", TYPE_INTEGER, COMPRESSION_TYPE4,3, false ) );
_projections["Q3_projection"]->addColumn
( new MetaColumn( "Q3_l_partkey", TYPE_INTEGER, COMPRESSION_TYPE4,4, false ) );
_projections["Q3_projection"]->addColumn
( new MetaColumn( "Q3_l_linenumber", TYPE_INTEGER, COMPRESSION_TYPE4,5, false ) );
_projections["Q3_projection"]->addColumn
( new MetaColumn( "Q3_l_quantity", TYPE_INTEGER, COMPRESSION_TYPE4,6, false ) );
_projections["Q3_projection"]->addColumn
( new MetaColumn( "Q3_l_extendedprice",TYPE_INTEGER, COMPRESSION_TYPE4,7, false ));
_projections["Q3_projection"]->addColumn
( new MetaColumn( "Q3_l_returnflag", TYPE_STRING, COMPRESSION_TYPE4,8, false ) );
_projections["Q4_projection"]->addColumn
( new MetaColumn("Q4_o_orderdate", TYPE_INTEGER, COMPRESSION_TYPE1,1, true ) );
// not used in the query, inserted for continuity. Can probably not have
// this entry at all (second column)
// Big mistake. Q4_l_shipdate is in fact 2nd column in the data file!
// Never mind, this was fixed.
_projections["Q4_projection"]->addColumn
( new MetaColumn("Q4_l_suppkey", TYPE_INTEGER, COMPRESSION_TYPE4,2, false ));
_projections["Q4_projection"]->addColumn
( new MetaColumn("Q4_l_shipdate", TYPE_INTEGER, COMPRESSION_TYPE4,3, false ) );
_projections["Q5_projection"]->addColumn
( new MetaColumn("Q5_o_orderdate", TYPE_INTEGER, COMPRESSION_TYPE1,1, true ) );
_projections["Q5_projection"]->addColumn
( new MetaColumn("Q5_l_suppkey", TYPE_INTEGER, COMPRESSION_TYPE4,2, true ));
_projections["Q5_projection"]->addColumn
( new MetaColumn( "Q5_l_shipdate", TYPE_INTEGER, COMPRESSION_TYPE4,3, false ) );
_projections["Q6_projection"]->addColumn
( new MetaColumn("Q6_o_orderdate", TYPE_INTEGER, COMPRESSION_TYPE1,1, true ) );
_projections["Q6_projection"]->addColumn
( new MetaColumn("Q6_l_suppkey", TYPE_INTEGER, COMPRESSION_TYPE4,2, true ) );
_projections["Q6_projection"]->addColumn
( new MetaColumn("Q6_l_shipdate" , TYPE_INTEGER, COMPRESSION_TYPE4,3, false ) );
_projections["Q7_projection"]->addColumn
( new MetaColumn("Q7_l_returnflag", TYPE_INTEGER, COMPRESSION_TYPE1,1, true ) );
_projections["Q7_projection"]->addColumn
( new MetaColumn("Q7_l_extendedprice",TYPE_INTEGER, COMPRESSION_TYPE4, 2, false ));
_projections["Q7_projection"]->addColumn
( new MetaColumn("Q7_c_nationkey", TYPE_INTEGER, COMPRESSION_TYPE4, 3, false ) );
_projections["D1.data"]->addColumn
( new MetaColumn("Q7_l_returnflag", TYPE_INTEGER, COMPRESSION_TYPE1,1, true ) );
/*
These files can be found in the
wosrosplay
directory on sorrel.
D6.data.ros/wos:
(l_shipdate, l_suppkey, l_orderkey, l_partkey, l_linenumber, l_quantity,
l_extendedprice, l_returnflag | l_shipdate, l_suppkey)
*/
_projections["D6.data"]->addColumn
( new MetaColumn( "D6_l_shipdate", TYPE_INTEGER, COMPRESSION_TYPE1,1, true ) );
_projections["D6.data"]->addColumn
( new MetaColumn( "D6_l_suppkey", TYPE_INTEGER, COMPRESSION_TYPE4,2, true ) );
_projections["D6.data"]->addColumn
( new MetaColumn( "D6_l_orderkey", TYPE_INTEGER, COMPRESSION_TYPE4,3, false ) );
_projections["D6.data"]->addColumn
( new MetaColumn( "D6_l_partkey", TYPE_INTEGER, COMPRESSION_TYPE4,4, false ) );
_projections["D6.data"]->addColumn
( new MetaColumn( "D6_l_linenumber", TYPE_INTEGER, COMPRESSION_TYPE4,5, false ) );
_projections["D6.data"]->addColumn
( new MetaColumn( "D6_l_quantity", TYPE_INTEGER, COMPRESSION_TYPE4,6, false ) );
_projections["D6.data"]->addColumn
( new MetaColumn( "D6_l_extendedprice",TYPE_INTEGER, COMPRESSION_TYPE4,7, false ));
_projections["D6.data"]->addColumn
( new MetaColumn( "D6_l_returnflag", TYPE_STRING, COMPRESSION_TYPE4,8, false ) );
//WOSManager* wm = new WOSManager( string(D6_DATA_WOS)+string(".dummy.dummy"), 2, 8 );
WOSManager* wm = new WOSManager( string(D6_DATA_WOS), 2, 8 );
//WOSManager* wm = new WOSManager( "RuntimeData/D10_dummy.wos", 2, 8 );
_wosManagers[ wm->getFileName() ] = wm;
_wosManagers[ "D6.data" ] = wm;
_wosManagers[ "Q1_projection" ] = wm;
_wosManagers[ "Q1_l_shipdate" ] = wm; // This is a slight naming hack
// a getWOS call that comes for Q1_l_shipdate column will return same
// as D6_DATA_WOS, because it is the same. Naming should be general
// most likely, the calling code should be fixed to substitute the
// projection name (?)
_wosManagers[ "Q1_l_shipdate" ] = wm;
_wosManagers[ "Q1_l_suppkey" ] = wm;
_wosManagers[ "Q1_l_orderkey" ] = wm;
_wosManagers[ "Q1_l_partkey" ] = wm;
_wosManagers[ "Q1_l_linenumber" ] = wm;
_wosManagers[ "Q1_l_quantity" ] = wm;
_wosManagers[ "Q1_l_extendedprice" ] = wm;
_wosManagers[ "Q1_l_returnflag" ] = wm;
_wosManagers[ "D6_l_shipdate" ] = wm;
_wosManagers[ "Q2_projection" ] = wm;
_wosManagers[ "Q2_l_suppkey" ] = wm;
_wosManagers[ "Q2_l_shipdate" ] = wm;
_wosManagers[ "Q2_l_orderkey" ] = wm;
_wosManagers[ "Q2_l_partkey" ] = wm;
_wosManagers[ "Q2_l_linenumber" ] = wm;
_wosManagers[ "Q2_l_quantity" ] = wm;
_wosManagers[ "Q2_l_extendedprice" ] = wm;
_wosManagers[ "Q2_l_returnflag" ] = wm;
_wosManagers[ "Q3_l_suppkey" ] = wm;
_wosManagers[ "Q3_l_shipdate" ] = wm;
_wosManagers[ "Q3_l_orderkey" ] = wm;
_wosManagers[ "Q3_l_partkey" ] = wm;
_wosManagers[ "Q3_l_linenumber" ] = wm;
_wosManagers[ "Q3_l_quantity" ] = wm;
_wosManagers[ "Q3_l_extendedprice" ] = wm;
_wosManagers[ "Q3_l_returnflag" ] = wm;
_wosManagers[ "D6_l_suppkey" ] = wm;
_wosManagers[ "D6_l_shipdate" ] = wm;
/*
D7.data.ros/wos:
(o_orderdate, l_suppkey, l_shipdate | o_orderdate, l_suppkey)
~= D2 from paper
*/
_projections[ "D7.data" ]->addColumn
( new MetaColumn( "D7_o_orderdate", TYPE_INTEGER, COMPRESSION_TYPE1,1, true ));
_projections[ "D7.data" ]->addColumn
( new MetaColumn( "D7_l_suppkey", TYPE_INTEGER, COMPRESSION_TYPE4,2, true ));
_projections[ "D7.data" ]->addColumn
( new MetaColumn( "D7_l_shipdate", TYPE_INTEGER, COMPRESSION_TYPE4,3, false ));
wm = new WOSManager( (string(D7_DATA_WOS)), 2, 3 );
_wosManagers[ wm->getFileName() ] = wm;
_wosManagers[ "D7.data" ] = wm;
_wosManagers[ "Q4_o_orderdate" ] = wm;
_wosManagers[ "Q5_o_orderdate" ] = wm;
_wosManagers[ "Q6_o_orderdate" ] = wm;
_wosManagers[ "Q4_l_shipdate" ] = wm;
_wosManagers[ "Q5_l_shipdate" ] = wm;
_wosManagers[ "Q6_l_shipdate" ] = wm;
_wosManagers[ "Q5_l_suppkey" ] = wm;
_wosManagers[ "Q6_l_suppkey" ] = wm;
_projections[ "D9.data" ]->addColumn
( new MetaColumn( "D9_o_orderdate", TYPE_INTEGER, COMPRESSION_TYPE1,1, true ));
_projections[ "D9.data" ]->addColumn
( new MetaColumn( "D9_l_suppkey", TYPE_INTEGER, COMPRESSION_TYPE4,2, true ));
_projections[ "D9.data" ]->addColumn
( new MetaColumn( "D9_l_shipdate", TYPE_INTEGER, COMPRESSION_TYPE4,3, false ));
wm = new WOSManager( D9_DATA_WOS, 2, 3 );
_wosManagers[ wm->getFileName() ] = wm;
_wosManagers[ "D9.data" ] = wm;
_wosManagers[ "Q7_c_nationkey" ] = wm;
_wosManagers[ "Q7_l_returnflag" ] = wm;
_wosManagers[ "Q7_l_extendedprice" ] = wm;
_projections[ "D8_projection" ]->addColumn
( new MetaColumn( "D8_orderdate", TYPE_INTEGER, COMPRESSION_TYPE4,1, true ));
_projections[ "D8_projection" ]->addColumn
( new MetaColumn( "D8_custkey", TYPE_INTEGER, COMPRESSION_TYPE4,2, false ));
_projections[ "D10_projection" ]->addColumn
( new MetaColumn( "D10_custkey", TYPE_INTEGER, COMPRESSION_TYPE4,1, true ));
_projections[ "D10_projection" ]->addColumn
( new MetaColumn( "D10_nationkey", TYPE_INTEGER, COMPRESSION_TYPE4,2, false ));
//wm = new WOSManager( "RuntimeData/D8_dummy.wos", 2, 8 );
wm = new WOSManager( D8_DATA_WOS, 2, 3 );
_wosManagers[ wm->getFileName() ] = wm;
_wosManagers[ "D8_projection" ] = wm;
_wosManagers[ "D8_orderdate" ] = wm;
_wosManagers[ "D8_custkey" ] = wm;
//wm = new WOSManager( "RuntimeData/D10_dummy.wos", 2, 2 );
wm = new WOSManager( D10_DATA_WOS, 2, 2 );
_wosManagers[ wm->getFileName() ] = wm;
_wosManagers[ "D10_projection" ] = wm;
_wosManagers[ "D10_nationkey" ] = wm;
_wosManagers[ "D10_custkey" ] = wm;
/*
MERGE OUT STUFF
*/
_projections["MO_D6.data"]->addColumn
( new MetaColumn( "MO_D6_l_shipdate", TYPE_INTEGER, COMPRESSION_TYPE1,1, true ) );
_projections["MO_D6.data"]->addColumn
( new MetaColumn( "MO_D6_l_suppkey", TYPE_INTEGER, COMPRESSION_TYPE4,2, true ) );
_projections["MO_D6.data"]->addColumn
( new MetaColumn( "MO_D6_l_orderkey", TYPE_INTEGER, COMPRESSION_TYPE4,3, false ) );
_projections["MO_D6.data"]->addColumn
( new MetaColumn( "MO_D6_l_partkey", TYPE_INTEGER, COMPRESSION_TYPE4,4, false ) );
_projections["MO_D6.data"]->addColumn
( new MetaColumn( "MO_D6_l_linenumber", TYPE_INTEGER, COMPRESSION_TYPE4,5, false ) );
_projections["MO_D6.data"]->addColumn
( new MetaColumn( "MO_D6_l_quantity", TYPE_INTEGER, COMPRESSION_TYPE4,6, false ) );
_projections["MO_D6.data"]->addColumn
( new MetaColumn( "MO_D6_l_extendedprice",TYPE_INTEGER, COMPRESSION_TYPE4,7, false ));
_projections["MO_D6.data"]->addColumn
( new MetaColumn( "MO_D6_l_returnflag", TYPE_STRING, COMPRESSION_TYPE4,8, false ) );
wm = new WOSManager( RUNTIME_DATA "MO_D6.data.wos", 2, 8 );
_wosManagers[ wm->getFileName() ] = wm;
_wosManagers[ "MO_D6.data" ] = wm;
_wosManagers[ "MO_D6_l_suppkey" ] = wm;
_wosManagers[ "MO_D6_l_shipdate" ] = wm;
_wosManagers[ "MO_D6_l_orderkey" ] = wm;
_wosManagers[ "MO_D6_l_partkey" ] = wm;
_wosManagers[ "MO_D6_l_linenumber"] = wm;
_wosManagers[ "MO_D6_l_returnflag" ] = wm;
_wosManagers[ "MO_D6_l_extendedprice"] = wm;
_wosManagers[ "MO_D6_l_quantity" ] = wm;
vector<string> *vec = NULL;
for ( unsigned int i = 0; i < sizeof( PROJECTIONS )/sizeof( string ); i ++ )
{
vec = _projections[ PROJECTIONS[i] ]->getAllColumns();
for ( vector<string>::iterator iter = vec->begin(); iter != vec->end(); iter++ )
{
_allColumns[ (*iter) ] = _projections[ PROJECTIONS[i] ]->getColumn( (*iter) );
}
delete vec;
}
}
CatalogInstance::~CatalogInstance()
{
for ( map<string, MetaProjection*>::iterator iter = _projections.begin();
iter != _projections.end(); iter++ )
{
if ( iter->second == NULL )
delete iter->second;
}
}
bool CatalogInstance::isSorted( string projName, string colName )
{
if ( _projections.find( projName ) == _projections.end() )
return false;
if ( _allColumns.find( colName ) == _allColumns.end() )
{
// throw exception
return false;
}
return _projections[ projName ]->getColumn( colName )->isSorted();
}
int CatalogInstance::getColumnIndex( string projName, string colName )
{
if ( _projections.find( projName ) == _projections.end() )
return -1;
if ( _allColumns.find( colName ) == _allColumns.end() )
{
// throw exception
cerr << "Column " << colName << " does not seem to be a column " << endl;
return -1;
}
return _projections[ projName ]->getColumn( colName )->getIndex();
}
bool CatalogInstance::isSorted( string colName )
{
if ( _allColumns.find( colName ) == _allColumns.end() )
{
// throw exception
return false;
}
return _allColumns[ colName ]->isSorted();
}
bool CatalogInstance::isValidProjection(string projName)
{
return ( _projections.find( projName ) != _projections.end() );
}
bool CatalogInstance::isColumnOf(string projName, string colName)
{
if ( isValidProjection( projName ) )
return ( _allColumns.find( colName ) != _allColumns.end() );
return false;
}
vector<string> *CatalogInstance::getSortOrderColumns( string projName )
{
return _projections[ projName ]->getSortOrderColumns();
}
string CatalogInstance::getPrimaryColumnName( string projName )
{
if ( _projections.find( projName ) == _projections.end() )
return NULL;
return _projections[ projName ]->getPrimaryColumnName();
}
int CatalogInstance::getEncodingType( string projName, string colName )
{
if ( _projections.find( projName ) == _projections.end() )
return -1;
if ( _allColumns.find( colName ) == _allColumns.end() )
{
// throw exception
return -1;
}
return _projections[ projName ]->getColumn( colName )->getEncodingType();
}
/*void CatalogInstance::setAlias( string alias ) {
m_sAlias = alias;
}
*/
string CatalogInstance::toString()
{
string cis = "";
for ( map<string, MetaProjection*>::iterator iter = _projections.begin();
iter != _projections.end(); iter++ )
cis += iter->second->toString();
return cis;
}
ROSAM *CatalogInstance::getROSAM( string projName, string colName)
{
if ( _projections.find( projName ) == _projections.end() )
{
cerr << " Looking for proj (and not finding it) " << projName << " name " << colName << endl;
return NULL;
}
if ( _allColumns.find( colName ) == _allColumns.end() )
{
// throw exception
cerr << " Looking for proj (and not finding it) " << projName << " name " << colName << endl;
return NULL;
}
return _projections[ projName ]->getColumn( colName )->getROSAM();
}
ROSAM *CatalogInstance::getROSAM( string colName)
{
//cout << "CATALOG: get ROSAM for " << colName << endl;
if ( _allColumns.find( colName ) == _allColumns.end() )
{
cerr << "Catalog: no such column: " << colName << endl;
// throw exception
return NULL;
}
return _allColumns[ colName ]->getROSAM();
}
WOSAM *CatalogInstance::getWOSAM( string projName, string colName)
{
// cout << " CALL on " << projName << " col name " << colName << " position " << _allColumns[ colName ]->getColumnPosition() << endl;
return _wosManagers[ (CatalogInstance::stripOffDirectory( projName )/* + string(".wos")*/) ]->getWOSAM( _allColumns[ colName ]->getColumnPosition() );
/*if ( _projections.find( projName ) == _projections.end() )
return NULL;
if ( _allColumns.find( colName ) == _allColumns.end() )
{
// throw exception
return NULL;
}
//cout << "Temporary Notice: getting proj " << projName << " column " << colName << endl;
return _projections[ projName ]->getColumn( colName )->getWOSAM();
*/
}
WOSAM *CatalogInstance::getWOSAM( string colName)
{
if ( _allColumns.find( colName ) == _allColumns.end() )
{
// throw exception
return NULL;
}
//cout << "Temporary Notice: getting proj column " << colName << endl;
return _allColumns[ colName ]->getWOSAM();
}
WOSAM *CatalogInstance::getWOSAM( string colName, int colIndex )
{
//cout << "Temporary Notice: getting proj column " << (CatalogInstance::stripOffDirectory( colName )) << " from " << colName << endl;
return _wosManagers[ (CatalogInstance::stripOffDirectory( colName ) /*+ string(".wos")*/) ]->getWOSAM( colIndex );
}
DVAM *CatalogInstance::getDVAM( string colName, bool ros )
{
//cout << "Temporary Notice: getting proj column " << (CatalogInstance::stripOffDirectory( colName ) + string(".wos")) << endl;
return _wosManagers[ (CatalogInstance::stripOffDirectory( colName ) /*+ string(".wos")*/) ]->getDVAM( ros );
}
WOSManager *CatalogInstance::getWOSManager( string colName )
{
return _wosManagers[ (CatalogInstance::stripOffDirectory( colName ) /*+ string(".wos")*/) ];
}
WOSAM *CatalogInstance::getWOSAM( int colIndex )
{
return _wosManagers[ "D6.data.wos" ]->getWOSAM( colIndex );
}
int CatalogInstance::getColumnType( string colName )
{
if ( _allColumns.find( colName ) == _allColumns.end() )
{
throw UnexpectedException("No such column exists");
}
return _allColumns[ colName ]->getDataType();
}
int CatalogInstance::getColumnType( string projName, string colName )
{
if ( _projections.find( projName ) == _projections.end() )
{
return 0;
}
return _projections[ projName ]->getColumn(colName)->getDataType();
}
string CatalogInstance::stripOffDirectory( string fName )
{
string s = fName;
int loc = s.rfind("/", string::npos);
if(s.rfind("/", string::npos) != string::npos)
return s.substr(loc+1);
else
return fName;
}
static bool getCat() {
return CatalogInstance::gottenCat;
}
static CatalogInstance* getCatalog()
{
if ( !CatalogInstance::catalog ) {
CatalogInstance::catalog = new CatalogInstance();
CatalogInstance::gottenCat=true;
}
return CatalogInstance::catalog;
}
vector<string> *CatalogInstance::getColumnNames( string projName )
{
if ( _projections.find( projName ) == _projections.end() )
{
cout << " Failed to find column names for " << projName << endl;
return new vector<string>();
}
return _projections[ projName ]->getAllColumns();
}
vector<string> *CatalogInstance::getColumnNamesInOrder( string projName )
{
if ( _projections.find( projName ) == _projections.end() )
{
cout << " Failed to find column names for " << projName << endl;
return new vector<string>();
}
return _projections[ projName ]->getAllColumnsInOrder();
}
void CatalogInstance::disposeOfWOS( WOSAM *wos )
{
cout << " Dispose of " << wos->getTableName() << endl;
//this migth become more complicated eventually.
if ( wos )
delete wos;
cout << "End Dispose" << endl;
}
void CatalogInstance::disposeOfROS( ROSAM *ros )
{
cout << " Dispose of " << ros->getTableName() << endl;
if ( ros )
delete ros;
cout << "End Dispose" << endl;
}
void CatalogInstance::disposeOfDV ( DVAM *dvam )
{
cout << " Dispose of " << dvam->getTableName() << endl;
/*if ( dvam )
delete dvam;*/
}
list<TVariable*> CatalogInstance::getColumns()
{
vector<string> *cols;
if( m_listTuples.empty() )
{
cols = _projections[ m_sProjName ]->getAllColumns();
for ( vector<string>::iterator iter = cols->begin();
iter != cols->end(); iter++ )
m_listTuples.push_front( getCol( *iter ) );
delete cols;
}
return m_listTuples;
}
CatalogInstance* CatalogInstance::getCatalog()
{
if ( !CatalogInstance::catalog )
{
CatalogInstance::catalog = new CatalogInstance();
CatalogInstance::gottenCat=true;
/*
try
{
CatalogInstance::dbEnv = new DbEnv( 0 );
CatalogInstance::dbEnv->open( ".DbCache",
DB_INIT_MPOOL | DB_CREATE| DB_PRIVATE,
0644 ); // DB_THREAD Not necessary yet?
//CatalogInstance::dbEnv->set_verbose( DB_VERB_REPLICATION, true );
//CatalogInstance::dbEnv->set_cachesize( 0, (10*CACHE_SIZE), 10 );
CatalogInstance::dbEnv->set_cachesize(2, 524288000, 3 );
CatalogInstance::dbEnv->set_data_dir( "." );
CatalogInstance::dbEnv->set_tmp_dir( ".tempDB" );
// DB and other code goes here
}
catch(DbException &e)
{
// DB error handling goes here
cout << "CatalogInstance::getCatalog(), exception: -" << e.what() << " -" << e.get_errno() << "-" << endl;
//char *a = new char[ 100 ];
//bzero( a, 100 );
//CatalogInstance::dbEnv->get_home( (const char **)&a );
//cout << " DB " << string( a ) << endl;
}
*/
}
return CatalogInstance::catalog;
}
void CatalogInstance::deallocAMs()
{
for ( vector<AM*>::iterator iter = CatalogInstance::allocatedAMs->begin();
iter != CatalogInstance::allocatedAMs->end(); iter++ )
{
//uncomment this line will cause exception if you're deleting DVAM
//cout << " deleting AM " << (*iter)->getColumnName() << endl;
delete (*iter);
}
CatalogInstance::allocatedAMs->clear();
}
bool CatalogInstance::getCat() {
return CatalogInstance::gottenCat;
}
TVariable* CatalogInstance::getCol( string name )
{
TVariable* lpTVariable = TVariable::create( m_projection, name, _projections[ m_sProjName ]->getColumn( name )->getDataType() );
return lpTVariable;
}
// Nga: for plan node memory management
void CatalogInstance::addAllocatedNode(Node* lpNode)
{
CatalogInstance::allocatedNodes->push_back(lpNode);
}
void CatalogInstance::deallocNodes()
{
for ( vector<Node*>::iterator iter = CatalogInstance::allocatedNodes->begin();
iter != CatalogInstance::allocatedNodes->end(); iter++ )
{
cout << " deleting Node " << (*iter)->getNodeID() << endl;
delete (*iter);
}
CatalogInstance::allocatedNodes->clear();
}
| 33.549813
| 330
| 0.666458
|
fsaintjacques
|
2a513e5ab77fc89931a095b7e07b743e045f68ce
| 2,807
|
hpp
|
C++
|
src/sprite.hpp
|
gulrak/lostcolonies
|
ba47bbb3b642fbde9c87670666d02f288cfe7984
|
[
"MIT"
] | 1
|
2022-02-03T20:42:24.000Z
|
2022-02-03T20:42:24.000Z
|
src/sprite.hpp
|
gulrak/lostcolonies
|
ba47bbb3b642fbde9c87670666d02f288cfe7984
|
[
"MIT"
] | null | null | null |
src/sprite.hpp
|
gulrak/lostcolonies
|
ba47bbb3b642fbde9c87670666d02f288cfe7984
|
[
"MIT"
] | null | null | null |
#pragma once
#include <raylib.h>
#include <algorithm>
#include <vector>
#include "raymath.hpp"
struct Sprite
{
enum Type { Unused, Alien, Player, ColonyShip, AlienShot, AlienBomb, PlayerShot, DotParticle };
Type _type{Unused};
Vector2 _pos{};
Vector2 _velocity{};
Rectangle _sprite{};
Rectangle _sprite2{};
Color _col{WHITE};
float _age{0};
Texture* _texture{nullptr};
Image* _image{nullptr};
Vector2 _posAlt{-1000,-1000};
std::vector<Vector3> _flightPath{};
void update(float dt_s)
{
_pos.x += _velocity.x * dt_s;
_pos.y += _velocity.y * dt_s;
//if(!_flightPath)
}
void draw(bool drawAlternative = false) const
{
if(drawAlternative && _sprite2.width) {
DrawTextureRec(*_texture, _sprite2, _pos, _col);
}
else {
DrawTextureRec(*_texture, _sprite, _pos, _col);
}
}
void draw(Vector2 offset, bool drawAlternative = false) const
{
if(offset.y + _pos.y + _sprite.height > 0 && offset.y + _pos.y < 400) {
if(drawAlternative && _sprite2.width) {
DrawTextureRec(*_texture, _sprite2, offset + _pos, _col);
}
else {
DrawTextureRec(*_texture, _sprite, offset + _pos, _col);
}
}
}
Vector2 screenToSpriteCoordinates(const Vector2& screenCoordinates) const
{
return Vector2Add(Vector2Subtract(screenCoordinates, _pos), {_sprite.x, _sprite.y});
}
bool isCollidingRect(const Sprite& other)
{
return CheckCollisionRecs({_pos.x, _pos.y, _sprite.width, _sprite.height}, {other._pos.x, other._pos.y, other._sprite.width, other._sprite.height});
}
bool isColliding(const Sprite& other)
{
if(!isCollidingRect(other)) {
return false;
}
Rectangle overlap{};
overlap.x = std::max(_pos.x, other._pos.x);
overlap.width = std::min(_pos.x + _sprite.width, other._pos.x + other._sprite.width) - overlap.x;
overlap.y = std::max(_pos.y, other._pos.y);
overlap.height = std::min(_pos.y + _sprite.height, other._pos.y + other._sprite.height) - overlap.y;
for (int x = overlap.x; x < int(overlap.x + overlap.width); ++x) {
for (int y = overlap.y; y < int(overlap.y + overlap.height); ++y) {
auto pos1 = screenToSpriteCoordinates({float(x), float(y)});
auto c1 = GetImageColor(*_image, pos1.x, pos1.y);
auto pos2 = other.screenToSpriteCoordinates({float(x), float(y)});
auto c2 = GetImageColor(*_image, pos2.x, pos2.y);
if (c1.a > 128 && c2.a > 128) {
return true;
}
}
}
return false;
}
};
| 32.639535
| 156
| 0.576772
|
gulrak
|
2a55eca06e121661d59d4d4095424ee625cddfb3
| 6,514
|
cpp
|
C++
|
source/console/Console.cpp
|
mkapusnik/duel6r
|
1e5ed50035b1c2878622c9129ee8255a5abf9227
|
[
"BSD-3-Clause"
] | 12
|
2015-06-21T14:57:53.000Z
|
2021-11-30T23:32:27.000Z
|
source/console/Console.cpp
|
mkapusnik/duel6r
|
1e5ed50035b1c2878622c9129ee8255a5abf9227
|
[
"BSD-3-Clause"
] | 37
|
2015-01-04T18:21:13.000Z
|
2020-11-02T15:50:38.000Z
|
source/console/Console.cpp
|
mkapusnik/duel6r
|
1e5ed50035b1c2878622c9129ee8255a5abf9227
|
[
"BSD-3-Clause"
] | 10
|
2015-03-12T23:31:31.000Z
|
2020-02-25T23:19:44.000Z
|
/*
* Copyright (c) 2006, Ondrej Danek (www.ondrej-danek.net)
* 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 Ondrej Danek 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.
*/
/*
Projekt: Konzole
Popis: Hlavni funkce
*/
#include <stdlib.h>
#include <string.h>
#include "ConsoleException.h"
#include "Console.h"
namespace Duel6 {
Console::Console(Uint32 flags) {
visible = false;
insert = false;
curpos = 0;
inputscroll = 0;
this->flags = flags;
histcnt = 0;
histscroll = 0;
width = CON_DEF_WIDTH;
show = CON_DEF_SHOWLAST;
text.resize(CON_TEXT_SIZE);
clear();
printLine("==========================");
printLine(CON_Lang("Console -- author O.Danek"));
printLine(CON_Format(CON_Lang("Version {0}")) << CON_VERSION);
printLine("==========================");
}
Console::~Console() {
vars.clear();
cmds.clear();
aliases.clear();
}
void Console::clear() {
bufpos = 0;
scroll = 0;
buffull = false;
memset(&text[0], '\n', CON_TEXT_SIZE);
}
Console &Console::print(const std::string &str) {
for (size_t pos = 0; pos < str.length(); ++pos) {
char tx = str[pos];
switch (tx) {
case '\n':
text[bufpos++] = tx;
break;
case '\t':
for (int i = 0; i < CON_TAB_WIDTH; i++, bufpos++) {
text[bufpos % CON_TEXT_SIZE] = ' ';
}
break;
default:
if (tx >= ' ') {
text[bufpos++] = tx;
}
break;
}
if (bufpos >= CON_TEXT_SIZE) {
bufpos -= CON_TEXT_SIZE;
buffull = true;
}
}
scroll = 0;
return *this;
}
Console &Console::printLine(const std::string &str) {
print(str);
print("\n");
return *this;
}
void Console::verifyRegistration(const std::string &proc, const std::string &name, bool isNull) {
if (name.empty()) {
D6_THROW(ConsoleException, CON_Format(CON_Lang("{0} : cannot register empty name")) << proc);
}
if (findCommand(name) != nullptr || findVar(name) != nullptr || findAlias(name) != nullptr) {
D6_THROW(ConsoleException,
CON_Format(CON_Lang("{0} : name \"{1}\" is already registered")) << proc << name);
}
if (isNull) {
D6_THROW(ConsoleException,
CON_Format(CON_Lang("{0} : attempt to register \"{1}\" with null pointer")) << proc << name);
}
}
void Console::registerCommand(const std::string &name, Command command) {
verifyRegistration(CON_Lang("Command registration"), name, !command);
CommandRecord newCommand(name, command);
// Zaradi novy prikaz tak, aby byly setridene podle abecedy
size_t position = 0;
for (const CommandRecord &cmd : cmds) {
if (cmd.getName().compare(name) > 0) {
break;
}
++position;
}
cmds.insert(cmds.begin() + position, newCommand);
if (hasFlag(RegInfoFlag)) {
print(CON_Format(CON_Lang("Command registration: \"{0}\" has been successful\n")) << name);
}
}
void Console::registerAlias(const std::string &name, const std::string &cmd) {
AliasRecord *a = findAlias(name);
if (a == nullptr) {
verifyRegistration(CON_Lang("Alias registration"), name, false);
AliasRecord newAlias(name, cmd);
// Zaradi novy alias tak, aby byly setridene podle abecedy
size_t position = 0;
for (const AliasRecord &alias : aliases) {
if (alias.getName().compare(name) > 0) {
break;
}
++position;
}
aliases.insert(aliases.begin() + position, newAlias);
} else {
a->setCommand(cmd);
}
if (hasFlag(RegInfoFlag)) {
print(CON_Format(CON_Lang("Alias registration: \"{0}\" as \"{1}\" has been successful\n")) << name << cmd);
}
}
Console::CommandRecord *Console::findCommand(const std::string &name) {
for (CommandRecord &command : cmds) {
if (command.getName() == name) {
return &command;
}
}
return nullptr;
}
Console::AliasRecord *Console::findAlias(const std::string &name) {
for (AliasRecord &alias : aliases) {
if (alias.getName() == name) {
return &alias;
}
}
return nullptr;
}
void Console::setLast(int sl) {
show = sl > 1 ? sl : 2;
}
const Uint8 *Console::getText(Size &bufPos, bool &bufFull) const {
bufPos = bufpos;
bufFull = buffull;
return &text[0];
}
}
| 32.08867
| 119
| 0.558336
|
mkapusnik
|
3985f0535f179aaf2cb072470e1acdf442469f85
| 8,868
|
cc
|
C++
|
ftr/label.cc
|
louis-tru/Ngui
|
c1f25d8b6c42e873d5969fb588af22f428c58d4c
|
[
"BSD-3-Clause-Clear"
] | 86
|
2017-11-21T01:05:30.000Z
|
2020-05-21T12:30:31.000Z
|
ftr/label.cc
|
louis-tru/Ngui
|
c1f25d8b6c42e873d5969fb588af22f428c58d4c
|
[
"BSD-3-Clause-Clear"
] | 14
|
2020-10-16T11:30:57.000Z
|
2021-04-16T06:10:06.000Z
|
ftr/label.cc
|
louis-tru/Ngui
|
c1f25d8b6c42e873d5969fb588af22f428c58d4c
|
[
"BSD-3-Clause-Clear"
] | 13
|
2017-11-21T10:18:53.000Z
|
2019-10-18T09:15:55.000Z
|
/* ***** BEGIN LICENSE BLOCK *****
* Distributed under the BSD license:
*
* Copyright (c) 2015, xuewen.chu
* 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 xuewen.chu 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 xuewen.chu 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.
*
* ***** END LICENSE BLOCK ***** */
#include "label.h"
#include "layout.h"
#include "app.h"
#include "display-port.h"
#include "text-rows.h"
FX_NS(ftr)
class Label::Inl: public Label {
public:
#define _inl(self) static_cast<Label::Inl*>(self)
template<TextAlign T>
FX_INLINE void end_line(Cell& cell, float baseline, float descender, float max_offset) {
uint count = cell.offset.length() - 1;
if ( count ) { /* 结束上一行 */
switch (T) {
default: cell.offset_start = 0; break; // LEFT
case TextAlign::CENTER:
cell.offset_start = -max_offset / 2.0;
break;
case TextAlign::RIGHT:
cell.offset_start = -max_offset;
break;
case TextAlign::LEFT_REVERSE:
cell.reverse = 1;
cell.offset_start = max_offset;
break;
case TextAlign::CENTER_REVERSE:
cell.reverse = 1;
cell.offset_start = max_offset / 2.0;
break;
case TextAlign::RIGHT_REVERSE:
cell.reverse = 1;
cell.offset_start = max_offset;
break;
}
cell.baseline = baseline;
m_data.cells.push(move(cell));
cell.offset.push(0); /* 添加第一个初始位置 */
}
// set box size
if ( max_offset > m_box_size.width() ) {
m_box_size.width(max_offset);
m_box_offset_start = cell.offset_start;
}
m_box_size.height(baseline + descender);
}
/**
* @func set_content_offset
*/
template<TextAlign T> void set_layout_content_offset() {
m_data.cells.clear(); // 清空旧布局
m_box_size = Vec2();
m_box_offset_start = 0;
m_data.cell_draw_begin = m_data.cell_draw_end = 0;
if ( m_data.string.is_empty() ) { return; }
// 在这里进行文本排版布局
FontGlyphTable* table = get_font_glyph_table_and_height(m_data, m_text_line_height.value);
float ascender = m_data.text_ascender; // 行顶与基线的距离
float descender = m_data.text_descender; // 基线与行底的距离
float ratio = 4096.0 / m_text_size.value; /* 64.0 * 64.0 = 4096.0 */
float baseline = ascender;
float offset = 0;
uint line = 0;
uint begin = 0;
uint end = m_data.string.length();
Cell cell = {
0, 0, 0, 0, Array<float>(), Array<uint16>(), 0
};
cell.offset.push(0);
while ( begin < end ) {
uint16 unicode = m_data.string[begin];
if ( unicode == 0x0A ) { // \n 换行
uint count = cell.offset.length() - 1;
end_line<T>( cell, baseline, descender, offset );
baseline += ascender + descender; /* 增加新行 */
line++;
/* 重置新行数据 */
cell.line_num = line; /* 文本单元所在的行 */
cell.begin = begin;
offset = 0;
} else {
float hori_advance = table->glyph(unicode)->hori_advance() / ratio; // 字符宽度
offset += hori_advance;
cell.offset.push(offset);
cell.chars.push(unicode);
}
begin++;
}
end_line<T>( cell, baseline, descender, offset );
}
/**
* @func compute_final_vertex
*/
void compute_final_vertex(Vec2* final_vertex) {
Vec2 A, B, C, D; // rect vertex
Vec2 start(m_box_offset_start - m_origin.x(), -m_origin.y());
Vec2 end (m_box_offset_start + m_box_size.width() - m_origin.x(),
m_box_size.height() - m_origin.y() );
final_vertex[0] = m_final_matrix * start;
final_vertex[1] = m_final_matrix * Vec2(end.x(), start.y());
final_vertex[2] = m_final_matrix * end;
final_vertex[3] = m_final_matrix * Vec2(start.x(), end.y());
}
};
Label::Label()
: m_text_align(TextAlign::LEFT)
, m_box_offset_start(0)
{
m_need_draw = false;
}
/**
* @overwrite
*/
void Label::prepend(View* child) throw(Error) {
FX_ERR("%s", "Error: Label can not have a child view");
}
/**
* @overwrite
*/
void Label::append(View* child) throw(Error) {
FX_ERR("%s", "Error: Label can not have a child view");
}
/**
* @overwrite
*/
View* Label::append_text(cUcs2String& str) throw(Error) {
m_data.string.push(str);
mark( Layout::M_CONTENT_OFFSET );
return nullptr;
}
/**
* @set set_value
*/
void Label::set_value(cUcs2String& str) {
m_data.string = str;
mark( Layout::M_CONTENT_OFFSET );
}
/**
* @overwrite
*/
void Label::mark_text(uint value) {
mark(value);
}
/**
* @overwrite
*/
void Label::accept_text(Ucs2StringBuilder& out) const {
out.push(m_data.string);
}
/**
* @set text_align
*/
void Label::set_text_align(TextAlign value) {
if (value != m_text_align) {
m_text_align = value;
mark( M_CONTENT_OFFSET );
}
}
/**
* @overwrite
*/
void Label::draw(Draw* draw) {
if ( m_visible ) {
if ( mark_value ) {
if ( mark_value & M_TEXT_FONT ) {
if (m_text_background_color.type == TextValueType::INHERIT) {
m_text_background_color.value = app()->default_text_background_color().value;
}
if (m_text_color.type == TextValueType::INHERIT) {
m_text_color.value = app()->default_text_color().value;
}
if (m_text_size.type == TextValueType::INHERIT) {
m_text_size.value = app()->default_text_size().value;
}
if (m_text_style.type == TextValueType::INHERIT) {
m_text_style.value = app()->default_text_style().value;
}
if (m_text_family.type == TextValueType::INHERIT) {
m_text_family.value = app()->default_text_family().value;
}
if (m_text_line_height.type == TextValueType::INHERIT) {
m_text_line_height.value = app()->default_text_line_height().value;
}
if (m_text_shadow.type == TextValueType::INHERIT) {
m_text_shadow.value = app()->default_text_shadow().value;
}
if (m_text_decoration.type == TextValueType::INHERIT) {
m_text_decoration.value = app()->default_text_decoration().value;
}
}
if ( mark_value & Layout::M_CONTENT_OFFSET ) {
mark_value |= (M_SHAPE); // 标记 M_SHAPE 是为了调用 set_draw_visible()
switch (m_text_align) {
case TextAlign::LEFT:
_inl(this)->set_layout_content_offset<TextAlign::LEFT>(); break;
case TextAlign::CENTER:
_inl(this)->set_layout_content_offset<TextAlign::CENTER>(); break;
case TextAlign::RIGHT:
_inl(this)->set_layout_content_offset<TextAlign::RIGHT>(); break;
case TextAlign::LEFT_REVERSE:
_inl(this)->set_layout_content_offset<TextAlign::LEFT_REVERSE>(); break;
case TextAlign::CENTER_REVERSE:
_inl(this)->set_layout_content_offset<TextAlign::CENTER_REVERSE>(); break;
case TextAlign::RIGHT_REVERSE:
_inl(this)->set_layout_content_offset<TextAlign::RIGHT_REVERSE>(); break;
}
}
solve();
if ( mark_value & (M_TRANSFORM | M_TEXT_SIZE) ) {
set_glyph_texture_level(m_data);
}
}
draw->draw(this);
mark_value = M_NONE;
}
}
/**
* @overwrite
*/
bool Label::overlap_test(Vec2 point) {
return View::overlap_test_from_convex_quadrilateral( m_final_vertex, point );
}
/**
* @overwrite
*/
CGRect Label::screen_rect() {
final_matrix();
_inl(this)->compute_final_vertex(m_final_vertex);
return View::screen_rect_from_convex_quadrilateral(m_final_vertex);
}
/**
* @func set_draw_visible
*/
void Label::set_draw_visible() {
_inl(this)->compute_final_vertex(m_final_vertex);
m_draw_visible =
compute_text_visible_draw(m_final_vertex,
m_data,
-m_box_offset_start,
m_box_offset_start + m_box_size.width(), 0);
}
/**
* @overwrite
*/
void Label::set_parent(View* parent) throw(Error) {
if ( parent != m_parent ) {
View::set_parent(parent);
mark(M_TEXT_FONT);
}
}
FX_END
| 27.286154
| 92
| 0.671967
|
louis-tru
|
3987183d1e817ce5ac116084fdd44af061869c3d
| 4,342
|
cpp
|
C++
|
DTLiving/core/effect/video_two_pass_effect.cpp
|
danjiang/DTLiving
|
c0008b7b7f94a392a514b112c0b97564d7d8f12a
|
[
"MIT"
] | 21
|
2020-04-04T13:41:45.000Z
|
2022-02-19T23:38:36.000Z
|
DTLiving/core/effect/video_two_pass_effect.cpp
|
danjiang/DTLiving
|
c0008b7b7f94a392a514b112c0b97564d7d8f12a
|
[
"MIT"
] | 9
|
2020-02-02T10:42:05.000Z
|
2022-02-28T18:50:48.000Z
|
DTLiving/core/effect/video_two_pass_effect.cpp
|
danjiang/DTLiving
|
c0008b7b7f94a392a514b112c0b97564d7d8f12a
|
[
"MIT"
] | 3
|
2020-10-19T08:28:38.000Z
|
2021-11-29T09:24:42.000Z
|
//
// video_two_pass_effect.cpp
// DTLiving
//
// Created by Dan Jiang on 2020/4/15.
// Copyright © 2020 Dan Thought Studio. All rights reserved.
//
#include "video_two_pass_effect.h"
#include "video_texture_cache.h"
namespace dtliving {
namespace effect {
VideoTwoPassEffect::VideoTwoPassEffect(std::string name)
: VideoEffect(name) {
}
void VideoTwoPassEffect::LoadShaderSource(std::string vertex_shader_source1, std::string fragment_shader_source1,
std::string vertex_shader_source2, std::string fragment_shader_source2) {
VideoEffect::LoadShaderSource(vertex_shader_source1, fragment_shader_source1);
program2_ = new ShaderProgram();
program2_->CompileSource(vertex_shader_source2.c_str(), fragment_shader_source2.c_str());
}
void VideoTwoPassEffect::LoadUniform() {
VideoEffect::LoadUniform();
a_position2_ = program2_->AttributeLocation("a_position");
a_texcoord2_ = program2_->AttributeLocation("a_texcoord");
u_texture2_ = program2_->UniformLocation("u_texture");
}
void VideoTwoPassEffect::Render(VideoFrame input_frame, VideoFrame output_frame, std::vector<GLfloat> positions, std::vector<GLfloat> texture_coordinates) {
// first pass
glBindTexture(GL_TEXTURE_2D, input_frame.texture_name);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
auto texture = VideoTextureCache::GetInstance()->FetchTexture(input_frame.width,
input_frame.height);
texture->Lock();
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture->get_texture_name(), 0);
program_->Use();
auto clear_color = get_clear_color();
glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w);
glClear(GL_COLOR_BUFFER_BIT);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, input_frame.texture_name);
glUniform1i(u_texture_, 0);
glEnableVertexAttribArray(a_position_);
glVertexAttribPointer(a_position_,
2,
GL_FLOAT,
GL_FALSE,
0,
positions.data());
glEnableVertexAttribArray(a_texcoord_);
glVertexAttribPointer(a_texcoord_,
2,
GL_FLOAT,
GL_FALSE,
0,
texture_coordinates.data());
BeforeDrawArrays(output_frame.width, output_frame.height, 0);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
// second pass
glBindTexture(GL_TEXTURE_2D, texture->get_texture_name());
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, output_frame.texture_name, 0);
program2_->Use();
glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w);
glClear(GL_COLOR_BUFFER_BIT);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, texture->get_texture_name());
glUniform1i(u_texture2_, 0);
glEnableVertexAttribArray(a_position2_);
glVertexAttribPointer(a_position2_,
2,
GL_FLOAT,
GL_FALSE,
0,
positions.data());
glEnableVertexAttribArray(a_texcoord2_);
glVertexAttribPointer(a_texcoord2_,
2,
GL_FLOAT,
GL_FALSE,
0,
texture_coordinates.data());
BeforeDrawArrays(output_frame.width, output_frame.height, 1);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
texture->UnLock();
}
}
}
| 34.460317
| 156
| 0.647167
|
danjiang
|
3987220c58035f6fabb2b13fb7b7bb47751ddbf7
| 3,962
|
cpp
|
C++
|
src/ffmpeg_io/avio_reading.cpp
|
zzu-andrew/ffmpeg_doc
|
dd9c3333b2aa00cf57e55fe2bd0d29503f16ab55
|
[
"Apache-2.0"
] | null | null | null |
src/ffmpeg_io/avio_reading.cpp
|
zzu-andrew/ffmpeg_doc
|
dd9c3333b2aa00cf57e55fe2bd0d29503f16ab55
|
[
"Apache-2.0"
] | null | null | null |
src/ffmpeg_io/avio_reading.cpp
|
zzu-andrew/ffmpeg_doc
|
dd9c3333b2aa00cf57e55fe2bd0d29503f16ab55
|
[
"Apache-2.0"
] | null | null | null |
//
// Created by andrew on 2020/12/13.
//
#include <iostream>
extern "C" {
#include <libavformat/avformat.h>
#include <libavutil/log.h>
#include <libavcodec/avcodec.h>
#include <libavformat/avio.h>
#include <libavutil/file.h>
#include <cstdio>
}
using namespace std;
// 为mmap buffer定义一个结构体指针用户管理数据
struct buffer_data {
uint8_t *ptr;
size_t size; // size left in the buffer
};
static int ReadPacket(void *pOpaque, uint8_t *pBuff, int bufferSize) {
auto *bd = (struct buffer_data *) pOpaque;
// #define FFMIN(a,b) ((a) > (b) ? (b) : (a))
bufferSize = FFMIN(bufferSize, bd->size);
if (!bufferSize) {
cout << "ptr = " << bd->ptr << "size = " << bd->size << endl;
}
// 将音视频数据内部的data复制到buff中
memcpy(pBuff, bd->ptr, bufferSize);
bd->ptr += bufferSize;
bd->size -= bufferSize;
return bufferSize;
}
int main(int argc, char *argv[]) {
AVIOContext *pAvioCtx = nullptr;
uint8_t *pAvioCtxBuffer = nullptr;
size_t avioCtxBufferSize = 4096;
struct buffer_data bufferData = {nullptr, 0};
// 贯穿全局的context信息
AVFormatContext *pFmtCtx = nullptr;
// 设置日志等级
av_log_set_level(AV_LOG_DEBUG);
if (argc != 2) {
cout << "please input a reading file" << "argc = " << argc << endl;
return -1;
}
char *inputFileName = argv[1];
// 将文件进行内存映射
/*
* mmap() creates a new mapping in the virtual address space of the calling process. The starting address for the new mapping is specified in addr. The length argument specifies the length of
the mapping (which must be greater than 0).
If addr is NULL, then the kernel chooses the (page-aligned) address at which to create the mapping; this is the most portable method of creating a new mapping. If addr is not NULL, then the
kernel takes it as a hint about where to place the mapping; on Linux, the kernel will pick a nearby page boundary (but always above or equal to the value specified by
/proc/sys/vm/mmap_min_addr) and attempt to create the mapping there. If another mapping already exists there, the kernel picks a new address that may or may not depend on the hint. The ad‐
dress of the new mapping is returned as the result of the call.
* */
uint8_t *buffer = nullptr;
size_t buffer_size = 0;
int ret = av_file_map(inputFileName, &buffer, &buffer_size, 0, nullptr);
if (ret < 0) {
cout << "av_file_map failed" << "ret = " << ret << endl;
goto end;
}
// 记录 @av_file_map 中获取的文件内存映射的内容和长度
bufferData.ptr = buffer;
bufferData.size = buffer_size;
// Allocate an AVFormatContext.
pFmtCtx = avformat_alloc_context();
if (!pFmtCtx) {
ret = AVERROR(ENOMEM);
goto end;
}
pAvioCtxBuffer = (uint8_t *) av_malloc(avioCtxBufferSize);
if (!pAvioCtxBuffer) {
ret = AVERROR(ENOMEM);
goto end;
}
pAvioCtx = avio_alloc_context(pAvioCtxBuffer, avioCtxBufferSize, 0, &bufferData, &ReadPacket,
nullptr,nullptr);
if (!pAvioCtx) {
ret = AVERROR(ENOMEM);
goto end;
}
// 调用 avformat_open_input 之前,要是使用文件的音视频处理,这里需要提前进行初始化,然后再调用、
// avformat_open_input 打开对应的文件
pFmtCtx->pb = pAvioCtx;
ret = avformat_open_input(&pFmtCtx, nullptr, nullptr, nullptr);
if (ret < 0) {
cerr << "Could not open input!" << endl;
goto end;
}
ret = avformat_find_stream_info(pFmtCtx, nullptr);
if (ret < 0) {
cerr << "Could not find stream information!" << endl;
goto end;
}
av_dump_format(pFmtCtx, 0, inputFileName, 0);
cout << "avio reading demo success" << endl;
end:
avformat_close_input(&pFmtCtx);
if (pAvioCtxBuffer && !pAvioCtx)
av_freep(pAvioCtxBuffer);
if (pAvioCtx)
av_freep(&pAvioCtx->buffer);
avio_context_free(&pAvioCtx);
av_file_unmap(buffer, buffer_size);
return 0;
}
| 31.444444
| 199
| 0.636295
|
zzu-andrew
|
39873ae8de1ba67e9cd7c929aa0bbd5fd8502ba5
| 13,585
|
hpp
|
C++
|
include/poplar/compact_bonsai_trie.hpp
|
MatsuTaku/dynpdt_Correction
|
10605c1dc8ae6196741bee0e991935e8877b930a
|
[
"MIT"
] | 47
|
2018-02-24T09:56:24.000Z
|
2022-02-13T12:10:00.000Z
|
include/poplar/compact_bonsai_trie.hpp
|
MatsuTaku/dynpdt_Correction
|
10605c1dc8ae6196741bee0e991935e8877b930a
|
[
"MIT"
] | 4
|
2018-03-08T03:28:05.000Z
|
2021-09-29T06:38:25.000Z
|
include/poplar/compact_bonsai_trie.hpp
|
MatsuTaku/dynpdt_Correction
|
10605c1dc8ae6196741bee0e991935e8877b930a
|
[
"MIT"
] | 5
|
2018-03-07T06:34:43.000Z
|
2022-02-12T19:54:18.000Z
|
/**
* MIT License
*
* Copyright (c) 2018–2019 Shunsuke Kanda
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef POPLAR_TRIE_COMPACT_BONSAI_TRIE_HPP
#define POPLAR_TRIE_COMPACT_BONSAI_TRIE_HPP
#include "bijective_hash.hpp"
#include "bit_vector.hpp"
#include "compact_hash_table.hpp"
#include "compact_vector.hpp"
#include "standard_hash_table.hpp"
namespace poplar {
template <uint32_t MaxFactor = 90, uint32_t Dsp1Bits = 4, class AuxCht = compact_hash_table<7>,
class AuxMap = standard_hash_table<>, class Hasher = bijective_hash::split_mix_hasher>
class compact_bonsai_trie {
static_assert(0 < MaxFactor and MaxFactor < 100);
static_assert(0 < Dsp1Bits and Dsp1Bits < 64);
public:
using this_type = compact_bonsai_trie<MaxFactor, Dsp1Bits, AuxCht, AuxMap, Hasher>;
using aux_cht_type = AuxCht;
using aux_map_type = AuxMap;
static constexpr uint64_t nil_id = UINT64_MAX;
static constexpr uint32_t min_capa_bits = 16;
static constexpr uint32_t dsp1_bits = Dsp1Bits;
static constexpr uint64_t dsp1_mask = (1ULL << dsp1_bits) - 1;
static constexpr uint32_t dsp2_bits = aux_cht_type::val_bits;
static constexpr uint32_t dsp2_mask = aux_cht_type::val_mask;
static constexpr auto trie_type_id = trie_type_ids::BONSAI_TRIE;
public:
compact_bonsai_trie() = default;
compact_bonsai_trie(uint32_t capa_bits, uint32_t symb_bits, uint32_t cht_capa_bits = 0) {
capa_size_ = size_p2{std::max(min_capa_bits, capa_bits)};
symb_size_ = size_p2{symb_bits};
max_size_ = static_cast<uint64_t>(capa_size_.size() * MaxFactor / 100.0);
hasher_ = Hasher{capa_size_.bits() + symb_size_.bits()};
table_ = compact_vector{capa_size_.size(), symb_size_.bits() + dsp1_bits};
aux_cht_ = aux_cht_type{capa_size_.bits(), cht_capa_bits};
}
~compact_bonsai_trie() = default;
uint64_t get_root() const {
assert(size_ != 0);
return 0;
}
void add_root() {
assert(size_ == 0);
size_ = 1;
}
uint64_t find_child(uint64_t node_id, uint64_t symb) const {
assert(node_id < capa_size_.size());
assert(symb < symb_size_.size());
if (size_ == 0) {
return nil_id;
}
auto [quo, mod] = decompose_(hasher_.hash(make_key_(node_id, symb)));
for (uint64_t i = mod, cnt = 1;; i = right_(i), ++cnt) {
if (i == get_root()) {
// because the root's dsp value is zero though it is defined
continue;
}
if (compare_dsp_(i, 0)) {
// this slot is empty
return nil_id;
}
if (compare_dsp_(i, cnt) and quo == get_quo_(i)) {
return i;
}
}
}
bool add_child(uint64_t& node_id, uint64_t symb) {
assert(node_id < capa_size_.size());
assert(symb < symb_size_.size());
auto [quo, mod] = decompose_(hasher_.hash(make_key_(node_id, symb)));
for (uint64_t i = mod, cnt = 1;; i = right_(i), ++cnt) {
// because the root's dsp value is zero though it is defined
if (i == get_root()) {
continue;
}
if (compare_dsp_(i, 0)) {
// this slot is empty
if (size_ == max_size_) {
return false; // needs to expand
}
update_slot_(i, quo, cnt);
++size_;
node_id = i;
return true;
}
if (compare_dsp_(i, cnt) and quo == get_quo_(i)) {
node_id = i;
return false; // already stored
}
}
}
std::pair<uint64_t, uint64_t> get_parent_and_symb(uint64_t node_id) const {
assert(node_id < capa_size_.size());
if (compare_dsp_(node_id, 0)) {
// root or not exist
return {nil_id, 0};
}
uint64_t dist = get_dsp_(node_id) - 1;
uint64_t init_id = dist <= node_id ? node_id - dist : table_.size() - (dist - node_id);
uint64_t key = hasher_.hash_inv(get_quo_(node_id) << capa_size_.bits() | init_id);
// Returns pair (parent, label)
return std::make_pair(key >> symb_size_.bits(), key & symb_size_.mask());
}
class node_map {
public:
node_map() = default;
node_map(compact_vector&& map_high, compact_vector&& map_low, bit_vector&& done_flags)
: map_high_(std::move(map_high)), map_low_(std::move(map_low)), done_flags_(std::move(done_flags)) {}
~node_map() = default;
uint64_t operator[](uint64_t i) const {
if (!done_flags_[i]) {
return UINT64_MAX;
}
if (map_high_.size() == 0) {
return map_low_[i];
} else {
return map_low_[i] | (map_high_[i] << map_low_.width());
}
}
uint64_t size() const {
return map_low_.size();
}
node_map(const node_map&) = delete;
node_map& operator=(const node_map&) = delete;
node_map(node_map&&) noexcept = default;
node_map& operator=(node_map&&) noexcept = default;
private:
compact_vector map_high_;
compact_vector map_low_;
bit_vector done_flags_;
};
bool needs_to_expand() const {
return max_size() <= size();
}
node_map expand() {
// this_type new_ht{capa_bits() + 1, symb_size_.bits(), aux_cht_.capa_bits()};
this_type new_ht{capa_bits() + 1, symb_size_.bits()};
new_ht.add_root();
#ifdef POPLAR_EXTRA_STATS
new_ht.num_resize_ = num_resize_ + 1;
#endif
bit_vector done_flags(capa_size());
done_flags.set(get_root());
size_p2 low_size{table_.width()};
compact_vector map_high;
if (low_size.bits() < new_ht.capa_bits()) {
map_high = compact_vector(capa_size(), new_ht.capa_bits() - low_size.bits());
}
std::vector<std::pair<uint64_t, uint64_t>> path;
path.reserve(256);
auto get_mapping = [&](uint64_t i) -> uint64_t {
if (map_high.size() == 0) {
return table_[i];
} else {
return table_[i] | (map_high[i] << low_size.bits());
}
};
auto set_mapping = [&](uint64_t i, uint64_t v) {
if (map_high.size() == 0) {
table_.set(i, v);
} else {
table_.set(i, v & low_size.mask());
map_high.set(i, v >> low_size.bits());
}
};
// 0 is root
for (uint64_t i = 1; i < table_.size(); ++i) {
if (done_flags[i] or compare_dsp_(i, 0)) {
// skip already processed or empty elements
continue;
}
path.clear();
uint64_t node_id = i;
do {
auto [parent, label] = get_parent_and_symb(node_id);
assert(parent != nil_id);
path.emplace_back(std::make_pair(node_id, label));
node_id = parent;
} while (!done_flags[node_id]);
uint64_t new_node_id = get_mapping(node_id);
for (auto rit = std::rbegin(path); rit != std::rend(path); ++rit) {
new_ht.add_child(new_node_id, rit->second);
set_mapping(rit->first, new_node_id);
done_flags.set(rit->first);
}
}
node_map node_map{std::move(map_high), std::move(table_), std::move(done_flags)};
std::swap(*this, new_ht);
return node_map;
}
uint64_t size() const {
return size_;
}
uint64_t max_size() const {
return max_size_;
}
uint64_t capa_size() const {
return capa_size_.size();
}
uint32_t capa_bits() const {
return capa_size_.bits();
}
uint64_t symb_size() const {
return symb_size_.size();
}
uint32_t symb_bits() const {
return symb_size_.bits();
}
#ifdef POPLAR_EXTRA_STATS
uint64_t num_resize() const {
return num_resize_;
}
#endif
uint64_t alloc_bytes() const {
uint64_t bytes = 0;
bytes += table_.alloc_bytes();
bytes += aux_cht_.alloc_bytes();
bytes += aux_map_.alloc_bytes();
return bytes;
}
void show_stats(std::ostream& os, int n = 0) const {
auto indent = get_indent(n);
show_stat(os, indent, "name", "compact_hash_trie");
show_stat(os, indent, "factor", double(size()) / capa_size() * 100);
show_stat(os, indent, "max_factor", MaxFactor);
show_stat(os, indent, "size", size());
show_stat(os, indent, "alloc_bytes", alloc_bytes());
show_stat(os, indent, "capa_bits", capa_bits());
show_stat(os, indent, "symb_bits", symb_bits());
show_stat(os, indent, "dsp1st_bits", dsp1_bits);
show_stat(os, indent, "dsp2nd_bits", dsp2_bits);
#ifdef POPLAR_EXTRA_STATS
show_stat(os, indent, "rate_dsp1st", double(num_dsps_[0]) / size());
show_stat(os, indent, "rate_dsp2nd", double(num_dsps_[1]) / size());
show_stat(os, indent, "rate_dsp3rd", double(num_dsps_[2]) / size());
show_stat(os, indent, "num_resize", num_resize_);
#endif
show_member(os, indent, "hasher_");
hasher_.show_stats(os, n + 1);
show_member(os, indent, "aux_cht_");
aux_cht_.show_stats(os, n + 1);
show_member(os, indent, "aux_map_");
aux_map_.show_stats(os, n + 1);
}
compact_bonsai_trie(const compact_bonsai_trie&) = delete;
compact_bonsai_trie& operator=(const compact_bonsai_trie&) = delete;
compact_bonsai_trie(compact_bonsai_trie&&) noexcept = default;
compact_bonsai_trie& operator=(compact_bonsai_trie&&) noexcept = default;
private:
Hasher hasher_;
compact_vector table_;
aux_cht_type aux_cht_; // 2nd dsp
aux_map_type aux_map_; // 3rd dsp
uint64_t size_ = 0; // # of registered nodes
uint64_t max_size_ = 0; // MaxFactor% of the capacity
size_p2 capa_size_;
size_p2 symb_size_;
#ifdef POPLAR_EXTRA_STATS
uint64_t num_resize_ = 0;
uint64_t num_dsps_[3] = {};
#endif
uint64_t make_key_(uint64_t node_id, uint64_t symb) const {
return (node_id << symb_size_.bits()) | symb;
}
std::pair<uint64_t, uint64_t> decompose_(uint64_t x) const {
return {x >> capa_size_.bits(), x & capa_size_.mask()};
}
uint64_t right_(uint64_t slot_id) const {
return (slot_id + 1) & capa_size_.mask();
}
uint64_t get_quo_(uint64_t slot_id) const {
return table_[slot_id] >> dsp1_bits;
}
uint64_t get_dsp_(uint64_t slot_id) const {
uint64_t dsp = table_[slot_id] & dsp1_mask;
if (dsp < dsp1_mask) {
return dsp;
}
dsp = aux_cht_.get(slot_id);
if (dsp != aux_cht_type::nil) {
return dsp + dsp1_mask;
}
return aux_map_.get(slot_id);
}
bool compare_dsp_(uint64_t slot_id, uint64_t rhs) const {
uint64_t lhs = table_[slot_id] & dsp1_mask;
if (lhs < dsp1_mask) {
return lhs == rhs;
}
if (rhs < dsp1_mask) {
return false;
}
lhs = aux_cht_.get(slot_id);
if (lhs != aux_cht_type::nil) {
return lhs + dsp1_mask == rhs;
}
if (rhs < dsp1_mask + dsp2_mask) {
return false;
}
auto val = aux_map_.get(slot_id);
assert(val != aux_map_type::nil);
return val == rhs;
}
void update_slot_(uint64_t slot_id, uint64_t quo, uint64_t dsp) {
assert(table_[slot_id] == 0);
assert(quo < symb_size_.size());
uint64_t v = quo << dsp1_bits;
if (dsp < dsp1_mask) {
v |= dsp;
} else {
v |= dsp1_mask;
uint64_t _dsp = dsp - dsp1_mask;
if (_dsp < dsp2_mask) {
aux_cht_.set(slot_id, _dsp);
} else {
aux_map_.set(slot_id, dsp);
}
}
#ifdef POPLAR_EXTRA_STATS
if (dsp < dsp1_mask) {
++num_dsps_[0];
} else if (dsp < dsp1_mask + dsp2_mask) {
++num_dsps_[1];
} else {
++num_dsps_[2];
}
#endif
table_.set(slot_id, v);
}
};
} // namespace poplar
#endif // POPLAR_TRIE_COMPACT_BONSAI_TRIE_HPP
| 31.666667
| 113
| 0.583585
|
MatsuTaku
|
39892cdc51302fced93a48a78ea60f237a0e6159
| 926
|
cpp
|
C++
|
C++/1663.SmallestStringWithAGivenNumericValue.cpp
|
SSKale1/LeetCode-Solutions
|
dd6ff16f6af1e96acd036b6e9c2a5cc11f0e330b
|
[
"MIT"
] | null | null | null |
C++/1663.SmallestStringWithAGivenNumericValue.cpp
|
SSKale1/LeetCode-Solutions
|
dd6ff16f6af1e96acd036b6e9c2a5cc11f0e330b
|
[
"MIT"
] | null | null | null |
C++/1663.SmallestStringWithAGivenNumericValue.cpp
|
SSKale1/LeetCode-Solutions
|
dd6ff16f6af1e96acd036b6e9c2a5cc11f0e330b
|
[
"MIT"
] | null | null | null |
class Solution {
public:
string getSmallestString(int n, int k) {
//initialising a string of length n and filling it with 'a'
string result(n, 'a');
//numeric value of 'a' = 1, the numeric value of the resulting string will become k-n as we have
//filled all with 'a', so k = k - (1*n);
k = k-n;
while(k>0)
{
//for iterating each index from the end
n--;
//changing the last value from 'a' to 'z' or k, whichever is minimum
result[n] = result[n] + min(25,k);
//decrementing k by the value to which 'a' was changed
k = k - min(25,k);
}
return result;
}
};
/*
You can checkout this link for understanding the problem through an example:
https://leetcode.com/problems/smallest-string-with-a-given-numeric-value/discuss/1871662/JavaC%2B%2B-Easiest-Possible-Exaplained!!
*/
| 29.870968
| 130
| 0.587473
|
SSKale1
|
399484533e6c99bd21e5f923282e780ad8129dac
| 4,076
|
hpp
|
C++
|
code/dtslam/ReprojectionError3DImpl.hpp
|
luoyongheng/dtslam
|
d3c2230d45db14c811eff6fd43e119ac39af1352
|
[
"BSD-3-Clause"
] | 144
|
2015-01-15T03:38:44.000Z
|
2022-02-17T09:07:52.000Z
|
code/dtslam/ReprojectionError3DImpl.hpp
|
luoyongheng/dtslam
|
d3c2230d45db14c811eff6fd43e119ac39af1352
|
[
"BSD-3-Clause"
] | 9
|
2015-09-09T06:51:46.000Z
|
2020-06-17T14:10:10.000Z
|
code/dtslam/ReprojectionError3DImpl.hpp
|
luoyongheng/dtslam
|
d3c2230d45db14c811eff6fd43e119ac39af1352
|
[
"BSD-3-Clause"
] | 58
|
2015-01-14T23:43:49.000Z
|
2021-11-15T05:19:08.000Z
|
/*
* ReprojectionError3DImpl.hpp
*
* Copyright(C) 2014, University of Oulu, all rights reserved.
* Copyright(C) 2014, NVIDIA Corporation, all rights reserved.
* Third party copyrights are property of their respective owners.
* Contact: Daniel Herrera C. (dherrera@ee.oulu.fi),
* Kihwan Kim(kihwank@nvidia.com)
* Author : Daniel Herrera C.
*/
#ifndef REPROJECTIONERROR3DIMPL_HPP_
#define REPROJECTIONERROR3DIMPL_HPP_
namespace dtslam
{
template<class T>
void ReprojectionError3D::pointResiduals(const T &u, const T &v, const int i, T *residuals) const
{
const cv::Point2f &p = mImgPoints[i];
residuals[0] = (u-T(p.x))/T(mScale);
residuals[1] = (v-T(p.y))/T(mScale);
}
template<class T>
void ReprojectionError3D::computeAllResidualsXc(const T * const xc, T *allResiduals) const
{
if(CeresUtils::ToDouble(xc[2]) <= 0)
{
//Negative point
for(int i=0; i<2*mImagePointCount; ++i)
allResiduals[i] = T(1e3);
}
else
{
//Point in front of camera, proceed
T u,v;
mCamera->projectFromWorld(xc[0],xc[1],xc[2],u,v);
//Calculate residuals for all points
for(int i=0; i<mImagePointCount; ++i)
{
pointResiduals(u,v,i,allResiduals+2*i);
}
}
}
template<class T>
void ReprojectionError3D::computeAllResidualsRparams(const T * const rparams, const T * const t, const T * const x, T *allResiduals) const
{
T xr[3];
ceres::AngleAxisRotatePoint(rparams, x, xr);
T xc[3];
xc[0] = xr[0]+t[0];
xc[1] = xr[1]+t[1];
xc[2] = xr[2]+t[2];
computeAllResidualsXc(xc,allResiduals);
}
template<class T>
void ReprojectionError3D::computeAllResidualsRmat(const T * const R, const T * const t, const T * const x, T *allResiduals) const
{
auto xwmat = CeresUtils::FixedRowMajorAdapter3x1(x);
auto Rmat = CeresUtils::FixedRowMajorAdapter3x3(R);
T xr[3];
auto xrmat = CeresUtils::FixedRowMajorAdapter3x1(xr);
CeresUtils::matrixMatrix(Rmat,xwmat,xrmat);
T xc[3];
xc[0] = xr[0]+t[0];
xc[1] = xr[1]+t[1];
xc[2] = xr[2]+t[2];
computeAllResidualsXc(xc,allResiduals);
}
template<class T>
void ReprojectionError3D::residualsToErrors(const std::vector<T> &allResiduals, const float errorThreshold, MatchReprojectionErrors &errors) const
{
assert(allResiduals.size() == 2*mImagePointCount);
float errorThresholdSq = errorThreshold*errorThreshold;
//Init errors
errors.isInlier=false;
errors.bestReprojectionErrorSq = std::numeric_limits<float>::infinity();
errors.reprojectionErrorsSq.resize(mImagePointCount);
errors.isImagePointInlier.resize(mImagePointCount);
for(int i=0; i!=mImagePointCount; ++i)
{
float r1 = (float)allResiduals[2 * i];
float r2 = (float)allResiduals[2 * i + 1];
auto &errorSq = errors.reprojectionErrorsSq[i];
errorSq = r1*r1+r2*r2;
//Min
if(errorSq < errors.bestReprojectionErrorSq)
errors.bestReprojectionErrorSq = errorSq;
//Update errors
if(errorSq < errorThresholdSq)
{
errors.isImagePointInlier[i] = true;
errors.isInlier = true;
}
else
errors.isImagePointInlier[i] = false;
}
}
template<class T>
bool PoseReprojectionError3D::operator()(const T * const rparams, const T * const t, T *residuals) const
{
T x[3] = {T(mFeaturePosition[0]),T(mFeaturePosition[1]),T(mFeaturePosition[2])};
if(mImagePointCount==1)
{
computeAllResidualsRparams(rparams, t, x, residuals);
}
else
{
std::vector<T> allResiduals(2*mImagePointCount);
computeAllResidualsRparams(rparams, t, x, allResiduals.data());
int minIndex;
CeresUtils::GetMinResiduals<2>(allResiduals.data(), mImagePointCount, residuals, minIndex);
}
return true;
}
template<class T>
bool BAReprojectionError3D::operator()(const T * const rparams, const T * const t, const T * const x, T *residuals) const
{
if(mImagePointCount==1)
{
computeAllResidualsRparams(rparams, t, x, residuals);
}
else
{
std::vector<T> allResiduals(2*mImagePointCount);
computeAllResidualsRparams(rparams, t, x, allResiduals.data());
int minIndex;
CeresUtils::GetMinResiduals<2>(allResiduals.data(), mImagePointCount, residuals, minIndex);
}
return true;
}
}
#endif /* REPROJECTIONERROR3DIMPL_HPP_ */
| 25.31677
| 146
| 0.717125
|
luoyongheng
|
399546e00444a45becd8ba3afbcbee2cdfc78038
| 1,935
|
cpp
|
C++
|
Engine/Plugins/GameWorks/Blast/Source/BlastEditor/Private/BlastActorFactory.cpp
|
windystrife/UnrealEngine_NVIDIAGameWork
|
b50e6338a7c5b26374d66306ebc7807541ff815e
|
[
"MIT"
] | 1
|
2022-01-29T18:36:12.000Z
|
2022-01-29T18:36:12.000Z
|
Engine/Plugins/GameWorks/Blast/Source/BlastEditor/Private/BlastActorFactory.cpp
|
windystrife/UnrealEngine_NVIDIAGameWork
|
b50e6338a7c5b26374d66306ebc7807541ff815e
|
[
"MIT"
] | null | null | null |
Engine/Plugins/GameWorks/Blast/Source/BlastEditor/Private/BlastActorFactory.cpp
|
windystrife/UnrealEngine_NVIDIAGameWork
|
b50e6338a7c5b26374d66306ebc7807541ff815e
|
[
"MIT"
] | null | null | null |
#include "BlastActorFactory.h"
#include "BlastMesh.h"
#include "BlastMeshActor.h"
#include "BlastMeshComponent.h"
#define LOCTEXT_NAMESPACE "Blast"
/*-----------------------------------------------------------------------------
UActorFactoryBlastMesh
-----------------------------------------------------------------------------*/
UActorFactoryBlastMesh::UActorFactoryBlastMesh(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer)
{
DisplayName = LOCTEXT("BlastMeshDisplayName", "Blast Mesh");
NewActorClass = ABlastMeshActor::StaticClass();
bUseSurfaceOrientation = true;
}
bool UActorFactoryBlastMesh::CanCreateActorFrom(const FAssetData& AssetData, FText& OutErrorMsg)
{
if (!AssetData.IsValid() ||
(!AssetData.GetClass()->IsChildOf(UBlastMesh::StaticClass()))
)
{
OutErrorMsg = NSLOCTEXT("CanCreateActor", "NoBlastMesh", "A valid blast mesh must be specified.");
return false;
}
return true;
}
UObject* UActorFactoryBlastMesh::GetAssetFromActorInstance(AActor* ActorInstance)
{
if (ABlastMeshActor* BlastActorInstance = Cast<ABlastMeshActor>(ActorInstance))
{
return BlastActorInstance->GetBlastMeshComponent()->GetBlastMesh();
}
return nullptr;
}
void UActorFactoryBlastMesh::PostSpawnActor(UObject* Asset, AActor* NewActor)
{
Super::PostSpawnActor(Asset, NewActor);
UBlastMesh* BlastMesh = Cast<UBlastMesh>(Asset);
UBlastMeshComponent* BlastComponent = Cast<ABlastMeshActor>(NewActor)->GetBlastMeshComponent();
// Change properties
BlastComponent->SetBlastMesh(BlastMesh);
}
void UActorFactoryBlastMesh::PostCreateBlueprint(UObject* Asset, AActor* CDO)
{
Super::PostCreateBlueprint(Asset, CDO);
if (Asset != NULL && CDO != NULL)
{
UBlastMesh* BlastMesh = Cast<UBlastMesh>(Asset);
UBlastMeshComponent* BlastComponent = Cast<ABlastMeshActor>(CDO)->GetBlastMeshComponent();
// Change properties
BlastComponent->SetBlastMesh(BlastMesh);
}
}
#undef LOCTEXT_NAMESPACE
| 30.234375
| 100
| 0.715245
|
windystrife
|
399670d626858db8cc6a3719e993b1bbe73c3d4d
| 10,258
|
cpp
|
C++
|
src/common/BitBuffer.cpp
|
AllMethodGrind/bmxlib
|
9480bdec14c082f9b121b7a6102461b05bdea547
|
[
"BSD-3-Clause"
] | 4
|
2015-02-24T23:55:07.000Z
|
2021-04-13T20:48:45.000Z
|
src/common/BitBuffer.cpp
|
AllMethodGrind/bmxlib
|
9480bdec14c082f9b121b7a6102461b05bdea547
|
[
"BSD-3-Clause"
] | null | null | null |
src/common/BitBuffer.cpp
|
AllMethodGrind/bmxlib
|
9480bdec14c082f9b121b7a6102461b05bdea547
|
[
"BSD-3-Clause"
] | 3
|
2019-03-20T18:34:45.000Z
|
2020-10-04T20:37:52.000Z
|
/*
* Copyright (C) 2013, British Broadcasting Corporation
* All Rights Reserved.
*
* Author: Philip de Nier
*
* 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 British Broadcasting Corporation 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.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#define __STDC_LIMIT_MACROS
#define __STDC_CONSTANT_MACROS
#include <cstring>
#include <memory>
#include <bmx/BitBuffer.h>
#include <bmx/Utils.h>
#include <bmx/BMXException.h>
#include <bmx/Logging.h>
using namespace std;
using namespace bmx;
GetBitBuffer::GetBitBuffer(const unsigned char *data, uint32_t size)
{
mData = data;
mSize = size;
mPos = 0;
mBitSize = (uint64_t)size << 3;
mBitPos = 0;
}
uint32_t GetBitBuffer::GetRemSize() const
{
if (mSize > mPos)
return mSize - mPos;
else
return 0;
}
uint64_t GetBitBuffer::GetRemBitSize() const
{
if (mBitSize > mBitPos)
return mBitSize - mBitPos;
else
return 0;
}
void GetBitBuffer::GetBytes(uint32_t request_size, const unsigned char **data, uint32_t *size)
{
BMX_ASSERT(!(mBitPos & 0x07));
*size = request_size;
if ((*size) > mSize - mPos)
*size = mSize - mPos;
if ((*size) > 0) {
*data = &mData[mPos];
mPos += *size;
mBitPos += (uint64_t)(*size) << 3;
} else {
*data = 0;
}
}
bool GetBitBuffer::GetUInt8(uint8_t *value)
{
BMX_ASSERT(!(mBitPos & 0x07));
if (mPos >= mSize)
return false;
*value = mData[mPos];
mPos++;
mBitPos += 8;
return true;
}
bool GetBitBuffer::GetBits(uint8_t num_bits, uint8_t *value)
{
uint64_t u64_value;
if (!GetBits(num_bits, &u64_value))
return false;
*value = (uint8_t)u64_value;
return true;
}
bool GetBitBuffer::GetBits(uint8_t num_bits, uint16_t *value)
{
uint64_t u64_value;
if (!GetBits(num_bits, &u64_value))
return false;
*value = (uint16_t)u64_value;
return true;
}
bool GetBitBuffer::GetBits(uint8_t num_bits, uint32_t *value)
{
uint64_t u64_value;
if (!GetBits(num_bits, &u64_value))
return false;
*value = (uint32_t)u64_value;
return true;
}
bool GetBitBuffer::GetBits(uint8_t num_bits, uint64_t *value)
{
if (num_bits > mBitSize - mBitPos)
return false;
if (num_bits > 0)
GetBits(mData, &mPos, &mBitPos, num_bits, value);
else
*value = 0;
return true;
}
bool GetBitBuffer::GetBits(uint8_t num_bits, int8_t *value)
{
int64_t i64_value;
if (!GetBits(num_bits, &i64_value))
return false;
*value = (int32_t)i64_value;
return true;
}
bool GetBitBuffer::GetBits(uint8_t num_bits, int16_t *value)
{
int64_t i64_value;
if (!GetBits(num_bits, &i64_value))
return false;
*value = (int32_t)i64_value;
return true;
}
bool GetBitBuffer::GetBits(uint8_t num_bits, int32_t *value)
{
int64_t i64_value;
if (!GetBits(num_bits, &i64_value))
return false;
*value = (int32_t)i64_value;
return true;
}
bool GetBitBuffer::GetBits(uint8_t num_bits, int64_t *value)
{
uint64_t u64_value;
if (!GetBits(num_bits, &u64_value))
return false;
int64_t sign = (int64_t)(UINT64_C(1) << (num_bits - 1));
*value = ((int64_t)u64_value ^ sign) - sign;
return true;
}
void GetBitBuffer::SetPos(uint32_t pos)
{
mPos = pos;
mBitPos = (uint64_t)pos << 3;
}
void GetBitBuffer::SetBitPos(uint64_t bit_pos)
{
mBitPos = bit_pos;
mPos = (uint32_t)(mBitPos >> 3);
}
void GetBitBuffer::GetBits(const unsigned char *data, uint32_t *pos_io, uint64_t *bit_pos_io, uint8_t num_bits,
uint64_t *value)
{
BMX_ASSERT(num_bits > 0 || num_bits <= 64);
const unsigned char *data_ptr = &data[*pos_io];
uint8_t min_consume_bits = (uint8_t)(((*bit_pos_io) & 0x07) + num_bits);
int16_t consumed_bits = 0;
*value = 0;
while (consumed_bits < min_consume_bits) {
*value = ((*value) << 8) | (*data_ptr);
data_ptr++;
consumed_bits += 8;
}
*value >>= consumed_bits - min_consume_bits;
if (consumed_bits > 64)
*value |= ((uint64_t)data[*pos_io]) << (64 - (consumed_bits - min_consume_bits));
*value &= UINT64_MAX >> (64 - num_bits);
*bit_pos_io += num_bits;
*pos_io = (uint32_t)((*bit_pos_io) >> 3);
}
PutBitBuffer::PutBitBuffer(ByteArray *w_buffer)
{
mWBuffer = w_buffer;
mRWBytes = 0;
mRWBytesSize = 0;
mRWBytesPos = 0;
mBitSize = (uint64_t)w_buffer->GetSize() << 3;
}
PutBitBuffer::PutBitBuffer(unsigned char *bytes, uint32_t size)
{
mWBuffer = 0;
mRWBytes = bytes;
mRWBytesSize = size;
mRWBytesPos = 0;
mBitSize = 0;
}
uint32_t PutBitBuffer::GetSize() const
{
if (mWBuffer)
return mWBuffer->GetSize();
else
return mRWBytesPos;
}
void PutBitBuffer::PutBytes(const unsigned char *data, uint32_t size)
{
BMX_ASSERT(!(mBitSize & 0x07));
Append(data, size);
mBitSize += (uint64_t)size << 3;
}
void PutBitBuffer::PutUInt8(uint8_t value)
{
BMX_ASSERT(!(mBitSize & 0x07));
Append(&value, 1);
mBitSize += 8;
}
void PutBitBuffer::PutBits(uint8_t num_bits, uint8_t value)
{
PutBits(num_bits, (uint64_t)value);
}
void PutBitBuffer::PutBits(uint8_t num_bits, uint16_t value)
{
PutBits(num_bits, (uint64_t)value);
}
void PutBitBuffer::PutBits(uint8_t num_bits, uint32_t value)
{
PutBits(num_bits, (uint64_t)value);
}
void PutBitBuffer::PutBits(uint8_t num_bits, uint64_t value)
{
uint8_t byte_bitpos = (uint8_t)(mBitSize & 0x07);
uint8_t next_byte_bitpos = (uint8_t)((mBitSize + num_bits) & 0x07);
uint8_t num_bytes = (byte_bitpos + num_bits + 7) / 8;
uint8_t incr_size = num_bytes;
if (byte_bitpos != 0)
incr_size -= 1;
Grow(incr_size);
unsigned char *bytes = GetBytesAvailable();
if (byte_bitpos != 0)
bytes--;
uint64_t shift_value; // bits shifted to msb
if ((64 - num_bits - byte_bitpos) >= 0)
shift_value = value << (64 - num_bits - byte_bitpos);
else
shift_value = value >> (- (64 - num_bits - byte_bitpos)); // existing + new bits > 64
uint8_t first_byte_mask = (uint8_t)(0xff << (8 - byte_bitpos));
uint8_t last_byte_mask = 0;
if (next_byte_bitpos != 0)
last_byte_mask = (uint8_t)(0xff >> next_byte_bitpos);
uint8_t existing_byte_mask;
uint8_t i;
for (i = 0; i < num_bytes; i++) {
existing_byte_mask = 0;
if (i == 0)
existing_byte_mask |= first_byte_mask;
if (i == num_bytes - 1)
existing_byte_mask |= last_byte_mask;
bytes[i] = (bytes[i] & existing_byte_mask) | (uint8_t)((shift_value >> 56) & 0xff);
shift_value <<= 8;
if (i == 0) // reinstate bits shifted out if (64 - num_bits - byte_bitpos) < 0
shift_value |= ((value << 8) >> byte_bitpos) & 0xff;
}
IncrementSize(incr_size);
mBitSize += num_bits;
}
void PutBitBuffer::PutBits(uint8_t num_bits, int8_t value)
{
PutBits(num_bits, (int64_t)value);
}
void PutBitBuffer::PutBits(uint8_t num_bits, int16_t value)
{
PutBits(num_bits, (int64_t)value);
}
void PutBitBuffer::PutBits(uint8_t num_bits, int32_t value)
{
PutBits(num_bits, (int64_t)value);
}
void PutBitBuffer::PutBits(uint8_t num_bits, int64_t value)
{
uint64_t sign = UINT64_C(1) << (num_bits - 1);
uint64_t u_value;
if (value < 0)
u_value = sign | (value & (sign - 1));
else
u_value = value;
PutBits(num_bits, u_value);
}
void PutBitBuffer::SetBitPos(uint64_t pos)
{
BMX_ASSERT(mRWBytes); // currently only implemented for mRWBytes
mBitSize = pos;
mRWBytesPos = (uint32_t)((pos + 7) >> 3);
}
void PutBitBuffer::Append(const unsigned char *bytes, uint32_t size)
{
if (mWBuffer) {
mWBuffer->Append(bytes, size);
} else {
BMX_CHECK(mRWBytesPos + size <= mRWBytesSize);
memcpy(&mRWBytes[mRWBytesPos], bytes, size);
mRWBytesPos += size;
}
}
unsigned char* PutBitBuffer::GetBytesAvailable() const
{
if (mWBuffer) {
return mWBuffer->GetBytesAvailable();
} else {
if (mRWBytesPos >= mRWBytesSize)
return 0;
else
return &mRWBytes[mRWBytesPos];
}
}
void PutBitBuffer::IncrementSize(uint32_t inc)
{
if (mWBuffer) {
mWBuffer->IncrementSize(inc);
} else {
BMX_CHECK(inc <= mRWBytesSize && mRWBytesPos <= mRWBytesSize - inc);
mRWBytesPos += inc;
}
}
void PutBitBuffer::Grow(uint32_t min_size)
{
if (mWBuffer) {
mWBuffer->Grow(min_size);
if (min_size > 0)
memset(mWBuffer->GetBytesAvailable(), 0, min_size);
} else {
BMX_CHECK(min_size <= mRWBytesSize && mRWBytesPos <= mRWBytesSize - min_size);
}
}
| 25.26601
| 111
| 0.649834
|
AllMethodGrind
|
39983831b290107356747722b8b8a138dd6d427d
| 799
|
hpp
|
C++
|
bs_bos_core/src/explicit_model.hpp
|
bs-eagle/bs-eagle
|
b1017a4f6ac2dcafba2deafec84052ddde792671
|
[
"BSD-3-Clause"
] | 7
|
2015-07-16T22:30:36.000Z
|
2020-02-06T10:16:42.000Z
|
bs_bos_core/src/explicit_model.hpp
|
bs-eagle/bs-eagle
|
b1017a4f6ac2dcafba2deafec84052ddde792671
|
[
"BSD-3-Clause"
] | null | null | null |
bs_bos_core/src/explicit_model.hpp
|
bs-eagle/bs-eagle
|
b1017a4f6ac2dcafba2deafec84052ddde792671
|
[
"BSD-3-Clause"
] | 3
|
2017-01-05T20:06:28.000Z
|
2021-12-20T16:19:10.000Z
|
#ifndef EXPLICIT_MODEL_HPP_b3428474_754b_11e0_a55e_8fd394202658
#define EXPLICIT_MODEL_HPP_b3428474_754b_11e0_a55e_8fd394202658
/**
* \file explicit_model.hpp
* \brief EXPLICIT Initialization model
* \author Sergey Miryanov (sergey-miryanov), sergey.miryanov@gmail.com
* \date 03.05.2011
* \copyright This source code is released under the terms of
* the BSD License. See LICENSE for more details.
* */
#include "init_model_iface.hpp"
namespace blue_sky
{
class idata;
class rs_mesh_iface;
class calc_model;
class BS_API_PLUGIN explicit_model : public init_model_iface
{
public:
BLUE_SKY_TYPE_DECL (explicit_model);
void
init (BS_SP (calc_model) model, BS_SP (idata) data, BS_SP (rs_mesh_iface) mesh);
};
}
#endif //
| 24.212121
| 84
| 0.71965
|
bs-eagle
|
399a60eb69b17fbcb51cc18fee6538f34f8feef9
| 28,716
|
cpp
|
C++
|
mtp/ffs/mtp_MtpDatabase.cpp
|
imranpopz/android_bootable_recovery-1
|
ec4512ad1e20f640b3dcd6faf8c04cae711e4f30
|
[
"Apache-2.0"
] | 95
|
2018-10-31T12:12:01.000Z
|
2022-03-20T21:30:48.000Z
|
mtp/ffs/mtp_MtpDatabase.cpp
|
imranpopz/android_bootable_recovery-1
|
ec4512ad1e20f640b3dcd6faf8c04cae711e4f30
|
[
"Apache-2.0"
] | 34
|
2018-10-22T11:01:15.000Z
|
2021-11-21T14:10:26.000Z
|
mtp/ffs/mtp_MtpDatabase.cpp
|
imranpopz/android_bootable_recovery-1
|
ec4512ad1e20f640b3dcd6faf8c04cae711e4f30
|
[
"Apache-2.0"
] | 81
|
2018-10-23T08:37:20.000Z
|
2022-03-20T00:27:08.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.
*
* Copyright (C) 2014 TeamWin - bigbiff and Dees_Troy mtp database conversion to C++
*/
#include <utils/Log.h>
#include <assert.h>
#include <cutils/properties.h>
#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
#include <libgen.h>
#include <limits.h>
#include <stdio.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <map>
#include <string>
#include "MtpDataPacket.h"
#include "MtpDatabase.h"
#include "MtpDebug.h"
#include "MtpObjectInfo.h"
#include "MtpProperty.h"
#include "MtpStorage.h"
#include "MtpStringBuffer.h"
#include "MtpUtils.h"
#include "mtp.h"
#include "mtp_MtpDatabase.hpp"
IMtpDatabase::IMtpDatabase() {
storagenum = 0;
count = -1;
}
IMtpDatabase::~IMtpDatabase() {
std::map<int, MtpStorage*>::iterator i;
for (i = storagemap.begin(); i != storagemap.end(); i++) {
delete i->second;
}
}
int IMtpDatabase::DEVICE_PROPERTIES[3] = { MTP_DEVICE_PROPERTY_SYNCHRONIZATION_PARTNER,
MTP_DEVICE_PROPERTY_DEVICE_FRIENDLY_NAME,
MTP_DEVICE_PROPERTY_IMAGE_SIZE };
int IMtpDatabase::FILE_PROPERTIES[10] = {
// NOTE must match beginning of AUDIO_PROPERTIES, VIDEO_PROPERTIES
// and IMAGE_PROPERTIES below
MTP_PROPERTY_STORAGE_ID, MTP_PROPERTY_OBJECT_FORMAT, MTP_PROPERTY_PROTECTION_STATUS,
MTP_PROPERTY_OBJECT_SIZE, MTP_PROPERTY_OBJECT_FILE_NAME, MTP_PROPERTY_DATE_MODIFIED,
MTP_PROPERTY_PARENT_OBJECT, MTP_PROPERTY_PERSISTENT_UID, MTP_PROPERTY_NAME,
// TODO: why is DISPLAY_NAME not here?
MTP_PROPERTY_DATE_ADDED
};
int IMtpDatabase::AUDIO_PROPERTIES[19] = {
// NOTE must match FILE_PROPERTIES above
MTP_PROPERTY_STORAGE_ID, MTP_PROPERTY_OBJECT_FORMAT, MTP_PROPERTY_PROTECTION_STATUS,
MTP_PROPERTY_OBJECT_SIZE, MTP_PROPERTY_OBJECT_FILE_NAME, MTP_PROPERTY_DATE_MODIFIED,
MTP_PROPERTY_PARENT_OBJECT, MTP_PROPERTY_PERSISTENT_UID, MTP_PROPERTY_NAME,
MTP_PROPERTY_DISPLAY_NAME, MTP_PROPERTY_DATE_ADDED,
// audio specific properties
MTP_PROPERTY_ARTIST, MTP_PROPERTY_ALBUM_NAME, MTP_PROPERTY_ALBUM_ARTIST, MTP_PROPERTY_TRACK,
MTP_PROPERTY_ORIGINAL_RELEASE_DATE, MTP_PROPERTY_DURATION, MTP_PROPERTY_GENRE,
MTP_PROPERTY_COMPOSER
};
int IMtpDatabase::VIDEO_PROPERTIES[15] = {
// NOTE must match FILE_PROPERTIES above
MTP_PROPERTY_STORAGE_ID, MTP_PROPERTY_OBJECT_FORMAT, MTP_PROPERTY_PROTECTION_STATUS,
MTP_PROPERTY_OBJECT_SIZE, MTP_PROPERTY_OBJECT_FILE_NAME, MTP_PROPERTY_DATE_MODIFIED,
MTP_PROPERTY_PARENT_OBJECT, MTP_PROPERTY_PERSISTENT_UID, MTP_PROPERTY_NAME,
MTP_PROPERTY_DISPLAY_NAME, MTP_PROPERTY_DATE_ADDED,
// video specific properties
MTP_PROPERTY_ARTIST, MTP_PROPERTY_ALBUM_NAME, MTP_PROPERTY_DURATION, MTP_PROPERTY_DESCRIPTION
};
int IMtpDatabase::IMAGE_PROPERTIES[12] = {
// NOTE must match FILE_PROPERTIES above
MTP_PROPERTY_STORAGE_ID, MTP_PROPERTY_OBJECT_FORMAT, MTP_PROPERTY_PROTECTION_STATUS,
MTP_PROPERTY_OBJECT_SIZE, MTP_PROPERTY_OBJECT_FILE_NAME, MTP_PROPERTY_DATE_MODIFIED,
MTP_PROPERTY_PARENT_OBJECT, MTP_PROPERTY_PERSISTENT_UID, MTP_PROPERTY_NAME,
MTP_PROPERTY_DISPLAY_NAME, MTP_PROPERTY_DATE_ADDED,
// image specific properties
MTP_PROPERTY_DESCRIPTION
};
int IMtpDatabase::ALL_PROPERTIES[25] = {
// NOTE must match FILE_PROPERTIES above
MTP_PROPERTY_STORAGE_ID, MTP_PROPERTY_OBJECT_FORMAT, MTP_PROPERTY_PROTECTION_STATUS,
MTP_PROPERTY_OBJECT_SIZE, MTP_PROPERTY_OBJECT_FILE_NAME, MTP_PROPERTY_DATE_MODIFIED,
MTP_PROPERTY_PARENT_OBJECT, MTP_PROPERTY_PERSISTENT_UID, MTP_PROPERTY_NAME,
MTP_PROPERTY_DISPLAY_NAME, MTP_PROPERTY_DATE_ADDED,
// image specific properties
MTP_PROPERTY_DESCRIPTION,
// audio specific properties
MTP_PROPERTY_ARTIST, MTP_PROPERTY_ALBUM_NAME, MTP_PROPERTY_ALBUM_ARTIST, MTP_PROPERTY_TRACK,
MTP_PROPERTY_ORIGINAL_RELEASE_DATE, MTP_PROPERTY_DURATION, MTP_PROPERTY_GENRE,
MTP_PROPERTY_COMPOSER,
// video specific properties
MTP_PROPERTY_ARTIST, MTP_PROPERTY_ALBUM_NAME, MTP_PROPERTY_DURATION, MTP_PROPERTY_DESCRIPTION,
// image specific properties
MTP_PROPERTY_DESCRIPTION
};
int IMtpDatabase::SUPPORTED_PLAYBACK_FORMATS[26] = { SUPPORTED_PLAYBACK_FORMAT_UNDEFINED,
SUPPORTED_PLAYBACK_FORMAT_ASSOCIATION,
SUPPORTED_PLAYBACK_FORMAT_TEXT,
SUPPORTED_PLAYBACK_FORMAT_HTML,
SUPPORTED_PLAYBACK_FORMAT_WAV,
SUPPORTED_PLAYBACK_FORMAT_MP3,
SUPPORTED_PLAYBACK_FORMAT_MPEG,
SUPPORTED_PLAYBACK_FORMAT_EXIF_JPEG,
SUPPORTED_PLAYBACK_FORMAT_TIFF_EP,
SUPPORTED_PLAYBACK_FORMAT_BMP,
SUPPORTED_PLAYBACK_FORMAT_GIF,
SUPPORTED_PLAYBACK_FORMAT_JFIF,
SUPPORTED_PLAYBACK_FORMAT_PNG,
SUPPORTED_PLAYBACK_FORMAT_TIFF,
SUPPORTED_PLAYBACK_FORMAT_WMA,
SUPPORTED_PLAYBACK_FORMAT_OGG,
SUPPORTED_PLAYBACK_FORMAT_AAC,
SUPPORTED_PLAYBACK_FORMAT_MP4_CONTAINER,
SUPPORTED_PLAYBACK_FORMAT_MP2,
SUPPORTED_PLAYBACK_FORMAT_3GP_CONTAINER,
SUPPORTED_PLAYBACK_FORMAT_ABSTRACT_AV_PLAYLIST,
SUPPORTED_PLAYBACK_FORMAT_WPL_PLAYLIST,
SUPPORTED_PLAYBACK_FORMAT_M3U_PLAYLIST,
SUPPORTED_PLAYBACK_FORMAT_PLS_PLAYLIST,
SUPPORTED_PLAYBACK_FORMAT_XML_DOCUMENT,
SUPPORTED_PLAYBACK_FORMAT_FLAC };
MtpObjectHandle IMtpDatabase::beginSendObject(const char* path, MtpObjectFormat format,
MtpObjectHandle parent, MtpStorageID storageID,
uint64_t size, time_t modified) {
if (storagemap.find(storageID) == storagemap.end()) return kInvalidObjectHandle;
return storagemap[storageID]->beginSendObject(path, format, parent, size, modified);
}
void IMtpDatabase::endSendObject(const char* path, MtpObjectHandle handle, MtpObjectFormat format,
bool succeeded) {
MTPD("endSendObject() %s\n", path);
if (!succeeded) {
MTPE("endSendObject() failed, unlinking %s\n", path);
unlink(path);
}
std::map<int, MtpStorage*>::iterator storit;
for (storit = storagemap.begin(); storit != storagemap.end(); storit++)
storit->second->endSendObject(path, handle, format, succeeded);
}
void IMtpDatabase::createDB(MtpStorage* storage, MtpStorageID storageID) {
storagemap[storageID] = storage;
storage->createDB();
}
void IMtpDatabase::destroyDB(MtpStorageID storageID) {
MtpStorage* storage = storagemap[storageID];
storagemap.erase(storageID);
delete storage;
}
MtpObjectHandleList* IMtpDatabase::getObjectList(MtpStorageID storageID,
__attribute__((unused)) MtpObjectFormat format,
MtpObjectHandle parent) {
MTPD("IMtpDatabase::getObjectList::storageID: %d\n", storageID);
MtpObjectHandleList* list = storagemap[storageID]->getObjectList(storageID, parent);
MTPD("IMtpDatabase::getObjectList::list size: %d\n", list->size());
return list;
}
int IMtpDatabase::getNumObjects(MtpStorageID storageID,
__attribute__((unused)) MtpObjectFormat format,
MtpObjectHandle parent) {
MtpObjectHandleList* list = storagemap[storageID]->getObjectList(storageID, parent);
int size = list->size();
delete list;
return size;
}
MtpObjectFormatList* IMtpDatabase::getSupportedPlaybackFormats() {
// This function tells the host PC which file formats the device supports
MtpObjectFormatList* list = new MtpObjectFormatList();
int length = sizeof(SUPPORTED_PLAYBACK_FORMATS) / sizeof(SUPPORTED_PLAYBACK_FORMATS[0]);
MTPD("IMtpDatabase::getSupportedPlaybackFormats length: %i\n", length);
for (int i = 0; i < length; i++) {
MTPD("supported playback format: %x\n", SUPPORTED_PLAYBACK_FORMATS[i]);
list->push_back(SUPPORTED_PLAYBACK_FORMATS[i]);
}
return list;
}
MtpObjectFormatList* IMtpDatabase::getSupportedCaptureFormats() {
// Android OS implementation of this function returns NULL
// so we are not implementing this function either.
MTPD(
"IMtpDatabase::getSupportedCaptureFormats returning NULL (This is what Android does as "
"well).\n");
return NULL;
}
MtpObjectPropertyList* IMtpDatabase::getSupportedObjectProperties(MtpObjectFormat format) {
int* properties;
MtpObjectPropertyList* list = new MtpObjectPropertyList();
int length = 0;
switch (format) {
case MTP_FORMAT_MP3:
case MTP_FORMAT_WAV:
case MTP_FORMAT_WMA:
case MTP_FORMAT_OGG:
case MTP_FORMAT_AAC:
properties = AUDIO_PROPERTIES;
length = sizeof(AUDIO_PROPERTIES) / sizeof(AUDIO_PROPERTIES[0]);
break;
case MTP_FORMAT_MPEG:
case MTP_FORMAT_3GP_CONTAINER:
case MTP_FORMAT_WMV:
properties = VIDEO_PROPERTIES;
length = sizeof(VIDEO_PROPERTIES) / sizeof(VIDEO_PROPERTIES[0]);
break;
case MTP_FORMAT_EXIF_JPEG:
case MTP_FORMAT_GIF:
case MTP_FORMAT_PNG:
case MTP_FORMAT_BMP:
properties = IMAGE_PROPERTIES;
length = sizeof(IMAGE_PROPERTIES) / sizeof(IMAGE_PROPERTIES[0]);
break;
case 0:
properties = ALL_PROPERTIES;
length = sizeof(ALL_PROPERTIES) / sizeof(ALL_PROPERTIES[0]);
break;
default:
properties = FILE_PROPERTIES;
length = sizeof(FILE_PROPERTIES) / sizeof(FILE_PROPERTIES[0]);
}
MTPD("IMtpDatabase::getSupportedObjectProperties length is: %i, format: %x", length, format);
for (int i = 0; i < length; i++) {
MTPD("supported object property: %x\n", properties[i]);
list->push_back(properties[i]);
}
return list;
}
MtpDevicePropertyList* IMtpDatabase::getSupportedDeviceProperties() {
MtpDevicePropertyList* list = new MtpDevicePropertyList();
int length = sizeof(DEVICE_PROPERTIES) / sizeof(DEVICE_PROPERTIES[0]);
MTPD("IMtpDatabase::getSupportedDeviceProperties length was: %i\n", length);
for (int i = 0; i < length; i++) list->push_back(DEVICE_PROPERTIES[i]);
return list;
}
MtpResponseCode IMtpDatabase::getObjectPropertyValue(MtpObjectHandle handle,
MtpObjectProperty property,
MtpDataPacket& packet) {
MTPD("IMtpDatabase::getObjectPropertyValue mtpid: %u, property: %x\n", handle, property);
int type;
MtpResponseCode result = MTP_RESPONSE_INVALID_OBJECT_HANDLE;
MtpStorage::PropEntry prop;
if (!getObjectPropertyInfo(property, type)) {
MTPE("IMtpDatabase::getObjectPropertyValue returning MTP_RESPONSE_OBJECT_PROP_NOT_SUPPORTED\n");
return MTP_RESPONSE_OBJECT_PROP_NOT_SUPPORTED;
}
std::map<int, MtpStorage*>::iterator storit;
for (storit = storagemap.begin(); storit != storagemap.end(); storit++) {
if (storit->second->getObjectPropertyValue(handle, property, prop) == 0) {
result = MTP_RESPONSE_OK;
break;
}
}
if (result != MTP_RESPONSE_OK) {
MTPE("IMtpDatabase::getObjectPropertyValue unable to locate handle: %u\n", handle);
return MTP_RESPONSE_INVALID_OBJECT_HANDLE;
}
uint64_t longValue = prop.intvalue;
// special case date properties, which are strings to MTP
// but stored internally as a uint64
if (property == MTP_PROPERTY_DATE_MODIFIED || property == MTP_PROPERTY_DATE_ADDED) {
char date[20];
formatDateTime(longValue, date, sizeof(date));
packet.putString(date);
goto out;
}
switch (type) {
case MTP_TYPE_INT8:
packet.putInt8(longValue);
break;
case MTP_TYPE_UINT8:
packet.putUInt8(longValue);
break;
case MTP_TYPE_INT16:
packet.putInt16(longValue);
break;
case MTP_TYPE_UINT16:
packet.putUInt16(longValue);
break;
case MTP_TYPE_INT32:
packet.putInt32(longValue);
break;
case MTP_TYPE_UINT32:
packet.putUInt32(longValue);
break;
case MTP_TYPE_INT64:
packet.putInt64(longValue);
break;
case MTP_TYPE_UINT64:
packet.putUInt64(longValue);
break;
case MTP_TYPE_INT128:
packet.putInt128(longValue);
break;
case MTP_TYPE_UINT128:
packet.putUInt128(longValue);
break;
case MTP_TYPE_STR: {
/*std::string stringValue = (string)stringValuesArray[0];
if (stringValue) {
const char* str = stringValue.c_str();
if (str == NULL) {
return MTP_RESPONSE_GENERAL_ERROR;
}
packet.putString(str);
} else {
packet.putEmptyString();
}*/
packet.putString(prop.strvalue.c_str());
MTPD("MTP_TYPE_STR: %x = %s\n", prop.property, prop.strvalue.c_str());
// MTPE("STRING unsupported type in getObjectPropertyValue\n");
// result = MTP_RESPONSE_INVALID_OBJECT_PROP_FORMAT;
break;
}
default:
MTPE("unsupported type in getObjectPropertyValue\n");
result = MTP_RESPONSE_INVALID_OBJECT_PROP_FORMAT;
}
out:
return result;
}
MtpResponseCode IMtpDatabase::setObjectPropertyValue(MtpObjectHandle handle,
MtpObjectProperty property,
MtpDataPacket& packet) {
int type;
MTPD("IMtpDatabase::setObjectPropertyValue start\n");
if (!getObjectPropertyInfo(property, type)) {
MTPE("IMtpDatabase::setObjectPropertyValue returning MTP_RESPONSE_OBJECT_PROP_NOT_SUPPORTED\n");
return MTP_RESPONSE_OBJECT_PROP_NOT_SUPPORTED;
}
MTPD("IMtpDatabase::setObjectPropertyValue continuing\n");
int8_t int8_t_value;
uint8_t uint8_t_value;
int16_t int16_t_value;
uint16_t uint16_t_value;
int32_t int32_t_value;
uint32_t uint32_t_value;
int64_t int64_t_value;
uint64_t uint64_t_value;
std::string stringValue;
switch (type) {
case MTP_TYPE_INT8:
MTPD("int8\n");
packet.getInt8(int8_t_value);
break;
case MTP_TYPE_UINT8:
MTPD("uint8\n");
packet.getUInt8(uint8_t_value);
break;
case MTP_TYPE_INT16:
MTPD("int16\n");
packet.getInt16(int16_t_value);
break;
case MTP_TYPE_UINT16:
MTPD("uint16\n");
packet.getUInt16(uint16_t_value);
break;
case MTP_TYPE_INT32:
MTPD("int32\n");
packet.getInt32(int32_t_value);
break;
case MTP_TYPE_UINT32:
MTPD("uint32\n");
packet.getUInt32(uint32_t_value);
break;
case MTP_TYPE_INT64:
MTPD("int64\n");
packet.getInt64(int64_t_value);
break;
case MTP_TYPE_UINT64:
MTPD("uint64\n");
packet.getUInt64(uint64_t_value);
break;
case MTP_TYPE_STR: {
MTPD("string\n");
MtpStringBuffer buffer;
packet.getString(buffer);
stringValue = buffer;
break;
}
default:
MTPE("IMtpDatabase::setObjectPropertyValue unsupported type %i in getObjectPropertyValue\n",
type);
return MTP_RESPONSE_INVALID_OBJECT_PROP_FORMAT;
}
int result = MTP_RESPONSE_OBJECT_PROP_NOT_SUPPORTED;
switch (property) {
case MTP_PROPERTY_OBJECT_FILE_NAME: {
MTPD("IMtpDatabase::setObjectPropertyValue renaming file, handle: %d, new name: '%s'\n",
handle, stringValue.c_str());
std::map<int, MtpStorage*>::iterator storit;
for (storit = storagemap.begin(); storit != storagemap.end(); storit++) {
if (storit->second->renameObject(handle, stringValue) == 0) {
MTPD("MTP_RESPONSE_OK\n");
result = MTP_RESPONSE_OK;
break;
}
}
} break;
default:
MTPE("IMtpDatabase::setObjectPropertyValue property %x not supported.\n", property);
result = MTP_RESPONSE_OBJECT_PROP_NOT_SUPPORTED;
}
MTPD("IMtpDatabase::setObjectPropertyValue returning %d\n", result);
return result;
}
MtpResponseCode IMtpDatabase::getDevicePropertyValue(MtpDeviceProperty property,
MtpDataPacket& packet) {
int type, result = 0;
char prop_value[PROPERTY_VALUE_MAX];
MTPD("property %s\n", MtpDebug::getDevicePropCodeName(property));
if (!getDevicePropertyInfo(property, type)) {
MTPE("IMtpDatabase::getDevicePropertyValue MTP_RESPONSE_DEVICE_PROP_NOT_SUPPORTED\n");
return MTP_RESPONSE_DEVICE_PROP_NOT_SUPPORTED;
}
MTPD("property %s\n", MtpDebug::getDevicePropCodeName(property));
MTPD("property %x\n", property);
MTPD("MTP_DEVICE_PROPERTY_DEVICE_FRIENDLY_NAME %x\n", MTP_DEVICE_PROPERTY_DEVICE_FRIENDLY_NAME);
switch (property) {
case MTP_DEVICE_PROPERTY_SYNCHRONIZATION_PARTNER:
case MTP_DEVICE_PROPERTY_DEVICE_FRIENDLY_NAME:
result = MTP_RESPONSE_OK;
break;
default: {
MTPE("IMtpDatabase::getDevicePropertyValue property %x not supported\n", property);
result = MTP_RESPONSE_DEVICE_PROP_NOT_SUPPORTED;
break;
}
}
if (result != MTP_RESPONSE_OK) {
MTPD("MTP_REPONSE_OK NOT OK\n");
return result;
}
long longValue = 0;
property_get("ro.build.product", prop_value, "unknown manufacturer");
switch (type) {
case MTP_TYPE_INT8: {
MTPD("MTP_TYPE_INT8\n");
packet.putInt8(longValue);
break;
}
case MTP_TYPE_UINT8: {
MTPD("MTP_TYPE_UINT8\n");
packet.putUInt8(longValue);
break;
}
case MTP_TYPE_INT16: {
MTPD("MTP_TYPE_INT16\n");
packet.putInt16(longValue);
break;
}
case MTP_TYPE_UINT16: {
MTPD("MTP_TYPE_UINT16\n");
packet.putUInt16(longValue);
break;
}
case MTP_TYPE_INT32: {
MTPD("MTP_TYPE_INT32\n");
packet.putInt32(longValue);
break;
}
case MTP_TYPE_UINT32: {
MTPD("MTP_TYPE_UINT32\n");
packet.putUInt32(longValue);
break;
}
case MTP_TYPE_INT64: {
MTPD("MTP_TYPE_INT64\n");
packet.putInt64(longValue);
break;
}
case MTP_TYPE_UINT64: {
MTPD("MTP_TYPE_UINT64\n");
packet.putUInt64(longValue);
break;
}
case MTP_TYPE_INT128: {
MTPD("MTP_TYPE_INT128\n");
packet.putInt128(longValue);
break;
}
case MTP_TYPE_UINT128: {
MTPD("MTP_TYPE_UINT128\n");
packet.putInt128(longValue);
break;
}
case MTP_TYPE_STR: {
MTPD("MTP_TYPE_STR\n");
char* str = prop_value;
packet.putString(str);
break;
}
default:
MTPE("IMtpDatabase::getDevicePropertyValue unsupported type %i in getDevicePropertyValue\n",
type);
return MTP_RESPONSE_INVALID_DEVICE_PROP_FORMAT;
}
return MTP_RESPONSE_OK;
}
MtpResponseCode IMtpDatabase::setDevicePropertyValue(__attribute__((unused))
MtpDeviceProperty property,
__attribute__((unused))
MtpDataPacket& packet) {
MTPE("IMtpDatabase::setDevicePropertyValue not implemented, returning 0\n");
return 0;
}
MtpResponseCode IMtpDatabase::resetDeviceProperty(__attribute__((unused))
MtpDeviceProperty property) {
MTPE("IMtpDatabase::resetDeviceProperty not implemented, returning -1\n");
return -1;
}
MtpResponseCode IMtpDatabase::getObjectPropertyList(MtpObjectHandle handle, uint32_t format,
uint32_t property, int groupCode, int depth,
MtpDataPacket& packet) {
MTPD("getObjectPropertyList()\n");
MTPD("property: %x\n", property);
std::map<int, MtpStorage*>::iterator storit;
for (storit = storagemap.begin(); storit != storagemap.end(); storit++) {
MTPD("IMtpDatabase::getObjectPropertyList calling getObjectPropertyList\n");
if (storit->second->getObjectPropertyList(handle, format, property, groupCode, depth, packet) ==
0) {
MTPD("MTP_RESPONSE_OK\n");
return MTP_RESPONSE_OK;
}
}
MTPE("IMtpDatabase::getObjectPropertyList MTP_RESPONSE_INVALID_OBJECT_HANDLE %i\n", handle);
return MTP_RESPONSE_INVALID_OBJECT_HANDLE;
}
MtpResponseCode IMtpDatabase::getObjectInfo(MtpObjectHandle handle, MtpObjectInfo& info) {
std::map<int, MtpStorage*>::iterator storit;
for (storit = storagemap.begin(); storit != storagemap.end(); storit++) {
if (storit->second->getObjectInfo(handle, info) == 0) {
MTPD("MTP_RESPONSE_OK\n");
return MTP_RESPONSE_OK;
}
}
MTPE("IMtpDatabase::getObjectInfo MTP_RESPONSE_INVALID_OBJECT_HANDLE %i\n", handle);
return MTP_RESPONSE_INVALID_OBJECT_HANDLE;
}
void* IMtpDatabase::getThumbnail(__attribute__((unused)) MtpObjectHandle handle,
__attribute__((unused)) size_t& outThumbSize) {
MTPE("IMtpDatabase::getThumbnail not implemented, returning 0\n");
return 0;
}
MtpResponseCode IMtpDatabase::getObjectFilePath(MtpObjectHandle handle,
MtpStringBuffer& outFilePath,
int64_t& outFileLength,
MtpObjectFormat& outFormat) {
std::map<int, MtpStorage*>::iterator storit;
for (storit = storagemap.begin(); storit != storagemap.end(); storit++) {
MTPD("IMtpDatabase::getObjectFilePath calling getObjectFilePath\n");
if (storit->second->getObjectFilePath(handle, outFilePath, outFileLength, outFormat) == 0) {
MTPD("MTP_RESPONSE_OK\n");
return MTP_RESPONSE_OK;
}
}
MTPE("IMtpDatabase::getObjectFilePath MTP_RESPONSE_INVALID_OBJECT_HANDLE %i\n", handle);
return MTP_RESPONSE_INVALID_OBJECT_HANDLE;
}
// MtpResponseCode IMtpDatabase::deleteFile(MtpObjectHandle handle) {
// MTPD("IMtpDatabase::deleteFile\n");
// std::map<int, MtpStorage*>::iterator storit;
// for (storit = storagemap.begin(); storit != storagemap.end(); storit++) {
// if (storit->second->deleteFile(handle) == 0) {
// MTPD("MTP_RESPONSE_OK\n");
// return MTP_RESPONSE_OK;
// }
// }
// MTPE("IMtpDatabase::deleteFile MTP_RESPONSE_INVALID_OBJECT_HANDLE %i\n", handle);
// return MTP_RESPONSE_INVALID_OBJECT_HANDLE;
// }
struct PropertyTableEntry {
MtpObjectProperty property;
int type;
};
static const PropertyTableEntry kObjectPropertyTable[] = {
{ MTP_PROPERTY_STORAGE_ID, MTP_TYPE_UINT32 },
{ MTP_PROPERTY_OBJECT_FORMAT, MTP_TYPE_UINT16 },
{ MTP_PROPERTY_PROTECTION_STATUS, MTP_TYPE_UINT16 },
{ MTP_PROPERTY_OBJECT_SIZE, MTP_TYPE_UINT64 },
{ MTP_PROPERTY_OBJECT_FILE_NAME, MTP_TYPE_STR },
{ MTP_PROPERTY_DATE_MODIFIED, MTP_TYPE_STR },
{ MTP_PROPERTY_PARENT_OBJECT, MTP_TYPE_UINT32 },
{ MTP_PROPERTY_PERSISTENT_UID, MTP_TYPE_UINT128 },
{ MTP_PROPERTY_NAME, MTP_TYPE_STR },
{ MTP_PROPERTY_DISPLAY_NAME, MTP_TYPE_STR },
{ MTP_PROPERTY_DATE_ADDED, MTP_TYPE_STR },
{ MTP_PROPERTY_ARTIST, MTP_TYPE_STR },
{ MTP_PROPERTY_ALBUM_NAME, MTP_TYPE_STR },
{ MTP_PROPERTY_ALBUM_ARTIST, MTP_TYPE_STR },
{ MTP_PROPERTY_TRACK, MTP_TYPE_UINT16 },
{ MTP_PROPERTY_ORIGINAL_RELEASE_DATE, MTP_TYPE_STR },
{ MTP_PROPERTY_GENRE, MTP_TYPE_STR },
{ MTP_PROPERTY_COMPOSER, MTP_TYPE_STR },
{ MTP_PROPERTY_DURATION, MTP_TYPE_UINT32 },
{ MTP_PROPERTY_DESCRIPTION, MTP_TYPE_STR },
};
static const PropertyTableEntry kDevicePropertyTable[] = {
{ MTP_DEVICE_PROPERTY_SYNCHRONIZATION_PARTNER, MTP_TYPE_STR },
{ MTP_DEVICE_PROPERTY_DEVICE_FRIENDLY_NAME, MTP_TYPE_STR },
{ MTP_DEVICE_PROPERTY_IMAGE_SIZE, MTP_TYPE_STR },
};
bool IMtpDatabase::getObjectPropertyInfo(MtpObjectProperty property, int& type) {
int count = sizeof(kObjectPropertyTable) / sizeof(kObjectPropertyTable[0]);
const PropertyTableEntry* entry = kObjectPropertyTable;
MTPD("IMtpDatabase::getObjectPropertyInfo size is: %i\n", count);
for (int i = 0; i < count; i++, entry++) {
if (entry->property == property) {
type = entry->type;
return true;
}
}
return false;
}
bool IMtpDatabase::getDevicePropertyInfo(MtpDeviceProperty property, int& type) {
int count = sizeof(kDevicePropertyTable) / sizeof(kDevicePropertyTable[0]);
const PropertyTableEntry* entry = kDevicePropertyTable;
MTPD("IMtpDatabase::getDevicePropertyInfo count is: %i\n", count);
for (int i = 0; i < count; i++, entry++) {
if (entry->property == property) {
type = entry->type;
MTPD("type: %x\n", type);
return true;
}
}
return false;
}
MtpObjectHandleList* IMtpDatabase::getObjectReferences(MtpObjectHandle handle) {
// call function and place files with associated handles into int array
MTPD(
"IMtpDatabase::getObjectReferences returning null, this seems to be what Android always "
"does.\n");
MTPD("handle: %d\n", handle);
// Windows + Android seems to always return a NULL in this function, c == null path
// The way that this is handled in Android then is to do this:
return NULL;
}
MtpResponseCode IMtpDatabase::setObjectReferences(__attribute__((unused)) MtpObjectHandle handle,
__attribute__((unused))
MtpObjectHandleList* references) {
MTPE("IMtpDatabase::setObjectReferences not implemented, returning 0\n");
return 0;
}
MtpProperty* IMtpDatabase::getObjectPropertyDesc(MtpObjectProperty property,
MtpObjectFormat format) {
MTPD("IMtpDatabase::getObjectPropertyDesc start\n");
MtpProperty* result = NULL;
switch (property) {
case MTP_PROPERTY_OBJECT_FORMAT:
// use format as default value
result = new MtpProperty(property, MTP_TYPE_UINT16, false, format);
break;
case MTP_PROPERTY_PROTECTION_STATUS:
case MTP_PROPERTY_TRACK:
result = new MtpProperty(property, MTP_TYPE_UINT16);
break;
case MTP_PROPERTY_STORAGE_ID:
case MTP_PROPERTY_PARENT_OBJECT:
case MTP_PROPERTY_DURATION:
result = new MtpProperty(property, MTP_TYPE_UINT32);
break;
case MTP_PROPERTY_OBJECT_SIZE:
result = new MtpProperty(property, MTP_TYPE_UINT64);
break;
case MTP_PROPERTY_PERSISTENT_UID:
result = new MtpProperty(property, MTP_TYPE_UINT128);
break;
case MTP_PROPERTY_NAME:
case MTP_PROPERTY_DISPLAY_NAME:
case MTP_PROPERTY_ARTIST:
case MTP_PROPERTY_ALBUM_NAME:
case MTP_PROPERTY_ALBUM_ARTIST:
case MTP_PROPERTY_GENRE:
case MTP_PROPERTY_COMPOSER:
case MTP_PROPERTY_DESCRIPTION:
result = new MtpProperty(property, MTP_TYPE_STR);
break;
case MTP_PROPERTY_DATE_MODIFIED:
case MTP_PROPERTY_DATE_ADDED:
case MTP_PROPERTY_ORIGINAL_RELEASE_DATE:
result = new MtpProperty(property, MTP_TYPE_STR);
result->setFormDateTime();
break;
case MTP_PROPERTY_OBJECT_FILE_NAME:
// We allow renaming files and folders
result = new MtpProperty(property, MTP_TYPE_STR, true);
break;
}
return result;
}
MtpProperty* IMtpDatabase::getDevicePropertyDesc(MtpDeviceProperty property) {
MtpProperty* result = NULL;
bool writable = false;
switch (property) {
case MTP_DEVICE_PROPERTY_SYNCHRONIZATION_PARTNER:
case MTP_DEVICE_PROPERTY_DEVICE_FRIENDLY_NAME:
writable = true;
// fall through
case MTP_DEVICE_PROPERTY_IMAGE_SIZE:
result = new MtpProperty(property, MTP_TYPE_STR, writable);
// get current value
// TODO: add actual values
result->setCurrentValue(0);
result->setDefaultValue(0);
break;
}
return result;
}
void IMtpDatabase::sessionStarted() {
MTPD("IMtpDatabase::sessionStarted not implemented or does nothing, returning\n");
return;
}
void IMtpDatabase::sessionEnded() {
MTPD("IMtpDatabase::sessionEnded not implemented or does nothing, returning\n");
return;
}
// ----------------------------------------------------------------------------
void IMtpDatabase::lockMutex(void) {
std::map<int, MtpStorage*>::iterator storit;
for (storit = storagemap.begin(); storit != storagemap.end(); storit++) {
storit->second->lockMutex(0);
}
}
void IMtpDatabase::unlockMutex(void) {
std::map<int, MtpStorage*>::iterator storit;
for (storit = storagemap.begin(); storit != storagemap.end(); storit++) {
storit->second->unlockMutex(0);
}
}
MtpResponseCode IMtpDatabase::beginDeleteObject(MtpObjectHandle handle) {
MTPD("IMtoDatabase::beginDeleteObject handle: %u\n", handle);
std::map<int, MtpStorage*>::iterator storit;
for (storit = storagemap.begin(); storit != storagemap.end(); storit++) {
if (storit->second->deleteFile(handle) == 0) {
MTPD("IMtpDatabase::beginDeleteObject::MTP_RESPONSE_OK\n");
return MTP_RESPONSE_OK;
}
}
return MTP_RESPONSE_INVALID_OBJECT_HANDLE;
}
void IMtpDatabase::endDeleteObject(MtpObjectHandle handle __unused, bool succeeded __unused) {
MTPD("IMtpDatabase::endDeleteObject not implemented yet\n");
}
void IMtpDatabase::rescanFile(const char* path __unused, MtpObjectHandle handle __unused,
MtpObjectFormat format __unused) {
MTPD("IMtpDatabase::rescanFile not implemented yet\n");
}
MtpResponseCode IMtpDatabase::beginMoveObject(MtpObjectHandle handle __unused,
MtpObjectHandle newParent __unused,
MtpStorageID newStorage __unused) {
MTPD("IMtpDatabase::beginMoveObject not implemented yet\n");
return MTP_RESPONSE_INVALID_OBJECT_HANDLE;
}
void IMtpDatabase::endMoveObject(MtpObjectHandle oldParent __unused,
MtpObjectHandle newParent __unused,
MtpStorageID oldStorage __unused, MtpStorageID newStorage __unused,
MtpObjectHandle handle __unused, bool succeeded __unused) {
MTPD("IMtpDatabase::endMoveObject not implemented yet\n");
}
MtpResponseCode IMtpDatabase::beginCopyObject(MtpObjectHandle handle __unused,
MtpObjectHandle newParent __unused,
MtpStorageID newStorage __unused) {
MTPD("IMtpDatabase::beginCopyObject not implemented yet\n");
return MTP_RESPONSE_INVALID_OBJECT_HANDLE;
}
void IMtpDatabase::endCopyObject(MtpObjectHandle handle __unused, bool succeeded __unused) {
MTPD("IMtpDatabase::endCopyObject not implemented yet\n");
}
| 33.743831
| 98
| 0.746309
|
imranpopz
|
399b5fe9995c29421efdc58b92713c79652f4502
| 292
|
cc
|
C++
|
storage/sharding/sharding.cc
|
hjinlin/toft
|
ebf3ebb3d37e9a59e27b197cefe8fdc3e8810441
|
[
"BSD-3-Clause"
] | 264
|
2015-01-03T11:50:17.000Z
|
2022-03-17T02:38:34.000Z
|
storage/sharding/sharding.cc
|
hjinlin/toft
|
ebf3ebb3d37e9a59e27b197cefe8fdc3e8810441
|
[
"BSD-3-Clause"
] | 12
|
2015-04-27T15:17:34.000Z
|
2021-05-01T04:31:18.000Z
|
storage/sharding/sharding.cc
|
hjinlin/toft
|
ebf3ebb3d37e9a59e27b197cefe8fdc3e8810441
|
[
"BSD-3-Clause"
] | 128
|
2015-02-07T18:13:10.000Z
|
2022-02-21T14:24:14.000Z
|
// Copyright (c) 2013, The Toft Authors.
// All rights reserved.
//
// Author: Ye Shunping <yeshunping@gmail.com>
#include "toft/storage/sharding/sharding.h"
namespace toft {
ShardingPolicy::ShardingPolicy() : shard_num_(1) {
}
ShardingPolicy::~ShardingPolicy() {
}
} // namespace util
| 17.176471
| 50
| 0.708904
|
hjinlin
|
399b7ec3c214faa112b544b4bb526a1dde110857
| 387
|
cpp
|
C++
|
recursion/6.cpp
|
ChiragLohani/Dsa-placement
|
be68273528283c41f7598169425b1e731d0eacb9
|
[
"Apache-2.0"
] | null | null | null |
recursion/6.cpp
|
ChiragLohani/Dsa-placement
|
be68273528283c41f7598169425b1e731d0eacb9
|
[
"Apache-2.0"
] | null | null | null |
recursion/6.cpp
|
ChiragLohani/Dsa-placement
|
be68273528283c41f7598169425b1e731d0eacb9
|
[
"Apache-2.0"
] | null | null | null |
#include <iostream>
using namespace std;
double sum_recursive(int n)
{
if (n <= 0) {
return 0.0;
} else {
cout << "1/" << n << (n!=1 ? " + " : " = "); // just for debugging
return (1.0 / double(n)) + sum_recursive(n-1);
}
}
int main()
{
int x;
cin>>x;
cout << sum_recursive(x) << " (recursive)" << endl;
return 0;
}
| 18.428571
| 75
| 0.459948
|
ChiragLohani
|
399f3ab199b29023dc728aec59c3b2639f73c2b5
| 392
|
cpp
|
C++
|
demo/main.cpp
|
IonkinaM/lab2
|
aa06f0430b589b8720bdf883925b4538de395045
|
[
"MIT"
] | null | null | null |
demo/main.cpp
|
IonkinaM/lab2
|
aa06f0430b589b8720bdf883925b4538de395045
|
[
"MIT"
] | null | null | null |
demo/main.cpp
|
IonkinaM/lab2
|
aa06f0430b589b8720bdf883925b4538de395045
|
[
"MIT"
] | null | null | null |
#include <header.hpp>
int main() {
const int L1 = 128;
const int L2 = 12288;
int *values = new int(9);
int k = 16;
filling_arr(values, count(L1, L2), k);
values[8] = pow(2, 20)*3;
print(values, count(L1, L2), std::cout);
delete(values);
// apple silicon 2 уровня кэша, первый = 128кб, второй = 8мб
// 64kb < 128kb < 256kb << 512kb << 1Mb << 2mb << 4mb << 8mb << 12mb
}
| 23.058824
| 70
| 0.589286
|
IonkinaM
|
39a30b122ce0e19281d620512e0297bd264d747e
| 161
|
cpp
|
C++
|
LuoguCodes/AT3918.cpp
|
Anguei/OI-Codes
|
0ef271e9af0619d4c236e314cd6d8708d356536a
|
[
"MIT"
] | null | null | null |
LuoguCodes/AT3918.cpp
|
Anguei/OI-Codes
|
0ef271e9af0619d4c236e314cd6d8708d356536a
|
[
"MIT"
] | null | null | null |
LuoguCodes/AT3918.cpp
|
Anguei/OI-Codes
|
0ef271e9af0619d4c236e314cd6d8708d356536a
|
[
"MIT"
] | null | null | null |
//【AT3918】Infinite Coins - 洛谷 - Wa
#include <iostream>
int main() {
int n, m;
std::cin >> n >> m;
std::cout << (n % 500 <= m ? "Yes" : "No") << std::endl;
}
| 20.125
| 57
| 0.509317
|
Anguei
|
39a32f5be200a05c51505a5fcb4cc8b85c8aa370
| 7,389
|
cpp
|
C++
|
src/irt/translator/expr.cpp
|
martinogden/mer
|
33b4b39b1604ce0708b0d3d1c809b95683a2f4cb
|
[
"Unlicense"
] | 2
|
2019-11-17T22:54:16.000Z
|
2020-08-07T20:53:25.000Z
|
src/irt/translator/expr.cpp
|
martinogden/mer
|
33b4b39b1604ce0708b0d3d1c809b95683a2f4cb
|
[
"Unlicense"
] | null | null | null |
src/irt/translator/expr.cpp
|
martinogden/mer
|
33b4b39b1604ce0708b0d3d1c809b95683a2f4cb
|
[
"Unlicense"
] | null | null | null |
#include "type/comparison.hpp"
#include "irt/size-analyser.hpp"
#include "irt/translator/utils.hpp"
#include "irt/translator/expr.hpp"
#include "irt/translator/bool-expr.hpp"
#include "irt/translator/lvalue.hpp"
ExprTranslator::ExprTranslator(Generator& gen, Map<IRTStruct>& structs) :
gen(gen),
structs(structs),
retval(nullptr)
{}
std::string ExprTranslator::freshLabel() {
return gen.label();
}
std::string ExprTranslator::freshTmp() {
return gen.tmp();
}
IRTStruct& ExprTranslator::getIRTStruct(const std::string& name) {
return structs.lookup(name);
}
void ExprTranslator::ret(CmdExprPtr val) {
retval = std::move(val);
}
void ExprTranslator::ret(IRTCmdPtr cmd, IRTExprPtr e) {
retval = std::make_unique<CmdExpr>(std::move(cmd), std::move(e));
}
CmdExprPtr ExprTranslator::get(Expr* expr) {
expr->accept(*this);
return std::move(retval);
}
CmdExprPtr ExprTranslator::get(ExprPtr expr) {
if (eq(expr->type, Type::BOOL))
return transBool( std::move(expr) );
expr->accept(*this);
return std::move(retval);
}
CmdExprPtr ExprTranslator::getAsLValue(ExprPtr expr) {
LValueTranslator lvt(*this);
return lvt.get(expr.get());
}
void ExprTranslator::visit(CallExpr& expr) {
std::vector<IRTCmdPtr> cmds;
std::vector<std::string> args;
for (auto& arg : expr.args) {
CmdExprPtr e = get( std::move(arg) );
std::string tmp = freshTmp();
cmds.push_back( std::move(e->cmd) );
cmds.push_back( std::make_unique<AssignCmd>(tmp, std::move(e->expr)) );
args.push_back(tmp);
}
std::string t = freshTmp();
cmds.push_back( std::make_unique<CallCmd>(t, expr.identifier, std::move(args)) );
ret( concat( std::move(cmds) ), std::make_unique<IRTIdExpr>(t) );
}
void ExprTranslator::visit(AllocExpr& expr) {
std::string tmp = freshTmp();
std::string param1 = freshTmp();
uint sz;
if ( auto t = dynamic_cast<StructType*>(expr.typeParam.get()) )
sz = structs.lookup(t->name).size;
else {
TypeSizeAnalyser tsa;
sz = tsa.get(expr.type);
}
IRTExprPtr size = std::make_unique<IRTIntExpr>(sz);
std::vector<IRTCmdPtr> cmds;
cmds.push_back( std::make_unique<AssignCmd>(param1, std::move(size)) );
std::vector<std::string> args;
std::string label;
if (expr.expr) {
std::string param2 = freshTmp();
CmdExprPtr e = get( std::move(expr.expr) );
cmds.push_back( std::move(e->cmd) );
cmds.push_back( std::make_unique<AssignCmd>(param2, std::move(e->expr)) );
args = {param1, param2};
label = "alloc_array";
}
else {
args = {param1};
label = "alloc";
}
cmds.push_back( std::make_unique<CallCmd>(tmp, "_c0_" + label, std::move(args)) );
ret( concat(std::move(cmds)), std::make_unique<IRTIdExpr>(tmp) );
}
void ExprTranslator::visit(TernaryExpr& expr) {
assert(eq(expr.type, Type::INT));
BoolExprTranslator btr(*this);
std::string l1 = freshLabel();
std::string l2 = freshLabel();
std::string l3 = freshLabel();
CmdExprPtr then = get( std::move(expr.then) );
CmdExprPtr otherwise = get( std::move(expr.otherwise) );
std::string t = freshTmp();
std::vector<IRTCmdPtr> cmds;
cmds.push_back( btr.get( std::move(expr.cond), l1, l2 ) );
cmds.push_back( std::make_unique<LabelCmd>(l1) );
cmds.push_back( std::move(then->cmd) );
cmds.push_back( std::make_unique<AssignCmd>(t, std::move(then->expr)) );
cmds.push_back( std::make_unique<GotoCmd>(l3) );
cmds.push_back( std::make_unique<LabelCmd>(l2) );
cmds.push_back( std::move(otherwise->cmd) );
cmds.push_back( std::make_unique<AssignCmd>(t, std::move(otherwise->expr)) );
cmds.push_back( std::make_unique<GotoCmd>(l3) );
cmds.push_back( std::make_unique<LabelCmd>(l3) );
IRTCmdPtr cmd = concat( std::move(cmds) );
ret( std::move(cmd), std::make_unique<IRTIdExpr>(t) );
}
void ExprTranslator::visit(BinaryExpr& expr) {
assert(eq(expr.type, Type::INT));
CmdExprPtr lhs = get( std::move(expr.left) );
CmdExprPtr rhs = get( std::move(expr.right) );
IRTCmdPtr left = std::move(lhs->cmd);
IRTCmdPtr right = std::move(rhs->cmd);
assert(left && right);
IRTCmdPtr cmd = std::make_unique<SeqCmd>( std::move(left), std::move(right) );
IRTExprPtr e;
if ( isPureOp(expr.op) )
e = std::make_unique<IRTBinaryExpr>(expr.op, std::move(lhs->expr), std::move(rhs->expr));
else {
std::string t = freshTmp();
std::vector<IRTCmdPtr> cmds;
cmds.push_back( std::move(cmd) );
cmds.push_back( std::make_unique<EffAssignCmd>(t, expr.op, std::move(lhs->expr), std::move(rhs->expr)) );
cmd = concat( std::move(cmds) );
e = std::make_unique<IRTIdExpr>(t);
}
ret( std::move(cmd), std::move(e) );
}
void ExprTranslator::visit(UnaryExpr& unary) {
assert(eq(unary.type, Type::INT));
CmdExprPtr e = get( std::move(unary.expr) );
IRTExprPtr expr;
IRTExprPtr zero = std::make_unique<IRTIntExpr>(0);
IRTExprPtr neg = std::make_unique<IRTBinaryExpr>(BinOp::SUB, std::move(zero), std::move(e->expr));
if (unary.op == UnOp::NEG)
expr = std::move(neg);
else if (unary.op == UnOp::BIT_NOT) {
// ~x = -x - 1
IRTExprPtr one = std::make_unique<IRTIntExpr>(1);
expr = std::make_unique<IRTBinaryExpr>(BinOp::SUB, std::move(neg), std::move(one));
}
else
throw 1; // we should never get here
ret( std::move(e->cmd), std::move(expr) );
}
void ExprTranslator::visit(LiteralExpr& expr) {
assert(eq(expr.type, Type::INT) || eq(expr.type, Type::INDEF));
int64_t val = expr.as.i;
if (val >= INT32_MAX) {
std::string t = freshTmp();
ret( std::make_unique<AssignCmd>(t, std::make_unique<IRTIntExpr>(val)), std::make_unique<IRTIdExpr>(t) );
}
else
ret( std::make_unique<NopCmd>(), std::make_unique<IRTIntExpr>(val) );
}
void ExprTranslator::visit(IdExpr& expr) {
ret( std::make_unique<NopCmd>(), std::make_unique<IRTIdExpr>(expr.identifier) );
}
void ExprTranslator::visit(SubscriptExpr& expr) {
ret( toRValue(expr) );
}
void ExprTranslator::visit(ArrowExpr& expr) {
throw 1; // we should never get here
}
void ExprTranslator::visit(DotExpr& expr) {
ret( toRValue(expr) );
}
void ExprTranslator::visit(DerefExpr& expr) {
ret( toRValue(expr) );
}
CmdExprPtr ExprTranslator::toRValue(Expr& expr) {
LValueTranslator lvt(*this);
CmdExprPtr e = lvt.get(&expr);
if ( dynamic_cast<IRTMemExpr*>(e->expr.get()) ) {
std::string addr = freshTmp();
std::string tmp = freshTmp();
std::vector<IRTCmdPtr> cmds;
cmds.push_back( std::move(e->cmd) );
cmds.push_back( std::make_unique<LoadCmd>(tmp, std::move(e->expr)) );
return std::make_unique<CmdExpr>( concat(std::move(cmds)), std::make_unique<IRTIdExpr>(tmp) );
}
else throw 1; // we should never get here
}
CmdExprPtr ExprTranslator::transBool(ExprPtr expr) {
BoolExprTranslator btr(*this);
std::string l1 = freshLabel();
std::string l2 = freshLabel();
std::string l3 = freshLabel();
std::string t = freshTmp();
std::vector<IRTCmdPtr> cmds;
cmds.push_back( btr.get(std::move(expr), l1, l2) );
cmds.push_back( std::make_unique<LabelCmd>(l1) );
cmds.push_back( std::make_unique<AssignCmd>(t, std::make_unique<IRTIntExpr>(1)) );
cmds.push_back( std::make_unique<GotoCmd>(l3) );
cmds.push_back( std::make_unique<LabelCmd>(l2) );
cmds.push_back( std::make_unique<AssignCmd>(t, std::make_unique<IRTIntExpr>(0)) );
cmds.push_back( std::make_unique<GotoCmd>(l3) );
cmds.push_back( std::make_unique<LabelCmd>(l3) );
IRTCmdPtr cmd = concat( std::move(cmds) );
return std::make_unique<CmdExpr>(std::move(cmd), std::make_unique<IRTIdExpr>(t));
}
| 25.926316
| 107
| 0.68223
|
martinogden
|
39aca69969eed09551e2ce784791eeac654e9393
| 135
|
cpp
|
C++
|
unix/reverse.cpp
|
kybr/MAT240B-2019
|
d3a875f90e12df195a172b4f4f485153d4251086
|
[
"MIT"
] | null | null | null |
unix/reverse.cpp
|
kybr/MAT240B-2019
|
d3a875f90e12df195a172b4f4f485153d4251086
|
[
"MIT"
] | null | null | null |
unix/reverse.cpp
|
kybr/MAT240B-2019
|
d3a875f90e12df195a172b4f4f485153d4251086
|
[
"MIT"
] | null | null | null |
#include "everything.h"
using namespace diy;
int main(int argc, char* argv[]) {
//
// reverse the stream of numbers coming in..
}
| 16.875
| 46
| 0.666667
|
kybr
|
39b2fc3009e1ef4d429390a9b45e43976ae93d52
| 1,002
|
cpp
|
C++
|
private/LoadedSQLData.cpp
|
Izowiuz/iz-sql-utilities
|
307a5c791f4e83b13e9a54dfec60fcd4c24b2ca3
|
[
"MIT"
] | 1
|
2019-07-11T07:05:03.000Z
|
2019-07-11T07:05:03.000Z
|
private/LoadedSQLData.cpp
|
Izowiuz/iz-sql-utilities
|
307a5c791f4e83b13e9a54dfec60fcd4c24b2ca3
|
[
"MIT"
] | null | null | null |
private/LoadedSQLData.cpp
|
Izowiuz/iz-sql-utilities
|
307a5c791f4e83b13e9a54dfec60fcd4c24b2ca3
|
[
"MIT"
] | null | null | null |
#include "LoadedSQLData.h"
QMap<int, QString> IzSQLUtilities::LoadedSQLData::indexColumnMap() const
{
return m_indexColumnMap;
}
void IzSQLUtilities::LoadedSQLData::setIndexColumnMap(const QMap<int, QString>& indexColumnMap)
{
m_indexColumnMap = indexColumnMap;
}
void IzSQLUtilities::LoadedSQLData::addRow(std::unique_ptr<SQLRow> row)
{
m_sqlData.push_back(std::move(row));
}
std::vector<QMetaType>& IzSQLUtilities::LoadedSQLData::sqlDataTypes()
{
return m_sqlDataTypes;
}
void IzSQLUtilities::LoadedSQLData::setSqlDataTypes(const std::vector<QMetaType>& sqlDataTypes)
{
m_sqlDataTypes = sqlDataTypes;
}
QHash<QString, int> IzSQLUtilities::LoadedSQLData::columnIndexMap() const
{
return m_columnIndexMap;
}
void IzSQLUtilities::LoadedSQLData::setColumnIndexMap(const QHash<QString, int>& columnIndexMap)
{
m_columnIndexMap = columnIndexMap;
}
std::vector<std::unique_ptr<IzSQLUtilities::SQLRow>>& IzSQLUtilities::LoadedSQLData::sqlData()
{
return m_sqlData;
}
| 23.857143
| 96
| 0.769461
|
Izowiuz
|
39b490bf22346d620848c16c8a008b0d0fb681d5
| 409
|
cpp
|
C++
|
PAT/PAT Basic/1010.cpp
|
Accelerator404/Algorithm-Demonstration
|
e40a499c23a56d363c743c76ac967d9c4247a4be
|
[
"Apache-2.0"
] | 1
|
2019-09-18T23:45:27.000Z
|
2019-09-18T23:45:27.000Z
|
PAT/PAT Basic/1010.cpp
|
Accelerator404/Algorithm-Demonstration
|
e40a499c23a56d363c743c76ac967d9c4247a4be
|
[
"Apache-2.0"
] | null | null | null |
PAT/PAT Basic/1010.cpp
|
Accelerator404/Algorithm-Demonstration
|
e40a499c23a56d363c743c76ac967d9c4247a4be
|
[
"Apache-2.0"
] | 1
|
2019-09-18T23:45:28.000Z
|
2019-09-18T23:45:28.000Z
|
#include <iostream>
using namespace std;
//PAT Advanced No.1010 “一元多项式求导”
int main() {
int c, i;
bool flag = false;
//利用输入动作触发输入循环
while (cin >> c >> i) {
if (c != 0 && i != 0) {
if (flag)
cout << ' ';
else
flag = true;
cout << c * i << ' ' << i - 1;
}
//注意题设中的指数递降,也就是如果第一次就输入指数为0即触发零多项式判断
else if (i == 0 && !flag) {
cout << "0 0" << endl;
return 0;
}
}
return 0;
}
| 15.730769
| 39
| 0.511002
|
Accelerator404
|
39b5f2f5cbf139a32e7665d06b9ee3684286d10a
| 1,683
|
cc
|
C++
|
components/component_updater/configurator_impl_unittest.cc
|
metux/chromium-deb
|
3c08e9b89a1b6f95f103a61ff4f528dbcd57fc42
|
[
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | null | null | null |
components/component_updater/configurator_impl_unittest.cc
|
metux/chromium-deb
|
3c08e9b89a1b6f95f103a61ff4f528dbcd57fc42
|
[
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | null | null | null |
components/component_updater/configurator_impl_unittest.cc
|
metux/chromium-deb
|
3c08e9b89a1b6f95f103a61ff4f528dbcd57fc42
|
[
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | null | null | null |
// Copyright (c) 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <memory>
#include "base/command_line.h"
#include "base/macros.h"
#include "components/component_updater/configurator_impl.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace component_updater {
namespace {
const int kDelayOneMinute = 60;
const int kDelayOneHour = kDelayOneMinute * 60;
} // namespace
using base::CommandLine;
class ComponentUpdaterConfiguratorImplTest : public testing::Test {
public:
ComponentUpdaterConfiguratorImplTest() {}
~ComponentUpdaterConfiguratorImplTest() override {}
private:
DISALLOW_COPY_AND_ASSIGN(ComponentUpdaterConfiguratorImplTest);
};
TEST_F(ComponentUpdaterConfiguratorImplTest, FastUpdate) {
// Test the default timing values when no command line argument is present.
base::CommandLine cmdline(base::CommandLine::NO_PROGRAM);
std::unique_ptr<ConfiguratorImpl> config(
new ConfiguratorImpl(&cmdline, nullptr, false));
CHECK_EQ(6 * kDelayOneMinute, config->InitialDelay());
CHECK_EQ(5 * kDelayOneHour, config->NextCheckDelay());
CHECK_EQ(30 * kDelayOneMinute, config->OnDemandDelay());
CHECK_EQ(15 * kDelayOneMinute, config->UpdateDelay());
// Test the fast-update timings.
cmdline.AppendSwitchASCII("--component-updater", "fast-update");
config.reset(new ConfiguratorImpl(&cmdline, nullptr, false));
CHECK_EQ(10, config->InitialDelay());
CHECK_EQ(5 * kDelayOneHour, config->NextCheckDelay());
CHECK_EQ(2, config->OnDemandDelay());
CHECK_EQ(10, config->UpdateDelay());
}
} // namespace component_updater
| 32.365385
| 77
| 0.762923
|
metux
|
39b6c205b7d40c3ebf4c554e262517b6b9a75b52
| 2,353
|
hpp
|
C++
|
Lib/Chip/Unknown/Toshiba/M061/PG.hpp
|
cjsmeele/Kvasir
|
c8d2acd8313ae52d78259ee2d409b963925f77d7
|
[
"Apache-2.0"
] | 376
|
2015-07-17T01:41:20.000Z
|
2022-03-26T04:02:49.000Z
|
Lib/Chip/Unknown/Toshiba/M061/PG.hpp
|
cjsmeele/Kvasir
|
c8d2acd8313ae52d78259ee2d409b963925f77d7
|
[
"Apache-2.0"
] | 59
|
2015-07-03T21:30:13.000Z
|
2021-03-05T11:30:08.000Z
|
Lib/Chip/Unknown/Toshiba/M061/PG.hpp
|
cjsmeele/Kvasir
|
c8d2acd8313ae52d78259ee2d409b963925f77d7
|
[
"Apache-2.0"
] | 53
|
2015-07-14T12:17:06.000Z
|
2021-06-04T07:28:40.000Z
|
#pragma once
#include <Register/Utility.hpp>
namespace Kvasir {
//General Purpose Input_Output Port (PG)
namespace PgData{ ///<PG Data Register
using Addr = Register::Address<0x400c0600,0xfffffffe,0x00000000,unsigned>;
///PG0
constexpr Register::FieldLocation<Addr,Register::maskFromRange(0,0),Register::ReadWriteAccess,unsigned> pg0{};
}
namespace PgCr{ ///<PG Control Register
using Addr = Register::Address<0x400c0604,0xfffffffe,0x00000000,unsigned>;
///PG0C
constexpr Register::FieldLocation<Addr,Register::maskFromRange(0,0),Register::ReadWriteAccess,unsigned> pg0c{};
}
namespace PgFr1{ ///<PG Function Register 1
using Addr = Register::Address<0x400c0608,0xfffffffe,0x00000000,unsigned>;
///PG0F1
constexpr Register::FieldLocation<Addr,Register::maskFromRange(0,0),Register::ReadWriteAccess,unsigned> pg0f1{};
}
namespace PgFr2{ ///<PG Function Register 2
using Addr = Register::Address<0x400c060c,0xfffffffe,0x00000000,unsigned>;
///PG0F2
constexpr Register::FieldLocation<Addr,Register::maskFromRange(0,0),Register::ReadWriteAccess,unsigned> pg0f2{};
}
namespace PgOd{ ///<PG Open Drain Control Register
using Addr = Register::Address<0x400c0628,0xfffffffe,0x00000000,unsigned>;
///PG0OD
constexpr Register::FieldLocation<Addr,Register::maskFromRange(0,0),Register::ReadWriteAccess,unsigned> pg0od{};
}
namespace PgPup{ ///<PG Pull-Up Control Register
using Addr = Register::Address<0x400c062c,0xfffffffe,0x00000000,unsigned>;
///PG0UP
constexpr Register::FieldLocation<Addr,Register::maskFromRange(0,0),Register::ReadWriteAccess,unsigned> pg0up{};
}
namespace PgPgn{ ///<PG Pull-Down Control Register
using Addr = Register::Address<0x400c0630,0xfffffffe,0x00000000,unsigned>;
///PG0DN
constexpr Register::FieldLocation<Addr,Register::maskFromRange(0,0),Register::ReadWriteAccess,unsigned> pg0dn{};
}
namespace PgIe{ ///<PG Input Enable Control Register
using Addr = Register::Address<0x400c0638,0xfffffffe,0x00000000,unsigned>;
///PG0IE
constexpr Register::FieldLocation<Addr,Register::maskFromRange(0,0),Register::ReadWriteAccess,unsigned> pg0ie{};
}
}
| 51.152174
| 121
| 0.695708
|
cjsmeele
|
39b77990f6b48c3cd3807cdf1c80cb9066de238f
| 317
|
cpp
|
C++
|
sonar_control/src/SonarControl.cpp
|
g4idrijs/underwater_map_construction
|
04c4ebbc094449994f53e280b85db604b468019b
|
[
"MIT"
] | null | null | null |
sonar_control/src/SonarControl.cpp
|
g4idrijs/underwater_map_construction
|
04c4ebbc094449994f53e280b85db604b468019b
|
[
"MIT"
] | null | null | null |
sonar_control/src/SonarControl.cpp
|
g4idrijs/underwater_map_construction
|
04c4ebbc094449994f53e280b85db604b468019b
|
[
"MIT"
] | 1
|
2020-06-28T09:45:26.000Z
|
2020-06-28T09:45:26.000Z
|
#include "SonarControl.h"
SonarControl::SonarControl(ros::NodeHandle* n){
ros::NodeHandle nh("~");
nh.param("cloudSubscribeTopic_", cloudSubscribeTopic_, string("/Sonar/Scan/SonarCloud"));
nh.param("cloudPublishTopic_", cloudPublishTopic_, string("/SonarControl/Cloud"));
}
int main (int argc, char** argv){
}
| 24.384615
| 90
| 0.735016
|
g4idrijs
|
39b8ae6a3265c4a39077cb71a6ff1392672ebffd
| 3,780
|
cpp
|
C++
|
DEM/Low/src/UI/CEGUI/DEMRenderTarget.cpp
|
niello/deusexmachina
|
2f698054fe82d8b40a0a0e58b86d64ffed0de06c
|
[
"MIT"
] | 15
|
2019-05-07T11:26:13.000Z
|
2022-01-12T18:26:45.000Z
|
DEM/Low/src/UI/CEGUI/DEMRenderTarget.cpp
|
niello/deusexmachina
|
2f698054fe82d8b40a0a0e58b86d64ffed0de06c
|
[
"MIT"
] | 16
|
2021-10-04T17:15:31.000Z
|
2022-03-20T09:34:29.000Z
|
DEM/Low/src/UI/CEGUI/DEMRenderTarget.cpp
|
niello/deusexmachina
|
2f698054fe82d8b40a0a0e58b86d64ffed0de06c
|
[
"MIT"
] | 2
|
2019-04-28T23:27:48.000Z
|
2019-05-07T11:26:18.000Z
|
#if defined(_MSC_VER)
# pragma warning(push)
# pragma warning(disable : 4530) // C++ exception handler used, but unwind semantics not enabled
#endif
#include "DEMRenderTarget.h"
#include <Render/GPUDriver.h>
#include <UI/CEGUI/DEMGeometryBuffer.h>
#include <glm/gtc/matrix_transform.hpp>
namespace CEGUI
{
CDEMRenderTarget::CDEMRenderTarget(CDEMRenderer& owner):
d_owner(owner)
{
}
//---------------------------------------------------------------------
void CDEMRenderTarget::activate()
{
if (!d_matrixValid)
updateMatrix(RenderTarget::createViewProjMatrixForDirect3D()); // FIXME: get handedness from GPU
Render::CViewport VP;
VP.Left = static_cast<float>(d_area.left());
VP.Top = static_cast<float>(d_area.top());
VP.Width = static_cast<float>(d_area.getWidth());
VP.Height = static_cast<float>(d_area.getHeight());
VP.MinDepth = 0.0f;
VP.MaxDepth = 1.0f;
d_owner.getGPUDriver()->SetViewport(0, &VP);
d_owner.setViewProjectionMatrix(RenderTarget::d_matrix);
RenderTarget::activate();
}
//---------------------------------------------------------------------
void CDEMRenderTarget::unprojectPoint(const GeometryBuffer& buff, const glm::vec2& p_in, glm::vec2& p_out) const
{
if (!d_matrixValid)
updateMatrix(RenderTarget::createViewProjMatrixForDirect3D()); // FIXME: get handedness from GPU
const CDEMGeometryBuffer& gb = static_cast<const CDEMGeometryBuffer&>(buff);
const I32 vp[4] = {
static_cast<I32>(RenderTarget::d_area.left()),
static_cast<I32>(RenderTarget::d_area.top()),
static_cast<I32>(RenderTarget::d_area.getWidth()),
static_cast<I32>(RenderTarget::d_area.getHeight())
};
float in_x, in_y = 0.0f, in_z = 0.0f;
glm::ivec4 viewPort = glm::ivec4(vp[0], vp[1], vp[2], vp[3]);
const glm::mat4& projMatrix = RenderTarget::d_matrix;
const glm::mat4& modelMatrix = gb.getModelMatrix();
// unproject the ends of the ray
glm::vec3 unprojected1;
glm::vec3 unprojected2;
in_x = vp[2] * 0.5f;
in_y = vp[3] * 0.5f;
in_z = -RenderTarget::d_viewDistance;
unprojected1 = glm::unProject(glm::vec3(in_x, in_y, in_z), modelMatrix, projMatrix, viewPort);
in_x = p_in.x;
in_y = vp[3] - p_in.y;
in_z = 0.0;
unprojected2 = glm::unProject(glm::vec3(in_x, in_y, in_z), modelMatrix, projMatrix, viewPort);
// project points to orientate them with GeometryBuffer plane
glm::vec3 projected1;
glm::vec3 projected2;
glm::vec3 projected3;
in_x = 0.0;
in_y = 0.0;
projected1 = glm::project(glm::vec3(in_x, in_y, in_z), modelMatrix, projMatrix, viewPort);
in_x = 1.0;
in_y = 0.0;
projected2 = glm::project(glm::vec3(in_x, in_y, in_z), modelMatrix, projMatrix, viewPort);
in_x = 0.0;
in_y = 1.0;
projected3 = glm::project(glm::vec3(in_x, in_y, in_z), modelMatrix, projMatrix, viewPort);
// calculate vectors for generating the plane
const glm::vec3 pv1 = projected2 - projected1;
const glm::vec3 pv2 = projected3 - projected1;
// given the vectors, calculate the plane normal
const glm::vec3 planeNormal = glm::cross(pv1, pv2);
// calculate plane
const glm::vec3 planeNormalNormalized = glm::normalize(planeNormal);
const double pl_d = - glm::dot(projected1, planeNormalNormalized);
// calculate vector of picking ray
const glm::vec3 rv = unprojected1 - unprojected2;
// calculate intersection of ray and plane
const double pn_dot_r1 = glm::dot(unprojected1, planeNormal);
const double pn_dot_rv = glm::dot(rv, planeNormal);
const double tmp1 = pn_dot_rv != 0.0 ? (pn_dot_r1 + pl_d) / pn_dot_rv : 0.0;
const double is_x = unprojected1.x - rv.x * tmp1;
const double is_y = unprojected1.y - rv.y * tmp1;
p_out.x = static_cast<float>(is_x);
p_out.y = static_cast<float>(is_y);
}
//---------------------------------------------------------------------
}
#if defined(_MSC_VER)
# pragma warning(pop)
#endif
| 33.75
| 112
| 0.682804
|
niello
|
39bd410749a02210b06bcdb9f71d74595f086d29
| 4,367
|
cpp
|
C++
|
read_rope_shared_library/test/test.cpp
|
adct-the-experimenter/read-rope
|
0f8603cf8d6c197266bcaa447cd3ed92714a5b9d
|
[
"BSD-3-Clause"
] | 2
|
2019-12-27T19:41:27.000Z
|
2019-12-27T19:41:38.000Z
|
read_rope_shared_library/test/test.cpp
|
adct-the-experimenter/read-rope
|
0f8603cf8d6c197266bcaa447cd3ed92714a5b9d
|
[
"BSD-3-Clause"
] | null | null | null |
read_rope_shared_library/test/test.cpp
|
adct-the-experimenter/read-rope
|
0f8603cf8d6c197266bcaa447cd3ed92714a5b9d
|
[
"BSD-3-Clause"
] | null | null | null |
#include "readrope.h"
int main(int argc, char** argv)
{
/*
************************************************************
Initialize read rope system
*************************************************************
*/
//initialize read rope system
ReadRope::InitReadRopeSystem();
/*
************************************************************
Initialize serial communication with the read rope device.
************************************************************
*/
std::string port = ReadRope::GetSerialPortOfReadRopeDevice();
if(port != "Null")
{
std::cout << "Read rope device port is " << port << std::endl;
if(ReadRope::InitSerialCommunication(port,9600) == ReadRope::Status::ERROR)
{
std::cout << "Failed to connect to port " << port << "at baud rate of 9600.\n";
}
else
{
std::cout << "Successfully able to connect to read rope device on port " << port << std::endl;
}
}
else
{
std::cout << "Failed to get port of read rope device! \n.";
}
/*
************************************************************
Get ADC Value from read rope device
************************************************************
*/
uint16_t readRopeADCValue = 0;
readRopeADCValue = ReadRope::GetADCValueOfReadRope();
std::cout << "ADC value from read rope: " << readRopeADCValue << std::endl;
/*
************************************************************
Calibration
************************************************************
*/
double calibrationPhaseTime = 7.0;
std::cout << "\nUsing default library calibration methods to calibrate the device...\n";
//Calibrate section zero
std::cout << "Calibrating section 0. Please bend only section zero as much as you can within " \
<< calibrationPhaseTime << " seconds.\n";
ReadRope::CalibrateSectionZeroMaxLimit(calibrationPhaseTime);
//Calibrate section 1
std::cout << "Calibrating section 1. Please bend only section one as much as you can within " \
<< calibrationPhaseTime << " seconds.\n";
ReadRope::CalibrateSectionOneMaxLimit(calibrationPhaseTime);
//Calibrate section 2
std::cout << "Calibrating section 2. Please bend only section two as much as you can within " \
<< calibrationPhaseTime << " seconds.\n";
ReadRope::CalibrateSectionTwoMaxLimit(calibrationPhaseTime);
/*
************************************************************
Get Bend location
************************************************************
*/
bool quit = false;
while(!quit)
{
switch( ReadRope::GetBendLocationFromReadRopeDevice() )
{
case ReadRope::Bend::ERROR_BEND_NO_CALIBRATION:
{
std::cout << "Error bend without calibration\n";
break;
}
case ReadRope::Bend::NO_BEND:
{
std::cout << "No bend detected." << "ADC value:" << ReadRope::GetADCValueOfReadRope() << std::endl;
break;
}
case ReadRope::Bend::BEND_S0:
{
std::cout << "Bend in section 0 detected." << "ADC value:" << ReadRope::GetADCValueOfReadRope() << std::endl;
break;
}
case ReadRope::Bend::BEND_S1:
{
std::cout << "Bend in section 1 detected." << "ADC value:" << ReadRope::GetADCValueOfReadRope() << std::endl;
break;
}
case ReadRope::Bend::BEND_S0_S1:
{
std::cout << "Bend in section 0 and section 1 detected." << "ADC value:" << ReadRope::GetADCValueOfReadRope() << std::endl;
break;
}
case ReadRope::Bend::BEND_S2:
{
std::cout << "Bend in section 2 detected." << "ADC value:" << ReadRope::GetADCValueOfReadRope() << std::endl;
break;
}
case ReadRope::Bend::BEND_S0_S2:
{
std::cout << "Bend in section 0 and section 2 detected." << "ADC value:" << ReadRope::GetADCValueOfReadRope() << std::endl;
break;
}
case ReadRope::Bend::BEND_S1_S2:
{
std::cout << "Bend in section 1 and section 2 detected." << "ADC value:" << ReadRope::GetADCValueOfReadRope() << std::endl;
break;
}
case ReadRope::Bend::BEND_S0_S1_S2:
{
std::cout << "Bend in all 3 sections detected." << "ADC value:" << ReadRope::GetADCValueOfReadRope() << std::endl;
break;
}
}
}
/*
************************************************************
Close read rope system
*************************************************************
*/
ReadRope::CloseReadRopeSystem();
return 0;
}
| 29.113333
| 127
| 0.531257
|
adct-the-experimenter
|
39bdbcd3e405ba6af33138c133145baba97163b9
| 6,940
|
hpp
|
C++
|
ThirdParty-mod/java2cpp/android/text/InputFilter.hpp
|
kakashidinho/HQEngine
|
8125b290afa7c62db6cc6eac14e964d8138c7fd0
|
[
"MIT"
] | 1
|
2019-04-03T01:53:28.000Z
|
2019-04-03T01:53:28.000Z
|
ThirdParty-mod/java2cpp/android/text/InputFilter.hpp
|
kakashidinho/HQEngine
|
8125b290afa7c62db6cc6eac14e964d8138c7fd0
|
[
"MIT"
] | null | null | null |
ThirdParty-mod/java2cpp/android/text/InputFilter.hpp
|
kakashidinho/HQEngine
|
8125b290afa7c62db6cc6eac14e964d8138c7fd0
|
[
"MIT"
] | null | null | null |
/*================================================================================
code generated by: java2cpp
author: Zoran Angelov, mailto://baldzar@gmail.com
class: android.text.InputFilter
================================================================================*/
#ifndef J2CPP_INCLUDE_IMPLEMENTATION
#ifndef J2CPP_ANDROID_TEXT_INPUTFILTER_HPP_DECL
#define J2CPP_ANDROID_TEXT_INPUTFILTER_HPP_DECL
namespace j2cpp { namespace java { namespace lang { class Object; } } }
namespace j2cpp { namespace java { namespace lang { class CharSequence; } } }
namespace j2cpp { namespace android { namespace text { class Spanned; } } }
#include <android/text/Spanned.hpp>
#include <java/lang/CharSequence.hpp>
#include <java/lang/Object.hpp>
namespace j2cpp {
namespace android { namespace text {
class InputFilter;
namespace InputFilter_ {
class LengthFilter;
class LengthFilter
: public object<LengthFilter>
{
public:
J2CPP_DECLARE_CLASS
J2CPP_DECLARE_METHOD(0)
J2CPP_DECLARE_METHOD(1)
explicit LengthFilter(jobject jobj)
: object<LengthFilter>(jobj)
{
}
operator local_ref<java::lang::Object>() const;
operator local_ref<android::text::InputFilter>() const;
LengthFilter(jint);
local_ref< java::lang::CharSequence > filter(local_ref< java::lang::CharSequence > const&, jint, jint, local_ref< android::text::Spanned > const&, jint, jint);
}; //class LengthFilter
class AllCaps;
class AllCaps
: public object<AllCaps>
{
public:
J2CPP_DECLARE_CLASS
J2CPP_DECLARE_METHOD(0)
J2CPP_DECLARE_METHOD(1)
explicit AllCaps(jobject jobj)
: object<AllCaps>(jobj)
{
}
operator local_ref<java::lang::Object>() const;
operator local_ref<android::text::InputFilter>() const;
AllCaps();
local_ref< java::lang::CharSequence > filter(local_ref< java::lang::CharSequence > const&, jint, jint, local_ref< android::text::Spanned > const&, jint, jint);
}; //class AllCaps
} //namespace InputFilter_
class InputFilter
: public object<InputFilter>
{
public:
J2CPP_DECLARE_CLASS
J2CPP_DECLARE_METHOD(0)
typedef InputFilter_::LengthFilter LengthFilter;
typedef InputFilter_::AllCaps AllCaps;
explicit InputFilter(jobject jobj)
: object<InputFilter>(jobj)
{
}
operator local_ref<java::lang::Object>() const;
local_ref< java::lang::CharSequence > filter(local_ref< java::lang::CharSequence > const&, jint, jint, local_ref< android::text::Spanned > const&, jint, jint);
}; //class InputFilter
} //namespace text
} //namespace android
} //namespace j2cpp
#endif //J2CPP_ANDROID_TEXT_INPUTFILTER_HPP_DECL
#else //J2CPP_INCLUDE_IMPLEMENTATION
#ifndef J2CPP_ANDROID_TEXT_INPUTFILTER_HPP_IMPL
#define J2CPP_ANDROID_TEXT_INPUTFILTER_HPP_IMPL
namespace j2cpp {
android::text::InputFilter_::LengthFilter::operator local_ref<java::lang::Object>() const
{
return local_ref<java::lang::Object>(get_jobject());
}
android::text::InputFilter_::LengthFilter::operator local_ref<android::text::InputFilter>() const
{
return local_ref<android::text::InputFilter>(get_jobject());
}
android::text::InputFilter_::LengthFilter::LengthFilter(jint a0)
: object<android::text::InputFilter_::LengthFilter>(
call_new_object<
android::text::InputFilter_::LengthFilter::J2CPP_CLASS_NAME,
android::text::InputFilter_::LengthFilter::J2CPP_METHOD_NAME(0),
android::text::InputFilter_::LengthFilter::J2CPP_METHOD_SIGNATURE(0)
>(a0)
)
{
}
local_ref< java::lang::CharSequence > android::text::InputFilter_::LengthFilter::filter(local_ref< java::lang::CharSequence > const &a0, jint a1, jint a2, local_ref< android::text::Spanned > const &a3, jint a4, jint a5)
{
return call_method<
android::text::InputFilter_::LengthFilter::J2CPP_CLASS_NAME,
android::text::InputFilter_::LengthFilter::J2CPP_METHOD_NAME(1),
android::text::InputFilter_::LengthFilter::J2CPP_METHOD_SIGNATURE(1),
local_ref< java::lang::CharSequence >
>(get_jobject(), a0, a1, a2, a3, a4, a5);
}
J2CPP_DEFINE_CLASS(android::text::InputFilter_::LengthFilter,"android/text/InputFilter$LengthFilter")
J2CPP_DEFINE_METHOD(android::text::InputFilter_::LengthFilter,0,"<init>","(I)V")
J2CPP_DEFINE_METHOD(android::text::InputFilter_::LengthFilter,1,"filter","(Ljava/lang/CharSequence;IILandroid/text/Spanned;II)Ljava/lang/CharSequence;")
android::text::InputFilter_::AllCaps::operator local_ref<java::lang::Object>() const
{
return local_ref<java::lang::Object>(get_jobject());
}
android::text::InputFilter_::AllCaps::operator local_ref<android::text::InputFilter>() const
{
return local_ref<android::text::InputFilter>(get_jobject());
}
android::text::InputFilter_::AllCaps::AllCaps()
: object<android::text::InputFilter_::AllCaps>(
call_new_object<
android::text::InputFilter_::AllCaps::J2CPP_CLASS_NAME,
android::text::InputFilter_::AllCaps::J2CPP_METHOD_NAME(0),
android::text::InputFilter_::AllCaps::J2CPP_METHOD_SIGNATURE(0)
>()
)
{
}
local_ref< java::lang::CharSequence > android::text::InputFilter_::AllCaps::filter(local_ref< java::lang::CharSequence > const &a0, jint a1, jint a2, local_ref< android::text::Spanned > const &a3, jint a4, jint a5)
{
return call_method<
android::text::InputFilter_::AllCaps::J2CPP_CLASS_NAME,
android::text::InputFilter_::AllCaps::J2CPP_METHOD_NAME(1),
android::text::InputFilter_::AllCaps::J2CPP_METHOD_SIGNATURE(1),
local_ref< java::lang::CharSequence >
>(get_jobject(), a0, a1, a2, a3, a4, a5);
}
J2CPP_DEFINE_CLASS(android::text::InputFilter_::AllCaps,"android/text/InputFilter$AllCaps")
J2CPP_DEFINE_METHOD(android::text::InputFilter_::AllCaps,0,"<init>","()V")
J2CPP_DEFINE_METHOD(android::text::InputFilter_::AllCaps,1,"filter","(Ljava/lang/CharSequence;IILandroid/text/Spanned;II)Ljava/lang/CharSequence;")
android::text::InputFilter::operator local_ref<java::lang::Object>() const
{
return local_ref<java::lang::Object>(get_jobject());
}
local_ref< java::lang::CharSequence > android::text::InputFilter::filter(local_ref< java::lang::CharSequence > const &a0, jint a1, jint a2, local_ref< android::text::Spanned > const &a3, jint a4, jint a5)
{
return call_method<
android::text::InputFilter::J2CPP_CLASS_NAME,
android::text::InputFilter::J2CPP_METHOD_NAME(0),
android::text::InputFilter::J2CPP_METHOD_SIGNATURE(0),
local_ref< java::lang::CharSequence >
>(get_jobject(), a0, a1, a2, a3, a4, a5);
}
J2CPP_DEFINE_CLASS(android::text::InputFilter,"android/text/InputFilter")
J2CPP_DEFINE_METHOD(android::text::InputFilter,0,"filter","(Ljava/lang/CharSequence;IILandroid/text/Spanned;II)Ljava/lang/CharSequence;")
} //namespace j2cpp
#endif //J2CPP_ANDROID_TEXT_INPUTFILTER_HPP_IMPL
#endif //J2CPP_INCLUDE_IMPLEMENTATION
| 30.982143
| 220
| 0.708646
|
kakashidinho
|
39be02b7823513716ee378ab7a6d34dde73493c8
| 1,372
|
cpp
|
C++
|
UTEngine/Native/NStatLogFile.cpp
|
neuromancer/UTEngine
|
630398eabbaa173c933234e4c44ff2d62f0347e8
|
[
"Apache-2.0",
"CC0-1.0"
] | 50
|
2020-12-02T17:41:17.000Z
|
2022-03-18T05:08:21.000Z
|
UTEngine/Native/NStatLogFile.cpp
|
neuromancer/UTEngine
|
630398eabbaa173c933234e4c44ff2d62f0347e8
|
[
"Apache-2.0",
"CC0-1.0"
] | 11
|
2021-07-14T13:41:12.000Z
|
2021-09-30T10:32:58.000Z
|
UTEngine/Native/NStatLogFile.cpp
|
neuromancer/UTEngine
|
630398eabbaa173c933234e4c44ff2d62f0347e8
|
[
"Apache-2.0",
"CC0-1.0"
] | 4
|
2021-07-20T20:22:36.000Z
|
2022-01-06T15:30:26.000Z
|
#include "Precomp.h"
#include "NStatLogFile.h"
#include "VM/NativeFunc.h"
#include "Engine.h"
void NStatLogFile::RegisterFunctions()
{
RegisterVMNativeFunc_0("StatLogFile", "CloseLog", &NStatLogFile::CloseLog, 0);
RegisterVMNativeFunc_0("StatLogFile", "FileFlush", &NStatLogFile::FileFlush, 0);
RegisterVMNativeFunc_1("StatLogFile", "FileLog", &NStatLogFile::FileLog, 0);
RegisterVMNativeFunc_1("StatLogFile", "GetChecksum", &NStatLogFile::GetChecksum, 0);
RegisterVMNativeFunc_0("StatLogFile", "OpenLog", &NStatLogFile::OpenLog, 0);
RegisterVMNativeFunc_1("StatLogFile", "Watermark", &NStatLogFile::Watermark, 0);
}
void NStatLogFile::CloseLog(UObject* Self)
{
engine->LogUnimplemented("StatLogFile.CloseLog");
}
void NStatLogFile::FileFlush(UObject* Self)
{
engine->LogUnimplemented("StatLogFile.FileFlush");
}
void NStatLogFile::FileLog(UObject* Self, const std::string& EventString)
{
engine->LogUnimplemented("StatLogFile.FileLog(" + EventString + ")");
}
void NStatLogFile::GetChecksum(UObject* Self, std::string& Checksum)
{
Checksum = "GetChecksum dummy value";
engine->LogUnimplemented("StatLogFile.GetChecksum");
}
void NStatLogFile::OpenLog(UObject* Self)
{
engine->LogUnimplemented("StatLogFile.OpenLog");
}
void NStatLogFile::Watermark(UObject* Self, const std::string& EventString)
{
engine->LogUnimplemented("StatLogFile.Watermark");
}
| 29.191489
| 85
| 0.764577
|
neuromancer
|
39c2a18b03880bec4bc9ebb178344add4c9e5a57
| 2,269
|
cpp
|
C++
|
test/input_cases/tcs_trough_physical_input.cpp
|
mfwatki2/ssc
|
289a6df2e0563bbad588da947e2a9fcc3f9dda55
|
[
"MIT"
] | null | null | null |
test/input_cases/tcs_trough_physical_input.cpp
|
mfwatki2/ssc
|
289a6df2e0563bbad588da947e2a9fcc3f9dda55
|
[
"MIT"
] | null | null | null |
test/input_cases/tcs_trough_physical_input.cpp
|
mfwatki2/ssc
|
289a6df2e0563bbad588da947e2a9fcc3f9dda55
|
[
"MIT"
] | null | null | null |
#include <string.h>
#include "sscapi.h"
#include "vartab.h"
#include "core.h"
#include "tcs_trough_physical_input.h"
using namespace std;
/**
* Custom Testing Handler that does nothing
*/
void var(var_table* vt, string name, string value){
var_data* vd = new var_data(value);
vt->assign(name, *vd);
}
void var(var_table* vt, string name, double value){
var_data* vd = new var_data((ssc_number_t)value);
vt->assign(name, *vd);
}
void var(var_table* vt, string name, float* array, int length){
var_data* vd = new var_data(array, length);
vt->assign(name, *vd);
}
void var(var_table* vt, string name, float* matrix, int nr, int nc){
var_data* vd = new var_data(matrix, nr, nc);
vt->assign(name, *vd);
}
void assign_default_variables(var_table* vt){
var(vt, "file_name", "weather.csv");
var(vt, "track_mode", 1);
var(vt, "tilt", 0);
var(vt, "azimuth", 0);
var(vt, "system_capacity", 99899.9921875);
var(vt, "nSCA", 8);
var(vt, "nHCEt", 4);
var(vt, "nColt", 4);
var(vt, "nHCEVar", 4);
var(vt, "nLoops", 181);
var(vt, "eta_pump", 0.85000002384185791);
var(vt, "HDR_rough", 4.5699998736381531e-005);
var(vt, "theta_stow", 170);
var(vt, "theta_dep", 10);
var(vt, "Row_Distance", 15);
var(vt, "FieldConfig", 2);
var(vt, "T_startup", 300);
var(vt, "P_ref", 111);
var(vt, "m_dot_htfmin", 1);
var(vt, "m_dot_htfmax", 12);
var(vt, "T_loop_in_des", 293);
var(vt, "T_loop_out", 391);
var(vt, "Fluid", 21);
var(vt, "T_fp", 150);
var(vt, "I_bn_des", 950);
var(vt, "V_hdr_max", 3);
var(vt, "V_hdr_min", 2);
var(vt, "Pipe_hl_coef", 0.44999998807907104);
var(vt, "SCA_drives_elec", 125);
var(vt, "fthrok", 1);
var(vt, "fthrctrl", 2);
var(vt, "water_usage_per_wash", 0.69999998807907104);
var(vt, "washing_frequency", 63);
var(vt, "accept_mode", 0);
var(vt, "accept_init", 0);
var(vt, "accept_loc", 1);
var(vt, "solar_mult", 2);
var(vt, "mc_bal_hot", 0.20000000298023224);
var(vt, "mc_bal_cold", 0.20000000298023224);
var(vt, "mc_bal_sca", 4.5);
}
void create_default(){
var_table* vartab = new var_table;
assign_default_variables(vartab);
ssc_data_t* p_data = reinterpret_cast<ssc_data_t*>(vartab);
// copy vartab data into p_data
std::string name = "tcstrough_physical";
//ssc_module_exec_simple(name.c_str(), p_data);
}
| 26.08046
| 68
| 0.668576
|
mfwatki2
|
39c39a66067ff8660dbe12126e281a7095d38236
| 63
|
hpp
|
C++
|
src/boost_mpl_aux__preprocessed_dmc_advance_forward.hpp
|
miathedev/BoostForArduino
|
919621dcd0c157094bed4df752b583ba6ea6409e
|
[
"BSL-1.0"
] | 10
|
2018-03-17T00:58:42.000Z
|
2021-07-06T02:48:49.000Z
|
src/boost_mpl_aux__preprocessed_dmc_advance_forward.hpp
|
miathedev/BoostForArduino
|
919621dcd0c157094bed4df752b583ba6ea6409e
|
[
"BSL-1.0"
] | 2
|
2021-03-26T15:17:35.000Z
|
2021-05-20T23:55:08.000Z
|
src/boost_mpl_aux__preprocessed_dmc_advance_forward.hpp
|
miathedev/BoostForArduino
|
919621dcd0c157094bed4df752b583ba6ea6409e
|
[
"BSL-1.0"
] | 4
|
2019-05-28T21:06:37.000Z
|
2021-07-06T03:06:52.000Z
|
#include <boost/mpl/aux_/preprocessed/dmc/advance_forward.hpp>
| 31.5
| 62
| 0.825397
|
miathedev
|
39c4d50c3a1d672bdb831a11cd5943a75d11d61d
| 884
|
cpp
|
C++
|
functions.cpp
|
swsvindland/MullersMethod
|
75a4c5cc47e2f4491626ba5499c36df623663f83
|
[
"MIT"
] | null | null | null |
functions.cpp
|
swsvindland/MullersMethod
|
75a4c5cc47e2f4491626ba5499c36df623663f83
|
[
"MIT"
] | null | null | null |
functions.cpp
|
swsvindland/MullersMethod
|
75a4c5cc47e2f4491626ba5499c36df623663f83
|
[
"MIT"
] | null | null | null |
#include <iostream>
#include "functions.h"
/**
*
* https://en.wikipedia.org/wiki/Divided_differences
*/
double dividedDifference(double (*f)(double), double *x, int n) {
double sum = 0.0;
for(int j = 0; j < n; ++j) {
double product = 1.0;
for(int k = 0; k < n; ++k) {
if(k != j) {
product *= x[j] - x[k];
}
}
sum += (*f)(x[j]) / product;
}
return sum;
}
/**
*
* https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method
*/
double approxSqrt(double x) {
double error = x * 1e-8;
double s = x;
while ((s - x / s) > error) {
s = (s + x / s) / 2;
}
return s;
}
double max(double x, double y) {
if(x >= y) {
return x;
}
return y;
}
double abs(double x) {
if(x > 0) {
return x;
}
return -1 * x;
}
| 18.416667
| 84
| 0.4819
|
swsvindland
|
39c5efe15eace3756e6fe49cc4a8d3ae0e994e1f
| 1,348
|
cpp
|
C++
|
LeetCode/C++/147. Insertion Sort List.cpp
|
shreejitverma/GeeksforGeeks
|
d7bcb166369fffa9a031a258e925b6aff8d44e6c
|
[
"MIT"
] | 3
|
2020-12-30T00:29:59.000Z
|
2021-01-24T22:43:04.000Z
|
LeetCode/C++/147. Insertion Sort List.cpp
|
shivaniverma1/Competitive-Programming-1
|
d7bcb166369fffa9a031a258e925b6aff8d44e6c
|
[
"MIT"
] | 6
|
2022-01-13T04:31:04.000Z
|
2022-03-12T01:06:16.000Z
|
LeetCode/C++/147. Insertion Sort List.cpp
|
shivaniverma1/Competitive-Programming-1
|
d7bcb166369fffa9a031a258e925b6aff8d44e6c
|
[
"MIT"
] | 2
|
2022-02-14T19:53:53.000Z
|
2022-02-18T05:14:30.000Z
|
//Runtime: 132 ms, faster than 5.57% of C++ online submissions for Insertion Sort List.
//Memory Usage: 8.6 MB, less than 100.00% of C++ online submissions for Insertion Sort List.
/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode(int x) : val(x), next(NULL) {}
* };
*/
class Solution {
public:
void swapValue(ListNode* a, ListNode* b){
int tmp = a->val;
a->val = b->val;
b->val = tmp;
};
void insert(ListNode* list, ListNode* node){
ListNode *cur = list, *prev, *tail;
//find in list a node that just larger than node
while(cur && cur->val <= node->val){
prev = cur;
cur = cur->next;
}
tail = list;
while(tail->next){
tail = tail->next;
}
// tail->next = node->next;
prev->next = node;
node->next = cur;
};
ListNode* insertionSortList(ListNode* head) {
ListNode *newHead = new ListNode(INT_MIN);
ListNode *node, *remaining = head;
while(remaining){
node = remaining;
remaining = remaining->next;
node->next = nullptr;
insert(newHead, node);
}
return newHead->next;
}
};
| 25.923077
| 92
| 0.511869
|
shreejitverma
|
39c899021bc217a26f65a5a907d6aba381dcfb57
| 75
|
cpp
|
C++
|
dev/premake/premake/samples/project/CppConsoleApp/CppConsoleApp.cpp
|
gdewald/Spacefrog
|
eae9bd5c91670f7d13442740b5d801286ba41e5e
|
[
"BSD-2-Clause"
] | 94
|
2015-04-02T05:41:21.000Z
|
2021-11-14T18:30:12.000Z
|
dev/premake/premake/samples/project/CppConsoleApp/CppConsoleApp.cpp
|
gdewald/Spacefrog
|
eae9bd5c91670f7d13442740b5d801286ba41e5e
|
[
"BSD-2-Clause"
] | 18
|
2015-06-16T16:57:14.000Z
|
2021-04-06T18:35:40.000Z
|
dev/premake/premake/samples/project/CppConsoleApp/CppConsoleApp.cpp
|
gdewald/Spacefrog
|
eae9bd5c91670f7d13442740b5d801286ba41e5e
|
[
"BSD-2-Clause"
] | 33
|
2015-04-07T05:43:54.000Z
|
2021-08-21T22:13:03.000Z
|
#include "stdafx.h"
int main()
{
printf("CppConsoleApp\n");
return 0;
}
| 9.375
| 27
| 0.64
|
gdewald
|
39ceba325ee4ff5066f63d189511d29caafabce4
| 351
|
cpp
|
C++
|
Userland/Libraries/LibWeb/DOM/DOMEventListener.cpp
|
densogiaichned/serenity
|
99c0b895fed02949b528437d6b450d85befde7a5
|
[
"BSD-2-Clause"
] | 2
|
2022-02-16T02:12:38.000Z
|
2022-02-20T18:40:41.000Z
|
Userland/Libraries/LibWeb/DOM/DOMEventListener.cpp
|
densogiaichned/serenity
|
99c0b895fed02949b528437d6b450d85befde7a5
|
[
"BSD-2-Clause"
] | null | null | null |
Userland/Libraries/LibWeb/DOM/DOMEventListener.cpp
|
densogiaichned/serenity
|
99c0b895fed02949b528437d6b450d85befde7a5
|
[
"BSD-2-Clause"
] | null | null | null |
/*
* Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibWeb/DOM/AbortSignal.h>
#include <LibWeb/DOM/DOMEventListener.h>
#include <LibWeb/DOM/IDLEventListener.h>
namespace Web::DOM {
DOMEventListener::DOMEventListener() = default;
DOMEventListener::~DOMEventListener() = default;
}
| 23.4
| 59
| 0.746439
|
densogiaichned
|
39cf381804f87c2540f96d09de47f01591f1f485
| 3,195
|
hpp
|
C++
|
include/metrics/m_psnr.hpp
|
ecarpita93/HPC_projet_1
|
a2c00e056c03227711c43cf2ad23d75c6afbe698
|
[
"Xnet",
"X11"
] | null | null | null |
include/metrics/m_psnr.hpp
|
ecarpita93/HPC_projet_1
|
a2c00e056c03227711c43cf2ad23d75c6afbe698
|
[
"Xnet",
"X11"
] | null | null | null |
include/metrics/m_psnr.hpp
|
ecarpita93/HPC_projet_1
|
a2c00e056c03227711c43cf2ad23d75c6afbe698
|
[
"Xnet",
"X11"
] | null | null | null |
/*
PICCANTE
The hottest HDR imaging library!
http://vcg.isti.cnr.it/piccante
Copyright (C) 2014
Visual Computing Laboratory - ISTI CNR
http://vcg.isti.cnr.it
First author: Francesco Banterle
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#ifndef PIC_METRICS_M_PSNR_HPP
#define PIC_METRICS_M_PSNR_HPP
#include <math.h>
#include "../base.hpp"
#include "../util/array.hpp"
#include "../image.hpp"
#include "../tone_mapping/get_all_exposures.hpp"
#include "../metrics/base.hpp"
#include "../metrics/mse.hpp"
namespace pic {
enum MULTI_EXPOSURE_TYPE{MET_HISTOGRAM, MET_MIN_MAX, MET_FROM_INPUT};
/**
* @brief mPSNR computes the multiple-exposure peak signal-to-noise ratio (mPSNR) between two images.
* @param ori is the original image.
* @param cmp is the distorted image.
* @param type.
* @param minFstop is the minimum f-stop value of ori.
* @param maxFstop is the maximum f-stop value of ori.
* @return It returns the nMPSR error value between ori and cmp.
*/
PIC_INLINE double mPSNR(Image *ori, Image *cmp, MULTI_EXPOSURE_TYPE type, int minFstop = 0, int maxFstop = 0)
{
if(ori == NULL || cmp == NULL) {
return -2.0;
}
if(!ori->isValid() || !cmp->isValid()) {
return -3.0;
}
if(!ori->isSimilarType(cmp)) {
return -1.0;
}
std::vector<float> exposures;
switch (type) {
case MET_HISTOGRAM: {
exposures = getAllExposures(ori);
} break;
case MET_MIN_MAX: {
if(minFstop == maxFstop) {
getMinMaxFstops(ori, minFstop, maxFstop);
}
int nExposures_v = 0;
float *exposures_v = NULL;
Arrayf::genRange(float(minFstop), 1.0f, float(maxFstop), exposures_v, nExposures_v);
exposures.insert(exposures.begin(), exposures_v, exposures_v + nExposures_v);
} break;
case MET_FROM_INPUT: {
for(int i = minFstop; i <= maxFstop; i++) {
exposures.push_back(float(i));
}
} break;
}
if(exposures.empty()) {
return -5.0;
}
#ifdef PIC_DEBUG
printf("-------------------------------------------------------\n");
printf("-- mPSNR:\n");
printf("-- min F-stop: %d \t max F-stop: %d\n", minFstop, maxFstop);
#endif
int nBit = 8;
float gamma = 2.2f; //typically 2.2
auto n = exposures.size();
double mse = 0.0;
for(auto i = 0; i < n; i++) {
double mse_i = MSE(ori, cmp, gamma, exposures[i], nBit);
#ifdef PIC_DEBUG
printf("-- Pass: %d \t MSE: %g\n", i, mse_i);
#endif
mse += mse_i;
}
mse /= double(n * ori->channels);
int nValues = (1 << nBit) - 1;
double nValuesd = double(nValues);
double ret = 10.0 * log10((nValuesd * nValuesd) / mse);
#ifdef PIC_DEBUG
printf("-- value: %f\n", ret);
printf("-------------------------------------------------------");
#endif
return ret;
}
} // end namespace pic
#endif /* PIC_METRICS_M_PSNR_HPP */
| 24.767442
| 109
| 0.57903
|
ecarpita93
|
39cf9236712bfa5b82bcf8db2a7f5e9f71783921
| 2,155
|
cc
|
C++
|
AbsEnv/AbsDetEnv.cc
|
brownd1978/FastSim
|
05f590d72d8e7f71856fd833114a38b84fc7fd48
|
[
"Apache-2.0"
] | null | null | null |
AbsEnv/AbsDetEnv.cc
|
brownd1978/FastSim
|
05f590d72d8e7f71856fd833114a38b84fc7fd48
|
[
"Apache-2.0"
] | null | null | null |
AbsEnv/AbsDetEnv.cc
|
brownd1978/FastSim
|
05f590d72d8e7f71856fd833114a38b84fc7fd48
|
[
"Apache-2.0"
] | null | null | null |
//--------------------------------------------------------------------------
// File and Version Information:
// $Id: AbsDetEnv.cc 483 2010-01-13 14:03:08Z stroili $
//
// Description:
// Class AbsDetEnv
//
// Abstract class for detector envirnoments. Individual
// detectors' environment classes will inherit from this
// class and define their own environment variables. Access
// to these variables is via an asbtract structure, which
// also contains neighbour information. See EmcEnv.cc/hh for
// an example.
//
//
// Environment:
// Software developed for the BaBar Detector at the SLAC B-Factory.
//
// Author List:
// Bob Jacobsen Original Author
// Stephen J. Gowdy University Of Edinburgh
// Phil Strother Imperial College
//
// Copyright Information:
// Copyright (C) 1995, 1996 Lawrence Berkeley Laboratory
//
//------------------------------------------------------------------------
#include "BaBar/BaBar.hh"
//-----------------------
// This Class's Header --
//-----------------------
#include "AbsEnv/AbsDetEnv.hh"
//-------------
// C Headers --
//-------------
//#include <assert.h>
//#include <string.h>
#include <iostream>
//-------------------------------
// Collaborating Class Headers --
//-------------------------------
//-----------------------------------------------------------------------
// Local Macros, Typedefs, Structures, Unions and Forward Declarations --
//-----------------------------------------------------------------------
// ----------------------------------------
// -- Public Function Member Definitions --
// ----------------------------------------
//----------------
// Constructors --
//----------------
//--------------
// Destructor --
//--------------
AbsDetEnv::~AbsDetEnv( )
{
}
// Selectors
const AbsDetStructure* AbsDetEnv::getDetStructure() const
{
return _detStructure;
}
// Modifiers
void AbsDetEnv::setDetStructure(const AbsDetStructure* detStructure)
{
//_detStructure=const_cast<AbsDetStructure*>(detStructure);
_detStructure=(AbsDetStructure*)detStructure;
}
| 22.925532
| 76
| 0.488631
|
brownd1978
|
39d2feb01906c3ba9ce50d4527fd3a718f70cf2f
| 2,256
|
cpp
|
C++
|
src/OpenGL/entrypoints/GL3.0/gl_uniform_2ui.cpp
|
kbiElude/VKGL
|
fffabf412723a3612ba1c5bfeafe1da38062bd18
|
[
"MIT"
] | 114
|
2018-08-05T16:26:53.000Z
|
2021-12-30T07:28:35.000Z
|
src/OpenGL/entrypoints/GL3.0/gl_uniform_2ui.cpp
|
kbiElude/VKGL
|
fffabf412723a3612ba1c5bfeafe1da38062bd18
|
[
"MIT"
] | 5
|
2018-08-18T21:16:58.000Z
|
2018-11-22T21:50:48.000Z
|
src/OpenGL/entrypoints/GL3.0/gl_uniform_2ui.cpp
|
kbiElude/VKGL
|
fffabf412723a3612ba1c5bfeafe1da38062bd18
|
[
"MIT"
] | 6
|
2018-08-05T22:32:28.000Z
|
2021-10-04T15:39:53.000Z
|
/* VKGL (c) 2018 Dominik Witczak
*
* This code is licensed under MIT license (see LICENSE.txt for details)
*/
#include "OpenGL/entrypoints/GL3.0/gl_uniform_2ui.h"
#include "OpenGL/context.h"
#include "OpenGL/globals.h"
static bool validate(OpenGL::Context* in_context_ptr,
const GLint& in_location,
const GLuint& in_v0,
const GLuint& in_v1)
{
bool result = false;
// ..
result = true;
return result;
}
void VKGL_APIENTRY OpenGL::vkglUniform2ui(GLint location,
GLuint v0,
GLuint v1)
{
const auto& dispatch_table_ptr = OpenGL::g_dispatch_table_ptr;
VKGL_TRACE("glUniform2ui(location=[%d] v0=[%u] v1=[%u])",
location,
v0,
v1);
dispatch_table_ptr->pGLUniform2ui(dispatch_table_ptr->bound_context_ptr,
location,
v0,
v1);
}
static void vkglUniform2ui_execute(OpenGL::Context* in_context_ptr,
const GLint& in_location,
const GLuint& in_v0,
const GLuint& in_v1)
{
const GLuint data[] =
{
in_v0,
in_v1
};
in_context_ptr->set_uniform(in_location,
OpenGL::GetSetArgumentType::Unsigned_Int,
2, /* in_n_components */
1, /* in_n_array_items */
data);
}
void OpenGL::vkglUniform2ui_with_validation(OpenGL::Context* in_context_ptr,
const GLint& in_location,
const GLuint& in_v0,
const GLuint& in_v1)
{
if (validate(in_context_ptr,
in_location,
in_v0,
in_v1) )
{
vkglUniform2ui_execute(in_context_ptr,
in_location,
in_v0,
in_v1);
}
}
| 30.90411
| 76
| 0.449025
|
kbiElude
|
39d72a4f6b8217868560200043da064b13b4df0c
| 430
|
cpp
|
C++
|
day19/main.cpp
|
wuggy-ianw/AoC2017
|
138c66bdd407e76f6ad71c9d68df50e0afa2251a
|
[
"Unlicense"
] | null | null | null |
day19/main.cpp
|
wuggy-ianw/AoC2017
|
138c66bdd407e76f6ad71c9d68df50e0afa2251a
|
[
"Unlicense"
] | null | null | null |
day19/main.cpp
|
wuggy-ianw/AoC2017
|
138c66bdd407e76f6ad71c9d68df50e0afa2251a
|
[
"Unlicense"
] | null | null | null |
#include "day19.h"
#include "../utils/aocutils.h"
#include <iostream>
#include <fstream>
int main(void)
{
std::ifstream ifs("input.txt");
std::vector<std::string> path = AOCUtils::parseByLines<std::string>(ifs, [](const std::string& s) -> std::string {return s;});
std::pair<std::string, int> result = Day19::solve(path);
std::cout << result.first << std::endl;
std::cout << result.second << std::endl;
return 0;
}
| 25.294118
| 128
| 0.646512
|
wuggy-ianw
|
39d7cbb0fba3bbfe79ad50d547f17fe04df866c2
| 286
|
cpp
|
C++
|
22.09.2021-Homework/Task8/Task8.cpp
|
Enigma1123/programming-c-2021-autumn-1course
|
b7c5400298bd9a3e346940e14c4025c954db90aa
|
[
"Apache-2.0"
] | null | null | null |
22.09.2021-Homework/Task8/Task8.cpp
|
Enigma1123/programming-c-2021-autumn-1course
|
b7c5400298bd9a3e346940e14c4025c954db90aa
|
[
"Apache-2.0"
] | null | null | null |
22.09.2021-Homework/Task8/Task8.cpp
|
Enigma1123/programming-c-2021-autumn-1course
|
b7c5400298bd9a3e346940e14c4025c954db90aa
|
[
"Apache-2.0"
] | null | null | null |
#include <iostream>
using namespace std;
int main()
{
int h1 = 0;
int m1 = 0;
int s1 = 0;
int h2 = 0;
int m2 = 0;
int s2 = 0;
int a = 0;
cin >> h1 >> m1 >> s1 >> h2 >> m2 >> s2;
a = abs((h1 * 3600 + m1 * 60 + s1) - (h2 * 3600 + m2 * 60 + s2));
cout << a;
}
| 16.823529
| 67
| 0.447552
|
Enigma1123
|
39d7ccd9b2ba51737016e43eb3e9b9671da3994c
| 29,668
|
cpp
|
C++
|
src/treecore/File.cpp
|
jiandingzhe/treecore
|
0a2a23dce68dbb55174569ec9cff64faeaac4a31
|
[
"MIT"
] | 2
|
2017-10-14T23:13:37.000Z
|
2019-11-18T16:23:49.000Z
|
src/treecore/File.cpp
|
jiandingzhe/treecore
|
0a2a23dce68dbb55174569ec9cff64faeaac4a31
|
[
"MIT"
] | null | null | null |
src/treecore/File.cpp
|
jiandingzhe/treecore
|
0a2a23dce68dbb55174569ec9cff64faeaac4a31
|
[
"MIT"
] | null | null | null |
/*
==============================================================================
This file is part of the juce_core module of the JUCE library.
Copyright (c) 2013 - Raw Material Software Ltd.
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.
------------------------------------------------------------------------------
NOTE! This permissive ISC license applies ONLY to files within the juce_core module!
All other JUCE modules are covered by a dual GPL/commercial license, so if you are
using any other modules, be sure to check that you also comply with their license.
For more details, visit www.juce.com
==============================================================================
*/
#include "treecore/File.h"
#include "treecore/DirectoryIterator.h"
#include "treecore/FileInputStream.h"
#include "treecore/FileOutputStream.h"
#include "treecore/MemoryMappedFile.h"
#include "treecore/MT19937.h"
#include "treecore/Process.h"
#include "treecore/ScopedPointer.h"
#include "treecore/StringRef.h"
#include "treecore/TemporaryFile.h"
#include "treecore/Time.h"
#if TREECORE_OS_WINDOWS
#else
# include <pwd.h>
#endif
namespace treecore {
File::File ( const String& fullPathName )
: fullPath( parseAbsolutePath( fullPathName ) )
{}
File File::createFileWithoutCheckingPath( const String& path ) noexcept
{
File f;
f.fullPath = path;
return f;
}
File::File ( const File& other )
: fullPath( other.fullPath )
{}
File& File::operator = ( const String& newPath )
{
fullPath = parseAbsolutePath( newPath );
return *this;
}
File& File::operator = ( const File& other )
{
fullPath = other.fullPath;
return *this;
}
File::File ( File&& other ) noexcept
: fullPath( static_cast<String &&>(other.fullPath) )
{}
File& File::operator = ( File&& other ) noexcept
{
fullPath = static_cast<String &&>(other.fullPath);
return *this;
}
const File File::nonexistent;
//==============================================================================
String File::parseAbsolutePath( const String& p )
{
if ( p.isEmpty() )
return String();
#if TREECORE_OS_WINDOWS
// Windows..
String path( p.replaceCharacter( '/', '\\' ) );
if ( path.startsWithChar( separator ) )
{
if (path[1] != separator)
{
/* When you supply a raw string to the File object constructor, it must be an absolute path.
If you're trying to parse a string that may be either a relative path or an absolute path,
you MUST provide a context against which the partial path can be evaluated - you can do
this by simply using File::getChildFile() instead of the File constructor. E.g. saying
"File::getCurrentWorkingDirectory().getChildFile (myUnknownPath)" would return an absolute
path if that's what was supplied, or would evaluate a partial path relative to the CWD.
*/
treecore_assert_false;
path = File::getCurrentWorkingDirectory().getFullPathName().substring( 0, 2 ) + path;
}
}
else if ( !path.containsChar( ':' ) )
{
/* When you supply a raw string to the File object constructor, it must be an absolute path.
If you're trying to parse a string that may be either a relative path or an absolute path,
you MUST provide a context against which the partial path can be evaluated - you can do
this by simply using File::getChildFile() instead of the File constructor. E.g. saying
"File::getCurrentWorkingDirectory().getChildFile (myUnknownPath)" would return an absolute
path if that's what was supplied, or would evaluate a partial path relative to the CWD.
*/
treecore_assert_false;
return File::getCurrentWorkingDirectory().getChildFile( path ).getFullPathName();
}
#elif TREECORE_OS_LINUX || TREECORE_OS_ANDROID || TREECORE_OS_OSX || TREECORE_OS_IOS
// Mac or Linux..
// Yes, I know it's legal for a unix pathname to contain a backslash, but this assertion is here
// to catch anyone who's trying to run code that was written on Windows with hard-coded path names.
// If that's why you've ended up here, use File::getChildFile() to build your paths instead.
treecore_assert( ( !p.containsChar( '\\' ) ) || ( p.indexOfChar( '/' ) >= 0 && p.indexOfChar( '/' ) < p.indexOfChar( '\\' ) ) );
String path( p );
if ( path.startsWithChar( '~' ) )
{
if (path[1] == separator || path[1] == 0)
{
// expand a name of the form "~/abc"
path = File::getSpecialLocation( File::userHomeDirectory ).getFullPathName()
+ path.substring( 1 );
}
else
{
// expand a name of type "~dave/abc"
const String userName( path.substring( 1 ).upToFirstOccurrenceOf( "/", false, false ) );
if ( struct passwd* const pw = getpwnam( userName.toUTF8() ) )
path = addTrailingSeparator( pw->pw_dir ) + path.fromFirstOccurrenceOf( "/", false, false );
}
}
else if ( !path.startsWithChar( separator ) )
{
# if TREECORE_DEBUG || TREECORE_LOG_ASSERTIONS
if ( !( path.startsWith( "./" ) || path.startsWith( "../" ) ) )
{
/* When you supply a raw string to the File object constructor, it must be an absolute path.
If you're trying to parse a string that may be either a relative path or an absolute path,
you MUST provide a context against which the partial path can be evaluated - you can do
this by simply using File::getChildFile() instead of the File constructor. E.g. saying
"File::getCurrentWorkingDirectory().getChildFile (myUnknownPath)" would return an absolute
path if that's what was supplied, or would evaluate a partial path relative to the CWD.
*/
treecore_assert_false;
# if TREECORE_LOG_ASSERTIONS
Logger::writeToLog( "Illegal absolute path: " + path );
# endif
}
# endif
return File::getCurrentWorkingDirectory().getChildFile( path ).getFullPathName();
}
#else
# error "unsupported OS"
#endif
while (path.endsWithChar( separator ) && path != separatorString) // careful not to turn a single "/" into an empty string.
path = path.dropLastCharacters( 1 );
return path;
}
String File::addTrailingSeparator( const String& path )
{
return path.endsWithChar( separator ) ? path
: path + separator;
}
//==============================================================================
#if TREECORE_OS_LINUX || TREECORE_OS_OSX || TREECORE_OS_IOS
# define NAMES_ARE_CASE_SENSITIVE 1
#elif TREECORE_OS_WINDOWS
#else
# error "TODO"
#endif
bool File::areFileNamesCaseSensitive()
{
#if NAMES_ARE_CASE_SENSITIVE
return true;
#else
return false;
#endif
}
static int compareFilenames( const String& name1, const String& name2 ) noexcept
{
#if NAMES_ARE_CASE_SENSITIVE
return name1.compare( name2 );
#else
return name1.compareIgnoreCase( name2 );
#endif
}
bool File::operator == ( const File& other ) const { return compareFilenames( fullPath, other.fullPath ) == 0; }
bool File::operator != ( const File& other ) const { return compareFilenames( fullPath, other.fullPath ) != 0; }
bool File::operator < ( const File& other ) const { return compareFilenames( fullPath, other.fullPath ) < 0; }
bool File::operator > ( const File& other ) const { return compareFilenames( fullPath, other.fullPath ) > 0; }
//==============================================================================
bool File::setReadOnly( const bool shouldBeReadOnly,
const bool applyRecursively ) const
{
bool worked = true;
if ( applyRecursively && isDirectory() )
{
Array<File> subFiles;
findChildFiles( subFiles, File::findFilesAndDirectories, false );
for (int i = subFiles.size(); --i >= 0; )
worked = subFiles[i].setReadOnly( shouldBeReadOnly, true ) && worked;
}
return setFileReadOnlyInternal( shouldBeReadOnly ) && worked;
}
bool File::deleteRecursively() const
{
bool worked = true;
if ( isDirectory() )
{
Array<File> subFiles;
findChildFiles( subFiles, File::findFilesAndDirectories, false );
for (int i = subFiles.size(); --i >= 0; )
worked = subFiles[i].deleteRecursively() && worked;
}
return deleteFile() && worked;
}
bool File::moveFileTo( const File& newFile ) const
{
if (newFile.fullPath == fullPath)
return true;
if ( !exists() )
return false;
#if !NAMES_ARE_CASE_SENSITIVE
if (*this != newFile)
#endif
if ( !newFile.deleteFile() )
return false;
return moveInternal( newFile );
}
bool File::copyFileTo( const File& newFile ) const
{
return (*this == newFile)
|| ( exists() && newFile.deleteFile() && copyInternal( newFile ) );
}
bool File::copyDirectoryTo( const File& newDirectory ) const
{
if ( isDirectory() && newDirectory.createDirectory() )
{
Array<File> subFiles;
findChildFiles( subFiles, File::findFiles, false );
for (int i = 0; i < subFiles.size(); ++i)
if ( !subFiles[i].copyFileTo( newDirectory.getChildFile( subFiles[i].getFileName() ) ) )
return false;
subFiles.clear();
findChildFiles( subFiles, File::findDirectories, false );
for (int i = 0; i < subFiles.size(); ++i)
if ( !subFiles[i].copyDirectoryTo( newDirectory.getChildFile( subFiles[i].getFileName() ) ) )
return false;
return true;
}
return false;
}
//==============================================================================
String File::getPathUpToLastSlash() const
{
const int lastSlash = fullPath.lastIndexOfChar( separator );
if (lastSlash > 0)
return fullPath.substring( 0, lastSlash );
if (lastSlash == 0)
return separatorString;
return fullPath;
}
File File::getParentDirectory() const
{
File f;
f.fullPath = getPathUpToLastSlash();
return f;
}
//==============================================================================
String File::getFileName() const
{
return fullPath.substring( fullPath.lastIndexOfChar( separator ) + 1 );
}
String File::getFileNameWithoutExtension() const
{
const int lastSlash = fullPath.lastIndexOfChar( separator ) + 1;
const int lastDot = fullPath.lastIndexOfChar( '.' );
if (lastDot > lastSlash)
return fullPath.substring( lastSlash, lastDot );
return fullPath.substring( lastSlash );
}
bool File::isAChildOf( const File& potentialParent ) const
{
if ( potentialParent.fullPath.isEmpty() )
return false;
const String ourPath( getPathUpToLastSlash() );
if (compareFilenames( potentialParent.fullPath, ourPath ) == 0)
return true;
if ( potentialParent.fullPath.length() >= ourPath.length() )
return false;
return getParentDirectory().isAChildOf( potentialParent );
}
int File::hashCode() const { return fullPath.hashCode(); }
int64 File::hashCode64() const { return fullPath.hashCode64(); }
//==============================================================================
bool File::isAbsolutePath( StringRef path )
{
return path.text[0] == separator
#if TREECORE_OS_WINDOWS
|| (path.isNotEmpty() && path.text[1] == ':');
#else
|| path.text[0] == '~';
#endif
}
File File::getChildFile( StringRef relativePath ) const
{
if ( isAbsolutePath( relativePath ) )
return File( String( relativePath.text ) );
if (relativePath[0] != '.')
return File( addTrailingSeparator( fullPath ) + relativePath );
String path( fullPath );
// It's relative, so remove any ../ or ./ bits at the start..
#if TREECORE_OS_WINDOWS
if (relativePath.text.indexOf( (treecore_wchar) '/' ) >= 0)
return getChildFile( String( relativePath.text ).replaceCharacter( '/', '\\' ) );
#endif
while (relativePath[0] == '.')
{
const treecore_wchar secondChar = relativePath[1];
if (secondChar == '.')
{
const treecore_wchar thirdChar = relativePath[2];
if (thirdChar == 0 || thirdChar == separator)
{
const int lastSlash = path.lastIndexOfChar( separator );
if (lastSlash >= 0)
path = path.substring( 0, lastSlash );
relativePath = relativePath.text + (thirdChar == 0 ? 2 : 3);
}
else
{
break;
}
}
else if (secondChar == separator)
{
relativePath = relativePath.text + 2;
}
else
{
break;
}
}
return File( addTrailingSeparator( path ) + relativePath );
}
File File::getSiblingFile( StringRef fileName ) const
{
return getParentDirectory().getChildFile( fileName );
}
//==============================================================================
String File::descriptionOfSizeInBytes( const int64 bytes )
{
const char* suffix;
double divisor = 0;
if (bytes == 1) { suffix = " byte"; }
else if (bytes < 1024) { suffix = " bytes"; }
else if (bytes < 1024 * 1024) { suffix = " KB"; divisor = 1024.0; }
else if (bytes < 1024 * 1024 * 1024) { suffix = " MB"; divisor = 1024.0 * 1024.0; }
else { suffix = " GB"; divisor = 1024.0 * 1024.0 * 1024.0; }
return ( divisor > 0 ? String( bytes / divisor, 1 ) : String( bytes ) ) + suffix;
}
//==============================================================================
Result File::create() const
{
if ( exists() )
return Result::ok();
const File parentDir( getParentDirectory() );
if (parentDir == *this)
return Result::fail( "Cannot create parent directory" );
Result r( parentDir.createDirectory() );
if ( r.wasOk() )
{
FileOutputStream fo( *this, 8 );
r = fo.getStatus();
}
return r;
}
Result File::createDirectory() const
{
if ( isDirectory() )
return Result::ok();
const File parentDir( getParentDirectory() );
if (parentDir == *this)
return Result::fail( "Cannot create parent directory" );
Result r( parentDir.createDirectory() );
if ( r.wasOk() )
r = createDirectoryInternal( fullPath.trimCharactersAtEnd( separatorString ) );
return r;
}
//==============================================================================
Time File::getLastModificationTime() const { int64 m, a, c; getFileTimesInternal( m, a, c ); return Time( m ); }
Time File::getLastAccessTime() const { int64 m, a, c; getFileTimesInternal( m, a, c ); return Time( a ); }
Time File::getCreationTime() const { int64 m, a, c; getFileTimesInternal( m, a, c ); return Time( c ); }
bool File::setLastModificationTime( Time t ) const { return setFileTimesInternal( t.toMilliseconds(), 0, 0 ); }
bool File::setLastAccessTime( Time t ) const { return setFileTimesInternal( 0, t.toMilliseconds(), 0 ); }
bool File::setCreationTime( Time t ) const { return setFileTimesInternal( 0, 0, t.toMilliseconds() ); }
//==============================================================================
bool File::loadFileAsData( MemoryBlock& destBlock ) const
{
if ( !existsAsFile() )
return false;
FileInputStream in( *this );
return in.openedOk() && getSize() == (int64) in.readIntoMemoryBlock( destBlock );
}
String File::loadFileAsString() const
{
if ( !existsAsFile() )
return String();
FileInputStream in( *this );
return in.openedOk() ? in.readEntireStreamAsString()
: String();
}
void File::readLines( StringArray& destLines ) const
{
destLines.addLines( loadFileAsString() );
}
//==============================================================================
int File::findChildFiles( Array<File>& results,
const int whatToLookFor,
const bool searchRecursively,
const String& wildCardPattern ) const
{
int total = 0;
for (DirectoryIterator di( *this, searchRecursively, wildCardPattern, whatToLookFor ); di.next(); )
{
results.add( di.getFile() );
++total;
}
return total;
}
int File::getNumberOfChildFiles( const int whatToLookFor, const String& wildCardPattern ) const
{
int total = 0;
for (DirectoryIterator di( *this, false, wildCardPattern, whatToLookFor ); di.next(); )
++total;
return total;
}
bool File::containsSubDirectories() const
{
if ( !isDirectory() )
return false;
DirectoryIterator di( *this, false, "*", findDirectories );
return di.next();
}
//==============================================================================
File File::getNonexistentChildFile( const String& suggestedPrefix,
const String& suffix,
bool putNumbersInBrackets ) const
{
File f( getChildFile( suggestedPrefix + suffix ) );
if ( f.exists() )
{
int number = 1;
String prefix( suggestedPrefix );
// remove any bracketed numbers that may already be on the end..
if ( prefix.trim().endsWithChar( ')' ) )
{
putNumbersInBrackets = true;
const int openBracks = prefix.lastIndexOfChar( '(' );
const int closeBracks = prefix.lastIndexOfChar( ')' );
if ( openBracks > 0
&& closeBracks > openBracks
&& prefix.substring( openBracks + 1, closeBracks ).containsOnly( "0123456789" ) )
{
number = prefix.substring( openBracks + 1, closeBracks ).getIntValue();
prefix = prefix.substring( 0, openBracks );
}
}
// also use brackets if it ends in a digit.
putNumbersInBrackets = putNumbersInBrackets
|| CharacterFunctions::isDigit( prefix.getLastCharacter() );
do
{
String newName( prefix );
if (putNumbersInBrackets)
newName << '(' << ++number << ')';
else
newName << ++number;
f = getChildFile( newName + suffix );
} while ( f.exists() );
}
return f;
}
File File::getNonexistentSibling( const bool putNumbersInBrackets ) const
{
if ( !exists() )
return *this;
return getParentDirectory().getNonexistentChildFile( getFileNameWithoutExtension(),
getFileExtension(),
putNumbersInBrackets );
}
//==============================================================================
String File::getFileExtension() const
{
const int indexOfDot = fullPath.lastIndexOfChar( '.' );
if ( indexOfDot > fullPath.lastIndexOfChar( separator ) )
return fullPath.substring( indexOfDot );
return String();
}
bool File::hasFileExtension( StringRef possibleSuffix ) const
{
if ( possibleSuffix.isEmpty() )
return fullPath.lastIndexOfChar( '.' ) <= fullPath.lastIndexOfChar( separator );
const int semicolon = possibleSuffix.text.indexOf( (treecore_wchar) ';' );
if (semicolon >= 0)
return hasFileExtension( String( possibleSuffix.text ).substring( 0, semicolon ).trimEnd() )
|| hasFileExtension( ( possibleSuffix.text + (semicolon + 1) ).findEndOfWhitespace() );
if ( fullPath.endsWithIgnoreCase( possibleSuffix ) )
{
if (possibleSuffix.text[0] == '.')
return true;
const int dotPos = fullPath.length() - possibleSuffix.length() - 1;
if (dotPos >= 0)
return fullPath [dotPos] == '.';
}
return false;
}
File File::withFileExtension( StringRef newExtension ) const
{
if ( fullPath.isEmpty() )
return File();
String filePart( getFileName() );
const int i = filePart.lastIndexOfChar( '.' );
if (i >= 0)
filePart = filePart.substring( 0, i );
if (newExtension.isNotEmpty() && newExtension.text[0] != '.')
filePart << '.';
return getSiblingFile( filePart + newExtension );
}
//==============================================================================
bool File::startAsProcess( const String& parameters ) const
{
return exists() && Process::openDocument( fullPath, parameters );
}
//==============================================================================
FileInputStream* File::createInputStream() const
{
ScopedPointer<FileInputStream> fin( new FileInputStream( *this ) );
if ( fin->openedOk() )
return fin.release();
return nullptr;
}
FileOutputStream* File::createOutputStream( const size_t bufferSize ) const
{
ScopedPointer<FileOutputStream> out( new FileOutputStream( *this, bufferSize ) );
return out->failedToOpen() ? nullptr
: out.release();
}
//==============================================================================
bool File::appendData( const void* const dataToAppend,
const size_t numberOfBytes ) const
{
treecore_assert( ( (ssize_t) numberOfBytes ) >= 0 );
if (numberOfBytes == 0)
return true;
FileOutputStream out( *this, 8192 );
return out.openedOk() && out.write( dataToAppend, numberOfBytes );
}
bool File::replaceWithData( const void* const dataToWrite,
const size_t numberOfBytes ) const
{
if (numberOfBytes == 0)
return deleteFile();
TemporaryFile tempFile( *this, TemporaryFile::useHiddenFile );
tempFile.getFile().appendData( dataToWrite, numberOfBytes );
return tempFile.overwriteTargetFileWithTemporary();
}
bool File::appendText( const String& text,
const bool asUnicode,
const bool writeUnicodeHeaderBytes ) const
{
FileOutputStream out( *this );
if ( out.failedToOpen() )
return false;
out.writeText( text, asUnicode, writeUnicodeHeaderBytes );
return true;
}
bool File::replaceWithText( const String& textToWrite,
const bool asUnicode,
const bool writeUnicodeHeaderBytes ) const
{
TemporaryFile tempFile( *this, TemporaryFile::useHiddenFile );
tempFile.getFile().appendText( textToWrite, asUnicode, writeUnicodeHeaderBytes );
return tempFile.overwriteTargetFileWithTemporary();
}
bool File::hasIdenticalContentTo( const File& other ) const
{
if (other == *this)
return true;
if ( getSize() == other.getSize() && existsAsFile() && other.existsAsFile() )
{
FileInputStream in1( *this ), in2( other );
if ( in1.openedOk() && in2.openedOk() )
{
const int bufferSize = 4096;
HeapBlock<char> buffer1( bufferSize ), buffer2( bufferSize );
for (;; )
{
const int num1 = in1.read( buffer1, bufferSize );
const int num2 = in2.read( buffer2, bufferSize );
if (num1 != num2)
break;
if (num1 <= 0)
return true;
if (memcmp( buffer1, buffer2, (size_t) num1 ) != 0)
break;
}
}
}
return false;
}
//==============================================================================
String File::createLegalPathName( const String& original )
{
String s( original );
String start;
if (s.isNotEmpty() && s[1] == ':')
{
start = s.substring( 0, 2 );
s = s.substring( 2 );
}
return start + s.removeCharacters( "\"#@,;:<>*^|?" )
.substring( 0, 1024 );
}
String File::createLegalFileName( const String& original )
{
String s( original.removeCharacters( "\"#@,;:<>*^|?\\/" ) );
const int maxLength = 128; // only the length of the filename, not the whole path
const int len = s.length();
if (len > maxLength)
{
const int lastDot = s.lastIndexOfChar( '.' );
if ( lastDot > jmax( 0, len - 12 ) )
{
s = s.substring( 0, maxLength - (len - lastDot) )
+ s.substring( lastDot );
}
else
{
s = s.substring( 0, maxLength );
}
}
return s;
}
//==============================================================================
static int countNumberOfSeparators( String::CharPointerType s )
{
int num = 0;
for (;; )
{
const treecore_wchar c = s.getAndAdvance();
if (c == 0)
break;
if (c == File::separator)
++num;
}
return num;
}
String File::getRelativePathFrom( const File& dir ) const
{
String thisPath( fullPath );
while ( thisPath.endsWithChar( separator ) )
thisPath = thisPath.dropLastCharacters( 1 );
String dirPath( addTrailingSeparator( dir.existsAsFile() ? dir.getParentDirectory().getFullPathName()
: dir.fullPath ) );
int commonBitLength = 0;
String::CharPointerType thisPathAfterCommon( thisPath.getCharPointer() );
String::CharPointerType dirPathAfterCommon( dirPath.getCharPointer() );
{
String::CharPointerType thisPathIter( thisPath.getCharPointer() );
String::CharPointerType dirPathIter( dirPath.getCharPointer() );
for (int i = 0;; )
{
const treecore_wchar c1 = thisPathIter.getAndAdvance();
const treecore_wchar c2 = dirPathIter.getAndAdvance();
#if NAMES_ARE_CASE_SENSITIVE
if (c1 != c2
#else
if ( ( c1 != c2 && CharacterFunctions::toLowerCase( c1 ) != CharacterFunctions::toLowerCase( c2 ) )
#endif
|| c1 == 0 )
break;
++i;
if (c1 == separator)
{
thisPathAfterCommon = thisPathIter;
dirPathAfterCommon = dirPathIter;
commonBitLength = i;
}
}
}
// if the only common bit is the root, then just return the full path..
if ( commonBitLength == 0 || (commonBitLength == 1 && thisPath[1] == separator) )
return fullPath;
const int numUpDirectoriesNeeded = countNumberOfSeparators( dirPathAfterCommon );
if (numUpDirectoriesNeeded == 0)
return thisPathAfterCommon;
#if TREECORE_OS_WINDOWS
String s( String::repeatedString( "..\\", numUpDirectoriesNeeded ) );
#else
String s( String::repeatedString( "../", numUpDirectoriesNeeded ) );
#endif
s.appendCharPointer( thisPathAfterCommon );
return s;
}
//==============================================================================
File File::createTempFile( StringRef fileNameEnding )
{
const File tempFile( getSpecialLocation( tempDirectory )
.getChildFile( "temp_" + String::toHexString( int( MT19937::getInstance()->next_uint64() ) ) )
.withFileExtension( fileNameEnding ) );
if ( tempFile.exists() )
return createTempFile( fileNameEnding );
return tempFile;
}
//==============================================================================
MemoryMappedFile::MemoryMappedFile ( const File& file, MemoryMappedFile::AccessMode mode )
: address( nullptr ), range( 0, file.getSize() ), fileHandle( 0 )
{
openInternal( file, mode );
}
MemoryMappedFile::MemoryMappedFile ( const File& file, const Range<int64>& fileRange, AccessMode mode )
: address( nullptr ), range( fileRange.getIntersectionWith( Range<int64>( 0, file.getSize() ) ) ), fileHandle( 0 )
{
openInternal( file, mode );
}
}
| 32.424044
| 133
| 0.555413
|
jiandingzhe
|
39d7e4e4a6f500f70e2a326e71d80d0c802871ea
| 751
|
cpp
|
C++
|
src/StringUtils.cpp
|
madmaxoft/LunaPaak
|
795fbc57bb592f2b33835b19f5fd75ceef23d95d
|
[
"Unlicense"
] | null | null | null |
src/StringUtils.cpp
|
madmaxoft/LunaPaak
|
795fbc57bb592f2b33835b19f5fd75ceef23d95d
|
[
"Unlicense"
] | null | null | null |
src/StringUtils.cpp
|
madmaxoft/LunaPaak
|
795fbc57bb592f2b33835b19f5fd75ceef23d95d
|
[
"Unlicense"
] | 1
|
2022-03-10T05:46:36.000Z
|
2022-03-10T05:46:36.000Z
|
#include "StringUtils.h"
#include <Windows.h>
std::string toUtf8(const std::wstring & aSrcWide)
{
auto srcLength = static_cast<int>(aSrcWide.length()) + 1;
auto len = WideCharToMultiByte(CP_UTF8, 0, aSrcWide.c_str(), srcLength, nullptr, 0, 0, nullptr);
std::string res(len, '\0');
WideCharToMultiByte(CP_UTF8, 0, aSrcWide.c_str(), srcLength, &res[0], len, 0, nullptr);
return res;
}
std::wstring toWide(const std::string & aSrcUtf8)
{
auto srcLength = static_cast<int>(aSrcUtf8.length()) + 1;
auto len = MultiByteToWideChar(CP_UTF8, 0, aSrcUtf8.c_str(), srcLength, nullptr, 0);
std::wstring res(len, '\0');
MultiByteToWideChar(CP_UTF8, 0, aSrcUtf8.c_str(), srcLength, &res[0], len);
return res;
}
| 25.896552
| 101
| 0.667111
|
madmaxoft
|
39db3e42db98fa485f60ffb204a13dbd0786931b
| 258
|
cpp
|
C++
|
c++/Project/project6-3/main.cpp
|
roostaa/cpp_archive
|
41e58a8c1e9cb7b4400fa4f5e5aa05df923fd872
|
[
"MIT"
] | null | null | null |
c++/Project/project6-3/main.cpp
|
roostaa/cpp_archive
|
41e58a8c1e9cb7b4400fa4f5e5aa05df923fd872
|
[
"MIT"
] | null | null | null |
c++/Project/project6-3/main.cpp
|
roostaa/cpp_archive
|
41e58a8c1e9cb7b4400fa4f5e5aa05df923fd872
|
[
"MIT"
] | null | null | null |
#include <iostream>
using namespace std;
int main()
{
int x;
for (x = 1; x <=20; x++)
{
if (x == 3 || x == 11 || x == 16)
{
continue;
}
cout << x << endl;
}
return 0;
}
| 12.285714
| 42
| 0.333333
|
roostaa
|
39dff968cb27b359b4c831bedb91c94bbe28945b
| 4,241
|
hpp
|
C++
|
Crowdflower Search Results Relevance/rgf1.2/src/tet/AzTET_Eval_Dflt.hpp
|
Tuanlase02874/Machine-Learning-Kaggle
|
c31651acd8f2407d8b60774e843a2527ce19b013
|
[
"MIT"
] | 1
|
2018-07-11T16:20:43.000Z
|
2018-07-11T16:20:43.000Z
|
Crowdflower Search Results Relevance/rgf1.2/src/tet/AzTET_Eval_Dflt.hpp
|
Tuanlase02874/Machine-Learning-Kaggle
|
c31651acd8f2407d8b60774e843a2527ce19b013
|
[
"MIT"
] | null | null | null |
Crowdflower Search Results Relevance/rgf1.2/src/tet/AzTET_Eval_Dflt.hpp
|
Tuanlase02874/Machine-Learning-Kaggle
|
c31651acd8f2407d8b60774e843a2527ce19b013
|
[
"MIT"
] | null | null | null |
/* * * * *
* AzTET_Eval_Dflt.hpp
* Copyright (C) 2011, 2012 Rie Johnson
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
* * * * */
#ifndef _AZ_TET_EVAL_DFLT_HPP_
#define _AZ_TET_EVAL_DFLT_HPP_
#include "AzUtil.hpp"
#include "AzTaskTools.hpp"
#include "AzPerfResult.hpp"
#include "AzDataForTrTree.hpp"
#include "AzLoss.hpp"
#include "AzTET_Eval.hpp"
//! Evaluationt module for Tree Ensemble Trainer.
/*-------------------------------------------------------*/
class AzTET_Eval_Dflt : /* implements */ public virtual AzTET_Eval {
protected:
/*--- targets ---*/
const AzDvect *v_y;
/*--- to output evaluation results ---*/
AzBytArr s_perf_fn;
AzPerfType perf_type;
AzLossType loss_type;
AzBytArr s_config;
AzOfs ofs;
AzOut perf_out;
bool doAppend;
public:
AzTET_Eval_Dflt() : v_y(NULL),
loss_type(AzLoss_None), doAppend(false) {}
~AzTET_Eval_Dflt() {
end();
}
inline virtual bool isActive() const {
if (v_y != NULL) return true;
return false;
}
virtual void reset() {
v_y= NULL;
s_perf_fn.reset();
s_config.reset();
if (ofs.is_open()) {
ofs.close();
}
}
void reset(const AzDvect *inp_v_y,
const char *perf_fn,
bool inp_doAppend)
{
v_y = inp_v_y;
s_perf_fn.reset(perf_fn);
doAppend = inp_doAppend;
}
virtual void resetConfig(const char *config) {
s_config.reset(config);
_clean(&s_config);
}
virtual void begin(const char *config,
AzLossType inp_loss_type) {
if (!isActive()) return;
_begin(config, inp_loss_type);
_clean(&s_config);
}
virtual void end() {
if (ofs.is_open()) {
ofs.close();
}
}
virtual void evaluate(const AzDvect *v_p,
const AzTE_ModelInfo *info,
const char *user_str=NULL) {
if (!isActive()) return;
AzPerfResult result=AzTaskTools::eval(v_p, v_y, loss_type);
/*--- signature and configuration ---*/
AzBytArr s_sign_config(info->s_sign);
s_sign_config.concat(":");
concat_config(info, &s_sign_config);
/*--- print ---*/
AzPrint o(perf_out);
o.printBegin("", ",", ",");
o.print("#tree", info->tree_num);
o.print("#leaf", info->leaf_num);
o.print("acc", result.acc, 4);
o.print("rmse", result.rmse, 4);
o.print("sqerr", result.rmse*result.rmse, 6);
o.print(loss_str[loss_type]);
o.print("loss", result.loss, 6);
o.print("#test", v_p->rowNum());
o.print("cfg"); /* for compatibility */
o.print(s_sign_config);
if (user_str != NULL) {
o.print(user_str);
}
o.printEnd();
}
protected:
virtual void _begin(const char *config, AzLossType inp_loss_type) {
s_config.reset(config);
loss_type = inp_loss_type;
if (ofs.is_open()) {
ofs.close();
}
const char *perf_fn = s_perf_fn.c_str();
if (AzTools::isSpecified(perf_fn)) {
ios_base::openmode mode = ios_base::out;
if (doAppend) {
mode = ios_base::app | ios_base::out;
}
ofs.open(perf_fn, mode);
ofs.set_to(perf_out);
}
else {
perf_out.setStdout();
}
}
virtual void _clean(AzBytArr *s) const {
/*-- replace comma with : for convenience later --*/
s->replace(',', ';');
}
virtual void concat_config(const AzTE_ModelInfo *info, AzBytArr *s) const {
if (s_config.length() > 0) {
s->concat(&s_config);
}
else {
AzBytArr s_cfg(&info->s_config);
_clean(&s_cfg);
s->concat(&s_cfg);
}
}
};
#endif
| 26.50625
| 77
| 0.603867
|
Tuanlase02874
|
39e055bceb1e414cb1b1f47a2fef97e2844cf7f0
| 8,559
|
cpp
|
C++
|
export/release/windows/obj/src/openfl/ui/Keyboard.cpp
|
bobisdabbing/Vs-The-United-Lands-stable
|
0807e58b6d8ad1440bdd350bf006b37a1b7ca9b5
|
[
"MIT"
] | null | null | null |
export/release/windows/obj/src/openfl/ui/Keyboard.cpp
|
bobisdabbing/Vs-The-United-Lands-stable
|
0807e58b6d8ad1440bdd350bf006b37a1b7ca9b5
|
[
"MIT"
] | null | null | null |
export/release/windows/obj/src/openfl/ui/Keyboard.cpp
|
bobisdabbing/Vs-The-United-Lands-stable
|
0807e58b6d8ad1440bdd350bf006b37a1b7ca9b5
|
[
"MIT"
] | null | null | null |
// Generated by Haxe 4.1.5
#include <hxcpp.h>
#ifndef INCLUDED_openfl_ui_Keyboard
#include <openfl/ui/Keyboard.h>
#endif
HX_LOCAL_STACK_FRAME(_hx_pos_410ccb691917537a_815___getCharCode,"openfl.ui.Keyboard","__getCharCode",0x5c5ae14e,"openfl.ui.Keyboard.__getCharCode","openfl/ui/Keyboard.hx",815,0x5fb867bb)
namespace openfl{
namespace ui{
void Keyboard_obj::__construct() { }
Dynamic Keyboard_obj::__CreateEmpty() { return new Keyboard_obj; }
void *Keyboard_obj::_hx_vtable = 0;
Dynamic Keyboard_obj::__Create(::hx::DynamicArray inArgs)
{
::hx::ObjectPtr< Keyboard_obj > _hx_result = new Keyboard_obj();
_hx_result->__construct();
return _hx_result;
}
bool Keyboard_obj::_hx_isInstanceOf(int inClassId) {
return inClassId==(int)0x00000001 || inClassId==(int)0x0c5957a7;
}
int Keyboard_obj::_hx___getCharCode(int key,::hx::Null< bool > __o_shift){
bool shift = __o_shift.Default(false);
HX_STACKFRAME(&_hx_pos_410ccb691917537a_815___getCharCode)
HXLINE( 816) if (!(shift)) {
HXLINE( 818) switch((int)(key)){
case (int)8: {
HXLINE( 821) return 8;
}
break;
case (int)9: {
HXLINE( 823) return 9;
}
break;
case (int)13: {
HXLINE( 825) return 13;
}
break;
case (int)27: {
HXLINE( 827) return 27;
}
break;
case (int)32: {
HXLINE( 829) return 32;
}
break;
case (int)186: {
HXLINE( 831) return 59;
}
break;
case (int)187: {
HXLINE( 833) return 61;
}
break;
case (int)188: {
HXLINE( 835) return 44;
}
break;
case (int)189: {
HXLINE( 837) return 45;
}
break;
case (int)190: {
HXLINE( 839) return 46;
}
break;
case (int)191: {
HXLINE( 841) return 47;
}
break;
case (int)192: {
HXLINE( 843) return 96;
}
break;
case (int)219: {
HXLINE( 845) return 91;
}
break;
case (int)220: {
HXLINE( 847) return 92;
}
break;
case (int)221: {
HXLINE( 849) return 93;
}
break;
case (int)222: {
HXLINE( 851) return 39;
}
break;
}
HXLINE( 854) bool _hx_tmp;
HXDLIN( 854) if ((key >= 48)) {
HXLINE( 854) _hx_tmp = (key <= 57);
}
else {
HXLINE( 854) _hx_tmp = false;
}
HXDLIN( 854) if (_hx_tmp) {
HXLINE( 856) return ((key - 48) + 48);
}
HXLINE( 859) bool _hx_tmp1;
HXDLIN( 859) if ((key >= 65)) {
HXLINE( 859) _hx_tmp1 = (key <= 90);
}
else {
HXLINE( 859) _hx_tmp1 = false;
}
HXDLIN( 859) if (_hx_tmp1) {
HXLINE( 861) return ((key - 65) + 97);
}
}
else {
HXLINE( 866) switch((int)(key)){
case (int)48: {
HXLINE( 869) return 41;
}
break;
case (int)49: {
HXLINE( 871) return 33;
}
break;
case (int)50: {
HXLINE( 873) return 64;
}
break;
case (int)51: {
HXLINE( 875) return 35;
}
break;
case (int)52: {
HXLINE( 877) return 36;
}
break;
case (int)53: {
HXLINE( 879) return 37;
}
break;
case (int)54: {
HXLINE( 881) return 94;
}
break;
case (int)55: {
HXLINE( 883) return 38;
}
break;
case (int)56: {
HXLINE( 885) return 42;
}
break;
case (int)57: {
HXLINE( 887) return 40;
}
break;
case (int)186: {
HXLINE( 889) return 58;
}
break;
case (int)187: {
HXLINE( 891) return 43;
}
break;
case (int)188: {
HXLINE( 893) return 60;
}
break;
case (int)189: {
HXLINE( 895) return 95;
}
break;
case (int)190: {
HXLINE( 897) return 62;
}
break;
case (int)191: {
HXLINE( 899) return 63;
}
break;
case (int)192: {
HXLINE( 901) return 126;
}
break;
case (int)219: {
HXLINE( 903) return 123;
}
break;
case (int)220: {
HXLINE( 905) return 124;
}
break;
case (int)221: {
HXLINE( 907) return 125;
}
break;
case (int)222: {
HXLINE( 909) return 34;
}
break;
}
HXLINE( 912) bool _hx_tmp;
HXDLIN( 912) if ((key >= 65)) {
HXLINE( 912) _hx_tmp = (key <= 90);
}
else {
HXLINE( 912) _hx_tmp = false;
}
HXDLIN( 912) if (_hx_tmp) {
HXLINE( 914) return ((key - 65) + 65);
}
}
HXLINE( 918) bool _hx_tmp;
HXDLIN( 918) if ((key >= 96)) {
HXLINE( 918) _hx_tmp = (key <= 105);
}
else {
HXLINE( 918) _hx_tmp = false;
}
HXDLIN( 918) if (_hx_tmp) {
HXLINE( 920) return ((key - 96) + 48);
}
HXLINE( 923) switch((int)(key)){
case (int)8: {
HXLINE( 940) return 8;
}
break;
case (int)13: {
HXLINE( 938) return 13;
}
break;
case (int)46: {
HXLINE( 936) return 127;
}
break;
case (int)106: {
HXLINE( 926) return 42;
}
break;
case (int)107: {
HXLINE( 928) return 43;
}
break;
case (int)108: {
HXLINE( 930) return 44;
}
break;
case (int)110: {
HXLINE( 932) return 45;
}
break;
case (int)111: {
HXLINE( 934) return 46;
}
break;
}
HXLINE( 943) return 0;
}
STATIC_HX_DEFINE_DYNAMIC_FUNC2(Keyboard_obj,_hx___getCharCode,return )
Keyboard_obj::Keyboard_obj()
{
}
bool Keyboard_obj::__GetStatic(const ::String &inName, Dynamic &outValue, ::hx::PropertyAccess inCallProp)
{
switch(inName.length) {
case 13:
if (HX_FIELD_EQ(inName,"__getCharCode") ) { outValue = _hx___getCharCode_dyn(); return true; }
}
return false;
}
#ifdef HXCPP_SCRIPTABLE
static ::hx::StorageInfo *Keyboard_obj_sMemberStorageInfo = 0;
static ::hx::StaticInfo *Keyboard_obj_sStaticStorageInfo = 0;
#endif
::hx::Class Keyboard_obj::__mClass;
static ::String Keyboard_obj_sStaticFields[] = {
HX_("__getCharCode",b9,62,90,0a),
::String(null())
};
void Keyboard_obj::__register()
{
Keyboard_obj _hx_dummy;
Keyboard_obj::_hx_vtable = *(void **)&_hx_dummy;
::hx::Static(__mClass) = new ::hx::Class_obj();
__mClass->mName = HX_("openfl.ui.Keyboard",43,b4,37,9a);
__mClass->mSuper = &super::__SGetClass();
__mClass->mConstructEmpty = &__CreateEmpty;
__mClass->mConstructArgs = &__Create;
__mClass->mGetStaticField = &Keyboard_obj::__GetStatic;
__mClass->mSetStaticField = &::hx::Class_obj::SetNoStaticField;
__mClass->mStatics = ::hx::Class_obj::dupFunctions(Keyboard_obj_sStaticFields);
__mClass->mMembers = ::hx::Class_obj::dupFunctions(0 /* sMemberFields */);
__mClass->mCanCast = ::hx::TCanCast< Keyboard_obj >;
#ifdef HXCPP_SCRIPTABLE
__mClass->mMemberStorageInfo = Keyboard_obj_sMemberStorageInfo;
#endif
#ifdef HXCPP_SCRIPTABLE
__mClass->mStaticStorageInfo = Keyboard_obj_sStaticStorageInfo;
#endif
::hx::_hx_RegisterClass(__mClass->mName, __mClass);
}
} // end namespace openfl
} // end namespace ui
| 26.830721
| 186
| 0.468746
|
bobisdabbing
|
39e063360296154fe53e3414e2779cf32e99311c
| 939
|
cpp
|
C++
|
LeetCode/Problems/Algorithms/#203_RemoveLinkedListElements_sol2_O(N)_time_O(1)_extra_space.cpp
|
Tudor67/Competitive-Programming
|
ae4dc6ed8bf76451775bf4f740c16394913f3ff1
|
[
"MIT"
] | 1
|
2022-01-26T14:50:07.000Z
|
2022-01-26T14:50:07.000Z
|
LeetCode/Problems/Algorithms/#203_RemoveLinkedListElements_sol2_O(N)_time_O(1)_extra_space.cpp
|
Tudor67/Competitive-Programming
|
ae4dc6ed8bf76451775bf4f740c16394913f3ff1
|
[
"MIT"
] | null | null | null |
LeetCode/Problems/Algorithms/#203_RemoveLinkedListElements_sol2_O(N)_time_O(1)_extra_space.cpp
|
Tudor67/Competitive-Programming
|
ae4dc6ed8bf76451775bf4f740c16394913f3ff1
|
[
"MIT"
] | null | null | null |
/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode() : val(0), next(nullptr) {}
* ListNode(int x) : val(x), next(nullptr) {}
* ListNode(int x, ListNode *next) : val(x), next(next) {}
* };
*/
class Solution {
public:
ListNode* removeElements(ListNode* head, int val) {
ListNode* prevHead = new ListNode(INT_MIN, head);
ListNode* prevNode = prevHead;
ListNode* node = head;
while(node != NULL){
if(node->val == val){
prevNode->next = node->next;
node->next = NULL;
delete node;
}else{
prevNode = node;
}
node = prevNode->next;
}
head = prevHead->next;
prevHead->next = NULL;
delete prevHead;
return head;
}
};
| 26.828571
| 63
| 0.467519
|
Tudor67
|
39e275300249bd12116dcbe24635ecc564ef59b2
| 644
|
cpp
|
C++
|
benchmark/sum_array.cilk.cpp
|
mikerainey/taskparts
|
27d4bdda15a5c370c25df6ce8be1233362107cc8
|
[
"MIT"
] | null | null | null |
benchmark/sum_array.cilk.cpp
|
mikerainey/taskparts
|
27d4bdda15a5c370c25df6ce8be1233362107cc8
|
[
"MIT"
] | null | null | null |
benchmark/sum_array.cilk.cpp
|
mikerainey/taskparts
|
27d4bdda15a5c370c25df6ce8be1233362107cc8
|
[
"MIT"
] | null | null | null |
#include "cilk.hpp"
double sum_array_cilk(double* __restrict__ a, uint64_t lo, uint64_t hi) {
cilk::reducer_opadd<double> sum(0);
cilk_for (uint64_t i = 0; i != hi; i++) {
*sum += a[i];
}
return sum.get_value();
}
int main() {
size_t nb_items = taskparts::cmdline::parse_or_default_long("n", 100 * 1000 * 1000);
double result = 0.0;
double* a = nullptr;
taskparts::benchmark_cilk([&] {
result = sum_array_cilk(a, 0, nb_items);
}, [&] {
a = new double[nb_items];
for (size_t i = 0; i < nb_items; i++) {
a[i] = 1.0;
}
}, [&] {
printf("result=%f\n",result);
delete [] a;
});
return 0;
}
| 23
| 86
| 0.579193
|
mikerainey
|
39e2c8de74e7882f16e38daa31a1cf9845f5ea05
| 5,158
|
cpp
|
C++
|
test/util/testMath.cpp
|
KUDB/MSDB
|
19e89d1d9c09c57b242737f0634ac30b4c8ecfd7
|
[
"MIT"
] | 2
|
2021-08-31T12:43:16.000Z
|
2021-12-13T13:49:19.000Z
|
test/util/testMath.cpp
|
KUDB/MSDB
|
19e89d1d9c09c57b242737f0634ac30b4c8ecfd7
|
[
"MIT"
] | 3
|
2021-09-09T17:23:31.000Z
|
2021-09-09T19:14:50.000Z
|
test/util/testMath.cpp
|
KUDB/MSDB
|
19e89d1d9c09c57b242737f0634ac30b4c8ecfd7
|
[
"MIT"
] | null | null | null |
#include <pch_test.h>
#include <util/math.h>
using namespace msdb::core;
TEST(util_math, msb_char)
{
// 0111 1000
EXPECT_EQ(msb<char>(120, 1), 7);
EXPECT_EQ(msb<char>(120, 2), 6);
EXPECT_EQ(msb<char>(120, 3), 5);
EXPECT_EQ(msb<char>(120, 4), 4);
EXPECT_EQ(msb<char>(120, 5), 0);
// 0101 0101
EXPECT_EQ(msb<char>(85, 1), 7);
EXPECT_EQ(msb<char>(85, 2), 5);
EXPECT_EQ(msb<char>(85, 3), 3);
EXPECT_EQ(msb<char>(85, 4), 1);
EXPECT_EQ(msb<char>(85, 5), 0);
// 0011 0100
EXPECT_EQ(msb<char>(52, 1), 6);
EXPECT_EQ(msb<char>(52, 2), 5);
EXPECT_EQ(msb<char>(52, 3), 3);
EXPECT_EQ(msb<char>(52, 4), 0);
// 1000 1000
EXPECT_EQ(msb<char>(-120, 1), 8);
EXPECT_EQ(msb<char>(-120, 2), 4);
EXPECT_EQ(msb<char>(-120, 3), 0);
EXPECT_EQ(msb<char>(-120, 4), 0);
EXPECT_EQ(msb<char>(-120, 5), 0);
// 1010 1011
EXPECT_EQ(msb<char>(-85, 1), 8);
EXPECT_EQ(msb<char>(-85, 2), 6);
EXPECT_EQ(msb<char>(-85, 3), 4);
EXPECT_EQ(msb<char>(-85, 4), 2);
EXPECT_EQ(msb<char>(-85, 5), 1);
EXPECT_EQ(msb<char>(-85, 6), 0);
// 1100 1100
EXPECT_EQ(msb<char>(-52, 1), 8);
EXPECT_EQ(msb<char>(-52, 2), 7);
EXPECT_EQ(msb<char>(-52, 3), 4);
EXPECT_EQ(msb<char>(-52, 4), 3);
EXPECT_EQ(msb<char>(-52, 5), 0);
// 1000 0001
EXPECT_EQ(msb<char>(-127, 1), 8);
EXPECT_EQ(msb<char>(-127, 2), 1);
EXPECT_EQ(msb<char>(-127, 3), 0);
// Special case: Min Limit
// 1000 0000
EXPECT_EQ(msb<char>(-128, 1), 7);
EXPECT_EQ(msb<char>(-128, 2), 0);
EXPECT_EQ(msb<char>(-128, 2), 0);
}
TEST(util_math, getMinBoundary)
{
// 28 (0001 1100)
EXPECT_EQ(getMinBoundary<char>(28, 1, 7), 64);
EXPECT_EQ(getMinBoundary<char>(28, 1, 6), 32);
EXPECT_EQ(getMinBoundary<char>(28, 1, 5), 28);
EXPECT_EQ(getMinBoundary<char>(28, 2, 4), 28);
EXPECT_EQ(getMinBoundary<char>(28, 3, 3), 28);
// -28
EXPECT_EQ(getMinBoundary<char>(-28, 1, -5), -28);
EXPECT_EQ(getMinBoundary<char>(-28, 1, -4), -15);
EXPECT_EQ(getMinBoundary<char>(-28, 1, -3), -7);
EXPECT_EQ(getMinBoundary<char>(-28, 1, -2), -3);
EXPECT_EQ(getMinBoundary<char>(-28, 1, -1), -1);
EXPECT_EQ(getMinBoundary<char>(-28, 2, -4), -28);
EXPECT_EQ(getMinBoundary<char>(-28, 2, -3), -23);
EXPECT_EQ(getMinBoundary<char>(-28, 2, -2), -19);
EXPECT_EQ(getMinBoundary<char>(-28, 2, -1), -17);
EXPECT_EQ(getMinBoundary<char>(-28, 3, -3), -28);
EXPECT_EQ(getMinBoundary<char>(-28, 3, -2), -27);
EXPECT_EQ(getMinBoundary<char>(-28, 3, -1), -25);
// 81 (0101 0001)
EXPECT_EQ(getMinBoundary<char>(81, 1, 7), 81);
EXPECT_EQ(getMinBoundary<char>(81, 2, 6), 96);
EXPECT_EQ(getMinBoundary<char>(81, 2, 5), 81);
EXPECT_EQ(getMinBoundary<char>(81, 3, 4), 88);
EXPECT_EQ(getMinBoundary<char>(81, 3, 3), 84);
EXPECT_EQ(getMinBoundary<char>(81, 3, 2), 82);
EXPECT_EQ(getMinBoundary<char>(81, 3, 1), 81);
// -126 (0111 1110)
EXPECT_EQ(getMinBoundary<char>(-126, 1, -7), -126);
// -91 (0101 1011)
EXPECT_EQ(getMinBoundary<char>(-91, 2, -5), -91);
}
TEST(util_math, getMaxBoundary)
{
// 81 (0101 0001)
EXPECT_EQ(getMaxBoundary<char>(81, 1, 7), 81);
EXPECT_EQ(getMaxBoundary<char>(81, 1, 6), 63);
EXPECT_EQ(getMaxBoundary<char>(81, 1, 5), 31);
EXPECT_EQ(getMaxBoundary<char>(81, 1, 4), 15);
EXPECT_EQ(getMaxBoundary<char>(81, 1, 3), 7);
EXPECT_EQ(getMaxBoundary<char>(81, 1, 2), 3);
EXPECT_EQ(getMaxBoundary<char>(81, 1, 1), 1);
// Cannot be large than prevLimit '81'
// 81, 2, (7, 6) >= 96
EXPECT_EQ(getMaxBoundary<char>(81, 2, 5), 81);
EXPECT_EQ(getMaxBoundary<char>(81, 2, 4), 79);
EXPECT_EQ(getMaxBoundary<char>(81, 2, 3), 71);
EXPECT_EQ(getMaxBoundary<char>(81, 2, 2), 67);
EXPECT_EQ(getMaxBoundary<char>(81, 2, 1), 65);
// Cannot be large than prevLimit '81'
// 81, 3, (4, 3, 2) >= 82
EXPECT_EQ(getMaxBoundary<char>(81, 3, 1), 81);
//////////////////////////////
EXPECT_EQ((char)getMaxBoundary<char>(127, 1, -7), -64);
EXPECT_EQ((char)getMaxBoundary<char>(127, 1, -6), -32);
EXPECT_EQ((char)getMaxBoundary<char>(127, 1, -5), -16);
EXPECT_EQ((char)getMaxBoundary<char>(127, 1, -4), -8);
EXPECT_EQ((char)getMaxBoundary<char>(127, 1, -3), -4);
EXPECT_EQ((char)getMaxBoundary<char>(127, 1, -2), -2);
EXPECT_EQ((char)getMaxBoundary<char>(127, 1, -1), -1);
EXPECT_EQ((char)getMaxBoundary<char>(127, 1, 0), 0);
EXPECT_EQ((char)getMaxBoundary<char>(127, 1, 1), 1);
EXPECT_EQ((char)getMaxBoundary<char>(127, 1, 2), 3);
EXPECT_EQ((char)getMaxBoundary<char>(127, 1, 3), 7);
EXPECT_EQ((char)getMaxBoundary<char>(127, 1, 4), 15);
EXPECT_EQ((char)getMaxBoundary<char>(127, 1, 5), 31);
EXPECT_EQ((char)getMaxBoundary<char>(127, 1, 6), 63);
EXPECT_EQ((char)getMaxBoundary<char>(127, 1, 7), 127);
//////////////////////////////
EXPECT_EQ((char)getMaxBoundary<char>(-78, 2, -4), -78);
}
TEST(util_math, getMaxValue)
{
EXPECT_EQ(getMaxValue<char>(), 127);
EXPECT_EQ(getMaxValue<uint8_t>(), 255);
EXPECT_EQ(getMaxValue<int16_t>(), 32767);
EXPECT_EQ(getMaxValue<uint16_t>(), 65535);
}
TEST(util_math, getMinValue)
{
EXPECT_EQ(getMinValue<char>(), -128);
EXPECT_EQ(getMinValue<uint8_t>(), 0);
EXPECT_EQ(getMinValue<int16_t>(), -32768);
EXPECT_EQ(getMinValue<uint16_t>(), 0);
}
TEST(util_math, getPrefixPosForPrevLimit)
{
EXPECT_EQ(getPrefixPosForPrevLimit(64, 2), 7);
}
| 29.988372
| 56
| 0.642691
|
KUDB
|
39e31ff5d9cf5478fc0183ec4f1664a9ad4218e9
| 31,717
|
inl
|
C++
|
engine/xboxsystem.xsessioncallstack.inl
|
DannyParker0001/Kisak-Strike
|
99ed85927336fe3aff2efd9b9382b2b32eb1d05d
|
[
"Unlicense"
] | 252
|
2020-12-16T15:34:43.000Z
|
2022-03-31T23:21:37.000Z
|
cstrike15_src/engine/xboxsystem.xsessioncallstack.inl
|
bahadiraraz/Counter-Strike-Global-Offensive
|
9a0534100cb98ffa1cf0c32e138f0e7971e910d3
|
[
"MIT"
] | 23
|
2020-12-20T18:02:54.000Z
|
2022-03-28T16:58:32.000Z
|
cstrike15_src/engine/xboxsystem.xsessioncallstack.inl
|
bahadiraraz/Counter-Strike-Global-Offensive
|
9a0534100cb98ffa1cf0c32e138f0e7971e910d3
|
[
"MIT"
] | 42
|
2020-12-19T04:32:33.000Z
|
2022-03-30T06:00:28.000Z
|
#define HELPER_OVERLAPPED_SESSION_CALL_C_0( )
#define HELPER_OVERLAPPED_SESSION_CALL_A_0( )
#define HELPER_OVERLAPPED_SESSION_CALL_P_0( )
#define HELPER_OVERLAPPED_SESSION_CALL_I_0( )
#define HELPER_OVERLAPPED_SESSION_CALL_M_0( )
#define DECLARE_OVERLAPPED_SESSION_CALL_0( XCallNameFN_T ) \
struct XCallNameFN_T##_OverlappedCall_t : public XSessionCallStack::OverlappedSessionCall { \
XCallNameFN_T##_OverlappedCall_t( HANDLE hSession, \
HELPER_OVERLAPPED_SESSION_CALL_C_0( ) \
PXOVERLAPPED pxOverlapped ) : \
XSessionCallStack::OverlappedSessionCall( hSession, pxOverlapped ) \
HELPER_OVERLAPPED_SESSION_CALL_A_0( ) {} \
virtual char const * Name() { return #XCallNameFN_T; } \
virtual DWORD Run() { \
DWORD ret = ::XCallNameFN_T( m_hSession, \
HELPER_OVERLAPPED_SESSION_CALL_P_0( ) \
m_pxOverlapped ? &m_xOverlapped : NULL ); \
if ( ret != ERROR_SUCCESS && ret != ERROR_IO_PENDING ) { Warning( "XCall " #XCallNameFN_T " failed ( ret = %d, overlapped = %p )!\n", ret, m_pxOverlapped ); Assert( 0 ); } \
return ret; } \
HELPER_OVERLAPPED_SESSION_CALL_M_0( ) \
};
#define IMPLEMENT_OVERLAPPED_SESSION_CALL_0( XCallNameFN_T ) \
DECLARE_OVERLAPPED_SESSION_CALL_0( XCallNameFN_T ) \
virtual DWORD XCallNameFN_T( HANDLE hSession, \
HELPER_OVERLAPPED_SESSION_CALL_C_0( ) \
PXOVERLAPPED pxOverlapped ) { \
return g_XSessionCallStack.ScheduleOverlappedSessionCall( new XCallNameFN_T##_OverlappedCall_t( hSession, \
HELPER_OVERLAPPED_SESSION_CALL_I_0( ) \
pxOverlapped ) ); \
};
#define HELPER_OVERLAPPED_SESSION_CALL_C_1( ArgType1, ArgName1 ) ArgType1 ArgName1,
#define HELPER_OVERLAPPED_SESSION_CALL_A_1( ArgType1, ArgName1 ) , m_##ArgName1( ArgName1 )
#define HELPER_OVERLAPPED_SESSION_CALL_P_1( ArgType1, ArgName1 ) m_##ArgName1,
#define HELPER_OVERLAPPED_SESSION_CALL_I_1( ArgType1, ArgName1 ) ArgName1,
#define HELPER_OVERLAPPED_SESSION_CALL_M_1( ArgType1, ArgName1 ) ArgType1 m_##ArgName1;
#define DECLARE_OVERLAPPED_SESSION_CALL_1( XCallNameFN_T, ArgType1, ArgName1 ) \
struct XCallNameFN_T##_OverlappedCall_t : public XSessionCallStack::OverlappedSessionCall { \
XCallNameFN_T##_OverlappedCall_t( HANDLE hSession, \
HELPER_OVERLAPPED_SESSION_CALL_C_1( ArgType1, ArgName1 ) \
PXOVERLAPPED pxOverlapped ) : \
XSessionCallStack::OverlappedSessionCall( hSession, pxOverlapped ) \
HELPER_OVERLAPPED_SESSION_CALL_A_1( ArgType1, ArgName1 ) {} \
virtual char const * Name() { return #XCallNameFN_T; } \
virtual DWORD Run() { \
DWORD ret = ::XCallNameFN_T( m_hSession, \
HELPER_OVERLAPPED_SESSION_CALL_P_1( ArgType1, ArgName1 ) \
m_pxOverlapped ? &m_xOverlapped : NULL ); \
if ( ret != ERROR_SUCCESS && ret != ERROR_IO_PENDING ) { Warning( "XCall " #XCallNameFN_T " failed ( ret = %d, overlapped = %p )!\n", ret, m_pxOverlapped ); Assert( 0 ); } \
return ret; } \
HELPER_OVERLAPPED_SESSION_CALL_M_1( ArgType1, ArgName1 ) \
};
#define IMPLEMENT_OVERLAPPED_SESSION_CALL_1( XCallNameFN_T, ArgType1, ArgName1 ) \
DECLARE_OVERLAPPED_SESSION_CALL_1( XCallNameFN_T, ArgType1, ArgName1 ) \
virtual DWORD XCallNameFN_T( HANDLE hSession, \
HELPER_OVERLAPPED_SESSION_CALL_C_1( ArgType1, ArgName1 ) \
PXOVERLAPPED pxOverlapped ) { \
return g_XSessionCallStack.ScheduleOverlappedSessionCall( new XCallNameFN_T##_OverlappedCall_t( hSession, \
HELPER_OVERLAPPED_SESSION_CALL_I_1( ArgType1, ArgName1 ) \
pxOverlapped ) ); \
};
#define HELPER_OVERLAPPED_SESSION_CALL_C_2( ArgType1, ArgName1, ArgType2, ArgName2 ) ArgType1 ArgName1, ArgType2 ArgName2,
#define HELPER_OVERLAPPED_SESSION_CALL_A_2( ArgType1, ArgName1, ArgType2, ArgName2 ) , m_##ArgName1( ArgName1 ), m_##ArgName2( ArgName2 )
#define HELPER_OVERLAPPED_SESSION_CALL_P_2( ArgType1, ArgName1, ArgType2, ArgName2 ) m_##ArgName1, m_##ArgName2,
#define HELPER_OVERLAPPED_SESSION_CALL_I_2( ArgType1, ArgName1, ArgType2, ArgName2 ) ArgName1, ArgName2,
#define HELPER_OVERLAPPED_SESSION_CALL_M_2( ArgType1, ArgName1, ArgType2, ArgName2 ) ArgType1 m_##ArgName1;ArgType2 m_##ArgName2;
#define DECLARE_OVERLAPPED_SESSION_CALL_2( XCallNameFN_T, ArgType1, ArgName1, ArgType2, ArgName2 ) \
struct XCallNameFN_T##_OverlappedCall_t : public XSessionCallStack::OverlappedSessionCall { \
XCallNameFN_T##_OverlappedCall_t( HANDLE hSession, \
HELPER_OVERLAPPED_SESSION_CALL_C_2( ArgType1, ArgName1, ArgType2, ArgName2 ) \
PXOVERLAPPED pxOverlapped ) : \
XSessionCallStack::OverlappedSessionCall( hSession, pxOverlapped ) \
HELPER_OVERLAPPED_SESSION_CALL_A_2( ArgType1, ArgName1, ArgType2, ArgName2 ) {} \
virtual char const * Name() { return #XCallNameFN_T; } \
virtual DWORD Run() { \
DWORD ret = ::XCallNameFN_T( m_hSession, \
HELPER_OVERLAPPED_SESSION_CALL_P_2( ArgType1, ArgName1, ArgType2, ArgName2 ) \
m_pxOverlapped ? &m_xOverlapped : NULL ); \
if ( ret != ERROR_SUCCESS && ret != ERROR_IO_PENDING ) { Warning( "XCall " #XCallNameFN_T " failed ( ret = %d, overlapped = %p )!\n", ret, m_pxOverlapped ); Assert( 0 ); } \
return ret; } \
HELPER_OVERLAPPED_SESSION_CALL_M_2( ArgType1, ArgName1, ArgType2, ArgName2 ) \
};
#define IMPLEMENT_OVERLAPPED_SESSION_CALL_2( XCallNameFN_T, ArgType1, ArgName1, ArgType2, ArgName2 ) \
DECLARE_OVERLAPPED_SESSION_CALL_2( XCallNameFN_T, ArgType1, ArgName1, ArgType2, ArgName2 ) \
virtual DWORD XCallNameFN_T( HANDLE hSession, \
HELPER_OVERLAPPED_SESSION_CALL_C_2( ArgType1, ArgName1, ArgType2, ArgName2 ) \
PXOVERLAPPED pxOverlapped ) { \
return g_XSessionCallStack.ScheduleOverlappedSessionCall( new XCallNameFN_T##_OverlappedCall_t( hSession, \
HELPER_OVERLAPPED_SESSION_CALL_I_2( ArgType1, ArgName1, ArgType2, ArgName2 ) \
pxOverlapped ) ); \
};
#define HELPER_OVERLAPPED_SESSION_CALL_C_3( ArgType1, ArgName1, ArgType2, ArgName2, ArgType3, ArgName3 ) ArgType1 ArgName1, ArgType2 ArgName2, ArgType3 ArgName3,
#define HELPER_OVERLAPPED_SESSION_CALL_A_3( ArgType1, ArgName1, ArgType2, ArgName2, ArgType3, ArgName3 ) , m_##ArgName1( ArgName1 ), m_##ArgName2( ArgName2 ), m_##ArgName3( ArgName3 )
#define HELPER_OVERLAPPED_SESSION_CALL_P_3( ArgType1, ArgName1, ArgType2, ArgName2, ArgType3, ArgName3 ) m_##ArgName1, m_##ArgName2, m_##ArgName3,
#define HELPER_OVERLAPPED_SESSION_CALL_I_3( ArgType1, ArgName1, ArgType2, ArgName2, ArgType3, ArgName3 ) ArgName1, ArgName2, ArgName3,
#define HELPER_OVERLAPPED_SESSION_CALL_M_3( ArgType1, ArgName1, ArgType2, ArgName2, ArgType3, ArgName3 ) ArgType1 m_##ArgName1;ArgType2 m_##ArgName2;ArgType3 m_##ArgName3;
#define DECLARE_OVERLAPPED_SESSION_CALL_3( XCallNameFN_T, ArgType1, ArgName1, ArgType2, ArgName2, ArgType3, ArgName3 ) \
struct XCallNameFN_T##_OverlappedCall_t : public XSessionCallStack::OverlappedSessionCall { \
XCallNameFN_T##_OverlappedCall_t( HANDLE hSession, \
HELPER_OVERLAPPED_SESSION_CALL_C_3( ArgType1, ArgName1, ArgType2, ArgName2, ArgType3, ArgName3 ) \
PXOVERLAPPED pxOverlapped ) : \
XSessionCallStack::OverlappedSessionCall( hSession, pxOverlapped ) \
HELPER_OVERLAPPED_SESSION_CALL_A_3( ArgType1, ArgName1, ArgType2, ArgName2, ArgType3, ArgName3 ) {} \
virtual char const * Name() { return #XCallNameFN_T; } \
virtual DWORD Run() { \
DWORD ret = ::XCallNameFN_T( m_hSession, \
HELPER_OVERLAPPED_SESSION_CALL_P_3( ArgType1, ArgName1, ArgType2, ArgName2, ArgType3, ArgName3 ) \
m_pxOverlapped ? &m_xOverlapped : NULL ); \
if ( ret != ERROR_SUCCESS && ret != ERROR_IO_PENDING ) { Warning( "XCall " #XCallNameFN_T " failed ( ret = %d, overlapped = %p )!\n", ret, m_pxOverlapped ); Assert( 0 ); } \
return ret; } \
HELPER_OVERLAPPED_SESSION_CALL_M_3( ArgType1, ArgName1, ArgType2, ArgName2, ArgType3, ArgName3 ) \
};
#define IMPLEMENT_OVERLAPPED_SESSION_CALL_3( XCallNameFN_T, ArgType1, ArgName1, ArgType2, ArgName2, ArgType3, ArgName3 ) \
DECLARE_OVERLAPPED_SESSION_CALL_3( XCallNameFN_T, ArgType1, ArgName1, ArgType2, ArgName2, ArgType3, ArgName3 ) \
virtual DWORD XCallNameFN_T( HANDLE hSession, \
HELPER_OVERLAPPED_SESSION_CALL_C_3( ArgType1, ArgName1, ArgType2, ArgName2, ArgType3, ArgName3 ) \
PXOVERLAPPED pxOverlapped ) { \
return g_XSessionCallStack.ScheduleOverlappedSessionCall( new XCallNameFN_T##_OverlappedCall_t( hSession, \
HELPER_OVERLAPPED_SESSION_CALL_I_3( ArgType1, ArgName1, ArgType2, ArgName2, ArgType3, ArgName3 ) \
pxOverlapped ) ); \
};
#define HELPER_OVERLAPPED_SESSION_CALL_C_4( ArgType1, ArgName1, ArgType2, ArgName2, ArgType3, ArgName3, ArgType4, ArgName4 ) ArgType1 ArgName1, ArgType2 ArgName2, ArgType3 ArgName3, ArgType4 ArgName4,
#define HELPER_OVERLAPPED_SESSION_CALL_A_4( ArgType1, ArgName1, ArgType2, ArgName2, ArgType3, ArgName3, ArgType4, ArgName4 ) , m_##ArgName1( ArgName1 ), m_##ArgName2( ArgName2 ), m_##ArgName3( ArgName3 ), m_##ArgName4( ArgName4 )
#define HELPER_OVERLAPPED_SESSION_CALL_P_4( ArgType1, ArgName1, ArgType2, ArgName2, ArgType3, ArgName3, ArgType4, ArgName4 ) m_##ArgName1, m_##ArgName2, m_##ArgName3, m_##ArgName4,
#define HELPER_OVERLAPPED_SESSION_CALL_I_4( ArgType1, ArgName1, ArgType2, ArgName2, ArgType3, ArgName3, ArgType4, ArgName4 ) ArgName1, ArgName2, ArgName3, ArgName4,
#define HELPER_OVERLAPPED_SESSION_CALL_M_4( ArgType1, ArgName1, ArgType2, ArgName2, ArgType3, ArgName3, ArgType4, ArgName4 ) ArgType1 m_##ArgName1;ArgType2 m_##ArgName2;ArgType3 m_##ArgName3;ArgType4 m_##ArgName4;
#define DECLARE_OVERLAPPED_SESSION_CALL_4( XCallNameFN_T, ArgType1, ArgName1, ArgType2, ArgName2, ArgType3, ArgName3, ArgType4, ArgName4 ) \
struct XCallNameFN_T##_OverlappedCall_t : public XSessionCallStack::OverlappedSessionCall { \
XCallNameFN_T##_OverlappedCall_t( HANDLE hSession, \
HELPER_OVERLAPPED_SESSION_CALL_C_4( ArgType1, ArgName1, ArgType2, ArgName2, ArgType3, ArgName3, ArgType4, ArgName4 ) \
PXOVERLAPPED pxOverlapped ) : \
XSessionCallStack::OverlappedSessionCall( hSession, pxOverlapped ) \
HELPER_OVERLAPPED_SESSION_CALL_A_4( ArgType1, ArgName1, ArgType2, ArgName2, ArgType3, ArgName3, ArgType4, ArgName4 ) {} \
virtual char const * Name() { return #XCallNameFN_T; } \
virtual DWORD Run() { \
DWORD ret = ::XCallNameFN_T( m_hSession, \
HELPER_OVERLAPPED_SESSION_CALL_P_4( ArgType1, ArgName1, ArgType2, ArgName2, ArgType3, ArgName3, ArgType4, ArgName4 ) \
m_pxOverlapped ? &m_xOverlapped : NULL ); \
if ( ret != ERROR_SUCCESS && ret != ERROR_IO_PENDING ) { Warning( "XCall " #XCallNameFN_T " failed ( ret = %d, overlapped = %p )!\n", ret, m_pxOverlapped ); Assert( 0 ); } \
return ret; } \
HELPER_OVERLAPPED_SESSION_CALL_M_4( ArgType1, ArgName1, ArgType2, ArgName2, ArgType3, ArgName3, ArgType4, ArgName4 ) \
};
#define IMPLEMENT_OVERLAPPED_SESSION_CALL_4( XCallNameFN_T, ArgType1, ArgName1, ArgType2, ArgName2, ArgType3, ArgName3, ArgType4, ArgName4 ) \
DECLARE_OVERLAPPED_SESSION_CALL_4( XCallNameFN_T, ArgType1, ArgName1, ArgType2, ArgName2, ArgType3, ArgName3, ArgType4, ArgName4 ) \
virtual DWORD XCallNameFN_T( HANDLE hSession, \
HELPER_OVERLAPPED_SESSION_CALL_C_4( ArgType1, ArgName1, ArgType2, ArgName2, ArgType3, ArgName3, ArgType4, ArgName4 ) \
PXOVERLAPPED pxOverlapped ) { \
return g_XSessionCallStack.ScheduleOverlappedSessionCall( new XCallNameFN_T##_OverlappedCall_t( hSession, \
HELPER_OVERLAPPED_SESSION_CALL_I_4( ArgType1, ArgName1, ArgType2, ArgName2, ArgType3, ArgName3, ArgType4, ArgName4 ) \
pxOverlapped ) ); \
};
#define HELPER_OVERLAPPED_SESSION_CALL_C_5( ArgType1, ArgName1, ArgType2, ArgName2, ArgType3, ArgName3, ArgType4, ArgName4, ArgType5, ArgName5 ) ArgType1 ArgName1, ArgType2 ArgName2, ArgType3 ArgName3, ArgType4 ArgName4, ArgType5 ArgName5,
#define HELPER_OVERLAPPED_SESSION_CALL_A_5( ArgType1, ArgName1, ArgType2, ArgName2, ArgType3, ArgName3, ArgType4, ArgName4, ArgType5, ArgName5 ) , m_##ArgName1( ArgName1 ), m_##ArgName2( ArgName2 ), m_##ArgName3( ArgName3 ), m_##ArgName4( ArgName4 ), m_##ArgName5( ArgName5 )
#define HELPER_OVERLAPPED_SESSION_CALL_P_5( ArgType1, ArgName1, ArgType2, ArgName2, ArgType3, ArgName3, ArgType4, ArgName4, ArgType5, ArgName5 ) m_##ArgName1, m_##ArgName2, m_##ArgName3, m_##ArgName4, m_##ArgName5,
#define HELPER_OVERLAPPED_SESSION_CALL_I_5( ArgType1, ArgName1, ArgType2, ArgName2, ArgType3, ArgName3, ArgType4, ArgName4, ArgType5, ArgName5 ) ArgName1, ArgName2, ArgName3, ArgName4, ArgName5,
#define HELPER_OVERLAPPED_SESSION_CALL_M_5( ArgType1, ArgName1, ArgType2, ArgName2, ArgType3, ArgName3, ArgType4, ArgName4, ArgType5, ArgName5 ) ArgType1 m_##ArgName1;ArgType2 m_##ArgName2;ArgType3 m_##ArgName3;ArgType4 m_##ArgName4;ArgType5 m_##ArgName5;
#define DECLARE_OVERLAPPED_SESSION_CALL_5( XCallNameFN_T, ArgType1, ArgName1, ArgType2, ArgName2, ArgType3, ArgName3, ArgType4, ArgName4, ArgType5, ArgName5 ) \
struct XCallNameFN_T##_OverlappedCall_t : public XSessionCallStack::OverlappedSessionCall { \
XCallNameFN_T##_OverlappedCall_t( HANDLE hSession, \
HELPER_OVERLAPPED_SESSION_CALL_C_5( ArgType1, ArgName1, ArgType2, ArgName2, ArgType3, ArgName3, ArgType4, ArgName4, ArgType5, ArgName5 ) \
PXOVERLAPPED pxOverlapped ) : \
XSessionCallStack::OverlappedSessionCall( hSession, pxOverlapped ) \
HELPER_OVERLAPPED_SESSION_CALL_A_5( ArgType1, ArgName1, ArgType2, ArgName2, ArgType3, ArgName3, ArgType4, ArgName4, ArgType5, ArgName5 ) {} \
virtual char const * Name() { return #XCallNameFN_T; } \
virtual DWORD Run() { \
DWORD ret = ::XCallNameFN_T( m_hSession, \
HELPER_OVERLAPPED_SESSION_CALL_P_5( ArgType1, ArgName1, ArgType2, ArgName2, ArgType3, ArgName3, ArgType4, ArgName4, ArgType5, ArgName5 ) \
m_pxOverlapped ? &m_xOverlapped : NULL ); \
if ( ret != ERROR_SUCCESS && ret != ERROR_IO_PENDING ) { Warning( "XCall " #XCallNameFN_T " failed ( ret = %d, overlapped = %p )!\n", ret, m_pxOverlapped ); Assert( 0 ); } \
return ret; } \
HELPER_OVERLAPPED_SESSION_CALL_M_5( ArgType1, ArgName1, ArgType2, ArgName2, ArgType3, ArgName3, ArgType4, ArgName4, ArgType5, ArgName5 ) \
};
#define IMPLEMENT_OVERLAPPED_SESSION_CALL_5( XCallNameFN_T, ArgType1, ArgName1, ArgType2, ArgName2, ArgType3, ArgName3, ArgType4, ArgName4, ArgType5, ArgName5 ) \
DECLARE_OVERLAPPED_SESSION_CALL_5( XCallNameFN_T, ArgType1, ArgName1, ArgType2, ArgName2, ArgType3, ArgName3, ArgType4, ArgName4, ArgType5, ArgName5 ) \
virtual DWORD XCallNameFN_T( HANDLE hSession, \
HELPER_OVERLAPPED_SESSION_CALL_C_5( ArgType1, ArgName1, ArgType2, ArgName2, ArgType3, ArgName3, ArgType4, ArgName4, ArgType5, ArgName5 ) \
PXOVERLAPPED pxOverlapped ) { \
return g_XSessionCallStack.ScheduleOverlappedSessionCall( new XCallNameFN_T##_OverlappedCall_t( hSession, \
HELPER_OVERLAPPED_SESSION_CALL_I_5( ArgType1, ArgName1, ArgType2, ArgName2, ArgType3, ArgName3, ArgType4, ArgName4, ArgType5, ArgName5 ) \
pxOverlapped ) ); \
};
#define HELPER_OVERLAPPED_SESSION_CALL_C_6( ArgType1, ArgName1, ArgType2, ArgName2, ArgType3, ArgName3, ArgType4, ArgName4, ArgType5, ArgName5, ArgType6, ArgName6 ) ArgType1 ArgName1, ArgType2 ArgName2, ArgType3 ArgName3, ArgType4 ArgName4, ArgType5 ArgName5, ArgType6 ArgName6,
#define HELPER_OVERLAPPED_SESSION_CALL_A_6( ArgType1, ArgName1, ArgType2, ArgName2, ArgType3, ArgName3, ArgType4, ArgName4, ArgType5, ArgName5, ArgType6, ArgName6 ) , m_##ArgName1( ArgName1 ), m_##ArgName2( ArgName2 ), m_##ArgName3( ArgName3 ), m_##ArgName4( ArgName4 ), m_##ArgName5( ArgName5 ), m_##ArgName6( ArgName6 )
#define HELPER_OVERLAPPED_SESSION_CALL_P_6( ArgType1, ArgName1, ArgType2, ArgName2, ArgType3, ArgName3, ArgType4, ArgName4, ArgType5, ArgName5, ArgType6, ArgName6 ) m_##ArgName1, m_##ArgName2, m_##ArgName3, m_##ArgName4, m_##ArgName5, m_##ArgName6,
#define HELPER_OVERLAPPED_SESSION_CALL_I_6( ArgType1, ArgName1, ArgType2, ArgName2, ArgType3, ArgName3, ArgType4, ArgName4, ArgType5, ArgName5, ArgType6, ArgName6 ) ArgName1, ArgName2, ArgName3, ArgName4, ArgName5, ArgName6,
#define HELPER_OVERLAPPED_SESSION_CALL_M_6( ArgType1, ArgName1, ArgType2, ArgName2, ArgType3, ArgName3, ArgType4, ArgName4, ArgType5, ArgName5, ArgType6, ArgName6 ) ArgType1 m_##ArgName1;ArgType2 m_##ArgName2;ArgType3 m_##ArgName3;ArgType4 m_##ArgName4;ArgType5 m_##ArgName5;ArgType6 m_##ArgName6;
#define DECLARE_OVERLAPPED_SESSION_CALL_6( XCallNameFN_T, ArgType1, ArgName1, ArgType2, ArgName2, ArgType3, ArgName3, ArgType4, ArgName4, ArgType5, ArgName5, ArgType6, ArgName6 ) \
struct XCallNameFN_T##_OverlappedCall_t : public XSessionCallStack::OverlappedSessionCall { \
XCallNameFN_T##_OverlappedCall_t( HANDLE hSession, \
HELPER_OVERLAPPED_SESSION_CALL_C_6( ArgType1, ArgName1, ArgType2, ArgName2, ArgType3, ArgName3, ArgType4, ArgName4, ArgType5, ArgName5, ArgType6, ArgName6 ) \
PXOVERLAPPED pxOverlapped ) : \
XSessionCallStack::OverlappedSessionCall( hSession, pxOverlapped ) \
HELPER_OVERLAPPED_SESSION_CALL_A_6( ArgType1, ArgName1, ArgType2, ArgName2, ArgType3, ArgName3, ArgType4, ArgName4, ArgType5, ArgName5, ArgType6, ArgName6 ) {} \
virtual char const * Name() { return #XCallNameFN_T; } \
virtual DWORD Run() { \
DWORD ret = ::XCallNameFN_T( m_hSession, \
HELPER_OVERLAPPED_SESSION_CALL_P_6( ArgType1, ArgName1, ArgType2, ArgName2, ArgType3, ArgName3, ArgType4, ArgName4, ArgType5, ArgName5, ArgType6, ArgName6 ) \
m_pxOverlapped ? &m_xOverlapped : NULL ); \
if ( ret != ERROR_SUCCESS && ret != ERROR_IO_PENDING ) { Warning( "XCall " #XCallNameFN_T " failed ( ret = %d, overlapped = %p )!\n", ret, m_pxOverlapped ); Assert( 0 ); } \
return ret; } \
HELPER_OVERLAPPED_SESSION_CALL_M_6( ArgType1, ArgName1, ArgType2, ArgName2, ArgType3, ArgName3, ArgType4, ArgName4, ArgType5, ArgName5, ArgType6, ArgName6 ) \
};
#define IMPLEMENT_OVERLAPPED_SESSION_CALL_6( XCallNameFN_T, ArgType1, ArgName1, ArgType2, ArgName2, ArgType3, ArgName3, ArgType4, ArgName4, ArgType5, ArgName5, ArgType6, ArgName6 ) \
DECLARE_OVERLAPPED_SESSION_CALL_6( XCallNameFN_T, ArgType1, ArgName1, ArgType2, ArgName2, ArgType3, ArgName3, ArgType4, ArgName4, ArgType5, ArgName5, ArgType6, ArgName6 ) \
virtual DWORD XCallNameFN_T( HANDLE hSession, \
HELPER_OVERLAPPED_SESSION_CALL_C_6( ArgType1, ArgName1, ArgType2, ArgName2, ArgType3, ArgName3, ArgType4, ArgName4, ArgType5, ArgName5, ArgType6, ArgName6 ) \
PXOVERLAPPED pxOverlapped ) { \
return g_XSessionCallStack.ScheduleOverlappedSessionCall( new XCallNameFN_T##_OverlappedCall_t( hSession, \
HELPER_OVERLAPPED_SESSION_CALL_I_6( ArgType1, ArgName1, ArgType2, ArgName2, ArgType3, ArgName3, ArgType4, ArgName4, ArgType5, ArgName5, ArgType6, ArgName6 ) \
pxOverlapped ) ); \
};
#define HELPER_OVERLAPPED_SESSION_CALL_C_7( ArgType1, ArgName1, ArgType2, ArgName2, ArgType3, ArgName3, ArgType4, ArgName4, ArgType5, ArgName5, ArgType6, ArgName6, ArgType7, ArgName7 ) ArgType1 ArgName1, ArgType2 ArgName2, ArgType3 ArgName3, ArgType4 ArgName4, ArgType5 ArgName5, ArgType6 ArgName6, ArgType7 ArgName7,
#define HELPER_OVERLAPPED_SESSION_CALL_A_7( ArgType1, ArgName1, ArgType2, ArgName2, ArgType3, ArgName3, ArgType4, ArgName4, ArgType5, ArgName5, ArgType6, ArgName6, ArgType7, ArgName7 ) , m_##ArgName1( ArgName1 ), m_##ArgName2( ArgName2 ), m_##ArgName3( ArgName3 ), m_##ArgName4( ArgName4 ), m_##ArgName5( ArgName5 ), m_##ArgName6( ArgName6 ), m_##ArgName7( ArgName7 )
#define HELPER_OVERLAPPED_SESSION_CALL_P_7( ArgType1, ArgName1, ArgType2, ArgName2, ArgType3, ArgName3, ArgType4, ArgName4, ArgType5, ArgName5, ArgType6, ArgName6, ArgType7, ArgName7 ) m_##ArgName1, m_##ArgName2, m_##ArgName3, m_##ArgName4, m_##ArgName5, m_##ArgName6, m_##ArgName7,
#define HELPER_OVERLAPPED_SESSION_CALL_I_7( ArgType1, ArgName1, ArgType2, ArgName2, ArgType3, ArgName3, ArgType4, ArgName4, ArgType5, ArgName5, ArgType6, ArgName6, ArgType7, ArgName7 ) ArgName1, ArgName2, ArgName3, ArgName4, ArgName5, ArgName6, ArgName7,
#define HELPER_OVERLAPPED_SESSION_CALL_M_7( ArgType1, ArgName1, ArgType2, ArgName2, ArgType3, ArgName3, ArgType4, ArgName4, ArgType5, ArgName5, ArgType6, ArgName6, ArgType7, ArgName7 ) ArgType1 m_##ArgName1;ArgType2 m_##ArgName2;ArgType3 m_##ArgName3;ArgType4 m_##ArgName4;ArgType5 m_##ArgName5;ArgType6 m_##ArgName6;ArgType7 m_##ArgName7;
#define DECLARE_OVERLAPPED_SESSION_CALL_7( XCallNameFN_T, ArgType1, ArgName1, ArgType2, ArgName2, ArgType3, ArgName3, ArgType4, ArgName4, ArgType5, ArgName5, ArgType6, ArgName6, ArgType7, ArgName7 ) \
struct XCallNameFN_T##_OverlappedCall_t : public XSessionCallStack::OverlappedSessionCall { \
XCallNameFN_T##_OverlappedCall_t( HANDLE hSession, \
HELPER_OVERLAPPED_SESSION_CALL_C_7( ArgType1, ArgName1, ArgType2, ArgName2, ArgType3, ArgName3, ArgType4, ArgName4, ArgType5, ArgName5, ArgType6, ArgName6, ArgType7, ArgName7 ) \
PXOVERLAPPED pxOverlapped ) : \
XSessionCallStack::OverlappedSessionCall( hSession, pxOverlapped ) \
HELPER_OVERLAPPED_SESSION_CALL_A_7( ArgType1, ArgName1, ArgType2, ArgName2, ArgType3, ArgName3, ArgType4, ArgName4, ArgType5, ArgName5, ArgType6, ArgName6, ArgType7, ArgName7 ) {} \
virtual char const * Name() { return #XCallNameFN_T; } \
virtual DWORD Run() { \
DWORD ret = ::XCallNameFN_T( m_hSession, \
HELPER_OVERLAPPED_SESSION_CALL_P_7( ArgType1, ArgName1, ArgType2, ArgName2, ArgType3, ArgName3, ArgType4, ArgName4, ArgType5, ArgName5, ArgType6, ArgName6, ArgType7, ArgName7 ) \
m_pxOverlapped ? &m_xOverlapped : NULL ); \
if ( ret != ERROR_SUCCESS && ret != ERROR_IO_PENDING ) { Warning( "XCall " #XCallNameFN_T " failed ( ret = %d, overlapped = %p )!\n", ret, m_pxOverlapped ); Assert( 0 ); } \
return ret; } \
HELPER_OVERLAPPED_SESSION_CALL_M_7( ArgType1, ArgName1, ArgType2, ArgName2, ArgType3, ArgName3, ArgType4, ArgName4, ArgType5, ArgName5, ArgType6, ArgName6, ArgType7, ArgName7 ) \
};
#define IMPLEMENT_OVERLAPPED_SESSION_CALL_7( XCallNameFN_T, ArgType1, ArgName1, ArgType2, ArgName2, ArgType3, ArgName3, ArgType4, ArgName4, ArgType5, ArgName5, ArgType6, ArgName6, ArgType7, ArgName7 ) \
DECLARE_OVERLAPPED_SESSION_CALL_7( XCallNameFN_T, ArgType1, ArgName1, ArgType2, ArgName2, ArgType3, ArgName3, ArgType4, ArgName4, ArgType5, ArgName5, ArgType6, ArgName6, ArgType7, ArgName7 ) \
virtual DWORD XCallNameFN_T( HANDLE hSession, \
HELPER_OVERLAPPED_SESSION_CALL_C_7( ArgType1, ArgName1, ArgType2, ArgName2, ArgType3, ArgName3, ArgType4, ArgName4, ArgType5, ArgName5, ArgType6, ArgName6, ArgType7, ArgName7 ) \
PXOVERLAPPED pxOverlapped ) { \
return g_XSessionCallStack.ScheduleOverlappedSessionCall( new XCallNameFN_T##_OverlappedCall_t( hSession, \
HELPER_OVERLAPPED_SESSION_CALL_I_7( ArgType1, ArgName1, ArgType2, ArgName2, ArgType3, ArgName3, ArgType4, ArgName4, ArgType5, ArgName5, ArgType6, ArgName6, ArgType7, ArgName7 ) \
pxOverlapped ) ); \
};
#define HELPER_OVERLAPPED_SESSION_CALL_C_8( ArgType1, ArgName1, ArgType2, ArgName2, ArgType3, ArgName3, ArgType4, ArgName4, ArgType5, ArgName5, ArgType6, ArgName6, ArgType7, ArgName7, ArgType8, ArgName8 ) ArgType1 ArgName1, ArgType2 ArgName2, ArgType3 ArgName3, ArgType4 ArgName4, ArgType5 ArgName5, ArgType6 ArgName6, ArgType7 ArgName7, ArgType8 ArgName8,
#define HELPER_OVERLAPPED_SESSION_CALL_A_8( ArgType1, ArgName1, ArgType2, ArgName2, ArgType3, ArgName3, ArgType4, ArgName4, ArgType5, ArgName5, ArgType6, ArgName6, ArgType7, ArgName7, ArgType8, ArgName8 ) , m_##ArgName1( ArgName1 ), m_##ArgName2( ArgName2 ), m_##ArgName3( ArgName3 ), m_##ArgName4( ArgName4 ), m_##ArgName5( ArgName5 ), m_##ArgName6( ArgName6 ), m_##ArgName7( ArgName7 ), m_##ArgName8( ArgName8 )
#define HELPER_OVERLAPPED_SESSION_CALL_P_8( ArgType1, ArgName1, ArgType2, ArgName2, ArgType3, ArgName3, ArgType4, ArgName4, ArgType5, ArgName5, ArgType6, ArgName6, ArgType7, ArgName7, ArgType8, ArgName8 ) m_##ArgName1, m_##ArgName2, m_##ArgName3, m_##ArgName4, m_##ArgName5, m_##ArgName6, m_##ArgName7, m_##ArgName8,
#define HELPER_OVERLAPPED_SESSION_CALL_I_8( ArgType1, ArgName1, ArgType2, ArgName2, ArgType3, ArgName3, ArgType4, ArgName4, ArgType5, ArgName5, ArgType6, ArgName6, ArgType7, ArgName7, ArgType8, ArgName8 ) ArgName1, ArgName2, ArgName3, ArgName4, ArgName5, ArgName6, ArgName7, ArgName8,
#define HELPER_OVERLAPPED_SESSION_CALL_M_8( ArgType1, ArgName1, ArgType2, ArgName2, ArgType3, ArgName3, ArgType4, ArgName4, ArgType5, ArgName5, ArgType6, ArgName6, ArgType7, ArgName7, ArgType8, ArgName8 ) ArgType1 m_##ArgName1;ArgType2 m_##ArgName2;ArgType3 m_##ArgName3;ArgType4 m_##ArgName4;ArgType5 m_##ArgName5;ArgType6 m_##ArgName6;ArgType7 m_##ArgName7;ArgType8 m_##ArgName8;
#define DECLARE_OVERLAPPED_SESSION_CALL_8( XCallNameFN_T, ArgType1, ArgName1, ArgType2, ArgName2, ArgType3, ArgName3, ArgType4, ArgName4, ArgType5, ArgName5, ArgType6, ArgName6, ArgType7, ArgName7, ArgType8, ArgName8 ) \
struct XCallNameFN_T##_OverlappedCall_t : public XSessionCallStack::OverlappedSessionCall { \
XCallNameFN_T##_OverlappedCall_t( HANDLE hSession, \
HELPER_OVERLAPPED_SESSION_CALL_C_8( ArgType1, ArgName1, ArgType2, ArgName2, ArgType3, ArgName3, ArgType4, ArgName4, ArgType5, ArgName5, ArgType6, ArgName6, ArgType7, ArgName7, ArgType8, ArgName8 ) \
PXOVERLAPPED pxOverlapped ) : \
XSessionCallStack::OverlappedSessionCall( hSession, pxOverlapped ) \
HELPER_OVERLAPPED_SESSION_CALL_A_8( ArgType1, ArgName1, ArgType2, ArgName2, ArgType3, ArgName3, ArgType4, ArgName4, ArgType5, ArgName5, ArgType6, ArgName6, ArgType7, ArgName7, ArgType8, ArgName8 ) {} \
virtual char const * Name() { return #XCallNameFN_T; } \
virtual DWORD Run() { \
DWORD ret = ::XCallNameFN_T( m_hSession, \
HELPER_OVERLAPPED_SESSION_CALL_P_8( ArgType1, ArgName1, ArgType2, ArgName2, ArgType3, ArgName3, ArgType4, ArgName4, ArgType5, ArgName5, ArgType6, ArgName6, ArgType7, ArgName7, ArgType8, ArgName8 ) \
m_pxOverlapped ? &m_xOverlapped : NULL ); \
if ( ret != ERROR_SUCCESS && ret != ERROR_IO_PENDING ) { Warning( "XCall " #XCallNameFN_T " failed ( ret = %d, overlapped = %p )!\n", ret, m_pxOverlapped ); Assert( 0 ); } \
return ret; } \
HELPER_OVERLAPPED_SESSION_CALL_M_8( ArgType1, ArgName1, ArgType2, ArgName2, ArgType3, ArgName3, ArgType4, ArgName4, ArgType5, ArgName5, ArgType6, ArgName6, ArgType7, ArgName7, ArgType8, ArgName8 ) \
};
#define IMPLEMENT_OVERLAPPED_SESSION_CALL_8( XCallNameFN_T, ArgType1, ArgName1, ArgType2, ArgName2, ArgType3, ArgName3, ArgType4, ArgName4, ArgType5, ArgName5, ArgType6, ArgName6, ArgType7, ArgName7, ArgType8, ArgName8 ) \
DECLARE_OVERLAPPED_SESSION_CALL_8( XCallNameFN_T, ArgType1, ArgName1, ArgType2, ArgName2, ArgType3, ArgName3, ArgType4, ArgName4, ArgType5, ArgName5, ArgType6, ArgName6, ArgType7, ArgName7, ArgType8, ArgName8 ) \
virtual DWORD XCallNameFN_T( HANDLE hSession, \
HELPER_OVERLAPPED_SESSION_CALL_C_8( ArgType1, ArgName1, ArgType2, ArgName2, ArgType3, ArgName3, ArgType4, ArgName4, ArgType5, ArgName5, ArgType6, ArgName6, ArgType7, ArgName7, ArgType8, ArgName8 ) \
PXOVERLAPPED pxOverlapped ) { \
return g_XSessionCallStack.ScheduleOverlappedSessionCall( new XCallNameFN_T##_OverlappedCall_t( hSession, \
HELPER_OVERLAPPED_SESSION_CALL_I_8( ArgType1, ArgName1, ArgType2, ArgName2, ArgType3, ArgName3, ArgType4, ArgName4, ArgType5, ArgName5, ArgType6, ArgName6, ArgType7, ArgName7, ArgType8, ArgName8 ) \
pxOverlapped ) ); \
};
#define HELPER_OVERLAPPED_SESSION_CALL_C_9( ArgType1, ArgName1, ArgType2, ArgName2, ArgType3, ArgName3, ArgType4, ArgName4, ArgType5, ArgName5, ArgType6, ArgName6, ArgType7, ArgName7, ArgType8, ArgName8, ArgType9, ArgName9 ) ArgType1 ArgName1, ArgType2 ArgName2, ArgType3 ArgName3, ArgType4 ArgName4, ArgType5 ArgName5, ArgType6 ArgName6, ArgType7 ArgName7, ArgType8 ArgName8, ArgType9 ArgName9,
#define HELPER_OVERLAPPED_SESSION_CALL_A_9( ArgType1, ArgName1, ArgType2, ArgName2, ArgType3, ArgName3, ArgType4, ArgName4, ArgType5, ArgName5, ArgType6, ArgName6, ArgType7, ArgName7, ArgType8, ArgName8, ArgType9, ArgName9 ) , m_##ArgName1( ArgName1 ), m_##ArgName2( ArgName2 ), m_##ArgName3( ArgName3 ), m_##ArgName4( ArgName4 ), m_##ArgName5( ArgName5 ), m_##ArgName6( ArgName6 ), m_##ArgName7( ArgName7 ), m_##ArgName8( ArgName8 ), m_##ArgName9( ArgName9 )
#define HELPER_OVERLAPPED_SESSION_CALL_P_9( ArgType1, ArgName1, ArgType2, ArgName2, ArgType3, ArgName3, ArgType4, ArgName4, ArgType5, ArgName5, ArgType6, ArgName6, ArgType7, ArgName7, ArgType8, ArgName8, ArgType9, ArgName9 ) m_##ArgName1, m_##ArgName2, m_##ArgName3, m_##ArgName4, m_##ArgName5, m_##ArgName6, m_##ArgName7, m_##ArgName8, m_##ArgName9,
#define HELPER_OVERLAPPED_SESSION_CALL_I_9( ArgType1, ArgName1, ArgType2, ArgName2, ArgType3, ArgName3, ArgType4, ArgName4, ArgType5, ArgName5, ArgType6, ArgName6, ArgType7, ArgName7, ArgType8, ArgName8, ArgType9, ArgName9 ) ArgName1, ArgName2, ArgName3, ArgName4, ArgName5, ArgName6, ArgName7, ArgName8, ArgName9,
#define HELPER_OVERLAPPED_SESSION_CALL_M_9( ArgType1, ArgName1, ArgType2, ArgName2, ArgType3, ArgName3, ArgType4, ArgName4, ArgType5, ArgName5, ArgType6, ArgName6, ArgType7, ArgName7, ArgType8, ArgName8, ArgType9, ArgName9 ) ArgType1 m_##ArgName1;ArgType2 m_##ArgName2;ArgType3 m_##ArgName3;ArgType4 m_##ArgName4;ArgType5 m_##ArgName5;ArgType6 m_##ArgName6;ArgType7 m_##ArgName7;ArgType8 m_##ArgName8;ArgType9 m_##ArgName9;
#define DECLARE_OVERLAPPED_SESSION_CALL_9( XCallNameFN_T, ArgType1, ArgName1, ArgType2, ArgName2, ArgType3, ArgName3, ArgType4, ArgName4, ArgType5, ArgName5, ArgType6, ArgName6, ArgType7, ArgName7, ArgType8, ArgName8, ArgType9, ArgName9 ) \
struct XCallNameFN_T##_OverlappedCall_t : public XSessionCallStack::OverlappedSessionCall { \
XCallNameFN_T##_OverlappedCall_t( HANDLE hSession, \
HELPER_OVERLAPPED_SESSION_CALL_C_9( ArgType1, ArgName1, ArgType2, ArgName2, ArgType3, ArgName3, ArgType4, ArgName4, ArgType5, ArgName5, ArgType6, ArgName6, ArgType7, ArgName7, ArgType8, ArgName8, ArgType9, ArgName9 ) \
PXOVERLAPPED pxOverlapped ) : \
XSessionCallStack::OverlappedSessionCall( hSession, pxOverlapped ) \
HELPER_OVERLAPPED_SESSION_CALL_A_9( ArgType1, ArgName1, ArgType2, ArgName2, ArgType3, ArgName3, ArgType4, ArgName4, ArgType5, ArgName5, ArgType6, ArgName6, ArgType7, ArgName7, ArgType8, ArgName8, ArgType9, ArgName9 ) {} \
virtual char const * Name() { return #XCallNameFN_T; } \
virtual DWORD Run() { \
DWORD ret = ::XCallNameFN_T( m_hSession, \
HELPER_OVERLAPPED_SESSION_CALL_P_9( ArgType1, ArgName1, ArgType2, ArgName2, ArgType3, ArgName3, ArgType4, ArgName4, ArgType5, ArgName5, ArgType6, ArgName6, ArgType7, ArgName7, ArgType8, ArgName8, ArgType9, ArgName9 ) \
m_pxOverlapped ? &m_xOverlapped : NULL ); \
if ( ret != ERROR_SUCCESS && ret != ERROR_IO_PENDING ) { Warning( "XCall " #XCallNameFN_T " failed ( ret = %d, overlapped = %p )!\n", ret, m_pxOverlapped ); Assert( 0 ); } \
return ret; } \
HELPER_OVERLAPPED_SESSION_CALL_M_9( ArgType1, ArgName1, ArgType2, ArgName2, ArgType3, ArgName3, ArgType4, ArgName4, ArgType5, ArgName5, ArgType6, ArgName6, ArgType7, ArgName7, ArgType8, ArgName8, ArgType9, ArgName9 ) \
};
#define IMPLEMENT_OVERLAPPED_SESSION_CALL_9( XCallNameFN_T, ArgType1, ArgName1, ArgType2, ArgName2, ArgType3, ArgName3, ArgType4, ArgName4, ArgType5, ArgName5, ArgType6, ArgName6, ArgType7, ArgName7, ArgType8, ArgName8, ArgType9, ArgName9 ) \
DECLARE_OVERLAPPED_SESSION_CALL_9( XCallNameFN_T, ArgType1, ArgName1, ArgType2, ArgName2, ArgType3, ArgName3, ArgType4, ArgName4, ArgType5, ArgName5, ArgType6, ArgName6, ArgType7, ArgName7, ArgType8, ArgName8, ArgType9, ArgName9 ) \
virtual DWORD XCallNameFN_T( HANDLE hSession, \
HELPER_OVERLAPPED_SESSION_CALL_C_9( ArgType1, ArgName1, ArgType2, ArgName2, ArgType3, ArgName3, ArgType4, ArgName4, ArgType5, ArgName5, ArgType6, ArgName6, ArgType7, ArgName7, ArgType8, ArgName8, ArgType9, ArgName9 ) \
PXOVERLAPPED pxOverlapped ) { \
return g_XSessionCallStack.ScheduleOverlappedSessionCall( new XCallNameFN_T##_OverlappedCall_t( hSession, \
HELPER_OVERLAPPED_SESSION_CALL_I_9( ArgType1, ArgName1, ArgType2, ArgName2, ArgType3, ArgName3, ArgType4, ArgName4, ArgType5, ArgName5, ArgType6, ArgName6, ArgType7, ArgName7, ArgType8, ArgName8, ArgType9, ArgName9 ) \
pxOverlapped ) ); \
};
| 90.361823
| 459
| 0.784437
|
DannyParker0001
|
39e32bb345f24ec8e744b243f14681b715305457
| 7,905
|
cpp
|
C++
|
Source/AllProjects/Tests/TestCIDLib/TestCIDLib_PerThreadData.cpp
|
eudora-jia/CIDLib
|
02795d283d95f8a5a4fafa401b6189851901b81b
|
[
"MIT"
] | 1
|
2019-05-28T06:33:01.000Z
|
2019-05-28T06:33:01.000Z
|
Source/AllProjects/Tests/TestCIDLib/TestCIDLib_PerThreadData.cpp
|
eudora-jia/CIDLib
|
02795d283d95f8a5a4fafa401b6189851901b81b
|
[
"MIT"
] | null | null | null |
Source/AllProjects/Tests/TestCIDLib/TestCIDLib_PerThreadData.cpp
|
eudora-jia/CIDLib
|
02795d283d95f8a5a4fafa401b6189851901b81b
|
[
"MIT"
] | null | null | null |
//
// FILE NAME: TestCIDLib_PerThreadData.cpp
//
// AUTHOR: Dean Roddey
//
// CREATED: 01/29/1998
//
// COPYRIGHT: Charmed Quark Systems, Ltd @ 2019
//
// This file is part of a demonstration program of the CIDLib C++
// Frameworks. Its contents are distributed 'as is', to provide guidance on
// the use of the CIDLib system. However, these demos are not intended to
// represent a full fledged applications. Any direct use of demo code in
// user applications is at the user's discretion, and no warranties are
// implied as to its correctness or applicability.
//
// DESCRIPTION:
//
// This module is part of the TestCIDLib.Exe program and is called from the
// program's main() function. The functions in this module test the
// per-thread data support.
//
// CAVEATS/GOTCHAS:
//
// LOG:
//
// $_CIDLib_Log_$
//
// -----------------------------------------------------------------------------
// Facility specific includes
// -----------------------------------------------------------------------------
#include "TestCIDLib.hpp"
// -----------------------------------------------------------------------------
// Local static data
//
// ptdArea
// ptdPoint
// ptdString
// Some per-thread data objects for areas, points, and strings. These are
// used in the testing below.
// -----------------------------------------------------------------------------
#if 0
static TPerThreadDataFor<TArea> ptdArea;
static TPerThreadDataFor<TPoint> ptdPoint;
static TPerThreadDataFor<TString> ptdString;
// -----------------------------------------------------------------------------
// TFacTestCIDLib: Local, static methods
// -----------------------------------------------------------------------------
static tCIDLib::TVoid CommonTests()
{
// Get a short cut to the output stream
TTextOutStream& strmOut = TFacTestCIDLib::strmOut();
//
// Check each of the objects and make sure that the initial values
// in them are initialized correct to zero.
//
if (ptdArea.pobjThis())
strmOut << CUR_LN << L"Area per-thread not initialized to zero" << kCIDLib::EndLn;
if (ptdPoint.pobjThis())
strmOut << CUR_LN << L"Point per-thread not initialized to zero" << kCIDLib::EndLn;
if (ptdString.pobjThis())
strmOut << CUR_LN << L"String per-thread not initialized to zero" << kCIDLib::EndLn;
//
// Set each one with an allocated object, then read the object back out
// and test that its the original object.
//
TArea* pareaSet = new TArea(1,2,3,4);
ptdArea.pobjThis(pareaSet);
TPoint* ppntSet = new TPoint(1,2);
ptdPoint.pobjThis(ppntSet);
TString* pstrSet = new TString(L"This is a test");
ptdString.pobjThis(pstrSet);
if (pareaSet != ptdArea.pobjThis())
strmOut << CUR_LN << L"Area object != to object set" << kCIDLib::EndLn;
if (ppntSet != ptdPoint.pobjThis())
strmOut << CUR_LN << L"Point object != to object set" << kCIDLib::EndLn;
if (pstrSet != ptdString.pobjThis())
strmOut << CUR_LN << L"String object != to object set" << kCIDLib::EndLn;
if (ptdArea.objThis() != TArea(1,2,3,4))
strmOut << CUR_LN << L"Area object value != to object set" << kCIDLib::EndLn;
if (ptdPoint.objThis() != TPoint(1,2))
strmOut << CUR_LN << L"Point object value != to object set" << kCIDLib::EndLn;
if (ptdString.objThis() != TString(L"This is a test"))
strmOut << CUR_LN << L"String object value != to object set" << kCIDLib::EndLn;
//
// Test out the dereference operator, which gets out the object pointer
// such that its convenient to access the methods of the object.
//
if (ptdArea->i4Left() != 1)
strmOut << CUR_LN << L"Deref access to area object failed" << kCIDLib::EndLn;
if (ptdPoint->i4Y() != 2)
strmOut << CUR_LN << L"Deref access to point object failed" << kCIDLib::EndLn;
if (ptdString->chAt(0) != L'T')
strmOut << CUR_LN << L"Deref access to string object failed" << kCIDLib::EndLn;
}
static tCIDLib::EExitCodes eTestFunc(TThread& thrThis, tCIDLib::TVoid* pData)
{
// We have to let our calling thread go first
thrThis.Sync();
// Get a short cut to the output stream
TTextOutStream& strmOut = TFacTestCIDLib::strmOut();
// Get started by doing the common tests
CommonTests();
//
// Loop around for a while and manipulate our copy of the data. Check
// each change to insure that it hasn't been stepped on by another
// thread.
//
for (tCIDLib::TCard4 c4LoopCnt = 0; c4LoopCnt < 256; c4LoopCnt++)
{
//
// Set the point to the loop count. Set the area size to the
// loop count. And set the string to the formatted loop count.
//
ptdArea->SetSize(c4LoopCnt, c4LoopCnt);
ptdPoint->i4X(tCIDLib::TInt4(c4LoopCnt));
ptdString.objThis() = TCardinal(c4LoopCnt);
TThread::Sleep(25);
// Check that the values are correct before doing the next loop
if (ptdArea->szSize() != TSize(c4LoopCnt))
strmOut << CUR_LN << L"Thread's area value change not correct" << kCIDLib::EndLn;
if (ptdPoint->i4X() != tCIDLib::TInt4(c4LoopCnt))
strmOut << CUR_LN << L"Thread's point value change not correct" << kCIDLib::EndLn;
if (ptdString.objThis() != TString(TCardinal(c4LoopCnt)))
strmOut << CUR_LN << L"Thread's string value change not correct" << kCIDLib::EndLn;
}
//
// We don't delete the objects for each thread. They should be deleted
// when this thread ends!
//
return tCIDLib::EExitCodes::Normal;
}
static tCIDLib::TVoid SimpleTests()
{
// Get a short cut to the output stream
TTextOutStream& strmOut = TFacTestCIDLib::strmOut();
// Call the common test function
CommonTests();
//
// Delete the objects and set the pointers back to zero so that it will
// work on the next pass if a memory leak pass is done.
//
ptdArea.CleanUpUserData();
ptdPoint.CleanUpUserData();
ptdString.CleanUpUserData();
}
static tCIDLib::TVoid ThreadedTests()
{
// Get a short cut to the output stream
TTextOutStream& strmOut = TFacTestCIDLib::strmOut();
// Kick off a set of threads and wait for all of them to die
const tCIDLib::TCard4 c4ThreadCount = 16;
TThread* apthrList[c4ThreadCount];
// Use a unique name object to create the thread names
TUniqueName unamThreads(L"PerThread%(1)");
tCIDLib::TCard4 c4Index;
for (c4Index = 0; c4Index < c4ThreadCount; c4Index++)
{
apthrList[c4Index] = new TThread
(
unamThreads.strQueryNewName()
, eTestFunc
);
}
// Kick off the threads
for (c4Index = 0; c4Index < c4ThreadCount; c4Index++)
apthrList[c4Index]->Start();
// And wait for all of them to die
for (c4Index = 0; c4Index < c4ThreadCount; c4Index++)
{
apthrList[c4Index]->eWaitForDeath();
delete apthrList[c4Index];
}
}
#endif
// -----------------------------------------------------------------------------
// TFacTestCIDLib: Public, non-virtual methods
// -----------------------------------------------------------------------------
//
// This method calls a number of local functions that test various
// instantiations of the per-thread data classes.
//
tCIDLib::TVoid TFacTestCIDLib::TestPerThreadData()
{
const tCIDLib::TCh* pszCurTest = L"None";
try
{
pszCurTest = L"Simple Test";
// SimpleTests();
pszCurTest = L"Threaded Test";
// ThreadedTests();
}
catch(TError& errToCatch)
{
errToCatch.AddStackLevel(CID_FILE, CID_LINE);
strmOut() << L"Exception occured during the " << pszCurTest
<< L" test" << kCIDLib::EndLn;
throw;
}
}
| 31.494024
| 95
| 0.588362
|
eudora-jia
|
39e48bf081d40ec8db3df48831bb390e76566619
| 6,256
|
cpp
|
C++
|
UnitTest/AlgorismTest/vertex_delaunay_test.cpp
|
rocketman123456/RocketEngine
|
ede1670d70c4689a5dc8543ca5351e8f23fcb840
|
[
"Apache-2.0"
] | null | null | null |
UnitTest/AlgorismTest/vertex_delaunay_test.cpp
|
rocketman123456/RocketEngine
|
ede1670d70c4689a5dc8543ca5351e8f23fcb840
|
[
"Apache-2.0"
] | null | null | null |
UnitTest/AlgorismTest/vertex_delaunay_test.cpp
|
rocketman123456/RocketEngine
|
ede1670d70c4689a5dc8543ca5351e8f23fcb840
|
[
"Apache-2.0"
] | null | null | null |
#include "Log/Log.h"
#include "Window/DesktopWindow.h"
#include "Render/SoftRasterizer.h"
#include "Render/SoftTriangle.h"
#include "Geometry/Vertex.h"
#include "Geometry/Triangle.h"
#include "Geometry/Sphere.h"
#include "Geometry/Tetrahedra.h"
#include "Geometry/MeshOperation/Delaunay3D.h"
using namespace Rocket;
#include <GLFW/glfw3.h>
#include <glad/glad.h>
#include <iostream>
#include <iomanip>
#include <random>
#include "../Utils/soft_render.h"
static std::mt19937 generator(0);
static std::uniform_real_distribution<> range_distribute(0.0, 1.0);
static std::vector<Geometry::VertexPtr> nodes;
static Geometry::SpherePtr sphere;
static Geometry::TetrahedraPtr tetrahedra;
static Delaunay3DPtr delaunay_3d;
double random(double a = 0.0, double b = 1.0) {
return range_distribute(generator) * (b-a) + a;
}
void VertexSphereTest() {
int32_t count = 0;
while(count <= 0) {
std::cout << "Input node count:";
std::cin >> count;
}
double radius = 1.0;
for(int i = 0; i < count; i++) {
double t1 = random(-3.14/2.0,3.14/2.0);
double t2 = random(0,3.14*2.0);
double x = radius * sin(t1) * sin(t2);
double y = radius * sin(t1) * cos(t2);
double z = radius * cos(t1);
//nodes.push_back(VertexPtr(new Vertex(Eigen::Vector3d(x, y, z))));
nodes.push_back(Geometry::VertexPtr(new Geometry::Vertex(Eigen::Vector3d(random(-1,1), random(-1,1), random(-1,1)))));
}
sphere = Geometry::SpherePtr(new Geometry::Sphere());
sphere->CreateBoundingSphere(nodes);
std::cout << "Sphere Center: "
<< sphere->center[0] << ","
<< sphere->center[1] << ","
<< sphere->center[2] << std::endl;
std::cout << "Sphere Radius: " << sphere->radius << std::endl;
tetrahedra = Geometry::TetrahedraPtr(new Geometry::Tetrahedra());
tetrahedra->CreateBoundingTetrahedra(
sphere,
Eigen::Vector3d(0,0,1),
Eigen::Vector3d(1,0,0),
Eigen::Vector3d(0,1,0)
);
delaunay_3d = Delaunay3DPtr(new Delaunay3D());
delaunay_3d->method = 1;
delaunay_3d->Initialize(nodes);
}
int main(int argc, char** argv) {
//Log::Init();
RenderApp app;
// load image, create texture and generate mipmaps
int32_t width = 1280;
int32_t height = 720;
int32_t nrChannels = 4;
app.Initialize(width, height);
SoftRasterizer rst(width, height);
rst.ClearAll(BufferType::COLOR | BufferType::DEPTH);
Eigen::Vector3f eye_pos = {0.0, 0.0, 5};
int32_t key = 0;
int32_t frame_count = 0;
//rst.DisableWireFrame();
rst.EnableWireFrame();
rst.EnableMsaa();
rst.SetMsaaLevel(0);
VertexSphereTest();
while(!app.ShouldClose()) {
app.Tick();
rst.NextFrame();
rst.Clear(BufferType::COLOR | BufferType::DEPTH);
rst.SetModel(get_model_matrix(global_angle_x, global_angle_y, global_angle_z));
//rst.SetModel(get_model_matrix(global_angle_y, global_angle_z));
//rst.SetModel(get_model_matrix(global_angle_z));
rst.SetView(get_view_matrix(eye_pos));
rst.SetProjection(get_perspective_matrix(45, ((float)width/(float)height), 0.1, 50));
//rst.SetProjection(get_orthographic_matrix(-6.4, 6.4, -50, 50, 3.6, -3.6));
rst.DrawLine3D({0,0,0}, {1,0,0}, {255,0,0}, {255,0,0}); // x
rst.DrawLine3D({0,0,0}, {0,1,0}, {0,255,0}, {0,255,0}); // y
rst.DrawLine3D({0,0,0}, {0,0,1}, {0,0,255}, {0,0,255}); // z
//rst.DrawLine3D({0.5,0.5,0}, {0.5,0.5,2}, {255,0,0}, {0,255,0});
rst.DrawPoint3D({1,1,0}, {255,0,0});
for(auto& node : delaunay_3d->GetNodes()) {
rst.DrawPoint3D(Eigen::Vector3f(node->position[0], node->position[1], node->position[2]));
}
std::vector<Geometry::TetrahedraPtr>& meshs = delaunay_3d->GetResultTetrahedras();
// for(TetrahedraPtr& mesh : meshs) {
// mesh->UpdateFaces();
// std::array<TrianglePtr, 4>& faces = mesh->faces;
// for(TrianglePtr& face : faces) {
// std::array<EdgePtr, 3>& edges = face->edges;
// for(EdgePtr& edge : edges) {
// rst.DrawLine3D(
// Eigen::Vector3f(edge->start->position[0], edge->start->position[1], edge->start->position[2]),
// Eigen::Vector3f(edge->end->position[0], edge->end->position[1], edge->end->position[2]),
// Eigen::Vector3f(255,0,0),
// Eigen::Vector3f(0,0,255)
// );
// }
// }
// }
static int32_t current = 0;
if(meshs.size() > 0) {
current++;
current = current % meshs.size();
auto mesh = meshs[current];
mesh->UpdateFaces();
std::array<Geometry::TrianglePtr, 4>& faces = mesh->faces;
for(Geometry::TrianglePtr& face : faces) {
std::array<Geometry::EdgePtr, 3>& edges = face->edges;
for(Geometry::EdgePtr& edge : edges) {
rst.DrawLine3D(
Eigen::Vector3f(edge->start->position[0], edge->start->position[1], edge->start->position[2]),
Eigen::Vector3f(edge->end->position[0], edge->end->position[1], edge->end->position[2]),
Eigen::Vector3f(255,0,0),
Eigen::Vector3f(0,0,255)
);
}
}
}
// auto& faces = tetrahedra.faces;
// for(auto face : faces) {
// auto& edges = face.edges;
// for(auto edge : edges) {
// rst.DrawLine3D(
// Eigen::Vector3f(edge.first.position[0], edge.first.position[1], edge.first.position[2]),
// Eigen::Vector3f(edge.second.position[0], edge.second.position[1], edge.second.position[2]),
// Eigen::Vector3f(255,0,0),
// Eigen::Vector3f(0,0,255)
// );
// }
// }
auto data = rst.FrameBuffer().data();
app.Render(data);
}
app.Finalize();
//Log::End();
return 0;
}
| 34
| 126
| 0.556426
|
rocketman123456
|
39e8a1fa6ba2d3f047d0316b7bd2a087c6c90956
| 15,548
|
cpp
|
C++
|
example/UIToolkitTest/mainwindow.cpp
|
fast01/chaosframework
|
28194bcca5f976fd5cf61448ca84ce545e94d822
|
[
"Apache-2.0"
] | 2
|
2020-04-16T13:20:57.000Z
|
2021-06-24T02:05:25.000Z
|
example/UIToolkitTest/mainwindow.cpp
|
fast01/chaosframework
|
28194bcca5f976fd5cf61448ca84ce545e94d822
|
[
"Apache-2.0"
] | null | null | null |
example/UIToolkitTest/mainwindow.cpp
|
fast01/chaosframework
|
28194bcca5f976fd5cf61448ca84ce545e94d822
|
[
"Apache-2.0"
] | null | null | null |
/*
* MainWindow.cpp
* !CHOAS
* Created by Bisegni Claudio.
*
* Copyright 2012 INFN, National Institute of Nuclear Physics
*
* 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 <QtGui>
#if ( QT_VERSION < QT_VERSION_CHECK(5, 0, 0) )
#include <QtGui/QApplication>
#else
#include <QtWidgets/QApplication>
#endif
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QDebug>
#include <QMessageBox>
#include <qwt_plot.h>
#include <qwt_plot_curve.h>
#include <cmath>
#include <QVBoxLayout>
#include <QStandardItemModel>
#include <vector>
#include <string>
#ifndef Q_MOC_RUN
#include <chaos/ui_toolkit/LowLevelApi/LLRpcApi.h>
#include <chaos/ui_toolkit/HighLevelApi/HLDataApi.h>
#include <controldialog.h>
#include <boost/shared_ptr.hpp>
#include <boost/thread.hpp>
#endif
#include <qevent.h>
#include <QTableWidgetItem>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow), settings("it.infn", "CHAOS")
{
QSettings settings;
ui->setupUi(this);
readSettings();
QVBoxLayout *gL = new QVBoxLayout();
graphWdg = new GraphWidget();
gL->addWidget(graphWdg, 1);
ui->graphWidget->setLayout(gL);
ui->tableView->setEditTriggers(QAbstractItemView::EditKeyPressed);
ui->listView->setEditTriggers(QAbstractItemView::NoEditTriggers);
//setup mds channel
mdsChannel = chaos::ui::LLRpcApi::getInstance()->getNewMetadataServerChannel();
d_timerId = -1;
lostPack = 0;
checkSequentialIDKey.assign(ui->lineEdit->text().toStdString());
deviceController = NULL;
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_buttonDeleteDevice_clicked(bool checked)
{
qDebug() << "received signal";
}
void MainWindow::on_actionShow_Info_triggered()
{
qDebug() << "Show info";
QMessageBox* msg = new QMessageBox(this);
msg->setText("!CHAOS Technology Test!");
msg->show();
}
void MainWindow::on_splitter_splitterMoved(int pos, int index)
{
settings.setValue("main_window/splitterSizes", ui->splitter->saveState());
}
void MainWindow::closeEvent(QCloseEvent *event)
{
settings.setValue("main_window", saveGeometry());
settings.setValue("main_window", saveState());
cleanLastDevice();
QMainWindow::closeEvent(event);
}
void MainWindow::readSettings()
{
restoreGeometry(settings.value("main_window/geometry").toByteArray());
restoreState(settings.value("main_window/windowState").toByteArray());
ui->splitter->restoreState(settings.value("main_window/splitterSizes").toByteArray());
}
void MainWindow::showContextMenuForWidget(const QPoint &pos) {
QMenu contextMenu(tr("Context menu"), this);
contextMenu.addAction(new QAction(tr("&Hello"), this));
contextMenu.exec(mapToGlobal(pos));
}
void MainWindow::on_buttonUpdateDeviceList_clicked()
{
//update device list
int err = 0;
std::vector<std::string> allActiveDeviceID;
err = mdsChannel->getAllDeviceID(allActiveDeviceID, 2000);
if(err!=0){
QMessageBox* msg = new QMessageBox(this);
msg->setText("Error retriving the devicel list from metadata server");
msg->show();
}
//load the device list
QStandardItemModel *model = new QStandardItemModel(allActiveDeviceID.size(), 1);
model->setHeaderData(0, Qt::Horizontal, QObject::tr("test header"));
int row=0;
for(std::vector<std::string>::iterator iter = allActiveDeviceID.begin();
iter != allActiveDeviceID.end();
iter++){
model->setItem(row++, new QStandardItem(QString((*iter).c_str())));
}
ui->listView->setModel(model);
}
void MainWindow::updateDeviceState() {
if(!deviceController) {
ui->labelState->setText("");
return;
}
chaos::CUStateKey::ControlUnitState currentState;
int err = deviceController->getState(currentState);
switch(err){
case 0:{
switch(currentState){
case chaos::CUStateKey::INIT:
ui->labelState->setText("Initialized");
break;
case chaos::CUStateKey::DEINIT:
ui->labelState->setText("Deinitialized");
break;
case chaos::CUStateKey::START:
ui->labelState->setText("Started");
break;
case chaos::CUStateKey::STOP:
ui->labelState->setText("Stopped");
break;
}
break;
default:
ui->labelState->setText("timeout/offline");
break;
}
}
}
/*
Try to remove the last selected device
*/
void MainWindow::cleanLastDevice() {
if(!deviceController) return;
ui->label_2->setText("");
ui->tableView->setModel(new QStandardItemModel(0, 4));
//stop the possible tracking
stopTracking();
//remove the plot
graphWdg->clearAllPlot();
chaos::ui::HLDataApi::getInstance()->disposeDeviceControllerPtr(deviceController);
}
void MainWindow::on_listView_doubleClicked(const QModelIndex &index)
{
//delete last device that is been controlled
cleanLastDevice();
//deviceController
std::string attributeDescription;
std::vector<string> attributesName;
QString selectedDevice = ui->listView->model()->data(index, Qt::DisplayRole).toString();
ui->label_2->setText(selectedDevice);
std::string dName = selectedDevice.toStdString();
deviceController = chaos::ui::HLDataApi::getInstance()->getControllerForDeviceID(dName);
deviceController->setRequestTimeWaith(4000);
deviceController->setupTracking();
//get only output o attribute
deviceController->getDeviceDatasetAttributesName(attributesName, chaos::DataType::Output);
QStandardItemModel *model = new QStandardItemModel(attributeDescription.size(), 4);
model->setHeaderData(0, Qt::Horizontal, QObject::tr("Name"));
model->setHeaderData(1, Qt::Horizontal, QObject::tr("Direction"));
model->setHeaderData(1, Qt::Horizontal, QObject::tr("Controller"));
model->setHeaderData(3, Qt::Horizontal, QObject::tr("Description"));
int row = 0;
for(std::vector<std::string>::iterator iter = attributesName.begin();
iter != attributesName.end();
iter++){
deviceController->getAttributeDescription((*iter), attributeDescription);
model->setItem(row, 0, new QStandardItem(QString((*iter).c_str())));
model->setItem(row, 1, new QStandardItem("Output"));
model->setItem(row, 2, new QStandardItem(returnAttributeTypeInString(*iter)));
model->setItem(row++, 3, new QStandardItem(QString(attributeDescription.c_str())));
}
//get only input o attribute
attributesName.clear();
//get only output o attribute
deviceController->getDeviceDatasetAttributesName(attributesName, chaos::DataType::Input);
for(std::vector<std::string>::iterator iter = attributesName.begin();
iter != attributesName.end();
iter++){
deviceController->getAttributeDescription((*iter), attributeDescription);
model->setItem(row, 0, new QStandardItem(QString((*iter).c_str())));
model->setItem(row, 1, new QStandardItem("Input"));
model->setItem(row, 2, new QStandardItem(returnAttributeTypeInString(*iter)));
model->setItem(row++, 3, new QStandardItem(QString(attributeDescription.c_str())));
}
ui->tableView->setModel(model);
ui->tableView->setEditTriggers(QAbstractItemView::SelectedClicked);
updateDeviceState();
QHeaderView *header = ui->tableView->horizontalHeader();
header->resizeSections(QHeaderView::Stretch);
}
QString MainWindow::returnAttributeTypeInString(string& attributeName) {
QString result;
chaos::common::data::RangeValueInfo attributeInfo;
deviceController->getDeviceAttributeRangeValueInfo(attributeName, attributeInfo);
switch(attributeInfo.valueType){
case chaos::DataType::TYPE_INT32:
result = "TYPE_INT32";
break;
case chaos::DataType::TYPE_DOUBLE:
result = "TYPE_DOUBLE";
break;
case chaos::DataType::TYPE_BYTEARRAY:
result = "TYPE_BYTEARRAY";
break;
case chaos::DataType::TYPE_INT64:
result = "TYPE_INT64";
break;
case chaos::DataType::TYPE_STRING:
result = "TYPE_STRING";
break;
}
return result;
}
void MainWindow::on_tableView_doubleClicked(const QModelIndex &index)
{
if(index.column() != 0) return;
QString selectedAttribute = ui->tableView->model()->data(index, Qt::DisplayRole).toString();
std::string attributeName = selectedAttribute.toStdString() ;
chaos::common::data::RangeValueInfo rangeInfo;
// check the type of attribute
chaos::DataType::DataSetAttributeIOAttribute direction;
if(deviceController->getDeviceAttributeDirection(attributeName, direction)!=0){
return;
}
if (direction == chaos::DataType::Output || direction == chaos::DataType::Bidirectional){
//output
if(graphWdg->hasPlot(attributeName)){
graphWdg->removePlot(attributeName);
} else {
deviceController->addAttributeToTrack(attributeName);
deviceController->getDeviceAttributeRangeValueInfo(attributeName, rangeInfo);
if(rangeInfo.valueType != chaos::DataType::TYPE_BYTEARRAY){
chaos::DataBuffer *attributeBuffer = deviceController->getBufferForAttribute(attributeName);
if(!attributeBuffer) {
QMessageBox* msg = new QMessageBox(this);
msg->setText("Errore getting buffer for attribute!");
msg->show();
return;
}
graphWdg->addNewPlot(attributeBuffer, attributeName, rangeInfo.valueType);
}else{
chaos::PointerBuffer *pointerBuffer = deviceController->getPtrBufferForAttribute(attributeName);
if(!pointerBuffer) {
QMessageBox* msg = new QMessageBox(this);
msg->setText("Errore getting buffer for attribute!");
msg->show();
return;
}
graphWdg->addNewPlot(pointerBuffer, attributeName, rangeInfo.valueType);
}
}
}
if (direction == chaos::DataType::Input || direction == chaos::DataType::Bidirectional) {
//input attribute
ControlDialog *ctrlDialog = new ControlDialog();
ctrlDialog->initDialog(deviceController, attributeName);
ctrlDialog->show();
}
}
void MainWindow::on_buttonInit_clicked()
{
if(!deviceController) return;
if(deviceController->initDevice()!= 0 ){
QMessageBox* msg = new QMessageBox(this);
msg->setText("Device already initialized or error");
msg->show();
}
deviceController->setScheduleDelay(ui->dialScheduleDevice->value()*1000);
updateDeviceState();
}
void MainWindow::on_buttonDeinit_clicked()
{
if(!deviceController) return;
if( deviceController->deinitDevice() != 0 ){
QMessageBox* msg = new QMessageBox(this);
msg->setText("Device alredy deinitialized or error");
msg->show();
}
updateDeviceState();
}
void MainWindow::on_buttonStart_clicked()
{
if(!deviceController) return;
if(deviceController->startDevice() != 0 ){
QMessageBox* msg = new QMessageBox(this);
msg->setText("Device already started or error");
msg->show();
}
updateDeviceState();
}
void MainWindow::on_buttonStop_clicked()
{
if(!deviceController) return;
if(deviceController->stopDevice() != 0 ){
QMessageBox* msg = new QMessageBox(this);
msg->setText("Device already stopped or error");
msg->show();
}
updateDeviceState();
}
void MainWindow::on_buttonStartTracking_clicked(){
bool tracking = schedThread.get() != NULL;
if(tracking){
stopTracking();
} else {
startTracking();
}
}
void MainWindow::startTracking()
{
if(schedThread.get()) return;
runThread = true;
schedThread.reset(new boost::thread(boost::bind(&MainWindow::executeOnThread, this)));
if(d_timerId != -1) return;
d_timerId = startTimer(40);
lastID = 0;
lostPack = 0;
oversampling = 0;
graphWdg->start();
ui->buttonStartTracking->setText("Stop Tracking");
}
void MainWindow::stopTracking() {
graphWdg->stop();
if(d_timerId != -1) killTimer(d_timerId);
d_timerId = -1;
runThread = false;
if(schedThread){
schedThread->join();
schedThread.reset();
}
ui->buttonStartTracking->setText("Start Tracking");
}
void MainWindow::executeOnThread(){
if(!deviceController) return;
while(runThread){
deviceController->fetchCurrentDeviceValue();
if(checkSequentialIDKey.size()>0){
chaos::common::data::CDataWrapper *wrapper = deviceController->getCurrentData();
if(wrapper == NULL) {
std::cout << "No data" << std::endl;
continue;
}
if(wrapper->hasKey(checkSequentialIDKey.c_str())){
int32_t curLastID = wrapper->getInt32Value(checkSequentialIDKey.c_str());
if(lastID+1<curLastID){
lostPack += (curLastID - lastID + 1);
}else if(lastID==curLastID){
oversampling++;
}
lastID = curLastID;
}
}
boost::this_thread::sleep(boost::posix_time::milliseconds(ui->dialTrackSpeed->value()));
}
}
void MainWindow::on_dialTrackSpeed_valueChanged(int value) {
}
void MainWindow::on_dialScheduleDevice_valueChanged(int value) {
if(!deviceController) return;
deviceController->setScheduleDelay(value*1000);
}
void MainWindow::on_spinDeviceSchedule_valueChanged(int value)
{
on_dialScheduleDevice_valueChanged(value);
}
void MainWindow::on_spinTrackSpeed_valueChanged(int value)
{
on_dialTrackSpeed_valueChanged(value);
}
void MainWindow::on_pushButton_clicked()
{
updateDeviceState();
}
void MainWindow::timerEvent(QTimerEvent *event)
{
if ( event->timerId() == d_timerId )
{
QString message= "LP:";
message.append(QString::number(lostPack));
message.append(" os:");
message.append(QString::number(oversampling));
ui->lostPackageCountLabel->setText(message);
}
QMainWindow::timerEvent(event);
}
void MainWindow::on_spinBox_valueChanged(int points)
{
if(graphWdg == NULL) return;
graphWdg->setPointNumber(points);
}
void MainWindow::on_lineEdit_returnPressed()
{
checkSequentialIDKey.assign(ui->lineEdit->text().toStdString());
}
void MainWindow::on_pushButtonResetStatistic_clicked()
{
lostPack = 0;
oversampling = 0;
}
void MainWindow::on_spinBoxMaxYGrid_valueChanged(int arg1)
{
graphWdg->setMinMaxGrid(ui->spinBoxMinYGrid->value(), ui->spinBoxMaxYGrid->value());
}
void MainWindow::on_spinBoxMinYGrid_valueChanged(int arg1)
{
graphWdg->setMinMaxGrid(ui->spinBoxMinYGrid->value(), ui->spinBoxMaxYGrid->value());
}
| 31.346774
| 112
| 0.665166
|
fast01
|
39ee791e1476915f2238a14bb8473981b6f899bc
| 7,082
|
cpp
|
C++
|
image_common/image_transport/src/image_transport.cpp
|
zhj-buffer/ROS2-driver-for-Realsense
|
936cf27be4e7dc3d699ff99499e72ea8638cc622
|
[
"Apache-2.0"
] | null | null | null |
image_common/image_transport/src/image_transport.cpp
|
zhj-buffer/ROS2-driver-for-Realsense
|
936cf27be4e7dc3d699ff99499e72ea8638cc622
|
[
"Apache-2.0"
] | null | null | null |
image_common/image_transport/src/image_transport.cpp
|
zhj-buffer/ROS2-driver-for-Realsense
|
936cf27be4e7dc3d699ff99499e72ea8638cc622
|
[
"Apache-2.0"
] | null | null | null |
/*********************************************************************
* Software License Agreement (BSD License)
*
* Copyright (c) 2009, Willow Garage, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of the Willow Garage 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 "image_transport/image_transport.hpp"
#include <memory>
#include <pluginlib/class_loader.hpp>
#include "image_transport/camera_common.hpp"
#include "image_transport/loader_fwds.hpp"
#include "image_transport/publisher_plugin.hpp"
#include "image_transport/subscriber_plugin.hpp"
namespace image_transport
{
struct Impl
{
PubLoaderPtr pub_loader_;
SubLoaderPtr sub_loader_;
Impl()
: pub_loader_(std::make_shared<PubLoader>("image_transport", "image_transport::PublisherPlugin")),
sub_loader_(std::make_shared<SubLoader>("image_transport", "image_transport::SubscriberPlugin"))
{
}
};
static Impl * kImpl = new Impl();
Publisher create_publisher(
rclcpp::Node * node,
const std::string & base_topic,
rmw_qos_profile_t custom_qos)
{
return Publisher(node, base_topic, kImpl->pub_loader_, custom_qos);
}
Subscriber create_subscription(
rclcpp::Node * node,
const std::string & base_topic,
const Subscriber::Callback & callback,
const std::string & transport,
rmw_qos_profile_t custom_qos,
rclcpp::SubscriptionOptions options)
{
return Subscriber(node, base_topic, callback, kImpl->sub_loader_, transport, custom_qos, options);
}
CameraPublisher create_camera_publisher(
rclcpp::Node * node,
const std::string & base_topic,
rmw_qos_profile_t custom_qos)
{
return CameraPublisher(node, base_topic, custom_qos);
}
CameraSubscriber create_camera_subscription(
rclcpp::Node * node,
const std::string & base_topic,
const CameraSubscriber::Callback & callback,
const std::string & transport,
rmw_qos_profile_t custom_qos)
{
return CameraSubscriber(node, base_topic, callback, transport, custom_qos);
}
std::vector<std::string> getDeclaredTransports()
{
std::vector<std::string> transports = kImpl->sub_loader_->getDeclaredClasses();
// Remove the "_sub" at the end of each class name.
for (std::string & transport: transports) {
transport = erase_last_copy(transport, "_sub");
}
return transports;
}
std::vector<std::string> getLoadableTransports()
{
std::vector<std::string> loadableTransports;
for (const std::string & transportPlugin: kImpl->sub_loader_->getDeclaredClasses() ) {
// If the plugin loads without throwing an exception, add its
// transport name to the list of valid plugins, otherwise ignore
// it.
try {
std::shared_ptr<image_transport::SubscriberPlugin> sub =
kImpl->sub_loader_->createUniqueInstance(transportPlugin);
loadableTransports.push_back(erase_last_copy(transportPlugin, "_sub")); // Remove the "_sub" at the end of each class name.
} catch (const pluginlib::LibraryLoadException & e) {
(void) e;
} catch (const pluginlib::CreateClassException & e) {
(void) e;
}
}
return loadableTransports;
}
struct ImageTransport::Impl
{
rclcpp::Node::SharedPtr node_;
};
ImageTransport::ImageTransport(rclcpp::Node::SharedPtr node)
: impl_(std::make_unique<ImageTransport::Impl>())
{
impl_->node_ = node;
}
ImageTransport::~ImageTransport() = default;
Publisher ImageTransport::advertise(const std::string & base_topic, uint32_t queue_size, bool latch)
{
// TODO(ros2) implement when resolved: https://github.com/ros2/ros2/issues/464
(void) latch;
rmw_qos_profile_t custom_qos = rmw_qos_profile_default;
custom_qos.depth = queue_size;
return create_publisher(impl_->node_.get(), base_topic, custom_qos);
}
Subscriber ImageTransport::subscribe(
const std::string & base_topic, uint32_t queue_size,
const Subscriber::Callback & callback,
const VoidPtr & tracked_object,
const TransportHints * transport_hints)
{
(void) tracked_object;
rmw_qos_profile_t custom_qos = rmw_qos_profile_default;
custom_qos.depth = queue_size;
return create_subscription(impl_->node_.get(), base_topic, callback,
getTransportOrDefault(transport_hints), custom_qos);
}
CameraPublisher ImageTransport::advertiseCamera(
const std::string & base_topic, uint32_t queue_size,
bool latch)
{
// TODO(ros2) implement when resolved: https://github.com/ros2/ros2/issues/464
(void) latch;
rmw_qos_profile_t custom_qos = rmw_qos_profile_default;
custom_qos.depth = queue_size;
return create_camera_publisher(impl_->node_.get(), base_topic, custom_qos);
}
CameraSubscriber ImageTransport::subscribeCamera(
const std::string & base_topic, uint32_t queue_size,
const CameraSubscriber::Callback & callback,
const VoidPtr & tracked_object,
const TransportHints * transport_hints)
{
(void) tracked_object;
rmw_qos_profile_t custom_qos = rmw_qos_profile_default;
custom_qos.depth = queue_size;
return create_camera_subscription(impl_->node_.get(), base_topic, callback,
getTransportOrDefault(transport_hints), custom_qos);
}
std::vector<std::string> ImageTransport::getDeclaredTransports() const
{
return image_transport::getDeclaredTransports();
}
std::vector<std::string> ImageTransport::getLoadableTransports() const
{
return image_transport::getLoadableTransports();
}
std::string ImageTransport::getTransportOrDefault(const TransportHints * transport_hints)
{
std::string ret;
if (nullptr == transport_hints) {
TransportHints th(impl_->node_.get());
ret = th.getTransport();
} else {
ret = transport_hints->getTransport();
}
return ret;
}
} //namespace image_transport
| 33.093458
| 129
| 0.741175
|
zhj-buffer
|
39ef41a0e19e73f03e71ce04e9ff3a329f3330b0
| 104,341
|
cpp
|
C++
|
core/jni/android_opengl_GLES11.cpp
|
rio-31/android_frameworks_base-1
|
091a068a3288d27d77636708679dde58b7b7fd25
|
[
"Apache-2.0"
] | 164
|
2015-01-05T16:49:11.000Z
|
2022-03-29T20:40:27.000Z
|
core/jni/android_opengl_GLES11.cpp
|
rio-31/android_frameworks_base-1
|
091a068a3288d27d77636708679dde58b7b7fd25
|
[
"Apache-2.0"
] | 127
|
2015-01-12T12:02:32.000Z
|
2021-11-28T08:46:25.000Z
|
core/jni/android_opengl_GLES11.cpp
|
rio-31/android_frameworks_base-1
|
091a068a3288d27d77636708679dde58b7b7fd25
|
[
"Apache-2.0"
] | 1,141
|
2015-01-01T22:54:40.000Z
|
2022-02-09T22:08:26.000Z
|
/*
**
** Copyright 2009, 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.
*/
// This source file is automatically generated
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wunused-function"
#include <GLES/gl.h>
#include <GLES/glext.h>
#include <jni.h>
#include <nativehelper/JNIHelp.h>
#include <android_runtime/AndroidRuntime.h>
#include <utils/misc.h>
#include <assert.h>
/* special calls implemented in Android's GLES wrapper used to more
* efficiently bound-check passed arrays */
extern "C" {
#ifdef GL_VERSION_ES_CM_1_1
GL_API void GL_APIENTRY glColorPointerBounds(GLint size, GLenum type, GLsizei stride,
const GLvoid *ptr, GLsizei count);
GL_API void GL_APIENTRY glNormalPointerBounds(GLenum type, GLsizei stride,
const GLvoid *pointer, GLsizei count);
GL_API void GL_APIENTRY glTexCoordPointerBounds(GLint size, GLenum type,
GLsizei stride, const GLvoid *pointer, GLsizei count);
GL_API void GL_APIENTRY glVertexPointerBounds(GLint size, GLenum type,
GLsizei stride, const GLvoid *pointer, GLsizei count);
GL_API void GL_APIENTRY glPointSizePointerOESBounds(GLenum type,
GLsizei stride, const GLvoid *pointer, GLsizei count);
GL_API void GL_APIENTRY glMatrixIndexPointerOESBounds(GLint size, GLenum type,
GLsizei stride, const GLvoid *pointer, GLsizei count);
GL_API void GL_APIENTRY glWeightPointerOESBounds(GLint size, GLenum type,
GLsizei stride, const GLvoid *pointer, GLsizei count);
#endif
#ifdef GL_ES_VERSION_2_0
static void glVertexAttribPointerBounds(GLuint indx, GLint size, GLenum type,
GLboolean normalized, GLsizei stride, const GLvoid *pointer, GLsizei count) {
glVertexAttribPointer(indx, size, type, normalized, stride, pointer);
}
#endif
#ifdef GL_ES_VERSION_3_0
static void glVertexAttribIPointerBounds(GLuint indx, GLint size, GLenum type,
GLsizei stride, const GLvoid *pointer, GLsizei count) {
glVertexAttribIPointer(indx, size, type, stride, pointer);
}
#endif
}
static void
nativeClassInit(JNIEnv *_env, jclass glImplClass)
{
}
static void *
getPointer(JNIEnv *_env, jobject buffer, jarray *array, jint *remaining, jint *offset)
{
jint position;
jint limit;
jint elementSizeShift;
jlong pointer;
pointer = jniGetNioBufferFields(_env, buffer, &position, &limit, &elementSizeShift);
*remaining = (limit - position) << elementSizeShift;
if (pointer != 0L) {
*array = nullptr;
pointer += position << elementSizeShift;
return reinterpret_cast<void*>(pointer);
}
*array = jniGetNioBufferBaseArray(_env, buffer);
*offset = jniGetNioBufferBaseArrayOffset(_env, buffer);
return nullptr;
}
class ByteArrayGetter {
public:
static void* Get(JNIEnv* _env, jbyteArray array, jboolean* is_copy) {
return _env->GetByteArrayElements(array, is_copy);
}
};
class BooleanArrayGetter {
public:
static void* Get(JNIEnv* _env, jbooleanArray array, jboolean* is_copy) {
return _env->GetBooleanArrayElements(array, is_copy);
}
};
class CharArrayGetter {
public:
static void* Get(JNIEnv* _env, jcharArray array, jboolean* is_copy) {
return _env->GetCharArrayElements(array, is_copy);
}
};
class ShortArrayGetter {
public:
static void* Get(JNIEnv* _env, jshortArray array, jboolean* is_copy) {
return _env->GetShortArrayElements(array, is_copy);
}
};
class IntArrayGetter {
public:
static void* Get(JNIEnv* _env, jintArray array, jboolean* is_copy) {
return _env->GetIntArrayElements(array, is_copy);
}
};
class LongArrayGetter {
public:
static void* Get(JNIEnv* _env, jlongArray array, jboolean* is_copy) {
return _env->GetLongArrayElements(array, is_copy);
}
};
class FloatArrayGetter {
public:
static void* Get(JNIEnv* _env, jfloatArray array, jboolean* is_copy) {
return _env->GetFloatArrayElements(array, is_copy);
}
};
class DoubleArrayGetter {
public:
static void* Get(JNIEnv* _env, jdoubleArray array, jboolean* is_copy) {
return _env->GetDoubleArrayElements(array, is_copy);
}
};
template<typename JTYPEARRAY, typename ARRAYGETTER>
static void*
getArrayPointer(JNIEnv *_env, JTYPEARRAY array, jboolean* is_copy) {
return ARRAYGETTER::Get(_env, array, is_copy);
}
class ByteArrayReleaser {
public:
static void Release(JNIEnv* _env, jbyteArray array, jbyte* data, jboolean commit) {
_env->ReleaseByteArrayElements(array, data, commit ? 0 : JNI_ABORT);
}
};
class BooleanArrayReleaser {
public:
static void Release(JNIEnv* _env, jbooleanArray array, jboolean* data, jboolean commit) {
_env->ReleaseBooleanArrayElements(array, data, commit ? 0 : JNI_ABORT);
}
};
class CharArrayReleaser {
public:
static void Release(JNIEnv* _env, jcharArray array, jchar* data, jboolean commit) {
_env->ReleaseCharArrayElements(array, data, commit ? 0 : JNI_ABORT);
}
};
class ShortArrayReleaser {
public:
static void Release(JNIEnv* _env, jshortArray array, jshort* data, jboolean commit) {
_env->ReleaseShortArrayElements(array, data, commit ? 0 : JNI_ABORT);
}
};
class IntArrayReleaser {
public:
static void Release(JNIEnv* _env, jintArray array, jint* data, jboolean commit) {
_env->ReleaseIntArrayElements(array, data, commit ? 0 : JNI_ABORT);
}
};
class LongArrayReleaser {
public:
static void Release(JNIEnv* _env, jlongArray array, jlong* data, jboolean commit) {
_env->ReleaseLongArrayElements(array, data, commit ? 0 : JNI_ABORT);
}
};
class FloatArrayReleaser {
public:
static void Release(JNIEnv* _env, jfloatArray array, jfloat* data, jboolean commit) {
_env->ReleaseFloatArrayElements(array, data, commit ? 0 : JNI_ABORT);
}
};
class DoubleArrayReleaser {
public:
static void Release(JNIEnv* _env, jdoubleArray array, jdouble* data, jboolean commit) {
_env->ReleaseDoubleArrayElements(array, data, commit ? 0 : JNI_ABORT);
}
};
template<typename JTYPEARRAY, typename NTYPEARRAY, typename ARRAYRELEASER>
static void
releaseArrayPointer(JNIEnv *_env, JTYPEARRAY array, NTYPEARRAY data, jboolean commit) {
ARRAYRELEASER::Release(_env, array, data, commit);
}
static void
releasePointer(JNIEnv *_env, jarray array, void *data, jboolean commit)
{
_env->ReleasePrimitiveArrayCritical(array, data,
commit ? 0 : JNI_ABORT);
}
static void *
getDirectBufferPointer(JNIEnv *_env, jobject buffer) {
jint position;
jint limit;
jint elementSizeShift;
jlong pointer;
pointer = jniGetNioBufferFields(_env, buffer, &position, &limit, &elementSizeShift);
if (pointer == 0) {
jniThrowException(_env, "java/lang/IllegalArgumentException",
"Must use a native order direct Buffer");
return nullptr;
}
pointer += position << elementSizeShift;
return reinterpret_cast<void*>(pointer);
}
// --------------------------------------------------------------------------
/*
* returns the number of values glGet returns for a given pname.
*
* The code below is written such that pnames requiring only one values
* are the default (and are not explicitely tested for). This makes the
* checking code much shorter/readable/efficient.
*
* This means that unknown pnames (e.g.: extensions) will default to 1. If
* that unknown pname needs more than 1 value, then the validation check
* is incomplete and the app may crash if it passed the wrong number params.
*/
static int getNeededCount(GLint pname) {
int needed = 1;
#ifdef GL_ES_VERSION_3_0
// GLES 3.x pnames
switch (pname) {
case GL_MAX_VIEWPORT_DIMS:
needed = 2;
break;
case GL_PROGRAM_BINARY_FORMATS:
glGetIntegerv(GL_NUM_PROGRAM_BINARY_FORMATS, &needed);
break;
}
#endif
#ifdef GL_ES_VERSION_2_0
// GLES 2.x pnames
switch (pname) {
case GL_ALIASED_LINE_WIDTH_RANGE:
case GL_ALIASED_POINT_SIZE_RANGE:
needed = 2;
break;
case GL_BLEND_COLOR:
case GL_COLOR_CLEAR_VALUE:
case GL_COLOR_WRITEMASK:
case GL_SCISSOR_BOX:
case GL_VIEWPORT:
needed = 4;
break;
case GL_COMPRESSED_TEXTURE_FORMATS:
glGetIntegerv(GL_NUM_COMPRESSED_TEXTURE_FORMATS, &needed);
break;
case GL_SHADER_BINARY_FORMATS:
glGetIntegerv(GL_NUM_SHADER_BINARY_FORMATS, &needed);
break;
}
#endif
#ifdef GL_VERSION_ES_CM_1_1
// GLES 1.x pnames
switch (pname) {
case GL_ALIASED_LINE_WIDTH_RANGE:
case GL_ALIASED_POINT_SIZE_RANGE:
case GL_DEPTH_RANGE:
case GL_SMOOTH_LINE_WIDTH_RANGE:
case GL_SMOOTH_POINT_SIZE_RANGE:
needed = 2;
break;
case GL_CURRENT_NORMAL:
case GL_POINT_DISTANCE_ATTENUATION:
needed = 3;
break;
case GL_COLOR_CLEAR_VALUE:
case GL_COLOR_WRITEMASK:
case GL_CURRENT_COLOR:
case GL_CURRENT_TEXTURE_COORDS:
case GL_FOG_COLOR:
case GL_LIGHT_MODEL_AMBIENT:
case GL_SCISSOR_BOX:
case GL_VIEWPORT:
needed = 4;
break;
case GL_MODELVIEW_MATRIX:
case GL_PROJECTION_MATRIX:
case GL_TEXTURE_MATRIX:
needed = 16;
break;
case GL_COMPRESSED_TEXTURE_FORMATS:
glGetIntegerv(GL_NUM_COMPRESSED_TEXTURE_FORMATS, &needed);
break;
}
#endif
return needed;
}
template <typename JTYPEARRAY, typename ARRAYGETTER, typename NTYPEARRAY,
typename ARRAYRELEASER, typename CTYPE, void GET(GLenum, CTYPE*)>
static void
get
(JNIEnv *_env, jobject _this, jint pname, JTYPEARRAY params_ref, jint offset) {
jint _exception = 0;
const char * _exceptionType;
const char * _exceptionMessage;
CTYPE *params_base = (CTYPE *) 0;
jint _remaining;
CTYPE *params = (CTYPE *) 0;
int _needed = 0;
if (!params_ref) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "params == null";
goto exit;
}
if (offset < 0) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "offset < 0";
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
_needed = getNeededCount(pname);
// if we didn't find this pname, we just assume the user passed
// an array of the right size -- this might happen with extensions
// or if we forget an enum here.
if (_remaining < _needed) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "length - offset < needed";
goto exit;
}
params_base = (CTYPE *) getArrayPointer<JTYPEARRAY, ARRAYGETTER>(
_env, params_ref, (jboolean *)0);
params = params_base + offset;
GET(
(GLenum)pname,
(CTYPE *)params
);
exit:
if (params_base) {
releaseArrayPointer<JTYPEARRAY, NTYPEARRAY, ARRAYRELEASER>(
_env, params_ref, params_base, !_exception);
}
if (_exception) {
jniThrowException(_env, _exceptionType, _exceptionMessage);
}
}
template <typename CTYPE, typename JTYPEARRAY, typename ARRAYGETTER, typename NTYPEARRAY,
typename ARRAYRELEASER, void GET(GLenum, CTYPE*)>
static void
getarray
(JNIEnv *_env, jobject _this, jint pname, jobject params_buf) {
jint _exception = 0;
const char * _exceptionType;
const char * _exceptionMessage;
JTYPEARRAY _array = (JTYPEARRAY) 0;
jint _bufferOffset = (jint) 0;
jint _remaining;
CTYPE *params = (CTYPE *) 0;
int _needed = 0;
params = (CTYPE *)getPointer(_env, params_buf, (jarray*)&_array, &_remaining, &_bufferOffset);
_remaining /= sizeof(CTYPE); // convert from bytes to item count
_needed = getNeededCount(pname);
// if we didn't find this pname, we just assume the user passed
// an array of the right size -- this might happen with extensions
// or if we forget an enum here.
if (_needed>0 && _remaining < _needed) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "remaining() < needed";
goto exit;
}
if (params == NULL) {
char * _paramsBase = (char *) getArrayPointer<JTYPEARRAY, ARRAYGETTER>(
_env, _array, (jboolean *) 0);
params = (CTYPE *) (_paramsBase + _bufferOffset);
}
GET(
(GLenum)pname,
(CTYPE *)params
);
exit:
if (_array) {
releaseArrayPointer<JTYPEARRAY, NTYPEARRAY, ARRAYRELEASER>(
_env, _array, (NTYPEARRAY)params, _exception ? JNI_FALSE : JNI_TRUE);
}
if (_exception) {
jniThrowException(_env, _exceptionType, _exceptionMessage);
}
}
// --------------------------------------------------------------------------
/* void glBindBuffer ( GLenum target, GLuint buffer ) */
static void
android_glBindBuffer__II
(JNIEnv *_env, jobject _this, jint target, jint buffer) {
glBindBuffer(
(GLenum)target,
(GLuint)buffer
);
}
/* void glBufferData ( GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage ) */
static void
android_glBufferData__IILjava_nio_Buffer_2I
(JNIEnv *_env, jobject _this, jint target, jint size, jobject data_buf, jint usage) {
jint _exception = 0;
const char * _exceptionType = NULL;
const char * _exceptionMessage = NULL;
jarray _array = (jarray) 0;
jint _bufferOffset = (jint) 0;
jint _remaining;
GLvoid *data = (GLvoid *) 0;
if (data_buf) {
data = (GLvoid *)getPointer(_env, data_buf, (jarray*)&_array, &_remaining, &_bufferOffset);
if (_remaining < size) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "remaining() < size < needed";
goto exit;
}
}
if (data_buf && data == NULL) {
char * _dataBase = (char *)_env->GetPrimitiveArrayCritical(_array, (jboolean *) 0);
data = (GLvoid *) (_dataBase + _bufferOffset);
}
glBufferData(
(GLenum)target,
(GLsizeiptr)size,
(GLvoid *)data,
(GLenum)usage
);
exit:
if (_array) {
releasePointer(_env, _array, data, JNI_FALSE);
}
if (_exception) {
jniThrowException(_env, _exceptionType, _exceptionMessage);
}
}
/* void glBufferSubData ( GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data ) */
static void
android_glBufferSubData__IIILjava_nio_Buffer_2
(JNIEnv *_env, jobject _this, jint target, jint offset, jint size, jobject data_buf) {
jint _exception = 0;
const char * _exceptionType = NULL;
const char * _exceptionMessage = NULL;
jarray _array = (jarray) 0;
jint _bufferOffset = (jint) 0;
jint _remaining;
GLvoid *data = (GLvoid *) 0;
if (!data_buf) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "data == null";
goto exit;
}
data = (GLvoid *)getPointer(_env, data_buf, (jarray*)&_array, &_remaining, &_bufferOffset);
if (_remaining < size) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "remaining() < size < needed";
goto exit;
}
if (data == NULL) {
char * _dataBase = (char *)_env->GetPrimitiveArrayCritical(_array, (jboolean *) 0);
data = (GLvoid *) (_dataBase + _bufferOffset);
}
glBufferSubData(
(GLenum)target,
(GLintptr)offset,
(GLsizeiptr)size,
(GLvoid *)data
);
exit:
if (_array) {
releasePointer(_env, _array, data, JNI_FALSE);
}
if (_exception) {
jniThrowException(_env, _exceptionType, _exceptionMessage);
}
}
/* void glClipPlanef ( GLenum plane, const GLfloat *equation ) */
static void
android_glClipPlanef__I_3FI
(JNIEnv *_env, jobject _this, jint plane, jfloatArray equation_ref, jint offset) {
jint _exception = 0;
const char * _exceptionType = NULL;
const char * _exceptionMessage = NULL;
GLfloat *equation_base = (GLfloat *) 0;
jint _remaining;
GLfloat *equation = (GLfloat *) 0;
if (!equation_ref) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "equation == null";
goto exit;
}
if (offset < 0) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "offset < 0";
goto exit;
}
_remaining = _env->GetArrayLength(equation_ref) - offset;
equation_base = (GLfloat *)
_env->GetFloatArrayElements(equation_ref, (jboolean *)0);
equation = equation_base + offset;
glClipPlanef(
(GLenum)plane,
(GLfloat *)equation
);
exit:
if (equation_base) {
_env->ReleaseFloatArrayElements(equation_ref, (jfloat*)equation_base,
JNI_ABORT);
}
if (_exception) {
jniThrowException(_env, _exceptionType, _exceptionMessage);
}
}
/* void glClipPlanef ( GLenum plane, const GLfloat *equation ) */
static void
android_glClipPlanef__ILjava_nio_FloatBuffer_2
(JNIEnv *_env, jobject _this, jint plane, jobject equation_buf) {
jint _exception = 0;
const char * _exceptionType = NULL;
const char * _exceptionMessage = NULL;
jfloatArray _array = (jfloatArray) 0;
jint _bufferOffset = (jint) 0;
jint _remaining;
GLfloat *equation = (GLfloat *) 0;
if (!equation_buf) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "equation == null";
goto exit;
}
equation = (GLfloat *)getPointer(_env, equation_buf, (jarray*)&_array, &_remaining, &_bufferOffset);
if (equation == NULL) {
char * _equationBase = (char *)_env->GetFloatArrayElements(_array, (jboolean *) 0);
equation = (GLfloat *) (_equationBase + _bufferOffset);
}
glClipPlanef(
(GLenum)plane,
(GLfloat *)equation
);
exit:
if (_array) {
_env->ReleaseFloatArrayElements(_array, (jfloat*)equation, JNI_ABORT);
}
if (_exception) {
jniThrowException(_env, _exceptionType, _exceptionMessage);
}
}
/* void glClipPlanex ( GLenum plane, const GLfixed *equation ) */
static void
android_glClipPlanex__I_3II
(JNIEnv *_env, jobject _this, jint plane, jintArray equation_ref, jint offset) {
jint _exception = 0;
const char * _exceptionType = NULL;
const char * _exceptionMessage = NULL;
GLfixed *equation_base = (GLfixed *) 0;
jint _remaining;
GLfixed *equation = (GLfixed *) 0;
if (!equation_ref) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "equation == null";
goto exit;
}
if (offset < 0) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "offset < 0";
goto exit;
}
_remaining = _env->GetArrayLength(equation_ref) - offset;
equation_base = (GLfixed *)
_env->GetIntArrayElements(equation_ref, (jboolean *)0);
equation = equation_base + offset;
glClipPlanex(
(GLenum)plane,
(GLfixed *)equation
);
exit:
if (equation_base) {
_env->ReleaseIntArrayElements(equation_ref, (jint*)equation_base,
JNI_ABORT);
}
if (_exception) {
jniThrowException(_env, _exceptionType, _exceptionMessage);
}
}
/* void glClipPlanex ( GLenum plane, const GLfixed *equation ) */
static void
android_glClipPlanex__ILjava_nio_IntBuffer_2
(JNIEnv *_env, jobject _this, jint plane, jobject equation_buf) {
jint _exception = 0;
const char * _exceptionType = NULL;
const char * _exceptionMessage = NULL;
jintArray _array = (jintArray) 0;
jint _bufferOffset = (jint) 0;
jint _remaining;
GLfixed *equation = (GLfixed *) 0;
if (!equation_buf) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "equation == null";
goto exit;
}
equation = (GLfixed *)getPointer(_env, equation_buf, (jarray*)&_array, &_remaining, &_bufferOffset);
if (equation == NULL) {
char * _equationBase = (char *)_env->GetIntArrayElements(_array, (jboolean *) 0);
equation = (GLfixed *) (_equationBase + _bufferOffset);
}
glClipPlanex(
(GLenum)plane,
(GLfixed *)equation
);
exit:
if (_array) {
_env->ReleaseIntArrayElements(_array, (jint*)equation, JNI_ABORT);
}
if (_exception) {
jniThrowException(_env, _exceptionType, _exceptionMessage);
}
}
/* void glColor4ub ( GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha ) */
static void
android_glColor4ub__BBBB
(JNIEnv *_env, jobject _this, jbyte red, jbyte green, jbyte blue, jbyte alpha) {
glColor4ub(
(GLubyte)red,
(GLubyte)green,
(GLubyte)blue,
(GLubyte)alpha
);
}
/* void glColorPointer ( GLint size, GLenum type, GLsizei stride, GLint offset ) */
static void
android_glColorPointer__IIII
(JNIEnv *_env, jobject _this, jint size, jint type, jint stride, jint offset) {
glColorPointer(
(GLint)size,
(GLenum)type,
(GLsizei)stride,
reinterpret_cast<GLvoid *>(offset)
);
}
/* void glDeleteBuffers ( GLsizei n, const GLuint *buffers ) */
static void
android_glDeleteBuffers__I_3II
(JNIEnv *_env, jobject _this, jint n, jintArray buffers_ref, jint offset) {
jint _exception = 0;
const char * _exceptionType = NULL;
const char * _exceptionMessage = NULL;
GLuint *buffers_base = (GLuint *) 0;
jint _remaining;
GLuint *buffers = (GLuint *) 0;
if (!buffers_ref) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "buffers == null";
goto exit;
}
if (offset < 0) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "offset < 0";
goto exit;
}
_remaining = _env->GetArrayLength(buffers_ref) - offset;
if (_remaining < n) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "length - offset < n < needed";
goto exit;
}
buffers_base = (GLuint *)
_env->GetIntArrayElements(buffers_ref, (jboolean *)0);
buffers = buffers_base + offset;
glDeleteBuffers(
(GLsizei)n,
(GLuint *)buffers
);
exit:
if (buffers_base) {
_env->ReleaseIntArrayElements(buffers_ref, (jint*)buffers_base,
JNI_ABORT);
}
if (_exception) {
jniThrowException(_env, _exceptionType, _exceptionMessage);
}
}
/* void glDeleteBuffers ( GLsizei n, const GLuint *buffers ) */
static void
android_glDeleteBuffers__ILjava_nio_IntBuffer_2
(JNIEnv *_env, jobject _this, jint n, jobject buffers_buf) {
jint _exception = 0;
const char * _exceptionType = NULL;
const char * _exceptionMessage = NULL;
jintArray _array = (jintArray) 0;
jint _bufferOffset = (jint) 0;
jint _remaining;
GLuint *buffers = (GLuint *) 0;
if (!buffers_buf) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "buffers == null";
goto exit;
}
buffers = (GLuint *)getPointer(_env, buffers_buf, (jarray*)&_array, &_remaining, &_bufferOffset);
if (_remaining < n) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "remaining() < n < needed";
goto exit;
}
if (buffers == NULL) {
char * _buffersBase = (char *)_env->GetIntArrayElements(_array, (jboolean *) 0);
buffers = (GLuint *) (_buffersBase + _bufferOffset);
}
glDeleteBuffers(
(GLsizei)n,
(GLuint *)buffers
);
exit:
if (_array) {
_env->ReleaseIntArrayElements(_array, (jint*)buffers, JNI_ABORT);
}
if (_exception) {
jniThrowException(_env, _exceptionType, _exceptionMessage);
}
}
/* void glDrawElements ( GLenum mode, GLsizei count, GLenum type, GLint offset ) */
static void
android_glDrawElements__IIII
(JNIEnv *_env, jobject _this, jint mode, jint count, jint type, jint offset) {
jint _exception = 0;
const char * _exceptionType = NULL;
const char * _exceptionMessage = NULL;
glDrawElements(
(GLenum)mode,
(GLsizei)count,
(GLenum)type,
reinterpret_cast<GLvoid *>(offset)
);
if (_exception) {
jniThrowException(_env, _exceptionType, _exceptionMessage);
}
}
/* void glGenBuffers ( GLsizei n, GLuint *buffers ) */
static void
android_glGenBuffers__I_3II
(JNIEnv *_env, jobject _this, jint n, jintArray buffers_ref, jint offset) {
jint _exception = 0;
const char * _exceptionType = NULL;
const char * _exceptionMessage = NULL;
GLuint *buffers_base = (GLuint *) 0;
jint _remaining;
GLuint *buffers = (GLuint *) 0;
if (!buffers_ref) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "buffers == null";
goto exit;
}
if (offset < 0) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "offset < 0";
goto exit;
}
_remaining = _env->GetArrayLength(buffers_ref) - offset;
if (_remaining < n) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "length - offset < n < needed";
goto exit;
}
buffers_base = (GLuint *)
_env->GetIntArrayElements(buffers_ref, (jboolean *)0);
buffers = buffers_base + offset;
glGenBuffers(
(GLsizei)n,
(GLuint *)buffers
);
exit:
if (buffers_base) {
_env->ReleaseIntArrayElements(buffers_ref, (jint*)buffers_base,
_exception ? JNI_ABORT: 0);
}
if (_exception) {
jniThrowException(_env, _exceptionType, _exceptionMessage);
}
}
/* void glGenBuffers ( GLsizei n, GLuint *buffers ) */
static void
android_glGenBuffers__ILjava_nio_IntBuffer_2
(JNIEnv *_env, jobject _this, jint n, jobject buffers_buf) {
jint _exception = 0;
const char * _exceptionType = NULL;
const char * _exceptionMessage = NULL;
jintArray _array = (jintArray) 0;
jint _bufferOffset = (jint) 0;
jint _remaining;
GLuint *buffers = (GLuint *) 0;
if (!buffers_buf) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "buffers == null";
goto exit;
}
buffers = (GLuint *)getPointer(_env, buffers_buf, (jarray*)&_array, &_remaining, &_bufferOffset);
if (_remaining < n) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "remaining() < n < needed";
goto exit;
}
if (buffers == NULL) {
char * _buffersBase = (char *)_env->GetIntArrayElements(_array, (jboolean *) 0);
buffers = (GLuint *) (_buffersBase + _bufferOffset);
}
glGenBuffers(
(GLsizei)n,
(GLuint *)buffers
);
exit:
if (_array) {
_env->ReleaseIntArrayElements(_array, (jint*)buffers, _exception ? JNI_ABORT : 0);
}
if (_exception) {
jniThrowException(_env, _exceptionType, _exceptionMessage);
}
}
/* void glGetBooleanv ( GLenum pname, GLboolean *params ) */
static void
android_glGetBooleanv__I_3ZI
(JNIEnv *_env, jobject _this, jint pname, jbooleanArray params_ref, jint offset) {
get<jbooleanArray, BooleanArrayGetter, jboolean*, BooleanArrayReleaser, GLboolean, glGetBooleanv>(
_env, _this, pname, params_ref, offset);
}
/* void glGetBooleanv ( GLenum pname, GLboolean *params ) */
static void
android_glGetBooleanv__ILjava_nio_IntBuffer_2
(JNIEnv *_env, jobject _this, jint pname, jobject params_buf) {
getarray<GLboolean, jintArray, IntArrayGetter, jint*, IntArrayReleaser, glGetBooleanv>(
_env, _this, pname, params_buf);
}
/* void glGetBufferParameteriv ( GLenum target, GLenum pname, GLint *params ) */
static void
android_glGetBufferParameteriv__II_3II
(JNIEnv *_env, jobject _this, jint target, jint pname, jintArray params_ref, jint offset) {
jint _exception = 0;
const char * _exceptionType = NULL;
const char * _exceptionMessage = NULL;
GLint *params_base = (GLint *) 0;
jint _remaining;
GLint *params = (GLint *) 0;
if (!params_ref) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "params == null";
goto exit;
}
if (offset < 0) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "offset < 0";
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
if (_remaining < 1) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "length - offset < 1 < needed";
goto exit;
}
params_base = (GLint *)
_env->GetIntArrayElements(params_ref, (jboolean *)0);
params = params_base + offset;
glGetBufferParameteriv(
(GLenum)target,
(GLenum)pname,
(GLint *)params
);
exit:
if (params_base) {
_env->ReleaseIntArrayElements(params_ref, (jint*)params_base,
_exception ? JNI_ABORT: 0);
}
if (_exception) {
jniThrowException(_env, _exceptionType, _exceptionMessage);
}
}
/* void glGetBufferParameteriv ( GLenum target, GLenum pname, GLint *params ) */
static void
android_glGetBufferParameteriv__IILjava_nio_IntBuffer_2
(JNIEnv *_env, jobject _this, jint target, jint pname, jobject params_buf) {
jint _exception = 0;
const char * _exceptionType = NULL;
const char * _exceptionMessage = NULL;
jintArray _array = (jintArray) 0;
jint _bufferOffset = (jint) 0;
jint _remaining;
GLint *params = (GLint *) 0;
if (!params_buf) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "params == null";
goto exit;
}
params = (GLint *)getPointer(_env, params_buf, (jarray*)&_array, &_remaining, &_bufferOffset);
if (_remaining < 1) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "remaining() < 1 < needed";
goto exit;
}
if (params == NULL) {
char * _paramsBase = (char *)_env->GetIntArrayElements(_array, (jboolean *) 0);
params = (GLint *) (_paramsBase + _bufferOffset);
}
glGetBufferParameteriv(
(GLenum)target,
(GLenum)pname,
(GLint *)params
);
exit:
if (_array) {
_env->ReleaseIntArrayElements(_array, (jint*)params, _exception ? JNI_ABORT : 0);
}
if (_exception) {
jniThrowException(_env, _exceptionType, _exceptionMessage);
}
}
/* void glGetClipPlanef ( GLenum pname, GLfloat *eqn ) */
static void
android_glGetClipPlanef__I_3FI
(JNIEnv *_env, jobject _this, jint pname, jfloatArray eqn_ref, jint offset) {
jint _exception = 0;
const char * _exceptionType = NULL;
const char * _exceptionMessage = NULL;
GLfloat *eqn_base = (GLfloat *) 0;
jint _remaining;
GLfloat *eqn = (GLfloat *) 0;
if (!eqn_ref) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "eqn == null";
goto exit;
}
if (offset < 0) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "offset < 0";
goto exit;
}
_remaining = _env->GetArrayLength(eqn_ref) - offset;
if (_remaining < 4) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "length - offset < 4 < needed";
goto exit;
}
eqn_base = (GLfloat *)
_env->GetFloatArrayElements(eqn_ref, (jboolean *)0);
eqn = eqn_base + offset;
glGetClipPlanef(
(GLenum)pname,
(GLfloat *)eqn
);
exit:
if (eqn_base) {
_env->ReleaseFloatArrayElements(eqn_ref, (jfloat*)eqn_base,
_exception ? JNI_ABORT: 0);
}
if (_exception) {
jniThrowException(_env, _exceptionType, _exceptionMessage);
}
}
/* void glGetClipPlanef ( GLenum pname, GLfloat *eqn ) */
static void
android_glGetClipPlanef__ILjava_nio_FloatBuffer_2
(JNIEnv *_env, jobject _this, jint pname, jobject eqn_buf) {
jint _exception = 0;
const char * _exceptionType = NULL;
const char * _exceptionMessage = NULL;
jfloatArray _array = (jfloatArray) 0;
jint _bufferOffset = (jint) 0;
jint _remaining;
GLfloat *eqn = (GLfloat *) 0;
if (!eqn_buf) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "eqn == null";
goto exit;
}
eqn = (GLfloat *)getPointer(_env, eqn_buf, (jarray*)&_array, &_remaining, &_bufferOffset);
if (_remaining < 4) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "remaining() < 4 < needed";
goto exit;
}
if (eqn == NULL) {
char * _eqnBase = (char *)_env->GetFloatArrayElements(_array, (jboolean *) 0);
eqn = (GLfloat *) (_eqnBase + _bufferOffset);
}
glGetClipPlanef(
(GLenum)pname,
(GLfloat *)eqn
);
exit:
if (_array) {
_env->ReleaseFloatArrayElements(_array, (jfloat*)eqn, _exception ? JNI_ABORT : 0);
}
if (_exception) {
jniThrowException(_env, _exceptionType, _exceptionMessage);
}
}
/* void glGetClipPlanex ( GLenum pname, GLfixed *eqn ) */
static void
android_glGetClipPlanex__I_3II
(JNIEnv *_env, jobject _this, jint pname, jintArray eqn_ref, jint offset) {
jint _exception = 0;
const char * _exceptionType = NULL;
const char * _exceptionMessage = NULL;
GLfixed *eqn_base = (GLfixed *) 0;
jint _remaining;
GLfixed *eqn = (GLfixed *) 0;
if (!eqn_ref) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "eqn == null";
goto exit;
}
if (offset < 0) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "offset < 0";
goto exit;
}
_remaining = _env->GetArrayLength(eqn_ref) - offset;
if (_remaining < 4) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "length - offset < 4 < needed";
goto exit;
}
eqn_base = (GLfixed *)
_env->GetIntArrayElements(eqn_ref, (jboolean *)0);
eqn = eqn_base + offset;
glGetClipPlanex(
(GLenum)pname,
(GLfixed *)eqn
);
exit:
if (eqn_base) {
_env->ReleaseIntArrayElements(eqn_ref, (jint*)eqn_base,
_exception ? JNI_ABORT: 0);
}
if (_exception) {
jniThrowException(_env, _exceptionType, _exceptionMessage);
}
}
/* void glGetClipPlanex ( GLenum pname, GLfixed *eqn ) */
static void
android_glGetClipPlanex__ILjava_nio_IntBuffer_2
(JNIEnv *_env, jobject _this, jint pname, jobject eqn_buf) {
jint _exception = 0;
const char * _exceptionType = NULL;
const char * _exceptionMessage = NULL;
jintArray _array = (jintArray) 0;
jint _bufferOffset = (jint) 0;
jint _remaining;
GLfixed *eqn = (GLfixed *) 0;
if (!eqn_buf) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "eqn == null";
goto exit;
}
eqn = (GLfixed *)getPointer(_env, eqn_buf, (jarray*)&_array, &_remaining, &_bufferOffset);
if (_remaining < 4) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "remaining() < 4 < needed";
goto exit;
}
if (eqn == NULL) {
char * _eqnBase = (char *)_env->GetIntArrayElements(_array, (jboolean *) 0);
eqn = (GLfixed *) (_eqnBase + _bufferOffset);
}
glGetClipPlanex(
(GLenum)pname,
(GLfixed *)eqn
);
exit:
if (_array) {
_env->ReleaseIntArrayElements(_array, (jint*)eqn, _exception ? JNI_ABORT : 0);
}
if (_exception) {
jniThrowException(_env, _exceptionType, _exceptionMessage);
}
}
/* void glGetFixedv ( GLenum pname, GLfixed *params ) */
static void
android_glGetFixedv__I_3II
(JNIEnv *_env, jobject _this, jint pname, jintArray params_ref, jint offset) {
jint _exception = 0;
const char * _exceptionType = NULL;
const char * _exceptionMessage = NULL;
GLfixed *params_base = (GLfixed *) 0;
jint _remaining;
GLfixed *params = (GLfixed *) 0;
if (!params_ref) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "params == null";
goto exit;
}
if (offset < 0) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "offset < 0";
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
params_base = (GLfixed *)
_env->GetIntArrayElements(params_ref, (jboolean *)0);
params = params_base + offset;
glGetFixedv(
(GLenum)pname,
(GLfixed *)params
);
exit:
if (params_base) {
_env->ReleaseIntArrayElements(params_ref, (jint*)params_base,
_exception ? JNI_ABORT: 0);
}
if (_exception) {
jniThrowException(_env, _exceptionType, _exceptionMessage);
}
}
/* void glGetFixedv ( GLenum pname, GLfixed *params ) */
static void
android_glGetFixedv__ILjava_nio_IntBuffer_2
(JNIEnv *_env, jobject _this, jint pname, jobject params_buf) {
jint _exception = 0;
const char * _exceptionType = NULL;
const char * _exceptionMessage = NULL;
jintArray _array = (jintArray) 0;
jint _bufferOffset = (jint) 0;
jint _remaining;
GLfixed *params = (GLfixed *) 0;
if (!params_buf) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "params == null";
goto exit;
}
params = (GLfixed *)getPointer(_env, params_buf, (jarray*)&_array, &_remaining, &_bufferOffset);
if (params == NULL) {
char * _paramsBase = (char *)_env->GetIntArrayElements(_array, (jboolean *) 0);
params = (GLfixed *) (_paramsBase + _bufferOffset);
}
glGetFixedv(
(GLenum)pname,
(GLfixed *)params
);
exit:
if (_array) {
_env->ReleaseIntArrayElements(_array, (jint*)params, _exception ? JNI_ABORT : 0);
}
if (_exception) {
jniThrowException(_env, _exceptionType, _exceptionMessage);
}
}
/* void glGetFloatv ( GLenum pname, GLfloat *params ) */
static void
android_glGetFloatv__I_3FI
(JNIEnv *_env, jobject _this, jint pname, jfloatArray params_ref, jint offset) {
get<jfloatArray, FloatArrayGetter, jfloat*, FloatArrayReleaser, GLfloat, glGetFloatv>(
_env, _this, pname, params_ref, offset);
}
/* void glGetFloatv ( GLenum pname, GLfloat *params ) */
static void
android_glGetFloatv__ILjava_nio_FloatBuffer_2
(JNIEnv *_env, jobject _this, jint pname, jobject params_buf) {
getarray<GLfloat, jfloatArray, FloatArrayGetter, jfloat*, FloatArrayReleaser, glGetFloatv>(
_env, _this, pname, params_buf);
}
/* void glGetLightfv ( GLenum light, GLenum pname, GLfloat *params ) */
static void
android_glGetLightfv__II_3FI
(JNIEnv *_env, jobject _this, jint light, jint pname, jfloatArray params_ref, jint offset) {
jint _exception = 0;
const char * _exceptionType = NULL;
const char * _exceptionMessage = NULL;
GLfloat *params_base = (GLfloat *) 0;
jint _remaining;
GLfloat *params = (GLfloat *) 0;
if (!params_ref) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "params == null";
goto exit;
}
if (offset < 0) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "offset < 0";
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
int _needed;
switch (pname) {
#if defined(GL_SPOT_DIRECTION)
case GL_SPOT_DIRECTION:
#endif // defined(GL_SPOT_DIRECTION)
_needed = 3;
break;
#if defined(GL_AMBIENT)
case GL_AMBIENT:
#endif // defined(GL_AMBIENT)
#if defined(GL_DIFFUSE)
case GL_DIFFUSE:
#endif // defined(GL_DIFFUSE)
#if defined(GL_SPECULAR)
case GL_SPECULAR:
#endif // defined(GL_SPECULAR)
#if defined(GL_EMISSION)
case GL_EMISSION:
#endif // defined(GL_EMISSION)
_needed = 4;
break;
default:
_needed = 1;
break;
}
if (_remaining < _needed) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "length - offset < needed";
goto exit;
}
params_base = (GLfloat *)
_env->GetFloatArrayElements(params_ref, (jboolean *)0);
params = params_base + offset;
glGetLightfv(
(GLenum)light,
(GLenum)pname,
(GLfloat *)params
);
exit:
if (params_base) {
_env->ReleaseFloatArrayElements(params_ref, (jfloat*)params_base,
_exception ? JNI_ABORT: 0);
}
if (_exception) {
jniThrowException(_env, _exceptionType, _exceptionMessage);
}
}
/* void glGetLightfv ( GLenum light, GLenum pname, GLfloat *params ) */
static void
android_glGetLightfv__IILjava_nio_FloatBuffer_2
(JNIEnv *_env, jobject _this, jint light, jint pname, jobject params_buf) {
jint _exception = 0;
const char * _exceptionType = NULL;
const char * _exceptionMessage = NULL;
jfloatArray _array = (jfloatArray) 0;
jint _bufferOffset = (jint) 0;
jint _remaining;
GLfloat *params = (GLfloat *) 0;
if (!params_buf) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "params == null";
goto exit;
}
params = (GLfloat *)getPointer(_env, params_buf, (jarray*)&_array, &_remaining, &_bufferOffset);
int _needed;
switch (pname) {
#if defined(GL_SPOT_DIRECTION)
case GL_SPOT_DIRECTION:
#endif // defined(GL_SPOT_DIRECTION)
_needed = 3;
break;
#if defined(GL_AMBIENT)
case GL_AMBIENT:
#endif // defined(GL_AMBIENT)
#if defined(GL_DIFFUSE)
case GL_DIFFUSE:
#endif // defined(GL_DIFFUSE)
#if defined(GL_SPECULAR)
case GL_SPECULAR:
#endif // defined(GL_SPECULAR)
#if defined(GL_EMISSION)
case GL_EMISSION:
#endif // defined(GL_EMISSION)
_needed = 4;
break;
default:
_needed = 1;
break;
}
if (_remaining < _needed) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "remaining() < needed";
goto exit;
}
if (params == NULL) {
char * _paramsBase = (char *)_env->GetFloatArrayElements(_array, (jboolean *) 0);
params = (GLfloat *) (_paramsBase + _bufferOffset);
}
glGetLightfv(
(GLenum)light,
(GLenum)pname,
(GLfloat *)params
);
exit:
if (_array) {
_env->ReleaseFloatArrayElements(_array, (jfloat*)params, _exception ? JNI_ABORT : 0);
}
if (_exception) {
jniThrowException(_env, _exceptionType, _exceptionMessage);
}
}
/* void glGetLightxv ( GLenum light, GLenum pname, GLfixed *params ) */
static void
android_glGetLightxv__II_3II
(JNIEnv *_env, jobject _this, jint light, jint pname, jintArray params_ref, jint offset) {
jint _exception = 0;
const char * _exceptionType = NULL;
const char * _exceptionMessage = NULL;
GLfixed *params_base = (GLfixed *) 0;
jint _remaining;
GLfixed *params = (GLfixed *) 0;
if (!params_ref) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "params == null";
goto exit;
}
if (offset < 0) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "offset < 0";
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
int _needed;
switch (pname) {
#if defined(GL_SPOT_DIRECTION)
case GL_SPOT_DIRECTION:
#endif // defined(GL_SPOT_DIRECTION)
_needed = 3;
break;
#if defined(GL_AMBIENT)
case GL_AMBIENT:
#endif // defined(GL_AMBIENT)
#if defined(GL_DIFFUSE)
case GL_DIFFUSE:
#endif // defined(GL_DIFFUSE)
#if defined(GL_SPECULAR)
case GL_SPECULAR:
#endif // defined(GL_SPECULAR)
#if defined(GL_EMISSION)
case GL_EMISSION:
#endif // defined(GL_EMISSION)
_needed = 4;
break;
default:
_needed = 1;
break;
}
if (_remaining < _needed) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "length - offset < needed";
goto exit;
}
params_base = (GLfixed *)
_env->GetIntArrayElements(params_ref, (jboolean *)0);
params = params_base + offset;
glGetLightxv(
(GLenum)light,
(GLenum)pname,
(GLfixed *)params
);
exit:
if (params_base) {
_env->ReleaseIntArrayElements(params_ref, (jint*)params_base,
_exception ? JNI_ABORT: 0);
}
if (_exception) {
jniThrowException(_env, _exceptionType, _exceptionMessage);
}
}
/* void glGetLightxv ( GLenum light, GLenum pname, GLfixed *params ) */
static void
android_glGetLightxv__IILjava_nio_IntBuffer_2
(JNIEnv *_env, jobject _this, jint light, jint pname, jobject params_buf) {
jint _exception = 0;
const char * _exceptionType = NULL;
const char * _exceptionMessage = NULL;
jintArray _array = (jintArray) 0;
jint _bufferOffset = (jint) 0;
jint _remaining;
GLfixed *params = (GLfixed *) 0;
if (!params_buf) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "params == null";
goto exit;
}
params = (GLfixed *)getPointer(_env, params_buf, (jarray*)&_array, &_remaining, &_bufferOffset);
int _needed;
switch (pname) {
#if defined(GL_SPOT_DIRECTION)
case GL_SPOT_DIRECTION:
#endif // defined(GL_SPOT_DIRECTION)
_needed = 3;
break;
#if defined(GL_AMBIENT)
case GL_AMBIENT:
#endif // defined(GL_AMBIENT)
#if defined(GL_DIFFUSE)
case GL_DIFFUSE:
#endif // defined(GL_DIFFUSE)
#if defined(GL_SPECULAR)
case GL_SPECULAR:
#endif // defined(GL_SPECULAR)
#if defined(GL_EMISSION)
case GL_EMISSION:
#endif // defined(GL_EMISSION)
_needed = 4;
break;
default:
_needed = 1;
break;
}
if (_remaining < _needed) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "remaining() < needed";
goto exit;
}
if (params == NULL) {
char * _paramsBase = (char *)_env->GetIntArrayElements(_array, (jboolean *) 0);
params = (GLfixed *) (_paramsBase + _bufferOffset);
}
glGetLightxv(
(GLenum)light,
(GLenum)pname,
(GLfixed *)params
);
exit:
if (_array) {
_env->ReleaseIntArrayElements(_array, (jint*)params, _exception ? JNI_ABORT : 0);
}
if (_exception) {
jniThrowException(_env, _exceptionType, _exceptionMessage);
}
}
/* void glGetMaterialfv ( GLenum face, GLenum pname, GLfloat *params ) */
static void
android_glGetMaterialfv__II_3FI
(JNIEnv *_env, jobject _this, jint face, jint pname, jfloatArray params_ref, jint offset) {
jint _exception = 0;
const char * _exceptionType = NULL;
const char * _exceptionMessage = NULL;
GLfloat *params_base = (GLfloat *) 0;
jint _remaining;
GLfloat *params = (GLfloat *) 0;
if (!params_ref) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "params == null";
goto exit;
}
if (offset < 0) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "offset < 0";
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
int _needed;
switch (pname) {
#if defined(GL_AMBIENT)
case GL_AMBIENT:
#endif // defined(GL_AMBIENT)
#if defined(GL_DIFFUSE)
case GL_DIFFUSE:
#endif // defined(GL_DIFFUSE)
#if defined(GL_SPECULAR)
case GL_SPECULAR:
#endif // defined(GL_SPECULAR)
#if defined(GL_EMISSION)
case GL_EMISSION:
#endif // defined(GL_EMISSION)
#if defined(GL_AMBIENT_AND_DIFFUSE)
case GL_AMBIENT_AND_DIFFUSE:
#endif // defined(GL_AMBIENT_AND_DIFFUSE)
_needed = 4;
break;
default:
_needed = 1;
break;
}
if (_remaining < _needed) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "length - offset < needed";
goto exit;
}
params_base = (GLfloat *)
_env->GetFloatArrayElements(params_ref, (jboolean *)0);
params = params_base + offset;
glGetMaterialfv(
(GLenum)face,
(GLenum)pname,
(GLfloat *)params
);
exit:
if (params_base) {
_env->ReleaseFloatArrayElements(params_ref, (jfloat*)params_base,
_exception ? JNI_ABORT: 0);
}
if (_exception) {
jniThrowException(_env, _exceptionType, _exceptionMessage);
}
}
/* void glGetMaterialfv ( GLenum face, GLenum pname, GLfloat *params ) */
static void
android_glGetMaterialfv__IILjava_nio_FloatBuffer_2
(JNIEnv *_env, jobject _this, jint face, jint pname, jobject params_buf) {
jint _exception = 0;
const char * _exceptionType = NULL;
const char * _exceptionMessage = NULL;
jfloatArray _array = (jfloatArray) 0;
jint _bufferOffset = (jint) 0;
jint _remaining;
GLfloat *params = (GLfloat *) 0;
if (!params_buf) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "params == null";
goto exit;
}
params = (GLfloat *)getPointer(_env, params_buf, (jarray*)&_array, &_remaining, &_bufferOffset);
int _needed;
switch (pname) {
#if defined(GL_AMBIENT)
case GL_AMBIENT:
#endif // defined(GL_AMBIENT)
#if defined(GL_DIFFUSE)
case GL_DIFFUSE:
#endif // defined(GL_DIFFUSE)
#if defined(GL_SPECULAR)
case GL_SPECULAR:
#endif // defined(GL_SPECULAR)
#if defined(GL_EMISSION)
case GL_EMISSION:
#endif // defined(GL_EMISSION)
#if defined(GL_AMBIENT_AND_DIFFUSE)
case GL_AMBIENT_AND_DIFFUSE:
#endif // defined(GL_AMBIENT_AND_DIFFUSE)
_needed = 4;
break;
default:
_needed = 1;
break;
}
if (_remaining < _needed) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "remaining() < needed";
goto exit;
}
if (params == NULL) {
char * _paramsBase = (char *)_env->GetFloatArrayElements(_array, (jboolean *) 0);
params = (GLfloat *) (_paramsBase + _bufferOffset);
}
glGetMaterialfv(
(GLenum)face,
(GLenum)pname,
(GLfloat *)params
);
exit:
if (_array) {
_env->ReleaseFloatArrayElements(_array, (jfloat*)params, _exception ? JNI_ABORT : 0);
}
if (_exception) {
jniThrowException(_env, _exceptionType, _exceptionMessage);
}
}
/* void glGetMaterialxv ( GLenum face, GLenum pname, GLfixed *params ) */
static void
android_glGetMaterialxv__II_3II
(JNIEnv *_env, jobject _this, jint face, jint pname, jintArray params_ref, jint offset) {
jint _exception = 0;
const char * _exceptionType = NULL;
const char * _exceptionMessage = NULL;
GLfixed *params_base = (GLfixed *) 0;
jint _remaining;
GLfixed *params = (GLfixed *) 0;
if (!params_ref) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "params == null";
goto exit;
}
if (offset < 0) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "offset < 0";
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
int _needed;
switch (pname) {
#if defined(GL_AMBIENT)
case GL_AMBIENT:
#endif // defined(GL_AMBIENT)
#if defined(GL_DIFFUSE)
case GL_DIFFUSE:
#endif // defined(GL_DIFFUSE)
#if defined(GL_SPECULAR)
case GL_SPECULAR:
#endif // defined(GL_SPECULAR)
#if defined(GL_EMISSION)
case GL_EMISSION:
#endif // defined(GL_EMISSION)
#if defined(GL_AMBIENT_AND_DIFFUSE)
case GL_AMBIENT_AND_DIFFUSE:
#endif // defined(GL_AMBIENT_AND_DIFFUSE)
_needed = 4;
break;
default:
_needed = 1;
break;
}
if (_remaining < _needed) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "length - offset < needed";
goto exit;
}
params_base = (GLfixed *)
_env->GetIntArrayElements(params_ref, (jboolean *)0);
params = params_base + offset;
glGetMaterialxv(
(GLenum)face,
(GLenum)pname,
(GLfixed *)params
);
exit:
if (params_base) {
_env->ReleaseIntArrayElements(params_ref, (jint*)params_base,
_exception ? JNI_ABORT: 0);
}
if (_exception) {
jniThrowException(_env, _exceptionType, _exceptionMessage);
}
}
/* void glGetMaterialxv ( GLenum face, GLenum pname, GLfixed *params ) */
static void
android_glGetMaterialxv__IILjava_nio_IntBuffer_2
(JNIEnv *_env, jobject _this, jint face, jint pname, jobject params_buf) {
jint _exception = 0;
const char * _exceptionType = NULL;
const char * _exceptionMessage = NULL;
jintArray _array = (jintArray) 0;
jint _bufferOffset = (jint) 0;
jint _remaining;
GLfixed *params = (GLfixed *) 0;
if (!params_buf) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "params == null";
goto exit;
}
params = (GLfixed *)getPointer(_env, params_buf, (jarray*)&_array, &_remaining, &_bufferOffset);
int _needed;
switch (pname) {
#if defined(GL_AMBIENT)
case GL_AMBIENT:
#endif // defined(GL_AMBIENT)
#if defined(GL_DIFFUSE)
case GL_DIFFUSE:
#endif // defined(GL_DIFFUSE)
#if defined(GL_SPECULAR)
case GL_SPECULAR:
#endif // defined(GL_SPECULAR)
#if defined(GL_EMISSION)
case GL_EMISSION:
#endif // defined(GL_EMISSION)
#if defined(GL_AMBIENT_AND_DIFFUSE)
case GL_AMBIENT_AND_DIFFUSE:
#endif // defined(GL_AMBIENT_AND_DIFFUSE)
_needed = 4;
break;
default:
_needed = 1;
break;
}
if (_remaining < _needed) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "remaining() < needed";
goto exit;
}
if (params == NULL) {
char * _paramsBase = (char *)_env->GetIntArrayElements(_array, (jboolean *) 0);
params = (GLfixed *) (_paramsBase + _bufferOffset);
}
glGetMaterialxv(
(GLenum)face,
(GLenum)pname,
(GLfixed *)params
);
exit:
if (_array) {
_env->ReleaseIntArrayElements(_array, (jint*)params, _exception ? JNI_ABORT : 0);
}
if (_exception) {
jniThrowException(_env, _exceptionType, _exceptionMessage);
}
}
/* void glGetTexEnvfv ( GLenum env, GLenum pname, GLfloat *params ) */
static void
android_glGetTexEnvfv__II_3FI
(JNIEnv *_env, jobject _this, jint env, jint pname, jfloatArray params_ref, jint offset) {
jint _exception = 0;
const char * _exceptionType = NULL;
const char * _exceptionMessage = NULL;
GLfloat *params_base = (GLfloat *) 0;
jint _remaining;
GLfloat *params = (GLfloat *) 0;
if (!params_ref) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "params == null";
goto exit;
}
if (offset < 0) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "offset < 0";
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
int _needed;
switch (pname) {
#if defined(GL_TEXTURE_ENV_COLOR)
case GL_TEXTURE_ENV_COLOR:
#endif // defined(GL_TEXTURE_ENV_COLOR)
_needed = 4;
break;
default:
_needed = 1;
break;
}
if (_remaining < _needed) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "length - offset < needed";
goto exit;
}
params_base = (GLfloat *)
_env->GetFloatArrayElements(params_ref, (jboolean *)0);
params = params_base + offset;
glGetTexEnvfv(
(GLenum)env,
(GLenum)pname,
(GLfloat *)params
);
exit:
if (params_base) {
_env->ReleaseFloatArrayElements(params_ref, (jfloat*)params_base,
_exception ? JNI_ABORT: 0);
}
if (_exception) {
jniThrowException(_env, _exceptionType, _exceptionMessage);
}
}
/* void glGetTexEnvfv ( GLenum env, GLenum pname, GLfloat *params ) */
static void
android_glGetTexEnvfv__IILjava_nio_FloatBuffer_2
(JNIEnv *_env, jobject _this, jint env, jint pname, jobject params_buf) {
jint _exception = 0;
const char * _exceptionType = NULL;
const char * _exceptionMessage = NULL;
jfloatArray _array = (jfloatArray) 0;
jint _bufferOffset = (jint) 0;
jint _remaining;
GLfloat *params = (GLfloat *) 0;
if (!params_buf) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "params == null";
goto exit;
}
params = (GLfloat *)getPointer(_env, params_buf, (jarray*)&_array, &_remaining, &_bufferOffset);
int _needed;
switch (pname) {
#if defined(GL_TEXTURE_ENV_COLOR)
case GL_TEXTURE_ENV_COLOR:
#endif // defined(GL_TEXTURE_ENV_COLOR)
_needed = 4;
break;
default:
_needed = 1;
break;
}
if (_remaining < _needed) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "remaining() < needed";
goto exit;
}
if (params == NULL) {
char * _paramsBase = (char *)_env->GetFloatArrayElements(_array, (jboolean *) 0);
params = (GLfloat *) (_paramsBase + _bufferOffset);
}
glGetTexEnvfv(
(GLenum)env,
(GLenum)pname,
(GLfloat *)params
);
exit:
if (_array) {
_env->ReleaseFloatArrayElements(_array, (jfloat*)params, _exception ? JNI_ABORT : 0);
}
if (_exception) {
jniThrowException(_env, _exceptionType, _exceptionMessage);
}
}
/* void glGetTexEnviv ( GLenum env, GLenum pname, GLint *params ) */
static void
android_glGetTexEnviv__II_3II
(JNIEnv *_env, jobject _this, jint env, jint pname, jintArray params_ref, jint offset) {
jint _exception = 0;
const char * _exceptionType = NULL;
const char * _exceptionMessage = NULL;
GLint *params_base = (GLint *) 0;
jint _remaining;
GLint *params = (GLint *) 0;
if (!params_ref) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "params == null";
goto exit;
}
if (offset < 0) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "offset < 0";
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
int _needed;
switch (pname) {
#if defined(GL_TEXTURE_ENV_COLOR)
case GL_TEXTURE_ENV_COLOR:
#endif // defined(GL_TEXTURE_ENV_COLOR)
_needed = 4;
break;
default:
_needed = 1;
break;
}
if (_remaining < _needed) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "length - offset < needed";
goto exit;
}
params_base = (GLint *)
_env->GetIntArrayElements(params_ref, (jboolean *)0);
params = params_base + offset;
glGetTexEnviv(
(GLenum)env,
(GLenum)pname,
(GLint *)params
);
exit:
if (params_base) {
_env->ReleaseIntArrayElements(params_ref, (jint*)params_base,
_exception ? JNI_ABORT: 0);
}
if (_exception) {
jniThrowException(_env, _exceptionType, _exceptionMessage);
}
}
/* void glGetTexEnviv ( GLenum env, GLenum pname, GLint *params ) */
static void
android_glGetTexEnviv__IILjava_nio_IntBuffer_2
(JNIEnv *_env, jobject _this, jint env, jint pname, jobject params_buf) {
jint _exception = 0;
const char * _exceptionType = NULL;
const char * _exceptionMessage = NULL;
jintArray _array = (jintArray) 0;
jint _bufferOffset = (jint) 0;
jint _remaining;
GLint *params = (GLint *) 0;
if (!params_buf) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "params == null";
goto exit;
}
params = (GLint *)getPointer(_env, params_buf, (jarray*)&_array, &_remaining, &_bufferOffset);
int _needed;
switch (pname) {
#if defined(GL_TEXTURE_ENV_COLOR)
case GL_TEXTURE_ENV_COLOR:
#endif // defined(GL_TEXTURE_ENV_COLOR)
_needed = 4;
break;
default:
_needed = 1;
break;
}
if (_remaining < _needed) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "remaining() < needed";
goto exit;
}
if (params == NULL) {
char * _paramsBase = (char *)_env->GetIntArrayElements(_array, (jboolean *) 0);
params = (GLint *) (_paramsBase + _bufferOffset);
}
glGetTexEnviv(
(GLenum)env,
(GLenum)pname,
(GLint *)params
);
exit:
if (_array) {
_env->ReleaseIntArrayElements(_array, (jint*)params, _exception ? JNI_ABORT : 0);
}
if (_exception) {
jniThrowException(_env, _exceptionType, _exceptionMessage);
}
}
/* void glGetTexEnvxv ( GLenum env, GLenum pname, GLfixed *params ) */
static void
android_glGetTexEnvxv__II_3II
(JNIEnv *_env, jobject _this, jint env, jint pname, jintArray params_ref, jint offset) {
jint _exception = 0;
const char * _exceptionType = NULL;
const char * _exceptionMessage = NULL;
GLfixed *params_base = (GLfixed *) 0;
jint _remaining;
GLfixed *params = (GLfixed *) 0;
if (!params_ref) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "params == null";
goto exit;
}
if (offset < 0) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "offset < 0";
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
int _needed;
switch (pname) {
#if defined(GL_TEXTURE_ENV_COLOR)
case GL_TEXTURE_ENV_COLOR:
#endif // defined(GL_TEXTURE_ENV_COLOR)
_needed = 4;
break;
default:
_needed = 1;
break;
}
if (_remaining < _needed) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "length - offset < needed";
goto exit;
}
params_base = (GLfixed *)
_env->GetIntArrayElements(params_ref, (jboolean *)0);
params = params_base + offset;
glGetTexEnvxv(
(GLenum)env,
(GLenum)pname,
(GLfixed *)params
);
exit:
if (params_base) {
_env->ReleaseIntArrayElements(params_ref, (jint*)params_base,
_exception ? JNI_ABORT: 0);
}
if (_exception) {
jniThrowException(_env, _exceptionType, _exceptionMessage);
}
}
/* void glGetTexEnvxv ( GLenum env, GLenum pname, GLfixed *params ) */
static void
android_glGetTexEnvxv__IILjava_nio_IntBuffer_2
(JNIEnv *_env, jobject _this, jint env, jint pname, jobject params_buf) {
jint _exception = 0;
const char * _exceptionType = NULL;
const char * _exceptionMessage = NULL;
jintArray _array = (jintArray) 0;
jint _bufferOffset = (jint) 0;
jint _remaining;
GLfixed *params = (GLfixed *) 0;
if (!params_buf) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "params == null";
goto exit;
}
params = (GLfixed *)getPointer(_env, params_buf, (jarray*)&_array, &_remaining, &_bufferOffset);
int _needed;
switch (pname) {
#if defined(GL_TEXTURE_ENV_COLOR)
case GL_TEXTURE_ENV_COLOR:
#endif // defined(GL_TEXTURE_ENV_COLOR)
_needed = 4;
break;
default:
_needed = 1;
break;
}
if (_remaining < _needed) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "remaining() < needed";
goto exit;
}
if (params == NULL) {
char * _paramsBase = (char *)_env->GetIntArrayElements(_array, (jboolean *) 0);
params = (GLfixed *) (_paramsBase + _bufferOffset);
}
glGetTexEnvxv(
(GLenum)env,
(GLenum)pname,
(GLfixed *)params
);
exit:
if (_array) {
_env->ReleaseIntArrayElements(_array, (jint*)params, _exception ? JNI_ABORT : 0);
}
if (_exception) {
jniThrowException(_env, _exceptionType, _exceptionMessage);
}
}
/* void glGetTexParameterfv ( GLenum target, GLenum pname, GLfloat *params ) */
static void
android_glGetTexParameterfv__II_3FI
(JNIEnv *_env, jobject _this, jint target, jint pname, jfloatArray params_ref, jint offset) {
jint _exception = 0;
const char * _exceptionType = NULL;
const char * _exceptionMessage = NULL;
GLfloat *params_base = (GLfloat *) 0;
jint _remaining;
GLfloat *params = (GLfloat *) 0;
if (!params_ref) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "params == null";
goto exit;
}
if (offset < 0) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "offset < 0";
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
if (_remaining < 1) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "length - offset < 1 < needed";
goto exit;
}
params_base = (GLfloat *)
_env->GetFloatArrayElements(params_ref, (jboolean *)0);
params = params_base + offset;
glGetTexParameterfv(
(GLenum)target,
(GLenum)pname,
(GLfloat *)params
);
exit:
if (params_base) {
_env->ReleaseFloatArrayElements(params_ref, (jfloat*)params_base,
_exception ? JNI_ABORT: 0);
}
if (_exception) {
jniThrowException(_env, _exceptionType, _exceptionMessage);
}
}
/* void glGetTexParameterfv ( GLenum target, GLenum pname, GLfloat *params ) */
static void
android_glGetTexParameterfv__IILjava_nio_FloatBuffer_2
(JNIEnv *_env, jobject _this, jint target, jint pname, jobject params_buf) {
jint _exception = 0;
const char * _exceptionType = NULL;
const char * _exceptionMessage = NULL;
jfloatArray _array = (jfloatArray) 0;
jint _bufferOffset = (jint) 0;
jint _remaining;
GLfloat *params = (GLfloat *) 0;
if (!params_buf) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "params == null";
goto exit;
}
params = (GLfloat *)getPointer(_env, params_buf, (jarray*)&_array, &_remaining, &_bufferOffset);
if (_remaining < 1) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "remaining() < 1 < needed";
goto exit;
}
if (params == NULL) {
char * _paramsBase = (char *)_env->GetFloatArrayElements(_array, (jboolean *) 0);
params = (GLfloat *) (_paramsBase + _bufferOffset);
}
glGetTexParameterfv(
(GLenum)target,
(GLenum)pname,
(GLfloat *)params
);
exit:
if (_array) {
_env->ReleaseFloatArrayElements(_array, (jfloat*)params, _exception ? JNI_ABORT : 0);
}
if (_exception) {
jniThrowException(_env, _exceptionType, _exceptionMessage);
}
}
/* void glGetTexParameteriv ( GLenum target, GLenum pname, GLint *params ) */
static void
android_glGetTexParameteriv__II_3II
(JNIEnv *_env, jobject _this, jint target, jint pname, jintArray params_ref, jint offset) {
jint _exception = 0;
const char * _exceptionType = NULL;
const char * _exceptionMessage = NULL;
GLint *params_base = (GLint *) 0;
jint _remaining;
GLint *params = (GLint *) 0;
if (!params_ref) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "params == null";
goto exit;
}
if (offset < 0) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "offset < 0";
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
if (_remaining < 1) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "length - offset < 1 < needed";
goto exit;
}
params_base = (GLint *)
_env->GetIntArrayElements(params_ref, (jboolean *)0);
params = params_base + offset;
glGetTexParameteriv(
(GLenum)target,
(GLenum)pname,
(GLint *)params
);
exit:
if (params_base) {
_env->ReleaseIntArrayElements(params_ref, (jint*)params_base,
_exception ? JNI_ABORT: 0);
}
if (_exception) {
jniThrowException(_env, _exceptionType, _exceptionMessage);
}
}
/* void glGetTexParameteriv ( GLenum target, GLenum pname, GLint *params ) */
static void
android_glGetTexParameteriv__IILjava_nio_IntBuffer_2
(JNIEnv *_env, jobject _this, jint target, jint pname, jobject params_buf) {
jint _exception = 0;
const char * _exceptionType = NULL;
const char * _exceptionMessage = NULL;
jintArray _array = (jintArray) 0;
jint _bufferOffset = (jint) 0;
jint _remaining;
GLint *params = (GLint *) 0;
if (!params_buf) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "params == null";
goto exit;
}
params = (GLint *)getPointer(_env, params_buf, (jarray*)&_array, &_remaining, &_bufferOffset);
if (_remaining < 1) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "remaining() < 1 < needed";
goto exit;
}
if (params == NULL) {
char * _paramsBase = (char *)_env->GetIntArrayElements(_array, (jboolean *) 0);
params = (GLint *) (_paramsBase + _bufferOffset);
}
glGetTexParameteriv(
(GLenum)target,
(GLenum)pname,
(GLint *)params
);
exit:
if (_array) {
_env->ReleaseIntArrayElements(_array, (jint*)params, _exception ? JNI_ABORT : 0);
}
if (_exception) {
jniThrowException(_env, _exceptionType, _exceptionMessage);
}
}
/* void glGetTexParameterxv ( GLenum target, GLenum pname, GLfixed *params ) */
static void
android_glGetTexParameterxv__II_3II
(JNIEnv *_env, jobject _this, jint target, jint pname, jintArray params_ref, jint offset) {
jint _exception = 0;
const char * _exceptionType = NULL;
const char * _exceptionMessage = NULL;
GLfixed *params_base = (GLfixed *) 0;
jint _remaining;
GLfixed *params = (GLfixed *) 0;
if (!params_ref) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "params == null";
goto exit;
}
if (offset < 0) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "offset < 0";
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
if (_remaining < 1) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "length - offset < 1 < needed";
goto exit;
}
params_base = (GLfixed *)
_env->GetIntArrayElements(params_ref, (jboolean *)0);
params = params_base + offset;
glGetTexParameterxv(
(GLenum)target,
(GLenum)pname,
(GLfixed *)params
);
exit:
if (params_base) {
_env->ReleaseIntArrayElements(params_ref, (jint*)params_base,
_exception ? JNI_ABORT: 0);
}
if (_exception) {
jniThrowException(_env, _exceptionType, _exceptionMessage);
}
}
/* void glGetTexParameterxv ( GLenum target, GLenum pname, GLfixed *params ) */
static void
android_glGetTexParameterxv__IILjava_nio_IntBuffer_2
(JNIEnv *_env, jobject _this, jint target, jint pname, jobject params_buf) {
jint _exception = 0;
const char * _exceptionType = NULL;
const char * _exceptionMessage = NULL;
jintArray _array = (jintArray) 0;
jint _bufferOffset = (jint) 0;
jint _remaining;
GLfixed *params = (GLfixed *) 0;
if (!params_buf) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "params == null";
goto exit;
}
params = (GLfixed *)getPointer(_env, params_buf, (jarray*)&_array, &_remaining, &_bufferOffset);
if (_remaining < 1) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "remaining() < 1 < needed";
goto exit;
}
if (params == NULL) {
char * _paramsBase = (char *)_env->GetIntArrayElements(_array, (jboolean *) 0);
params = (GLfixed *) (_paramsBase + _bufferOffset);
}
glGetTexParameterxv(
(GLenum)target,
(GLenum)pname,
(GLfixed *)params
);
exit:
if (_array) {
_env->ReleaseIntArrayElements(_array, (jint*)params, _exception ? JNI_ABORT : 0);
}
if (_exception) {
jniThrowException(_env, _exceptionType, _exceptionMessage);
}
}
/* GLboolean glIsBuffer ( GLuint buffer ) */
static jboolean
android_glIsBuffer__I
(JNIEnv *_env, jobject _this, jint buffer) {
GLboolean _returnValue;
_returnValue = glIsBuffer(
(GLuint)buffer
);
return (jboolean)_returnValue;
}
/* GLboolean glIsEnabled ( GLenum cap ) */
static jboolean
android_glIsEnabled__I
(JNIEnv *_env, jobject _this, jint cap) {
GLboolean _returnValue;
_returnValue = glIsEnabled(
(GLenum)cap
);
return (jboolean)_returnValue;
}
/* GLboolean glIsTexture ( GLuint texture ) */
static jboolean
android_glIsTexture__I
(JNIEnv *_env, jobject _this, jint texture) {
GLboolean _returnValue;
_returnValue = glIsTexture(
(GLuint)texture
);
return (jboolean)_returnValue;
}
/* void glNormalPointer ( GLenum type, GLsizei stride, GLint offset ) */
static void
android_glNormalPointer__III
(JNIEnv *_env, jobject _this, jint type, jint stride, jint offset) {
glNormalPointer(
(GLenum)type,
(GLsizei)stride,
reinterpret_cast<GLvoid *>(offset)
);
}
/* void glPointParameterf ( GLenum pname, GLfloat param ) */
static void
android_glPointParameterf__IF
(JNIEnv *_env, jobject _this, jint pname, jfloat param) {
glPointParameterf(
(GLenum)pname,
(GLfloat)param
);
}
/* void glPointParameterfv ( GLenum pname, const GLfloat *params ) */
static void
android_glPointParameterfv__I_3FI
(JNIEnv *_env, jobject _this, jint pname, jfloatArray params_ref, jint offset) {
jint _exception = 0;
const char * _exceptionType = NULL;
const char * _exceptionMessage = NULL;
GLfloat *params_base = (GLfloat *) 0;
jint _remaining;
GLfloat *params = (GLfloat *) 0;
if (!params_ref) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "params == null";
goto exit;
}
if (offset < 0) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "offset < 0";
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
if (_remaining < 1) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "length - offset < 1 < needed";
goto exit;
}
params_base = (GLfloat *)
_env->GetFloatArrayElements(params_ref, (jboolean *)0);
params = params_base + offset;
glPointParameterfv(
(GLenum)pname,
(GLfloat *)params
);
exit:
if (params_base) {
_env->ReleaseFloatArrayElements(params_ref, (jfloat*)params_base,
JNI_ABORT);
}
if (_exception) {
jniThrowException(_env, _exceptionType, _exceptionMessage);
}
}
/* void glPointParameterfv ( GLenum pname, const GLfloat *params ) */
static void
android_glPointParameterfv__ILjava_nio_FloatBuffer_2
(JNIEnv *_env, jobject _this, jint pname, jobject params_buf) {
jint _exception = 0;
const char * _exceptionType = NULL;
const char * _exceptionMessage = NULL;
jfloatArray _array = (jfloatArray) 0;
jint _bufferOffset = (jint) 0;
jint _remaining;
GLfloat *params = (GLfloat *) 0;
if (!params_buf) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "params == null";
goto exit;
}
params = (GLfloat *)getPointer(_env, params_buf, (jarray*)&_array, &_remaining, &_bufferOffset);
if (_remaining < 1) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "remaining() < 1 < needed";
goto exit;
}
if (params == NULL) {
char * _paramsBase = (char *)_env->GetFloatArrayElements(_array, (jboolean *) 0);
params = (GLfloat *) (_paramsBase + _bufferOffset);
}
glPointParameterfv(
(GLenum)pname,
(GLfloat *)params
);
exit:
if (_array) {
_env->ReleaseFloatArrayElements(_array, (jfloat*)params, JNI_ABORT);
}
if (_exception) {
jniThrowException(_env, _exceptionType, _exceptionMessage);
}
}
/* void glPointParameterx ( GLenum pname, GLfixed param ) */
static void
android_glPointParameterx__II
(JNIEnv *_env, jobject _this, jint pname, jint param) {
glPointParameterx(
(GLenum)pname,
(GLfixed)param
);
}
/* void glPointParameterxv ( GLenum pname, const GLfixed *params ) */
static void
android_glPointParameterxv__I_3II
(JNIEnv *_env, jobject _this, jint pname, jintArray params_ref, jint offset) {
jint _exception = 0;
const char * _exceptionType = NULL;
const char * _exceptionMessage = NULL;
GLfixed *params_base = (GLfixed *) 0;
jint _remaining;
GLfixed *params = (GLfixed *) 0;
if (!params_ref) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "params == null";
goto exit;
}
if (offset < 0) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "offset < 0";
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
if (_remaining < 1) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "length - offset < 1 < needed";
goto exit;
}
params_base = (GLfixed *)
_env->GetIntArrayElements(params_ref, (jboolean *)0);
params = params_base + offset;
glPointParameterxv(
(GLenum)pname,
(GLfixed *)params
);
exit:
if (params_base) {
_env->ReleaseIntArrayElements(params_ref, (jint*)params_base,
JNI_ABORT);
}
if (_exception) {
jniThrowException(_env, _exceptionType, _exceptionMessage);
}
}
/* void glPointParameterxv ( GLenum pname, const GLfixed *params ) */
static void
android_glPointParameterxv__ILjava_nio_IntBuffer_2
(JNIEnv *_env, jobject _this, jint pname, jobject params_buf) {
jint _exception = 0;
const char * _exceptionType = NULL;
const char * _exceptionMessage = NULL;
jintArray _array = (jintArray) 0;
jint _bufferOffset = (jint) 0;
jint _remaining;
GLfixed *params = (GLfixed *) 0;
if (!params_buf) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "params == null";
goto exit;
}
params = (GLfixed *)getPointer(_env, params_buf, (jarray*)&_array, &_remaining, &_bufferOffset);
if (_remaining < 1) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "remaining() < 1 < needed";
goto exit;
}
if (params == NULL) {
char * _paramsBase = (char *)_env->GetIntArrayElements(_array, (jboolean *) 0);
params = (GLfixed *) (_paramsBase + _bufferOffset);
}
glPointParameterxv(
(GLenum)pname,
(GLfixed *)params
);
exit:
if (_array) {
_env->ReleaseIntArrayElements(_array, (jint*)params, JNI_ABORT);
}
if (_exception) {
jniThrowException(_env, _exceptionType, _exceptionMessage);
}
}
/* void glPointSizePointerOES ( GLenum type, GLsizei stride, const GLvoid *pointer ) */
static void
android_glPointSizePointerOESBounds__IILjava_nio_Buffer_2I
(JNIEnv *_env, jobject _this, jint type, jint stride, jobject pointer_buf, jint remaining) {
jint _exception = 0;
const char * _exceptionType = NULL;
const char * _exceptionMessage = NULL;
jarray _array = (jarray) 0;
jint _bufferOffset = (jint) 0;
jint _remaining;
GLvoid *pointer = (GLvoid *) 0;
if (pointer_buf) {
pointer = (GLvoid *) getDirectBufferPointer(_env, pointer_buf);
if ( ! pointer ) {
return;
}
}
glPointSizePointerOESBounds(
(GLenum)type,
(GLsizei)stride,
(GLvoid *)pointer,
(GLsizei)remaining
);
if (_exception) {
jniThrowException(_env, _exceptionType, _exceptionMessage);
}
}
/* void glTexCoordPointer ( GLint size, GLenum type, GLsizei stride, GLint offset ) */
static void
android_glTexCoordPointer__IIII
(JNIEnv *_env, jobject _this, jint size, jint type, jint stride, jint offset) {
glTexCoordPointer(
(GLint)size,
(GLenum)type,
(GLsizei)stride,
reinterpret_cast<GLvoid *>(offset)
);
}
/* void glTexEnvi ( GLenum target, GLenum pname, GLint param ) */
static void
android_glTexEnvi__III
(JNIEnv *_env, jobject _this, jint target, jint pname, jint param) {
glTexEnvi(
(GLenum)target,
(GLenum)pname,
(GLint)param
);
}
/* void glTexEnviv ( GLenum target, GLenum pname, const GLint *params ) */
static void
android_glTexEnviv__II_3II
(JNIEnv *_env, jobject _this, jint target, jint pname, jintArray params_ref, jint offset) {
jint _exception = 0;
const char * _exceptionType = NULL;
const char * _exceptionMessage = NULL;
GLint *params_base = (GLint *) 0;
jint _remaining;
GLint *params = (GLint *) 0;
if (!params_ref) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "params == null";
goto exit;
}
if (offset < 0) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "offset < 0";
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
int _needed;
switch (pname) {
#if defined(GL_TEXTURE_ENV_COLOR)
case GL_TEXTURE_ENV_COLOR:
#endif // defined(GL_TEXTURE_ENV_COLOR)
_needed = 4;
break;
default:
_needed = 1;
break;
}
if (_remaining < _needed) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "length - offset < needed";
goto exit;
}
params_base = (GLint *)
_env->GetIntArrayElements(params_ref, (jboolean *)0);
params = params_base + offset;
glTexEnviv(
(GLenum)target,
(GLenum)pname,
(GLint *)params
);
exit:
if (params_base) {
_env->ReleaseIntArrayElements(params_ref, (jint*)params_base,
JNI_ABORT);
}
if (_exception) {
jniThrowException(_env, _exceptionType, _exceptionMessage);
}
}
/* void glTexEnviv ( GLenum target, GLenum pname, const GLint *params ) */
static void
android_glTexEnviv__IILjava_nio_IntBuffer_2
(JNIEnv *_env, jobject _this, jint target, jint pname, jobject params_buf) {
jint _exception = 0;
const char * _exceptionType = NULL;
const char * _exceptionMessage = NULL;
jintArray _array = (jintArray) 0;
jint _bufferOffset = (jint) 0;
jint _remaining;
GLint *params = (GLint *) 0;
if (!params_buf) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "params == null";
goto exit;
}
params = (GLint *)getPointer(_env, params_buf, (jarray*)&_array, &_remaining, &_bufferOffset);
int _needed;
switch (pname) {
#if defined(GL_TEXTURE_ENV_COLOR)
case GL_TEXTURE_ENV_COLOR:
#endif // defined(GL_TEXTURE_ENV_COLOR)
_needed = 4;
break;
default:
_needed = 1;
break;
}
if (_remaining < _needed) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "remaining() < needed";
goto exit;
}
if (params == NULL) {
char * _paramsBase = (char *)_env->GetIntArrayElements(_array, (jboolean *) 0);
params = (GLint *) (_paramsBase + _bufferOffset);
}
glTexEnviv(
(GLenum)target,
(GLenum)pname,
(GLint *)params
);
exit:
if (_array) {
_env->ReleaseIntArrayElements(_array, (jint*)params, JNI_ABORT);
}
if (_exception) {
jniThrowException(_env, _exceptionType, _exceptionMessage);
}
}
/* void glTexParameterfv ( GLenum target, GLenum pname, const GLfloat *params ) */
static void
android_glTexParameterfv__II_3FI
(JNIEnv *_env, jobject _this, jint target, jint pname, jfloatArray params_ref, jint offset) {
jint _exception = 0;
const char * _exceptionType = NULL;
const char * _exceptionMessage = NULL;
GLfloat *params_base = (GLfloat *) 0;
jint _remaining;
GLfloat *params = (GLfloat *) 0;
if (!params_ref) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "params == null";
goto exit;
}
if (offset < 0) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "offset < 0";
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
if (_remaining < 1) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "length - offset < 1 < needed";
goto exit;
}
params_base = (GLfloat *)
_env->GetFloatArrayElements(params_ref, (jboolean *)0);
params = params_base + offset;
glTexParameterfv(
(GLenum)target,
(GLenum)pname,
(GLfloat *)params
);
exit:
if (params_base) {
_env->ReleaseFloatArrayElements(params_ref, (jfloat*)params_base,
JNI_ABORT);
}
if (_exception) {
jniThrowException(_env, _exceptionType, _exceptionMessage);
}
}
/* void glTexParameterfv ( GLenum target, GLenum pname, const GLfloat *params ) */
static void
android_glTexParameterfv__IILjava_nio_FloatBuffer_2
(JNIEnv *_env, jobject _this, jint target, jint pname, jobject params_buf) {
jint _exception = 0;
const char * _exceptionType = NULL;
const char * _exceptionMessage = NULL;
jfloatArray _array = (jfloatArray) 0;
jint _bufferOffset = (jint) 0;
jint _remaining;
GLfloat *params = (GLfloat *) 0;
if (!params_buf) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "params == null";
goto exit;
}
params = (GLfloat *)getPointer(_env, params_buf, (jarray*)&_array, &_remaining, &_bufferOffset);
if (_remaining < 1) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "remaining() < 1 < needed";
goto exit;
}
if (params == NULL) {
char * _paramsBase = (char *)_env->GetFloatArrayElements(_array, (jboolean *) 0);
params = (GLfloat *) (_paramsBase + _bufferOffset);
}
glTexParameterfv(
(GLenum)target,
(GLenum)pname,
(GLfloat *)params
);
exit:
if (_array) {
_env->ReleaseFloatArrayElements(_array, (jfloat*)params, JNI_ABORT);
}
if (_exception) {
jniThrowException(_env, _exceptionType, _exceptionMessage);
}
}
/* void glTexParameteri ( GLenum target, GLenum pname, GLint param ) */
static void
android_glTexParameteri__III
(JNIEnv *_env, jobject _this, jint target, jint pname, jint param) {
glTexParameteri(
(GLenum)target,
(GLenum)pname,
(GLint)param
);
}
/* void glTexParameteriv ( GLenum target, GLenum pname, const GLint *params ) */
static void
android_glTexParameteriv__II_3II
(JNIEnv *_env, jobject _this, jint target, jint pname, jintArray params_ref, jint offset) {
jint _exception = 0;
const char * _exceptionType = NULL;
const char * _exceptionMessage = NULL;
GLint *params_base = (GLint *) 0;
jint _remaining;
GLint *params = (GLint *) 0;
if (!params_ref) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "params == null";
goto exit;
}
if (offset < 0) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "offset < 0";
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
if (_remaining < 1) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "length - offset < 1 < needed";
goto exit;
}
params_base = (GLint *)
_env->GetIntArrayElements(params_ref, (jboolean *)0);
params = params_base + offset;
glTexParameteriv(
(GLenum)target,
(GLenum)pname,
(GLint *)params
);
exit:
if (params_base) {
_env->ReleaseIntArrayElements(params_ref, (jint*)params_base,
JNI_ABORT);
}
if (_exception) {
jniThrowException(_env, _exceptionType, _exceptionMessage);
}
}
/* void glTexParameteriv ( GLenum target, GLenum pname, const GLint *params ) */
static void
android_glTexParameteriv__IILjava_nio_IntBuffer_2
(JNIEnv *_env, jobject _this, jint target, jint pname, jobject params_buf) {
jint _exception = 0;
const char * _exceptionType = NULL;
const char * _exceptionMessage = NULL;
jintArray _array = (jintArray) 0;
jint _bufferOffset = (jint) 0;
jint _remaining;
GLint *params = (GLint *) 0;
if (!params_buf) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "params == null";
goto exit;
}
params = (GLint *)getPointer(_env, params_buf, (jarray*)&_array, &_remaining, &_bufferOffset);
if (_remaining < 1) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "remaining() < 1 < needed";
goto exit;
}
if (params == NULL) {
char * _paramsBase = (char *)_env->GetIntArrayElements(_array, (jboolean *) 0);
params = (GLint *) (_paramsBase + _bufferOffset);
}
glTexParameteriv(
(GLenum)target,
(GLenum)pname,
(GLint *)params
);
exit:
if (_array) {
_env->ReleaseIntArrayElements(_array, (jint*)params, JNI_ABORT);
}
if (_exception) {
jniThrowException(_env, _exceptionType, _exceptionMessage);
}
}
/* void glTexParameterxv ( GLenum target, GLenum pname, const GLfixed *params ) */
static void
android_glTexParameterxv__II_3II
(JNIEnv *_env, jobject _this, jint target, jint pname, jintArray params_ref, jint offset) {
jint _exception = 0;
const char * _exceptionType = NULL;
const char * _exceptionMessage = NULL;
GLfixed *params_base = (GLfixed *) 0;
jint _remaining;
GLfixed *params = (GLfixed *) 0;
if (!params_ref) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "params == null";
goto exit;
}
if (offset < 0) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "offset < 0";
goto exit;
}
_remaining = _env->GetArrayLength(params_ref) - offset;
if (_remaining < 1) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "length - offset < 1 < needed";
goto exit;
}
params_base = (GLfixed *)
_env->GetIntArrayElements(params_ref, (jboolean *)0);
params = params_base + offset;
glTexParameterxv(
(GLenum)target,
(GLenum)pname,
(GLfixed *)params
);
exit:
if (params_base) {
_env->ReleaseIntArrayElements(params_ref, (jint*)params_base,
JNI_ABORT);
}
if (_exception) {
jniThrowException(_env, _exceptionType, _exceptionMessage);
}
}
/* void glTexParameterxv ( GLenum target, GLenum pname, const GLfixed *params ) */
static void
android_glTexParameterxv__IILjava_nio_IntBuffer_2
(JNIEnv *_env, jobject _this, jint target, jint pname, jobject params_buf) {
jint _exception = 0;
const char * _exceptionType = NULL;
const char * _exceptionMessage = NULL;
jintArray _array = (jintArray) 0;
jint _bufferOffset = (jint) 0;
jint _remaining;
GLfixed *params = (GLfixed *) 0;
if (!params_buf) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "params == null";
goto exit;
}
params = (GLfixed *)getPointer(_env, params_buf, (jarray*)&_array, &_remaining, &_bufferOffset);
if (_remaining < 1) {
_exception = 1;
_exceptionType = "java/lang/IllegalArgumentException";
_exceptionMessage = "remaining() < 1 < needed";
goto exit;
}
if (params == NULL) {
char * _paramsBase = (char *)_env->GetIntArrayElements(_array, (jboolean *) 0);
params = (GLfixed *) (_paramsBase + _bufferOffset);
}
glTexParameterxv(
(GLenum)target,
(GLenum)pname,
(GLfixed *)params
);
exit:
if (_array) {
_env->ReleaseIntArrayElements(_array, (jint*)params, JNI_ABORT);
}
if (_exception) {
jniThrowException(_env, _exceptionType, _exceptionMessage);
}
}
/* void glVertexPointer ( GLint size, GLenum type, GLsizei stride, GLint offset ) */
static void
android_glVertexPointer__IIII
(JNIEnv *_env, jobject _this, jint size, jint type, jint stride, jint offset) {
glVertexPointer(
(GLint)size,
(GLenum)type,
(GLsizei)stride,
reinterpret_cast<GLvoid *>(offset)
);
}
static const char *classPathName = "android/opengl/GLES11";
static const JNINativeMethod methods[] = {
{"_nativeClassInit", "()V", (void*)nativeClassInit },
{"glBindBuffer", "(II)V", (void *) android_glBindBuffer__II },
{"glBufferData", "(IILjava/nio/Buffer;I)V", (void *) android_glBufferData__IILjava_nio_Buffer_2I },
{"glBufferSubData", "(IIILjava/nio/Buffer;)V", (void *) android_glBufferSubData__IIILjava_nio_Buffer_2 },
{"glClipPlanef", "(I[FI)V", (void *) android_glClipPlanef__I_3FI },
{"glClipPlanef", "(ILjava/nio/FloatBuffer;)V", (void *) android_glClipPlanef__ILjava_nio_FloatBuffer_2 },
{"glClipPlanex", "(I[II)V", (void *) android_glClipPlanex__I_3II },
{"glClipPlanex", "(ILjava/nio/IntBuffer;)V", (void *) android_glClipPlanex__ILjava_nio_IntBuffer_2 },
{"glColor4ub", "(BBBB)V", (void *) android_glColor4ub__BBBB },
{"glColorPointer", "(IIII)V", (void *) android_glColorPointer__IIII },
{"glDeleteBuffers", "(I[II)V", (void *) android_glDeleteBuffers__I_3II },
{"glDeleteBuffers", "(ILjava/nio/IntBuffer;)V", (void *) android_glDeleteBuffers__ILjava_nio_IntBuffer_2 },
{"glDrawElements", "(IIII)V", (void *) android_glDrawElements__IIII },
{"glGenBuffers", "(I[II)V", (void *) android_glGenBuffers__I_3II },
{"glGenBuffers", "(ILjava/nio/IntBuffer;)V", (void *) android_glGenBuffers__ILjava_nio_IntBuffer_2 },
{"glGetBooleanv", "(I[ZI)V", (void *) android_glGetBooleanv__I_3ZI },
{"glGetBooleanv", "(ILjava/nio/IntBuffer;)V", (void *) android_glGetBooleanv__ILjava_nio_IntBuffer_2 },
{"glGetBufferParameteriv", "(II[II)V", (void *) android_glGetBufferParameteriv__II_3II },
{"glGetBufferParameteriv", "(IILjava/nio/IntBuffer;)V", (void *) android_glGetBufferParameteriv__IILjava_nio_IntBuffer_2 },
{"glGetClipPlanef", "(I[FI)V", (void *) android_glGetClipPlanef__I_3FI },
{"glGetClipPlanef", "(ILjava/nio/FloatBuffer;)V", (void *) android_glGetClipPlanef__ILjava_nio_FloatBuffer_2 },
{"glGetClipPlanex", "(I[II)V", (void *) android_glGetClipPlanex__I_3II },
{"glGetClipPlanex", "(ILjava/nio/IntBuffer;)V", (void *) android_glGetClipPlanex__ILjava_nio_IntBuffer_2 },
{"glGetFixedv", "(I[II)V", (void *) android_glGetFixedv__I_3II },
{"glGetFixedv", "(ILjava/nio/IntBuffer;)V", (void *) android_glGetFixedv__ILjava_nio_IntBuffer_2 },
{"glGetFloatv", "(I[FI)V", (void *) android_glGetFloatv__I_3FI },
{"glGetFloatv", "(ILjava/nio/FloatBuffer;)V", (void *) android_glGetFloatv__ILjava_nio_FloatBuffer_2 },
{"glGetLightfv", "(II[FI)V", (void *) android_glGetLightfv__II_3FI },
{"glGetLightfv", "(IILjava/nio/FloatBuffer;)V", (void *) android_glGetLightfv__IILjava_nio_FloatBuffer_2 },
{"glGetLightxv", "(II[II)V", (void *) android_glGetLightxv__II_3II },
{"glGetLightxv", "(IILjava/nio/IntBuffer;)V", (void *) android_glGetLightxv__IILjava_nio_IntBuffer_2 },
{"glGetMaterialfv", "(II[FI)V", (void *) android_glGetMaterialfv__II_3FI },
{"glGetMaterialfv", "(IILjava/nio/FloatBuffer;)V", (void *) android_glGetMaterialfv__IILjava_nio_FloatBuffer_2 },
{"glGetMaterialxv", "(II[II)V", (void *) android_glGetMaterialxv__II_3II },
{"glGetMaterialxv", "(IILjava/nio/IntBuffer;)V", (void *) android_glGetMaterialxv__IILjava_nio_IntBuffer_2 },
{"glGetTexEnvfv", "(II[FI)V", (void *) android_glGetTexEnvfv__II_3FI },
{"glGetTexEnvfv", "(IILjava/nio/FloatBuffer;)V", (void *) android_glGetTexEnvfv__IILjava_nio_FloatBuffer_2 },
{"glGetTexEnviv", "(II[II)V", (void *) android_glGetTexEnviv__II_3II },
{"glGetTexEnviv", "(IILjava/nio/IntBuffer;)V", (void *) android_glGetTexEnviv__IILjava_nio_IntBuffer_2 },
{"glGetTexEnvxv", "(II[II)V", (void *) android_glGetTexEnvxv__II_3II },
{"glGetTexEnvxv", "(IILjava/nio/IntBuffer;)V", (void *) android_glGetTexEnvxv__IILjava_nio_IntBuffer_2 },
{"glGetTexParameterfv", "(II[FI)V", (void *) android_glGetTexParameterfv__II_3FI },
{"glGetTexParameterfv", "(IILjava/nio/FloatBuffer;)V", (void *) android_glGetTexParameterfv__IILjava_nio_FloatBuffer_2 },
{"glGetTexParameteriv", "(II[II)V", (void *) android_glGetTexParameteriv__II_3II },
{"glGetTexParameteriv", "(IILjava/nio/IntBuffer;)V", (void *) android_glGetTexParameteriv__IILjava_nio_IntBuffer_2 },
{"glGetTexParameterxv", "(II[II)V", (void *) android_glGetTexParameterxv__II_3II },
{"glGetTexParameterxv", "(IILjava/nio/IntBuffer;)V", (void *) android_glGetTexParameterxv__IILjava_nio_IntBuffer_2 },
{"glIsBuffer", "(I)Z", (void *) android_glIsBuffer__I },
{"glIsEnabled", "(I)Z", (void *) android_glIsEnabled__I },
{"glIsTexture", "(I)Z", (void *) android_glIsTexture__I },
{"glNormalPointer", "(III)V", (void *) android_glNormalPointer__III },
{"glPointParameterf", "(IF)V", (void *) android_glPointParameterf__IF },
{"glPointParameterfv", "(I[FI)V", (void *) android_glPointParameterfv__I_3FI },
{"glPointParameterfv", "(ILjava/nio/FloatBuffer;)V", (void *) android_glPointParameterfv__ILjava_nio_FloatBuffer_2 },
{"glPointParameterx", "(II)V", (void *) android_glPointParameterx__II },
{"glPointParameterxv", "(I[II)V", (void *) android_glPointParameterxv__I_3II },
{"glPointParameterxv", "(ILjava/nio/IntBuffer;)V", (void *) android_glPointParameterxv__ILjava_nio_IntBuffer_2 },
{"glPointSizePointerOESBounds", "(IILjava/nio/Buffer;I)V", (void *) android_glPointSizePointerOESBounds__IILjava_nio_Buffer_2I },
{"glTexCoordPointer", "(IIII)V", (void *) android_glTexCoordPointer__IIII },
{"glTexEnvi", "(III)V", (void *) android_glTexEnvi__III },
{"glTexEnviv", "(II[II)V", (void *) android_glTexEnviv__II_3II },
{"glTexEnviv", "(IILjava/nio/IntBuffer;)V", (void *) android_glTexEnviv__IILjava_nio_IntBuffer_2 },
{"glTexParameterfv", "(II[FI)V", (void *) android_glTexParameterfv__II_3FI },
{"glTexParameterfv", "(IILjava/nio/FloatBuffer;)V", (void *) android_glTexParameterfv__IILjava_nio_FloatBuffer_2 },
{"glTexParameteri", "(III)V", (void *) android_glTexParameteri__III },
{"glTexParameteriv", "(II[II)V", (void *) android_glTexParameteriv__II_3II },
{"glTexParameteriv", "(IILjava/nio/IntBuffer;)V", (void *) android_glTexParameteriv__IILjava_nio_IntBuffer_2 },
{"glTexParameterxv", "(II[II)V", (void *) android_glTexParameterxv__II_3II },
{"glTexParameterxv", "(IILjava/nio/IntBuffer;)V", (void *) android_glTexParameterxv__IILjava_nio_IntBuffer_2 },
{"glVertexPointer", "(IIII)V", (void *) android_glVertexPointer__IIII },
};
int register_android_opengl_jni_GLES11(JNIEnv *_env)
{
int err;
err = android::AndroidRuntime::registerNativeMethods(_env, classPathName, methods, NELEM(methods));
return err;
}
| 31.685697
| 129
| 0.644617
|
rio-31
|
39f29b35292f353d7248f2c14e87aa69ce48235a
| 2,824
|
cpp
|
C++
|
salmap_rv/src/salmap_rv_interface.cpp
|
flyingfalling/salmap_rv
|
61827a42f456afcd9c930646de33bc3f9533e3e2
|
[
"MIT"
] | 1
|
2022-02-17T03:05:40.000Z
|
2022-02-17T03:05:40.000Z
|
salmap_rv/src/salmap_rv_interface.cpp
|
flyingfalling/salmap_rv
|
61827a42f456afcd9c930646de33bc3f9533e3e2
|
[
"MIT"
] | null | null | null |
salmap_rv/src/salmap_rv_interface.cpp
|
flyingfalling/salmap_rv
|
61827a42f456afcd9c930646de33bc3f9533e3e2
|
[
"MIT"
] | null | null | null |
#include <salmap_rv/include/salmap_rv_interface.hpp>
#include <salmap_rv/include/salmap.hpp>
#include <salmap_rv/include/itti_salmap.hpp>
#include <salmap_rv/include/param_set.hpp>
#include <salmap_rv/include/util_functs.hpp>
using namespace salmap_rv;
int salmap_vers( )
{
return salmap_rv::SalMap::VERSION;
}
void* salmap_ptr_init( const std::string& _paramset_fname, const float64_t input_dva_wid, const float64_t input_dva_hei )
{
std::string paramset_fname(_paramset_fname);
param_set p = itti_formal_default_params();
if( false == paramset_fname.empty() )
{
p.fromfile( paramset_fname );
}
p.set<int64_t>("dt_nsec", 1 );
p.set<float64_t>("input_dva_wid", input_dva_wid);
p.set<float64_t>("input_dva_hei", input_dva_hei);
p.enumerate();
SalMap* cpusalmap = new SalMap();
make_itti_dyadic_cpu_weighted_formal( p, *cpusalmap, nullptr );
return (void*)cpusalmap;
}
void salmap_ptr_uninit( void* _salmap )
{
SalMap* salmap = (SalMap*)_salmap ;
delete salmap;
}
void salmap_add_input( void* _salmap, const std::string& _inputmapname, cv::Mat& inputmat )
{
std::string inputmapname( _inputmapname );
SalMap* salmap = (SalMap*) _salmap;
salmap->add_input_direct_realtime( inputmapname, inputmat, salmap->get_realtime_sec() );
}
int64_t salmap_update( void* _salmap )
{
SalMap* salmap = (SalMap*) _salmap;
bool updated = salmap->update();
int64_t time = -1;
if( updated )
{
time = salmap->get_time_nsec();
}
return time;
}
cv::Mat salmap_get_map_now_nickname( void* _salmap, const std::string& _filtername, const std::string& _mapname )
{
SalMap* salmap = (SalMap*) _salmap;
cv::Mat ret = salmap->get_map_now_nickname( _filtername, _mapname, cv::Size(0,0) );
return ret;
}
cv::Mat salmap_get_map_pretty( void* _salmap, const std::string& _filtername, const std::string& _mapname, const std::string& _overlaywithinputmap, const float64_t alpha, const int resize_wid_pix )
{
SalMap* salmap = (SalMap*) _salmap;
cv::Mat raw = salmap->get_map_now_nickname( salmap_rv::SalMap::INPUT_FILTER_NICKNAME, _overlaywithinputmap );
cv::Mat sal = salmap->get_map_now_nickname( _filtername, _mapname );
fflush(stderr);
cv::Mat ret;
if( raw.empty() || sal.empty() )
{
fprintf(stderr, "REV: LOLOLOLOL raw or sal was empty?\n");
return ret;
}
int interp = cv::INTER_LINEAR;
cv::Mat rraw = resize_wid( raw, resize_wid_pix, interp );
cv::Mat rsal = resize_wid( sal, resize_wid_pix, interp );
cv::Mat colorsal = apply_color( rsal );
ret = overlay_salmap( rraw, colorsal, alpha, interp );
return ret;
}
| 25.214286
| 199
| 0.661827
|
flyingfalling
|
39f2e3009dc60767bc21fd301b10c4e591572eea
| 1,139
|
cpp
|
C++
|
src/leetcode/q0101_0200/q0102.cpp
|
jielyu/leetcode
|
ce5327f5e5ceaa867ea2ddd58a93bfb02b427810
|
[
"MIT"
] | 9
|
2020-04-09T12:37:50.000Z
|
2021-04-01T14:01:14.000Z
|
src/leetcode/q0101_0200/q0102.cpp
|
jielyu/leetcode
|
ce5327f5e5ceaa867ea2ddd58a93bfb02b427810
|
[
"MIT"
] | 3
|
2020-05-05T02:43:54.000Z
|
2020-05-20T11:12:16.000Z
|
src/leetcode/q0101_0200/q0102.cpp
|
jielyu/leetcode
|
ce5327f5e5ceaa867ea2ddd58a93bfb02b427810
|
[
"MIT"
] | 5
|
2020-04-17T02:32:10.000Z
|
2020-05-20T10:12:26.000Z
|
/*
#面试刷题# 第0113期
#Leetcode# Q0102 按层次顺序遍历二叉树
难度:中
给定一个二叉树,返回其节点值的级别顺序遍历。即,从左到右,逐级递进)。
示例:
Input: [3,9,20,null,null,15,7]
Output: [[3],[9,20],[15,7]]
*/
#include "leetcode.h"
namespace q0102
{
template<typename T>
bool run_testcases() {
T slt;
}
// Runtime: 4 ms, faster than 94.38%
// Memory Usage: 12.5 MB, less than 100.00%
class Solution {
public:
vector<vector<int>> levelOrder(TreeNode* root) {
vector<vector<int>> ret;
if (!root) {return ret;}
vector<int> mid;
// create a queue to store children nodes
queue<TreeNode*> buff;
buff.push(root);
while (buff.size() > 0) {
mid.clear();
// traversal nodes with the same level
for (int i = buff.size(); i > 0; --i) {
auto * node = buff.front(); buff.pop();
mid.push_back(node->val);
// add child nodes to the buff
if (node->left) {buff.push(node->left);}
if (node->right) {buff.push(node->right);}
}
ret.push_back(mid);
}
return ret;
}
};
} // namespace q0102
| 23.729167
| 58
| 0.535558
|
jielyu
|
39f474ef79a775e7cae39e502c4f1fcf981e7cf3
| 1,528
|
cpp
|
C++
|
dev_esp/lib/GasValue/GasValue.cpp
|
Granyy/SensAir
|
f56458322975a67793c6be92944e370cbd0117b2
|
[
"MIT"
] | 2
|
2021-08-12T14:37:43.000Z
|
2021-08-17T13:59:35.000Z
|
dev_esp/lib/GasValue/GasValue.cpp
|
Granyy/SensAir
|
f56458322975a67793c6be92944e370cbd0117b2
|
[
"MIT"
] | null | null | null |
dev_esp/lib/GasValue/GasValue.cpp
|
Granyy/SensAir
|
f56458322975a67793c6be92944e370cbd0117b2
|
[
"MIT"
] | 2
|
2021-08-17T13:59:36.000Z
|
2021-11-05T03:46:12.000Z
|
/******************************************************************************/
/* @TITLE : GasValue.cpp */
/* @VERSION : 1.0 */
/* @CREATION : dec 27, 2017 */
/* @MODIFICATION : dec 27, 2017 */
/* @AUTHOR : Leo GRANIER */
/******************************************************************************/
#include "GasValue.h"
GasValue::GasValue() {
gasSemaphore = xSemaphoreCreateBinary();
xSemaphoreGive(gasSemaphore);
gasValue = {0,0,0,0};
gasRawValue = {0,0,0,0};
}
struct gasRaw GasValue::get_gasRawValue() {
struct gasRaw _gasRawValue;
if(xSemaphoreTake(gasSemaphore,portMAX_DELAY) == pdTRUE) {
_gasRawValue = gasRawValue;
xSemaphoreGive(gasSemaphore);
}
return _gasRawValue;
}
struct gas GasValue::get_gasValue() {
struct gas _gasValue;
if(xSemaphoreTake(gasSemaphore,portMAX_DELAY) == pdTRUE) {
_gasValue = gasValue;
xSemaphoreGive(gasSemaphore);
}
return _gasValue;
}
void GasValue::set_gasValue(struct gas _gasValue) {
if(xSemaphoreTake(gasSemaphore,portMAX_DELAY) == pdTRUE) {
gasValue = _gasValue;
xSemaphoreGive(gasSemaphore);
}
}
void GasValue::set_gasRawValue(struct gasRaw _gasRawValue) {
if(xSemaphoreTake(gasSemaphore,portMAX_DELAY) == pdTRUE) {
gasRawValue = _gasRawValue;
xSemaphoreGive(gasSemaphore);
}
}
| 29.960784
| 80
| 0.524869
|
Granyy
|
39f491a0815135ec3d8aff68d39ff960d16fa93f
| 25,050
|
cpp
|
C++
|
c-transactions-extractor/code/main.cpp
|
rodrigo-brito/co-change-analysis
|
298bb5437371ab29fb94a9e2f9012d3a5cf033f7
|
[
"MIT"
] | 1
|
2019-04-15T22:27:52.000Z
|
2019-04-15T22:27:52.000Z
|
c-transactions-extractor/code/main.cpp
|
rodrigo-brito/co-change-analysis
|
298bb5437371ab29fb94a9e2f9012d3a5cf033f7
|
[
"MIT"
] | 1
|
2019-05-09T01:55:12.000Z
|
2019-05-09T02:14:41.000Z
|
c-transactions-extractor/code/main.cpp
|
rodrigo-brito/co-change-analysis
|
298bb5437371ab29fb94a9e2f9012d3a5cf033f7
|
[
"MIT"
] | 2
|
2019-05-09T01:41:29.000Z
|
2019-06-12T18:59:45.000Z
|
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#define assert(x)
#define STB_LEAKCHECK_IMPLEMENTATION
#include "stb_leakcheck.h"
#include "dd_array.cpp"
#define min(a, b) (a < b ? a:b)
#define max(a, b) (a > b ? a:b)
#include "Memory.h"
#include "Array.cpp"
#include "EntireFile.cpp"
#include "FileReader.cpp"
#include "FileWriter.cpp"
#include "String.cpp"
#include "string_utils.cpp"
#define ANSI_COLOR_YELLOW(text) "\x1b[33m" text "\x1b[0m"
#define LOOP_SIZE 50
enum TokenType {
TokenTypeNone,
TokenTypeLeftBrace,
TokenTypeRightBrace,
TokenTypeLeftParentesis,
TokenTypeRightParentesis,
TokenTypeLineComment,
TokenTypeBlockComment,
TokenTypeEOF,
TokenTypeUnknown,
TokenTypeCount
};
struct Token {
TokenType type;
char* string;
int charIndex;
int line;
};
struct ChangeInfo {
int oldFileLine;
int oldFileCount;
int newFileLine;
int newFileCount;
};
struct DiffChunk {
char oldFile[256];
char newFile[256];
ChangeInfo* changes;
//char** functionsChanged;
};
struct CommitInfo {
char hash[256];
DiffChunk* chunks;
char** functionsChanged;
};
struct FunctionInFile {
char name[256];
int firstLine;
int lastLine;
bool changed;
};
Token readNextToken(FileReader& reader) {
//while (isWhiteSpace(reader.content[reader.at]) || startWithReader(reader, "//") || startWithReader(reader, "#define") || startWithReader(reader, "/*")) {
while (isWhiteSpace(reader.content[reader.at])
|| startWithReader(reader, "/*")
|| startWithReader(reader, "//")
|| startWithReader(reader, "#define")
|| (startWithReader(reader, "\"") && *(reader.content+reader.at-1) != '\\')) {
while (isWhiteSpace(reader.content[reader.at])) {
skipWhiteSpace(&reader);
}
while (startWithReader(reader, "//")) {
//printf("line comment\n");
readUntilCharIsReached(&reader, '\n');
}
while (startWithReader(reader, "\"") && *(reader.content+reader.at-1) != '\\') {
//printf("string literal\n");
advance(&reader);
FileReader r = readUntilCharIsReached(&reader, '\"');
while (*(reader.content+reader.at-1) == '\\') {
advance(&reader);
readUntilCharIsReached(&reader, '\"');
}
advance(&reader);
}
while (startWithReader(reader, "#define")) {
//printf("define start %d\n", reader.line);
FileReader defineLine = readUntilCharIsReached(&reader, '\n');
advance(&reader);
char* c = at(&reader);
while (isWhiteSpace(*c)) --c;
while (*c == '\\') {
defineLine = readUntilCharIsReached(&reader, '\n');
advance(&reader);
c = at(&reader);
while (isWhiteSpace(*c)) --c;
}
//printf("define end %d\n", reader.line);
}
while (startWithReader(reader, "/*")) {
//printf("block comment %d\n", reader.line);
advance(&reader, 2);
FileReader r = readUntilCharIsReached(&reader, '*');
//printf("%.*s\n", r.size, at(&r));
while (peek(&reader) != '/') {
advance(&reader);
readUntilCharIsReached(&reader, '*');
if (eof(reader)) break;
}
if (eof(reader)) break;
//printf("end %d\n", reader.line);
advance(&reader, 2);
}
if (eof(reader)) break;
}
if (reader.at >= reader.size || reader.content[reader.at] == 0)
return {TokenTypeEOF, 0, reader.at, reader.line};
Token token = {};
token.line = reader.line;
if (reader.content[reader.at] == '{') {
token.type = TokenTypeLeftBrace;
} else if (reader.content[reader.at] == '}') {
token.type = TokenTypeRightBrace;
} else if (reader.content[reader.at] == '(') {
token.type = TokenTypeLeftParentesis;
} else if (reader.content[reader.at] == ')') {
token.type = TokenTypeRightParentesis;
} else {
advance(&reader);
return {};
//printf("Unexpected character %c\n", reader.content[reader.at]);
//assert(0);
}
token.charIndex = reader.at;
advance(&reader);
return token;
}
int loadProcessOutput(char* buffer, const char* formatString, ...) {
char path[1024];
va_list argList;
va_start(argList, formatString);
vsprintf(path, formatString, argList);
va_end(argList);
FILE* f = popen(path, "r");
if (f == nullptr) {
printf("Failed to load process %s\n", path);
return false;
}
char* at = buffer;
char lineBuffer[2048];
while (fgets(lineBuffer, 2048, f)) {
int len = strlen(lineBuffer);
memcpy(at, lineBuffer, len);
at += len;
}
pclose(f);
return at-buffer;
}
FunctionInFile* getFunctionsInFile(EntireFile entireFile) {
FunctionInFile* functions = arralloc(FunctionInFile, 50);
FileReader reader = {entireFile.content, entireFile.size, 0, 1};
Token token1 = readNextToken(reader);
while (!eof(reader)) {
Token token2 = readNextToken(reader);
if (token1.type == TokenTypeRightParentesis && token2.type == TokenTypeLeftBrace) {
FunctionInFile function = {};
char* c = &entireFile.content[token1.charIndex];
int scope = 0;
while (1) {
--c;
if (*c == ')') ++scope;
else if (*c == '(' && scope > 0) --scope;
else if (*c == '(' && scope == 0) break;
}
char* nameEnd = --c;
while (isAlphaNum(*c) || *c == '_') --c;
char* nameBegin = ++c;
sprintf(function.name, "%.*s", (int) (nameEnd-nameBegin+1), nameBegin);
function.firstLine = reader.line;
int scopeLevel = 0;
while (!eof(reader)) {
Token tk = readNextToken(reader);
if (tk.type == TokenTypeRightBrace) {
if (scopeLevel == 0) {
break;
} else {
--scopeLevel;
}
} else if (tk.type == TokenTypeLeftBrace) {
++scopeLevel;
}
}
function.lastLine = reader.line;
arradd(functions, function);
//printf("%s{%d, %d}\n", function.name, function.firstLine, function.lastLine);
}
token1 = token2;
}
return functions;
}
void writeCommit(FileWriter* writer, CommitInfo commit) {
writeTextInFile(writer, " [");
writeTextInFile(writer, "\"%s\"", commit.functionsChanged[0]);
for (int f = 1; f < arrcount(commit.functionsChanged); ++f) {
writeTextInFile(writer, ", \"%s\"", commit.functionsChanged[f]);
}
writeTextInFile(writer, "]");
}
int main(int argc, char* argv[]) {
#if 1
if (argc < 4) {
printf("Usage: %s <git_repo_path> <output_path> <num_commits>", argv[0]);
return 0;
}
char repositoryPath[512];
sprintf(repositoryPath, "%s/.git", argv[1]);
char outputPath[512];
sprintf(outputPath, "%s", argv[2]);
int maxNumberOfCommitsToAnalyse = atoi(argv[3]);
FILE* outputFile = fopen(outputPath, "w");
fwrite("[\n", 1, 2, outputFile);
char totalCommitCountString[12];
loadProcessOutput(totalCommitCountString, "git --git-dir=\"%s\" rev-list --count master", repositoryPath);
int totalCommitCount = atoi(totalCommitCountString);
FileReader commitHashesOutput = {(char*) malloc(MEGA_BYTES(40))};
commitHashesOutput.size = loadProcessOutput(commitHashesOutput.content, "git --git-dir=\"%s\" log --oneline --pretty=tformat:\"%%H\"", repositoryPath);
char** commitHashes = arralloc(char*, totalCommitCount);
while (!eof(commitHashesOutput)) {
char* commitHash = (char*) malloc(64);
readUntilCharIsReached(commitHash, &commitHashesOutput, '\n');
advance(&commitHashesOutput);
arradd(commitHashes, commitHash);
}
free(commitHashesOutput.content);
int numberOfCommitsToAnalyse = min(totalCommitCount, maxNumberOfCommitsToAnalyse);
EntireFile ef = {};
ef.content = (char*) malloc(MEGA_BYTES(500));
CommitInfo* commits = (CommitInfo*) malloc(numberOfCommitsToAnalyse*sizeof(CommitInfo));
int commitCount = 0;
int upToCommit = 0;
int sinceCommit = min(numberOfCommitsToAnalyse-1, LOOP_SIZE);
while (sinceCommit <= numberOfCommitsToAnalyse) {
ef.size = loadProcessOutput(
ef.content,
"git --git-dir=\"%s\" log ^%s^..^%s^ --diff-filter=M -p --unified=0",
repositoryPath,
commitHashes[sinceCommit],
commitHashes[upToCommit]
);
printf(ANSI_COLOR_YELLOW("Analysing log from %.*s to %.*s (size: %.2fmb)\n"),
6, commitHashes[sinceCommit],
6, commitHashes[upToCommit],
(float)ef.size/MEGA_BYTES(1)
);
CommitInfo* currentCommit = 0;
DiffChunk* currentChunk = 0;
int newCommits = 0;
FileReader reader = {ef.content, ef.size, 0, 1};
while (!eof(reader)) {
FileReader line = readUntilCharIsReached(&reader, '\n');
if (startsWith(line.content, "commit")) {
advance(&line, sizeof("commit"));
currentCommit = &commits[commitCount++];
readUntilCharIsReached(currentCommit->hash, &line, '\n');
printf("%6d: %s\n", commitCount, currentCommit->hash);
currentCommit->chunks = arralloc(DiffChunk, 10);
++newCommits;
} else if (startsWith(line.content, "---")) {
advance(&line, sizeof("--- a"));
DiffChunk chunk = {};
readUntilCharIsReached(chunk.oldFile, &line, '\n');
chunk.changes = arralloc(ChangeInfo, 10);
//chunk.functionsChanged = 0;
arradd(currentCommit->chunks, chunk);
currentChunk = &arrlast(currentCommit->chunks);
} else if (startsWith(line.content, "+++")) {
advance(&line, sizeof("+++ b"));
readUntilCharIsReached(currentChunk->newFile, &line, '\n');
} else if (startsWith(line.content, "@@")) {
advance(&line, sizeof("@@ "));
char sourceLine[32];
char sourceCount[32];
char targetLine[32];
char targetCount[32];
FileReader sourceInfo = readUntilCharIsReached(&line, ' ');
readUntilCharIsReached(sourceLine, &sourceInfo, ',');
advance(&sourceInfo);
if (!eof(sourceInfo)) {
readRemainder(sourceCount, &sourceInfo);
}
advance(&line, 2);
FileReader targetInfo = readUntilCharIsReached(&line, ' ');
readUntilCharIsReached(targetLine, &targetInfo, ',');
advance(&targetInfo);
if (!eof(targetInfo)) {
readRemainder(targetCount, &targetInfo);
}
ChangeInfo change = {};
change.oldFileLine = atoi(sourceLine);
change.oldFileCount = atoi(sourceCount);
change.newFileLine = atoi(targetLine);
change.newFileCount = atoi(targetCount);
arradd(currentChunk->changes, change);
}
advance(&reader);
}
for (int i = commitCount - newCommits; i < commitCount; ++i) {
//printf("%s\n", commits[i].hash);
char** functionsChanged = arralloc(char*, 10);
for (int j = 0; j < arrcount(commits[i].chunks); ++j) {
DiffChunk& chunk = commits[i].chunks[j];
if (endsWith(chunk.newFile, ".cpp")
|| endsWith(chunk.newFile, ".hpp")
|| endsWith(chunk.newFile, ".c")
|| endsWith(chunk.newFile, ".h")) {
EntireFile file = {};
file.content = (char*) malloc(MEGA_BYTES(64));
file.size = loadProcessOutput(file.content, "git --git-dir=%s/.git show %s:%s", argv[1], commits[i].hash, chunk.newFile);
FunctionInFile* functions = getFunctionsInFile(file);
for (int k = 0; k < arrcount(chunk.changes); ++k) {
ChangeInfo change = chunk.changes[k];
for (int f = 0; f < arrcount(functions); ++f) {
FunctionInFile& function = functions[f];
if (change.newFileLine >= function.firstLine && change.newFileLine <= function.lastLine) {
function.changed = true;
}
}
}
for (int f = 0; f < arrcount(functions); ++f) {
FunctionInFile& function = functions[f];
if (function.changed) {
char* functionName = (char*) malloc(256);
sprintf(functionName, "[%s] %s", chunk.newFile, function.name);
arradd(functionsChanged, functionName);
}
}
arrfree(functions);
free(file.content);
}
}
commits[i].functionsChanged = functionsChanged;
}
FileWriter writer = {(char*) malloc(MEGA_BYTES(100))};
if (newCommits) {
for (int i = commitCount - newCommits; i < commitCount; ++i) {
writeCommit(&writer, commits[i]);
writeTextInFile(&writer, ",\n");
}
}
appendFile(writer, outputFile);
free(writer.buffer);
for (int i = commitCount-newCommits; i < commitCount; ++i) {
for (int j = 0; j < arrcount(commits[i].chunks); ++j) {
arrfree(commits[i].chunks[j].changes);
}
for (int f = 0; f < arrcount(commits[i].functionsChanged); ++f) {
free(commits[i].functionsChanged[f]);
}
arrfree(commits[i].functionsChanged);
arrfree(commits[i].chunks);
}
upToCommit = sinceCommit;
sinceCommit += LOOP_SIZE;
sinceCommit = min(sinceCommit, numberOfCommitsToAnalyse);
if (sinceCommit == upToCommit) break;
}
fseek(outputFile, -3, SEEK_CUR);
fwrite("\n]", 1, 2, outputFile);
printf("Done!\n");
free(ef.content);
for (int i = 0; i < arrcount(commitHashes); ++i) {
free(commitHashes[i]);
}
arrfree(commitHashes);
arrfree(commits);
stb_leakcheck_dumpmem();
return 0;
#elif 0
const char* repos[] = {
"php/php-src"
};
for (unsigned int repoIndex = 0; repoIndex < sizeof(repos); ++repoIndex) {
system("rd /s /q \"../../temp-clone\"");
system("mkdir \"../../temp-clone\"");
printf("%s\n", repos[repoIndex]);
char commandLine[512];
sprintf(commandLine, "git clone https://github.com/%s.git ../../temp-clone", repos[repoIndex]);
system(commandLine);
char repositoryPath[512];
sprintf(repositoryPath, "../../temp-clone/.git");
char outputPath[512];
sprintf(outputPath, "../../transactions/");
FileReader rd = {};
rd.content = (char*) repos[repoIndex];
rd.size = strlen(repos[repoIndex]);
readUntilCharIsReached(outputPath + strlen(outputPath), &rd, '/');
advance(&rd);
rd = readRemainder(&rd);
sprintf(outputPath + strlen(outputPath), "_%.*s.txt", rd.size, rd.content);
printf("Output path: %s\n", outputPath);
int maxNumberOfCommitsToAnalyse = 10000;
FILE* outputFile = fopen(outputPath, "w");
fwrite("[\n", 1, 2, outputFile);
char branchName[128];
loadProcessOutput(branchName, "git --git-dir=\"%s\" branch | grep \\* | cut -d ' ' -f2", repositoryPath);
branchName[strlen(branchName)-1] = 0;
char totalCommitCountString[12];
loadProcessOutput(totalCommitCountString, "git --git-dir=\"%s\" rev-list --count %s", repositoryPath, branchName);
int totalCommitCount = atoi(totalCommitCountString);
FileReader commitHashesOutput = {(char*) malloc(MEGA_BYTES(40))};
commitHashesOutput.size = loadProcessOutput(commitHashesOutput.content, "git --git-dir=\"%s\" log --oneline --pretty=tformat:\"%%H\"", repositoryPath);
char** commitHashes = arralloc(char*, totalCommitCount);
while (!eof(commitHashesOutput)) {
char* commitHash = (char*) malloc(64);
readUntilCharIsReached(commitHash, &commitHashesOutput, '\n');
advance(&commitHashesOutput);
arradd(commitHashes, commitHash);
}
free(commitHashesOutput.content);
int numberOfCommitsToAnalyse = min(totalCommitCount, maxNumberOfCommitsToAnalyse);
EntireFile ef = {};
ef.content = (char*) malloc(MEGA_BYTES(500));
CommitInfo* commits = arralloc(CommitInfo, numberOfCommitsToAnalyse);
int commitCount = 0;
int upToCommit = 0;
int sinceCommit = min(numberOfCommitsToAnalyse-1, LOOP_SIZE);
for (int commitIndex = 0; commitIndex < numberOfCommitsToAnalyse; ++commitIndex) {
ef.size = loadProcessOutput(
ef.content,
"git --git-dir=\"%s\" log %s --diff-filter=M -p --unified=0 -1",
repositoryPath,
commitHashes[commitIndex]
);
CommitInfo* currentCommit = 0;
DiffChunk* currentChunk = 0;
int newCommits = 0;
FileReader reader = {ef.content, ef.size, 0, 1};
while (!eof(reader)) {
FileReader line = readUntilCharIsReached(&reader, '\n');
if (startsWith(line.content, "commit")) {
advance(&line, sizeof("commit"));
currentCommit = &commits[commitCount++];
readUntilCharIsReached(currentCommit->hash, &line, '\n');
printf(ANSI_COLOR_YELLOW("%6d: ") "%s\n", commitCount, currentCommit->hash);
currentCommit->chunks = arralloc(DiffChunk, 10);
++newCommits;
} else if (startsWith(line.content, "---")) {
advance(&line, sizeof("--- a"));
DiffChunk chunk = {};
readUntilCharIsReached(chunk.oldFile, &line, '\n');
chunk.changes = arralloc(ChangeInfo, 10);
//chunk.functionsChanged = 0;
arradd(currentCommit->chunks, chunk);
currentChunk = &arrlast(currentCommit->chunks);
} else if (startsWith(line.content, "+++")) {
advance(&line, sizeof("+++ b"));
readUntilCharIsReached(currentChunk->newFile, &line, '\n');
} else if (startsWith(line.content, "@@")) {
advance(&line, sizeof("@@ "));
char sourceLine[32];
char sourceCount[32];
char targetLine[32];
char targetCount[32];
FileReader sourceInfo = readUntilCharIsReached(&line, ' ');
readUntilCharIsReached(sourceLine, &sourceInfo, ',');
advance(&sourceInfo);
if (!eof(sourceInfo)) {
readRemainder(sourceCount, &sourceInfo);
}
advance(&line, 2);
FileReader targetInfo = readUntilCharIsReached(&line, ' ');
readUntilCharIsReached(targetLine, &targetInfo, ',');
advance(&targetInfo);
if (!eof(targetInfo)) {
readRemainder(targetCount, &targetInfo);
}
ChangeInfo change = {};
change.oldFileLine = atoi(sourceLine);
change.oldFileCount = atoi(sourceCount);
change.newFileLine = atoi(targetLine);
change.newFileCount = atoi(targetCount);
arradd(currentChunk->changes, change);
}
advance(&reader);
}
for (int i = commitCount - newCommits; i < commitCount; ++i) {
//printf("%s\n", commits[i].hash);
char** functionsChanged = arralloc(char*, 10);
for (int j = 0; j < arrcount(commits[i].chunks); ++j) {
DiffChunk& chunk = commits[i].chunks[j];
if (endsWith(chunk.newFile, ".cpp")
|| endsWith(chunk.newFile, ".hpp")
|| endsWith(chunk.newFile, ".c")
|| endsWith(chunk.newFile, ".h")) {
EntireFile file = {};
file.content = (char*) malloc(MEGA_BYTES(64));
file.size = loadProcessOutput(file.content, "git --git-dir=../../temp-clone/.git show %s:%s", commits[i].hash, chunk.newFile);
FunctionInFile* functions = getFunctionsInFile(file);
for (int k = 0; k < arrcount(chunk.changes); ++k) {
ChangeInfo change = chunk.changes[k];
for (int f = 0; f < arrcount(functions); ++f) {
FunctionInFile& function = functions[f];
if (change.newFileLine >= function.firstLine && change.newFileLine <= function.lastLine) {
function.changed = true;
}
}
}
for (int f = 0; f < arrcount(functions); ++f) {
FunctionInFile& function = functions[f];
if (function.changed) {
char* functionName = (char*) malloc(256);
sprintf(functionName, "[%s] %s", chunk.newFile, function.name);
arradd(functionsChanged, functionName);
}
}
arrfree(functions);
free(file.content);
}
}
commits[i].functionsChanged = functionsChanged;
}
FileWriter writer = {(char*) malloc(MEGA_BYTES(100))};
if (newCommits) {
for (int i = commitCount - newCommits; i < commitCount; ++i) {
if (arrcount(commits[i].functionsChanged)) {
writeCommit(&writer, commits[i]);
writeTextInFile(&writer, ",\n");
}
}
}
appendFile(writer, outputFile);
free(writer.buffer);
for (int i = commitCount-newCommits; i < commitCount; ++i) {
for (int j = 0; j < arrcount(commits[i].chunks); ++j) {
arrfree(commits[i].chunks[j].changes);
}
for (int f = 0; f < arrcount(commits[i].functionsChanged); ++f) {
free(commits[i].functionsChanged[f]);
}
arrfree(commits[i].functionsChanged);
arrfree(commits[i].chunks);
}
}
fseek(outputFile, -3, SEEK_CUR);
fwrite("\n]", 1, 2, outputFile);
fclose(outputFile);
printf("Done!\n");
free(ef.content);
for (int i = 0; i < arrcount(commitHashes); ++i) {
free(commitHashes[i]);
}
arrfree(commitHashes);
arrfree(commits);
//stb_leakcheck_dumpmem();
}
return 0;
#endif
}
| 35.582386
| 160
| 0.506028
|
rodrigo-brito
|
39f821f32de24e02de68f7ffda67b4a5d03b2338
| 3,062
|
cpp
|
C++
|
svntrunk/src/untabbed/BlueMatter/analysis/src/bootstrap.cpp
|
Bhaskers-Blu-Org1/BlueMatter
|
1ab2c41af870c19e2e1b1095edd1d5c85eeb9b5e
|
[
"BSD-2-Clause"
] | 7
|
2020-02-25T15:46:18.000Z
|
2022-02-25T07:04:47.000Z
|
svntrunk/src/untabbed/BlueMatter/analysis/src/bootstrap.cpp
|
IBM/BlueMatter
|
5243c0ef119e599fc3e9b7c4213ecfe837de59f3
|
[
"BSD-2-Clause"
] | null | null | null |
svntrunk/src/untabbed/BlueMatter/analysis/src/bootstrap.cpp
|
IBM/BlueMatter
|
5243c0ef119e599fc3e9b7c4213ecfe837de59f3
|
[
"BSD-2-Clause"
] | 5
|
2019-06-06T16:30:21.000Z
|
2020-11-16T19:43:01.000Z
|
/* Copyright 2001, 2019 IBM Corporation
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
* following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
* following disclaimer in the documentation and/or other materials provided with the distribution.
*
* 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.
*/
// **********************************************************************
// File: bootstrap.cpp
// Author: RSG
// Date: April 17, 2002
// Class: Bootstrap
// Template Parameter: TDerived (function object taking a const reference
// to a vector<double> as an argument and
// returning a double
// Description: class encapsulating the operations associated with the
// "bootstrap" procedure used to estimate uncertainties
// of a function defined on a set of iid values.
// **********************************************************************
#include <BlueMatter/bootstrap.hpp>
#include <BlueMatter/rmsd.hpp>
#include <algorithm>
Bootstrap::Bootstrap(const std::vector<double>& data) : d_data(data)
{}
Bootstrap::~Bootstrap()
{}
const std::vector<double>& Bootstrap::eval(int size)
{
Rmsd derived;
time_t foo;
foo = time(&foo);
unsigned int seed = foo;
unsigned int length = d_data.size();
char state[256];
initstate(seed, state, 256);
std::vector<double> syntheticValue;
syntheticValue.reserve(d_data.size());
d_syntheticDerived.clear();
d_syntheticDerived.reserve(size);
for (int j = 0; j < size; ++j)
{
// generate the synthetic data set by random selection from the
// real dataset with replacement
for (int i = 0; i < d_data.size(); ++i)
{
int index = random() % d_data.size();
syntheticValue.push_back(d_data[index]);
}
// compute the derived quantity for the synthetic dataset
d_syntheticDerived.push_back(derived(syntheticValue));
syntheticValue.clear();
}
std::sort(d_syntheticDerived.begin(), d_syntheticDerived.end());
return(d_syntheticDerived);
}
| 39.25641
| 118
| 0.6855
|
Bhaskers-Blu-Org1
|
39f94e132ec565178e4dd922c8930ca532840825
| 1,854
|
cc
|
C++
|
chrome/browser/ash/power/auto_screen_brightness/model_config.cc
|
zealoussnow/chromium
|
fd8a8914ca0183f0add65ae55f04e287543c7d4a
|
[
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 14,668
|
2015-01-01T01:57:10.000Z
|
2022-03-31T23:33:32.000Z
|
chrome/browser/ash/power/auto_screen_brightness/model_config.cc
|
zealoussnow/chromium
|
fd8a8914ca0183f0add65ae55f04e287543c7d4a
|
[
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 86
|
2015-10-21T13:02:42.000Z
|
2022-03-14T07:50:50.000Z
|
chrome/browser/ash/power/auto_screen_brightness/model_config.cc
|
zealoussnow/chromium
|
fd8a8914ca0183f0add65ae55f04e287543c7d4a
|
[
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 5,941
|
2015-01-02T11:32:21.000Z
|
2022-03-31T16:35:46.000Z
|
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <cmath>
#include "chrome/browser/ash/power/auto_screen_brightness/model_config.h"
namespace ash {
namespace power {
namespace auto_screen_brightness {
ModelConfig::ModelConfig() = default;
ModelConfig::ModelConfig(const ModelConfig& config) = default;
ModelConfig::~ModelConfig() = default;
bool ModelConfig::operator==(const ModelConfig& config) const {
const double kTol = 1e-10;
if (std::abs(auto_brightness_als_horizon_seconds -
config.auto_brightness_als_horizon_seconds) >= kTol)
return false;
if (enabled != config.enabled)
return false;
if (log_lux.size() != config.log_lux.size())
return false;
for (size_t i = 0; i < log_lux.size(); ++i) {
if (std::abs(log_lux[i] - config.log_lux[i]) >= kTol)
return false;
}
if (brightness.size() != config.brightness.size())
return false;
for (size_t i = 0; i < brightness.size(); ++i) {
if (std::abs(brightness[i] - config.brightness[i]) >= kTol)
return false;
}
if (metrics_key != config.metrics_key)
return false;
if (std::abs(model_als_horizon_seconds - config.model_als_horizon_seconds) >=
kTol)
return false;
return true;
}
bool IsValidModelConfig(const ModelConfig& model_config) {
if (model_config.auto_brightness_als_horizon_seconds <= 0)
return false;
if (model_config.log_lux.size() != model_config.brightness.size() ||
model_config.brightness.size() < 2)
return false;
if (model_config.metrics_key.empty())
return false;
if (model_config.model_als_horizon_seconds <= 0)
return false;
return true;
}
} // namespace auto_screen_brightness
} // namespace power
} // namespace ash
| 25.054054
| 79
| 0.696332
|
zealoussnow
|
39f9a1535130f5c46084c4e29bf8877c8ddc2cdd
| 12,330
|
cpp
|
C++
|
small-and-simple-programs-in-qt/computer-assembly-qt/computer-assembly/mainwindow.cpp
|
gusenov/examples-qt
|
083a51feedf6cefe82b6de79d701da23d1da2a2f
|
[
"MIT"
] | 2
|
2020-09-01T18:37:30.000Z
|
2021-11-28T16:25:04.000Z
|
small-and-simple-programs-in-qt/computer-assembly-qt/computer-assembly/mainwindow.cpp
|
gusenov/examples-qt
|
083a51feedf6cefe82b6de79d701da23d1da2a2f
|
[
"MIT"
] | null | null | null |
small-and-simple-programs-in-qt/computer-assembly-qt/computer-assembly/mainwindow.cpp
|
gusenov/examples-qt
|
083a51feedf6cefe82b6de79d701da23d1da2a2f
|
[
"MIT"
] | null | null | null |
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QDebug>
#include <QDesktopServices>
#include <QUrl>
#include <QDir>
#include <QMessageBox>
// Конструктор:
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent), // вызов родительского конструктора.
ui(new Ui::MainWindow)
{
// Приложение пока ещё не инциализировано:
isInitialized = false;
ui->setupUi(this);
// Установить фиксированный размер окна:
this->setFixedSize(QSize(width(), height()));
// Установка иконки для окна программы:
setWindowIcon(QIcon("://Home-Server-icon.png"));
// Создание экземпляра окна в котором отображается информация о программе:
about = new About(this);
// Делаем окно О программе… модальным:
about->setWindowFlags(Qt::Dialog);
about->setWindowModality(Qt::WindowModal);
// Окно для печати:
print = new Print(this);
// Делаем окно для печати модальным:
print->setWindowFlags(Qt::Dialog);
print->setWindowModality(Qt::WindowModal);
// Настройка моделей для выпадающих списков:
setupModels();
isInitialized = true; // приложение инициализировано.
checkCompatibility(); // проверка совместимости выбранных компонентов.
connect(ui->widgetSelectVideoCard, SIGNAL(checkCompatibilitySignal()), this, SLOT(checkCompatibility()));
connect(ui->widgetSelectHDD, SIGNAL(checkCompatibilitySignal()), this, SLOT(checkCompatibility()));
}
// Настройка моделей данных для выпадающих списков:
void MainWindow::setupModels()
{
// Создаем модель данных приложения:
appDataModel = new AppModel("://data.csv");
// Создаем и устанавливаем модели данных для выпадающих списков:
modelVideoCard = new QStringListModel(appDataModel->getVideoCardStringList());
ui->widgetSelectVideoCard->config(modelVideoCard, appDataModel, DeviceType::VideoCard);
modelMotherboard = new QStringListModel(appDataModel->getMotherboardStringList());
ui->comboBoxMotherboardChoice->setModel(modelMotherboard);
modelHDD = new QStringListModel(appDataModel->getHddStringList());
ui->widgetSelectHDD->config(modelHDD, appDataModel, DeviceType::HDD);
modelCPU = new QStringListModel(appDataModel->getCpuStringList());
ui->comboBoxCPUChoice->setModel(modelCPU);
modelPowerSupply = new QStringListModel(appDataModel->getPowerSupplyStringList());
ui->comboBoxPowerSupplyChoice->setModel(modelPowerSupply);
modelRAM = new QStringListModel(appDataModel->getRamStringList());
ui->comboBoxRAMChoice->setModel(modelRAM);
}
// Деструктор:
MainWindow::~MainWindow()
{
delete ui;
// Удаление экземпляра окна в котором отображается информация о программе:
if (about) delete about;
// Удаление окна печати:
if (print) delete print;
// Удаление модели данных программы:
if (appDataModel) delete appDataModel;
// Удаление моделей данных выпадающих списков:
if (modelVideoCard) delete modelVideoCard;
if (modelMotherboard) delete modelMotherboard;
if (modelHDD) delete modelHDD;
if (modelCPU) delete modelCPU;
if (modelPowerSupply) delete modelPowerSupply;
if (modelRAM) delete modelRAM;
// Удаление временного файла в котором хранится информация о проекте:
if (filePathProjectInfo != nullptr)
{
if (QFile(*filePathProjectInfo).remove())
{
qDebug() << "Файл" << *filePathProjectInfo << "удален";
}
else
{
qDebug() << "Проблемы при удалении файла" << *filePathProjectInfo;
}
delete filePathProjectInfo;
}
}
// Выход из программы:
void MainWindow::on_actionExit_triggered()
{
QApplication::quit(); // выход.
}
// Обработчик события выбора пункта главного меню Справка → О программе Сборка ПК…:
void MainWindow::on_actionAbout_triggered()
{
about->show(); // показать окно.
}
// Обработчик события смены материнской платы:
void MainWindow::on_comboBoxMotherboardChoice_currentIndexChanged(int index)
{
// Показать характеристики выбранного компонента:
ui->plainTextEditMotherboardSpecifications->setPlainText(
appDataModel->getSpecificationsByIndex(DeviceType::Motherboard, index)
);
// Пересчитать цену в завимисости от количества:
priceMotherboard = appDataModel->getPriceByIndex(DeviceType::Motherboard, index);
ui->labelMotherboardPriceValue->setText(
QString::number(priceMotherboard) + " ₽"
);
// Проверить совместимость:
checkCompatibility();
}
// Обработчик события смены процессора:
void MainWindow::on_comboBoxCPUChoice_currentIndexChanged(int index)
{
// Показать характеристики выбранного компонента:
ui->plainTextEditCPUSpecifications->setPlainText(
appDataModel->getSpecificationsByIndex(DeviceType::CPU, index)
);
// Пересчитать цену в завимисости от количества:
priceCPU = appDataModel->getPriceByIndex(DeviceType::CPU, index);
// qDebug() << priceCPU;
ui->labelCPUPriceValue->setText(
QString::number(priceCPU) + " ₽"
);
// Проверить совместимость:
checkCompatibility();
}
// Обработчик события смены блока питания:
void MainWindow::on_comboBoxPowerSupplyChoice_currentIndexChanged(int index)
{
// Показать характеристики выбранного компонента:
ui->plainTextEditPowerSupplySpecifications->setPlainText(
appDataModel->getSpecificationsByIndex(DeviceType::PowerSupply, index)
);
// Пересчитать цену в завимисости от количества:
pricePowerSupply = appDataModel->getPriceByIndex(DeviceType::PowerSupply, index);
ui->labelPowerSupplyPriceValue->setText(
QString::number(pricePowerSupply) + " ₽"
);
// Проверить совместимость:
checkCompatibility();
}
// Обработчик события смены оперативной памяти:
void MainWindow::on_comboBoxRAMChoice_currentIndexChanged(int index)
{
// Показать характеристики выбранного компонента:
ui->plainTextEditRAMSpecifications->setPlainText(
appDataModel->getSpecificationsByIndex(DeviceType::RAM, index)
);
// Пересчитать цену в завимисости от количества:
priceRAM = ui->spinBoxRAMQuantityValue->value();
on_spinBoxRAMQuantityValue_valueChanged(priceRAM);
// Проверить совместимость:
checkCompatibility();
}
// Обработчик события смены количества оперативной памяти:
void MainWindow::on_spinBoxRAMQuantityValue_valueChanged(int arg1)
{
int currentRAMIndex = ui->comboBoxRAMChoice->currentIndex();
if (currentRAMIndex == -1)
return;
// Пересчитать цену в завимисости от количества:
priceRAM = appDataModel->getPriceByIndex(DeviceType::RAM, currentRAMIndex) * arg1;
ui->labelRAMPriceValue->setText(
QString::number(priceRAM) + " ₽"
);
}
// Метод для получения итоговой цены:
int MainWindow::getTotalPrice()
{
// qDebug() << "Видеокарты = " << ui->widgetSelectVideoCard->getPrice();
// qDebug() << "Мат. плата = " << priceMotherboard;
// qDebug() << "Диски = " << ui->widgetSelectHDD->getPrice();
// qDebug() << "ЦП = " << priceCPU;
// qDebug() << "Питание = " << pricePowerSupply;
// qDebug() << "ОЗУ = " << priceRAM;
return ui->widgetSelectVideoCard->getPrice()
+ priceMotherboard
+ ui->widgetSelectHDD->getPrice()
+ priceCPU
+ pricePowerSupply
+ priceRAM;
}
// Обработчик нажатия на кнопку
// "Собрать готовое решение персонального компьютера и вывести цену":
void MainWindow::on_pushButtonBuild_clicked()
{
// Форматируем текст по шаблону:
QString result = QString("%1"
"%2 = %3\n%4\n\n"
"%5"
"%6 = %7\n%8\n\n"
"%9 = %10\n%11\n\n"
"%12 x%13 = %14\n%15\n\n\n"
"ИТОГО: %16 ₽").arg(
ui->widgetSelectVideoCard->getText(),
ui->comboBoxMotherboardChoice->currentText(),
ui->labelMotherboardPriceValue->text(),
ui->plainTextEditMotherboardSpecifications->toPlainText(),
ui->widgetSelectHDD->getText()
).arg(
ui->comboBoxCPUChoice->currentText(),
ui->labelCPUPriceValue->text(),
ui->plainTextEditCPUSpecifications->toPlainText()
).arg(
ui->comboBoxPowerSupplyChoice->currentText(),
ui->labelPowerSupplyPriceValue->text(),
ui->plainTextEditPowerSupplySpecifications->toPlainText(),
ui->comboBoxRAMChoice->currentText(),
QString::number(ui->spinBoxRAMQuantityValue->value()),
ui->labelRAMPriceValue->text(),
ui->plainTextEditRAMSpecifications->toPlainText(),
QString::number(getTotalPrice())
);
print->setResultText(result);
print->show();
}
// Метод для открытия файла из ресурсов приложения
// (этот метод нужен для того чтобы скопировать файл из
// ресурсов программы во временную папку, а потом уже из
// временной папки открыть его внешней программой):
void MainWindow::openFileFromRes(QString filePathInRes, QString* output_path)
{
// Путь к папке с программой:
qDebug() << "applicationDirPath =" << QCoreApplication::applicationDirPath();
// Путь к временной папке:
qDebug() << "tempPath =" << QDir::tempPath();
// Файл и его путь:
QFile input_file(filePathInRes);
// Открытие файла:
if (!input_file.open(QFile::ReadOnly | QFile::Text))
{
qDebug() << "Невозможно открыть файл для чтения";
return;
}
// Чтение содежимого файла:
QTextStream in(&input_file);
QString myText = in.readAll();
// Закрытие файла:
input_file.close();
// Путь к временному файлу во временной папке:
*output_path = QDir::temp().filePath(QFileInfo(input_file).fileName());
// Выходной временный файл:
QFile output_file(*output_path);
// Открытие временного файла:
if (!output_file.open(QIODevice::WriteOnly))
{
// Закрытие временного файла:
output_file.close();
return;
} else {
// Копирование входного файла во временный файл:
QTextStream out(&output_file);
out << myText;
// Закрытие временного файла:
output_file.close();
}
// Запуск на открытие временного в операционной системе
// (для *.html файлов откроётся браузер):
QDesktopServices::openUrl(QUrl("file:///" + *output_path));
}
// Обработчик события выбора пункта главного меню Справка → Информация о проекте:
void MainWindow::on_actionInfo_triggered()
{
openFileFromRes(":/info.html", filePathProjectInfo);
}
// Метод для проверки совместимости выбранных устройств:
void MainWindow::checkCompatibility()
{
if (!isInitialized)
return;
// Получаем текстовую информацию о результатах совместимости:
QString compatibilityInfo = appDataModel->getCompatibilityInfo(
ui->widgetSelectVideoCard->getDeviceIndexes(),
ui->comboBoxMotherboardChoice->currentIndex(),
ui->widgetSelectHDD->getDeviceIndexes(),
ui->comboBoxCPUChoice->currentIndex(),
ui->comboBoxPowerSupplyChoice->currentIndex(),
ui->comboBoxRAMChoice->currentIndex()
);
// Отображаем текстовую информацию о результатах совместимости:
ui->plainTextEditCompatibilityInfo->setPlainText(compatibilityInfo);
// Палитра цветов:
QPalette p = ui->plainTextEditCompatibilityInfo->palette();
// Если есть какая-то несовместимость:
if (compatibilityInfo.contains("не совместим")) {
p.setColor(QPalette::Base, Qt::white); // делаем текст красным.
p.setColor(QPalette::Text, Qt::red);
ui->pushButtonBuild->setEnabled(false); // выключить кнопку сборки.
// Иначе:
} else {
p.setColor(QPalette::Base, Qt::white);
p.setColor(QPalette::Text, Qt::black);
ui->pushButtonBuild->setEnabled(true); // включить кнопку сборки.
}
ui->plainTextEditCompatibilityInfo->setPalette(p);
}
| 32.88
| 110
| 0.66253
|
gusenov
|
39f9e16fdc0f4ff2f6f202000875bfcb3f0960f3
| 15,736
|
cpp
|
C++
|
oblibtest/testclot.cpp
|
uesp/tes4lib
|
7b426c9209ff7996d3d763e6d4e217abfefae406
|
[
"MIT"
] | 1
|
2021-02-07T07:32:14.000Z
|
2021-02-07T07:32:14.000Z
|
oblibtest/testclot.cpp
|
uesp/tes4lib
|
7b426c9209ff7996d3d763e6d4e217abfefae406
|
[
"MIT"
] | null | null | null |
oblibtest/testclot.cpp
|
uesp/tes4lib
|
7b426c9209ff7996d3d763e6d4e217abfefae406
|
[
"MIT"
] | null | null | null |
/*===========================================================================
*
* File: TestClot.CPP
* Author: Dave Humphrey (uesp@sympatico.ca)
* Created On: April 17, 2006
*
* Description
*
*=========================================================================*/
/* Include Files */
#include "testclot.h"
/*===========================================================================
*
* Begin Local Definitions
*
*=========================================================================*/
testclot_t g_TestData = {
0x00170000,
{ 1, 2.3f },
OB_CLOTFLAG_HIDEAMULET,
120,
0x00170001,
"cloth_test",
"Clothing Name",
"model1.nif",
"model2.nif",
"model3.nif",
"model4.nif",
"icon1.dds",
"icon2.dds",
0x00170002
};
static testclot_t g_TestValues[] = {
{ 0x00170000, { 1, 2.3f },
0, 120, 0x00123,
"cloth_test", "Clothing Name", "model1.nif", "model2.nif", "model3.nif", "model4.nif", "icon1.dds", "icon2.dds", 0x00040002 },
{ 0x00170002, { 1, 2 },
OB_BIPEDFLAG_HEAD,
5, 0, "cloth_head", "Clothing Test", "model1.nif", NULL, NULL, NULL, "icon1.dds", NULL, 0 },
{ 0x00170003, { 1, 2 },
OB_BIPEDFLAG_HAIR,
5, 0, "cloth_hair", "Clothing Test", "model1.nif", NULL, NULL, NULL, "icon1.dds", NULL, 0 },
{ 0x00170004, { 1, 2 },
OB_BIPEDFLAG_UPPERBODY,
5, 0, "cloth_upperbody", "Clothing Test", "model1.nif", NULL, NULL, NULL, "icon1.dds", NULL, 0 },
{ 0x00170005, { 1, 2 },
OB_BIPEDFLAG_LOWERBODY,
5, 0, "cloth_lowerbody", "Clothing Test", "model1.nif", NULL, NULL, NULL, "icon1.dds", NULL, 0 },
{ 0x00170006, { 1, 2 },
OB_BIPEDFLAG_HAND,
5, 0, "cloth_hand", "Clothing Test", "model1.nif", NULL, NULL, NULL, "icon1.dds", NULL, 0 },
{ 0x00170007, { 1, 2 },
OB_BIPEDFLAG_FOOT,
5, 0, "cloth_foot", "Clothing Test", "model1.nif", NULL, NULL, NULL, "icon1.dds", NULL, 0 },
{ 0x00170008, { 1, 2 },
OB_BIPEDFLAG_RIGHTRING,
5, 0, "cloth_rightring", "Clothing Test", "model1.nif", NULL, NULL, NULL, "icon1.dds", NULL, 0 },
{ 0x00170009, { 1, 2 },
OB_BIPEDFLAG_LEFTRING,
5, 0, "cloth_leftring", "Clothing Test", "model1.nif", NULL, NULL, NULL, "icon1.dds", NULL, 0 },
{ 0x0017000A, { 1, 2 },
OB_BIPEDFLAG_AMULET,
5, 0, "cloth_amulet", "Clothing Test", "model1.nif", NULL, NULL, NULL, "icon1.dds", NULL, 0 },
{ 0x0017000B, { 1, 2 },
OB_BIPEDFLAG_WEAPON,
5, 0, "cloth_weapon", "Clothing Test", "model1.nif", NULL, NULL, NULL, "icon1.dds", NULL, 0 },
{ 0x0017000C, { 1, 2 },
OB_BIPEDFLAG_BACKWEAPON,
5, 0, "cloth_backweapon", "Clothing Test", "model1.nif", NULL, NULL, NULL, "icon1.dds", NULL, 0 },
{ 0x0017000D, { 1, 2 },
OB_BIPEDFLAG_SIDEWEAPON,
5, 0, "cloth_sideweapon", "Clothing Test", "model1.nif", NULL, NULL, NULL, "icon1.dds", NULL, 0 },
{ 0x0017000E, { 1, 2 },
OB_BIPEDFLAG_QUIVER,
5, 0, "cloth_quiver", "Clothing Test", "model1.nif", NULL, NULL, NULL, "icon1.dds", NULL, 0 },
{ 0x0017000F, { 1, 2 },
OB_BIPEDFLAG_SHIELD,
5, 0, "cloth_shield", "Clothing Test", "model1.nif", NULL, NULL, NULL, "icon1.dds", NULL, 0 },
{ 0x00170010, { 1, 2 },
OB_BIPEDFLAG_TORCH,
5, 0, "cloth_torch", "Clothing Test", "model1.nif", NULL, NULL, NULL, "icon1.dds", NULL, 0 },
{ 0x00170011, { 1, 2 },
OB_BIPEDFLAG_TAIL,
5, 0, "cloth_tail", "Clothing Test", "model1.nif", NULL, NULL, NULL, "icon1.dds", NULL, 0 },
{ 0x00170012, { 1, 2 },
OB_CLOTFLAG_HIDEAMULET,
5, 0, "cloth_hideamulet", "Clothing Test", "model1.nif", NULL, NULL, NULL, "icon1.dds", NULL, 0 },
{ 0x00170013, { 1, 2 },
OB_CLOTFLAG_HIDERINGS,
5, 0, "cloth_hiderings", "Clothing Test", "model1.nif", NULL, NULL, NULL, "icon1.dds", NULL, 0 },
{ 0x00170014, { 1, 2 },
OB_CLOTFLAG_NONPLAYABLE,
5, 0, "cloth_nonplayable", "Clothing Test", "model1.nif", NULL, NULL, NULL, "icon1.dds", NULL, 0 },
{ 0x00170014, { 0, 0 },
0,
5, 0, "cloth_null", NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0 },
{ 0, { 0, 0 }, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0 }
};
/*===========================================================================
* End of Local Definitions
*=========================================================================*/
/*===========================================================================
*
* Function - bool TestClot_SetGet (void);
*
* Tests basic set/get methods of an CLOT record.
*
*=========================================================================*/
bool TestClot_SetGet (void) {
CObClotRecord Record;
OBTEST_LEVEL("CLOT Set/Get")
Record.InitializeNew();
OBTEST_START_TEST("Editor ID")
Record.SetEditorID(g_TestData.pEditorID);
OBTEST_DOSTRCOMPARE(Record.GetEditorID(), ==, g_TestData.pEditorID)
OBTEST_END_TEST()
OBTEST_START_TEST("Form ID")
Record.SetFormID(g_TestData.FormID);
OBTEST_DOINTCOMPARE(Record.GetFormID(), ==, g_TestData.FormID)
OBTEST_END_TEST()
OBTEST_START_TEST("Item Name")
Record.SetItemName(g_TestData.pItemName);
OBTEST_DOSTRCOMPARE(Record.GetItemName(), ==, g_TestData.pItemName)
OBTEST_END_TEST()
OBTEST_START_TEST("Model1")
Record.SetModel(g_TestData.pModel1);
OBTEST_DOSTRCOMPARE(Record.GetModel(), ==, g_TestData.pModel1)
OBTEST_END_TEST()
OBTEST_START_TEST("Model2")
Record.SetModel2(g_TestData.pModel2);
OBTEST_DOSTRCOMPARE(Record.GetModel2(), ==, g_TestData.pModel2)
OBTEST_END_TEST()
OBTEST_START_TEST("Model3")
Record.SetModel3(g_TestData.pModel3);
OBTEST_DOSTRCOMPARE(Record.GetModel3(), ==, g_TestData.pModel3)
OBTEST_END_TEST()
OBTEST_START_TEST("Model4")
Record.SetModel4(g_TestData.pModel4);
OBTEST_DOSTRCOMPARE(Record.GetModel4(), ==, g_TestData.pModel4)
OBTEST_END_TEST()
OBTEST_START_TEST("Icon1")
Record.SetIcon(g_TestData.pIcon1);
OBTEST_DOSTRCOMPARE(Record.GetIcon(), ==, g_TestData.pIcon1)
OBTEST_END_TEST()
OBTEST_START_TEST("Icon2")
Record.SetIcon2(g_TestData.pIcon2);
OBTEST_DOSTRCOMPARE(Record.GetIcon2(), ==, g_TestData.pIcon2)
OBTEST_END_TEST()
OBTEST_START_TEST("Value")
Record.SetValue(g_TestData.Data.Value);
OBTEST_DOINTCOMPARE(Record.GetValue(), ==, g_TestData.Data.Value)
OBTEST_END_TEST()
OBTEST_START_TEST("Weight")
Record.SetWeight(g_TestData.Data.Weight);
OBTEST_DOFLTCOMPARE(Record.GetWeight(), ==, g_TestData.Data.Weight)
OBTEST_END_TEST()
OBTEST_START_TEST("Set Hide Amulet (true)")
Record.SetHideAmulet(true);
OBTEST_DOINTCOMPARE(Record.IsHideAmulet(), ==, true)
OBTEST_END_TEST()
OBTEST_START_TEST("Set Hide Amulet (false)")
Record.SetHideAmulet(false);
OBTEST_DOINTCOMPARE(Record.IsHideAmulet(), ==, false)
OBTEST_END_TEST()
OBTEST_START_TEST("Set Hide Rings (true)")
Record.SetHideRings(true);
OBTEST_DOINTCOMPARE(Record.IsHideRings(), ==, true)
OBTEST_END_TEST()
OBTEST_START_TEST("Set Hide Rings (false)")
Record.SetHideRings(false);
OBTEST_DOINTCOMPARE(Record.IsHideRings(), ==, false)
OBTEST_END_TEST()
OBTEST_START_TEST("Set Playable (true)")
Record.SetPlayable(true);
OBTEST_DOINTCOMPARE(Record.IsPlayable(), ==, true)
OBTEST_END_TEST()
OBTEST_START_TEST("Set Playable (false)")
Record.SetPlayable(false);
OBTEST_DOINTCOMPARE(Record.IsPlayable(), ==, false)
OBTEST_END_TEST()
OBTEST_START_TEST("Set Biped Flags")
Record.SetBipedFlags(OB_BIPEDFLAG_HEAD);
OBTEST_DOINTCOMPARE(Record.GetBipedFlags(), ==, OB_BIPEDFLAG_HEAD)
OBTEST_END_TEST()
OBTEST_START_TEST("Clear Biped Flags")
Record.ClearBipedFlags();
OBTEST_DOINTCOMPARE(Record.GetBipedFlags(), ==, 0)
OBTEST_END_TEST()
OBTEST_START_TEST("Set Biped Flags (all)")
Record.SetBipedFlags(OB_BIPEDFLAG_MASK);
OBTEST_DOINTCOMPARE(Record.GetBipedFlags(), ==, OB_BIPEDFLAG_MASK)
OBTEST_END_TEST()
OBTEST_START_TEST("Check Script (0)")
OBTEST_DOINTCOMPARE(Record.GetScript(), ==, OB_FORMID_NULL)
OBTEST_END_TEST()
OBTEST_START_TEST("Set Script")
Record.SetScript(0x1234);
OBTEST_DOINTCOMPARE(Record.GetScript(), ==, 0x1234)
OBTEST_END_TEST()
OBTEST_START_TEST("Check Enchantment")
OBTEST_DOINTCOMPARE(Record.GetEnchantment(), ==, OB_FORMID_NULL)
OBTEST_END_TEST()
OBTEST_START_TEST("Set Enchantment")
Record.SetEnchantment(0x55668);
OBTEST_DOINTCOMPARE(Record.GetEnchantment(), ==, 0x55668)
OBTEST_END_TEST()
OBTEST_START_TEST("Set Enchantment Points")
Record.SetEnchantPoints(101);
OBTEST_DOINTCOMPARE(Record.GetEnchantPoints(), ==, 101)
OBTEST_END_TEST()
return (true);
}
/*===========================================================================
* End of Function TestClot_SetGet()
*=========================================================================*/
/*===========================================================================
*
* Function - bool TestClot_Output (File);
*
* Outputs basic CLOT records to the given file.
*
*=========================================================================*/
bool TestClot_Output (CObEspFile& File) {
CObClotRecord* pRecord;
CObBaseRecord* pBase;
dword Index;
OBTEST_LEVEL("CLOT Output")
for (Index = 0; g_TestValues[Index].pItemName != NULL; ++Index) {
OBTEST_START_TEST("Create new record")
pBase = File.AddNewRecord(OB_NAME_CLOT);
OBTEST_DOCOMPARE(pBase, !=, NULL)
OBTEST_END_TEST()
OBTEST_START_TEST("Check class")
pRecord = ObCastClass(CObClotRecord, pBase);
OBTEST_DOCOMPARE(pRecord, !=, NULL)
OBTEST_END_TEST()
if (pRecord == NULL) continue;
pRecord->SetFormID(g_TestValues[Index].FormID);
if (g_TestValues[Index].pItemName != NULL) pRecord->SetItemName(g_TestValues[Index].pItemName);
if (g_TestValues[Index].pEditorID != NULL) pRecord->SetEditorID(g_TestValues[Index].pEditorID);
if (g_TestValues[Index].pModel1 != NULL) pRecord->SetModel(g_TestValues[Index].pModel1);
if (g_TestValues[Index].pModel2 != NULL) pRecord->SetModel2(g_TestValues[Index].pModel2);
if (g_TestValues[Index].pModel3 != NULL) pRecord->SetModel3(g_TestValues[Index].pModel3);
if (g_TestValues[Index].pModel4 != NULL) pRecord->SetModel4(g_TestValues[Index].pModel4);
if (g_TestValues[Index].pIcon1 != NULL) pRecord->SetIcon(g_TestValues[Index].pIcon1);
if (g_TestValues[Index].pIcon2 != NULL) pRecord->SetIcon2(g_TestValues[Index].pIcon2);
if (g_TestValues[Index].ScriptFormID != 0) pRecord->SetScript(g_TestValues[Index].ScriptFormID);
if (g_TestValues[Index].EnchantFormID != 0) pRecord->SetEnchantment(g_TestValues[Index].EnchantFormID);
if (g_TestValues[Index].EnchantPts != 0) pRecord->SetEnchantPoints(g_TestValues[Index].EnchantPts);
pRecord->SetValue(g_TestValues[Index].Data.Value);
pRecord->SetWeight(g_TestValues[Index].Data.Weight);
pRecord->SetHideRings((g_TestValues[Index].Flags & OB_CLOTFLAG_HIDERINGS) != 0);
pRecord->SetHideAmulet((g_TestValues[Index].Flags & OB_CLOTFLAG_HIDEAMULET) != 0);
pRecord->SetPlayable((g_TestValues[Index].Flags & OB_CLOTFLAG_NONPLAYABLE) == 0);
pRecord->ClearBipedFlags();
pRecord->SetBipedFlags(g_TestValues[Index].Flags & OB_BIPEDFLAG_MASK);
}
return (true);
}
/*===========================================================================
* End of Function TestClot_Output()
*=========================================================================*/
/*===========================================================================
*
* Function - bool TestClot_Input (File);
*
* Checks the values of CLOT records in the given file and ensures they
* match those previously output.
*
*=========================================================================*/
bool TestClot_Input (CObEspFile& File) {
CObBaseRecord* pBase;
CObClotRecord* pRecord;
dword Index;
OBTEST_LEVEL("CLOT Input")
for (Index = 0; g_TestValues[Index].pItemName != NULL; ++Index) {
OnTestOutputNote("Testing Record (%d, '%s')", g_TestValues[Index].FormID, g_TestValues[Index].pEditorID);
OBTEST_START_TEST("Find record by formID")
pBase = File.FindFormID(g_TestValues[Index].FormID);
OBTEST_DOCOMPARE(pBase, !=, NULL)
OBTEST_END_TEST()
if (pBase == NULL) continue;
OBTEST_START_TEST("Check record type")
OBTEST_DOCOMPARE(pBase->IsRecord(), ==, true)
OBTEST_END_TEST()
if (!pBase->IsRecord()) continue;
OBTEST_START_TEST("Check record name")
OBTEST_DOCOMPARE(pBase->GetName(), ==, OB_NAME_CLOT)
OBTEST_END_TEST()
if (pBase->GetName() != OB_NAME_CLOT) continue;
OBTEST_START_TEST("Check class")
pRecord = ObCastClass(CObClotRecord, pBase);
OBTEST_DOCOMPARE(pRecord, !=, NULL)
OBTEST_END_TEST()
if (pRecord == NULL) continue;
OBTEST_START_TEST("Check item name")
OBTEST_DOSTRCOMPARE1(pRecord->GetItemName(), ==, g_TestValues[Index].pItemName);
OBTEST_END_TEST()
OBTEST_START_TEST("Check editor ID name")
OBTEST_DOSTRCOMPARE1(pRecord->GetEditorID(), ==, g_TestValues[Index].pEditorID);
OBTEST_END_TEST()
OBTEST_START_TEST("Check model1")
OBTEST_DOSTRCOMPARE1(pRecord->GetModel(), ==, g_TestValues[Index].pModel1);
OBTEST_END_TEST()
OBTEST_START_TEST("Check model2")
OBTEST_DOSTRCOMPARE1(pRecord->GetModel2(), ==, g_TestValues[Index].pModel2);
OBTEST_END_TEST()
OBTEST_START_TEST("Check model3")
OBTEST_DOSTRCOMPARE1(pRecord->GetModel3(), ==, g_TestValues[Index].pModel3);
OBTEST_END_TEST()
OBTEST_START_TEST("Check model4")
OBTEST_DOSTRCOMPARE1(pRecord->GetModel4(), ==, g_TestValues[Index].pModel4);
OBTEST_END_TEST()
OBTEST_START_TEST("Check icon1")
OBTEST_DOSTRCOMPARE1(pRecord->GetIcon(), ==, g_TestValues[Index].pIcon1);
OBTEST_END_TEST()
OBTEST_START_TEST("Check icon2")
OBTEST_DOSTRCOMPARE1(pRecord->GetIcon2(), ==, g_TestValues[Index].pIcon2);
OBTEST_END_TEST()
OBTEST_START_TEST("Check weight")
OBTEST_DOINTCOMPARE(pRecord->GetWeight(), ==, g_TestValues[Index].Data.Weight);
OBTEST_END_TEST()
OBTEST_START_TEST("Check value")
OBTEST_DOINTCOMPARE(pRecord->GetValue(), ==, g_TestValues[Index].Data.Value);
OBTEST_END_TEST()
OBTEST_START_TEST("Check Biped Flags")
OBTEST_DOINTCOMPARE(pRecord->GetBipedFlags(), ==, (g_TestValues[Index].Flags & OB_BIPEDFLAG_MASK));
OBTEST_END_TEST()
OBTEST_START_TEST("Check hide amulet")
OBTEST_DOINTCOMPARE(pRecord->IsHideAmulet(), ==, ((g_TestValues[Index].Flags & OB_CLOTFLAG_HIDEAMULET) != 0));
OBTEST_END_TEST()
OBTEST_START_TEST("Check hide rings")
OBTEST_DOINTCOMPARE(pRecord->IsHideRings(), ==, ((g_TestValues[Index].Flags & OB_CLOTFLAG_HIDERINGS) != 0));
OBTEST_END_TEST()
OBTEST_START_TEST("Check playable")
OBTEST_DOINTCOMPARE(pRecord->IsPlayable(), ==, ((g_TestValues[Index].Flags & OB_CLOTFLAG_NONPLAYABLE) == 0));
OBTEST_END_TEST()
OBTEST_START_TEST("Check script formID")
OBTEST_DOINTCOMPARE(pRecord->GetScript(), ==, g_TestValues[Index].ScriptFormID);
OBTEST_END_TEST()
OBTEST_START_TEST("Check enchantment formID")
OBTEST_DOINTCOMPARE(pRecord->GetEnchantment(), ==, g_TestValues[Index].EnchantFormID);
OBTEST_END_TEST()
OBTEST_START_TEST("Check enchant points")
OBTEST_DOINTCOMPARE(pRecord->GetEnchantPoints(), ==, g_TestValues[Index].EnchantPts);
OBTEST_END_TEST()
}
return (true);
}
/*===========================================================================
* End of Function TestClot_Input()
*=========================================================================*/
| 36.766355
| 129
| 0.626843
|
uesp
|
39fa8414a7efdd1a3993b0b3a31cad00cf0e31c9
| 10,880
|
hpp
|
C++
|
include/ripple/utility/memory.hpp
|
robclu/ripple
|
734dfa77e100a86b3c60589d41ca627e41d4a783
|
[
"MIT"
] | 4
|
2021-04-25T16:38:12.000Z
|
2021-12-23T08:32:15.000Z
|
include/ripple/utility/memory.hpp
|
robclu/ripple
|
734dfa77e100a86b3c60589d41ca627e41d4a783
|
[
"MIT"
] | null | null | null |
include/ripple/utility/memory.hpp
|
robclu/ripple
|
734dfa77e100a86b3c60589d41ca627e41d4a783
|
[
"MIT"
] | null | null | null |
/**=--- ripple/utility/memory.hpp -------------------------- -*- C++ -*- ---==**
*
* Ripple
*
* Copyright (c) 2019 - 2021 Rob Clucas.
*
* This file is distributed under the MIT License. See LICENSE for details.
*
*==-------------------------------------------------------------------------==*
*
* \file memory.hpp
* \brief This file defines a utility functions for memory related operations.
*
*==------------------------------------------------------------------------==*/
#ifndef RIPPLE_UTILITY_MEMORY_HPP
#define RIPPLE_UTILITY_MEMORY_HPP
#include "portability.hpp"
#include <cassert>
#include <cstdint>
namespace ripple {
/**
* Gets a new ptr offset by the given amount from the ptr.
*
* \note This does __not__ ensure alignemt. If the pointer needs to be aligned,
* then pass the result to `align()`.
*
* \sa align
*
* \param ptr The pointer to offset.
* \param amount The amount to offset ptr by.
* \return A new pointer at the offset location.
*/
ripple_all static inline auto
offset_ptr(const void* ptr, uint32_t amount) noexcept -> void* {
return reinterpret_cast<void*>(uintptr_t(ptr) + amount);
}
/**
* Gets a pointer with an address aligned to the goven alignment.
*
* \note In debug, this will assert at runtime if the alignemnt is not a power
* of two, in release, the behaviour is undefined.
*
* \param ptr The pointer to align.
* \param alignment The alignment to ensure.
*/
ripple_all static inline auto
align_ptr(const void* ptr, size_t alignment) noexcept -> void* {
assert(
!(alignment & (alignment - 1)) &&
"Alignment must be a power of two for linear allocation!");
return reinterpret_cast<void*>(
(uintptr_t(ptr) + alignment - 1) & ~(alignment - 1));
}
namespace gpu {
/*==--- [device to device]--------------------------------------------------==*/
/**
* Copies the given bytes of data from one device pointer to the other.
*
* \note This will block on the host until the copy is complete.
*
* \param dev_ptr_in The device pointer to copy from.
* \param dev_ptr_out The device pointer to copy to.
* \param bytes The number of bytes to copy.
* \tparam DevPtr The type of the device pointer.
*/
template <typename DevPtr>
static inline auto memcpy_device_to_device(
DevPtr* dev_ptr_out, const DevPtr* dev_ptr_in, size_t bytes) -> void {
ripple_check_cuda_result(ripple_if_cuda(
cudaMemcpy(dev_ptr_out, dev_ptr_in, bytes, cudaMemcpyDeviceToDevice)));
}
/**
* Copies given number of bytes of data from the one device pointer to the
* other device ptr, asynchronously.
*
* \note This will not block on the host, and will likely return before the
* copy is complete.
*
* \param dev_ptr_in The device pointer to copy from.
* \param dev_ptr_out The device pointer to copy to.
* \param bytes The number of bytes to copy.
* \tparam DevPtr The type of the device pointer.
*/
template <typename DevPtr>
static inline auto memcpy_device_to_device_async(
DevPtr* dev_ptr_out, const DevPtr* dev_ptr_in, size_t bytes) -> void {
ripple_check_cuda_result(ripple_if_cuda(
cudaMemcpyAsync(dev_ptr_out, dev_ptr_in, bytes, cudaMemcpyDeviceToDevice)));
}
/**
* Copies given number of bytes of data from the one device pointer to the
* other device ptr, asynchronously on the given stream.
*
* \note This will not block on the host, and will likely return before the
* copy is complete.
*
* \param dev_ptr_in The device pointer to copy from.
* \param dev_ptr_out The device pointer to copy to.
* \param bytes The number of bytes to copy.
* \param stream The stream to perform the copy on.
* \tparam DevPtr The type of the device pointer.
*/
template <typename DevPtr>
static inline auto memcpy_device_to_device_async(
DevPtr* dev_ptr_out, const DevPtr* dev_ptr_in, size_t bytes, GpuStream stream)
-> void {
ripple_check_cuda_result(ripple_if_cuda(cudaMemcpyAsync(
dev_ptr_out, dev_ptr_in, bytes, cudaMemcpyDeviceToDevice, stream)));
}
/*==--- [host to device] ---------------------------------------------------==*/
/**
* Copies the given number of bytes of data from the host pointer to the device
* pointer.
*
* \note This will block on the host until the copy completes.
*
* \param dev_ptr The device pointer to copy to.
* \param host_ptr The host pointer to copy from.
* \param bytes The number of bytes to copy.
* \tparam DevPtr The type of the device pointer.
* \tparam HostPtr The type of the host pointer.
*/
template <typename DevPtr, typename HostPtr>
static inline auto
memcpy_host_to_device(DevPtr* dev_ptr, const HostPtr* host_ptr, size_t bytes)
-> void {
ripple_check_cuda_result(ripple_if_cuda(
cudaMemcpy(dev_ptr, host_ptr, bytes, cudaMemcpyHostToDevice)));
}
/**
* Copies the given number of bytes of data from the host pointer to the device
* pointer, asynchronously.
*
* \note This will not block on the host until the copy completes.
*
* \param dev_ptr The device pointer to copy to.
* \param host_ptr The host pointer to copy from.
* \param bytes The number of bytes to copy.
* \tparam DevPtr The type of the device pointer.
* \tparam HostPtr The type of the host pointer.
*/
template <typename DevPtr, typename HostPtr>
static inline auto memcpy_host_to_device_async(
DevPtr* dev_ptr, const HostPtr* host_ptr, size_t bytes) -> void {
ripple_check_cuda_result(ripple_if_cuda(
cudaMemcpyAsync(dev_ptr, host_ptr, bytes, cudaMemcpyHostToDevice)));
}
/**
* Copies the given number of bytes of data from the host pointer to the device
* pointer, asynchronously.
*
* \note This will not block on the host until the copy completes.
*
* \note This requires that the \p host_ptr data be page locked, which should
* have been allocated with alloc_pinned(). This overload alows the
* stream to be specified, which will allow the copy operation to be
* overlapped with operations in other streams, and possibly computation
* in the same stream, if suppored.
*
* \param dev_ptr The device pointer to copy to.
* \param host_ptr The host pointer to copy from.
* \param bytes The number of bytes to copy.
* \param stream The stream to perform the copy on.
* \tparam DevPtr The type of the device pointer.
* \tparam HostPtr The type of the host pointer.
*/
template <typename DevPtr, typename HostPtr>
static inline auto memcpy_host_to_device_async(
DevPtr* dev_ptr, const HostPtr* host_ptr, size_t bytes, GpuStream stream)
-> void {
ripple_check_cuda_result(ripple_if_cuda(
cudaMemcpyAsync(dev_ptr, host_ptr, bytes, cudaMemcpyHostToDevice, stream)));
}
/*==--- [device to host] ---------------------------------------------------==*/
/**
* Copies the given number of bytes of data from the device pointer to the
* host pointer.
*
* \note This will block on the host until the copy is complete.
*
* \param host_ptr The host pointer to copy from.
* \param dev_ptr The device pointer to copy to.
* \param bytes The number of bytes to copy.
* \tparam HostPtr The type of the host pointer.
* \tparam DevPtr The type of the device pointer.
*/
template <typename HostPtr, typename DevPtr>
static inline auto
memcpy_device_to_host(HostPtr* host_ptr, const DevPtr* dev_ptr, size_t bytes)
-> void {
ripple_check_cuda_result(ripple_if_cuda(
cudaMemcpy(host_ptr, dev_ptr, bytes, cudaMemcpyDeviceToHost)));
}
/**
* Copies the given number of bytes of data from the device pointer to the
* host pointer. asynchronously.
*
* \note This will not block on the host until the copy is complete.
*
* \param host_ptr The host pointer to copy from.
* \param dev_ptr The device pointer to copy to.
* \param bytes The number of bytes to copy.
* \tparam HostPtr The type of the host pointer.
* \tparam DevPtr The type of the device pointer.
*/
template <typename HostPtr, typename DevPtr>
static inline auto memcpy_device_to_host_async(
HostPtr* host_ptr, const DevPtr* dev_ptr, size_t bytes) -> void {
ripple_check_cuda_result(ripple_if_cuda(
cudaMemcpyAsync(host_ptr, dev_ptr, bytes, cudaMemcpyDeviceToHost)));
}
/**
* Copies the given number of bytes of data from the device pointer to the
* host pointer. asynchronously, on the given stream.
*
* \note This will not block on the host until the copy is complete.
*
* \param host_ptr The host pointer to copy from.
* \param dev_ptr The device pointer to copy to.
* \param bytes The number of bytes to copy.
* \param stream The stream to perform the copy on.
* \tparam HostPtr The type of the host pointer.
* \tparam DevPtr The type of the device pointer.
*/
template <typename HostPtr, typename DevPtr>
static inline auto memcpy_device_to_host_async(
HostPtr* host_ptr,
const DevPtr* dev_ptr,
size_t bytes,
const GpuStream& stream) -> void {
ripple_check_cuda_result(ripple_if_cuda(
cudaMemcpyAsync(host_ptr, dev_ptr, bytes, cudaMemcpyDeviceToHost, stream)));
}
/*==--- [allocation device] ------------------------------------------------==*/
/**
* Allocates the given number of bytes of memory on the device at the location
* pointed to by the pointer.
* \param dev_ptr The device pointer to allocate memory for.
* \param bytes The number of bytes to allocate.
* \tparam Ptr The type of the pointer.
*/
template <typename Ptr>
static inline auto allocate_device(Ptr** dev_ptr, size_t bytes) -> void {
ripple_check_cuda_result(ripple_if_cuda(cudaMalloc((void**)dev_ptr, bytes)));
}
/**
* Frees the pointer.
* \param ptr The pointer to free.
* \tparam Ptr The type of the pointer to free.
*/
template <typename Ptr>
static inline auto free_device(Ptr* ptr) -> void {
ripple_check_cuda_result(ripple_if_cuda(cudaFree(ptr)));
}
} // namespace gpu
namespace cpu {
/**
* Allocates the given number of bytes of page locked (pinned) memory at the
* location of the host pointer.
*
* \todo Add support for pinned allocation if no cuda.
*
* \param host_ptr The host pointer for the allocated memory.
* \param bytes The number of bytes to allocate.
* \tparam Ptr The type of the pointer.
*/
template <typename Ptr>
static inline auto allocate_host_pinned(Ptr** host_ptr, size_t bytes) -> void {
ripple_check_cuda_result(ripple_if_cuda(
cudaHostAlloc((void**)host_ptr, bytes, cudaHostAllocPortable)));
}
/**
* Frees the pointer which was allocated as pinned memory.
*
* \param ptr The pointer to free.
* \tparam Ptr The type of the pointer to free.
*/
template <typename Ptr>
static inline auto free_host_pinned(Ptr* ptr) -> void {
ripple_check_cuda_result(ripple_if_cuda(cudaFreeHost(ptr)));
}
} // namespace cpu
} // namespace ripple
#endif // RIPPLE_UTILITY_MEMORY_HPP
| 34.983923
| 80
| 0.688879
|
robclu
|
39fcd126f2f7b60511a4fffe5052e76a511f9731
| 7,477
|
cpp
|
C++
|
trunk/win/Source/BT_ThreadableUnit.cpp
|
dyzmapl/BumpTop
|
1329ea41411c7368516b942d19add694af3d602f
|
[
"Apache-2.0"
] | 460
|
2016-01-13T12:49:34.000Z
|
2022-02-20T04:10:40.000Z
|
trunk/win/Source/BT_ThreadableUnit.cpp
|
dyzmapl/BumpTop
|
1329ea41411c7368516b942d19add694af3d602f
|
[
"Apache-2.0"
] | 24
|
2016-11-07T04:59:49.000Z
|
2022-03-14T06:34:12.000Z
|
trunk/win/Source/BT_ThreadableUnit.cpp
|
dyzmapl/BumpTop
|
1329ea41411c7368516b942d19add694af3d602f
|
[
"Apache-2.0"
] | 148
|
2016-01-17T03:16:43.000Z
|
2022-03-17T12:20:36.000Z
|
// Copyright 2012 Google Inc. 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 "BT_Common.h"
#include "BT_ThreadableUnit.h"
#include "BT_Util.h"
ThreadableUnit::ThreadableUnit()
: _state(Queued)
, _thread(NULL)
, _result(false)
, _repeated(false)
, _repeatedDelay(0)
, _threadDebugIdentifier(0)
{}
ThreadableUnit::~ThreadableUnit()
{
// force kill the thread
join(512);
}
unsigned int __stdcall ThreadableUnit::pRunFunc(LPVOID lpParameter)
{
ThreadableUnit * unit = (ThreadableUnit *) lpParameter;
unit->_mutex.lock();
unit->_state = Processing;
bool repeated = unit->_repeated;
unit->_mutex.unlock();
bool res = true;
// if we are repeating, then run the runOnce func
if (repeated)
res = unit->_runRepeatedOnceFunc();
// if not repeating or repeating and runOnce succeeds, then runFunc()
do
{
if (res)
unit->_runFunc();
unit->_mutex.lock();
if (!repeated || !res)
{
// thread has completed, just return
unit->_result = res;
unit->_state = ThreadableUnit::Complete;
CloseHandle(unit->_thread);
unit->_thread = NULL;
unit->_mutex.unlock();
break;
}
else
{
int delay = unit->_repeatedDelay;
// run the thread again after the specified delay
unit->_state = ProcessingIdle;
unit->_mutex.unlock();
// sleep _after_ unlocking the mutex
Sleep(delay);
}
} while (repeated);
return 0;
}
void ThreadableUnit::run(boost::function<bool ()> runFunc, int threadDebugIdentifier)
{
_mutex.lock();
// create a new thread which calls the runFunc
_state = Queued;
_repeated = false;
_result = false;
_runFunc = runFunc;
_threadDebugIdentifier = threadDebugIdentifier;
_thread = (HANDLE) _beginthreadex(NULL, 0, &pRunFunc, (LPVOID) this, 0, NULL);
_mutex.unlock();
}
void ThreadableUnit::reRun()
{
_mutex.lock();
// create a new thread which calls the previous runFunc
_state = Queued;
_repeated = false;
_result = false;
_thread = (HANDLE) _beginthreadex(NULL, 0, &pRunFunc, (LPVOID) this, 0, NULL);
_mutex.unlock();
}
void ThreadableUnit::runRepeated( boost::function<bool ()> runRepeatedOnceFunc, boost::function<bool ()> runFunc, int delay, int threadDebugIdentifier )
{
assert(delay > 0);
_mutex.lock();
// create a new thread which calls the runFunc over and over again until
// the thread either joins or runFunc returns false
_state = Queued;
_repeated = true;
_repeatedDelay = delay;
_result = false;
_runFunc = runFunc;
_runRepeatedOnceFunc = runRepeatedOnceFunc;
_threadDebugIdentifier = threadDebugIdentifier;
_thread = (HANDLE) _beginthreadex(NULL, 0, &pRunFunc, (LPVOID) this, 0, NULL);
_mutex.unlock();
}
void ThreadableUnit::join(int killAfterMillis)
{
// wait until it is safe to terminate
int count = 0;
while ((getState() == Processing) &&
((count < killAfterMillis) || (killAfterMillis < 0)))
{
Sleep(32);
count += 32;
}
if (getState() == ProcessingIdle ||
killAfterMillis > -1)
{
_mutex.lock();
if (_thread)
{
TerminateThread(_thread, 0);
CloseHandle(_thread);
}
_thread = NULL;
_state = Complete;
_mutex.unlock();
}
}
ThreadableUnit::State ThreadableUnit::getState()
{
if (_mutex.tryLock())
{
State s = _state;
_mutex.unlock();
return s;
}
else
return ThreadableUnit::Processing;
}
bool ThreadableUnit::getResult()
{
// XXX: Note that it is expected that this is only called when the state is complete
if (getState() == ThreadableUnit::Complete)
return _result;
else
return false;
}
void ThreadableUnit::markAsSafeToJoin(bool safeToTerminate)
{
_mutex.lock();
_state = (safeToTerminate ? ProcessingIdle : Processing);
_mutex.unlock();
}
void ThreadableUnit::setRepeatDelay( int delay )
{
_mutex.lock();
_repeatedDelay = delay;
_mutex.unlock();
}
// ------------------------------------------------------------------------------------------------
ThreadableTextureUnit::ThreadableTextureUnit(const GLTextureObject& param, int maxRuntime)
: _state(Queued)
, _thread(NULL)
, _result(false)
, _param(param)
{
_runtimeTimer.setTimerDuration(maxRuntime);
_runtimeTimer.setTimerEventHandler(boost::bind(&ThreadableTextureUnit::joinNow, this));
}
ThreadableTextureUnit::ThreadableTextureUnit(const GLTextureObject& param)
: _state(Queued)
, _thread(NULL)
, _result(false)
, _param(param)
{}
ThreadableTextureUnit::~ThreadableTextureUnit()
{
// force kill the thread
join(512);
}
unsigned int __stdcall ThreadableTextureUnit::pRunFunc(LPVOID lpParameter)
{
ThreadableTextureUnit * unit = (ThreadableTextureUnit *) lpParameter;
unit->_mutex.lock();
unit->_state = Processing;
unit->_mutex.unlock();
int res = unit->_runFunc(unit->_param);
unit->_mutex.lock();
// thread has completed, just return
unit->_result = res;
unit->_state = ThreadableTextureUnit::Complete;
CloseHandle(unit->_thread);
unit->_thread = NULL;
unit->_mutex.unlock();
return 0;
}
void ThreadableTextureUnit::run(boost::function<int (GLTextureObject)> runFunc, int threadDebugIdentifier)
{
_mutex.lock();
// create a new thread which calls the runFunc
_result = -1;
_runFunc = runFunc;
_threadDebugIdentifier = threadDebugIdentifier;
if (_runtimeTimer.getDuration() > 0)
_runtimeTimer.start();
_thread = (HANDLE) _beginthreadex(NULL, 0, &pRunFunc, (LPVOID) this, 0, NULL);
_mutex.unlock();
}
void ThreadableTextureUnit::join(int killAfterMillis)
{
// wait until it is safe to terminate
int count = 0;
while (getState() == Processing &&
count < killAfterMillis)
{
Sleep(32);
count += 32;
}
if (getState() == ProcessingIdle ||
killAfterMillis > -1)
{
_mutex.lock();
if (_thread)
{
TerminateThread(_thread, 0);
CloseHandle(_thread);
}
_thread = NULL;
_state = Complete;
_mutex.unlock();
}
}
ThreadableTextureUnit::State ThreadableTextureUnit::getState() const
{
if (_mutex.tryLock())
{
State s = _state;
_mutex.unlock();
return s;
}
else
return ThreadableTextureUnit::Processing;
}
int ThreadableTextureUnit::getResult() const
{
// XXX: Note that it is expected that this is only called when the state is complete
if (getState() == ThreadableTextureUnit::Complete)
return _result;
else
return -1;
}
void ThreadableTextureUnit::markAsSafeToJoin(bool safeToTerminate)
{
_mutex.lock();
_state = (safeToTerminate ? ProcessingIdle : Processing);
_mutex.unlock();
}
GLTextureObject ThreadableTextureUnit::getParam()
{
// NOTE: since this is a read-only variable, we don't have to synchronize access to it
return _param;
}
void ThreadableTextureUnit::joinNow()
{
join(0);
_mutex.lock();
_state = Expired;
_mutex.unlock();
}
| 24.923333
| 153
| 0.671927
|
dyzmapl
|
2603f24fa10bb207b89b226b36885e6a30549682
| 5,911
|
hpp
|
C++
|
include/graphics.hpp
|
a276me/MilSim
|
b3ba8ef8cc46b6ae9cc7befece6cd00b016038ea
|
[
"MIT"
] | null | null | null |
include/graphics.hpp
|
a276me/MilSim
|
b3ba8ef8cc46b6ae9cc7befece6cd00b016038ea
|
[
"MIT"
] | null | null | null |
include/graphics.hpp
|
a276me/MilSim
|
b3ba8ef8cc46b6ae9cc7befece6cd00b016038ea
|
[
"MIT"
] | null | null | null |
#pragma once
#include "raylib.h"
#include "main.hpp"
#include "Division.hpp"
const int SCREEN_WIDTH = 1280*1.5;
const int SCREEN_HEIGHT = 960*1.2;
Texture2D natoTest;
Texture2D natoInf;
Texture2D natoArmor;
Texture2D natoMechInf;
Texture2D hostileInf;
Texture2D hostileArmor;
Texture2D hostileMechInf;
void initRL();
void endRL();
void drawUI();
void drawDivision();
void drawCamera();
void drawScreen();
void loadResources();
void updateVariables();
Camera2D camera = { 0 };
void updateVariables(){
int t = 1;
if(IsKeyDown(KEY_LEFT_SHIFT)) t = 3;
int s = 10;
if (IsKeyDown(KEY_A)) camera.target.x -= t*s;
else if (IsKeyDown(KEY_D)) camera.target.x += t*s;
if (IsKeyDown(KEY_W)) camera.target.y -= t*s;
else if (IsKeyDown(KEY_S)) camera.target.y += t*s;
// Camera zoom controls
camera.zoom += ((float)GetMouseWheelMove()*t*0.02f);
if (camera.zoom > 3.f) camera.zoom = 3.f;
else if (camera.zoom < .01f) camera.zoom = .01f;
// Camera reset (zoom and rotation)
if (IsKeyPressed(KEY_R))
{
camera.zoom = 1.0f;
camera.rotation = 0.0f;
camera.target = (Vector2){0,0};
}
}
void loadResources(){
natoTest = LoadTexture("nato.png");
natoInf = LoadTexture("./assets/NATO/friendly_infantry.png");
natoMechInf = LoadTexture("./assets/NATO/friendly_mech_infantry.png");
natoArmor = LoadTexture("./assets/NATO/friendly_armor.png");
hostileInf = LoadTexture("./assets/HOSTILE/hostile_inf.png");
hostileMechInf = LoadTexture("./assets/HOSTILE/hostile_mech_inf.png");
hostileArmor = LoadTexture("./assets/HOSTILE/hostile_armor.png");
}
void initRL(){
InitWindow(SCREEN_WIDTH, SCREEN_HEIGHT, "raylib [core] example - basic window");
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
loadResources();
camera.target = (Vector2){ 0,0 };
camera.offset = (Vector2){ SCREEN_WIDTH/2.0f, SCREEN_HEIGHT/2.0f };
camera.rotation = 0.0f;
camera.zoom = 1.0f;
MaximizeWindow();
}
void endRL(){
UnloadTexture(natoTest);
UnloadTexture(natoInf);
UnloadTexture(natoArmor);
UnloadTexture(natoMechInf);
UnloadTexture(hostileInf);
UnloadTexture(hostileArmor);
UnloadTexture(hostileMechInf);
CloseWindow();
}
void drawUI(){
ClearBackground((Color){ 245, 245, 245, 255 });
DrawFPS(10,10);
}
void drawDivision(){
float s = 0.7f;
float ss = 100.f;
for(int i=0; i<divisions.size(); i++){
DrawCircleV((Vector2){divisions[i].position.x*ss, -divisions[i].position.y*ss}, ss*divisions[i].getBD()/2.f, (Color){ 100, 100, 100, 100 });
if(divisions[i].moving) DrawLineEx((Vector2){divisions[i].position.x*ss,-divisions[i].position.y*ss}, (Vector2){divisions[i].getTarget().x*ss, -divisions[i].getTarget().y*ss}, 20, (Color){0,0,0,255});
}
for(int i=0; i<divisions.size(); i++){
if(divisions[i].team == 0){
if(divisions[i].getType() == INFANTRY_DIV){
DrawTextureEx(natoInf, (Vector2){ss*divisions[i].getPos().x-(natoInf.width/2)*s,ss*-divisions[i].getPos().y-(natoInf.height/2)*s}, 0, s,(Color){ 255, 255, 255, 255 });
} else if(divisions[i].getType() == ARMORED_DIV){
DrawTextureEx(natoArmor, (Vector2){ss*divisions[i].getPos().x-(natoArmor.width/2)*s,ss*-divisions[i].getPos().y-(natoArmor.height/2)*s}, 0, s,(Color){ 255, 255, 255, 255 });
} else if(divisions[i].getType() == MECH_INFANTRY_DIV){
DrawTextureEx(natoMechInf, (Vector2){ss*divisions[i].getPos().x-(natoMechInf.width/2)*s,ss*-divisions[i].getPos().y-(natoMechInf.height/2)*s}, 0, s,(Color){ 255, 255, 255, 255 });
}
}else if(divisions[i].team == 1){
if(divisions[i].getType() == INFANTRY_DIV){
DrawTextureEx(hostileInf, (Vector2){ss*divisions[i].getPos().x-(hostileInf.width/2)*s,ss*-divisions[i].getPos().y-(hostileInf.height/2)*s}, 0, s,(Color){ 255, 255, 255, 255 });
} else if(divisions[i].getType() == ARMORED_DIV){
DrawTextureEx(hostileArmor, (Vector2){ss*divisions[i].getPos().x-(hostileArmor.width/2)*s,ss*-divisions[i].getPos().y-(hostileArmor.height/2)*s}, 0, s,(Color){ 255, 255, 255, 255 });
} else if(divisions[i].getType() == MECH_INFANTRY_DIV){
DrawTextureEx(hostileMechInf, (Vector2){ss*divisions[i].getPos().x-(hostileMechInf.width/2)*s,ss*-divisions[i].getPos().y-(hostileMechInf.height/2)*s}, 0, s,(Color){ 255, 255, 255, 255 });
}
}
DrawText(divisions[i].getName().c_str(),ss*divisions[i].getPos().x-(MeasureText(divisions[i].getName().c_str(), 200)/2), ss*-divisions[i].getPos().y-(hostileInf.height/2)*s-220,200,(Color){ 0, 0, 0, 255 });
DrawText(std::to_string((int)divisions[i].getOrg()).c_str(),ss*divisions[i].getPos().x+(natoInf.width/2)*s+20, ss*-divisions[i].getPos().y-210,200,(Color){ 0, 0, 0, 255 });
DrawText(std::to_string((int)divisions[i].getStrength()).c_str(),ss*divisions[i].getPos().x+(natoInf.width/2)*s+20, ss*-divisions[i].getPos().y,200,(Color){ 0, 0, 0, 255 });
DrawText(std::to_string((int)divisions[i].getBV()).c_str(),ss*divisions[i].getPos().x-(natoInf.width/2)*s-MeasureText(std::to_string((int)divisions[i].getBV()).c_str(),200)-30, ss*-divisions[i].getPos().y-200,200,(Color){ 0, 0, 0, 255 });
DrawText(std::to_string((int)divisions[i].getDV()).c_str(),ss*divisions[i].getPos().x-(natoInf.width/2)*s-MeasureText(std::to_string((int)divisions[i].getDV()).c_str(),200)-30, ss*-divisions[i].getPos().y+20,200,(Color){ 0, 0, 0, 255 });
}
}
void drawCamera(){
updateVariables();
BeginMode2D(camera);
drawDivision();
EndMode2D();
}
void drawScreen(){
BeginDrawing();
drawUI();
drawCamera();
EndDrawing();
}
| 34.366279
| 246
| 0.630012
|
a276me
|
26060c9cd453f6eb01ded7d869aafb8e9c4fb67d
| 997
|
hpp
|
C++
|
RayTracer/core/source/RTweekend.hpp
|
ZFhuang/AmbiRenderer
|
d223e1c4d947872c9011c1cba6a8f498ebbaf3b7
|
[
"Apache-2.0"
] | null | null | null |
RayTracer/core/source/RTweekend.hpp
|
ZFhuang/AmbiRenderer
|
d223e1c4d947872c9011c1cba6a8f498ebbaf3b7
|
[
"Apache-2.0"
] | null | null | null |
RayTracer/core/source/RTweekend.hpp
|
ZFhuang/AmbiRenderer
|
d223e1c4d947872c9011c1cba6a8f498ebbaf3b7
|
[
"Apache-2.0"
] | null | null | null |
#pragma once
#include <cmath>
#include <limits>
#include <memory>
#include <random>
// 保存Ray Tracing in One Weekend项目所需的基本常量和函数
using std::shared_ptr;
using std::make_shared;
using std::sqrt;
const double infinity = std::numeric_limits<double>::infinity();
const double pi = 3.1415926535897932385;
// 角度转弧度
inline double degrees_to_radians(double degrees) {
return degrees * pi / 180.0;
}
// 生成范围内的double均匀分布随机数
inline double random_double(double min = 0.0, double max = 1.0) {
// 生成种子
static std::random_device rd;
// 调用生成器
static std::mt19937 generator(rd());
// 注意这个该死的生成器只能生成非负数
static std::uniform_real_distribution<double> distribution(0.0, 1.0);
// 移动分布范围
return min + (max - min) * distribution(generator);
}
inline int random_int(int min = 0, int max = 1) {
return static_cast<int>(random_double(min, max + 1));
}
// 按照min和max对值进行截断
inline double clamp(double x, double min, double max) {
if (x < min) {
return min;
}
if (x > max) {
return max;
}
return x;
}
| 20.346939
| 70
| 0.706118
|
ZFhuang
|
2609c25feca6969e8f9c31b3be4f6301848dc8dc
| 3,645
|
cpp
|
C++
|
2017-09-10-practice/E.cpp
|
tangjz/Three-Investigators
|
46dc9b2f0fbb4fe89b075a81feaacc33feeb1b52
|
[
"MIT"
] | 3
|
2018-04-02T06:00:51.000Z
|
2018-05-29T04:46:29.000Z
|
2017-09-10-practice/E.cpp
|
tangjz/Three-Investigators
|
46dc9b2f0fbb4fe89b075a81feaacc33feeb1b52
|
[
"MIT"
] | 2
|
2018-03-31T17:54:30.000Z
|
2018-05-02T11:31:06.000Z
|
2017-09-10-practice/E.cpp
|
tangjz/Three-Investigators
|
46dc9b2f0fbb4fe89b075a81feaacc33feeb1b52
|
[
"MIT"
] | 2
|
2018-10-07T00:08:06.000Z
|
2021-06-28T11:02:59.000Z
|
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef long double DB;
const int maxn = 500001, INF = 0x3f3f3f3f;
int rad, n, totL, totR;
struct Query {
int typ, x, y;
} que[maxn];
struct Fraction {
LL x, y;
Fraction() {}
Fraction(LL _x, LL _y) { // _y > 0
LL r = __gcd(abs(_x), _y);
x = _x / r;
y = _y / r;
}
bool operator == (Fraction const &t) const {
return x == t.x && y == t.y;
}
bool operator < (Fraction const &t) const {
return (DB)x * t.y < (DB)t.x * y;
}
} pL[maxn], pR[maxn], seqL[maxn], seqR[maxn];
int cnt, idx[maxn], ord[maxn], pos[maxn], seg[maxn << 1 | 1];
inline int seg_idx(int L, int R) {
return (L + R) | (L < R);
}
void seg_upd(int L, int R, int x, int v) {
int rt = seg_idx(L, R);
if(L == R) {
seg[rt] = v;
return;
}
int M = (L + R) >> 1, lch = seg_idx(L, M), rch = seg_idx(M + 1, R);
if(x <= M)
seg_upd(L, M, x, v);
else
seg_upd(M + 1, R, x, v);
seg[rt] = min(seg[lch], seg[rch]);
}
int seg_que(int L, int R, int l, int r) {
if(l <= L && R <= r)
return seg[seg_idx(L, R)];
int M = (L + R) >> 1, ret = INF;
if(l <= M)
ret = min(ret, seg_que(L, M, l, r));
if(M < r)
ret = min(ret, seg_que(M + 1, R, l, r));
return ret;
}
inline int sgn(int x) {
return (x > 0) - (x < 0);
}
inline LL sqr(int x) {
return (LL)x * x;
}
bool cmp(int const &u, int const &v) {
return que[u].x < que[v].x;
}
int main() {
scanf("%d%d", &rad, &n);
for(int i = 1; i <= n; ++i) {
int &typ = que[i].typ, &x = que[i].x, &y = que[i].y;
scanf("%d%d", &typ, &x);
if(typ != 2)
scanf("%d", &y);
if(typ != 1)
continue;
LL A = sqr(rad + x), B = sqr(rad - x), C = sqr(y);
seqL[++totL] = pL[i] = Fraction(sgn(rad + x) * A, A + C);
seqR[++totR] = pR[i] = Fraction(sgn(rad - x) * B, B + C);
}
sort(seqL + 1, seqL + totL + 1);
totL = unique(seqL + 1, seqL + totL + 1) - seqL - 1;
sort(seqR + 1, seqR + totR + 1);
totR = unique(seqR + 1, seqR + totR + 1) - seqR - 1;
for(int i = 1; i <= n; ++i) {
int &typ = que[i].typ, &x = que[i].x, &y = que[i].y;
if(typ == 1) {
int px = x, py = y;
x = lower_bound(seqL + 1, seqL + totL + 1, pL[i]) - seqL;
y = lower_bound(seqR + 1, seqR + totR + 1, pR[i]) - seqR;
pL[i] = px >= -rad ? Fraction(sqr(px + rad) - sqr(py), sqr(px + rad) + sqr(py)) : Fraction(-1, 1);
pR[i] = px <= rad ? Fraction(sqr(py) - sqr(px - rad), sqr(px - rad) + sqr(py)) : Fraction(1, 1);
ord[++cnt] = i;
idx[cnt] = i;
}
}
sort(ord + 1, ord + cnt + 1, cmp);
for(int i = 1; i <= cnt; ++i)
pos[ord[i]] = i;
static bool vis[maxn] = {};
memset(seg + 1, 0x3f, (cnt << 1) * sizeof(int));
for(int i = 1; i <= n; ++i) {
int &typ = que[i].typ, &x = que[i].x, &y = que[i].y;
if(typ == 1) {
vis[i] = 1;
// printf("ins %d: %d %d\n", pos[i], que[i].x, que[i].y);
seg_upd(1, cnt, pos[i], que[i].y);
} else if(typ == 2) {
x = idx[x];
assert(vis[x] == 1);
// printf("rem %d: %d %d\n", pos[x], que[x].x, que[x].y);
seg_upd(1, cnt, pos[x], INF);
vis[x] = 0;
} else {
x = idx[x], y = idx[y];
assert(vis[x] == 1 && vis[y] == 1);
// printf("ask (%d, %d) (%d, %d)\n", que[x].x, que[x].y, que[y].x, que[y].y);
if(min(pR[x], pR[y]) < max(pL[x], pL[y])) {
puts("NO");
continue;
}
int A = max(que[x].x, que[y].x), B = max(que[x].y, que[y].y);
seg_upd(1, cnt, pos[x], INF);
seg_upd(1, cnt, pos[y], INF);
que[0] = (Query){0, A};
int id = upper_bound(ord + 1, ord + cnt + 1, 0, cmp) - ord - 1;
// printf("query [%d, %d]\n", 1, id);
puts(seg_que(1, cnt, 1, id) > B ? "YES" : "NO");
seg_upd(1, cnt, pos[x], que[x].y);
seg_upd(1, cnt, pos[y], que[y].y);
}
}
return 0;
}
| 28.476563
| 101
| 0.494925
|
tangjz
|
260e864a1f93c48554bc7ee15e6a536d28c1bc43
| 5,340
|
hpp
|
C++
|
include/GTGE/Editor/ParticleEditor/ParticleEditor.hpp
|
mackron/GTGameEngine
|
380d1e01774fe6bc2940979e4e5983deef0bf082
|
[
"BSD-3-Clause"
] | 31
|
2015-03-19T08:44:48.000Z
|
2021-12-15T20:52:31.000Z
|
include/GTGE/Editor/ParticleEditor/ParticleEditor.hpp
|
mackron/GTGameEngine
|
380d1e01774fe6bc2940979e4e5983deef0bf082
|
[
"BSD-3-Clause"
] | 19
|
2015-07-09T09:02:44.000Z
|
2016-06-09T03:51:03.000Z
|
include/GTGE/Editor/ParticleEditor/ParticleEditor.hpp
|
mackron/GTGameEngine
|
380d1e01774fe6bc2940979e4e5983deef0bf082
|
[
"BSD-3-Clause"
] | 3
|
2017-10-04T23:38:18.000Z
|
2022-03-07T08:27:13.000Z
|
// Copyright (C) 2011 - 2014 David Reid. See included LICENCE.
#ifndef GT_ParticleEditor
#define GT_ParticleEditor
#include "../SubEditor.hpp"
#include "../Editor3DViewportEventHandler.hpp"
#include "../EditorGrid.hpp"
#include "../EditorAxisArrows.hpp"
#include "../../ParticleSystem.hpp"
#include "../../Scene.hpp"
namespace GT
{
/// Class representing the particle system editor.
class ParticleEditor : public SubEditor
{
public:
/// Constructor.
ParticleEditor(Editor &ownerEditor, const char* absolutePath, const char* relativePath);
/// Destructor.
~ParticleEditor();
/// Resets the camera.
void ResetCamera();
/// Retrieves a reference tothe camera scene node.
SceneNode & GetCameraSceneNode() { return this->camera; }
const SceneNode & GetCameraSceneNode() const { return this->camera; }
/// Retrieves a reference to the particle system definition being editted.
ParticleSystemDefinition & GetParticleSystemDefinition();
/// Refreshes the viewport so that it shows the current state of the particle system being editted.
///
/// @remarks
/// This should be called whenever the particle definition has been modified.
void RefreshViewport();
/// Sets the orientation of the preview particle system.
void SetOrientation(const glm::quat &orientation);
/// Shows the grid.
void ShowGrid();
/// Hides the grid.
void HideGrid();
/// Determines whether or not the grid is showing.
bool IsShowingGrid() const;
/// Shows the axis arrows.
void ShowAxisArrows();
/// Hides the axis arrows.
void HideAxisArrows();
/// Determines whether or not the axis arrows is showing.
bool IsShowingAxisArrows() const;
///////////////////////////////////////////////////
// GUI Events.
//
// These events are received in response to certain GUI events.
/// Called when the main viewport is resized.
void OnViewportSize();
///////////////////////////////////////////////////
// Virtual Methods.
/// SubEditor::GetMainElement()
GUIElement* GetMainElement() { return this->mainElement; }
const GUIElement* GetMainElement() const { return this->mainElement; }
/// SubEditor::Show()
void Show();
/// SubEditor::Hide()
void Hide();
/// SubEditor::Save()
bool Save();
/// SubEditor::Update()
void OnUpdate(double deltaTimeInSeconds);
/// SubEditor::OnFileUpdate()
void OnFileUpdate(const char* absolutePath);
private:
private:
/// The particle system definition that is being editted. This is not instantiated by the particle system library.
ParticleSystemDefinition particleSystemDefinition;
/// The particle system to use in the preview window.
ParticleSystem particleSystem;
/// The scene for the preview window.
Scene scene;
/// The scene node acting as the camera for the preview window viewport.
SceneNode camera;
/// The scene node containing the particle system.
SceneNode particleNode;
/// The main container element.
GUIElement* mainElement;
/// The viewport element.
GUIElement* viewportElement;
/// The viewport event handler to we can detect when it is resized.
struct ViewportEventHandler : public Editor3DViewportEventHandler
{
/// Constructor.
ViewportEventHandler(ParticleEditor &ownerIn, Context &context, SceneViewport &viewport)
: Editor3DViewportEventHandler(context, viewport), owner(ownerIn)
{
}
/// Called after the element has been resized.
void OnSize(GUIElement &element)
{
Editor3DViewportEventHandler::OnSize(element);
owner.OnViewportSize();
}
/// The owner of the viewport.
ParticleEditor &owner;
}viewportEventHandler;
float cameraXRotation; ///< The camera's current X rotation.
float cameraYRotation; ///< The camera's current Y rotation.
/// The grid.
EditorGrid grid;
/// The axis arrows.
EditorAxisArrows axisArrows;
/// Keeps track of whether or not the editor is in the middle of saving. We use this in determining whether or not the settings should be
/// set when it detects a modification to the file on disk.
bool isSaving;
/// Keeps track of whether or not we are handling a reload. We use this in keeping track of whether or not to mark the file as modified
/// when the settings are changed.
bool isReloading;
/// Keeps track of whether or not the grid is visible.
bool isShowingGrid;
/// Keeps track of whether or not the axis arrows are visible.
bool isShowingAxisArrows;
private: // No copying.
ParticleEditor(const ParticleEditor &);
ParticleEditor & operator=(const ParticleEditor &);
};
}
#endif
| 27.525773
| 145
| 0.603933
|
mackron
|
260fbcac89d9c171b877e48c878a90c4994a737c
| 1,586
|
hpp
|
C++
|
legacy/galaxy/meta/UniqueId.hpp
|
reworks/rework
|
90508252c9a4c77e45a38e7ce63cfd99f533f42b
|
[
"Apache-2.0"
] | 6
|
2018-07-21T20:37:01.000Z
|
2018-10-31T01:49:35.000Z
|
legacy/galaxy/meta/UniqueId.hpp
|
reworks/rework
|
90508252c9a4c77e45a38e7ce63cfd99f533f42b
|
[
"Apache-2.0"
] | null | null | null |
legacy/galaxy/meta/UniqueId.hpp
|
reworks/rework
|
90508252c9a4c77e45a38e7ce63cfd99f533f42b
|
[
"Apache-2.0"
] | null | null | null |
///
/// UniqueId.hpp
/// galaxy
///
/// Refer to LICENSE.txt for more details.
///
#ifndef GALAXY_META_UNIQUEID_HPP_
#define GALAXY_META_UNIQUEID_HPP_
#include "galaxy/meta/Concepts.hpp"
namespace galaxy
{
namespace meta
{
///
/// Generates a unique id for a type for each type of specialization.
/// And the id is kept as a compile time constant.
///
template<is_class Specialization>
class UniqueId final
{
public:
///
/// Destructor.
///
~UniqueId() noexcept = default;
///
/// Use this function to retrieve the ID.
/// Will generate a new id if it is called for the first time.
///
/// \return Unique ID for the specialization of that type.
///
template<typename Type>
[[nodiscard]] static std::size_t get() noexcept;
private:
///
/// Constructor.
///
UniqueId() noexcept = default;
///
/// Copy constructor.
///
UniqueId(const UniqueId&) = delete;
///
/// Move constructor.
///
UniqueId(UniqueId&&) = delete;
///
/// Copy assignment operator.
///
UniqueId& operator=(const UniqueId&) = delete;
///
/// Move assignment operator.
///
UniqueId& operator=(UniqueId&&) = delete;
private:
///
/// Internal counter to keep track of allocated ids.
///
inline static std::size_t s_counter = 0;
};
template<is_class Specialization>
template<typename Type>
[[nodiscard]] inline std::size_t UniqueId<Specialization>::get() noexcept
{
static std::size_t id = s_counter++;
return id;
}
} // namespace meta
} // namespace galaxy
#endif
| 19.341463
| 75
| 0.628625
|
reworks
|