blob_id stringlengths 40 40 | directory_id stringlengths 40 40 | path stringlengths 3 264 | content_id stringlengths 40 40 | detected_licenses listlengths 0 85 | license_type stringclasses 2
values | repo_name stringlengths 5 140 | snapshot_id stringlengths 40 40 | revision_id stringlengths 40 40 | branch_name stringclasses 905
values | visit_date timestamp[us]date 2015-08-09 11:21:18 2023-09-06 10:45:07 | revision_date timestamp[us]date 1997-09-14 05:04:47 2023-09-17 19:19:19 | committer_date timestamp[us]date 1997-09-14 05:04:47 2023-09-06 06:22:19 | github_id int64 3.89k 681M ⌀ | star_events_count int64 0 209k | fork_events_count int64 0 110k | gha_license_id stringclasses 22
values | gha_event_created_at timestamp[us]date 2012-06-07 00:51:45 2023-09-14 21:58:39 ⌀ | gha_created_at timestamp[us]date 2008-03-27 23:40:48 2023-08-21 23:17:38 ⌀ | gha_language stringclasses 141
values | src_encoding stringclasses 34
values | language stringclasses 1
value | is_vendor bool 1
class | is_generated bool 2
classes | length_bytes int64 3 10.4M | extension stringclasses 115
values | content stringlengths 3 10.4M | authors listlengths 1 1 | author_id stringlengths 0 158 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
d6811ad3b73d8ecd99a60e8a33c54433a60af3c7 | a85a1e6c776e0433c30aa5830aa353a82f4c8833 | /styxnet/network_url.cpp | 1112cba6d36a8d2cdf47c38c7048596783568796 | [] | no_license | IceCube-22/darkreign2 | fe97ccb194b9eacf849d97b2657e7bd1c52d2916 | 9ce9da5f21604310a997f0c41e9cd383f5e292c3 | refs/heads/master | 2023-03-20T02:27:03.321950 | 2018-10-04T10:06:38 | 2018-10-04T10:06:38 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 602 | cpp | ////////////////////////////////////////////////////////////////////////////////
//
// Network Ping
//
// Copyright 1999-2000
// Matthew Versluys
//
////////////////////////////////////////////////////////////////////////////////
//
// Includes
//
#include "network_url.h"
////////////////////////////////////////////////////////////////////////////////
//
// NameSpace Network
//
namespace Network
{
////////////////////////////////////////////////////////////////////////////////
//
// Class Url
//
// Construct from a text string
Url::Url(const char *text)
{
text;
}
}
| [
"eider@protonmail.com"
] | eider@protonmail.com |
1e69ce7722195d6ad953f0f80e15b67e90d00e2c | 6ef890c3c67576b2aebdc50e6a00da1c5a7903d9 | /hexl/include/hexl/eltwise/eltwise-reduce-mod.hpp | 98042651e326cc6d7c97bdf41ad551549c574c05 | [
"Apache-2.0"
] | permissive | QQWangYao/hexl | e917afe5e012be7b02076530750a557e050c6933 | 24f7ffbe573911c583317a4dfd48eca691d06b9d | refs/heads/main | 2023-03-28T19:32:34.138315 | 2021-04-05T20:36:25 | 2021-04-05T20:36:25 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,091 | hpp | // Copyright (C) 2020-2021 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
#pragma once
#include <stdint.h>
namespace intel {
namespace hexl {
/// @brief Performs elementwise modular reduction
/// @param[out] result Stores the result
/// @param[in] operand
/// @param[in] n Number of elements in operand
/// @param[in] modulus Modulus with which to perform modular reduction
/// @param[in] input_mod_factor Assumes input elements are in [0,
/// input_mod_factor * p) Must be 0, 1, 2 or 4. input_mod_factor=0 means, no
/// knowledge of input range. Barrett reduction will be used in this case.
/// input_mod_factor >= output_mod_factor unless input_mod_factor == 0
/// @param[in] output_mod_factor output elements will be in [0,
/// output_mod_factor
/// * p) Must be 1 or 2. for input_mod_factor=0, output_mod_factor will be set
/// to 1.
void EltwiseReduceMod(uint64_t* result, const uint64_t* operand,
uint64_t modulus, uint64_t n, uint64_t input_mod_factor,
uint64_t output_mod_factor);
} // namespace hexl
} // namespace intel
| [
"fabian.boemer@intel.com"
] | fabian.boemer@intel.com |
a3afdfcf590498960c08bd06666f6edee223134a | b81bb88f02d9b3ea3030dcad42d326c0ebbe215d | /c/on_material.cpp | a621a30d4d674c0548d520d081768fcf98d9a39b | [
"LicenseRef-scancode-warranty-disclaimer"
] | no_license | arendvw/rhinocommon | fe7a6355bf6364e712addc3c10da07862dc17644 | c7f394498ab7d3c44cf7cb4cfed42046c831e194 | refs/heads/master | 2021-01-18T05:42:41.952897 | 2016-05-08T23:09:42 | 2016-05-08T23:09:42 | 7,479,517 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 14,103 | cpp | #include "StdAfx.h"
RH_C_FUNCTION ON_Material* ON_Material_New(const ON_Material* pConstOther)
{
ON_Material* rc = new ON_Material();
if( pConstOther )
*rc = *pConstOther;
return rc;
}
RH_C_FUNCTION void ON_Material_Default(ON_Material* pMaterial)
{
if( pMaterial )
pMaterial->Default();
}
RH_C_FUNCTION int ON_Material_Index(const ON_Material* pConstMaterial)
{
if( pConstMaterial )
return pConstMaterial->m_material_index;
return -1;
}
RH_C_FUNCTION int ON_Material_FindBitmapTexture(const ON_Material* pConstMaterial, const RHMONO_STRING* filename)
{
int rc = -1;
INPUTSTRINGCOERCE(_filename, filename);
if( pConstMaterial )
{
rc = pConstMaterial->FindTexture(_filename, ON_Texture::bitmap_texture);
}
return rc;
}
RH_C_FUNCTION void ON_Material_SetBitmapTexture(ON_Material* pMaterial, int index, const RHMONO_STRING* filename)
{
INPUTSTRINGCOERCE(_filename, filename);
if( pMaterial && index>=0 && index<pMaterial->m_textures.Count())
{
pMaterial->m_textures[index].m_filename = _filename;
}
}
RH_C_FUNCTION int ON_Material_AddBitmapTexture(ON_Material* pMaterial, const RHMONO_STRING* filename)
{
int rc = -1;
INPUTSTRINGCOERCE(_filename, filename);
if( pMaterial && _filename)
{
rc = pMaterial->AddTexture(_filename, ON_Texture::bitmap_texture);
}
return rc;
}
RH_C_FUNCTION int ON_Material_AddBumpTexture(ON_Material* pMaterial, const RHMONO_STRING* filename)
{
int rc = -1;
INPUTSTRINGCOERCE(_filename, filename);
if( pMaterial && _filename)
{
rc = pMaterial->AddTexture(_filename, ON_Texture::bump_texture);
}
return rc;
}
RH_C_FUNCTION int ON_Material_AddEnvironmentTexture(ON_Material* pMaterial, const RHMONO_STRING* filename)
{
int rc = -1;
INPUTSTRINGCOERCE(_filename, filename);
if( pMaterial && _filename)
{
rc = pMaterial->AddTexture(_filename, ON_Texture::emap_texture);
}
return rc;
}
RH_C_FUNCTION int ON_Material_AddTransparencyTexture(ON_Material* pMaterial, const RHMONO_STRING* filename)
{
int rc = -1;
INPUTSTRINGCOERCE(_filename, filename);
if( pMaterial && _filename)
{
rc = pMaterial->AddTexture(_filename, ON_Texture::transparency_texture);
}
return rc;
}
RH_C_FUNCTION bool ON_Material_ModifyTexture(ON_Material* pMaterial, ON_UUID texture_id, const ON_Texture* pConstTexture)
{
bool rc = false;
if( pMaterial && pConstTexture )
{
int index = pMaterial->FindTexture(texture_id);
if( index>=0 )
{
pMaterial->m_textures[index] = *pConstTexture;
rc = true;
}
}
return rc;
}
RH_C_FUNCTION double ON_Material_GetDouble(const ON_Material* pConstMaterial, int which)
{
const int idxShine = 0;
const int idxTransparency = 1;
const int idxIOR = 2;
const int idxReflectivity = 3;
double rc = 0;
if( pConstMaterial )
{
switch(which)
{
case idxShine:
rc = pConstMaterial->m_shine;
break;
case idxTransparency:
rc = pConstMaterial->m_transparency;
break;
case idxIOR:
rc = pConstMaterial->m_index_of_refraction;
break;
case idxReflectivity:
rc = pConstMaterial->m_reflectivity;
break;
}
}
return rc;
}
RH_C_FUNCTION void ON_Material_SetDouble(ON_Material* pMaterial, int which, double val)
{
const int idxShine = 0;
const int idxTransparency = 1;
const int idxIOR = 2;
const int idxReflectivity = 3;
if( pMaterial )
{
switch(which)
{
case idxShine:
pMaterial->SetShine(val);
break;
case idxTransparency:
pMaterial->SetTransparency(val);
break;
case idxIOR:
pMaterial->m_index_of_refraction = val;
break;
case idxReflectivity:
pMaterial->m_reflectivity = val;
break;
}
}
}
RH_C_FUNCTION bool ON_Material_AddTexture(ON_Material* pMaterial, const RHMONO_STRING* filename, int which)
{
// const int idxBitmapTexture = 0;
const int idxBumpTexture = 1;
const int idxEmapTexture = 2;
const int idxTransparencyTexture = 3;
bool rc = false;
if( pMaterial && filename )
{
ON_Texture::TYPE tex_type = ON_Texture::bitmap_texture;
if( idxBumpTexture==which ) tex_type = ON_Texture::bump_texture;
if( idxEmapTexture==which ) tex_type = ON_Texture::emap_texture;
if( idxTransparencyTexture==which ) tex_type = ON_Texture::transparency_texture;
int index = pMaterial->FindTexture(NULL, tex_type);
if( index>=0 )
pMaterial->DeleteTexture(NULL, tex_type);
INPUTSTRINGCOERCE(_filename, filename);
rc = pMaterial->AddTexture(_filename, tex_type)>=0;
}
return rc;
}
RH_C_FUNCTION bool ON_Material_SetTexture(ON_Material* pMaterial, const ON_Texture* pConstTexture, int which)
{
// const int idxBitmapTexture = 0;
const int idxBumpTexture = 1;
const int idxEmapTexture = 2;
const int idxTransparencyTexture = 3;
bool rc = false;
if( pMaterial && pConstTexture )
{
ON_Texture::TYPE tex_type = ON_Texture::bitmap_texture;
if( idxBumpTexture==which ) tex_type = ON_Texture::bump_texture;
if( idxEmapTexture==which ) tex_type = ON_Texture::emap_texture;
if( idxTransparencyTexture==which ) tex_type = ON_Texture::transparency_texture;
int index = pMaterial->FindTexture(NULL, tex_type);
if( index>=0 )
pMaterial->DeleteTexture(NULL, tex_type);
ON_Texture texture(*pConstTexture);
texture.m_type = tex_type;
rc = pMaterial->AddTexture(texture)>=0;
}
return rc;
}
RH_C_FUNCTION int ON_Material_GetTexture(const ON_Material* pConstMaterial, int which)
{
// const int idxBitmapTexture = 0;
const int idxBumpTexture = 1;
const int idxEmapTexture = 2;
const int idxTransparencyTexture = 3;
int rc = -1;
if( pConstMaterial )
{
ON_Texture::TYPE tex_type = ON_Texture::bitmap_texture;
if( idxBumpTexture==which ) tex_type = ON_Texture::bump_texture;
if( idxEmapTexture==which ) tex_type = ON_Texture::emap_texture;
if( idxTransparencyTexture==which ) tex_type = ON_Texture::transparency_texture;
rc = pConstMaterial->FindTexture(NULL, tex_type);
}
return rc;
}
RH_C_FUNCTION int ON_Material_GetTextureCount(const ON_Material* pConstMaterial)
{
if( pConstMaterial )
return pConstMaterial->m_textures.Count();
return 0;
}
RH_C_FUNCTION int ON_Material_GetColor( const ON_Material* pConstMaterial, int which )
{
const int idxDiffuse = 0;
const int idxAmbient = 1;
const int idxEmission = 2;
const int idxSpecular = 3;
const int idxReflection = 4;
const int idxTransparent = 5;
int rc = 0;
if( pConstMaterial )
{
unsigned int abgr = 0;
switch(which)
{
case idxDiffuse:
abgr = (unsigned int)(pConstMaterial->m_diffuse);
break;
case idxAmbient:
abgr = (unsigned int)(pConstMaterial->m_ambient);
break;
case idxEmission:
abgr = (unsigned int)(pConstMaterial->m_emission);
break;
case idxSpecular:
abgr = (unsigned int)(pConstMaterial->m_specular);
break;
case idxReflection:
abgr = (unsigned int)(pConstMaterial->m_reflection);
break;
case idxTransparent:
abgr = (unsigned int)(pConstMaterial->m_transparent);
break;
}
rc = (int)abgr;
}
return rc;
}
RH_C_FUNCTION void ON_Material_SetColor( ON_Material* pMaterial, int which, int argb )
{
const int idxDiffuse = 0;
const int idxAmbient = 1;
const int idxEmission = 2;
const int idxSpecular = 3;
const int idxReflection = 4;
const int idxTransparent = 5;
int abgr = ARGB_to_ABGR(argb);
if( pMaterial )
{
switch(which)
{
case idxDiffuse:
pMaterial->m_diffuse = abgr;
break;
case idxAmbient:
pMaterial->m_ambient = abgr;
break;
case idxEmission:
pMaterial->m_emission = abgr;
break;
case idxSpecular:
pMaterial->m_specular = abgr;
break;
case idxReflection:
pMaterial->m_reflection = abgr;
break;
case idxTransparent:
pMaterial->m_transparent = abgr;
break;
}
}
}
RH_C_FUNCTION void ON_Material_GetName(const ON_Material* pConstMaterial, CRhCmnStringHolder* pString)
{
if( pConstMaterial && pString )
{
pString->Set(pConstMaterial->m_material_name);
}
}
RH_C_FUNCTION void ON_Material_SetName(ON_Material* pMaterial, const RHMONO_STRING* name)
{
if( pMaterial )
{
INPUTSTRINGCOERCE(_name, name);
pMaterial->m_material_name = _name;
}
}
/////////////////////////////////////////////////////////////
RH_C_FUNCTION ON_Texture* ON_Texture_New()
{
return new ON_Texture();
}
RH_C_FUNCTION const ON_Texture* ON_Material_GetTexturePointer(const ON_Material* pConstMaterial, int index)
{
const ON_Texture* rc = NULL;
if( pConstMaterial && index>=0 )
{
rc = pConstMaterial->m_textures.At(index);
}
return rc;
}
RH_C_FUNCTION int ON_Material_NextBitmapTexture(const ON_Material* pConstMaterial, int index)
{
int rc = -1;
if( pConstMaterial )
{
rc = pConstMaterial->FindTexture(NULL, ON_Texture::bitmap_texture, index);
}
return rc;
}
RH_C_FUNCTION int ON_Material_NextBumpTexture(const ON_Material* pConstMaterial, int index)
{
int rc = -1;
if( pConstMaterial )
{
rc = pConstMaterial->FindTexture(NULL, ON_Texture::bump_texture, index);
}
return rc;
}
RH_C_FUNCTION int ON_Material_NextEnvironmentTexture(const ON_Material* pConstMaterial, int index)
{
int rc = -1;
if( pConstMaterial )
{
rc = pConstMaterial->FindTexture(NULL, ON_Texture::emap_texture, index);
}
return rc;
}
RH_C_FUNCTION int ON_Material_NextTransparencyTexture(const ON_Material* pConstMaterial, int index)
{
int rc = -1;
if( pConstMaterial )
{
rc = pConstMaterial->FindTexture(NULL, ON_Texture::transparency_texture, index);
}
return rc;
}
RH_C_FUNCTION void ON_Texture_GetFileName(const ON_Texture* pConstTexture, CRhCmnStringHolder* pString)
{
if( pConstTexture && pString )
{
pString->Set(pConstTexture->m_filename);
}
}
RH_C_FUNCTION void ON_Texture_SetFileName(ON_Texture* pTexture, const RHMONO_STRING* filename)
{
if( pTexture )
{
INPUTSTRINGCOERCE(_filename, filename);
pTexture->m_filename = _filename;
}
}
RH_C_FUNCTION ON_UUID ON_Texture_GetId(const ON_Texture* pConstTexture)
{
if( pConstTexture )
return pConstTexture->m_texture_id;
return ON_nil_uuid;
}
RH_C_FUNCTION bool ON_Texture_GetEnabled(const ON_Texture* pConstTexture)
{
if( pConstTexture )
return pConstTexture->m_bOn;
return false;
}
RH_C_FUNCTION void ON_Texture_SetEnabled(ON_Texture* pTexture, bool enabled)
{
if( pTexture )
{
pTexture->m_bOn = enabled;
}
}
RH_C_FUNCTION int ON_Texture_TextureType(const ON_Texture* pConstTexture)
{
if( pConstTexture )
return (int)pConstTexture->m_type;
return (int)ON_Texture::no_texture_type;
}
RH_C_FUNCTION void ON_Texture_SetTextureType(ON_Texture* pTexture, int texture_type)
{
if( pTexture )
pTexture->m_type = ON_Texture::TypeFromInt(texture_type);
}
RH_C_FUNCTION int ON_Texture_Mode(const ON_Texture* pConstTexture)
{
if( pConstTexture )
return (int)pConstTexture->m_mode;
return (int)ON_Texture::no_texture_mode;
}
RH_C_FUNCTION void ON_Texture_SetMode(ON_Texture* pTexture, int value)
{
if( pTexture )
pTexture->m_mode = ON_Texture::ModeFromInt(value);
}
const int IDX_WRAPMODE_U = 0;
const int IDX_WRAPMODE_V = 1;
const int IDX_WRAPMODE_W = 2;
RH_C_FUNCTION int ON_Texture_wrapuvw(const ON_Texture* pConstTexture, int uvw)
{
if( pConstTexture )
{
if (uvw == IDX_WRAPMODE_U)
return pConstTexture->m_wrapu;
if (uvw == IDX_WRAPMODE_V)
return pConstTexture->m_wrapv;
if (uvw == IDX_WRAPMODE_W)
return pConstTexture->m_wrapw;
}
return (int)ON_Texture::force_32bit_texture_wrap;
}
RH_C_FUNCTION void ON_Texture_Set_wrapuvw(ON_Texture* pTexture, int uvw, int value)
{
if( pTexture )
{
if (uvw == IDX_WRAPMODE_U)
pTexture->m_wrapu = ON_Texture::WrapFromInt(value);
else if (uvw == IDX_WRAPMODE_V)
pTexture->m_wrapv = ON_Texture::WrapFromInt(value);
else if (uvw == IDX_WRAPMODE_W)
pTexture->m_wrapw = ON_Texture::WrapFromInt(value);
}
}
RH_C_FUNCTION bool ON_Texture_Apply_uvw(const ON_Texture* pConstTexture)
{
if( pConstTexture )
return pConstTexture->m_bApply_uvw;
return false;
}
RH_C_FUNCTION void ON_Texture_SetApply_uvw(ON_Texture* pTexture, bool value)
{
if( pTexture )
pTexture->m_bApply_uvw = value;
}
RH_C_FUNCTION void ON_Texture_uvw(const ON_Texture* pConstTexture, ON_Xform* instanceXform)
{
if (pConstTexture && instanceXform)
*instanceXform = pConstTexture->m_uvw;
}
RH_C_FUNCTION void ON_Texture_Setuvw(ON_Texture* pTexture, ON_Xform* instanceXform)
{
if (pTexture && instanceXform)
pTexture->m_uvw = *instanceXform;
}
RH_C_FUNCTION void ON_Texture_GetAlphaBlendValues(const ON_Texture* pConstTexture, double* c, double* a0, double* a1, double* a2, double* a3)
{
if( pConstTexture && c && a0 && a1 && a2 && a3 )
{
*c = pConstTexture->m_blend_constant_A;
*a0 = pConstTexture->m_blend_A[0];
*a1 = pConstTexture->m_blend_A[1];
*a2 = pConstTexture->m_blend_A[2];
*a3 = pConstTexture->m_blend_A[3];
}
}
RH_C_FUNCTION void ON_Texture_SetAlphaBlendValues(ON_Texture* pTexture, double c, double a0, double a1, double a2, double a3)
{
if( pTexture )
{
pTexture->m_blend_constant_A = c;
pTexture->m_blend_A[0] = a0;
pTexture->m_blend_A[1] = a1;
pTexture->m_blend_A[2] = a2;
pTexture->m_blend_A[3] = a3;
}
}
RH_C_FUNCTION int ON_Texture_GetMappingChannelId(const ON_Texture* pConstTexture)
{
if (pConstTexture) return pConstTexture->m_mapping_channel_id;
return 0;
}
RH_C_FUNCTION ON_UUID ON_Material_ModelObjectId(const ON_Material* pConstMaterial)
{
if( pConstMaterial )
return pConstMaterial->ModelObjectId();
return ON_nil_uuid;
}
RH_C_FUNCTION ON_UUID ON_Material_PlugInId(const ON_Material* pConstMaterial)
{
if( pConstMaterial )
return pConstMaterial->m_plugin_id;
return ON_nil_uuid;
}
RH_C_FUNCTION void ON_Material_SetPlugInId(ON_Material* pMaterial, ON_UUID id)
{
if( pMaterial )
pMaterial->m_plugin_id = id;
}
| [
"steve@mcneel.com"
] | steve@mcneel.com |
a117dd83a5178f08a0257a62d7c8d7c1b555cc1c | 950276f370539ad552c1969170258cb8a13e137d | /src/BeamTransform.cxx | 9d74449451822770c75de06dd60ae263e670412b | [
"BSD-3-Clause"
] | permissive | fermi-lat/G4Generator | b4be72b15c7898fa2c49d553e4ad09bc6bced4ca | e62475754d1be9330e2c865b0a4517f8d9b105e9 | refs/heads/master | 2022-02-17T03:19:37.917081 | 2019-08-27T17:27:36 | 2019-08-27T17:27:36 | 103,186,864 | 0 | 0 | null | 2018-07-05T20:47:41 | 2017-09-11T20:51:33 | C++ | UTF-8 | C++ | false | false | 11,270 | cxx | /** @file BeamTransform.cxx
@brief declartion, implementaion of the class BeamTransform
Transforms particle trajectories generated in the beamtest-2006 beam frame
into the CU frame, taking into account the translations and rotations of the
x-y table.
@authors Toby Burnett, Leon Rochester
$Header: /nfs/slac/g/glast/ground/cvs/GlastRelease-scons/G4Generator/src/BeamTransform.cxx,v 1.15.446.1 2010/10/08 16:27:51 heather Exp $
*/
// Gaudi system includes
#include "GaudiKernel/MsgStream.h"
#include "GaudiKernel/AlgFactory.h"
#include "GaudiKernel/SmartDataPtr.h"
#include "GaudiKernel/Algorithm.h"
// CLHEP for geometry
#include "CLHEP/Vector/Rotation.h"
#include "CLHEP/Vector/ThreeVector.h"
// TDS class declarations: input data, and McParticle tree
#include "Event/MonteCarlo/McParticle.h"
#include "Event/TopLevel/Event.h"
#include "Event/TopLevel/EventModel.h"
#include "Event/TopLevel/MCEvent.h"
#include "geometry/Ray.h"
// TU: Hack for CLHEP 1.9.2.2
typedef HepGeom::Point3D<double> HepPoint3D;
typedef HepGeom::Vector3D<double> HepVector3D;
/** @class BeamTransform
@brief alg to transform the beam particle(s) into the detector frame
This involves a transformation of coordinates, and translation and rotation of the "x-y table."
Here's the latest word:
Beamline coordinate system:
x is along the beam
z is up
y completes the right-handed system
CU coordinate system:
z is opposite to the beam direction
y is down
x completes the right-handed system
The x-y table translations are specified in the beam system:
m_transz is the up-down direction
m_transy is the sideways direction
The pivot position is specified in the CU system
m_pivot_height is in the z direction
m_pivot_offset is in the x direction
*/
class BeamTransform : public Algorithm {
public:
BeamTransform(const std::string& name, ISvcLocator* pSvcLocator);
/// set parameters and attach to various perhaps useful services.
StatusCode initialize();
/// process one event
StatusCode execute();
/// clean up
StatusCode finalize();
private:
int m_count;
/// z position of pivot in CU frame
DoubleProperty m_pivot_height; // z position of pivot in glast frame
DoubleProperty m_pivot_offset; // x position of pivot in glast frame
DoubleProperty m_beam_plane; // z position of reporting plane in beam frame
DoubleProperty m_beam_plane_glast; // z position of reporting plane in glast frame
DoubleProperty m_transy, m_transz; // translation in x-y table plane
DoubleProperty m_angle; // rotation about table pivot (y-axis in instr.) (deg)
DoubleProperty m_tilt; // rotation about x-axis in instr. (deg)
DoubleArrayProperty m_point_on_beamline; // point in CU on central ray of beam
double m_c, m_s; // cos, sin of rot angle
double m_ct, m_st; // cos, sin of tilt
void transform(Event::McParticle& mcp );
CLHEP::Hep3Vector m_translation, m_pivot;
CLHEP::HepRotationY m_rotY; // the table rotation
CLHEP::HepRotationX m_rotX; // the table tilt
CLHEP::HepRotation m_rot; // the full rotation
};
namespace {
const double degToRad = M_PI/180.;
}
//static const AlgFactory<BeamTransform> Factory;
//const IAlgFactory& BeamTransformFactory = Factory;
DECLARE_ALGORITHM_FACTORY(BeamTransform);
BeamTransform::BeamTransform(const std::string& name, ISvcLocator* pSvcLocator)
:Algorithm(name, pSvcLocator)
,m_count(0)
{
// declare properties with setProperties calls
// translations, rotation and tilt of x-y table
// distances in mm, angles in degrees
// vertical translation of the table (along z(beam))
declareProperty("vertical_translation", m_transz=0);
// horizontal translation of the table, (along y(beam))
declareProperty("horizontal_translation",m_transy=0);
// rotation of the table around the pivot
declareProperty("table_rotation", m_angle=0);
// tilt of the table around an axis along x(CU), going through the pivot
declareProperty("table_tilt", m_tilt=0);
// z position of pivot in glast frame
declareProperty("pivot_location", m_pivot_height=-130);
// x position of pivot in glast frame
declareProperty("pivot_offset", m_pivot_offset=45);
// z position of reporting plane in beam frame
declareProperty("beam_plane", m_beam_plane=3300);
// z coordinate of reporting plane in instrument frame
declareProperty("beam_plane_glast" , m_beam_plane_glast=1000);
// point in CU along central ray of beam
declareProperty("point_on_beamline",
m_point_on_beamline=std::vector<double>(3,-9999.));
}
StatusCode BeamTransform::initialize(){
StatusCode sc = StatusCode::SUCCESS;
MsgStream log(msgSvc(), name());
log << MSG::INFO << "initialize" << endreq;
// Use the Job options service to set the Algorithm's parameters
setProperties();
const std::vector<double>& POBx = m_point_on_beamline.value( );
Point POB = Point(POBx[0], POBx[1], POBx[2]);
// this is the rotation matrix
m_rotY = CLHEP::HepRotationY(m_angle*degToRad);
m_rotX = CLHEP::HepRotationX(m_tilt*degToRad);
m_rot = m_rotX*m_rotY;
// location of pivot
m_pivot = CLHEP::Hep3Vector( m_pivot_offset,0, m_pivot_height);
log << MSG::INFO << endreq << "*********************************************"
<< endreq << "*********************************************"
<< endreq << endreq;
if(POB[0]!=-9999.) {
log << MSG::INFO
<< "A point in the CU has been requested... " << endreq
<< "The original x-y table coordinates will be over-written" << endreq;
log << MSG::INFO << "CU point requested: ("
<< POB[0] << ", " << POB[1] << ", " << POB[2] << ")"
<< ", angle: " << m_angle << " degrees" << endreq;
log << MSG::INFO << "XY table Before: horizontal " << m_transy
<< " mm, vertical " << m_transz << " mm" << endreq;
m_transz = POB[1];
if( m_angle==0&&m_tilt==0) {
m_transy = -POB[0];
} else {
// I'm amazed that this code seems to work for angles of +-90.
// I guess that's the power of vector arithmetic!
// That said, this seems a bit complicated...
Point pivot(m_pivot.x(), m_pivot.y(), m_pivot.z());
//make a ray orthogonal to the beam angle going thru the pivot
double orthAngle = degToRad*(180. - m_angle);
double tilt = degToRad*m_tilt;
Vector orthDir(cos(orthAngle), 0.0, sin(orthAngle));
Ray orthRay(pivot, orthDir);
// move by the offset of the pivot along this line
// it's where the central ray enters for no translation
Point point1 = orthRay.position(m_pivot.x());
Vector dirBeam(0.0, 0.0, 1.0);
dirBeam = m_rot*dirBeam;
dirBeam = Vector(dirBeam.x(), 0.0, dirBeam.z());
dirBeam.unit();
Ray zeroRay(point1, dirBeam);
// Here's the point you want the beam to go thru, projected onto the y(CU)=0 plane
Point point2(POB[0], 0.0, POB[2]);
Vector v1 = point2 - point1;
// The distance along the beam central ray that gets you to the
// doca for the beam point
double lenB = v1*dirBeam;
Point pointOnZero = zeroRay.position(lenB);
Point projPOZ(pointOnZero.x(), 0.0, pointOnZero.z());
Vector disp = point2-projPOZ;
// This is how much you have to move
double dist1 = disp.mag();
// and this is the direction
double sign = (disp*orthDir<0 ? -1.0 : 1.0);
m_transy = sign*dist1;
// correct vertical translation for the tilt
m_transz = m_transz - (m_pivot.z()-POB[2])*tan(tilt);
}
log << MSG::INFO << " After: horizontal " << m_transy
<< " mm, vertical " << m_transz << " mm" << endreq;
} else {
log << MSG::INFO << "XY table: horizontal " << m_transy
<< " mm, vertical " << m_transz
<< " mm, rotation: " << m_angle << " degrees" << endreq;
}
log << MSG::INFO << endreq << "*********************************************"
<< endreq << "*********************************************"
<< endreq << endreq;
// define the transformation matrix here.
m_translation = CLHEP::Hep3Vector(0, m_transy, m_transz);
return sc;
}
void BeamTransform::transform(Event::McParticle& mcp )
{
// get the positions and momenta
// "m" means momentum, "c" means coordinates
// "I" and "F" refer to initial and final quantities
CLHEP::HepLorentzVector mBeamI = mcp.initialFourMomentum();
CLHEP::Hep3Vector cBeamI = mcp.initialPosition();
// ditto final
CLHEP::HepLorentzVector mBeamF = mcp.finalFourMomentum();
CLHEP::Hep3Vector cBeamF = mcp.finalPosition();
// translate in beam frame
cBeamI -= m_translation;
cBeamF -= m_translation;
// convert to unrotated instrument coordinates
CLHEP::Hep3Vector cI(cBeamI.y(), -cBeamI.z(),
-cBeamI.x() + m_beam_plane + m_beam_plane_glast);
CLHEP::Hep3Vector cF(cBeamF.y(), -cBeamF.z(),
-cBeamF.x() + m_beam_plane + m_beam_plane_glast);
CLHEP::HepLorentzVector mI(mBeamI.y(), -mBeamI.z(), -mBeamI.x(), mBeamI.e());
CLHEP::HepLorentzVector mF(mBeamF.y(), -mBeamF.z(), -mBeamF.x(), mBeamF.e());
mcp.transform(m_rot*mI, m_rot*mF,
m_rot*(cI-m_pivot)+m_pivot, m_rot*(cF-m_pivot)+m_pivot);
}
StatusCode BeamTransform::execute(){
StatusCode sc = StatusCode::SUCCESS;
MsgStream log( msgSvc(), name() );
++m_count;
// Retrieving pointers from the TDS
SmartDataPtr<Event::EventHeader> header(eventSvc(), EventModel::EventHeader);
SmartDataPtr<Event::MCEvent> mcheader(eventSvc(), EventModel::MC::Event);
SmartDataPtr<Event::McParticleCol> particles(eventSvc(), EventModel::MC::McParticleCol);
double t = header->time();
log << MSG::DEBUG;
bool debug = log.isActive();
//debug = true;
if (debug) {log << "Event time: " << t;}
log << endreq;;
// loop over the monte carlo particle collection
if (particles) {
Event::McParticleCol::iterator piter;
for (piter = particles->begin(); piter != particles->end(); piter++) {
Event::McParticle& mcp = **piter;
if (debug) {
log << MSG::DEBUG;
log.stream() << mcp;
log << endreq;
}
// translate position
transform(mcp);
if (debug) {
log << MSG::DEBUG << "after transform: ";
log.stream() << mcp;
log << endreq;
}
}
}
return sc;
}
StatusCode BeamTransform::finalize(){
StatusCode sc = StatusCode::SUCCESS;
MsgStream log(msgSvc(), name());
log << MSG::INFO << "processed " << m_count << " events." << endreq;
return sc;
}
| [
""
] | |
0ecc3a6f7fb75901ecf54ee8d141f7c2413a0747 | d7c5bfdcd282f75910783b345a9e22bee63c5261 | /app/src/main/jni/DssFundamentals/IDssModeEncoder.h | c2a8c45024a473526b8ea4680a67b19af4f655ff | [] | no_license | merlydavidson/ODAndroidMobile | a4f98017bcc75580283f150397bb816894aa44dd | e0c53be2c3a38af40d74daf30d996f1e8bf33e2b | refs/heads/master | 2020-07-05T18:27:01.346239 | 2019-08-27T08:44:19 | 2019-08-27T08:44:19 | 202,726,787 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 480 | h | #ifndef I_DSS_MODE_ENCODER_H__
#define I_DSS_MODE_ENCODER_H__
#include "DssModeCodecCommon.h"
class IDssModeEncoder{
public:
IDssModeEncoder() {;}
virtual ~IDssModeEncoder() {}
virtual bool init() = 0;
virtual int encode_frames(short *psInput, int cInSamples, byte_t *pbOut, int& cbOutBytes, int mode) = 0;
virtual long get_remaining() = 0;
virtual void finish() = 0;
virtual void flush() = 0;
protected:
};
IDssModeEncoder* createDssEncoder(dss_mode_t mode);
#endif
| [
"merlindavidson19@gmail.com"
] | merlindavidson19@gmail.com |
a18a503dbd465093af57af0c6b8e9bc46d8ecaea | 6d162c19c9f1dc1d03f330cad63d0dcde1df082d | /qrenderdoc/3rdparty/qt/include/QtNetwork/qhostaddress.h | fdbdbfc72c02c843e1ebd2ef71ab736e16d6884a | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"LGPL-2.0-or-later",
"LGPL-3.0-only",
"GPL-3.0-only",
"Python-2.0",
"LicenseRef-scancode-other-copyleft",
"LicenseRef-scancode-mit-old-style",
"LGPL-2.1-or-later",
"LGPL-2.1-only",
"LicenseRef-scancode-warranty-disclaimer",
"LicenseRef-sc... | permissive | baldurk/renderdoc | 24efbb84446a9d443bb9350013f3bfab9e9c5923 | a214ffcaf38bf5319b2b23d3d014cf3772cda3c6 | refs/heads/v1.x | 2023-08-16T21:20:43.886587 | 2023-07-28T22:34:10 | 2023-08-15T09:09:40 | 17,253,131 | 7,729 | 1,358 | MIT | 2023-09-13T09:36:53 | 2014-02-27T15:16:30 | C++ | UTF-8 | C++ | false | false | 6,269 | h | /****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Copyright (C) 2016 Intel Corporation.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 3 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL3 included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 3 requirements
** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 2.0 or (at your option) the GNU General
** Public license version 3 or any later version approved by the KDE Free
** Qt Foundation. The licenses are as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-2.0.html and
** https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QHOSTADDRESS_H
#define QHOSTADDRESS_H
#include <QtNetwork/qtnetworkglobal.h>
#include <QtCore/qpair.h>
#include <QtCore/qstring.h>
#include <QtCore/qshareddata.h>
#include <QtNetwork/qabstractsocket.h>
struct sockaddr;
QT_BEGIN_NAMESPACE
class QHostAddressPrivate;
class Q_NETWORK_EXPORT QIPv6Address
{
public:
inline quint8 &operator [](int index) { return c[index]; }
inline quint8 operator [](int index) const { return c[index]; }
quint8 c[16];
};
typedef QIPv6Address Q_IPV6ADDR;
class QHostAddress;
// qHash is a friend, but we can't use default arguments for friends (§8.3.6.4)
Q_NETWORK_EXPORT uint qHash(const QHostAddress &key, uint seed = 0) Q_DECL_NOTHROW;
class Q_NETWORK_EXPORT QHostAddress
{
public:
enum SpecialAddress {
Null,
Broadcast,
LocalHost,
LocalHostIPv6,
Any,
AnyIPv6,
AnyIPv4
};
enum ConversionModeFlag {
ConvertV4MappedToIPv4 = 1,
ConvertV4CompatToIPv4 = 2,
ConvertUnspecifiedAddress = 4,
ConvertLocalHost = 8,
TolerantConversion = 0xff,
StrictConversion = 0
};
Q_DECLARE_FLAGS(ConversionMode, ConversionModeFlag)
QHostAddress();
explicit QHostAddress(quint32 ip4Addr);
explicit QHostAddress(quint8 *ip6Addr); // ### Qt 6: remove me
explicit QHostAddress(const quint8 *ip6Addr);
explicit QHostAddress(const Q_IPV6ADDR &ip6Addr);
explicit QHostAddress(const sockaddr *address);
explicit QHostAddress(const QString &address);
QHostAddress(const QHostAddress ©);
QHostAddress(SpecialAddress address);
~QHostAddress();
#ifdef Q_COMPILER_RVALUE_REFS
QHostAddress &operator=(QHostAddress &&other) Q_DECL_NOTHROW
{ swap(other); return *this; }
#endif
QHostAddress &operator=(const QHostAddress &other);
#if QT_DEPRECATED_SINCE(5, 8)
QT_DEPRECATED_X("use = QHostAddress(string) instead")
QHostAddress &operator=(const QString &address);
#endif
QHostAddress &operator=(SpecialAddress address);
void swap(QHostAddress &other) Q_DECL_NOTHROW { d.swap(other.d); }
void setAddress(quint32 ip4Addr);
void setAddress(quint8 *ip6Addr); // ### Qt 6: remove me
void setAddress(const quint8 *ip6Addr);
void setAddress(const Q_IPV6ADDR &ip6Addr);
void setAddress(const sockaddr *address);
bool setAddress(const QString &address);
void setAddress(SpecialAddress address);
QAbstractSocket::NetworkLayerProtocol protocol() const;
quint32 toIPv4Address() const; // ### Qt6: merge with next overload
quint32 toIPv4Address(bool *ok) const;
Q_IPV6ADDR toIPv6Address() const;
QString toString() const;
QString scopeId() const;
void setScopeId(const QString &id);
bool isEqual(const QHostAddress &address, ConversionMode mode = TolerantConversion) const;
bool operator ==(const QHostAddress &address) const;
bool operator ==(SpecialAddress address) const;
inline bool operator !=(const QHostAddress &address) const
{ return !operator==(address); }
inline bool operator !=(SpecialAddress address) const
{ return !operator==(address); }
bool isNull() const;
void clear();
bool isInSubnet(const QHostAddress &subnet, int netmask) const;
bool isInSubnet(const QPair<QHostAddress, int> &subnet) const;
bool isLoopback() const;
bool isMulticast() const;
static QPair<QHostAddress, int> parseSubnet(const QString &subnet);
friend Q_NETWORK_EXPORT uint qHash(const QHostAddress &key, uint seed) Q_DECL_NOTHROW;
protected:
QExplicitlySharedDataPointer<QHostAddressPrivate> d;
};
Q_DECLARE_OPERATORS_FOR_FLAGS(QHostAddress::ConversionMode)
Q_DECLARE_SHARED_NOT_MOVABLE_UNTIL_QT6(QHostAddress)
inline bool operator ==(QHostAddress::SpecialAddress address1, const QHostAddress &address2)
{ return address2 == address1; }
inline bool operator!=(QHostAddress::SpecialAddress lhs, const QHostAddress &rhs)
{ return rhs != lhs; }
#ifndef QT_NO_DEBUG_STREAM
Q_NETWORK_EXPORT QDebug operator<<(QDebug, const QHostAddress &);
#endif
#ifndef QT_NO_DATASTREAM
Q_NETWORK_EXPORT QDataStream &operator<<(QDataStream &, const QHostAddress &);
Q_NETWORK_EXPORT QDataStream &operator>>(QDataStream &, QHostAddress &);
#endif
QT_END_NAMESPACE
#endif // QHOSTADDRESS_H
| [
"baldurk@baldurk.org"
] | baldurk@baldurk.org |
b6edb28e9b7fbb0d539214808de767ed4dc290bd | 8b575163d31e45385f74dcde2ba18125603a320d | /cocos3d/Engine/libcocos3d/Materials/CC3Material.h | 96d26c010158b99aacb969a387efa346ef0ec802 | [] | no_license | xuwei2048/cocos3d-x | f8e4aac4bab40fbfc97e667d04fb5dfd1fa0f53e | 1a0996dd4852ff09312a8f8718fded80fbf5777b | refs/heads/master | 2021-01-15T10:25:14.866209 | 2015-11-13T11:02:43 | 2015-11-13T11:02:43 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 53,777 | h | /*
* Cocos3D-X 1.0.0
* Author: Bill Hollings
* Copyright (c) 2010-2014 The Brenwill Workshop Ltd. All rights reserved.
* http://www.brenwill.com
*
* Copyright (c) 2014-2015 Jason Wong
* http://www.cocos3dx.org/
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* http://en.wikipedia.org/wiki/MIT_License
*/
#ifndef _CCL_CC3MATERIAL_H_
#define _CCL_CC3MATERIAL_H_
NS_COCOS3D_BEGIN
/** Default material color under ambient lighting. */
static const ccColor4F kCC3DefaultMaterialColorAmbient = { 0.2f, 0.2f, 0.2f, 1.0f };
/** Default material color under diffuse lighting. */
static const ccColor4F kCC3DefaultMaterialColorDiffuse = { 0.8f, 0.8f, 0.8f, 1.0f };
/** Default material color under specular lighting. */
static const ccColor4F kCC3DefaultMaterialColorSpecular = { 0.0f, 0.0f, 0.0f, 1.0f };
/** Default emissive material color. */
static const ccColor4F kCC3DefaultMaterialColorEmission = { 0.0f, 0.0f, 0.0f, 1.0f };
/** Default material shininess. */
static const GLfloat kCC3DefaultMaterialShininess = 0.0f;
/** Maximum material shininess allowed by OpenGL ES. */
static const GLfloat kCC3MaximumMaterialShininess = 128.0f;
/** Default material reflectivity. */
static const GLfloat kCC3DefaultMaterialReflectivity = 0.0f;
/**
* CC3Material manages information about a material that is used to cover one or more meshes.
* This includes:
* - color
* - texture
* - interaction with lighting
* - opacity, translucency, and blending with background objects
*
* CC3Material supports two levels of control for blending and translucency:
* - To achieve the highest level of detail, accuracy and realism, you can individually
* set the explicit ambientColor, diffuseColor, specularColor, emissiveColor, shininess,
* sourceBlend, and destinationBlend properties. This suite of properties gives you the
* most complete control over the appearance of the material and its interaction with
* lighting conditions and the colors of the objects behind it, allowing you to generate
* rich visual effects. In addition, the isOpaque property sets the most commonly used
* blending combinations, and can be used to simplify your management of blending opaque
* or transparent materials, while still providing fine control of the ambient, diffuse
* and specular coloring.
* - At a simpler level, CC3Material also supports the Cocos2D <CCRGBAProtocol> protocol.
* You can use the color and opacity properties of this protocol to set the most commonly
* used coloring and blending characteristics simply and easily. Setting the color property
* changes both the ambient and diffuse colors of the material in tandem. Setting the
* opacity property also automatically sets the source and destination blend functions to
* appropriate values for the opacity level. By using the color and opacity properties,
* you will not be able to achieve the complexity and realism that you can by using the
* more detailed properties, but you can achieve good effect with much less effort.
* And by supporting the <CCRGBAProtocol> protocol, the coloring and translucency of nodes
* with materials can be changed using standard Cocos2D CCTint and CCFade actions, making
* it easier for you to add dynamic coloring effects to your nodes.
*
* CC3Material also supports alpha testing, where the alpha value of each pixel can be
* tested to determine whether or not it should be drawn. By default, alpha testing is
* disabled, but alpha testing can sometimes be useful when drawing overlapping objects
* each contain transparency and it is not possible to rely only on drawing order and
* depth testing to mediate whether a pixel should be drawn.
*
* Textures are optional. In some cases, if simple solid coloring is to be used, the material
* may hold no texture at all. This solid coloring will still interact with lighting, creating
* a realistic surface.
*
* More commonly, a material will hold a single instance of CC3Texture in the texture
* property to provide a simple single-texture surface. This is the most common application
* of textures to a material.
*
* For more sophisticated surfaces, materials also support multi-texturing, where more than
* one instance of CC3Texture is added to the material using the addTexture: method. Using
* multi-texturing, these textures can be combined in flexible, customized fashion,
* permitting sophisticated surface effects.
*
* With OpenGL, multi-texturing is processed by a chain of texture units. The material's
* first texture is processed by the first texture unit (texture unit zero), and subsequent
* textures held in the material are processed by subsequent texture units, in the order in
* which the textures were added to the material.
*
* Each texture unit combines its texture with the output of the previous texture unit
* in the chain. Combining textures is quite flexible under OpenGL, and there are many
* ways that each texture can be combined with the output of the previous texture unit.
*
* Under fixed-pipeline rendering, such as with OpenGL ES 1.1, the way that a particular
* texture combines with the previous textures is defined by an instance of CC3TextureUnit,
* held in the textureUnit property of each texture that was added to the material.
* To support a texture unit, the texture must be of type CC3TextureUnitTexture.
*
* For example, to configure a material for bump-mapping, add a CC3TextureUnitTexture
* instance that contains a normal vector at each pixel instead of a color, and set the
* textureUnit property of the texture to a CC3BumpMapTextureUnit. You can then combine
* the output of this bump-mapping with an additional texture that contains the image
* that will be visible, to provide a detailed 3D bump-mapped surface. To do so, add that
* second texture to the material, with a texture unit that defines how that addtional
* texture is to be combined with the output of the bump-mapped texture.
*
* The maximum number of texture units is platform dependent, and can be read from the
* CC3OpenGL.sharedGL.maxNumberOfTextureUnits property. This effectively defines how many
* textures you can add to a material.
*
* You'll notice that there are two ways to assign textures to a material: through the
* texture propety, and through the addTexture: method. The texture property exists for
* the common case where only one texture is attached to a material. The addTexture:
* method is used when more than one texture is to be added to the material. However,
* for the first texture, the two mechanisms are synonomous. The texture property
* corresponds to the first texture added using the addTexture: method, and for that
* first texture, you can use either the texture property or the addTexture: method.
* When multi-texturing, for consistency and simplicity, you would likely just use the
* addTexture: method for all textures added to the material, including the first texture.
*
* Each CC3MeshNode instance references an instance of CC3Material. Many CC3MeshNode
* instances may reference the same instance of CC3Material, allowing many objects to
* be covered by the same material.
*
* Once this material has been assigned to a mesh node, changing a texture to a new
* texture should be performed through the mesh node itself, and not through the
* material. This is to keep the mesh aligned with the orientation and usable area of
* the textures since, under iOS, textures are padded to dimensions of a power-of-two
* (POT), and most texture formats are loaded updside-down.
*
* When being drawn, the CC3MeshNode invokes the draw method on the CC3Material
* instance prior to drawing the associated mesh.
*
* When drawing the material to the GL engine, this class remembers which material was
* last drawn, and only binds the material data to the GL engine when a different material
* is drawn. This allows the application to organize the CC3MeshNodes within the CC3Scene
* so that nodes using the same material are drawn together, before moving on to other
* materials. This strategy can minimize the number of mesh switches in the GL engine,
* which improves performance.
*/
class CC3Material : public CC3Identifiable
{
DECLARE_SUPER( CC3Identifiable );
public:
CC3Material();
virtual ~CC3Material();
public:
/**
* If this value is set to YES, current lighting conditions (from either lights or light probes)
* will be taken into consideration when drawing colors and textures.
*
* If this value is set to NO, lighting conditions will be ignored when drawing colors and
* textures, and the emissionColor will be applied to the mesh surface, without regard to
* lighting. Blending will still occur, but the other material aspects, including ambientColor,
* diffuseColor, specularColor, and shininess will be ignored. This is useful for a cartoon
* effect, where you want a pure color, or the natural colors of the texture, to be included
* in blending calculations, without having to arrange lighting, or if you want those colors
* to be displayed in their natural values despite current lighting conditions.
*
* Be aware that the initial value of the emissionColor property is normally black. If you
* find your node disappears or turns black when you set this property to NO, try changing
* the value of the emissionColor property.
*
* The initial value of this property is YES.
*/
bool shouldUseLighting();
void setShouldUseLighting( bool shouldUse );
/**
* The color of this material under ambient lighting.
* Initially set to kCC3DefaultMaterialColorAmbient.
*
* The value of this property is also affected by changes to the color and opacity
* properties. See the notes for those properties for more information.
*/
ccColor4F getAmbientColor();
void setAmbientColor( const ccColor4F& color );
/**
* The color of this material under ambient lighting.
* Initially set to kCC3DefaultMaterialColorDiffuse.
*
* The value of this property is also affected by changes to the color and opacity
* properties. See the notes for those properties for more information.
*/
ccColor4F getDiffuseColor();
void setDiffuseColor( const ccColor4F& color );
/**
* The color of this material under ambient lighting.
* Initially set to kCC3DefaultMaterialColorSpecular.
*
* The value of this property is also affected by changes to the opacity property.
* See the notes for the opacity property for more information.
*/
ccColor4F getSpecularColor();
void setSpecularColor( const ccColor4F& color );
/**
* The emission color of this material.
* Initially set to kCC3DefaultMaterialColorEmission.
*
* The value of this property is also affected by changes to the opacity property.
* See the notes for the opacity property for more information.
*/
ccColor4F getEmissionColor();
void setEmissionColor( const ccColor4F& color );
/**
* The ambient colour currently used by this material during rendering.
*
* The value of this property is influenced by the value of the shouldApplyOpacityToColor property.
* If the shouldApplyOpacityToColor property is set to YES, this property scales each of the red,
* green & blue componenents of the ambientColor property by its alpha component and returns the
* result. Otherwise, this property returns the unaltered value of the ambientColor property.
*/
ccColor4F getEffectiveAmbientColor();
/**
* The diffuse colour currently used by this material during rendering.
*
* The value of this property is influenced by the value of the shouldApplyOpacityToColor property.
* If the shouldApplyOpacityToColor property is set to YES, this property scales each of the red,
* green & blue componenents of the diffuseColor property by its alpha component and returns the
* result. Otherwise, this property returns the unaltered value of the diffuseColor property.
*/
ccColor4F getEffectiveDiffuseColor();
/**
* The specular colour currently used by this material during rendering.
*
* The value of this property is influenced by the value of the shouldApplyOpacityToColor property.
* If the shouldApplyOpacityToColor property is set to YES, this property scales each of the red,
* green & blue componenents of the specularColor property by its alpha component and returns the
* result. Otherwise, this property returns the unaltered value of the specularColor property.
*/
ccColor4F getEffectiveSpecularColor();
/**
* The emission colour currently used by this material during rendering.
*
* The value of this property is influenced by the value of the shouldApplyOpacityToColor property.
* If the shouldApplyOpacityToColor property is set to YES, this property scales each of the red,
* green & blue componenents of the emissionColor property by its alpha component and returns the
* result. Otherwise, this property returns the unaltered value of the emissionColor property.
*/
ccColor4F getEffectiveEmissionColor();
/**
* The shininess of this material.
*
* The value of this property is clamped to between zero and kCC3MaximumMaterialShininess.
* The initial value of this property is kCC3DefaultMaterialShininess (zero).
*/
GLfloat getShininess();
void setShininess( GLfloat shininess );
/**
* The reflectivity of this material.
*
* This property can be used when the material is covered by an environmental reflection cube-map
* texture to indicate the weighting that should be applied to the reflection texture, relative to
* any other textures on the material. A value of zero indicates that the surface should be
* completely unreflective, and a value of one indicates that the surface is entirely reflective.
*
* This property requires a programmable pipeline and has no effect when running OpenGL ES 1.1
* on iOS, or a fixed rendering pipeline when running OpenGL on OSX.
*
* The value of this property is clamped to between zero and one.
* The initial value of this property is kCC3DefaultMaterialReflectivity (zero).
*/
GLfloat getReflectivity();
void setReflectivity( GLfloat reflectivity );
/**
* The blending function to be applied to the source material (this material). This property must
* be set to one of the valid GL blending functions.
*
* The value in this property combines with the value in the destinationBlend property to determine
* the way that materials are combined when one (the source) is drawn over another (the destination).
* Features such as transparency can cause the two to blend together in various ways.
*
* Although you can set this property directly, you can also allow this material to manage the
* value of this property automatically, based on the values of the isOpaque and opacity properties.
* See the notes for those properties for more information.
*
* If this property is set to GL_ONE, and the hasPremultipliedAlpha property returns YES, the red,
* green and blue components of all material color properties will be blended with their alpha
* components prior to being applied to the GL engine. This enables correct fading of materials
* containing a texture with pre-multiplied alpha.
*
* If you want the source to completely cover the destination, set sourceBlend to GL_ONE.
*
* If you want to have the destination show through the source, either by setting the diffuse
* alpha below one, or by covering this material with a texture that contains transparency, set
* the sourceBlend to GL_ONE_MINUS_SRC_ALPHA.
*
* However, watch out for textures with a pre-multiplied alpha channel. If this material has a texture
* with a pre-multiplied alpha channel, set sourceBlend to GL_ONE, so that the pre-multiplied alpha of
* the source will blend with the destination correctly.
*
* Opaque materials can be managed more efficiently than translucent materials. If a material really
* does not allow other materials to be seen behind it, you should ensure that the sourceBlend and
* destinationBlend properties are set to GL_ONE and GL_ZERO, respectively, to optimize rendering
* performance. The performance improvement is small, but can add up if a large number of opaque
* objects are rendered as if they were translucent.
*
* Materials support different using blending functions for the RGB components and the alpha component.
* To set separate source blend values for RGB and alpha, use the sourceBlendRGB and sourceBlendAlpha
* properties instead. Setting this property sets the sourceBlendRGB and sourceBlendAlpha properties
* to the same value. Querying this property returns the value of the sourceBlendRGB property.
*
* The initial value is determined by the value of the class-side property
* defaultBlendFunc, which can be modified by the setDefaultBlendFunc: method.
*/
GLenum getSourceBlend();
void setSourceBlend( GLenum sourceBlend );
/**
* The blending function to be applied to the destination material. This property must be set to
* one of the valid GL blending functions.
*
* The value in this property combines with the value in the sourceBlend property to determine the
* way that materials are combined when one (the source) is drawn over another (the destination).
* Features such as transparency can cause the two to blend together in various ways.
*
* Although you can set this property directly, you can also allow this material to manage the
* value of this property automatically, based on the values of the isOpaque and opacity properties.
* See the notes for those properties for more information.
*
* If you want the source to completely cover the destination, set destinationBlend to GL_ZERO.
*
* If you want to have the destination show through the source, either by setting the diffuse
* alpha below one, or by covering this material with a texture that contains an alpha channel
* (including a pre-multiplied alpha channel), set the destinationBlend to GL_ONE_MINUS_SRC_ALPHA.
*
* Opaque materials can be managed more efficiently than translucent materials. If a material really
* does not allow other materials to be seen behind it, you should ensure that the sourceBlend and
* destinationBlend properties are set to GL_ONE and GL_ZERO, respectively, to optimize rendering
* performance. The performance improvement is small, but can add up if a large number of opaque
* objects are rendered as if they were translucent.
*
* Materials support different using blending functions for the RGB components and the alpha component.
* To set separate destination blend values for RGB and alpha, use the destinationBlendRGB and
* destinationBlendAlpha properties instead. Setting this property sets the destinationBlendRGB and
* destinationBlendAlpha properties to the same value. Querying this property returns the value of
* the destinationBlendRGB property.
*
* The initial value is determined by the value of the class-side property
* defaultBlendFunc, which can be modified by the setDefaultBlendFunc: method.
*/
GLenum getDestinationBlend();
void setDestinationBlend( GLenum destinationBlend );
/**
* The blending function to be applied to the RGB components of the source material (this material).
* This property must be set to one of the valid GL blending functions.
*
* In conjunction with the sourceBlendAlpha property, this property allows the RGB blending and
* alpha blending to be specified separately. Alternately, you can use the sourceBlend property
* to set both RGB and alpha blending functions to the same value.
*
* See the notes of the sourceBlend property for more information about material blending.
*/
GLenum getSourceBlendRGB();
void setSourceBlendRGB( GLenum sourceBlendRGB );
/**
* The blending function to be applied to the RGB components of the destination material.
* This property must be set to one of the valid GL blending functions.
*
* In conjunction with the destinationBlendAlpha property, this property allows the RGB blending
* and alpha blending to be specified separately. Alternately, you can use the destinationBlend
* property to set both RGB and alpha blending functions to the same value.
*
* See the notes of the destinationBlend property for more information about material blending.
*/
GLenum getDestinationBlendRGB();
void setDestinationBlendRGB( GLenum destinationBlend );
/**
* The blending function to be applied to the alpha components of the source material (this material).
* This property must be set to one of the valid GL blending functions.
*
* In conjunction with the sourceBlendRGB property, this property allows the RGB blending and
* alpha blending to be specified separately. Alternately, you can use the sourceBlend property
* to set both RGB and alpha blending functions to the same value.
*
* See the notes of the sourceBlend property for more information about material blending.
*/
GLenum getSourceBlendAlpha();
void setSourceBlendAlpha( GLenum sourceBlendAlpha );
/**
* The blending function to be applied to the alpha components of the destination material.
* This property must be set to one of the valid GL blending functions.
*
* In conjunction with the destinationBlendRGB property, this property allows the RGB blending
* and alpha blending to be specified separately. Alternately, you can use the destinationBlend
* property to set both RGB and alpha blending functions to the same value.
*
* See the notes of the destinationBlend property for more information about material blending.
*/
GLenum getDestinationBlendAlpha();
void setDestinationBlendAlpha( GLenum destinationBlendAlpha );
/**
* Indicates whether this material is opaque.
*
* This method returns YES if the values of the sourceBlend and destinationBlend
* properties are GL_ONE and GL_ZERO, respectively, otherwise this method returns NO.
*
* Setting this property to YES sets the value of the sourceBlend property to GL_ONE and the value
* of the destinationBlend to GL_ZERO. Setting this property to YES is a convenient way to force
* the source to completely cover the destination, even if the diffuse alpha value is less than one,
* and even if the texture contains translucency.
*
* If the sourceBlend and destinationBlend properties have not been set to something else, setting
* this property to NO sets the value of the destinationBlend property to GL_ONE_MINUS_SRC_ALPHA,
* and sets the sourceBlend property to GL_SRC_ALPHA if the alpha channel of the diffuseColor is
* below one and this material does not contain a texture that contains pre-multiplied alpha, in
* which case sourceBlend is left at GL_ONE.
*
* Setting the value of this property does not change the alpha values of any of the material colors.
*
* The state of this property is also affected by setting the opacity property. As a convenience,
* setting the opacity property to a value less than kCCOpacityFull will automatically cause this
* isOpaque property to be set to NO, which, as described above, will also affect the sourceBlend and
* destinationBlend properties, so that the translucency will be blended correctly.
*
* Setting the opacity property to kCCOpacityFull will automatically cause this isOpaque property to be set
* to YES (affecting the sourceBlend and destinationBlend properties), unless the shouldBlendAtFullOpacity
* property is set to YES, in which case the isOpaque property will be left set to NO.
*
* Setting this property can be thought of as a convenient way to switch between the two most
* common types of blending combinations. For finer control of blending, set the sourceBlend
* and destinationBlend properties and the alpha values of the individual material colors directly,
* and avoid making changes to this property, or the opacity property.
*
* Opaque materials can be managed slightly more efficiently than translucent materials.
* If a material really does not allow other materials to be seen behind it, you should
* ensure that this property is set to YES. The performance improvement is small, but
* can add up if a large number of opaque objects are rendered as if they were translucent.
*/
bool isOpaque();
void setIsOpaque( bool opaque );
/**
* Indicates whether blending should be applied even when the material is at full opacity.
*
* If this property is set to NO, when the opacity property of this material is set to full
* opacity (kCCOpacityFull), the isOpaque property will be set to YES, which in turn will set
* the sourceBlend property to GL_ONE and the destinationBlend property to GL_ZERO, effectively
* turning blending off. This allows a node that is opaque to be faded, but when fading is
* complete, and full opacity is restored, the node will be set fully opaque, which improves
* performance and the affects the rendering order of the node relative to other nodes.
*
* If this property is set to YES, when the opacity property of this material is set to full
* opacity (kCCOpacityFull), the isOpaque property will be set to NO, which will leave the
* sourceBlend and destination properties at their current values, generally leaving blending
* enabled. This is useful when using fading on a material that contains textures that in turn
* contain transparency. When this material reaches full opacity, blending will be left enabled,
* and the transparent sections of the textures will continue to be rendered correctly.
*
* The initial value of this property is NO. Whenever a texture is added to, or removed from,
* this material, the value is set to the value of the hasTextureAlpha property, reflecting
* whether any of the textures contain an alpha channel. If you know that the alpha channel
* in each texture does not contain transparency, and that this material will be displayed at
* full opacity, you can set this property back to NO to benefit from improved performance
* in sorting and rendering opaque materials.
*/
bool shouldBlendAtFullOpacity();
void setShouldBlendAtFullOpacity( bool shouldBlendAtFullOpacity );
/**
* Indicates the alpha test function that is used to determine if a pixel should be
* drawn, based on the value of its alpha component.
*
* The value of this property must be one of the following values:
* - GL_ALWAYS: The pixel is always drawn, regardless of its alpha value.
* - GL_GREATER - The pixel is drawn only if its alpha value is greater than the
* value in the reference property.
* - GL_GEQUAL - The pixel is drawn only if its alpha value is greater than or equal
* to the value in the reference property.
* - GL_LESS - The pixel is drawn only if its alpha value is less than the value
* in the reference property.
* - GL_LEQUAL - The pixel is drawn only if its alpha value is less than or equal
* to the value in the reference property.
* - GL_EQUAL - The pixel is drawn only if its alpha value is equal to the value
* in the reference property.
* - GL_NOTEQUAL - The pixel is drawn only if its alpha value is not equal to the
* value in the reference property.
* - GL_NEVER: The pixel is never drawn.
*
* The initial value of this property is GL_ALWAYS, indicating that each pixel will
* always be drawn, regardless of its alpha value.
*
* For most situations, alpha testing is not necessary, and you can leave the value of this
* property at its initial value. Alpha testing can sometimes be useful when drawing overlapping
* objects that each contain transparency, and it is not possible to rely only on drawing order
* and depth testing to mediate whether a pixel should be drawn.
*
* Although you can set this property directly, since the most common values are either GL_ALWAYS
* or GL_GREATER, you can use the shouldDrawLowAlpha property as a shortcut to switch between
* these two values.
*
* Alpha testing within the GL engine is automatically disabled if this property
* is set to GL_ALWAYS, and enabled for any other value.
*/
GLenum getAlphaTestFunction();
void setAlphaTestFunction( GLenum function );
/**
* Indicates the reference value used by the alpha test function to compare against
* the alpha value of each pixel to determine if it should be drawn.
*
* The value of this property must be between zero and one, inclusive. The value
* is clamped by the GL engine if it is set to a value outside this range.
*
* The initial value of this property is zero.
*
* The value of this property has no effect if the value of the alphaTestFunction
* property is either GL_ALWAYS or GL_NEVER.
*
* See the notes for the alphaTestFunction property for more information on alpha testing.
*/
GLfloat getAlphaTestReference();
void setAlphaTestReference( GLfloat alphaTestReference );
/**
* Indicates whether alpha testing should be used to determine if pixels with
* lower alpha values should be drawn.
*
* This property is really a shortcut for setting the alphaTestFunction to either
* of its two most common values. Setting this property to YES will set the
* alphaTestFunction propery to GL_ALWAYS. Setting this property to NO will set
* the alphaTestFunction property to GL_GREATER.
*
* If the value of this property is set to YES, each pixel will be drawn regardless
* of the value of its alpha component. If the value of this property is set to NO,
* the value of the alpha component of each pixel will be compared against the value
* in the alphaTestReference property, and only those pixel alpha values that are
* greater than that reference value will be drawn. You can set the value of the
* alphaTestReference property to determine the cutoff level.
*
* Reading the value of this property will return YES if the value of the alphaTestFunction
* is any of GL_ALWAYS, GL_LESS or GL_LEQUAL, otherwise it returns NO.
*
* The initial value of this property is YES, indicating that pixels with lower
* alpha values will be drawn.
*
* For most situations, alpha testing is not necessary, and you can leave the value
* of this property set to YES. Alpha testing can sometimes be useful when drawing
* overlapping objects that each contain transparency, and it is not possible to rely
* only on drawing order and depth testing to mediate whether a pixel should be drawn.
*/
bool shouldDrawLowAlpha();
void setShouldDrawLowAlpha( bool shouldDrawLowAlpha );
/**
* The color of this material, as a CCColorRef.
*
* The function of this property depends on the value of the shouldUseLighting property.
*
* If the shouldUseLighting property is set to YES, querying this property returns a value
* derived from the diffuseColor property, and setting this property modifies the value of
* both the ambientColor and diffuseColor properties.
*
* If the shouldUseLighting property is set to NO, querying this property returns a value
* derived from the emissionColor property, and setting this property modifies the value of
* the emissionColor properties.
*
* When setting this property, the alpha of each of the affected properties is not modified.
*/
CCColorRef getColor();
void setColor( const CCColorRef& color );
/**
* The opacity of this material.
*
* Querying this property returns the alpha component of either the diffuseColor property or
* the emissionColor property, depending on whether the shouldUseLighting property is set to
* YES or NO, respectively.
*
* When setting this property, the value is converted to a floating point number between 0 and 1,
* and is set into the alpha component of the ambientColor, diffuseColor, specularColor, and
* emissionColor properties. The RGB components of each of those properties remain unchanged.
*
* Setting this property also affects the isOpaque property. As a convenience, setting this opacity
* property to a value less than kCCOpacityFull will automatically cause the isOpaque property to be
* set to NO, which will also affect the sourceBlend and destinationBlend properties, so that the
* translucency will be blended correctly. See the notes of the isOpaque property for more information.
*
* However, setting this opacity property to kCCOpacityFull will NOT automatically cause the isOpaque
* property to be set to YES. Even if the opacity of the material is full, the texture may contain
* translucency, which would be ignored if the isOpaque property were to be set to YES.
*
* Conversely, setting the value of this opacity property to kCCOpacityFull will automatically cause the
* isOpaque property to be set to YES, which will affect the sourceBlen and destinationBlend properties
* so that blending will be turned off. See the notes of the isOpaque property for more information.
*
* Setting this property can be thought of as a convenient way to make simple changes to the opacity
* of a material, using the most common types of blending combinations. For finer control of blending,
* set the sourceBlend and destinationBlend properties, and the alpha values of the individual colors
* directly, and avoid making changes to this property.
*/
CCOpacity getOpacity();
void setOpacity( CCOpacity opacity );
/**
* Implementation of the CCBlendProtocol blendFunc property.
*
* This is a convenience property that gets and sets the sourceBlend and destinationBlend
* properties using a single structure.
*
* Materials support different using blending functions for the RGB components and the alpha component.
* To set separate blend values for RGB and alpha, use the blendFuncRGB and blendFuncAlpha properties
* instead. Setting this property sets the blendFuncRGB and blendFuncAlpha properties to the same value.
* Querying this property returns the value of the blendFuncRGB property.
*/
ccBlendFunc getBlendFunc();
void setBlendFunc( const ccBlendFunc& blendFunc );
/**
* The blending function to be applied to the RGB components.
*
* This is a convenience property that gets and sets both the sourceBlendRGB and
* destinationBlendRGB properties using a single structure.
*
* In conjunction with the blendFuncAlpha property, this property allows the RGB blending and
* alpha blending to be specified separately. Alternately, you can use the blendFunc property
* to set both RGB and alpha blending functions to the same value.
*
* See the notes of the sourceBlend and destinationBlend properties for more information
* about material blending.
*/
ccBlendFunc getBlendFuncRGB();
void setBlendFuncRGB( const ccBlendFunc& blendFunc );
/**
* The blending function to be applied to the alpha component.
*
* This is a convenience property that gets and sets both the sourceBlendAlpha and
* destinationBlendAlpha properties using a single structure.
*
* In conjunction with the blendFuncRGB property, this property allows the RGB blending and
* alpha blending to be specified separately. Alternately, you can use the blendFunc property
* to set both RGB and alpha blending functions to the same value.
*
* See the notes of the sourceBlend and destinationBlend properties for more information
* about material blending.
*/
ccBlendFunc getBlendFuncAlpha();
void setBlendFuncAlpha( const ccBlendFunc& blendFunc );
/**
* Returns the default GL material source and destination blend function used for new instances.
* This affects both the RGB and alpha blending components.
*
* The initial value is {GL_ONE, GL_ZERO}.
*/
static ccBlendFunc getDefaultBlendFunc();
/**
* Sets the default GL material source and destination blend function used for new instances.
* This affects both the RGB and alpha blending components.
*/
static void setDefaultBlendFunc( const ccBlendFunc& aBlendFunc );
/**
* Returns the number of textures attached to this material, regardless of whether
* the textures were attached using the texture property or the addTexture: method.
*/
GLuint getTextureCount();
/**
* When using a single texture for this material, this property holds that texture.
*
* This property may be left nil if no texture is needed.
*
* When using multiple textures for this material, this property holds the first
* texture. You can add additional textures using the addTexture: method.
*
* As a convenience, this property can also be set using the addTexture: method,
* which will set this property if it has not been set already. This is useful when
* using multi-texturing, because it allows all textures attached to this material
* to be handled the same way.
*
* The texture held by this property will be processed by the first GL texture unit
* (texture unit zero).
*
* Once this material has been added to a mesh node, changes to this property should
* be made through the same property on the mesh node itself, and not made to this
* property directly, in order to keep the mesh aligned with the orientation and
* usable area of the textures. See the notes for the same property on CC3MeshNode
* for more information.
*
* When building for iOS, raw PNG and TGA images are pre-processed by Xcode to pre-multiply
* alpha, and to reorder the pixel component byte order, to optimize the image for the iOS
* platform. If you want to avoid this pre-processing for PNG or TGA files, for textures
* such as normal maps or lighting maps, that you don't want to be modified, you can prepend
* a 'p' to the file extension ("ppng" or "ptga") to cause Xcode to skip this pre-processing
* and to use a loader that does not pre-multiply the alpha. You can also use this for other
* file types as well. See the notes for the CC3STBImage useForFileExtensions class-side
* property for more info.
*/
CC3Texture* getTexture();
void setTexture( CC3Texture* texture );
/**
* In most situations, the material will use a single CC3Texture in the texture property.
* However, if multi-texturing is used, additional CC3Texture instances can be provided
* by adding them using this method.
*
* When multiple textures are attached to a material, when drawing, the material will
* combine these textures together using configurations contained in the textureUnit
* property of each texture.
*
* As a consistency convenience, if the texture property has not yet been set directly,
* the first texture added using this method will appear in that property.
*
* Textures are processed by GL texture units in the order they are added to the material.
* The first texture added (or set directly into the texture property) will be processed
* by GL texture unit zero. Subsequent textures added with this method will be processed
* by subsequent texture units, in the order they were added.
*
* The maximum number of texture units available is platform dependent, but will be
* at least two. The maximum number of texture units available can be read from the
* CC3OpenGL.sharedGL.maxNumberOfTextureUnits property. If you attempt to add more than
* this number of textures to the material, the additional textures will be ignored,
* and an informational message to that fact will be logged.
*
* Once this material has been added to a mesh node, new textures should be added
* through the same method on the mesh node itself, instead of this method, in order
* to keep the mesh aligned with the orientation and usable area of the textures.
* See the notes for the same method on CC3MeshNode for more information.
*
* When building for iOS, raw PNG and TGA images are pre-processed by Xcode to pre-multiply
* alpha, and to reorder the pixel component byte order, to optimize the image for the iOS
* platform. If you want to avoid this pre-processing for PNG or TGA files, for textures
* such as normal maps or lighting maps, that you don't want to be modified, you can prepend
* a 'p' to the file extension ("ppng" or "ptga") to cause Xcode to skip this pre-processing
* and to use a loader that does not pre-multiply the alpha. You can also use this for other
* file types as well. See the notes for the CC3STBImage useForFileExtensions class-side
* property for more info.
*/
virtual void addTexture( CC3Texture* aTexture );
/**
* Removes the specified texture from this material.
*
* If the specified texture is that in the texture property, that property is set to nil.
*/
void removeTexture( CC3Texture* aTexture );
/** Removes all textures from this material. */
void removeAllTextures();
/**
* Returns the texture with the specified name, that was added either via the texture
* property or via the addTexture: method. Returns nil if such a texture cannot be found.
*/
CC3Texture* getTextureNamed( const char* aName );
/**
* Returns the texture that will be processed by the texture unit with the specified index.
* Texture unit indices start at zero.
*
* The value returned will be nil if there are no textures, or if the specified index is
* greater than one less than the value of the textureCount property.
*/
CC3Texture* getTextureForTextureUnit( GLuint texUnit );
/**
* Sets the texture that will be processed by the texture unit with the specified index,
* which should be a number between zero, and the value of the textureCount property.
*
* If the specified index is less than the number of texture units added already, the
* specified texture will replace the one assigned to that texture unit. Otherwise, this
* implementation will invoke the addTexture: method to add the texture to this material.
*
* If the specified texture unit index is zero, the value of the texture property will
* be changed to the specified texture.
*
* Once this material has been added to a mesh node, changing a texture should be
* performed through the same method on the mesh node itself, instead of this method,
* in order to keep the mesh aligned with the orientation and usable area of the
* textures. See the notes for the same method on CC3MeshNode for more information.
*/
void setTexture( CC3Texture* aTexture, GLuint texUnit );
/**
* Returns whether any of the textures used by this material have an alpha channel, representing opacity.
*
* Returns YES if any of the textures contained in this instance has an alpha channel.
*
* See also the notes of the shouldBlendAtFullOpacity property for the effects of using a
* texture with an alpha channel.
*/
bool hasTextureAlpha();
/**
* Returns whether the alpha channel has already been multiplied into each of the RGB
* color channels, in any of the textures used by this material.
*
* Returns YES if any of the textures contained in this instance has pre-mulitiplied alpha.
*
* See also the notes of the shouldApplyOpacityToColor property for the effects of using textures
* with pre-multiplied alpha.
*/
bool hasTexturePremultipliedAlpha();
/**
* Returns whether the opacity of each of the material colors (ambient, diffuse, specular and emission)
* should be blended (multiplied) by its alpha value prior to being submitted to the GL engine.
*
* This property returns YES if the sourceBlendRGB property is set to GL_ONE and the hasPremultipliedAlpha
* property returns YES, otherwise this property returns NO. The combination of full source blending
* and pre-multiplied texture alpha can be made translucent by blending each color with its alpha value.
*
* If this property returns YES, each of the material colors will automatically be blended with its
* alpha component prior to being submitted to the GL engine.
*/
bool shouldApplyOpacityToColor();
/**
* Returns a cube-map texture if this material contains such a texture, or nil if it does not.
*
* This is a convenience property that returns the first cube-map texture that was added.
*/
CC3Texture* getTextureCube();
/**
* Returns whether this material contains a texture that is a six-sided cube-map texture.
*
* Returns YES only if one of the textures that was added to this material (either through the
* texture property or the addTexture: method) returns YES from its isTextureCube property.
* Otherwise, this property returns NO.
*/
bool hasTextureCube();
/**
* Returns whether this material contains a texture that is configured as a bump-map.
*
* Returns YES only if one of the textures that was added to this material (either
* through the texture property or the addTexture: method) returns YES from its
* isBumpMap property. Otherwise, this property returns NO.
*/
bool hasBumpMap();
/**
* The direction, in local tangent coordinates, of the light source that is to
* interact with any texture contained in this material that has been configured
* as a bump-map.
*
* Bump-maps are textures that store a normal vector (XYZ coordinates) in
* the RGB components of each texture pixel, instead of color information.
* These per-pixel normals interact with the value of this lightDirection
* property (through a dot-product), to determine the luminance of the pixel.
*
* Setting this property sets the equivalent property in all textures contained
* within this material.
*
* Reading this value returns the value of the equivalent property in the first
* texture that is configrued as a bump-map. Otherwise kCC3VectorZero is returned.
*
* The value of this property must be in the tangent-space coordinates associated
* with the texture UV space, in practice, this property is typically not set
* directly. Instead, you can use the globalLightPosition property of the mesh
* node that is making use of this texture.
*/
CC3Vector getLightDirection();
void setLightDirection( const CC3Vector& direction );
/**
* Allocates and initializes an autoreleased unnamed instance with an automatically
* generated unique tag value. The tag value is generated using a call to nextTag.
*/
static CC3Material* material();
/** Allocates and initializes an unnamed autoreleased instance with the specified tag. */
static CC3Material* materialWithTag( GLuint aTag );
/**
* Allocates and initializes an autoreleased instance with the specified name and an
* automatically generated unique tag value. The tag value is generated using a call to nextTag.
*/
static CC3Material* materialWithName( const std::string& aName );
/** Allocates and initializes an autoreleased instance with the specified tag and name. */
static CC3Material* materialWithTag( GLuint aTag, const std::string& aName );
/**
* Allocates and initializes an autoreleased unnamed instance with an automatically
* generated unique tag value. The tag value is generated using a call to nextTag.
*
* The returned instance will have a specularColor of { 1.0, 1.0, 1.0, 1.0 } and a
* shininess of 75.0.
*/
static CC3Material* shiny();
/**
* Allocates and initializes an autoreleased unnamed instance with an automatically
* generated unique tag value. The tag value is generated using a call to nextTag.
*
* The returned instance will have both diffuseColor and specularColor set to
* { 1.0, 1.0, 1.0, 1.0 } and a shininess of 75.0.
*/
static CC3Material* shinyWhite();
/**
* Applies this material to the GL engine. The specified visitor encapsulates
* the frustum of the currently active camera, and certain drawing options.
*
* This implementation first determines if this material is different than the material
* that was last bound to the GL engine. If this material is indeed different, this method
* applies the material to the GL engine, otherwise it does nothing.
*
* Draws this texture to the GL engine as follows:
* - Applies the blending properties to the GL engine
* - Applies the various lighting and color properties to the GL engine
* - Binds the texture property to the GL engine as texture unit zero.
* - Binds any additional textures added using addTexture: to additional texture units.
* - Disables any unused texture units.
*
* If the texture property is nil, and there are no overlays, all texture units
* in the GL engine will be disabled.
*
* This method is invoked automatically during node drawing. Usually, the application
* never needs to invoke this method directly.
*/
void drawWithVisitor( CC3NodeDrawingVisitor* visitor );
/**
* Unbinds all materials from the GL engine.
*
* Disables material blending in the GL engine.
*
* This method is invoked automatically from the CC3MeshNode instance.
* Usually, the application never needs to invoke this method directly.
*/
static void unbindWithVisitor( CC3NodeDrawingVisitor* visitor );
CCColorRef getDisplayedColor();
bool isCascadeColorEnabled();
void setCascadeColorEnabled( bool cascadeColorEnabled );
void updateDisplayedColor( const CCColorRef& color );
CCOpacity getDisplayedOpacity();
void setCascadeOpacityEnabled( bool cascadeOpacityEnabled );
void updateDisplayedOpacity( CCOpacity opacity );
void drawTexturesWithVisitor( CC3NodeDrawingVisitor* visitor );
bool isCascadeOpacityEnabled();
void texturesHaveChanged();
void applyColorsWithVisitor( CC3NodeDrawingVisitor* visitor );
void applyAlphaTestWithVisitor( CC3NodeDrawingVisitor* visitor );
void applyBlendWithVisitor( CC3NodeDrawingVisitor* visitor );
void initWithTag( GLuint aTag, const std::string& aName );
void initWithTag( GLuint aTag );
void populateFrom( CC3Material* another );
virtual CCObject* copyWithZone( CCZone* zone );
/**
* Applies the PFX effect with the specified name, found in the cached CC3PFXResource with the
* specifed name, to this material.
*
* Sets the textures of this material to those defined by the retrieved PFX effect.
*
* Raises an assertion error if a PFX resource with the specified name cannot be found in the PFX
* resource cache, or if that PFX resource does not contain an effect with the specified effect name.
*/
virtual void applyEffectNamedFromRez( const std::string& effectName, const std::string& rezName );
/**
* Applies the PFX effect with the specified name, found in the CC3PFXResource loaded from the
* specfied file, to this material.
*
* Sets the textures of this material to those defined by the retrieved PFX effect.
*
* Raises an assertion error if the PFX resource file could not be loaded, or if that
* PFX resource does not contain an effect with the specified effect name.
*/
virtual void applyEffectNamedFromFile( const std::string& effectName, const std::string& filePath );
virtual std::string getNameSuffix();
protected:
CC3Texture* _texture;
CCArray* _textureOverlays;
ccColor4F _ambientColor;
ccColor4F _diffuseColor;
ccColor4F _specularColor;
ccColor4F _emissionColor;
GLfloat _shininess;
GLfloat _reflectivity;
GLenum _alphaTestFunction;
GLfloat _alphaTestReference;
ccBlendFunc _blendFuncRGB;
ccBlendFunc _blendFuncAlpha;
bool _shouldUseLighting : 1;
bool _shouldBlendAtFullOpacity : 1;
};
NS_COCOS3D_END
#endif
| [
"michaelgamedev@sina.cn"
] | michaelgamedev@sina.cn |
64644c5f9cee8db32754a01524aebcd06222fe2c | 569d64661f9e6557022cc45428b89eefad9a6984 | /code/gameholder/regular_maoxian_262.h | e76628ace511eeacf7eb284d37f345536d40a88c | [] | no_license | dgkang/ROG | a2a3c8233c903fa416df81a8261aab2d8d9ac449 | 115d8d952a32cca7fb7ff01b63939769b7bfb984 | refs/heads/master | 2020-05-25T02:44:44.555599 | 2019-05-20T08:33:51 | 2019-05-20T08:33:51 | 187,584,950 | 0 | 1 | null | 2019-05-20T06:59:06 | 2019-05-20T06:59:05 | null | UTF-8 | C++ | false | false | 345 | h | #ifndef regular_maoxian_262_h__
#define regular_maoxian_262_h__
#include "regular_maoxian_base.h"
// 冒险地图262
class RegularMaoXian_262 : public RegularMaoXianBase
{
public:
RegularMaoXian_262(RegularDoc* pDoc);
virtual ~RegularMaoXian_262();
virtual void FirstUpdate();
private:
};
#endif // regular_maoxian_062_h__
| [
"judge23253@sina.com"
] | judge23253@sina.com |
efb525092a9fd07513fb2690b75f407d8a1914e9 | 9e1e09ea61632e80465f371a083625d03b1e5ab2 | /src/Wallet/WalletErrors.h | 1e5188f0ce5ff51683e8fda73147972c7a62f236 | [
"MIT"
] | permissive | bitcoin-note/bitcoin-note | 0f93c5a04dda2df6ff838187d894a0c4af633649 | 7be1e60f327b7ce1f995fee97f80131dcb934e70 | refs/heads/master | 2021-05-11T19:50:51.485229 | 2018-01-18T00:05:24 | 2018-01-18T00:05:24 | 117,895,059 | 3 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 4,094 | h | // Copyright (c) 2018, The Bitcoin Note Developers.
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#pragma once
#include <string>
#include <system_error>
namespace CryptoNote {
namespace error {
// custom error conditions enum type:
enum WalletErrorCodes {
NOT_INITIALIZED = 1,
ALREADY_INITIALIZED,
WRONG_STATE,
WRONG_PASSWORD,
INTERNAL_WALLET_ERROR,
MIXIN_COUNT_TOO_BIG,
BAD_ADDRESS,
TRANSACTION_SIZE_TOO_BIG,
WRONG_AMOUNT,
SUM_OVERFLOW,
ZERO_DESTINATION,
TX_CANCEL_IMPOSSIBLE,
TX_CANCELLED,
OPERATION_CANCELLED,
TX_TRANSFER_IMPOSSIBLE,
WRONG_VERSION,
FEE_TOO_SMALL,
KEY_GENERATION_ERROR,
INDEX_OUT_OF_RANGE,
ADDRESS_ALREADY_EXISTS,
TRACKING_MODE,
WRONG_PARAMETERS,
OBJECT_NOT_FOUND,
WALLET_NOT_FOUND,
CHANGE_ADDRESS_REQUIRED,
CHANGE_ADDRESS_NOT_FOUND,
DESTINATION_ADDRESS_REQUIRED,
DESTINATION_ADDRESS_NOT_FOUND,
BAD_PAYMENT_ID,
BAD_TRANSACTION_EXTRA
};
// custom category:
class WalletErrorCategory : public std::error_category {
public:
static WalletErrorCategory INSTANCE;
virtual const char* name() const throw() override {
return "WalletErrorCategory";
}
virtual std::error_condition default_error_condition(int ev) const throw() override {
return std::error_condition(ev, *this);
}
virtual std::string message(int ev) const override {
switch (ev) {
case NOT_INITIALIZED: return "Object was not initialized";
case WRONG_PASSWORD: return "The password is wrong";
case ALREADY_INITIALIZED: return "The object is already initialized";
case INTERNAL_WALLET_ERROR: return "Internal error occurred";
case MIXIN_COUNT_TOO_BIG: return "MixIn count is too big";
case BAD_ADDRESS: return "Bad address";
case TRANSACTION_SIZE_TOO_BIG: return "Transaction size is too big";
case WRONG_AMOUNT: return "Wrong amount";
case SUM_OVERFLOW: return "Sum overflow";
case ZERO_DESTINATION: return "The destination is empty";
case TX_CANCEL_IMPOSSIBLE: return "Impossible to cancel transaction";
case WRONG_STATE: return "The wallet is in wrong state (maybe loading or saving), try again later";
case OPERATION_CANCELLED: return "The operation you've requested has been cancelled";
case TX_TRANSFER_IMPOSSIBLE: return "Transaction transfer impossible";
case WRONG_VERSION: return "Wrong version";
case FEE_TOO_SMALL: return "Transaction fee is too small";
case KEY_GENERATION_ERROR: return "Cannot generate new key";
case INDEX_OUT_OF_RANGE: return "Index is out of range";
case ADDRESS_ALREADY_EXISTS: return "Address already exists";
case TRACKING_MODE: return "The wallet is in tracking mode";
case WRONG_PARAMETERS: return "Wrong parameters passed";
case OBJECT_NOT_FOUND: return "Object not found";
case WALLET_NOT_FOUND: return "Requested wallet not found";
case CHANGE_ADDRESS_REQUIRED: return "Change address required";
case CHANGE_ADDRESS_NOT_FOUND: return "Change address not found";
case DESTINATION_ADDRESS_REQUIRED: return "Destination address required";
case DESTINATION_ADDRESS_NOT_FOUND: return "Destination address not found";
case BAD_PAYMENT_ID: return "Wrong payment id format";
case BAD_TRANSACTION_EXTRA: return "Wrong transaction extra format";
default: return "Unknown error";
}
}
private:
WalletErrorCategory() {
}
};
}
}
inline std::error_code make_error_code(CryptoNote::error::WalletErrorCodes e) {
return std::error_code(static_cast<int>(e), CryptoNote::error::WalletErrorCategory::INSTANCE);
}
namespace std {
template <>
struct is_error_code_enum<CryptoNote::error::WalletErrorCodes>: public true_type {};
}
| [
"bitnotecurrency@gmail.com"
] | bitnotecurrency@gmail.com |
a8f932d0e2c4672bb14da493bdb55420dbb857bf | 2e08bcd483446313086b97b72751559595e849e4 | /Server/src/ftp_server_connection.cpp | 1f03867843a2c35539edba1b9dd5344725f008f6 | [] | no_license | macdonaldezra/ClientServer | 5a8289454e7bbd8fb26953fed6f3c35d0593dfd0 | 562c10edb2c317cf66bff2a8691120d6aab7fa90 | refs/heads/master | 2022-10-19T14:29:38.643217 | 2020-06-14T04:50:44 | 2020-06-14T04:50:44 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,427 | cpp | #include "../include/ftp_server_connection.hpp"
#include "../include/ftp_server_net_util.hpp"
#include <iostream>
#include <unistd.h>
#include <sys/socket.h>
#include <cstring>
using namespace std;
int sendToRemote(int sockDescriptor, const char* message, int messageLength) {
int bytesLeft = messageLength;
int bytesSent;
while((messageLength - bytesLeft) < messageLength) {
bytesSent = send(sockDescriptor, message + messageLength - bytesLeft, bytesLeft, 0);
if (bytesSent == -1) {
return -1;
}
bytesLeft -= bytesSent;
}
return messageLength - bytesLeft;
}
bool isConnectionReadyToRead(int sockDescriptor, int timeoutSec, int timeoutUSec, bool& isError, bool&isTimedout) {
return isSocketReadyToRead(sockDescriptor, timeoutSec, timeoutUSec, isError, isTimedout);
}
int receiveFromRemote(int sockDescriptor, char* message, int messageLength) {
return recv(sockDescriptor, message, messageLength, 0);
}
void closeConnection(int& sockDescriptor) {
closeSocket(sockDescriptor);
}
void closeAllConnections(int& controlSockDescriptor, int& dataListenerSockDescriptor, int& dataSockDescriptor, bool& isClientConnected) {
printf("Closing client's connections.......\n");
closeConnection(controlSockDescriptor);
closeConnection(dataListenerSockDescriptor);
closeConnection(dataSockDescriptor);
isClientConnected = false;
}
| [
"macdonaldezra@gmail.com"
] | macdonaldezra@gmail.com |
c80303fd0ed99d32849e61b7d3d3b19631b34fba | 3306ffb058ea67d4140dcbc641a735d3cafdfd68 | /src/smessage.h | e7cb7e21339749c2fc1f3fe8e0b0b48402b8d80f | [
"MIT"
] | permissive | niobiumcoin/niobiumcoin | a98f724f3f5047ff6cdda4aba2d5e7e6ddf6fd44 | b6f3d8691231f51aa83c119740fb0971d764267a | refs/heads/master | 2019-07-12T20:14:00.837924 | 2017-11-21T19:59:34 | 2017-11-21T19:59:34 | 107,165,666 | 2 | 4 | null | null | null | null | UTF-8 | C++ | false | false | 10,789 | h | // Copyright (c) 2014-2015 The ShadowCoin developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef SEC_MESSAGE_H
#define SEC_MESSAGE_H
#include <leveldb/db.h>
#include <leveldb/write_batch.h>
#include "net.h"
#include "db.h"
#include "wallet.h"
#include "base58.h"
#include "lz4/lz4.h"
const unsigned int SMSG_HDR_LEN = 104; // length of unencrypted header, 4 + 2 + 1 + 8 + 16 + 33 + 32 + 4 +4
const unsigned int SMSG_PL_HDR_LEN = 1+20+65+4; // length of encrypted header in payload
const unsigned int SMSG_BUCKET_LEN = 60 * 10; // in seconds
const unsigned int SMSG_RETENTION = 60 * 60 * 48; // in seconds
const unsigned int SMSG_SEND_DELAY = 2; // in seconds, SecureMsgSendData will delay this long between firing
const unsigned int SMSG_THREAD_DELAY = 30;
const unsigned int SMSG_THREAD_LOG_GAP = 6;
const unsigned int SMSG_TIME_LEEWAY = 60;
const unsigned int SMSG_TIME_IGNORE = 90; // seconds that a peer is ignored for if they fail to deliver messages for a smsgWant
const unsigned int SMSG_MAX_MSG_BYTES = 4096; // the user input part
// max size of payload worst case compression
const unsigned int SMSG_MAX_MSG_WORST = LZ4_COMPRESSBOUND(SMSG_MAX_MSG_BYTES+SMSG_PL_HDR_LEN);
#define SMSG_MASK_UNREAD (1 << 0)
extern bool fSecMsgEnabled;
class SecMsgStored;
// Inbox db changed, called with lock cs_smsgDB held.
extern boost::signals2::signal<void (SecMsgStored& inboxHdr)> NotifySecMsgInboxChanged;
// Outbox db changed, called with lock cs_smsgDB held.
extern boost::signals2::signal<void (SecMsgStored& outboxHdr)> NotifySecMsgOutboxChanged;
// Wallet Unlocked, called after all messages received while locked have been processed.
extern boost::signals2::signal<void ()> NotifySecMsgWalletUnlocked;
class SecMsgBucket;
class SecMsgAddress;
class SecMsgOptions;
extern std::map<int64_t, SecMsgBucket> smsgBuckets;
extern std::vector<SecMsgAddress> smsgAddresses;
extern SecMsgOptions smsgOptions;
extern CCriticalSection cs_smsg; // all except inbox and outbox
extern CCriticalSection cs_smsgDB;
#pragma pack(push, 1)
class SecureMessage
{
public:
SecureMessage()
{
nPayload = 0;
pPayload = NULL;
};
~SecureMessage()
{
if (pPayload)
delete[] pPayload;
pPayload = NULL;
};
uint8_t hash[4];
uint8_t version[2];
uint8_t flags;
int64_t timestamp;
uint8_t iv[16];
uint8_t cpkR[33];
uint8_t mac[32];
uint8_t nonse[4];
uint32_t nPayload;
uint8_t* pPayload;
};
#pragma pack(pop)
class MessageData
{
// -- Decrypted SecureMessage data
public:
int64_t timestamp;
std::string sToAddress;
std::string sFromAddress;
std::vector<uint8_t> vchMessage; // null terminated plaintext
};
class SecMsgToken
{
public:
SecMsgToken(int64_t ts, uint8_t* p, int np, long int o)
{
timestamp = ts;
if (np < 8) // payload will always be > 8, just make sure
memset(sample, 0, 8);
else
memcpy(sample, p, 8);
offset = o;
};
SecMsgToken() {};
~SecMsgToken() {};
bool operator <(const SecMsgToken& y) const
{
// pack and memcmp from timesent?
if (timestamp == y.timestamp)
return memcmp(sample, y.sample, 8) < 0;
return timestamp < y.timestamp;
}
int64_t timestamp; // doesn't need to be full 64 bytes?
uint8_t sample[8]; // first 8 bytes of payload - a hash
int64_t offset; // offset
};
class SecMsgBucket
{
public:
SecMsgBucket()
{
timeChanged = 0;
hash = 0;
nLockCount = 0;
nLockPeerId = 0;
};
~SecMsgBucket() {};
void hashBucket();
int64_t timeChanged;
uint32_t hash; // token set should get ordered the same on each node
uint32_t nLockCount; // set when smsgWant first sent, unset at end of smsgMsg, ticks down in ThreadSecureMsg()
NodeId nLockPeerId; // id of peer that bucket is locked for
std::set<SecMsgToken> setTokens;
};
// -- get at the data
class CNiobiumAddress_B : public CNiobiumAddress
{
public:
uint8_t getVersion()
{
// TODO: fix
if (vchVersion.size() > 0)
return vchVersion[0];
return 0;
}
};
class CKeyID_B : public CKeyID
{
public:
uint32_t* GetPPN()
{
return pn;
}
};
class SecMsgAddress
{
public:
SecMsgAddress() {};
SecMsgAddress(std::string sAddr, bool receiveOn, bool receiveAnon)
{
sAddress = sAddr;
fReceiveEnabled = receiveOn;
fReceiveAnon = receiveAnon;
};
std::string sAddress;
bool fReceiveEnabled;
bool fReceiveAnon;
IMPLEMENT_SERIALIZE
(
READWRITE(this->sAddress);
READWRITE(this->fReceiveEnabled);
READWRITE(this->fReceiveAnon);
);
};
class SecMsgOptions
{
public:
SecMsgOptions()
{
// -- default options
fNewAddressRecv = true;
fNewAddressAnon = true;
fScanIncoming = true;
}
bool fNewAddressRecv;
bool fNewAddressAnon;
bool fScanIncoming;
};
class SecMsgCrypter
{
private:
uint8_t chKey[32];
uint8_t chIV[16];
bool fKeySet;
public:
SecMsgCrypter()
{
// Try to keep the key data out of swap (and be a bit over-careful to keep the IV that we don't even use out of swap)
// Note that this does nothing about suspend-to-disk (which will put all our key data on disk)
// Note as well that at no point in this program is any attempt made to prevent stealing of keys by reading the memory of the running process.
LockedPageManager::Instance().LockRange(&chKey[0], sizeof chKey);
LockedPageManager::Instance().LockRange(&chIV[0], sizeof chIV);
fKeySet = false;
}
~SecMsgCrypter()
{
// clean key
memset(&chKey, 0, sizeof chKey);
memset(&chIV, 0, sizeof chIV);
fKeySet = false;
LockedPageManager::Instance().LockRange(&chKey[0], sizeof chKey);
LockedPageManager::Instance().LockRange(&chIV[0], sizeof chIV);
}
bool SetKey(const std::vector<uint8_t>& vchNewKey, uint8_t* chNewIV);
bool SetKey(const uint8_t* chNewKey, uint8_t* chNewIV);
bool Encrypt(uint8_t* chPlaintext, uint32_t nPlain, std::vector<uint8_t> &vchCiphertext);
bool Decrypt(uint8_t* chCiphertext, uint32_t nCipher, std::vector<uint8_t>& vchPlaintext);
};
class SecMsgStored
{
public:
int64_t timeReceived;
char status; // read etc
uint16_t folderId;
std::string sAddrTo; // when in owned addr, when sent remote addr
std::string sAddrOutbox; // owned address this copy was encrypted with
std::vector<uint8_t> vchMessage; // message header + encryped payload
IMPLEMENT_SERIALIZE
(
READWRITE(this->timeReceived);
READWRITE(this->status);
READWRITE(this->folderId);
READWRITE(this->sAddrTo);
READWRITE(this->sAddrOutbox);
READWRITE(this->vchMessage);
);
};
class SecMsgDB
{
public:
SecMsgDB()
{
activeBatch = NULL;
};
~SecMsgDB()
{
// -- deletes only data scoped to this TxDB object.
if (activeBatch)
delete activeBatch;
};
bool Open(const char* pszMode="r+");
bool ScanBatch(const CDataStream& key, std::string* value, bool* deleted) const;
bool TxnBegin();
bool TxnCommit();
bool TxnAbort();
bool ReadPK(CKeyID& addr, CPubKey& pubkey);
bool WritePK(CKeyID& addr, CPubKey& pubkey);
bool ExistsPK(CKeyID& addr);
bool NextSmesg(leveldb::Iterator* it, std::string& prefix, uint8_t* vchKey, SecMsgStored& smsgStored);
bool NextSmesgKey(leveldb::Iterator* it, std::string& prefix, uint8_t* vchKey);
bool ReadSmesg(uint8_t* chKey, SecMsgStored& smsgStored);
bool WriteSmesg(uint8_t* chKey, SecMsgStored& smsgStored);
bool ExistsSmesg(uint8_t* chKey);
bool EraseSmesg(uint8_t* chKey);
leveldb::DB *pdb; // points to the global instance
leveldb::WriteBatch *activeBatch;
};
int SecureMsgBuildBucketSet();
int SecureMsgAddWalletAddresses();
int SecureMsgReadIni();
int SecureMsgWriteIni();
bool SecureMsgStart(bool fDontStart, bool fScanChain);
bool SecureMsgShutdown();
bool SecureMsgEnable();
bool SecureMsgDisable();
bool SecureMsgReceiveData(CNode* pfrom, std::string strCommand, CDataStream& vRecv);
bool SecureMsgSendData(CNode* pto, bool fSendTrickle);
bool SecureMsgScanBlock(CBlock& block);
bool ScanChainForPublicKeys(CBlockIndex* pindexStart);
bool SecureMsgScanBlockChain();
bool SecureMsgScanBuckets();
int SecureMsgWalletUnlocked();
int SecureMsgWalletKeyChanged(std::string sAddress, std::string sLabel, ChangeType mode);
int SecureMsgScanMessage(uint8_t *pHeader, uint8_t *pPayload, uint32_t nPayload, bool reportToGui);
int SecureMsgGetStoredKey(CKeyID& ckid, CPubKey& cpkOut);
int SecureMsgGetLocalKey(CKeyID& ckid, CPubKey& cpkOut);
int SecureMsgGetLocalPublicKey(std::string& strAddress, std::string& strPublicKey);
int SecureMsgAddAddress(std::string& address, std::string& publicKey);
int SecureMsgRetrieve(SecMsgToken &token, std::vector<uint8_t>& vchData);
int SecureMsgReceive(CNode* pfrom, std::vector<uint8_t>& vchData);
int SecureMsgStoreUnscanned(uint8_t *pHeader, uint8_t *pPayload, uint32_t nPayload);
int SecureMsgStore(uint8_t *pHeader, uint8_t *pPayload, uint32_t nPayload, bool fUpdateBucket);
int SecureMsgStore(SecureMessage& smsg, bool fUpdateBucket);
int SecureMsgSend(std::string &addressFrom, std::string &addressTo, std::string &message, std::string &sError);
int SecureMsgValidate(uint8_t *pHeader, uint8_t *pPayload, uint32_t nPayload);
int SecureMsgSetHash(uint8_t *pHeader, uint8_t *pPayload, uint32_t nPayload);
int SecureMsgEncrypt(SecureMessage &smsg, const std::string &addressFrom, const std::string &addressTo, const std::string &message);
int SecureMsgDecrypt(bool fTestOnly, std::string &address, uint8_t *pHeader, uint8_t *pPayload, uint32_t nPayload, MessageData &msg);
int SecureMsgDecrypt(bool fTestOnly, std::string &address, SecureMessage &smsg, MessageData &msg);
#endif // SEC_MESSAGE_H
| [
"dev@niobiumcoin.org"
] | dev@niobiumcoin.org |
5c1eb0a004721006ec536e09d06ff02164b559af | 9439733c1fa7689ec711b6e71d960e260b30e724 | /oldC/mgs/ranges/range_traits.cc | 30186b983888240e456f983b87c4a3019f2e2f67 | [] | no_license | bobstine/lang_C | 65a75951b450bee92ca2e411f20be961b660c2e6 | dfe3411ffe5aa4389b6c43baced1bb974de7b995 | refs/heads/master | 2020-05-31T00:09:18.192842 | 2020-04-20T18:21:03 | 2020-04-20T18:21:03 | 190,020,135 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 91 | cc | // $Id: range_traits.cc,v 1.1.1.1 2002/06/16 14:54:14 bob Exp $
#include "range_traits.h"
| [
"stine@wharton.upenn.edu"
] | stine@wharton.upenn.edu |
53c04fe957fd7505c3403b4ef9111b8af8d4bf0e | 1cd83dbb498655ee456431e15421199deaa39149 | /hw1/Tclock.cc | bbc380c66ca49058f33c7e52301b4b227c61c5de | [] | no_license | qwskykite/pp | f481abf0d9337a4c086b109f5174cf5f304df9e9 | 0a5dac26a018010e6586f0c3b0fa72c34ee27335 | refs/heads/master | 2020-08-20T13:32:35.671750 | 2019-10-18T13:22:52 | 2019-10-18T13:22:52 | 216,028,482 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 896 | cc | #include<ctime>
#include<string>
#include<cstdio>
using namespace std;
class Tclock{
public:
Tclock(string title);
void AddDura();
void Reset();
void Print();
private:
clock_t start;
double totalTime;
string title;
};
Tclock::Tclock(string title){
this->title = title;
Reset();
start = clock();
totalTime = 0;
}
void Tclock::AddDura(){
totalTime += double(clock() - start) / CLOCKS_PER_SEC;
start = clock();
}
void Tclock::Reset(){
start = clock();
totalTime = 0;
}
void Tclock::Print(){
printf("%s: %lfs\n", title.c_str(), totalTime);
}
int main(){
int k = 0;
Tclock ft = Tclock("fxx");
for(int i = 0; i < 1e9; i++)
k = k + 1;
ft.AddDura();
ft.Print();
for(int i = 0; i < 1e9; i++)
k = k + 1;
ft.AddDura();
ft.Print();
return 0;
} | [
"qwskykite209@gmail.com"
] | qwskykite209@gmail.com |
46f74f82b739dc03d9bc6e8caf4306f1c250e9fd | 66df1f3203bda375f673e5166afedd46a027065c | /src/main.cpp | 29cde64df663567f3e82013e0b4c0b16b9ccd61d | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | aerosayan/gefork-DOOM3-o2d3m | 7ca2bb36bf1351363a42fa840b023d23ebf5fae9 | 840bd10fb5ca9f3d02be2a0b0e2c838030b621b9 | refs/heads/master | 2022-01-19T10:25:45.670339 | 2018-09-28T21:55:45 | 2018-09-28T21:55:45 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,680 | cpp | /* {{{
MIT LICENSE
Copyright (c) 2018, Mihail Szabolcs
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the 'Software'), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
}}} */
#include "version.h"
#include "command_line_runner.h"
#include "od/helper.h"
#include <QCoreApplication>
#include <QCommandLineParser>
#include <QFileInfo>
#include <QTimer>
#ifndef OD_DEFAULT_SCALE
#define OD_DEFAULT_SCALE 32.0f
#endif
#ifndef OD_DEFAULT_MATERIAL
#define OD_DEFAULT_MATERIAL "textures/base_floor/squaretile"
#endif
using namespace od;
int main(int argc, char *argv[])
{
QCoreApplication app(argc, argv);
app.setApplicationName(QFileInfo(argv[0]).fileName());
app.setApplicationVersion(OD_VERSION_STRING);
QCommandLineParser parser;
parser.setApplicationDescription("Converts any Wavefront OBJ to a DOOM3 map.");
parser.addHelpOption();
parser.addVersionOption();
QCommandLineOption watchOption(
QStringList() << "w" << "watch", "Watches input file for changes.");
parser.addOption(watchOption);
QCommandLineOption outputOption(
QStringList() << "o" << "output", "Sets output file. (default: stdout)", "file");
parser.addOption(outputOption);
QCommandLineOption scaleOption(
QStringList() << "s" << "scale",
QString("Sets scale. (default: %1)").arg(OD_DEFAULT_SCALE), "scale");
parser.addOption(scaleOption);
QCommandLineOption materialOption(
QStringList() << "m" << "material",
QString("Sets default material.\n(default: %1)").arg(OD_DEFAULT_MATERIAL), "material");
parser.addOption(materialOption);
QCommandLineOption noWeaponsOption(
QStringList() << "no-weapons", "Starts with no weapons.");
parser.addOption(noWeaponsOption);
QCommandLineOption noMonsterAttackOption(
QStringList() << "no-monster-attack", "Monsters do not attack.");
parser.addOption(noMonsterAttackOption);
parser.addPositionalArgument("file", "Input file.");
if(argc < 2)
{
parser.showHelp();
return -1;
}
parser.process(app);
QStringList input = parser.positionalArguments();
if(input.isEmpty())
{
parser.showHelp();
return -1;
}
CommandLineArguments args;
args.noWeapons = parser.isSet(noWeaponsOption);
args.noMonsterAttack = parser.isSet(noMonsterAttackOption);
args.watch = parser.isSet(watchOption);
args.scale = parser.value(scaleOption).toFloat();
args.output = parser.value(outputOption);
args.material = parser.value(materialOption);
args.input = input.first();
if(args.scale <= 0.0f)
args.scale = OD_DEFAULT_SCALE;
if(args.material.isEmpty())
args.material = OD_DEFAULT_MATERIAL;
else
args.material = text::sanitize(args.material);
CommandLineRunner runner(args);
QTimer::singleShot(0, &runner, SLOT(exec()));
return app.exec();
}
/* vim: set ts=4 sw=4 sts=4 noet: */
| [
"theicebreaker007@gmail.com"
] | theicebreaker007@gmail.com |
d63f7edbd52b0a79aebda5d219e6b44b4b7b5dbe | 861c74edceb06b4f39093600a78879d8c5452f26 | /TapTown/Classes/HelloWorldScene.cpp | 21e738ec7f2ca1e54711eb3135569ca99fba5f7a | [] | no_license | level-two/TapTown | c989d15489243d45d1837ec88e6a3f67f329893c | c265637a7f978172cb98611cb69d267df2f5fccf | refs/heads/master | 2020-06-06T13:49:15.992046 | 2013-01-29T13:06:07 | 2013-01-29T13:06:07 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 9,203 | cpp | #include "HelloWorldScene.h"
#include "SimpleAudioEngine.h"
#define NONE 0
#define AI 1
#define HUMAN 2
using namespace cocos2d;
using namespace CocosDenshion;
CCScene* HelloWorld::scene()
{
// 'scene' is an autorelease object
CCScene *scene = CCScene::node();
// 'layer' is an autorelease object
HelloWorld *layer = HelloWorld::create();
// add layer as a child to scene
scene->addChild(layer);
// return the scene
return scene;
}
// on "init" you need to initialize your instance
bool HelloWorld::init()
{
if ( !CCLayer::init() )
{
return false;
}
s = CCDirector::sharedDirector()->getWinSize();
startNewGame();
return true;
}
void HelloWorld::onEnter()
{
CCLayer::onEnter();
CCDirector::sharedDirector()->getTouchDispatcher()->addTargetedDelegate(this, 0, true);
this->setKeypadEnabled(true);
}
void HelloWorld::onExit()
{
CCDirector::sharedDirector()->getTouchDispatcher()->removeDelegate(this);
CCLayer::onExit();
}
void HelloWorld::touchDelegateRetain()
{
this->retain();
}
void HelloWorld::touchDelegateRelease()
{
this->release();
}
bool HelloWorld::ccTouchBegan(CCTouch *pTouch, CCEvent *pEvent)
{
// return true;
//}
//
//void HelloWorld::ccTouchesEnded(CCSet* touches, CCEvent* event)
//{
// Choose one of the touches to work with
// CCTouch* touch = (CCTouch*)( touches->anyObject() );
if (winrarShown)
{
startNewGame();
return false;
}
float colWidth = CCDirector::sharedDirector()->getWinSize().width / COLS;
int column = pTouch->locationInView().x / colWidth;
bool ok = addPointInColumnAndDraw(column, HUMAN);
if (ok) {
if (!isPositionWinrar(column, findFreeRow(column)-1)) {
int aiMove = performAIMove();
if (isPositionWinrar(aiMove, findFreeRow(aiMove)-1))
showWinrar(AI);
}
else {
showWinrar(HUMAN);
}
}
return false;
}
void HelloWorld::startNewGame()
{
winrarShown = false;
for (int i = 0; i< COLS; i++)
for (int j = 0; j< ROWS; j++)
board[i][j] = NONE;
removeAllChildrenWithCleanup(false);
float wh = CCDirector::sharedDirector()->getWinSize().height;
float ww = CCDirector::sharedDirector()->getWinSize().width;
CCSprite *boardSpr = CCSprite::createWithSpriteFrameName("BOARD.png");
boardSpr->setPosition(ccp( ww/2, wh/2 ));
boardSpr->setRotation(90);
addChild(boardSpr);
}
bool HelloWorld::insertPointInColumn(int column, int color)
{
bool result = false;
for (int j = 0; j< ROWS; j++) {
if (board[column][j] == NONE) {
board[column][j] = color;
result = true;
break;
}
}
return result;
}
bool HelloWorld::removePointFromColumn(int column)
{
bool result = false;
for (int j = ROWS-1; j>=0; j--) {
if (board[column][j] != NONE) {
board[column][j] = NONE;
result = true;
break;
}
}
return result;
}
int HelloWorld::performAIMove()
{
int bestMove = 0;
float min = 1e6;
for (int i=0; i<COLS; i++)
{
if (!insertPointInColumn(i, AI))
continue;
if (isPositionWinrar(i, findFreeRow(i)-1))
{
bestMove=i;
removePointFromColumn(i);
break;
}
float max = -1e6;
for (int k=0; k<COLS; k++)
{
if (!insertPointInColumn(k, HUMAN))
continue;
float s[3];
getPositionStrength(s);
if (isPositionWinrar(k, findFreeRow(k)-1))
s[HUMAN] += 10000;
float ds = s[HUMAN]-s[AI];
if (ds>max) max = ds;
removePointFromColumn(k);
}
if (max<min) { min=max; bestMove=i; }
removePointFromColumn(i);
}
addPointInColumnAndDraw(bestMove, AI);
return bestMove;
}
bool HelloWorld::isPositionWinrar(int i, int j)
{
PositionData pd1, pd2;
int color = board[i][j];
float s[3] = {0,0,0};
getStrengthInDirection(i, j, 1, 0, &pd1);
getStrengthInDirection(i, j, -1, 0, &pd2);
getSum(pd1, pd2, s);
if (s[color]+1 >= 4) return true;
getStrengthInDirection(i, j, 0, -1, &pd1);
getStrengthInDirection(i, j, 0, 1, &pd2);
getSum(pd1, pd2, s);
if (s[color]+1 >= 4) return true;
getStrengthInDirection(i, j, 1, 1, &pd1);
getStrengthInDirection(i, j, -1, -1, &pd2);
getSum(pd1, pd2, s);
if (s[color]+1 >= 4) return true;
getStrengthInDirection(i, j, -1, 1, &pd1);
getStrengthInDirection(i, j, 1, -1, &pd2);
getSum(pd1, pd2, s);
if (s[color]+1 >= 4) return true;
return false;
}
void HelloWorld::getSum(PositionData &pd1, PositionData &pd2, float s[])
{
s[0] = s[1] = s[2] = 0;
s[pd1.color]+=pd1.sum;
s[pd2.color]+=pd2.sum;
}
void HelloWorld::getPositionStrength(float s[])
{
s[0]=0; s[1]=0; s[2]=0;
for (int i=0; i<COLS; i++)
{
int j = findFreeRow(i);
getStrengthForCoordinate(i, j, s);
}
}
int HelloWorld::findFreeRow(int i)
{
int j=0;
while (j<ROWS) {
if (board[i][j] == NONE) break;
j++;
}
return j;
}
void HelloWorld::getStrengthForCoordinate(int i, int j, float s[])
{
PositionData pd1, pd2;
getStrengthInDirection(i, j, 1, 0, &pd1);
getStrengthInDirection(i, j, -1, 0, &pd2);
calculateSum(pd1, pd2, s);
getStrengthInDirection(i, j, 0, -1, &pd1);
getStrengthInDirection(i, j, 0, 1, &pd2);
calculateSum(pd1, pd2, s);
getStrengthInDirection(i, j, 1, 1, &pd1);
getStrengthInDirection(i, j, -1, -1, &pd2);
calculateSum(pd1, pd2, s);
getStrengthInDirection(i, j, -1, 1, &pd1);
getStrengthInDirection(i, j, 1, -1, &pd2);
calculateSum(pd1, pd2, s);
}
void HelloWorld::calculateSum(PositionData &pd1, PositionData &pd2, float s[])
{
if (pd1.color == pd2.color)
{
int sum = pd1.sum + pd2.sum;
if (pd1.blocked && pd2.blocked && sum >= WINLEN-1) // если блокировано сумма >= трех
s[pd1.color] += 7.0 * sum;
else if (!pd1.blocked && !pd2.blocked && sum >= WINLEN-1) // если оба неблокированные
s[pd1.color] += 10.0 * sum;
else if (!pd1.blocked && !pd2.blocked) // если оба неблокированные
s[pd1.color] += 2.0 * sum;
else if (pd1.blocked != pd2.blocked) // если блокировано с одной стороны
s[pd1.color] += 1.2 * sum;
}
else
{
if (pd1.sum == WINLEN-1) // если трешка
s[pd1.color] += 7.0 * pd1.sum;
else if (!pd1.blocked && pd2.color == NONE) // если неблокированное с обеих сторон
s[pd1.color] += 2.0 * pd1.sum;
else if (pd1.blocked && pd2.color == NONE) // блокировано с одной стороны
s[pd1.color] += pd1.sum;
if (pd2.sum == WINLEN-1) // если трешка
s[pd2.color] += 7.0 * pd2.sum;
else if (!pd2.blocked && pd1.color == NONE) // если неблокированное с обеих сторон
s[pd2.color] += 2.0 * pd2.sum;
else if (pd2.blocked && pd1.color == NONE) // блокировано с одной стороны
s[pd2.color] += pd2.sum;
}
}
void HelloWorld::getStrengthInDirection(int i, int j, int di, int dj, PositionData *pd)
{
pd->blocked = false;
pd->color = NONE;
pd->sum = 0;
i += di; j += dj;
if (i>=0 && i<COLS && j>=0 && j<ROWS)
pd->color = board[i][j];
if (pd->color == NONE)
return;
pd->sum++;
i+=di; j+=dj;
while (true)
{
if (i<0 || i==COLS || j<0 || j==ROWS)
{
pd->blocked = true;
break;
}
if (board[i][j] == NONE)
break;
if (board[i][j] != pd->color)
{
pd->blocked = true;
break;
}
pd->sum++;
i+=di; j+=dj;
}
}
bool HelloWorld::addPointInColumnAndDraw(int column, int color)
{
if (!insertPointInColumn(column, color))
return false;
int row = ROWS-1;
while (board[column][row] == NONE && row>=0) row--;
float colWidth = s.width / COLS;
float rowHeight = s.height / ROWS;
CCSprite* pointSpr = CCSprite::createWithSpriteFrameName(color == AI ? "AI.png" : "HUMAN.png");
pointSpr->setPosition(ccp( (column+0.5)*colWidth, (row+0.5)*rowHeight) );
addChild(pointSpr);
return true;
}
void HelloWorld::showWinrar(int color)
{
winrarShown = true;
CCLabelTTF *label = CCLabelTTF::create(color==AI ? "The Winrar is Hi" : "The Winrar is You" , "Thonburi", 60);
addChild(label);
label->setPosition(ccp(s.width/2, s.height/2));
label->setColor(ccBLACK);
CCLOG("The Winrar is %s", color==AI ? "Hi" : "You");
} | [
"bredobulbulizator@gmail.com"
] | bredobulbulizator@gmail.com |
5f375d3fe222b3c4bbdfa2abcaed9203defe41a8 | 1f0e52daa702a442db609766a56f99f833368a6b | /2018summer/9 10/uva11982.cpp | c84fb2ffa7842a28062dbdfb00d29673c600e262 | [] | no_license | TouwaErioH/Algorithm | e0495b053e6f33353a4e526955cd269d2acc0027 | a5851529168a68147ab548678c16251f6dfa017d | refs/heads/master | 2022-12-07T03:46:50.674787 | 2020-08-20T08:45:49 | 2020-08-20T08:45:49 | null | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 1,453 | cpp | /*
首先我们定义第一维状态是当前匹配到的点是谁。
然后我们容易发现对于S1 集合的 i 和 S2 集合的 i , 当二分图处于完美匹配时, S2 中的 i 及 i 以上的点中会有几个点不与S1 中 i 点以上的点匹配。 把这些边去掉之后这几个点就成为了未匹配点。
由此我们发现了子问题:i-1以上有j 个点未匹配时的总数。
于是我们定义状态的第二维:S2中i点以上未匹配点有j个
至此状态定义完毕。
*/
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1005;
int length;
char s[maxn];
long long dp[maxn][maxn];
const long long mod = 1000000007;
void fdp(void){
memset(dp,0,sizeof(dp));
dp[0][0] = 1;
for (int i = 1; i <= length; i++){
if (s[i] == 'U'){
for (int j = 0; j <= i; j++){
if (j > 0)
dp[i][j] = (dp[i][j] + dp[i - 1][j - 1] + dp[i - 1][j]*j%mod) % mod;
else
dp[i][j] = (dp[i][j] + dp[i - 1][j]*j%mod) % mod;
}
}
else if (s[i] == 'D'){
for (int j = 0; j <= i; j++){
dp[i][j] = (dp[i][j] + dp[i - 1][j] * j%mod +
dp[i - 1][j + 1] * (j + 1) % mod*(j + 1) % mod) % mod;
}
}
else{
for (int j = 0; j <= i; j++)
dp[i][j] = dp[i - 1][j];
}
}
}
int main(){
int T,kase=0;
cin >> T;
while(T--){
scanf("%s",s+1);
length = strlen(s+1);
fdp();
printf("Case %d: %d\n",++kase,dp[length][0]);
}
return 0;
}
| [
"1301004462@qq.com"
] | 1301004462@qq.com |
21b4f6357f0f37f74b7db20478d70e65063e1989 | 6b8c3974d3ce5f7841e51dcb406666c0c5d92155 | /vtn/coordinator/modules/uppl/itc_configuration_request.cc | 6975c229f02b567bfd0524c3f86f6e36ba80352e | [] | no_license | swjang/cloudexchange | bbbf78a2e7444c1070a55378092c17e8ecb27059 | c06ed54f38daeff23166fb0940b27df74c70fc3e | refs/heads/master | 2020-12-29T03:18:43.076887 | 2015-09-21T07:13:22 | 2015-09-21T07:13:22 | 42,845,532 | 1 | 1 | null | 2015-09-21T07:13:22 | 2015-09-21T05:19:35 | C++ | UTF-8 | C++ | false | false | 19,162 | cc | /*
* Copyright (c) 2012-2014 NEC Corporation
* All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this
* distribution, and is available at http://www.eclipse.org/legal/epl-v10.html
*/
/**
* @brief ITC Configuration Req
* @file itc_configuration_request.cc
*
*/
#include "itc_kt_base.hh"
#include "itc_kt_root.hh"
#include "itc_kt_controller.hh"
#include "itc_kt_switch.hh"
#include "itc_kt_boundary.hh"
#include "itc_kt_ctr_domain.hh"
#include "itc_kt_link.hh"
#include "itc_kt_port.hh"
#include "itc_kt_logicalport.hh"
#include "itc_kt_logical_member_port.hh"
#include "itc_configuration_request.hh"
#include "ipct_util.hh"
using unc::uppl::PhysicalLayer;
/* ConfigurationRequest
* @Description : This function initializes the member variables
* and allocates the memory for the key instances of
* kt_root,kt_controller,kt_domain,kt_boundary
* @param[in] : None
* @return : None
* */
ConfigurationRequest::ConfigurationRequest() {
memset(&key_root_obj, 0, sizeof(key_root_t));
memset(&key_ctr_obj, 0, sizeof(key_ctr_t));
memset(&val_ctr_obj, 0, sizeof(val_ctr_t));
memset(&key_domain_obj, 0, sizeof(key_ctr_domain_t));
memset(&val_domain_obj, 0, sizeof(val_ctr_domain_t));
memset(&key_boundary_obj, 0, sizeof(key_boundary_t));
memset(&val_boundary_obj, 0, sizeof(val_boundary_t));
}
/* ~ConfigurationRequest
* @Description : This function releases the memory allocated to
* pointer member data
* @param[in] : None
* @param[out] : None
* @return : None
* */
ConfigurationRequest::~ConfigurationRequest() {
}
/* ProcessReq
* @Description : This function creates the respective Kt class object to
* process the configuration request received from north bound
* @param[in] : session - Object of ServerSession where the request
* argument present
* @return : UNC_RC_SUCCESS is returned when the response is added to
* ipc session successfully otherwise Common error code is
* returned when ipc response could not be added to session.
* */
UncRespCode ConfigurationRequest::ProcessReq(
ServerSession &session,
physical_request_header &obj_req_hdr) {
PhysicalLayer *physical_layer = PhysicalLayer::get_instance();
PhysicalCore* physical_core = physical_layer->get_physical_core();
if (physical_core->system_transit_state_ == true) {
pfc_log_error("UNC is in state transit mode ");
return UNC_UPPL_RC_ERR_OPERATION_NOT_ALLOWED;
}
Kt_Base *KtObj = NULL;
UncRespCode db_ret = UNC_RC_SUCCESS;
OPEN_DB_CONNECTION(unc::uppl::kOdbcmConnReadWriteNb, db_ret);
if (db_ret != UNC_RC_SUCCESS) {
pfc_log_fatal("DB Connection failure for operation %d",
obj_req_hdr.operation);
return db_ret;
}
UncRespCode return_code = UNC_RC_SUCCESS, resp_code = UNC_RC_SUCCESS;
void* key_struct = NULL;
void* val_struct = NULL;
physical_response_header rsh;
PhyUtil::getRespHeaderFromReqHeader(obj_req_hdr, rsh);
resp_code = ValidateReq(&db_conn, session, obj_req_hdr,
key_struct, val_struct, KtObj);
if (resp_code != UNC_RC_SUCCESS) {
// validation failed call add output
// return the actual response
pfc_log_error("Config validation failed %d", resp_code);
rsh.result_code = resp_code;
int err = PhyUtil::sessOutRespHeader(session, rsh);
if (KtObj != NULL) {
err |= KtObj->AddKeyStructuretoSession(obj_req_hdr.key_type,
&session, key_struct);
delete KtObj;
KtObj = NULL;
}
if (err != 0) {
return_code = UNC_UPPL_RC_ERR_IPC_WRITE_ERROR;
} else {
return_code = UNC_RC_SUCCESS;
}
return return_code;
}
switch (obj_req_hdr.operation) {
case UNC_OP_CREATE:
{
resp_code = KtObj->Create(&db_conn, obj_req_hdr.client_sess_id,
obj_req_hdr.config_id,
key_struct,
val_struct,
obj_req_hdr.data_type,
session);
break;
}
case UNC_OP_UPDATE:
{
// Invoke Update operation for respective KT class
resp_code = KtObj->Update(&db_conn, obj_req_hdr.client_sess_id,
obj_req_hdr.config_id,
key_struct,
val_struct,
obj_req_hdr.data_type,
session);
break;
}
case UNC_OP_DELETE:
{
// Invoke Delete operation for respective KT class
resp_code = KtObj->Delete(&db_conn, obj_req_hdr.client_sess_id,
obj_req_hdr.config_id,
key_struct,
obj_req_hdr.data_type,
session);
break;
}
default:
// Already handled
break;
}
if (resp_code != UNC_RC_SUCCESS) {
// validation failed call add out put
// return the actual response
pfc_log_error("Config validation failed");
rsh.result_code = resp_code;
int err = PhyUtil::sessOutRespHeader(session, rsh);
err |= KtObj->AddKeyStructuretoSession(obj_req_hdr.key_type, &session,
key_struct);
if (err == 0) {
resp_code = UNC_RC_SUCCESS;
} else {
resp_code = UNC_UPPL_RC_ERR_IPC_WRITE_ERROR;
}
}
if (KtObj != NULL) {
delete KtObj;
KtObj = NULL;
}
if (resp_code == UNC_UPPL_RC_ERR_IPC_WRITE_ERROR) {
// It's a common error code
return_code = UNC_UPPL_RC_ERR_IPC_WRITE_ERROR;
}
pfc_log_debug("Returning %d from config request handler", return_code);
return return_code;
}
/* ValidateReq
* @Description : This function validates the request received from north bound
* @param[in] : session - Object of ServerSession where the request
* argument present
* key struct - the key instance for appropriate key types
* value struct - the value struct for the appropriate key types
* obj_req_hdr - object of physical request header
* KtObj - Object of the base class to invoke appropriate
* kt class
* @return : UNC_RC_SUCCESS if validation is successful
* or UNC_UPPL_RC_ERR_* if validation is failed
* */
UncRespCode ConfigurationRequest::ValidateReq(
OdbcmConnectionHandler *db_conn,
ServerSession &session,
physical_request_header obj_req_hdr,
void* &key_struct, void* &val_struct,
Kt_Base* &KtObj) {
UncRespCode return_code = UNC_RC_SUCCESS, resp_code = UNC_RC_SUCCESS;
physical_response_header rsh;
PhyUtil::getRespHeaderFromReqHeader(obj_req_hdr, rsh);
uint32_t key_type = obj_req_hdr.key_type;
// other than kt_controller keytype create is not allowed from NB
// if unc is running in coexists mode
UncMode unc_mode = PhysicalLayer::get_instance()->\
get_physical_core()->getunc_mode();
if (unc_mode == UNC_COEXISTS_MODE && key_type != UNC_KT_CONTROLLER) {
pfc_log_error("unc coexists mode will support only kt_controller keytype");
return UNC_UPPL_RC_ERR_OPERATION_NOT_SUPPORTED;
}
// create the respective object to invoke appropriate Kt class
switch (key_type) {
case UNC_KT_ROOT:
{
KtObj = new Kt_Root();
if (KtObj == NULL) {
pfc_log_error("Resource allocation error");
return UNC_UPPL_RC_ERR_FATAL_RESOURCE_ALLOCATION;
}
// The root key in request is not considered
key_struct = static_cast<void*> (&key_root_obj);
val_struct = NULL;
break;
}
case UNC_KT_DATAFLOW:
{ if (obj_req_hdr.operation != UNC_OP_READ) {
pfc_log_error("Config operations not allowed for KtDataflow");
return UNC_UPPL_RC_ERR_OPERATION_NOT_ALLOWED;
}
break;
}
case UNC_KT_CONTROLLER:
{
resp_code = ValidateController(db_conn, session,
obj_req_hdr.data_type,
obj_req_hdr.operation,
key_struct,
val_struct);
if (resp_code != UNC_RC_SUCCESS) {
return resp_code;
}
KtObj = new Kt_Controller();
if (KtObj == NULL) {
pfc_log_error("Resource allocation error");
return UNC_UPPL_RC_ERR_FATAL_RESOURCE_ALLOCATION;
}
// check the uncmode, ctrtype and return error
// if ctrtype is non-pfc controller
if (unc_mode == UNC_COEXISTS_MODE) {
if (obj_req_hdr.operation == UNC_OP_CREATE &&
val_ctr_obj.type != UNC_CT_PFC) {
pfc_log_error("non-pfc type controller create is not supported in"
"unc coexists mode");
return UNC_UPPL_RC_ERR_OPERATION_NOT_SUPPORTED;
}
if (obj_req_hdr.operation == UNC_OP_DELETE) {
// retrieve the controller type from db
unc_keytype_ctrtype_t type = UNC_CT_UNKNOWN;
key_ctr_t *obj_key_ctr= reinterpret_cast<key_ctr_t*>(key_struct);
UncRespCode ctr_type_status =
PhyUtil::get_controller_type(db_conn,
reinterpret_cast<const char*>(obj_key_ctr->controller_name),
type, (unc_keytype_datatype_t) obj_req_hdr.data_type);
if (ctr_type_status != UNC_RC_SUCCESS) {
pfc_log_error(
"Operation %d is not allowed as controller instance %s not exists",
obj_req_hdr.operation, obj_key_ctr->controller_name);
return UNC_UPPL_RC_ERR_OPERATION_NOT_SUPPORTED;
}
pfc_log_debug("Controller type: %d", type);
if (type != UNC_CT_PFC) {
pfc_log_error("non-pfc type controller delete is not supported in"
"unc coexists mode");
return UNC_UPPL_RC_ERR_OPERATION_NOT_SUPPORTED;
}
}
if (obj_req_hdr.operation == UNC_OP_UPDATE) {
pfc_log_error("kt_controller update is not supported in"
"unc coexists mode");
return UNC_UPPL_RC_ERR_OPERATION_NOT_SUPPORTED;
}
if (obj_req_hdr.operation == UNC_OP_CREATE) {
UncRespCode ctr_count_status =
KtObj->ValidateControllerCount(
db_conn, key_struct, val_struct, UNC_DT_CANDIDATE);
if (ctr_count_status != UNC_RC_SUCCESS) {
pfc_log_error("kt_controller count is exceeds (>1) in"
"unc coexists mode");
return ctr_count_status;
}
}
}
break;
}
case UNC_KT_CTR_DATAFLOW:
{ if (obj_req_hdr.operation != UNC_OP_READ) {
pfc_log_error("Config operations not allowed for KtCtrDataflow");
return UNC_UPPL_RC_ERR_OPERATION_NOT_ALLOWED;
}
break;
}
case UNC_KT_CTR_DOMAIN:
{
resp_code = ValidateDomain(db_conn, session,
obj_req_hdr.data_type,
obj_req_hdr.operation,
key_struct,
val_struct);
if (resp_code != UNC_RC_SUCCESS) {
return resp_code;
}
KtObj = new Kt_Ctr_Domain();
if (KtObj == NULL) {
pfc_log_error("Resource allocation error");
return UNC_UPPL_RC_ERR_FATAL_RESOURCE_ALLOCATION;
}
break;
}
case UNC_KT_BOUNDARY:
{
resp_code = ValidateBoundary(db_conn, session,
obj_req_hdr.data_type,
obj_req_hdr.operation,
key_struct,
val_struct);
if (resp_code != UNC_RC_SUCCESS) {
return resp_code;
}
KtObj = new Kt_Boundary();
if (KtObj == NULL) {
pfc_log_error("Resource allocation error");
return UNC_UPPL_RC_ERR_FATAL_RESOURCE_ALLOCATION;
}
break;
}
case UNC_KT_LOGICAL_PORT:
case UNC_KT_PORT:
case UNC_KT_LOGICAL_MEMBER_PORT:
case UNC_KT_SWITCH:
case UNC_KT_LINK:
{
pfc_log_error("Operation not allowed");
return UNC_UPPL_RC_ERR_OPERATION_NOT_ALLOWED;
}
default:
{
pfc_log_error("Key type not supported");
return UNC_UPPL_RC_ERR_KEYTYPE_NOT_SUPPORTED;
}
}
switch (obj_req_hdr.operation) {
case UNC_OP_CREATE:
case UNC_OP_UPDATE:
case UNC_OP_DELETE:
{
// form validate request for CREATE operation
resp_code = KtObj->ValidateRequest(db_conn, key_struct,
val_struct,
obj_req_hdr.operation,
obj_req_hdr.data_type,
key_type);
break;
}
default:
resp_code = UNC_UPPL_RC_ERR_OPERATION_NOT_SUPPORTED;
break;
}
if (resp_code != UNC_RC_SUCCESS) {
// validation failed call add output
// return the actual response
pfc_log_error("Config validation failed");
return resp_code;
}
pfc_log_debug("Returning %d from config validate request handler",
return_code);
return return_code;
}
/* ValidateController
* @Description : This function validates the value struct and the scalability
* and also checks the capability for UNC_KT_CONTROLLER
* @param[in] : session - Object of ServerSession where the request
* argument present
* data_type - The data_type UNC_DT_CANDIDATE is only allowed
* operation - contains UNC_OP_CREATE or UNC_OP_UPDATE
* key struct - specifies key instance of KT_Controller
* value struct - specifies value structure of KT_CONTROLLER
* @return : UNC_RC_SUCCESS if scalability number is within range
* or UNC_UPPL_RC_ERR_* if not
* * */
UncRespCode ConfigurationRequest::ValidateController(
OdbcmConnectionHandler *db_conn,
ServerSession &session,
uint32_t data_type,
uint32_t operation,
void* &key_struct,
void* &val_struct) {
UncRespCode resp_code = UNC_RC_SUCCESS;
if (data_type != UNC_DT_CANDIDATE) {
pfc_log_info("Operation not allowed in given data type %d",
data_type);
resp_code = UNC_UPPL_RC_ERR_OPERATION_NOT_ALLOWED;
return resp_code;
}
// populate key_ctr structure
int err = session.getArgument(8, key_ctr_obj);
pfc_log_debug("%s", IpctUtil::get_string(key_ctr_obj).c_str());
key_struct = static_cast<void*> (&key_ctr_obj);
if (err == 0 &&
(operation == UNC_OP_CREATE ||
operation == UNC_OP_UPDATE)) {
// populate val_ctr structure
err |= session.getArgument(9, val_ctr_obj);
val_struct = static_cast<void*> (&val_ctr_obj);
pfc_log_debug("%s", IpctUtil::get_string(val_ctr_obj).c_str());
}
if (err != 0) {
pfc_log_error("Not able to read val_ctr_obj, err is %d", err);
return UNC_UPPL_RC_ERR_BAD_REQUEST;
}
if (operation != UNC_OP_CREATE) {
pfc_log_debug("Validation not required for other than create");
return UNC_RC_SUCCESS;
}
return UNC_RC_SUCCESS;
}
/* ValidateDomain
* @Description : This function validates the value struct of the
* UNC_KT_DOMAIN
* @param[in] : session - Object of ServerSession where the request
* argument present
* data_type - The data_type UNC_DT_CANDIDATE is only allowed
* operation - contains UNC_OP_CREATE or UNC_OP_UPDATE
* key struct - specifies key instance of KT_Domain
* value struct - specifies value structure of KT_Domain
* @return : UNC_RC_SUCCESS if the validation is success
* or UNC_UPPL_RC_ERR_* if validation is failed
* */
UncRespCode ConfigurationRequest::ValidateDomain(
OdbcmConnectionHandler *db_conn,
ServerSession &session,
uint32_t data_type,
uint32_t operation,
void* &key_struct,
void* &val_struct) {
UncRespCode resp_code = UNC_RC_SUCCESS;
if (data_type != UNC_DT_CANDIDATE) {
pfc_log_info("Operation not allowed in given data type %d",
data_type);
resp_code = UNC_UPPL_RC_ERR_OPERATION_NOT_ALLOWED;
return resp_code;
}
// populate key_domain_obj structure
int err = session.getArgument(8, key_domain_obj);
key_struct = static_cast<void*> (&key_domain_obj);
pfc_log_debug("%s", IpctUtil::get_string(key_domain_obj).c_str());
if (err == 0 &&
(operation == UNC_OP_CREATE ||
operation == UNC_OP_UPDATE)) {
// populate val_domain_obj structure
err |= session.getArgument(9, val_domain_obj);
val_struct = static_cast<void*> (&val_domain_obj);
pfc_log_debug("%s", IpctUtil::get_string(val_domain_obj).c_str());
}
if (err != 0) {
pfc_log_error("Not able to read val_domain_obj, err is %d", err);
return UNC_UPPL_RC_ERR_BAD_REQUEST;
}
return UNC_RC_SUCCESS;
}
/* ValidateBoundary
* @Description : This function validates the value struct of the
* UNC_KT_BOUNDARY
* @param[in] : session - Object of ServerSession where the request
* argument present
* data_type - The data_type UNC_DT_CANDIDATE is only allowed
* operation - contains UNC_OP_CREATE or UNC_OP_UPDATE
* key struct - specifies key instance of KT_Boundary
* value struct - specifies value structure of KT_Boundary
* @return : UNC_RC_SUCCESS if the validation is success
* or UNC_UPPL_RC_ERR_* if validation is failed
* */
UncRespCode ConfigurationRequest::ValidateBoundary(
OdbcmConnectionHandler *db_conn,
ServerSession &session,
uint32_t data_type,
uint32_t operation,
void* &key_struct,
void* &val_struct) {
UncRespCode resp_code = UNC_RC_SUCCESS;
if (data_type != UNC_DT_CANDIDATE) {
pfc_log_info("Operation not allowed in given data type %d",
data_type);
resp_code = UNC_UPPL_RC_ERR_OPERATION_NOT_ALLOWED;
return resp_code;
}
// populate key_boundary_obj structure
int err = session.getArgument(8, key_boundary_obj);
if (err != 0) {
pfc_log_error("Not able to read key_boundary_obj, err is %d", err);
return UNC_UPPL_RC_ERR_BAD_REQUEST;
}
key_struct = static_cast<void*> (&key_boundary_obj);
pfc_log_debug("%s", IpctUtil::get_string(key_boundary_obj).c_str());
if (err == 0 &&
(operation == UNC_OP_CREATE ||
operation == UNC_OP_UPDATE)) {
// populate val_boundary_obj structure
err |= session.getArgument(9, val_boundary_obj);
val_struct = static_cast<void*> (&val_boundary_obj);
pfc_log_debug("%s", IpctUtil::get_string(val_boundary_obj).c_str());
}
if (err != 0) {
pfc_log_error("Not able to read val_boundary_obj, err is %d", err);
return UNC_UPPL_RC_ERR_BAD_REQUEST;
}
return UNC_RC_SUCCESS;
}
| [
"kiku4@kinx.net"
] | kiku4@kinx.net |
1a95cf7cbcd362e22eba419b488d80d4a79a48f2 | d48cbdfb400c2470dbe5a9407cd87bad297598f0 | /main.cpp | 001572814be433fa9aaf654202e61d7e6e5f297d | [] | no_license | mirastroie/FibonacciHeaps | a4efd20e7b4c3a5964396b323daae2c39bb0981c | bfd2973c989a3c4cee4173b916f521897987b989 | refs/heads/master | 2022-04-26T20:35:03.922132 | 2020-04-30T20:04:55 | 2020-04-30T20:04:55 | 260,306,639 | 0 | 0 | null | null | null | null | WINDOWS-1252 | C++ | false | false | 17,377 | cpp | #include <iostream>
#include <cmath>
#include <vector>
#include "MyException.h"
using namespace std;
struct Node
{
int data,degree;
bool mark=false;
bool searched=false;
Node *parent=NULL,*child=NULL,*left=NULL,*right=NULL;
};
void fibHeapInsert(Node*&Min, int new_data, int&n)
{
n++;
Node *new_node=new Node;
new_node->data=new_data;
new_node->degree=0;
new_node->mark=false;
new_node->parent=NULL;
new_node->child=NULL;
if(Min==NULL) ///verificam daca H este gol
{
new_node->left=new_node;
new_node->right=new_node;
///la sfarsit setam pointer-ul Min catre nod
Min=new_node;
return;
}
///altfel - daca heap-ul contine si alti arbori
///ideea este urmatoare: important este sa schimbi valoarea lui min->left->right inainte de cea a lui min->left
///altfel, nodul new_node o sa fie legat la dreapta de el insusi
new_node->left=Min->left;
Min->left->right=new_node;
Min->left=new_node;
new_node->right=Min;
if(new_node->data<Min->data)
Min=new_node;
}
void FibonacciHeap(Node*&Min, int&n)
{
n=0;
Min=NULL;
}
Node* fibHeapBuild(vector<int> v)
{
Node *Min;
int n=0;
FibonacciHeap(Min,n);
for(auto &x: v)
fibHeapInsert(Min,x,n);
return Min;
}
int findMin(Node*Min)
{
return Min->data;
}
void fibHeapDisplayChildren(Node*x)
{
if(x->child!=NULL)
{
cout<<"( Copii nodului "<<x->data<<" sunt : ";
Node *it=x->child;
do
{
if(it!=x->child)cout<<", ";
cout<<it->data;
fibHeapDisplayChildren(it);
it=it->right;
}
while(it!=x->child);
cout<<" endoflist)\n";
}
}
void fibHeapDisplay(Node *Min, int n=0)
{
Node*start=Min;
if(start==NULL)
{
cout<<"Heap-ul este gol\n";
return;
}
cout<<"Heapul are "<<n<<" noduri si valorile: \n";
do
{
if (start != Min)
{
cout << "-->";
}
cout<<start->data<<" ";
fibHeapDisplayChildren(start);
start=start->right;
}
while(start!=Min);
cout<<"\n";
}
void fibHeapLink(Node *&x, Node*&y)
{
Node *new_child=y;
///il eliminam pe y din root list
y->left->right=y->right;
y->right->left=y->left;
x->degree++;
new_child->left=new_child;
new_child->right=new_child;
///salvam copilul lui x ca sa ne fie mai usor sa implementam legaturile
Node*brother=x->child;
if(brother!=NULL)
{
///inseram y in dreapta copilului lui x
new_child->right=brother->right;
brother->right->left=new_child;
brother->right=new_child;
new_child->left=brother;
///il punem pe x sa pointeze catre cel mai mic copil
if(new_child->data<brother->data)
x->child=new_child;
}
else
x->child=new_child;
///il facem pe x parinte a lui new_child
new_child->parent=x;
new_child->mark=false;
}
void add(Node*&Min,Node*new_node)
{
if(Min!=NULL)
{
Min->right->left=new_node;
new_node->right=Min->right;
Min->right=new_node;
new_node->left=Min;
return;
}
Min=new_node;
Min->right=Min;
Min->left=Min;
}
void consolidate(Node*&Min, int n)
{
int D=log2(n);
Node* A[D+1];
for(int i=0; i<=D+1; i++)
A[i]=NULL;
///pentru fiecare nod din root list parcurgem urmatorul algoritm
Node *it=Min;
Node *x=it;
do
{
int d=x->degree;
while(A[d]!=NULL)
{
///daca mai exista un nod de acelasi degree->trebuie sa facem link intre cele doua;
Node *y=A[d];
///interschimbam intre ei pointerii; astfel x
///va pointa mereu catre nodul care are valoare retinuta
///mai mica - cel pe care vrem sa il facem parinte
///al celuilalt nod de acelasi degree
if(x->data>y->data)
{
Node *aux=x;
x=y;
y=aux;
}
if(y==Min)
Min=x;
fibHeapLink(x,y);
A[d]=NULL;
d=d+1;
}
A[d]=x;
x=x->right;
}
while(x!=Min);
///golim heap-ul nostru, fara a sterge insa nodurile din memorie
///o sa reconstruim heap-ul pe baza informatiilor din vectorul A
Min=NULL;
for(int i=0; i<=D+1; i++)
{
if(A[i]!=NULL)
{
add(Min,A[i]);
///actualizam Minimul
if(Min==NULL || A[i]->data<Min->data)
Min=A[i];
}
}
}
void fibHeapUnion(Node *&Min1,Node*&Min2, Node *&Min, int n1, int n2, int &n)
{
FibonacciHeap(Min,n); ///cream un nou heap H
Min=Min1; ///acum heap-ul nostru contine componentele heapului H1
///concatenam lista nodurilor lui H2 cu cele ale lui H
///folosim 2 pointeri temporari
Node *last,*last2;
last=Min->left;
last2=Min2->left;
Min->left->right=Min2;
Min2->left->right=Min;
Min->left=Min2->left;
last2=last->right;
n=n1+n2;
if(Min1==NULL || (Min2!=NULL && Min2->data<Min1->data))
Min=Min2;
}
void cut(Node*&Min,Node*&x,Node*&y)
{
y->degree--;
if(y->child==x && x->right!=x)
y->child=x->right;
else if(y->child==x && x->right==x)
y->child=NULL;
if(y->child!=NULL) ///daca are altii copii ->trebuie eliminat nodul
///din child list
{
x->right->left=x->left;
x->left->right=x->right;
}
///il formatam ca si o lista cu un singur nod
x->right=x;
x->left=x;
///il adaugam in root list, in stanga minimului
Min->left->right=x;
x->left=Min->left;
x->right=Min;
Min->left=x;
x->parent=NULL;
x->mark=false;
}
void cascading_cut(Node*&Min,Node*&y)
{
Node*z=y->parent;
if(z!=NULL)
{
if(y->mark==false)
{
y->mark=true; ///marcam faptul ca nodul si-a pierdut primul copil
}
else
{
cut(Min,y,z);
cascading_cut(Min,z);
}
}
}
void fibHeapDecreaseKey(Node*&Min, Node*&x, int k)
{
if(k>x->data)
{
throw(MyException("Valoare e mai mare ca valoarea nodului.",3));
}
x->data=k;
Node*y=x->parent;
///verificam daca a fost incalcata regula pentru un heap min-ordered
if(y!=NULL && x->data<y->data)
{
cut(Min,x,y);
cascading_cut(Min,y);
}
///actualizam minimul daca este cazul
if(x->data<Min->data)
Min=x;
}
Node* fibHeapExtractMin(Node*&Min, int &n)
{
Node *kid=NULL,*stunt,*brother=NULL;
stunt=Min;
if(Min!=NULL)
{
///Vom avea nevoie de trei pointeri de tip Node
/// 1.) cel care sa prelucreze copii node - denumit kid
/// 2.) unul care sa retina adresa fratelui nodului, inainte sa modificam legaturile nodului (si care face posibila iteratia prin child list) - denumit brother
/// 3.) unul care sa retina adresa nodului Min, cel care ne va ajuta sa eliminam nodul minim din root list - denumit stunt
if(stunt->child!=NULL)
{
///adaugam fiecare copil a lui stunt in root list
Node *kid=stunt->child;
do
{
brother=kid->right;
stunt->left->right=kid;
kid->left=stunt->left;
stunt->left=kid;
kid->right=stunt;
kid->parent=NULL;
kid=brother;
}
while(brother!=stunt->child);
///scoatem stunt-ul din root list
}
stunt->left->right=stunt->right;
stunt->right->left=stunt->left;
///daca H a fost creat dintr-un singur nod
if(stunt==stunt->right)
{
Min=NULL;
}
else
{
///altfel
Min=stunt->right;
stunt->right=stunt;
stunt->left=stunt;
consolidate(Min,n);
}
n--;
}
return stunt;
}
void fibHeapChild(Node*&Min,Node*&x, int new_node,int &n)
{
n++;
Node *kid=new Node;
kid->data=new_node;
kid->left=kid;
kid->right=kid;
kid->degree=0;
kid->parent=x;
x->degree++;
if(x->child==NULL)
x->child=kid;
else
{
///trebuie inserat in child list
Node*brother=x->child;
brother->left->right=kid;
kid->left=brother->left;
kid->right=brother;
brother->left=kid;
}
}
void fibHeapDelete(Node*&Min,Node*&x,int &n)
{
fibHeapDecreaseKey(Min,x,-100000);
Node*result=fibHeapExtractMin(Min,n);
delete result;
}
///Pentru a implementa aceasta functie, am mai adaugat in componenta nodului o variabila bool denumita searched,
///initializata la inceput cu false. Ea devine true pentru un nod X in momentul in care se apeleaza functia de cautare pentru
///arborele avand Min pointat catre acel nod X. Valoarea redevine false in momentul in care am terminat de verificat
///atat nodul, child list cat si root list. Variabila este utila in momentul in care verificam nodurile unui root list.
///Intrucat avem lista circulara dublu inlantuita, pentru a nu cauta la infinit valoarea in lista aceasta, retinem
/// unde am inceput cautarea folosind "searched".In momentul in care o root list(si toate listele child ale nodurilor din root list)
/// a fost verificata complet, valorile acelor noduri redevin false, facand astfel posibila cautarea si a altor valori in heap.
Node* fibHeapSearchValue(Node*&Min, int value)
{
Node*found=NULL;
Node *x=Min;
x->searched=true; ///marcam faptul ca, pentru nodul Min, a fost apelata functia de cautare;
if(x->data==value)
{
x->searched=false;
found=x;
}
///in cazul in care nu este egal cu minimul - adica found inca nu pointeaza catre un nod
if(found==NULL)
{
if(x->child!=NULL)
{
Node *result=fibHeapSearchValue(x->child,value);
found=result;
}
if(found==NULL && x->right->searched==false)
{
Node *result=fibHeapSearchValue(x->right,value);
found=result;
}
}
x->searched=false;
return found;
}
void fibHeapDecreaseKeyExample()
{
///Am verificat functionalitatea operatiei de delete min luand ca heap
///un exemplu din Introduction to Algorithms - ch.20 p. 491
Node*Min;
int n;
FibonacciHeap(Min,n);
fibHeapInsert(Min,7,n);
fibHeapInsert(Min,18,n);
fibHeapInsert(Min,38,n);
fibHeapChild(Min,Min,24,n);
fibHeapChild(Min,Min,17,n);
fibHeapChild(Min,Min,23,n);
fibHeapChild(Min,Min->child,26,n);
fibHeapChild(Min,Min->child,46,n);
fibHeapChild(Min,Min->child->right,30,n);
fibHeapChild(Min,Min->child->child,35,n);
Min->child->child->mark=true;
cout<<"Initial Heap: \n";
fibHeapDisplay(Min,n);
Node*c=Min->child->child->right;
fibHeapDecreaseKey(Min,c,15);
cout<<"\nDecrease 46 to 15\n";
fibHeapDisplay(Min,n);
cout<<"\nDecrease 35 to 5\n";
c=Min->child->child->child;
fibHeapDecreaseKey(Min,c,5);
fibHeapDisplay(Min,n);
}
void fibHeapExtractMinExample()
{
///Am verificat functionalitatea operatiei de extract min luand ca heap
///un exemplu din Introduction to Algorithms - ch.20 p. 484
Node*Min;
int n;
FibonacciHeap(Min,n);
fibHeapInsert(Min,3,n);
fibHeapInsert(Min,17,n);
fibHeapInsert(Min,24,n);
fibHeapInsert(Min,23,n);
fibHeapInsert(Min,7,n);
fibHeapInsert(Min,21,n);
fibHeapChild(Min,Min,18,n);
fibHeapChild(Min,Min,52,n);
fibHeapChild(Min,Min,38,n);
fibHeapChild(Min,Min->child,39,n);
fibHeapChild(Min,Min->child->left,41,n);
fibHeapChild(Min,Min->right,30,n);
fibHeapChild(Min,Min->right->right,26,n);
fibHeapChild(Min,Min->right->right->child,35,n);
fibHeapChild(Min,Min->right->right,46,n);
Node*result=fibHeapExtractMin(Min,n);
cout<<"Minimul initial a fost "<<result->data<<" . Acum minimul este "<<Min->data<<" si heap-ul: \n";
delete result;
fibHeapDisplay(Min,n);
}
void fibHeapUnionExample()
{
Node*Min,*Min2,*Min3;
int n,n2,n3;
FibonacciHeap(Min,n);
fibHeapInsert(Min,3,n);
fibHeapInsert(Min,17,n);
fibHeapInsert(Min,24,n);
fibHeapInsert(Min,23,n);
fibHeapInsert(Min,7,n);
fibHeapInsert(Min,21,n);
fibHeapChild(Min,Min,18,n);
fibHeapChild(Min,Min,52,n);
fibHeapChild(Min,Min,38,n);
fibHeapChild(Min,Min->child,39,n);
fibHeapChild(Min,Min->child->left,41,n);
fibHeapChild(Min,Min->right,30,n);
fibHeapChild(Min,Min->right->right,26,n);
fibHeapChild(Min,Min->right->right->child,35,n);
fibHeapChild(Min,Min->right->right,46,n);
cout<<"Primul heap este:\n";
fibHeapDisplay(Min,n);
FibonacciHeap(Min2,n2);
fibHeapInsert(Min2,992,n2);
fibHeapInsert(Min2,-17,n2);
fibHeapChild(Min2,Min2,19,n2);
cout<<"Al doilea heap este:\n";
fibHeapDisplay(Min2,n2);
cout<<"\nRezultatul este operatiei merge este:\n";
fibHeapUnion(Min,Min2,Min3,n,n2,n3);
fibHeapDisplay(Min3,n3);
}
///Referinte: T.H. Cormen, C.E. Leiserson, R.L. Rivest, C. Stein, “Fibonacci Heaps”
///in Introduction to Algorithms, 2nd ed., Cambridge, MA: The MIT Press, 2001, ch. 20, pp.476-497
///https://www.geeksforgeeks.org
int main()
{
Node *Min;
int n,N;
int answer,value;
cout<<"Introdu numarul de operatii: \n";
cin>>N;
FibonacciHeap(Min,n);
for(int i=0; i<N; i++)
{
cout<<"Inserare(1), delete(2),find min(3) sau delete min(4)?\n";
try
{
cin>>answer;
switch(answer)
{
case 1:
cin>>value;
fibHeapInsert(Min,value,n);
fibHeapDisplay(Min,n);
break;
case 2:
{
cin>>value;
try
{
Node*node_searched=fibHeapSearchValue(Min,value);
if(node_searched==NULL)
throw(MyException("Nodul introdus nu se afla in Heap",2));
fibHeapDelete(Min,node_searched,n);
fibHeapDisplay(Min,n);
}
catch(MyException&e)
{
throw;
}
break;
}
case 3:
{
cout<<"Minimul este: "<<findMin(Min)<<"\n";
break;
}
case 4:
{
Node*result=fibHeapExtractMin(Min,n);
cout<<"Nodul "<<result->data<<" a fost eliminat\n";
delete result;
fibHeapDisplay(Min,n);
break;
}
default:
throw(MyException("Input gresit",0));
}
}
catch(MyException&e)
{
cout<<e.what()<<"\n";
}
}
try
{
cout<<"Vrei sa vezi si operatia de build?Introdu 1 in acest caz,0 daca nu.\n";
cin>>answer;
switch(answer)
{
case 1:
{
cout<<"Introdu un vector de numere - numar de elemente si valori.\n";
int length,element;
Node *Min1;
cin>>length;
vector <int> v;
for(int i=0; i<length; i++)
{
cin>>element;
v.push_back(element);
}
Min1=fibHeapBuild(v);
fibHeapDisplay(Min1,length);
break;
}
case 0:
cout<<"Cum vrei tu. . . \n";
break;
default:
throw(MyException("Input gresit",2));
}
cout<<"Vrei sa vezi si operatia de merge?Introdu 1 pentru a vedea un exemplu predefinit,2 pentru a construii\
\ 2 heapuri pe care sa le unesti, 3 daca nu vrei oricare din cele 2 optiuni.\n";
cin>>answer;
switch(answer)
{
case 1:
fibHeapUnionExample();
break;
case 2:
{
cout<<"Introdu primul vector de numere - numar de elemente si valori.\n";
int length,element;
Node *Min1;
cin>>length;
vector <int> v;
for(int i=0; i<length; i++)
{
cin>>element;
v.push_back(element);
}
Min1=fibHeapBuild(v);
cout<<"Introdu al doilea vector de numere - numar de elemente si valori.\n";
int length2,element2;
Node *Min2;
cin>>length2;
vector <int> v2;
for(int i=0; i<length2; i++)
{
cin>>element2;
v2.push_back(element2);
}
Min2=fibHeapBuild(v2);
Node*Min3;
int length3;
fibHeapUnion(Min1,Min2,Min3,length,length2,length3);
fibHeapDisplay(Min3,length3);
break;
}
case 3:
cout<<"Cum vrei tu. . . \n";
break;
default:
throw(MyException("Input gresit",2));
}
}
catch(MyException&e)
{
cout<<e.what()<<"\n";
}
return 0;
}
| [
"miramaria27@yahoo.com"
] | miramaria27@yahoo.com |
82c4aac1e107f3054386f224d75393df1941d3e5 | 73aebe462c9201c1c258951788cd66375e76e95a | /spojMNTILE.cpp | 22db35a314bac14ba9e9d5ecc31ac1233467264a | [] | no_license | purak24/Spoj | c184000df64a665616ce74855c10572037c348b5 | e83b307519b5521236560fb3bea5f58676dfc11b | refs/heads/master | 2021-01-20T00:50:57.160521 | 2015-09-21T18:43:34 | 2015-09-21T18:43:34 | 37,717,012 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 300 | cpp | #include<bits/stdc++.h>
using namespace std;int main(){int t,w,h,j,k;cin>>t;while(t--){double a=1;cin>>w>>h;if(h>w)swap(w,h);if(w*h%2!=0)cout<<0;else{for(j=1;j<=ceil(w/2);++j)for(k=1;k<=ceil(h/2);++k)a*=4*pow(cos(M_PI*j/(w+1)),2)+4*pow(cos(M_PI*k/(h+1)),2);cout<<(long long)a;}cout<<endl;}return 0;}
| [
"prkj24@gmail.com"
] | prkj24@gmail.com |
4ab8a50cd2bce3643d1ad46d1a52c06820c4c5c4 | 8832b04803f1657567cefb6708593ecd92a01432 | /FAQ_C++/StringBuilder.cpp | 95fd643c3bb0f3efd583ba244cf1e9881bc3402d | [] | no_license | haspeleo/Algorithms-implementation | f7d41c1c8d83a4b6ef2d75225662af4a7782c0f7 | 78b5b0f7b6ae4f0211ad26051870b9608a99720a | refs/heads/master | 2016-09-10T20:08:36.924676 | 2012-11-03T18:10:50 | 2012-11-03T18:10:50 | 2,006,372 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 498 | cpp | #include <sstream>
#include <string>
#include <iostream>
using namespace std;
class StringBuilder {
public:
template<typename T>
StringBuilder& operator() (const T& t) {
std::ostringstream oss;
oss << t;
String_ += oss.str();
return *this;
}
//string print(StringBuilder s) {
// return (string)s;
// }
private:
std::string String_;
};
int main (int, char **) {
StringBuilder s;
s("Salut, j'ai")(27)("ans");
// cout << (string)s <<endl;
return 0;
} | [
"doghmen@MBP-tao.(none)"
] | doghmen@MBP-tao.(none) |
52246b47e3f9e70158d4d118d09b52719b345c02 | ed91c77afaeb0e075da38153aa89c6ee8382d3fc | /mediasoup-client/deps/webrtc/src/video/video_analyzer.cc | 62ee7b4352996d70c79367a0836776b5c6c33c38 | [
"BSD-3-Clause",
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-google-patent-license-webrtc",
"LicenseRef-scancode-google-patent-license-webm",
"MIT"
] | permissive | whatisor/mediasoup-client-android | 37bf1aeaadc8db642cff449a26545bf15da27539 | dc3d812974991d9b94efbc303aa2deb358928546 | refs/heads/master | 2023-04-26T12:24:18.355241 | 2023-01-02T16:55:19 | 2023-01-02T16:55:19 | 243,833,549 | 0 | 0 | MIT | 2020-02-28T18:56:36 | 2020-02-28T18:56:36 | null | UTF-8 | C++ | false | false | 38,612 | cc | /*
* Copyright 2018 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include "video/video_analyzer.h"
#include <algorithm>
#include <utility>
#include "absl/algorithm/container.h"
#include "absl/flags/flag.h"
#include "absl/flags/parse.h"
#include "common_video/libyuv/include/webrtc_libyuv.h"
#include "modules/rtp_rtcp/source/create_video_rtp_depacketizer.h"
#include "modules/rtp_rtcp/source/rtp_packet.h"
#include "modules/rtp_rtcp/source/rtp_util.h"
#include "rtc_base/cpu_time.h"
#include "rtc_base/format_macros.h"
#include "rtc_base/memory_usage.h"
#include "rtc_base/task_queue_for_test.h"
#include "rtc_base/task_utils/repeating_task.h"
#include "rtc_base/time_utils.h"
#include "system_wrappers/include/cpu_info.h"
#include "test/call_test.h"
#include "test/testsupport/file_utils.h"
#include "test/testsupport/frame_writer.h"
#include "test/testsupport/perf_test.h"
#include "test/testsupport/test_artifacts.h"
ABSL_FLAG(bool,
save_worst_frame,
false,
"Enable saving a frame with the lowest PSNR to a jpeg file in the "
"test_artifacts_dir");
namespace webrtc {
namespace {
constexpr TimeDelta kSendStatsPollingInterval = TimeDelta::Seconds(1);
constexpr size_t kMaxComparisons = 10;
// How often is keep alive message printed.
constexpr int kKeepAliveIntervalSeconds = 30;
// Interval between checking that the test is over.
constexpr int kProbingIntervalMs = 500;
constexpr int kKeepAliveIntervalIterations =
kKeepAliveIntervalSeconds * 1000 / kProbingIntervalMs;
bool IsFlexfec(int payload_type) {
return payload_type == test::CallTest::kFlexfecPayloadType;
}
} // namespace
VideoAnalyzer::VideoAnalyzer(test::LayerFilteringTransport* transport,
const std::string& test_label,
double avg_psnr_threshold,
double avg_ssim_threshold,
int duration_frames,
TimeDelta test_duration,
FILE* graph_data_output_file,
const std::string& graph_title,
uint32_t ssrc_to_analyze,
uint32_t rtx_ssrc_to_analyze,
size_t selected_stream,
int selected_sl,
int selected_tl,
bool is_quick_test_enabled,
Clock* clock,
std::string rtp_dump_name,
TaskQueueBase* task_queue)
: transport_(transport),
receiver_(nullptr),
call_(nullptr),
send_stream_(nullptr),
receive_stream_(nullptr),
audio_receive_stream_(nullptr),
captured_frame_forwarder_(this, clock, duration_frames, test_duration),
test_label_(test_label),
graph_data_output_file_(graph_data_output_file),
graph_title_(graph_title),
ssrc_to_analyze_(ssrc_to_analyze),
rtx_ssrc_to_analyze_(rtx_ssrc_to_analyze),
selected_stream_(selected_stream),
selected_sl_(selected_sl),
selected_tl_(selected_tl),
mean_decode_time_ms_(0.0),
freeze_count_(0),
total_freezes_duration_ms_(0),
total_frames_duration_ms_(0),
sum_squared_frame_durations_(0),
decode_frame_rate_(0),
render_frame_rate_(0),
last_fec_bytes_(0),
frames_to_process_(duration_frames),
test_end_(clock->CurrentTime() + test_duration),
frames_recorded_(0),
frames_processed_(0),
captured_frames_(0),
dropped_frames_(0),
dropped_frames_before_first_encode_(0),
dropped_frames_before_rendering_(0),
last_render_time_(0),
last_render_delta_ms_(0),
last_unfreeze_time_ms_(0),
rtp_timestamp_delta_(0),
cpu_time_(0),
wallclock_time_(0),
avg_psnr_threshold_(avg_psnr_threshold),
avg_ssim_threshold_(avg_ssim_threshold),
is_quick_test_enabled_(is_quick_test_enabled),
quit_(false),
done_(true, false),
vp8_depacketizer_(CreateVideoRtpDepacketizer(kVideoCodecVP8)),
vp9_depacketizer_(CreateVideoRtpDepacketizer(kVideoCodecVP9)),
clock_(clock),
start_ms_(clock->TimeInMilliseconds()),
task_queue_(task_queue) {
// Create thread pool for CPU-expensive PSNR/SSIM calculations.
// Try to use about as many threads as cores, but leave kMinCoresLeft alone,
// so that we don't accidentally starve "real" worker threads (codec etc).
// Also, don't allocate more than kMaxComparisonThreads, even if there are
// spare cores.
uint32_t num_cores = CpuInfo::DetectNumberOfCores();
RTC_DCHECK_GE(num_cores, 1);
static const uint32_t kMinCoresLeft = 4;
static const uint32_t kMaxComparisonThreads = 8;
if (num_cores <= kMinCoresLeft) {
num_cores = 1;
} else {
num_cores -= kMinCoresLeft;
num_cores = std::min(num_cores, kMaxComparisonThreads);
}
for (uint32_t i = 0; i < num_cores; ++i) {
comparison_thread_pool_.push_back(rtc::PlatformThread::SpawnJoinable(
[this] {
while (CompareFrames()) {
}
},
"Analyzer"));
}
if (!rtp_dump_name.empty()) {
fprintf(stdout, "Writing rtp dump to %s\n", rtp_dump_name.c_str());
rtp_file_writer_.reset(test::RtpFileWriter::Create(
test::RtpFileWriter::kRtpDump, rtp_dump_name));
}
}
VideoAnalyzer::~VideoAnalyzer() {
{
MutexLock lock(&comparison_lock_);
quit_ = true;
}
// Joins all threads.
comparison_thread_pool_.clear();
}
void VideoAnalyzer::SetReceiver(PacketReceiver* receiver) {
receiver_ = receiver;
}
void VideoAnalyzer::SetSource(
rtc::VideoSourceInterface<VideoFrame>* video_source,
bool respect_sink_wants) {
if (respect_sink_wants)
captured_frame_forwarder_.SetSource(video_source);
rtc::VideoSinkWants wants;
video_source->AddOrUpdateSink(InputInterface(), wants);
}
void VideoAnalyzer::SetCall(Call* call) {
MutexLock lock(&lock_);
RTC_DCHECK(!call_);
call_ = call;
}
void VideoAnalyzer::SetSendStream(VideoSendStream* stream) {
MutexLock lock(&lock_);
RTC_DCHECK(!send_stream_);
send_stream_ = stream;
}
void VideoAnalyzer::SetReceiveStream(VideoReceiveStream* stream) {
MutexLock lock(&lock_);
RTC_DCHECK(!receive_stream_);
receive_stream_ = stream;
}
void VideoAnalyzer::SetAudioReceiveStream(AudioReceiveStream* recv_stream) {
MutexLock lock(&lock_);
RTC_CHECK(!audio_receive_stream_);
audio_receive_stream_ = recv_stream;
}
rtc::VideoSinkInterface<VideoFrame>* VideoAnalyzer::InputInterface() {
return &captured_frame_forwarder_;
}
rtc::VideoSourceInterface<VideoFrame>* VideoAnalyzer::OutputInterface() {
return &captured_frame_forwarder_;
}
PacketReceiver::DeliveryStatus VideoAnalyzer::DeliverPacket(
MediaType media_type,
rtc::CopyOnWriteBuffer packet,
int64_t packet_time_us) {
// Ignore timestamps of RTCP packets. They're not synchronized with
// RTP packet timestamps and so they would confuse wrap_handler_.
if (IsRtcpPacket(packet)) {
return receiver_->DeliverPacket(media_type, std::move(packet),
packet_time_us);
}
if (rtp_file_writer_) {
test::RtpPacket p;
memcpy(p.data, packet.cdata(), packet.size());
p.length = packet.size();
p.original_length = packet.size();
p.time_ms = clock_->TimeInMilliseconds() - start_ms_;
rtp_file_writer_->WritePacket(&p);
}
RtpPacket rtp_packet;
rtp_packet.Parse(packet);
if (!IsFlexfec(rtp_packet.PayloadType()) &&
(rtp_packet.Ssrc() == ssrc_to_analyze_ ||
rtp_packet.Ssrc() == rtx_ssrc_to_analyze_)) {
// Ignore FlexFEC timestamps, to avoid collisions with media timestamps.
// (FlexFEC and media are sent on different SSRCs, which have different
// timestamps spaces.)
// Also ignore packets from wrong SSRC, but include retransmits.
MutexLock lock(&lock_);
int64_t timestamp =
wrap_handler_.Unwrap(rtp_packet.Timestamp() - rtp_timestamp_delta_);
recv_times_[timestamp] = clock_->CurrentNtpInMilliseconds();
}
return receiver_->DeliverPacket(media_type, std::move(packet),
packet_time_us);
}
void VideoAnalyzer::PreEncodeOnFrame(const VideoFrame& video_frame) {
MutexLock lock(&lock_);
if (!first_encoded_timestamp_) {
while (frames_.front().timestamp() != video_frame.timestamp()) {
++dropped_frames_before_first_encode_;
frames_.pop_front();
RTC_CHECK(!frames_.empty());
}
first_encoded_timestamp_ = video_frame.timestamp();
}
}
void VideoAnalyzer::PostEncodeOnFrame(size_t stream_id, uint32_t timestamp) {
MutexLock lock(&lock_);
if (!first_sent_timestamp_ && stream_id == selected_stream_) {
first_sent_timestamp_ = timestamp;
}
}
bool VideoAnalyzer::SendRtp(const uint8_t* packet,
size_t length,
const PacketOptions& options) {
RtpPacket rtp_packet;
rtp_packet.Parse(packet, length);
int64_t current_time = clock_->CurrentNtpInMilliseconds();
bool result = transport_->SendRtp(packet, length, options);
{
MutexLock lock(&lock_);
if (rtp_timestamp_delta_ == 0 && rtp_packet.Ssrc() == ssrc_to_analyze_) {
RTC_CHECK(static_cast<bool>(first_sent_timestamp_));
rtp_timestamp_delta_ = rtp_packet.Timestamp() - *first_sent_timestamp_;
}
if (!IsFlexfec(rtp_packet.PayloadType()) &&
rtp_packet.Ssrc() == ssrc_to_analyze_) {
// Ignore FlexFEC timestamps, to avoid collisions with media timestamps.
// (FlexFEC and media are sent on different SSRCs, which have different
// timestamps spaces.)
// Also ignore packets from wrong SSRC and retransmits.
int64_t timestamp =
wrap_handler_.Unwrap(rtp_packet.Timestamp() - rtp_timestamp_delta_);
send_times_[timestamp] = current_time;
if (IsInSelectedSpatialAndTemporalLayer(rtp_packet)) {
encoded_frame_sizes_[timestamp] += rtp_packet.payload_size();
}
}
}
return result;
}
bool VideoAnalyzer::SendRtcp(const uint8_t* packet, size_t length) {
return transport_->SendRtcp(packet, length);
}
void VideoAnalyzer::OnFrame(const VideoFrame& video_frame) {
int64_t render_time_ms = clock_->CurrentNtpInMilliseconds();
MutexLock lock(&lock_);
StartExcludingCpuThreadTime();
int64_t send_timestamp =
wrap_handler_.Unwrap(video_frame.timestamp() - rtp_timestamp_delta_);
while (wrap_handler_.Unwrap(frames_.front().timestamp()) < send_timestamp) {
if (!last_rendered_frame_) {
// No previous frame rendered, this one was dropped after sending but
// before rendering.
++dropped_frames_before_rendering_;
} else {
AddFrameComparison(frames_.front(), *last_rendered_frame_, true,
render_time_ms);
}
frames_.pop_front();
RTC_DCHECK(!frames_.empty());
}
VideoFrame reference_frame = frames_.front();
frames_.pop_front();
int64_t reference_timestamp =
wrap_handler_.Unwrap(reference_frame.timestamp());
if (send_timestamp == reference_timestamp - 1) {
// TODO(ivica): Make this work for > 2 streams.
// Look at RTPSender::BuildRTPHeader.
++send_timestamp;
}
ASSERT_EQ(reference_timestamp, send_timestamp);
AddFrameComparison(reference_frame, video_frame, false, render_time_ms);
last_rendered_frame_ = video_frame;
StopExcludingCpuThreadTime();
}
void VideoAnalyzer::Wait() {
// Frame comparisons can be very expensive. Wait for test to be done, but
// at time-out check if frames_processed is going up. If so, give it more
// time, otherwise fail. Hopefully this will reduce test flakiness.
RepeatingTaskHandle stats_polling_task = RepeatingTaskHandle::DelayedStart(
task_queue_, kSendStatsPollingInterval, [this] {
PollStats();
return kSendStatsPollingInterval;
});
int last_frames_processed = -1;
int last_frames_captured = -1;
int iteration = 0;
while (!done_.Wait(kProbingIntervalMs)) {
int frames_processed;
int frames_captured;
{
MutexLock lock(&comparison_lock_);
frames_processed = frames_processed_;
frames_captured = captured_frames_;
}
// Print some output so test infrastructure won't think we've crashed.
const char* kKeepAliveMessages[3] = {
"Uh, I'm-I'm not quite dead, sir.",
"Uh, I-I think uh, I could pull through, sir.",
"Actually, I think I'm all right to come with you--"};
if (++iteration % kKeepAliveIntervalIterations == 0) {
printf("- %s\n", kKeepAliveMessages[iteration % 3]);
}
if (last_frames_processed == -1) {
last_frames_processed = frames_processed;
last_frames_captured = frames_captured;
continue;
}
if (frames_processed == last_frames_processed &&
last_frames_captured == frames_captured &&
clock_->CurrentTime() > test_end_) {
done_.Set();
break;
}
last_frames_processed = frames_processed;
last_frames_captured = frames_captured;
}
if (iteration > 0)
printf("- Farewell, sweet Concorde!\n");
SendTask(RTC_FROM_HERE, task_queue_, [&] { stats_polling_task.Stop(); });
PrintResults();
if (graph_data_output_file_)
PrintSamplesToFile();
}
void VideoAnalyzer::StartMeasuringCpuProcessTime() {
MutexLock lock(&cpu_measurement_lock_);
cpu_time_ -= rtc::GetProcessCpuTimeNanos();
wallclock_time_ -= rtc::SystemTimeNanos();
}
void VideoAnalyzer::StopMeasuringCpuProcessTime() {
MutexLock lock(&cpu_measurement_lock_);
cpu_time_ += rtc::GetProcessCpuTimeNanos();
wallclock_time_ += rtc::SystemTimeNanos();
}
void VideoAnalyzer::StartExcludingCpuThreadTime() {
MutexLock lock(&cpu_measurement_lock_);
cpu_time_ += rtc::GetThreadCpuTimeNanos();
}
void VideoAnalyzer::StopExcludingCpuThreadTime() {
MutexLock lock(&cpu_measurement_lock_);
cpu_time_ -= rtc::GetThreadCpuTimeNanos();
}
double VideoAnalyzer::GetCpuUsagePercent() {
MutexLock lock(&cpu_measurement_lock_);
return static_cast<double>(cpu_time_) / wallclock_time_ * 100.0;
}
bool VideoAnalyzer::IsInSelectedSpatialAndTemporalLayer(
const RtpPacket& rtp_packet) {
if (rtp_packet.PayloadType() == test::CallTest::kPayloadTypeVP8) {
auto parsed_payload = vp8_depacketizer_->Parse(rtp_packet.PayloadBuffer());
RTC_DCHECK(parsed_payload);
const auto& vp8_header = absl::get<RTPVideoHeaderVP8>(
parsed_payload->video_header.video_type_header);
int temporal_idx = vp8_header.temporalIdx;
return selected_tl_ < 0 || temporal_idx == kNoTemporalIdx ||
temporal_idx <= selected_tl_;
}
if (rtp_packet.PayloadType() == test::CallTest::kPayloadTypeVP9) {
auto parsed_payload = vp9_depacketizer_->Parse(rtp_packet.PayloadBuffer());
RTC_DCHECK(parsed_payload);
const auto& vp9_header = absl::get<RTPVideoHeaderVP9>(
parsed_payload->video_header.video_type_header);
int temporal_idx = vp9_header.temporal_idx;
int spatial_idx = vp9_header.spatial_idx;
return (selected_tl_ < 0 || temporal_idx == kNoTemporalIdx ||
temporal_idx <= selected_tl_) &&
(selected_sl_ < 0 || spatial_idx == kNoSpatialIdx ||
spatial_idx <= selected_sl_);
}
return true;
}
void VideoAnalyzer::PollStats() {
// Do not grab `comparison_lock_`, before `GetStats()` completes.
// Otherwise a deadlock may occur:
// 1) `comparison_lock_` is acquired after `lock_`
// 2) `lock_` is acquired after internal pacer lock in SendRtp()
// 3) internal pacer lock is acquired by GetStats().
Call::Stats call_stats = call_->GetStats();
MutexLock lock(&comparison_lock_);
send_bandwidth_bps_.AddSample(call_stats.send_bandwidth_bps);
VideoSendStream::Stats send_stats = send_stream_->GetStats();
// It's not certain that we yet have estimates for any of these stats.
// Check that they are positive before mixing them in.
if (send_stats.encode_frame_rate > 0)
encode_frame_rate_.AddSample(send_stats.encode_frame_rate);
if (send_stats.avg_encode_time_ms > 0)
encode_time_ms_.AddSample(send_stats.avg_encode_time_ms);
if (send_stats.encode_usage_percent > 0)
encode_usage_percent_.AddSample(send_stats.encode_usage_percent);
if (send_stats.media_bitrate_bps > 0)
media_bitrate_bps_.AddSample(send_stats.media_bitrate_bps);
size_t fec_bytes = 0;
for (const auto& kv : send_stats.substreams) {
fec_bytes += kv.second.rtp_stats.fec.payload_bytes +
kv.second.rtp_stats.fec.padding_bytes;
}
fec_bitrate_bps_.AddSample((fec_bytes - last_fec_bytes_) * 8);
last_fec_bytes_ = fec_bytes;
if (receive_stream_ != nullptr) {
VideoReceiveStream::Stats receive_stats = receive_stream_->GetStats();
// `total_decode_time_ms` gives a good estimate of the mean decode time,
// `decode_ms` is used to keep track of the standard deviation.
if (receive_stats.frames_decoded > 0)
mean_decode_time_ms_ =
static_cast<double>(receive_stats.total_decode_time_ms) /
receive_stats.frames_decoded;
if (receive_stats.decode_ms > 0)
decode_time_ms_.AddSample(receive_stats.decode_ms);
if (receive_stats.max_decode_ms > 0)
decode_time_max_ms_.AddSample(receive_stats.max_decode_ms);
if (receive_stats.width > 0 && receive_stats.height > 0) {
pixels_.AddSample(receive_stats.width * receive_stats.height);
}
// `frames_decoded` and `frames_rendered` are used because they are more
// accurate than `decode_frame_rate` and `render_frame_rate`.
// The latter two are calculated on a momentary basis.
const double total_frames_duration_sec_double =
static_cast<double>(receive_stats.total_frames_duration_ms) / 1000.0;
if (total_frames_duration_sec_double > 0) {
decode_frame_rate_ = static_cast<double>(receive_stats.frames_decoded) /
total_frames_duration_sec_double;
render_frame_rate_ = static_cast<double>(receive_stats.frames_rendered) /
total_frames_duration_sec_double;
}
// Freeze metrics.
freeze_count_ = receive_stats.freeze_count;
total_freezes_duration_ms_ = receive_stats.total_freezes_duration_ms;
total_frames_duration_ms_ = receive_stats.total_frames_duration_ms;
sum_squared_frame_durations_ = receive_stats.sum_squared_frame_durations;
}
if (audio_receive_stream_ != nullptr) {
AudioReceiveStream::Stats receive_stats =
audio_receive_stream_->GetStats(/*get_and_clear_legacy_stats=*/true);
audio_expand_rate_.AddSample(receive_stats.expand_rate);
audio_accelerate_rate_.AddSample(receive_stats.accelerate_rate);
audio_jitter_buffer_ms_.AddSample(receive_stats.jitter_buffer_ms);
}
memory_usage_.AddSample(rtc::GetProcessResidentSizeBytes());
}
bool VideoAnalyzer::CompareFrames() {
if (AllFramesRecorded())
return false;
FrameComparison comparison;
if (!PopComparison(&comparison)) {
// Wait until new comparison task is available, or test is done.
// If done, wake up remaining threads waiting.
comparison_available_event_.Wait(1000);
if (AllFramesRecorded()) {
comparison_available_event_.Set();
return false;
}
return true; // Try again.
}
StartExcludingCpuThreadTime();
PerformFrameComparison(comparison);
StopExcludingCpuThreadTime();
if (FrameProcessed()) {
done_.Set();
comparison_available_event_.Set();
return false;
}
return true;
}
bool VideoAnalyzer::PopComparison(VideoAnalyzer::FrameComparison* comparison) {
MutexLock lock(&comparison_lock_);
// If AllFramesRecorded() is true, it means we have already popped
// frames_to_process_ frames from comparisons_, so there is no more work
// for this thread to be done. frames_processed_ might still be lower if
// all comparisons are not done, but those frames are currently being
// worked on by other threads.
if (comparisons_.empty() || AllFramesRecordedLocked())
return false;
*comparison = comparisons_.front();
comparisons_.pop_front();
FrameRecorded();
return true;
}
void VideoAnalyzer::FrameRecorded() {
++frames_recorded_;
}
bool VideoAnalyzer::AllFramesRecorded() {
MutexLock lock(&comparison_lock_);
return AllFramesRecordedLocked();
}
bool VideoAnalyzer::AllFramesRecordedLocked() {
RTC_DCHECK(frames_recorded_ <= frames_to_process_);
return frames_recorded_ == frames_to_process_ ||
(clock_->CurrentTime() > test_end_ && comparisons_.empty()) || quit_;
}
bool VideoAnalyzer::FrameProcessed() {
MutexLock lock(&comparison_lock_);
++frames_processed_;
RTC_DCHECK_LE(frames_processed_, frames_to_process_);
return frames_processed_ == frames_to_process_ ||
(clock_->CurrentTime() > test_end_ && comparisons_.empty());
}
void VideoAnalyzer::PrintResults() {
using ::webrtc::test::ImproveDirection;
StopMeasuringCpuProcessTime();
int dropped_frames_diff;
{
MutexLock lock(&lock_);
dropped_frames_diff = dropped_frames_before_first_encode_ +
dropped_frames_before_rendering_ + frames_.size();
}
MutexLock lock(&comparison_lock_);
PrintResult("psnr", psnr_, "dB", ImproveDirection::kBiggerIsBetter);
PrintResult("ssim", ssim_, "unitless", ImproveDirection::kBiggerIsBetter);
PrintResult("sender_time", sender_time_, "ms",
ImproveDirection::kSmallerIsBetter);
PrintResult("receiver_time", receiver_time_, "ms",
ImproveDirection::kSmallerIsBetter);
PrintResult("network_time", network_time_, "ms",
ImproveDirection::kSmallerIsBetter);
PrintResult("total_delay_incl_network", end_to_end_, "ms",
ImproveDirection::kSmallerIsBetter);
PrintResult("time_between_rendered_frames", rendered_delta_, "ms",
ImproveDirection::kSmallerIsBetter);
PrintResult("encode_frame_rate", encode_frame_rate_, "fps",
ImproveDirection::kBiggerIsBetter);
PrintResult("encode_time", encode_time_ms_, "ms",
ImproveDirection::kSmallerIsBetter);
PrintResult("media_bitrate", media_bitrate_bps_, "bps",
ImproveDirection::kNone);
PrintResult("fec_bitrate", fec_bitrate_bps_, "bps", ImproveDirection::kNone);
PrintResult("send_bandwidth", send_bandwidth_bps_, "bps",
ImproveDirection::kNone);
PrintResult("pixels_per_frame", pixels_, "count",
ImproveDirection::kBiggerIsBetter);
test::PrintResult("decode_frame_rate", "", test_label_.c_str(),
decode_frame_rate_, "fps", false,
ImproveDirection::kBiggerIsBetter);
test::PrintResult("render_frame_rate", "", test_label_.c_str(),
render_frame_rate_, "fps", false,
ImproveDirection::kBiggerIsBetter);
// Record the time from the last freeze until the last rendered frame to
// ensure we cover the full timespan of the session. Otherwise the metric
// would penalize an early freeze followed by no freezes until the end.
time_between_freezes_.AddSample(last_render_time_ - last_unfreeze_time_ms_);
// Freeze metrics.
PrintResult("time_between_freezes", time_between_freezes_, "ms",
ImproveDirection::kBiggerIsBetter);
const double freeze_count_double = static_cast<double>(freeze_count_);
const double total_freezes_duration_ms_double =
static_cast<double>(total_freezes_duration_ms_);
const double total_frames_duration_ms_double =
static_cast<double>(total_frames_duration_ms_);
if (total_frames_duration_ms_double > 0) {
test::PrintResult(
"freeze_duration_ratio", "", test_label_.c_str(),
total_freezes_duration_ms_double / total_frames_duration_ms_double,
"unitless", false, ImproveDirection::kSmallerIsBetter);
RTC_DCHECK_LE(total_freezes_duration_ms_double,
total_frames_duration_ms_double);
constexpr double ms_per_minute = 60 * 1000;
const double total_frames_duration_min =
total_frames_duration_ms_double / ms_per_minute;
if (total_frames_duration_min > 0) {
test::PrintResult("freeze_count_per_minute", "", test_label_.c_str(),
freeze_count_double / total_frames_duration_min,
"unitless", false, ImproveDirection::kSmallerIsBetter);
}
}
test::PrintResult("freeze_duration_average", "", test_label_.c_str(),
freeze_count_double > 0
? total_freezes_duration_ms_double / freeze_count_double
: 0,
"ms", false, ImproveDirection::kSmallerIsBetter);
if (1000 * sum_squared_frame_durations_ > 0) {
test::PrintResult(
"harmonic_frame_rate", "", test_label_.c_str(),
total_frames_duration_ms_double / (1000 * sum_squared_frame_durations_),
"fps", false, ImproveDirection::kBiggerIsBetter);
}
if (worst_frame_) {
test::PrintResult("min_psnr", "", test_label_.c_str(), worst_frame_->psnr,
"dB", false, ImproveDirection::kBiggerIsBetter);
}
if (receive_stream_ != nullptr) {
PrintResultWithExternalMean("decode_time", mean_decode_time_ms_,
decode_time_ms_, "ms",
ImproveDirection::kSmallerIsBetter);
}
dropped_frames_ += dropped_frames_diff;
test::PrintResult("dropped_frames", "", test_label_.c_str(), dropped_frames_,
"count", false, ImproveDirection::kSmallerIsBetter);
test::PrintResult("cpu_usage", "", test_label_.c_str(), GetCpuUsagePercent(),
"%", false, ImproveDirection::kSmallerIsBetter);
#if defined(WEBRTC_WIN)
// On Linux and Mac in Resident Set some unused pages may be counted.
// Therefore this metric will depend on order in which tests are run and
// will be flaky.
PrintResult("memory_usage", memory_usage_, "sizeInBytes",
ImproveDirection::kSmallerIsBetter);
#endif
// Saving only the worst frame for manual analysis. Intention here is to
// only detect video corruptions and not to track picture quality. Thus,
// jpeg is used here.
if (absl::GetFlag(FLAGS_save_worst_frame) && worst_frame_) {
std::string output_dir;
test::GetTestArtifactsDir(&output_dir);
std::string output_path =
test::JoinFilename(output_dir, test_label_ + ".jpg");
RTC_LOG(LS_INFO) << "Saving worst frame to " << output_path;
test::JpegFrameWriter frame_writer(output_path);
RTC_CHECK(
frame_writer.WriteFrame(worst_frame_->frame, 100 /*best quality*/));
}
if (audio_receive_stream_ != nullptr) {
PrintResult("audio_expand_rate", audio_expand_rate_, "unitless",
ImproveDirection::kSmallerIsBetter);
PrintResult("audio_accelerate_rate", audio_accelerate_rate_, "unitless",
ImproveDirection::kSmallerIsBetter);
PrintResult("audio_jitter_buffer", audio_jitter_buffer_ms_, "ms",
ImproveDirection::kNone);
}
// Disable quality check for quick test, as quality checks may fail
// because too few samples were collected.
if (!is_quick_test_enabled_) {
EXPECT_GT(*psnr_.GetMean(), avg_psnr_threshold_);
EXPECT_GT(*ssim_.GetMean(), avg_ssim_threshold_);
}
}
void VideoAnalyzer::PerformFrameComparison(
const VideoAnalyzer::FrameComparison& comparison) {
// Perform expensive psnr and ssim calculations while not holding lock.
double psnr = -1.0;
double ssim = -1.0;
if (comparison.reference && !comparison.dropped) {
psnr = I420PSNR(&*comparison.reference, &*comparison.render);
ssim = I420SSIM(&*comparison.reference, &*comparison.render);
}
MutexLock lock(&comparison_lock_);
if (psnr >= 0.0 && (!worst_frame_ || worst_frame_->psnr > psnr)) {
worst_frame_.emplace(FrameWithPsnr{psnr, *comparison.render});
}
if (graph_data_output_file_) {
samples_.push_back(Sample(comparison.dropped, comparison.input_time_ms,
comparison.send_time_ms, comparison.recv_time_ms,
comparison.render_time_ms,
comparison.encoded_frame_size, psnr, ssim));
}
if (psnr >= 0.0)
psnr_.AddSample(psnr);
if (ssim >= 0.0)
ssim_.AddSample(ssim);
if (comparison.dropped) {
++dropped_frames_;
return;
}
if (last_unfreeze_time_ms_ == 0)
last_unfreeze_time_ms_ = comparison.render_time_ms;
if (last_render_time_ != 0) {
const int64_t render_delta_ms =
comparison.render_time_ms - last_render_time_;
rendered_delta_.AddSample(render_delta_ms);
if (last_render_delta_ms_ != 0 &&
render_delta_ms - last_render_delta_ms_ > 150) {
time_between_freezes_.AddSample(last_render_time_ -
last_unfreeze_time_ms_);
last_unfreeze_time_ms_ = comparison.render_time_ms;
}
last_render_delta_ms_ = render_delta_ms;
}
last_render_time_ = comparison.render_time_ms;
sender_time_.AddSample(comparison.send_time_ms - comparison.input_time_ms);
if (comparison.recv_time_ms > 0) {
// If recv_time_ms == 0, this frame consisted of a packets which were all
// lost in the transport. Since we were able to render the frame, however,
// the dropped packets were recovered by FlexFEC. The FlexFEC recovery
// happens internally in Call, and we can therefore here not know which
// FEC packets that protected the lost media packets. Consequently, we
// were not able to record a meaningful recv_time_ms. We therefore skip
// this sample.
//
// The reasoning above does not hold for ULPFEC and RTX, as for those
// strategies the timestamp of the received packets is set to the
// timestamp of the protected/retransmitted media packet. I.e., then
// recv_time_ms != 0, even though the media packets were lost.
receiver_time_.AddSample(comparison.render_time_ms -
comparison.recv_time_ms);
network_time_.AddSample(comparison.recv_time_ms - comparison.send_time_ms);
}
end_to_end_.AddSample(comparison.render_time_ms - comparison.input_time_ms);
encoded_frame_size_.AddSample(comparison.encoded_frame_size);
}
void VideoAnalyzer::PrintResult(
const char* result_type,
Statistics stats,
const char* unit,
webrtc::test::ImproveDirection improve_direction) {
test::PrintResultMeanAndError(
result_type, "", test_label_.c_str(), stats.GetMean().value_or(0),
stats.GetStandardDeviation().value_or(0), unit, false, improve_direction);
}
void VideoAnalyzer::PrintResultWithExternalMean(
const char* result_type,
double mean,
Statistics stats,
const char* unit,
webrtc::test::ImproveDirection improve_direction) {
// If the true mean is different than the sample mean, the sample variance is
// too low. The sample variance given a known mean is obtained by adding the
// squared error between the true mean and the sample mean.
double compensated_variance =
stats.Size() > 0
? *stats.GetVariance() + pow(mean - *stats.GetMean(), 2.0)
: 0.0;
test::PrintResultMeanAndError(result_type, "", test_label_.c_str(), mean,
std::sqrt(compensated_variance), unit, false,
improve_direction);
}
void VideoAnalyzer::PrintSamplesToFile() {
FILE* out = graph_data_output_file_;
MutexLock lock(&comparison_lock_);
absl::c_sort(samples_, [](const Sample& A, const Sample& B) -> bool {
return A.input_time_ms < B.input_time_ms;
});
fprintf(out, "%s\n", graph_title_.c_str());
fprintf(out, "%" RTC_PRIuS "\n", samples_.size());
fprintf(out,
"dropped "
"input_time_ms "
"send_time_ms "
"recv_time_ms "
"render_time_ms "
"encoded_frame_size "
"psnr "
"ssim "
"encode_time_ms\n");
for (const Sample& sample : samples_) {
fprintf(out,
"%d %" PRId64 " %" PRId64 " %" PRId64 " %" PRId64 " %" RTC_PRIuS
" %lf %lf\n",
sample.dropped, sample.input_time_ms, sample.send_time_ms,
sample.recv_time_ms, sample.render_time_ms,
sample.encoded_frame_size, sample.psnr, sample.ssim);
}
}
void VideoAnalyzer::AddCapturedFrameForComparison(
const VideoFrame& video_frame) {
bool must_capture = false;
{
MutexLock lock(&comparison_lock_);
must_capture = captured_frames_ < frames_to_process_;
if (must_capture) {
++captured_frames_;
}
}
if (must_capture) {
MutexLock lock(&lock_);
frames_.push_back(video_frame);
}
}
void VideoAnalyzer::AddFrameComparison(const VideoFrame& reference,
const VideoFrame& render,
bool dropped,
int64_t render_time_ms) {
int64_t reference_timestamp = wrap_handler_.Unwrap(reference.timestamp());
int64_t send_time_ms = send_times_[reference_timestamp];
send_times_.erase(reference_timestamp);
int64_t recv_time_ms = recv_times_[reference_timestamp];
recv_times_.erase(reference_timestamp);
// TODO(ivica): Make this work for > 2 streams.
auto it = encoded_frame_sizes_.find(reference_timestamp);
if (it == encoded_frame_sizes_.end())
it = encoded_frame_sizes_.find(reference_timestamp - 1);
size_t encoded_size = it == encoded_frame_sizes_.end() ? 0 : it->second;
if (it != encoded_frame_sizes_.end())
encoded_frame_sizes_.erase(it);
MutexLock lock(&comparison_lock_);
if (comparisons_.size() < kMaxComparisons) {
comparisons_.push_back(FrameComparison(
reference, render, dropped, reference.ntp_time_ms(), send_time_ms,
recv_time_ms, render_time_ms, encoded_size));
} else {
comparisons_.push_back(FrameComparison(dropped, reference.ntp_time_ms(),
send_time_ms, recv_time_ms,
render_time_ms, encoded_size));
}
comparison_available_event_.Set();
}
VideoAnalyzer::FrameComparison::FrameComparison()
: dropped(false),
input_time_ms(0),
send_time_ms(0),
recv_time_ms(0),
render_time_ms(0),
encoded_frame_size(0) {}
VideoAnalyzer::FrameComparison::FrameComparison(const VideoFrame& reference,
const VideoFrame& render,
bool dropped,
int64_t input_time_ms,
int64_t send_time_ms,
int64_t recv_time_ms,
int64_t render_time_ms,
size_t encoded_frame_size)
: reference(reference),
render(render),
dropped(dropped),
input_time_ms(input_time_ms),
send_time_ms(send_time_ms),
recv_time_ms(recv_time_ms),
render_time_ms(render_time_ms),
encoded_frame_size(encoded_frame_size) {}
VideoAnalyzer::FrameComparison::FrameComparison(bool dropped,
int64_t input_time_ms,
int64_t send_time_ms,
int64_t recv_time_ms,
int64_t render_time_ms,
size_t encoded_frame_size)
: dropped(dropped),
input_time_ms(input_time_ms),
send_time_ms(send_time_ms),
recv_time_ms(recv_time_ms),
render_time_ms(render_time_ms),
encoded_frame_size(encoded_frame_size) {}
VideoAnalyzer::Sample::Sample(int dropped,
int64_t input_time_ms,
int64_t send_time_ms,
int64_t recv_time_ms,
int64_t render_time_ms,
size_t encoded_frame_size,
double psnr,
double ssim)
: dropped(dropped),
input_time_ms(input_time_ms),
send_time_ms(send_time_ms),
recv_time_ms(recv_time_ms),
render_time_ms(render_time_ms),
encoded_frame_size(encoded_frame_size),
psnr(psnr),
ssim(ssim) {}
VideoAnalyzer::CapturedFrameForwarder::CapturedFrameForwarder(
VideoAnalyzer* analyzer,
Clock* clock,
int frames_to_capture,
TimeDelta test_duration)
: analyzer_(analyzer),
send_stream_input_(nullptr),
video_source_(nullptr),
clock_(clock),
captured_frames_(0),
frames_to_capture_(frames_to_capture),
test_end_(clock->CurrentTime() + test_duration) {}
void VideoAnalyzer::CapturedFrameForwarder::SetSource(
VideoSourceInterface<VideoFrame>* video_source) {
video_source_ = video_source;
}
void VideoAnalyzer::CapturedFrameForwarder::OnFrame(
const VideoFrame& video_frame) {
VideoFrame copy = video_frame;
// Frames from the capturer does not have a rtp timestamp.
// Create one so it can be used for comparison.
RTC_DCHECK_EQ(0, video_frame.timestamp());
if (video_frame.ntp_time_ms() == 0)
copy.set_ntp_time_ms(clock_->CurrentNtpInMilliseconds());
copy.set_timestamp(copy.ntp_time_ms() * 90);
analyzer_->AddCapturedFrameForComparison(copy);
MutexLock lock(&lock_);
++captured_frames_;
if (send_stream_input_ && clock_->CurrentTime() <= test_end_ &&
captured_frames_ <= frames_to_capture_) {
send_stream_input_->OnFrame(copy);
}
}
void VideoAnalyzer::CapturedFrameForwarder::AddOrUpdateSink(
rtc::VideoSinkInterface<VideoFrame>* sink,
const rtc::VideoSinkWants& wants) {
{
MutexLock lock(&lock_);
RTC_DCHECK(!send_stream_input_ || send_stream_input_ == sink);
send_stream_input_ = sink;
}
if (video_source_) {
video_source_->AddOrUpdateSink(this, wants);
}
}
void VideoAnalyzer::CapturedFrameForwarder::RemoveSink(
rtc::VideoSinkInterface<VideoFrame>* sink) {
MutexLock lock(&lock_);
RTC_DCHECK(sink == send_stream_input_);
send_stream_input_ = nullptr;
}
} // namespace webrtc
| [
"wuhaiyang1213@gmail.com"
] | wuhaiyang1213@gmail.com |
32bcb67627f32374f0951494feaae46d393c87aa | 010279e2ba272d09e9d2c4e903722e5faba2cf7a | /contrib/libs/icu/i18n/units_complexconverter.cpp | edbb6573ff11f4c55c0f859afcff0be703c950cd | [
"LicenseRef-scancode-unicode",
"ICU",
"LicenseRef-scancode-unknown-license-reference",
"NTP",
"NAIST-2003",
"GPL-2.0-or-later",
"LicenseRef-scancode-autoconf-simple-exception",
"GPL-3.0-or-later",
"BSD-3-Clause",
"Autoconf-exception-generic",
"LicenseRef-scancode-public-domain",
"BSD-2-Clause"... | permissive | catboost/catboost | 854c1a1f439a96f1ae6b48e16644be20aa04dba2 | f5042e35b945aded77b23470ead62d7eacefde92 | refs/heads/master | 2023-09-01T12:14:14.174108 | 2023-09-01T10:01:01 | 2023-09-01T10:22:12 | 97,556,265 | 8,012 | 1,425 | Apache-2.0 | 2023-09-11T03:32:32 | 2017-07-18T05:29:04 | Python | UTF-8 | C++ | false | false | 11,712 | cpp | // © 2020 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
#include "unicode/utypes.h"
#if !UCONFIG_NO_FORMATTING
#include <cmath>
#include "cmemory.h"
#include "number_decimalquantity.h"
#include "number_roundingutils.h"
#include "putilimp.h"
#include "uarrsort.h"
#include "uassert.h"
#include "unicode/fmtable.h"
#include "unicode/localpointer.h"
#include "unicode/measunit.h"
#include "unicode/measure.h"
#include "units_complexconverter.h"
#include "units_converter.h"
U_NAMESPACE_BEGIN
namespace units {
ComplexUnitsConverter::ComplexUnitsConverter(const MeasureUnitImpl &targetUnit,
const ConversionRates &ratesInfo, UErrorCode &status)
: units_(targetUnit.extractIndividualUnitsWithIndices(status)) {
if (U_FAILURE(status)) {
return;
}
U_ASSERT(units_.length() != 0);
// Just borrowing a pointer to the instance
MeasureUnitImpl *biggestUnit = &units_[0]->unitImpl;
for (int32_t i = 1; i < units_.length(); i++) {
if (UnitsConverter::compareTwoUnits(units_[i]->unitImpl, *biggestUnit, ratesInfo, status) > 0 &&
U_SUCCESS(status)) {
biggestUnit = &units_[i]->unitImpl;
}
if (U_FAILURE(status)) {
return;
}
}
this->init(*biggestUnit, ratesInfo, status);
}
ComplexUnitsConverter::ComplexUnitsConverter(StringPiece inputUnitIdentifier,
StringPiece outputUnitsIdentifier, UErrorCode &status) {
if (U_FAILURE(status)) {
return;
}
MeasureUnitImpl inputUnit = MeasureUnitImpl::forIdentifier(inputUnitIdentifier, status);
MeasureUnitImpl outputUnits = MeasureUnitImpl::forIdentifier(outputUnitsIdentifier, status);
this->units_ = outputUnits.extractIndividualUnitsWithIndices(status);
U_ASSERT(units_.length() != 0);
this->init(inputUnit, ConversionRates(status), status);
}
ComplexUnitsConverter::ComplexUnitsConverter(const MeasureUnitImpl &inputUnit,
const MeasureUnitImpl &outputUnits,
const ConversionRates &ratesInfo, UErrorCode &status)
: units_(outputUnits.extractIndividualUnitsWithIndices(status)) {
if (U_FAILURE(status)) {
return;
}
U_ASSERT(units_.length() != 0);
this->init(inputUnit, ratesInfo, status);
}
void ComplexUnitsConverter::init(const MeasureUnitImpl &inputUnit,
const ConversionRates &ratesInfo,
UErrorCode &status) {
// Sorts units in descending order. Therefore, we return -1 if
// the left is bigger than right and so on.
auto descendingCompareUnits = [](const void *context, const void *left, const void *right) {
UErrorCode status = U_ZERO_ERROR;
const auto *leftPointer = static_cast<const MeasureUnitImplWithIndex *const *>(left);
const auto *rightPointer = static_cast<const MeasureUnitImplWithIndex *const *>(right);
// Multiply by -1 to sort in descending order
return (-1) * UnitsConverter::compareTwoUnits((**leftPointer).unitImpl, //
(**rightPointer).unitImpl, //
*static_cast<const ConversionRates *>(context), //
status);
};
uprv_sortArray(units_.getAlias(), //
units_.length(), //
sizeof units_[0], /* NOTE: we have already asserted that the units_ is not empty.*/ //
descendingCompareUnits, //
&ratesInfo, //
false, //
&status //
);
// In case the `outputUnits` are `UMEASURE_UNIT_MIXED` such as `foot+inch`. In this case we need more
// converters to convert from the `inputUnit` to the first unit in the `outputUnits`. Then, a
// converter from the first unit in the `outputUnits` to the second unit and so on.
// For Example:
// - inputUnit is `meter`
// - outputUnits is `foot+inch`
// - Therefore, we need to have two converters:
// 1. a converter from `meter` to `foot`
// 2. a converter from `foot` to `inch`
// - Therefore, if the input is `2 meter`:
// 1. convert `meter` to `foot` --> 2 meter to 6.56168 feet
// 2. convert the residual of 6.56168 feet (0.56168) to inches, which will be (6.74016
// inches)
// 3. then, the final result will be (6 feet and 6.74016 inches)
for (int i = 0, n = units_.length(); i < n; i++) {
if (i == 0) { // first element
unitsConverters_.emplaceBackAndCheckErrorCode(status, inputUnit, units_[i]->unitImpl,
ratesInfo, status);
} else {
unitsConverters_.emplaceBackAndCheckErrorCode(status, units_[i - 1]->unitImpl,
units_[i]->unitImpl, ratesInfo, status);
}
if (U_FAILURE(status)) {
return;
}
}
}
UBool ComplexUnitsConverter::greaterThanOrEqual(double quantity, double limit) const {
U_ASSERT(unitsConverters_.length() > 0);
// First converter converts to the biggest quantity.
double newQuantity = unitsConverters_[0]->convert(quantity);
return newQuantity >= limit;
}
MaybeStackVector<Measure> ComplexUnitsConverter::convert(double quantity,
icu::number::impl::RoundingImpl *rounder,
UErrorCode &status) const {
// TODO: return an error for "foot-and-foot"?
MaybeStackVector<Measure> result;
int sign = 1;
if (quantity < 0 && unitsConverters_.length() > 1) {
quantity *= -1;
sign = -1;
}
// For N converters:
// - the first converter converts from the input unit to the largest unit,
// - the following N-2 converters convert to bigger units for which we want integers,
// - the Nth converter (index N-1) converts to the smallest unit, for which
// we keep a double.
MaybeStackArray<int64_t, 5> intValues(unitsConverters_.length() - 1, status);
if (U_FAILURE(status)) {
return result;
}
uprv_memset(intValues.getAlias(), 0, (unitsConverters_.length() - 1) * sizeof(int64_t));
for (int i = 0, n = unitsConverters_.length(); i < n; ++i) {
quantity = (*unitsConverters_[i]).convert(quantity);
if (i < n - 1) {
// If quantity is at the limits of double's precision from an
// integer value, we take that integer value.
int64_t flooredQuantity;
if (uprv_isNaN(quantity)) {
// With clang on Linux: floor does not support NaN, resulting in
// a giant negative number. For now, we produce "0 feet, NaN
// inches". TODO(icu-units#131): revisit desired output.
flooredQuantity = 0;
} else {
flooredQuantity = static_cast<int64_t>(floor(quantity * (1 + DBL_EPSILON)));
}
intValues[i] = flooredQuantity;
// Keep the residual of the quantity.
// For example: `3.6 feet`, keep only `0.6 feet`
double remainder = quantity - flooredQuantity;
if (remainder < 0) {
// Because we nudged flooredQuantity up by eps, remainder may be
// negative: we must treat such a remainder as zero.
quantity = 0;
} else {
quantity = remainder;
}
}
}
applyRounder(intValues, quantity, rounder, status);
// Initialize empty result. We use a MaybeStackArray directly so we can
// assign pointers - for this privilege we have to take care of cleanup.
MaybeStackArray<Measure *, 4> tmpResult(unitsConverters_.length(), status);
if (U_FAILURE(status)) {
return result;
}
// Package values into temporary Measure instances in tmpResult:
for (int i = 0, n = unitsConverters_.length(); i < n; ++i) {
if (i < n - 1) {
Formattable formattableQuantity(intValues[i] * sign);
// Measure takes ownership of the MeasureUnit*
MeasureUnit *type = new MeasureUnit(units_[i]->unitImpl.copy(status).build(status));
tmpResult[units_[i]->index] = new Measure(formattableQuantity, type, status);
} else { // LAST ELEMENT
Formattable formattableQuantity(quantity * sign);
// Measure takes ownership of the MeasureUnit*
MeasureUnit *type = new MeasureUnit(units_[i]->unitImpl.copy(status).build(status));
tmpResult[units_[i]->index] = new Measure(formattableQuantity, type, status);
}
}
// Transfer values into result and return:
for(int32_t i = 0, n = unitsConverters_.length(); i < n; ++i) {
U_ASSERT(tmpResult[i] != nullptr);
result.emplaceBackAndCheckErrorCode(status, *tmpResult[i]);
delete tmpResult[i];
}
return result;
}
void ComplexUnitsConverter::applyRounder(MaybeStackArray<int64_t, 5> &intValues, double &quantity,
icu::number::impl::RoundingImpl *rounder,
UErrorCode &status) const {
if (uprv_isInfinite(quantity) || uprv_isNaN(quantity)) {
// Inf and NaN can't be rounded, and calculating `carry` below is known
// to fail on Gentoo on HPPA and OpenSUSE on riscv64. Nothing to do.
return;
}
if (rounder == nullptr) {
// Nothing to do for the quantity.
return;
}
number::impl::DecimalQuantity decimalQuantity;
decimalQuantity.setToDouble(quantity);
rounder->apply(decimalQuantity, status);
if (U_FAILURE(status)) {
return;
}
quantity = decimalQuantity.toDouble();
int32_t lastIndex = unitsConverters_.length() - 1;
if (lastIndex == 0) {
// Only one element, no need to bubble up the carry
return;
}
// Check if there's a carry, and bubble it back up the resulting intValues.
int64_t carry = static_cast<int64_t>(floor(unitsConverters_[lastIndex]->convertInverse(quantity) * (1 + DBL_EPSILON)));
if (carry <= 0) {
return;
}
quantity -= unitsConverters_[lastIndex]->convert(static_cast<double>(carry));
intValues[lastIndex - 1] += carry;
// We don't use the first converter: that one is for the input unit
for (int32_t j = lastIndex - 1; j > 0; j--) {
carry = static_cast<int64_t>(floor(unitsConverters_[j]->convertInverse(static_cast<double>(intValues[j])) * (1 + DBL_EPSILON)));
if (carry <= 0) {
return;
}
intValues[j] -= static_cast<int64_t>(round(unitsConverters_[j]->convert(static_cast<double>(carry))));
intValues[j - 1] += carry;
}
}
} // namespace units
U_NAMESPACE_END
#endif /* #if !UCONFIG_NO_FORMATTING */
| [
"shadchin@yandex-team.com"
] | shadchin@yandex-team.com |
5cedac17efddd3ed4162cb9c2044f83eacd6c208 | 29a4c1e436bc90deaaf7711e468154597fc379b7 | /modules/elliptic/include/nt2/toolbox/elliptic/function/simd/sse/sse4_2/ellipke.hpp | a37c592e4bbaf2e92732003f2b9c8bb15034c30e | [
"BSL-1.0"
] | permissive | brycelelbach/nt2 | 31bdde2338ebcaa24bb76f542bd0778a620f8e7c | 73d7e8dd390fa4c8d251c6451acdae65def70e0b | refs/heads/master | 2021-01-17T12:41:35.021457 | 2011-04-03T17:37:15 | 2011-04-03T17:37:15 | 1,263,345 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 732 | hpp | //////////////////////////////////////////////////////////////////////////////
/// Copyright 2003 and onward LASMEA UMR 6602 CNRS/U.B.P Clermont-Ferrand
/// Copyright 2009 and onward LRI UMR 8623 CNRS/Univ Paris Sud XI
///
/// Distributed under the Boost Software License, Version 1.0
/// See accompanying file LICENSE.txt or copy at
/// http://www.boost.org/LICENSE_1_0.txt
//////////////////////////////////////////////////////////////////////////////
#ifndef NT2_TOOLBOX_ELLIPTIC_FUNCTION_SIMD_SSE_SSE4_2_ELLIPKE_HPP_INCLUDED
#define NT2_TOOLBOX_ELLIPTIC_FUNCTION_SIMD_SSE_SSE4_2_ELLIPKE_HPP_INCLUDED
#include <nt2/toolbox/elliptic/function/simd/sse/sse4_1/ellipke.hpp>
#endif
| [
"jtlapreste@gmail.com"
] | jtlapreste@gmail.com |
05acfe9f96946e701af53b9887f4a1cca38d7961 | 15b9caf5294e02c271fc8bc7a8ae81d43338013b | /jimmyhxy/字符串最小.cpp | 88be84ec40478cd3daca361f9d884a3713da8456 | [] | no_license | jimmyhxy/master | 5d5e768fdf38771590c5f17da40e7cb8461e24cd | 42180372a5b3f2530d5692a751d1e65c4b345980 | refs/heads/master | 2021-01-10T09:11:37.318772 | 2017-05-07T14:10:43 | 2017-05-07T14:10:43 | 47,455,492 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 402 | cpp | #include<iostream>
#include<algorithm>
#include<string>
using namespace std;
string fj(string s)
{
string a,b;
int len;
len=(int)s.length();
if(len&1) return s;
a=s.substr(0,len/2);
b=s.substr(len/2+1);
a=fj(a);
b=fj(b);
if(a>b) swap(a,b);
return a+b;
}
int main()
{
string n;
cin>>n;
cout<<fj(n);
return 0;
}
| [
"1369523160@qq.com"
] | 1369523160@qq.com |
ee8bb9868e6556c27e3de885b2842d7f4b3b17c4 | 8f4ea7054fe6ac79dd01f6c34eb900814e359c46 | /src/angle.h | 3725493b5016fbe57c226eb77ffe3f12e85595e7 | [] | no_license | speleotica/unitized-cpp | 95eccf925cf8b5cc002c9e7b379acc1ec79ea921 | 3682d2e3d03c8c1191aee2733ca5ca2b27ffc045 | refs/heads/master | 2022-10-13T22:30:04.396358 | 2020-06-14T06:15:48 | 2020-06-14T06:15:48 | 270,135,978 | 0 | 1 | null | 2020-06-07T00:07:38 | 2020-06-06T23:40:01 | C++ | UTF-8 | C++ | false | false | 1,952 | h | #ifndef UNITIZED_ANGLE_H
#define UNITIZED_ANGLE_H
namespace unitized {
class Angle
{
public:
enum Unit {
Degrees = 1,
Gradians = 2,
Radians = 3,
MilsNATO = 4,
PercentGrade = 5
};
Angle(double value, Unit unit);
static Angle degrees(double value);
static Angle gradians(double value);
static Angle radians(double value);
static Angle milsNATO(double value);
static Angle percentGrade(double value);
static double sin(Angle angle);
static double cos(Angle angle);
static double tan(Angle angle);
static Angle asin(double value);
static Angle acos(double value);
static Angle atan(double value);
static Angle atan2(double y, double x);
double convertTo(Unit unit) const;
double toDegrees() const;
double toGradians() const;
double toRadians() const;
double toMilsNATO() const;
double toPercentGrade() const;
Angle as(Unit unit) const;
Angle asDegrees() const;
Angle asGradians() const;
Angle asRadians() const;
Angle asMilsNATO() const;
Angle asPercentGrade() const;
Angle add(Angle addend) const;
Angle sub(Angle subtrahend) const;
Angle mul(double multiplicand) const;
Angle div(double denominator) const;
double divUnitless(Angle denominator) const;
Angle mod(Angle modulus) const;
Angle abs() const;
Angle negate() const;
bool isFinite() const;
bool isInfinite() const;
bool isNaN() const;
bool isNegative() const;
bool isPositive() const;
bool isZero() const;
bool isNonzero() const;
bool equals(Angle other) const;
int compareTo(Angle other) const;
const Unit unit;
private:
const double value;
static double convert(double value, Unit from, Unit to);
static double fromBase(double value, Unit to);
static double toBase(double value, Unit from);
};
} // namespace unitized
#endif // UNITIZED_ANGLE_H
| [
"jedwards@fastmail.com"
] | jedwards@fastmail.com |
4e632a7d937542af8cdddc440ec6670c92d8208a | e6cbc77651095327aa65f7e2849e2e304e11eb1a | /src/G02RunAction.cc | 241ebf66b3c8f37d8d61129d2ff02fd766432e24 | [] | no_license | wdconinc/eic-cad-to-gdml-test-simulation | c7f6c4974886f55fb4d8f316419c0d57e4686cd3 | 1225bf323a3647ca06fe5ae35d4b4d704324b114 | refs/heads/main | 2023-03-30T02:58:06.696676 | 2021-04-06T23:37:01 | 2021-04-06T23:37:01 | 354,589,438 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,923 | cc | //
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
/// \file persistency/gdml/G02/src/G02RunAction.cc
/// \brief Implementation of the G02RunAction class
//
//
//
// Class G02RunAction implementation
//
// ----------------------------------------------------------------------------
#include "G4ios.hh"
#include <iomanip>
#include "globals.hh"
#include "Randomize.hh"
#include "G02RunAction.hh"
#include "G4Run.hh"
#include "G4UImanager.hh"
#include "G4VVisManager.hh"
#include "G4VisAttributes.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G02RunAction::G02RunAction()
: G4UserRunAction()
{ }
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G02RunAction::~G02RunAction()
{ }
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void G02RunAction::BeginOfRunAction(const G4Run* aRun)
{
G4cout << "### Run " << aRun->GetRunID() << " start." << G4endl;
if (IsMaster()) fTimer.Start();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void G02RunAction::EndOfRunAction(const G4Run* aRun)
{
if (IsMaster()) {
fTimer.Stop();
G4cout << "### Run " << aRun->GetRunID() << " ended "
<< "(" << fTimer.GetUserElapsed() << "s)." << G4endl;
}
}
| [
"wdconinc@gmail.com"
] | wdconinc@gmail.com |
5e4806ccc59c85f676a173dd5d07df04632819b4 | e49dcda9c13b3aecc24b4b64e418da801321fab7 | /Pattern/src/playerjump.h | 4f0c39c05ed7e23a346914848217cf68db9c03d9 | [] | no_license | 55pp/labs | 987eb907487df4f505d20e211bf4259868d2e56f | 64529d4ee95e89583978ec2d4530206baf1d3124 | refs/heads/master | 2021-05-08T21:34:42.987091 | 2019-12-19T13:56:45 | 2019-12-19T13:56:45 | 119,648,119 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,134 | h | #ifndef PLAYERJUMP_H
#define PLAYERJUMP_H
#include "ianimation.h"
#include <SFML/Graphics.hpp>
#include <iostream>
#include <time.h>
class PlayerJump : public IAnimation
{
public:
virtual void action(std::shared_ptr<sf::Texture>& texture, sf::Sprite& sprite)
{
sf::Image image_jump;
image_jump.loadFromFile("/home/konstantin/QtProjects/Pattern/src/Resource/"
"Sprites/player/player-jump.png");
texture->loadFromImage(image_jump);
// int width = sprite.getTextureRect().width;
// int height = sprite.getTextureRect().height;
x_pos = sprite.getTextureRect().left;
if (x_pos >= 64) {
x_pos = 64;
// std::cout << "yep" << std::endl;
} else {
x_pos += 32;
// std::cout << "nope" << std::endl;
}
x_pos = (x_pos / 32) * 32;
sf::IntRect new_rect = sf::IntRect(x_pos, 0, 32, 36);
// std::cout << sprite.getTextureRect().left << " " << new_rect.left
// << std::endl;
sprite.setTexture(*texture);
sprite.setTextureRect(new_rect);
}
~PlayerJump() {}
private:
int x_pos = 0;
};
#endif // PLAYERJUMP_H
| [
"kruvpky@mail.ru"
] | kruvpky@mail.ru |
25f7456a8215e0406f19ef5a5aa6ccc657a3aed1 | 93bb87f91e55d55dc2f9bf78b914e6290c3a17be | /src/Disassembler.cpp | 77c995a1aa5afa15e5feeead26d3c14ebfd77543 | [
"MIT"
] | permissive | doe300/VC4C | 5bbde383fb1230af42f72bd20accb84418b8b7fa | 3d89be8692ae20b8f712e9d2bc45b6998dac8259 | refs/heads/master | 2023-06-07T06:25:07.948224 | 2023-05-30T09:42:15 | 2023-05-30T16:11:04 | 106,166,771 | 123 | 38 | MIT | 2023-05-30T16:11:05 | 2017-10-08T10:11:39 | C | UTF-8 | C++ | false | false | 17,425 | cpp | /*
* Author: doe300
*
* See the file "LICENSE" for the full license governing this code.
*/
#include "VC4C.h"
#include "GlobalValues.h"
#include "Locals.h"
#include "asm/ALUInstruction.h"
#include "asm/Instruction.h"
#include "asm/KernelInfo.h"
#include "asm/LoadInstruction.h"
#include "log.h"
#include <fstream>
#include <sstream>
using namespace vc4c;
// Is located in Types.cpp
extern TypeHolder GLOBAL_TYPE_HOLDER;
LCOV_EXCL_START
static std::vector<std::string> createUniformValues(const KernelHeader& kernel)
{
/* the order of implicit/explicit parameters needs to match the order of parameters in
* optimizations::addStartStopSegment:
* - work_dim: number of dimensions
* - local_sizes: local number of work-items in its work-group per dimension
* - local_ids: local id of this work-item within its work-group
* - num_groups (x,y,z): global number of work-groups per dimension
* - group_id (x, y, z): id of this work-group
* - global_offset (x, y, z): global initial offset per dimension
* - address of global data / to load the global data from
* - parameters
* - re-run counter
*/
const KernelUniforms& uniformsUsed = kernel.uniformsUsed;
std::vector<std::string> values;
values.reserve(uniformsUsed.countUniforms() + kernel.getParamCount());
if(uniformsUsed.getWorkDimensionsUsed())
values.emplace_back("work dimensions");
if(uniformsUsed.getLocalSizesUsed())
values.emplace_back("local sizes");
if(uniformsUsed.getLocalIDsUsed())
values.emplace_back("local IDs");
if(uniformsUsed.getNumGroupsXUsed())
values.emplace_back("number of groups X");
if(uniformsUsed.getNumGroupsYUsed())
values.emplace_back("number of groups Y");
if(uniformsUsed.getNumGroupsZUsed())
values.emplace_back("number of groups Z");
if(uniformsUsed.getGroupIDXUsed())
values.emplace_back("group ID X");
if(uniformsUsed.getGroupIDYUsed())
values.emplace_back("group ID Y");
if(uniformsUsed.getGroupIDZUsed())
values.emplace_back("group ID Z");
if(uniformsUsed.getGlobalOffsetXUsed())
values.emplace_back("global offset X");
if(uniformsUsed.getGlobalOffsetYUsed())
values.emplace_back("global offset Y");
if(uniformsUsed.getGlobalOffsetZUsed())
values.emplace_back("global offset Z");
if(uniformsUsed.getGlobalDataAddressUsed())
values.emplace_back("global data address");
for(const auto& param : kernel.parameters)
{
// To correctly annotate multi-UNIFORM parameters (e.g. literal vectors)
for(uint16_t i = 0; i < param.getVectorElements(); ++i)
values.emplace_back(param.typeName + " " + param.name);
}
if(uniformsUsed.getUniformAddressUsed())
values.emplace_back("uniform address");
if(uniformsUsed.getMaxGroupIDXUsed())
values.emplace_back("maximum group ID X");
if(uniformsUsed.getMaxGroupIDYUsed())
values.emplace_back("maximum group ID Y");
if(uniformsUsed.getMaxGroupIDZUsed())
values.emplace_back("maximum group ID Z");
return values;
}
static bool readsUniform(Register reg)
{
return reg.file != RegisterFile::ACCUMULATOR && reg.num == REG_UNIFORM.num;
}
static std::string getUniform(unsigned index, const std::vector<std::string>& values)
{
if(index >= values.size())
{
return "UNIFORM out of bounds!";
}
return values[index];
}
static std::string annotateRegisters(const qpu_asm::Instruction& instr, std::size_t index, const ModuleHeader& module)
{
static FastMap<Register, std::string> currentRegisterMapping;
static const KernelHeader* currentKernel = nullptr;
static unsigned currentUniformsRead = 0;
static std::vector<std::string> currentUniformValues;
if(instr.getSig() == SIGNAL_END_PROGRAM)
{
// all following registers belong to new kernel
currentRegisterMapping.clear();
currentKernel = nullptr;
currentUniformsRead = 0;
currentUniformValues.clear();
return "";
}
if(currentKernel == nullptr)
{
// determine the next kernel with the largest offset smaller than the current index as current kernel
for(const auto& kernel : module.kernels)
{
if(kernel.getOffset() <= index)
{
if(currentKernel && currentKernel->getOffset() > kernel.getOffset())
continue;
currentKernel = &kernel;
}
}
if(currentKernel == nullptr)
return "";
else
// TODO order of kernels extracted/kernel-code association is wrong, see test_vector.cl
currentUniformValues = createUniformValues(*currentKernel);
}
std::set<std::string> annotations;
// the first few UNIFORMs are the work-item and work-group info
if(auto op = instr.as<qpu_asm::ALUInstruction>())
{
if(readsUniform(op->getAddFirstOperand()) || readsUniform(op->getAddSecondOperand()))
annotations.emplace("uniform read: " + getUniform(currentUniformsRead, currentUniformValues));
if(readsUniform(op->getMulFirstOperand()) || readsUniform(op->getMulSecondOperand()))
annotations.emplace("uniform read: " + getUniform(currentUniformsRead, currentUniformValues));
FastMap<Register, std::string>::const_iterator regIt;
if((regIt = currentRegisterMapping.find(op->getAddFirstOperand())) != currentRegisterMapping.end())
annotations.emplace("read " + regIt->second);
if((regIt = currentRegisterMapping.find(op->getAddSecondOperand())) != currentRegisterMapping.end())
annotations.emplace("read " + regIt->second);
if((regIt = currentRegisterMapping.find(op->getMulFirstOperand())) != currentRegisterMapping.end())
annotations.emplace("read " + regIt->second);
if((regIt = currentRegisterMapping.find(op->getMulSecondOperand())) != currentRegisterMapping.end())
annotations.emplace("read " + regIt->second);
// TODO handle both writing the same register
if(op->getAddition() == OP_OR.opAdd && op->getAddFirstOperand() == op->getAddSecondOperand() &&
op->getAddCondition() == COND_ALWAYS)
{
// propagate moves
if(readsUniform(op->getAddFirstOperand()))
currentRegisterMapping[op->getAddOutput()] = getUniform(currentUniformsRead, currentUniformValues);
else if((regIt = currentRegisterMapping.find(op->getAddFirstOperand())) != currentRegisterMapping.end())
currentRegisterMapping[op->getAddOutput()] = regIt->second;
}
else
currentRegisterMapping.erase(op->getAddOutput());
if(op->getMultiplication() == OP_V8MIN.opMul && op->getMulFirstOperand() == op->getMulSecondOperand() &&
op->getMulCondition() == COND_ALWAYS)
{
if(readsUniform(op->getMulFirstOperand()))
currentRegisterMapping[op->getMulOutput()] = getUniform(currentUniformsRead, currentUniformValues);
else if((regIt = currentRegisterMapping.find(op->getMulFirstOperand())) != currentRegisterMapping.end())
currentRegisterMapping[op->getMulOutput()] = regIt->second;
}
else
currentRegisterMapping.erase(op->getMulOutput());
if(readsUniform(op->getAddFirstOperand()) || readsUniform(op->getAddSecondOperand()) ||
readsUniform(op->getMulFirstOperand()) || readsUniform(op->getMulSecondOperand()))
++currentUniformsRead;
}
else if(auto load = instr.as<qpu_asm::LoadInstruction>())
{
switch(load->getType())
{
case OpLoad::LOAD_IMM_32:
if(load->getAddCondition() == COND_ALWAYS)
currentRegisterMapping[load->getAddOutput()] = std::to_string(load->getImmediateInt());
if(load->getMulCondition() == COND_ALWAYS)
currentRegisterMapping[load->getMulOutput()] = std::to_string(load->getImmediateInt());
break;
case OpLoad::LOAD_SIGNED:
if(load->getAddCondition() == COND_ALWAYS)
currentRegisterMapping[load->getAddOutput()] = "(" + std::to_string(load->getImmediateSignedShort0()) +
"," + std::to_string(load->getImmediateSignedShort1()) + ")";
if(load->getMulCondition() == COND_ALWAYS)
currentRegisterMapping[load->getMulOutput()] = "(" + std::to_string(load->getImmediateSignedShort0()) +
"," + std::to_string(load->getImmediateSignedShort1()) + ")";
break;
case OpLoad::LOAD_UNSIGNED:
if(load->getAddCondition() == COND_ALWAYS)
currentRegisterMapping[load->getAddOutput()] = "(" + std::to_string(load->getImmediateShort0()) + "," +
std::to_string(load->getImmediateShort1()) + ")";
if(load->getMulCondition() == COND_ALWAYS)
currentRegisterMapping[load->getMulOutput()] = "(" + std::to_string(load->getImmediateShort0()) + "," +
std::to_string(load->getImmediateShort1()) + ")";
break;
}
}
// TODO some more annotations, e.g. mark parameters, annotate all offsets accordingly (e.g. "%in + 72" or "%in +
// offset"). Do same for global data, determine global referenced by offset?
return annotations.empty() ? "" : (" // " + vc4c::to_string<std::string, std::set<std::string>>(annotations));
}
LCOV_EXCL_STOP
void extractBinary(const CompilationData& binary, ModuleHeader& module, StableList<Global>& globals,
std::vector<qpu_asm::Instruction>& instructions)
{
std::vector<uint64_t> binaryData;
std::vector<uint8_t> rawData;
if(binary.getRawData(rawData))
{
binaryData.resize(rawData.size() / sizeof(uint64_t));
std::memcpy(binaryData.data(), rawData.data(), (rawData.size() / sizeof(uint64_t)) * sizeof(uint64_t));
}
else
{
// read whole stream into 64-bit words
std::stringstream binaryStream;
binary.readInto(binaryStream);
binaryStream.seekg(0, binaryStream.end);
auto numBytes = static_cast<std::size_t>(std::max(binaryStream.tellg(), std::streampos{8192}));
binaryStream.seekg(0);
binaryStream.clear();
binaryData.reserve(numBytes / sizeof(uint64_t));
uint64_t tmp = 0;
while(binaryStream.read(reinterpret_cast<char*>(&tmp), sizeof(tmp)))
binaryData.push_back(tmp);
}
module = ModuleHeader::fromBinaryData(binaryData);
auto initialInstructionOffset = std::numeric_limits<std::size_t>::max();
std::size_t totalInstructions = 0;
CPPLOG_LAZY(logging::Level::DEBUG,
log << "Extracted module with " << module.getKernelCount() << " kernels, " << module.getGlobalDataSize()
<< " words of global data and " << module.getStackFrameSize() << " words of stack-frames" << logging::endl);
for(const auto& kernel : module.kernels)
{
totalInstructions += kernel.getLength();
initialInstructionOffset = std::min(initialInstructionOffset, kernel.getOffset());
CPPLOG_LAZY_BLOCK(logging::Level::DEBUG, {
logging::debug() << "Extracted kernel '" << kernel.name << "' with " << kernel.getParamCount()
<< " parameters and " << kernel.getLength() << " instructions starting at offset "
<< kernel.getOffset() << logging::endl;
for(const auto& param : kernel.parameters)
logging::debug() << "Extracted parameter '" << param.typeName << " " << param.name << logging::endl;
});
}
if(module.getGlobalDataSize() > 0)
{
// since we don't know the number, sizes and types of the original globals, we build a single global containing
// all the data
auto num32BitWords = module.getGlobalDataSize() * 2;
const DataType type =
DataType(GLOBAL_TYPE_HOLDER.createArrayType(TYPE_INT32, static_cast<unsigned>(num32BitWords)));
std::vector<CompoundConstant> elements;
elements.reserve(num32BitWords);
for(std::size_t i = 0; i < module.getGlobalDataSize(); ++i)
{
// words are already in little endian
auto word = binaryData[module.getGlobalDataOffset() + i];
elements.emplace_back(TYPE_INT32, Literal(truncate<unsigned>(word)));
elements.emplace_back(TYPE_INT32, Literal(truncate<unsigned>(word >> 32)));
}
globals.emplace_back("globalData", DataType(GLOBAL_TYPE_HOLDER.createPointerType(type, AddressSpace::GLOBAL)),
CompoundConstant(type, std::move(elements)), false);
CPPLOG_LAZY(logging::Level::DEBUG,
log << "Extracted " << module.getGlobalDataSize() << " words of global data" << logging::endl);
}
// the remainder is kernel-code
// we don't need to associate it to any particular kernel
instructions.reserve(totalInstructions);
for(auto i = initialInstructionOffset; i < totalInstructions + initialInstructionOffset; ++i)
{
uint64_t tmp64 = binaryData[i];
qpu_asm::Instruction instr(tmp64);
if(!instr.isValidInstruction())
throw CompilationError(CompilationStep::GENERAL, "Unrecognized instruction", std::to_string(tmp64));
instructions.emplace_back(instr);
logging::logLazy(logging::Level::DEBUG, [&](std::wostream& os) {
os << instr.toASMString() << annotateRegisters(instr, i, module) << logging::endl;
});
}
CPPLOG_LAZY(logging::Level::DEBUG,
log << "Extracted " << totalInstructions << " machine-code instructions" << logging::endl);
}
static std::size_t generateOutput(std::ostream& stream, ModuleHeader& module, const StableList<Global>& globals,
const std::vector<qpu_asm::Instruction>& instructions, const OutputMode outputMode)
{
std::size_t numBytes = qpu_asm::writeModule(stream, module, outputMode, globals, Byte(0)) * sizeof(uint64_t);
for(const auto& instr : instructions)
{
switch(outputMode)
{
case OutputMode::ASSEMBLER:
stream << instr.toASMString() << std::endl;
numBytes += 0; // doesn't matter here, since the number of bytes is unused for assembler output
break;
case OutputMode::HEX:
stream << instr.toHexString(true) << std::endl;
numBytes += 8; // doesn't matter here, since the number of bytes is unused for hexadecimal output
break;
default:
throw CompilationError(
CompilationStep::GENERAL, "Invalid output mode", std::to_string(static_cast<unsigned>(outputMode)));
}
}
stream.flush();
return numBytes;
}
std::size_t vc4c::disassembleModule(const CompilationData& binaryData, std::ostream& output, OutputMode outputMode)
{
if(binaryData.getType() != SourceType::QPUASM_BIN)
throw CompilationError(CompilationStep::GENERAL, "Invalid input binary for disassembling!");
if(outputMode == OutputMode::BINARY)
{
binaryData.readInto(output);
return 0;
}
ModuleHeader module;
StableList<Global> globals;
std::vector<qpu_asm::Instruction> instructions;
extractBinary(binaryData, module, globals, instructions);
return generateOutput(output, module, globals, instructions, outputMode);
}
std::size_t vc4c::disassembleCodeOnly(
std::istream& binary, std::ostream& output, std::size_t numInstructions, const OutputMode outputMode)
{
std::size_t numBytes = 0;
for(std::size_t i = 0; i < numInstructions; ++i)
{
uint64_t tmp64 = 0;
binary.read(reinterpret_cast<char*>(&tmp64), sizeof(tmp64));
qpu_asm::Instruction instr(tmp64);
if(!instr.isValidInstruction())
throw CompilationError(CompilationStep::GENERAL, "Unrecognized instruction", std::to_string(tmp64));
switch(outputMode)
{
case OutputMode::ASSEMBLER:
output << instr.toASMString() << std::endl;
numBytes += 0; // doesn't matter here, since the number of bytes is unused for assembler output
break;
case OutputMode::HEX:
output << instr.toHexString(true) << std::endl;
numBytes += 8; // doesn't matter here, since the number of bytes is unused for hexadecimal output
break;
default:
throw CompilationError(
CompilationStep::GENERAL, "Invalid output mode", std::to_string(static_cast<unsigned>(outputMode)));
}
}
return numBytes;
}
// command-line version
void disassemble(const std::string& input, const std::string& output, const OutputMode outputMode)
{
CompilationData inputData{};
std::unique_ptr<std::ostream> outputFile;
std::ostream* os = nullptr;
if(input == "-" || input == "/dev/stdin")
inputData = CompilationData{std::cin, SourceType::UNKNOWN, "stdin"};
else
inputData = CompilationData{input};
if(output.empty() || output == "-" || output == "/dev/stdout")
os = &std::cout;
else
{
outputFile = std::make_unique<std::ofstream>(output);
os = outputFile.get();
}
disassembleModule(inputData, *os, outputMode);
}
| [
"stadeldani@web.de"
] | stadeldani@web.de |
e7ace44c9cb914d77ee9562062d260b541ae508b | b8723a2862a0bc34e02a44628a2f9434693ea7d1 | /kattis/pet.cpp | c5bbbde2fb48c3827f70a672953f636079041614 | [] | no_license | mario7lorenzo/cp | ea6d20bbde7ec7217b7bab45f635dda40d2e078b | 253c16599a06cb676a3c94b4892279905486cf5d | refs/heads/master | 2022-05-03T22:27:07.710681 | 2022-04-10T08:37:53 | 2022-04-10T08:37:53 | 158,787,709 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 330 | cpp | #include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, c, d;
int final = 0;
int counter = 1;
int cntr = 1;
while (cin >> a >> b >> c >> d) {
int summary = a + b + c + d;
if (final < summary) {
counter = cntr;
}
final = max(final, summary);
cntr += 1;
}
cout << counter << ' ' << final << endl;
} | [
"mariolorenzo213@gmail.com"
] | mariolorenzo213@gmail.com |
fe42038d96c0aac3720030af81c2b311b089c563 | 7538f30404c0eb74c17d5b982eae689b754e227e | /13.4/Frameworks/SpriteKit.framework/CDStructures.h | 9a2058ab563b5021f143c3ec4f7fa14c1f823d24 | [] | no_license | xybp888/iOS-Header | cdb31acaa22236818917245619fe4f4b90d62d30 | 0c23e5a9242f1d8fd04d376c22e88d2ec74c3374 | refs/heads/master | 2022-11-18T22:35:35.676837 | 2022-10-29T23:47:18 | 2022-10-29T23:47:18 | 204,074,346 | 156 | 63 | null | null | null | null | UTF-8 | C++ | false | false | 34,259 | h | //
// Generated by class-dump 3.5 (64 bit) (Debug version compiled Nov 12 2019 23:20:19).
//
// class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2015 by Steve Nygard.
//
#pragma mark Blocks
typedef void (^CDUnknownBlockType)(void); // return type and parameters are unknown
#pragma mark Named Structures
struct CGPoint {
double x;
double y;
};
struct CGRect {
struct CGPoint origin;
struct CGSize size;
};
struct CGSize {
double width;
double height;
};
struct CGVector {
double dx;
double dy;
};
struct MaxRectTexturePacker;
struct PKCAether;
struct PKPath;
struct SKCAction {
CDUnknownFunctionPointerType *_field1;
unsigned int _field2;
float _field3;
CDUnknownBlockType _field4;
id _field5;
_Bool _field6;
double _field7;
double _field8;
float _field9;
float _field10;
double _field11;
_Bool _field12;
_Bool _field13;
CDUnknownBlockType _field14;
long long _field15;
float _field16;
float _field17;
float _field18;
float _field19;
};
struct SKCAnimate {
CDUnknownFunctionPointerType *_field1;
unsigned int _field2;
float _field3;
CDUnknownBlockType _field4;
id _field5;
_Bool _field6;
double _field7;
double _field8;
float _field9;
float _field10;
double _field11;
_Bool _field12;
_Bool _field13;
CDUnknownBlockType _field14;
long long _field15;
float _field16;
float _field17;
float _field18;
float _field19;
struct vector<SKTexture *, std::__1::allocator<SKTexture *>> _field20;
double _field21;
id _field22;
struct {
float _field1;
float _field2;
} _field23;
_Bool _field24;
_Bool _field25;
_Bool _field26;
};
struct SKCAnimateMesh {
CDUnknownFunctionPointerType *_field1;
unsigned int _field2;
float _field3;
CDUnknownBlockType _field4;
id _field5;
_Bool _field6;
double _field7;
double _field8;
float _field9;
float _field10;
double _field11;
_Bool _field12;
_Bool _field13;
CDUnknownBlockType _field14;
long long _field15;
float _field16;
float _field17;
float _field18;
float _field19;
id _field20;
id _field21;
id _field22;
_Bool _field23;
};
struct SKCColorize {
CDUnknownFunctionPointerType *_field1;
unsigned int _field2;
float _field3;
CDUnknownBlockType _field4;
id _field5;
_Bool _field6;
double _field7;
double _field8;
float _field9;
float _field10;
double _field11;
_Bool _field12;
_Bool _field13;
CDUnknownBlockType _field14;
long long _field15;
float _field16;
float _field17;
float _field18;
float _field19;
CDStruct_818bb265 _field20;
float _field21;
CDStruct_818bb265 _field22;
float _field23;
CDStruct_818bb265 _field24;
float _field25;
_Bool _field26;
};
struct SKCCustomAction {
CDUnknownFunctionPointerType *_field1;
unsigned int _field2;
float _field3;
CDUnknownBlockType _field4;
id _field5;
_Bool _field6;
double _field7;
double _field8;
float _field9;
float _field10;
double _field11;
_Bool _field12;
_Bool _field13;
CDUnknownBlockType _field14;
long long _field15;
float _field16;
float _field17;
float _field18;
float _field19;
CDUnknownBlockType _field20;
};
struct SKCFade {
CDUnknownFunctionPointerType *_field1;
unsigned int _field2;
float _field3;
CDUnknownBlockType _field4;
id _field5;
_Bool _field6;
double _field7;
double _field8;
float _field9;
float _field10;
double _field11;
_Bool _field12;
_Bool _field13;
CDUnknownBlockType _field14;
long long _field15;
float _field16;
float _field17;
float _field18;
float _field19;
float _field20;
float _field21;
float _field22;
_Bool _field23;
};
struct SKCFalloff {
CDUnknownFunctionPointerType *_field1;
unsigned int _field2;
float _field3;
CDUnknownBlockType _field4;
id _field5;
_Bool _field6;
double _field7;
double _field8;
float _field9;
float _field10;
double _field11;
_Bool _field12;
_Bool _field13;
CDUnknownBlockType _field14;
long long _field15;
float _field16;
float _field17;
float _field18;
float _field19;
float _field20;
float _field21;
float _field22;
float _field23;
float _field24;
_Bool _field25;
_Bool _field26;
};
struct SKCFollowPath {
CDUnknownFunctionPointerType *_field1;
unsigned int _field2;
float _field3;
CDUnknownBlockType _field4;
id _field5;
_Bool _field6;
double _field7;
double _field8;
float _field9;
float _field10;
double _field11;
_Bool _field12;
_Bool _field13;
CDUnknownBlockType _field14;
long long _field15;
float _field16;
float _field17;
float _field18;
float _field19;
float _field20;
unsigned int _field21;
struct PKPath *_field22;
struct {
float _field1;
float _field2;
} _field23;
_Bool _field24;
_Bool _field25;
};
struct SKCGroup {
CDUnknownFunctionPointerType *_field1;
unsigned int _field2;
float _field3;
CDUnknownBlockType _field4;
id _field5;
_Bool _field6;
double _field7;
double _field8;
float _field9;
float _field10;
double _field11;
_Bool _field12;
_Bool _field13;
CDUnknownBlockType _field14;
long long _field15;
float _field16;
float _field17;
float _field18;
float _field19;
struct list<SKCAction *, std::__1::allocator<SKCAction *>> _field20;
};
struct SKCHide {
CDUnknownFunctionPointerType *_field1;
unsigned int _field2;
float _field3;
CDUnknownBlockType _field4;
id _field5;
_Bool _field6;
double _field7;
double _field8;
float _field9;
float _field10;
double _field11;
_Bool _field12;
_Bool _field13;
CDUnknownBlockType _field14;
long long _field15;
float _field16;
float _field17;
float _field18;
float _field19;
_Bool _field20;
};
struct SKCKeyframeSequence {
int _field1;
int _field2;
long long _field3;
long long _field4;
float *_field5;
float *_field6;
};
struct SKCMove {
CDUnknownFunctionPointerType *_field1;
unsigned int _field2;
float _field3;
CDUnknownBlockType _field4;
id _field5;
_Bool _field6;
double _field7;
double _field8;
float _field9;
float _field10;
double _field11;
_Bool _field12;
_Bool _field13;
CDUnknownBlockType _field14;
long long _field15;
float _field16;
float _field17;
float _field18;
float _field19;
float _field20;
struct {
float _field1;
float _field2;
} _field21;
struct {
float _field1;
float _field2;
} _field22;
struct {
float _field1;
float _field2;
} _field23;
_Bool _field24;
_Bool _field25;
_Bool _field26;
_Bool _field27;
};
struct SKCPlaySound {
CDUnknownFunctionPointerType *_field1;
unsigned int _field2;
float _field3;
CDUnknownBlockType _field4;
id _field5;
_Bool _field6;
double _field7;
double _field8;
float _field9;
float _field10;
double _field11;
_Bool _field12;
_Bool _field13;
CDUnknownBlockType _field14;
long long _field15;
float _field16;
float _field17;
float _field18;
float _field19;
id _field20;
_Bool _field21;
_Bool _field22;
};
struct SKCReferencedAction {
CDUnknownFunctionPointerType *_field1;
unsigned int _field2;
float _field3;
CDUnknownBlockType _field4;
id _field5;
_Bool _field6;
double _field7;
double _field8;
float _field9;
float _field10;
double _field11;
_Bool _field12;
_Bool _field13;
CDUnknownBlockType _field14;
long long _field15;
float _field16;
float _field17;
float _field18;
float _field19;
struct SKCAction *_field20;
};
struct SKCRepeat {
CDUnknownFunctionPointerType *_field1;
unsigned int _field2;
float _field3;
CDUnknownBlockType _field4;
id _field5;
_Bool _field6;
double _field7;
double _field8;
float _field9;
float _field10;
double _field11;
_Bool _field12;
_Bool _field13;
CDUnknownBlockType _field14;
long long _field15;
float _field16;
float _field17;
float _field18;
float _field19;
struct SKCAction *_field20;
unsigned long long _field21;
unsigned long long _field22;
_Bool _field23;
};
struct SKCResize {
CDUnknownFunctionPointerType *_field1;
unsigned int _field2;
float _field3;
CDUnknownBlockType _field4;
id _field5;
_Bool _field6;
double _field7;
double _field8;
float _field9;
float _field10;
double _field11;
_Bool _field12;
_Bool _field13;
CDUnknownBlockType _field14;
long long _field15;
float _field16;
float _field17;
float _field18;
float _field19;
float _field20;
struct {
float _field1;
float _field2;
} _field21;
struct {
float _field1;
float _field2;
} _field22;
struct {
float _field1;
float _field2;
} _field23;
_Bool _field24;
_Bool _field25;
_Bool _field26;
_Bool _field27;
};
struct SKCRotate {
CDUnknownFunctionPointerType *_field1;
unsigned int _field2;
float _field3;
CDUnknownBlockType _field4;
id _field5;
_Bool _field6;
double _field7;
double _field8;
float _field9;
float _field10;
double _field11;
_Bool _field12;
_Bool _field13;
CDUnknownBlockType _field14;
long long _field15;
float _field16;
float _field17;
float _field18;
float _field19;
float _field20;
float _field21;
float _field22;
float _field23;
float _field24;
float _field25;
float _field26;
float _field27;
float _field28;
float _field29;
_Bool _field30;
_Bool _field31;
_Bool _field32;
_Bool _field33;
_Bool _field34;
_Bool _field35;
};
struct SKCScale {
CDUnknownFunctionPointerType *_field1;
unsigned int _field2;
float _field3;
CDUnknownBlockType _field4;
id _field5;
_Bool _field6;
double _field7;
double _field8;
float _field9;
float _field10;
double _field11;
_Bool _field12;
_Bool _field13;
CDUnknownBlockType _field14;
long long _field15;
float _field16;
float _field17;
float _field18;
float _field19;
float _field20;
float _field21;
float _field22;
float _field23;
float _field24;
float _field25;
float _field26;
float _field27;
float _field28;
_Bool _field29;
_Bool _field30;
_Bool _field31;
_Bool _field32;
_Bool _field33;
struct CGSize _field34;
};
struct SKCSequence {
CDUnknownFunctionPointerType *_field1;
unsigned int _field2;
float _field3;
CDUnknownBlockType _field4;
id _field5;
_Bool _field6;
double _field7;
double _field8;
float _field9;
float _field10;
double _field11;
_Bool _field12;
_Bool _field13;
CDUnknownBlockType _field14;
long long _field15;
float _field16;
float _field17;
float _field18;
float _field19;
struct vector<SKCAction *, std::__1::allocator<SKCAction *>> _field20;
unsigned long long _field21;
};
struct SKCSpeed {
CDUnknownFunctionPointerType *_field1;
unsigned int _field2;
float _field3;
CDUnknownBlockType _field4;
id _field5;
_Bool _field6;
double _field7;
double _field8;
float _field9;
float _field10;
double _field11;
_Bool _field12;
_Bool _field13;
CDUnknownBlockType _field14;
long long _field15;
float _field16;
float _field17;
float _field18;
float _field19;
float _field20;
float _field21;
float _field22;
float _field23;
float _field24;
_Bool _field25;
_Bool _field26;
};
struct SKCStats {
CDUnknownFunctionPointerType *_vptr$SKCStats;
double frameBeginTime;
double frameDuration;
double baseTime;
double currentTime;
int frameCount;
CDStruct_febfcd7b clientUpdate;
CDStruct_febfcd7b update;
struct {
double beginTime;
double duration;
int bodyCount;
} physics;
struct {
double beginTime;
double duration;
int constraintCount;
} constraints;
struct {
double beginTime;
double duration;
int opCount;
int quadCount;
int nodeTraversalCount;
int sknodeTraversalCount;
int nodeRenderCount;
int drawCallCount;
int passCount;
int maxBatchElementCount;
} render;
};
struct SKCStrength {
CDUnknownFunctionPointerType *_field1;
unsigned int _field2;
float _field3;
CDUnknownBlockType _field4;
id _field5;
_Bool _field6;
double _field7;
double _field8;
float _field9;
float _field10;
double _field11;
_Bool _field12;
_Bool _field13;
CDUnknownBlockType _field14;
long long _field15;
float _field16;
float _field17;
float _field18;
float _field19;
float _field20;
float _field21;
float _field22;
float _field23;
float _field24;
_Bool _field25;
_Bool _field26;
};
struct SKCWait {
CDUnknownFunctionPointerType *_field1;
unsigned int _field2;
float _field3;
CDUnknownBlockType _field4;
id _field5;
_Bool _field6;
double _field7;
double _field8;
float _field9;
float _field10;
double _field11;
_Bool _field12;
_Bool _field13;
CDUnknownBlockType _field14;
long long _field15;
float _field16;
float _field17;
float _field18;
float _field19;
};
struct TextureInfo;
struct Token;
struct __hash_node_base<std::__1::__hash_node<std::__1::__hash_value_type<std::__1::basic_string<char>, SKTexture *>, void *>*> {
struct __hash_node_base<std::__1::__hash_node<std::__1::__hash_value_type<std::__1::basic_string<char>, SKTexture *>, void *>*> *__next_;
};
struct __list_node_base<SKCAction *, void *> {
struct __list_node_base<SKCAction *, void *> *_field1;
struct __list_node_base<SKCAction *, void *> *_field2;
};
struct __shared_weak_count;
struct __tree_end_node<std::__1::__tree_node_base<void *>*> {
struct __tree_node_base<void *> *__left_;
};
struct _opaque_pthread_mutex_t {
long long __sig;
char __opaque[56];
};
struct basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> {
struct __compressed_pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>::__rep, std::__1::allocator<char>> {
struct __rep {
union {
struct __long {
unsigned long long __cap_;
unsigned long long __size_;
char *__data_;
} __l;
struct __short {
union {
unsigned char __size_;
char __lx;
} ;
char __data_[23];
} __s;
struct __raw {
unsigned long long __words[3];
} __r;
} ;
} __value_;
} __r_;
};
struct jet_command_buffer;
struct jet_fence;
struct jet_framebuffer;
struct jet_program;
struct jet_texture;
struct list<SKCAction *, std::__1::allocator<SKCAction *>> {
struct __list_node_base<SKCAction *, void *> _field1;
struct __compressed_pair<unsigned long, std::__1::allocator<std::__1::__list_node<SKCAction *, void *>>> {
unsigned long long _field1;
} _field2;
};
struct map<std::__1::basic_string<char>, std::__1::shared_ptr<jet_buffer_pool>, std::__1::less<std::__1::basic_string<char>>, std::__1::allocator<std::__1::pair<const std::__1::basic_string<char>, std::__1::shared_ptr<jet_buffer_pool>>>> {
struct __tree<std::__1::__value_type<std::__1::basic_string<char>, std::__1::shared_ptr<jet_buffer_pool>>, std::__1::__map_value_compare<std::__1::basic_string<char>, std::__1::__value_type<std::__1::basic_string<char>, std::__1::shared_ptr<jet_buffer_pool>>, std::__1::less<std::__1::basic_string<char>>, true>, std::__1::allocator<std::__1::__value_type<std::__1::basic_string<char>, std::__1::shared_ptr<jet_buffer_pool>>>> {
struct __tree_end_node<std::__1::__tree_node_base<void *>*> *__begin_node_;
struct __compressed_pair<std::__1::__tree_end_node<std::__1::__tree_node_base<void *>*>, std::__1::allocator<std::__1::__tree_node<std::__1::__value_type<std::__1::basic_string<char>, std::__1::shared_ptr<jet_buffer_pool>>, void *>>> {
struct __tree_end_node<std::__1::__tree_node_base<void *>*> __value_;
} __pair1_;
struct __compressed_pair<unsigned long, std::__1::__map_value_compare<std::__1::basic_string<char>, std::__1::__value_type<std::__1::basic_string<char>, std::__1::shared_ptr<jet_buffer_pool>>, std::__1::less<std::__1::basic_string<char>>, true>> {
unsigned long long __value_;
} __pair3_;
} __tree_;
};
struct map<unsigned int, double, std::__1::less<unsigned int>, std::__1::allocator<std::__1::pair<const unsigned int, double>>> {
struct __tree<std::__1::__value_type<unsigned int, double>, std::__1::__map_value_compare<unsigned int, std::__1::__value_type<unsigned int, double>, std::__1::less<unsigned int>, true>, std::__1::allocator<std::__1::__value_type<unsigned int, double>>> {
struct __tree_end_node<std::__1::__tree_node_base<void *>*> *__begin_node_;
struct __compressed_pair<std::__1::__tree_end_node<std::__1::__tree_node_base<void *>*>, std::__1::allocator<std::__1::__tree_node<std::__1::__value_type<unsigned int, double>, void *>>> {
struct __tree_end_node<std::__1::__tree_node_base<void *>*> __value_;
} __pair1_;
struct __compressed_pair<unsigned long, std::__1::__map_value_compare<unsigned int, std::__1::__value_type<unsigned int, double>, std::__1::less<unsigned int>, true>> {
unsigned long long __value_;
} __pair3_;
} __tree_;
};
struct map<unsigned short, SKSpriteNode *, std::__1::less<unsigned short>, std::__1::allocator<std::__1::pair<const unsigned short, SKSpriteNode *>>> {
struct __tree<std::__1::__value_type<unsigned short, SKSpriteNode *>, std::__1::__map_value_compare<unsigned short, std::__1::__value_type<unsigned short, SKSpriteNode *>, std::__1::less<unsigned short>, true>, std::__1::allocator<std::__1::__value_type<unsigned short, SKSpriteNode *>>> {
struct __tree_end_node<std::__1::__tree_node_base<void *>*> *__begin_node_;
struct __compressed_pair<std::__1::__tree_end_node<std::__1::__tree_node_base<void *>*>, std::__1::allocator<std::__1::__tree_node<std::__1::__value_type<unsigned short, SKSpriteNode *>, void *>>> {
struct __tree_end_node<std::__1::__tree_node_base<void *>*> __value_;
} __pair1_;
struct __compressed_pair<unsigned long, std::__1::__map_value_compare<unsigned short, std::__1::__value_type<unsigned short, SKSpriteNode *>, std::__1::less<unsigned short>, true>> {
unsigned long long __value_;
} __pair3_;
} __tree_;
};
struct map<unsigned short, double, std::__1::less<unsigned short>, std::__1::allocator<std::__1::pair<const unsigned short, double>>> {
struct __tree<std::__1::__value_type<unsigned short, double>, std::__1::__map_value_compare<unsigned short, std::__1::__value_type<unsigned short, double>, std::__1::less<unsigned short>, true>, std::__1::allocator<std::__1::__value_type<unsigned short, double>>> {
struct __tree_end_node<std::__1::__tree_node_base<void *>*> *__begin_node_;
struct __compressed_pair<std::__1::__tree_end_node<std::__1::__tree_node_base<void *>*>, std::__1::allocator<std::__1::__tree_node<std::__1::__value_type<unsigned short, double>, void *>>> {
struct __tree_end_node<std::__1::__tree_node_base<void *>*> __value_;
} __pair1_;
struct __compressed_pair<unsigned long, std::__1::__map_value_compare<unsigned short, std::__1::__value_type<unsigned short, double>, std::__1::less<unsigned short>, true>> {
unsigned long long __value_;
} __pair3_;
} __tree_;
};
struct set<SKNode *, std::__1::less<SKNode *>, std::__1::allocator<SKNode *>> {
struct __tree<SKNode *, std::__1::less<SKNode *>, std::__1::allocator<SKNode *>> {
struct __tree_end_node<std::__1::__tree_node_base<void *>*> *_field1;
struct __compressed_pair<std::__1::__tree_end_node<std::__1::__tree_node_base<void *>*>, std::__1::allocator<std::__1::__tree_node<SKNode *, void *>>> {
struct __tree_end_node<std::__1::__tree_node_base<void *>*> _field1;
} _field2;
struct __compressed_pair<unsigned long, std::__1::less<SKNode *>> {
unsigned long long _field1;
} _field3;
} _field1;
};
struct shared_ptr<MaxRectTexturePacker> {
struct MaxRectTexturePacker *_field1;
struct __shared_weak_count *_field2;
};
struct shared_ptr<PKCAether> {
struct PKCAether *_field1;
struct __shared_weak_count *_field2;
};
struct shared_ptr<jet_command_buffer> {
struct jet_command_buffer *_field1;
struct __shared_weak_count *_field2;
};
struct shared_ptr<jet_fence> {
struct jet_fence *__ptr_;
struct __shared_weak_count *__cntrl_;
};
struct shared_ptr<jet_framebuffer> {
struct jet_framebuffer *__ptr_;
struct __shared_weak_count *__cntrl_;
};
struct shared_ptr<jet_program> {
struct jet_program *__ptr_;
struct __shared_weak_count *__cntrl_;
};
struct shared_ptr<jet_texture> {
struct jet_texture *__ptr_;
struct __shared_weak_count *__cntrl_;
};
struct unique_ptr<std::__1::__hash_node_base<std::__1::__hash_node<std::__1::__hash_value_type<std::__1::basic_string<char>, SKTexture *>, void *>*>*[], std::__1::__bucket_list_deallocator<std::__1::allocator<std::__1::__hash_node_base<std::__1::__hash_node<std::__1::__hash_value_type<std::__1::basic_string<char>, SKTexture *>, void *>*>*>>> {
struct __compressed_pair<std::__1::__hash_node_base<std::__1::__hash_node<std::__1::__hash_value_type<std::__1::basic_string<char>, SKTexture *>, void *>*>**, std::__1::__bucket_list_deallocator<std::__1::allocator<std::__1::__hash_node_base<std::__1::__hash_node<std::__1::__hash_value_type<std::__1::basic_string<char>, SKTexture *>, void *>*>*>>> {
struct __hash_node_base<std::__1::__hash_node<std::__1::__hash_value_type<std::__1::basic_string<char>, SKTexture *>, void *>*> **__value_;
struct __bucket_list_deallocator<std::__1::allocator<std::__1::__hash_node_base<std::__1::__hash_node<std::__1::__hash_value_type<std::__1::basic_string<char>, SKTexture *>, void *>*>*>> {
struct __compressed_pair<unsigned long, std::__1::allocator<std::__1::__hash_node_base<std::__1::__hash_node<std::__1::__hash_value_type<std::__1::basic_string<char>, SKTexture *>, void *>*>*>> {
unsigned long long __value_;
} __data_;
} __value_;
} __ptr_;
};
struct unordered_map<std::__1::basic_string<char>, SKTexture *, std::__1::hash<std::__1::basic_string<char>>, std::__1::equal_to<std::__1::basic_string<char>>, std::__1::allocator<std::__1::pair<const std::__1::basic_string<char>, SKTexture *>>> {
struct __hash_table<std::__1::__hash_value_type<std::__1::basic_string<char>, SKTexture *>, std::__1::__unordered_map_hasher<std::__1::basic_string<char>, std::__1::__hash_value_type<std::__1::basic_string<char>, SKTexture *>, std::__1::hash<std::__1::basic_string<char>>, true>, std::__1::__unordered_map_equal<std::__1::basic_string<char>, std::__1::__hash_value_type<std::__1::basic_string<char>, SKTexture *>, std::__1::equal_to<std::__1::basic_string<char>>, true>, std::__1::allocator<std::__1::__hash_value_type<std::__1::basic_string<char>, SKTexture *>>> {
struct unique_ptr<std::__1::__hash_node_base<std::__1::__hash_node<std::__1::__hash_value_type<std::__1::basic_string<char>, SKTexture *>, void *>*>*[], std::__1::__bucket_list_deallocator<std::__1::allocator<std::__1::__hash_node_base<std::__1::__hash_node<std::__1::__hash_value_type<std::__1::basic_string<char>, SKTexture *>, void *>*>*>>> __bucket_list_;
struct __compressed_pair<std::__1::__hash_node_base<std::__1::__hash_node<std::__1::__hash_value_type<std::__1::basic_string<char>, SKTexture *>, void *>*>, std::__1::allocator<std::__1::__hash_node<std::__1::__hash_value_type<std::__1::basic_string<char>, SKTexture *>, void *>>> {
struct __hash_node_base<std::__1::__hash_node<std::__1::__hash_value_type<std::__1::basic_string<char>, SKTexture *>, void *>*> __value_;
} __p1_;
struct __compressed_pair<unsigned long, std::__1::__unordered_map_hasher<std::__1::basic_string<char>, std::__1::__hash_value_type<std::__1::basic_string<char>, SKTexture *>, std::__1::hash<std::__1::basic_string<char>>, true>> {
unsigned long long __value_;
} __p2_;
struct __compressed_pair<float, std::__1::__unordered_map_equal<std::__1::basic_string<char>, std::__1::__hash_value_type<std::__1::basic_string<char>, SKTexture *>, std::__1::equal_to<std::__1::basic_string<char>>, true>> {
float __value_;
} __p3_;
} __table_;
};
struct vector<CGRect, std::__1::allocator<CGRect>> {
struct CGRect *_field1;
struct CGRect *_field2;
struct __compressed_pair<CGRect *, std::__1::allocator<CGRect>> {
struct CGRect *_field1;
} _field3;
};
struct vector<CGSize, std::__1::allocator<CGSize>> {
struct CGSize *_field1;
struct CGSize *_field2;
struct __compressed_pair<CGSize *, std::__1::allocator<CGSize>> {
struct CGSize *_field1;
} _field3;
};
struct vector<SKCAction *, std::__1::allocator<SKCAction *>> {
struct SKCAction **_field1;
struct SKCAction **_field2;
struct __compressed_pair<SKCAction **, std::__1::allocator<SKCAction *>> {
struct SKCAction **_field1;
} _field3;
};
struct vector<SKTexture *, std::__1::allocator<SKTexture *>> {
id *_field1;
id *_field2;
struct __compressed_pair<SKTexture *__strong *, std::__1::allocator<SKTexture *>> {
id *_field1;
} _field3;
};
struct vector<TextureInfo, std::__1::allocator<TextureInfo>> {
struct TextureInfo *_field1;
struct TextureInfo *_field2;
struct __compressed_pair<TextureInfo *, std::__1::allocator<TextureInfo>> {
struct TextureInfo *_field1;
} _field3;
};
struct vector<Token, std::__1::allocator<Token>> {
struct Token *_field1;
struct Token *_field2;
struct __compressed_pair<Token *, std::__1::allocator<Token>> {
struct Token *_field1;
} _field3;
};
struct vector<float __attribute__((ext_vector_type(2))), std::__1::allocator<float __attribute__((ext_vector_type(2)))>> {
void *__begin_;
void *__end_;
struct __compressed_pair<float * __attribute__((ext_vector_type(2))), std::__1::allocator<float __attribute__((ext_vector_type(2)))>> {
void *__value_;
} __end_cap_;
};
#pragma mark Typedef'd Structures
typedef struct {
unsigned long long _field1;
id *_field2;
unsigned long long *_field3;
unsigned long long _field4[5];
} CDStruct_70511ce9;
typedef struct {
double beginTime;
double duration;
} CDStruct_febfcd7b;
typedef struct {
float _field1;
float _field2;
float _field3;
float _field4;
} CDStruct_818bb265;
typedef struct {
float _field1;
float _field2;
float _field3;
} CDStruct_869f9c67;
// Ambiguous groups
typedef struct {
float _field1;
float _field2;
} CDStruct_b2fbf00d;
typedef struct basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> {
struct __compressed_pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>::__rep, std::__1::allocator<char>> {
struct __rep {
union {
struct __long {
unsigned long long __cap_;
unsigned long long __size_;
char *__data_;
} __l;
struct __short {
union {
unsigned char __size_;
char __lx;
} ;
char __data_[23];
} __s;
struct __raw {
unsigned long long __words[3];
} __r;
} ;
} __value_;
} __r_;
} basic_string_23d93216;
typedef struct map<std::__1::basic_string<char>, std::__1::shared_ptr<jet_buffer_pool>, std::__1::less<std::__1::basic_string<char>>, std::__1::allocator<std::__1::pair<const std::__1::basic_string<char>, std::__1::shared_ptr<jet_buffer_pool>>>> {
struct __tree<std::__1::__value_type<std::__1::basic_string<char>, std::__1::shared_ptr<jet_buffer_pool>>, std::__1::__map_value_compare<std::__1::basic_string<char>, std::__1::__value_type<std::__1::basic_string<char>, std::__1::shared_ptr<jet_buffer_pool>>, std::__1::less<std::__1::basic_string<char>>, true>, std::__1::allocator<std::__1::__value_type<std::__1::basic_string<char>, std::__1::shared_ptr<jet_buffer_pool>>>> {
struct __tree_end_node<std::__1::__tree_node_base<void *>*> *__begin_node_;
struct __compressed_pair<std::__1::__tree_end_node<std::__1::__tree_node_base<void *>*>, std::__1::allocator<std::__1::__tree_node<std::__1::__value_type<std::__1::basic_string<char>, std::__1::shared_ptr<jet_buffer_pool>>, void *>>> {
struct __tree_end_node<std::__1::__tree_node_base<void *>*> __value_;
} __pair1_;
struct __compressed_pair<unsigned long, std::__1::__map_value_compare<std::__1::basic_string<char>, std::__1::__value_type<std::__1::basic_string<char>, std::__1::shared_ptr<jet_buffer_pool>>, std::__1::less<std::__1::basic_string<char>>, true>> {
unsigned long long __value_;
} __pair3_;
} __tree_;
} map_48758480;
typedef struct set<SKNode *, std::__1::less<SKNode *>, std::__1::allocator<SKNode *>> {
struct __tree<SKNode *, std::__1::less<SKNode *>, std::__1::allocator<SKNode *>> {
struct __tree_end_node<std::__1::__tree_node_base<void *>*> *_field1;
struct __compressed_pair<std::__1::__tree_end_node<std::__1::__tree_node_base<void *>*>, std::__1::allocator<std::__1::__tree_node<SKNode *, void *>>> {
struct __tree_end_node<std::__1::__tree_node_base<void *>*> _field1;
} _field2;
struct __compressed_pair<unsigned long, std::__1::less<SKNode *>> {
unsigned long long _field1;
} _field3;
} _field1;
} set_3449d313;
typedef struct shared_ptr<MaxRectTexturePacker> {
struct MaxRectTexturePacker *_field1;
struct __shared_weak_count *_field2;
} shared_ptr_7747cbe3;
typedef struct shared_ptr<PKCAether> {
struct PKCAether *_field1;
struct __shared_weak_count *_field2;
} shared_ptr_11a7378b;
typedef struct shared_ptr<jet_command_buffer> {
struct jet_command_buffer *_field1;
struct __shared_weak_count *_field2;
} shared_ptr_d7c0f433;
typedef struct shared_ptr<jet_framebuffer> {
struct jet_framebuffer *__ptr_;
struct __shared_weak_count *__cntrl_;
} shared_ptr_2ce53ef7;
typedef struct shared_ptr<jet_program> {
struct jet_program *__ptr_;
struct __shared_weak_count *__cntrl_;
} shared_ptr_394c00aa;
typedef struct shared_ptr<jet_texture> {
struct jet_texture *__ptr_;
struct __shared_weak_count *__cntrl_;
} shared_ptr_bb77cfd9;
typedef struct vector<CGRect, std::__1::allocator<CGRect>> {
struct CGRect *_field1;
struct CGRect *_field2;
struct __compressed_pair<CGRect *, std::__1::allocator<CGRect>> {
struct CGRect *_field1;
} _field3;
} vector_ea45b3ba;
typedef struct vector<CGSize, std::__1::allocator<CGSize>> {
struct CGSize *_field1;
struct CGSize *_field2;
struct __compressed_pair<CGSize *, std::__1::allocator<CGSize>> {
struct CGSize *_field1;
} _field3;
} vector_c74fc2b3;
typedef struct vector<TextureInfo, std::__1::allocator<TextureInfo>> {
struct TextureInfo *_field1;
struct TextureInfo *_field2;
struct __compressed_pair<TextureInfo *, std::__1::allocator<TextureInfo>> {
struct TextureInfo *_field1;
} _field3;
} vector_65e381fc;
typedef struct vector<Token, std::__1::allocator<Token>> {
struct Token *_field1;
struct Token *_field2;
struct __compressed_pair<Token *, std::__1::allocator<Token>> {
struct Token *_field1;
} _field3;
} vector_408ca79d;
#pragma mark Named Unions
union _GLKMatrix2 {
CDStruct_818bb265 _field1;
float _field2[2][2];
float _field3[4];
};
union _GLKMatrix3 {
struct {
float _field1;
float _field2;
float _field3;
float _field4;
float _field5;
float _field6;
float _field7;
float _field8;
float _field9;
} _field1;
float _field2[9];
};
union _GLKMatrix4 {
struct {
float _field1;
float _field2;
float _field3;
float _field4;
float _field5;
float _field6;
float _field7;
float _field8;
float _field9;
float _field10;
float _field11;
float _field12;
float _field13;
float _field14;
float _field15;
float _field16;
} _field1;
float _field2[16];
};
union _GLKVector2 {
struct {
float x;
float y;
} ;
struct {
float s;
float t;
} ;
float v[2];
};
union _GLKVector3 {
CDStruct_869f9c67 _field1;
CDStruct_869f9c67 _field2;
CDStruct_869f9c67 _field3;
float _field4[3];
};
union _GLKVector4 {
CDStruct_818bb265 _field1;
CDStruct_818bb265 _field2;
CDStruct_818bb265 _field3;
float _field4[4];
};
| [
"8657156@qq.com"
] | 8657156@qq.com |
be660048197127ecc0c08a67009c1632a8aaadfc | 4415c5ede372070df91397b17cadff2567ed7178 | /31 = 888144/try-catch/ex03.cpp | dccce5f90138837582355d45452d9a5d19538af5 | [] | no_license | NitichaiSawangsai/BUU-Y1 | 67798d16930234c45eb50ca4098edaea84c66a76 | ad8dc6fc59b46f7492874db24adf1e620bf73829 | refs/heads/master | 2023-07-11T05:45:20.299221 | 2021-08-22T01:47:44 | 2021-08-22T01:47:44 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 851 | cpp | // Division by zero and the assert function.
#include <iostream>
#include <cassert>
using namespace std;
int main()
{
int dividend, divisor, quotient; //Line 1
cout << "Line 2: Enter the dividend: "; //Line 2
cin >> dividend; //Line 3
cout << endl; //Line 4
cout << "Line 5: Enter the divisor: "; //Line 5
cin >> divisor; //Line 6
cout << endl; //Line 7
assert(divisor != 0); //Line 8
quotient = dividend / divisor; //Line 9
cout << "Line 10: Quotient = " << quotient
<< endl; //Line 10
return 0; //Line 11
}
| [
"NitichaiSawangsai@gmail.com"
] | NitichaiSawangsai@gmail.com |
32bac9da5215df0618920ec332ccee23959f7e1e | 9030ce2789a58888904d0c50c21591632eddffd7 | /SDK/ARKSurvivalEvolved_PrimalItemSkin_WW_XmasSweater_RaptorClaws_functions.cpp | 8eece5e608e80725e31c656f343d6003f7c89199 | [
"MIT"
] | permissive | 2bite/ARK-SDK | 8ce93f504b2e3bd4f8e7ced184980b13f127b7bf | ce1f4906ccf82ed38518558c0163c4f92f5f7b14 | refs/heads/master | 2022-09-19T06:28:20.076298 | 2022-09-03T17:21:00 | 2022-09-03T17:21:00 | 232,411,353 | 14 | 5 | null | null | null | null | UTF-8 | C++ | false | false | 1,280 | cpp | // ARKSurvivalEvolved (332.8) SDK
#ifdef _MSC_VER
#pragma pack(push, 0x8)
#endif
#include "ARKSurvivalEvolved_PrimalItemSkin_WW_XmasSweater_RaptorClaws_parameters.hpp"
namespace sdk
{
//---------------------------------------------------------------------------
//Functions
//---------------------------------------------------------------------------
// Function PrimalItemSkin_WW_XmasSweater_RaptorClaws.PrimalItemSkin_WW_XmasSweater_RaptorClaws_C.ExecuteUbergraph_PrimalItemSkin_WW_XmasSweater_RaptorClaws
// ()
// Parameters:
// int EntryPoint (Parm, ZeroConstructor, IsPlainOldData)
void UPrimalItemSkin_WW_XmasSweater_RaptorClaws_C::ExecuteUbergraph_PrimalItemSkin_WW_XmasSweater_RaptorClaws(int EntryPoint)
{
static auto fn = UObject::FindObject<UFunction>("Function PrimalItemSkin_WW_XmasSweater_RaptorClaws.PrimalItemSkin_WW_XmasSweater_RaptorClaws_C.ExecuteUbergraph_PrimalItemSkin_WW_XmasSweater_RaptorClaws");
UPrimalItemSkin_WW_XmasSweater_RaptorClaws_C_ExecuteUbergraph_PrimalItemSkin_WW_XmasSweater_RaptorClaws_Params params;
params.EntryPoint = EntryPoint;
auto flags = fn->FunctionFlags;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
}
}
#ifdef _MSC_VER
#pragma pack(pop)
#endif
| [
"sergey.2bite@gmail.com"
] | sergey.2bite@gmail.com |
72a022b29d5bf743c0b182fdbf1d594a1bb218e2 | 6606fa8ff441522c7a7150b7f3521dd8e6f2f6c7 | /Lab2/Lab2/Primitives.h | 6b13f19eb37546a6d53319a51372f389c4d5768a | [] | no_license | Jane1408/PP | 08e11260b7662183a2786f2c3984654470108a60 | 7d9311512328739f576bd9037bcd226760283863 | refs/heads/master | 2021-01-12T16:43:19.169578 | 2017-01-18T15:24:10 | 2017-01-18T15:24:10 | 71,437,972 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 561 | h | #pragma once
#include "targetver.h"
#include <stdio.h>
#include <tchar.h>
#include <iostream>
#include <vector>
#include <Windows.h>
enum class PrimitiveType
{
CRITICAL_SECTION,
MUTEX,
SEMAPHORE,
EVENT,
NO
};
struct Primitives
{
PrimitiveType type;
HANDLE hMutex;
HANDLE hSemaphore;
HANDLE hEvent;
CRITICAL_SECTION critical_section;
Primitives()
: hMutex(CreateMutex(NULL, false, NULL))
, hSemaphore(CreateSemaphore(NULL, 1, 1, NULL))
, hEvent(CreateEvent(NULL, false, true, NULL))
{
InitializeCriticalSection(&critical_section);
}
}; | [
"Женечка"
] | Женечка |
4084dc8c26ddfa6b9bfe4be1795cf7303a804e68 | 630a68871d4cdcc9dbc1f8ac8b44f579ff994ecf | /myodd/boost/libs/phoenix/test/container/container_tests3a.cpp | a10fdee6dcc6eaefa98daeb4f7ca3ec2cc34be46 | [
"MIT",
"BSL-1.0"
] | permissive | FFMG/myoddweb.piger | b56b3529346d9a1ed23034098356ea420c04929d | 6f5a183940661bd7457e6a497fd39509e186cbf5 | refs/heads/master | 2023-01-09T12:45:27.156140 | 2022-12-31T12:40:31 | 2022-12-31T12:40:31 | 52,210,495 | 19 | 2 | MIT | 2022-12-31T12:40:32 | 2016-02-21T14:31:50 | C++ | UTF-8 | C++ | false | false | 1,748 | cpp | /*=============================================================================
Copyright (c) 2004 Angus Leeming
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 "container_tests.hpp"
#include <boost/static_assert.hpp>
std::map<int, int> const build_map()
{
typedef std::map<int, int> int_map;
typedef std::vector<int> int_vector;
int_map result;
int_vector const data = build_vector();
int_vector::const_iterator it = data.begin();
int_vector::const_iterator const end = data.end();
for (; it != end; ++it) {
int const value = *it;
result[value] = 100 * value;
}
return result;
}
std::vector<int> const init_vector()
{
typedef std::vector<int> int_vector;
int const data[] = { -4, -3, -2, -1, 0 };
int_vector::size_type const data_size = sizeof(data) / sizeof(data[0]);
return int_vector(data, data + data_size);
}
std::vector<int> const build_vector()
{
typedef std::vector<int> int_vector;
static int_vector data = init_vector();
int_vector::size_type const size = data.size();
int_vector::iterator it = data.begin();
int_vector::iterator const end = data.end();
for (; it != end; ++it)
*it += size;
return data;
}
int
main()
{
BOOST_STATIC_ASSERT((phx::stl::has_mapped_type<std::map<int, int> >::value));
std::map<int, int> const data = build_map();
test_begin(data);
test_clear(data);
test_empty(data);
test_end(data);
test_map_erase(data);
test_get_allocator(data);
return boost::report_errors();
}
| [
"github@myoddweb.com"
] | github@myoddweb.com |
c5e7f00d9bcc92ee90388090a994bc8209ed43c3 | 85381529f7a09d11b2e2491671c2d5e965467ac6 | /OJ/Leetcode/Algorithm/204. Count Primes.cpp | 3c85fa37d3dc45a903f87e6dbae71f2362965e61 | [] | no_license | Mr-Phoebe/ACM-ICPC | 862a06666d9db622a8eded7607be5eec1b1a4055 | baf6b1b7ce3ad1592208377a13f8153a8b942e91 | refs/heads/master | 2023-04-07T03:46:03.631407 | 2023-03-19T03:41:05 | 2023-03-19T03:41:05 | 46,262,661 | 19 | 3 | null | null | null | null | UTF-8 | C++ | false | false | 358 | cpp | class Solution {
public:
int countPrimes(int n) {
vector<bool> prime(n, true);
prime[0] = false, prime[1] = false;
for (int i = 0; i < sqrt(n); i++)
if (prime[i])
for (int j = i*i; j < n; j += i)
prime[j] = false;
return count(prime.begin(), prime.end(), true);
}
};
| [
"whn289467822@outlook.com"
] | whn289467822@outlook.com |
b70670a0203eb7d1b002a3faa00977418575d788 | e217eaf05d0dab8dd339032b6c58636841aa8815 | /IfcBridge/src/OpenInfraPlatform/IfcBridge/entity/IfcStructuralSurfaceConnection.cpp | 433ee320c1e55280b676ceb6a43680b9f232da7a | [] | no_license | bigdoods/OpenInfraPlatform | f7785ebe4cb46e24d7f636e1b4110679d78a4303 | 0266e86a9f25f2ea9ec837d8d340d31a58a83c8e | refs/heads/master | 2021-01-21T03:41:20.124443 | 2016-01-26T23:20:21 | 2016-01-26T23:20:21 | 57,377,206 | 0 | 1 | null | 2016-04-29T10:38:19 | 2016-04-29T10:38:19 | null | UTF-8 | C++ | false | false | 4,953 | cpp | /*! \verbatim
* \copyright Copyright (c) 2014 Julian Amann. All rights reserved.
* \date 2014-02-15 23:00
* \author Julian Amann <julian.amann@tum.de> (https://www.cms.bgu.tum.de/en/team/amann)
* \brief This file is part of the BlueFramework.
* \endverbatim
*/
#include <sstream>
#include <limits>
#include "model/IfcBridgeException.h"
#include "reader/ReaderUtil.h"
#include "writer/WriterUtil.h"
#include "IfcBridgeEntityEnums.h"
#include "include/IfcBoundaryCondition.h"
#include "include/IfcGloballyUniqueId.h"
#include "include/IfcLabel.h"
#include "include/IfcObjectPlacement.h"
#include "include/IfcOwnerHistory.h"
#include "include/IfcProductRepresentation.h"
#include "include/IfcRelAggregates.h"
#include "include/IfcRelAssigns.h"
#include "include/IfcRelAssignsToProduct.h"
#include "include/IfcRelAssociates.h"
#include "include/IfcRelConnectsStructuralActivity.h"
#include "include/IfcRelConnectsStructuralMember.h"
#include "include/IfcRelDeclares.h"
#include "include/IfcRelDefinesByObject.h"
#include "include/IfcRelDefinesByProperties.h"
#include "include/IfcRelDefinesByType.h"
#include "include/IfcRelNests.h"
#include "include/IfcStructuralSurfaceConnection.h"
#include "include/IfcText.h"
namespace OpenInfraPlatform
{
namespace IfcBridge
{
// ENTITY IfcStructuralSurfaceConnection
IfcStructuralSurfaceConnection::IfcStructuralSurfaceConnection() { m_entity_enum = IFCSTRUCTURALSURFACECONNECTION; }
IfcStructuralSurfaceConnection::IfcStructuralSurfaceConnection( int id ) { m_id = id; m_entity_enum = IFCSTRUCTURALSURFACECONNECTION; }
IfcStructuralSurfaceConnection::~IfcStructuralSurfaceConnection() {}
// method setEntity takes over all attributes from another instance of the class
void IfcStructuralSurfaceConnection::setEntity( shared_ptr<IfcBridgeEntity> other_entity )
{
shared_ptr<IfcStructuralSurfaceConnection> other = dynamic_pointer_cast<IfcStructuralSurfaceConnection>(other_entity);
if( !other) { return; }
m_GlobalId = other->m_GlobalId;
m_OwnerHistory = other->m_OwnerHistory;
m_Name = other->m_Name;
m_Description = other->m_Description;
m_ObjectType = other->m_ObjectType;
m_ObjectPlacement = other->m_ObjectPlacement;
m_Representation = other->m_Representation;
m_AppliedCondition = other->m_AppliedCondition;
}
void IfcStructuralSurfaceConnection::getStepLine( std::stringstream& stream ) const
{
stream << "#" << m_id << "=IFCSTRUCTURALSURFACECONNECTION" << "(";
if( m_GlobalId ) { m_GlobalId->getStepParameter( stream ); } else { stream << "$"; }
stream << ",";
if( m_OwnerHistory ) { stream << "#" << m_OwnerHistory->getId(); } else { stream << "$"; }
stream << ",";
if( m_Name ) { m_Name->getStepParameter( stream ); } else { stream << "$"; }
stream << ",";
if( m_Description ) { m_Description->getStepParameter( stream ); } else { stream << "$"; }
stream << ",";
if( m_ObjectType ) { m_ObjectType->getStepParameter( stream ); } else { stream << "$"; }
stream << ",";
if( m_ObjectPlacement ) { stream << "#" << m_ObjectPlacement->getId(); } else { stream << "$"; }
stream << ",";
if( m_Representation ) { stream << "#" << m_Representation->getId(); } else { stream << "$"; }
stream << ",";
if( m_AppliedCondition ) { stream << "#" << m_AppliedCondition->getId(); } else { stream << "$"; }
stream << ");";
}
void IfcStructuralSurfaceConnection::getStepParameter( std::stringstream& stream, bool ) const { stream << "#" << m_id; }
void IfcStructuralSurfaceConnection::readStepData( std::vector<std::string>& args, const std::map<int,shared_ptr<IfcBridgeEntity> >& map )
{
const int num_args = (int)args.size();
if( num_args<8 ){ std::stringstream strserr; strserr << "Wrong parameter count for entity IfcStructuralSurfaceConnection, expecting 8, having " << num_args << ". Object id: " << getId() << std::endl; throw IfcBridgeException( strserr.str().c_str() ); }
#ifdef _DEBUG
if( num_args>8 ){ std::cout << "Wrong parameter count for entity IfcStructuralSurfaceConnection, expecting 8, having " << num_args << ". Object id: " << getId() << std::endl; }
#endif
m_GlobalId = IfcGloballyUniqueId::readStepData( args[0] );
readEntityReference( args[1], m_OwnerHistory, map );
m_Name = IfcLabel::readStepData( args[2] );
m_Description = IfcText::readStepData( args[3] );
m_ObjectType = IfcLabel::readStepData( args[4] );
readEntityReference( args[5], m_ObjectPlacement, map );
readEntityReference( args[6], m_Representation, map );
readEntityReference( args[7], m_AppliedCondition, map );
}
void IfcStructuralSurfaceConnection::setInverseCounterparts( shared_ptr<IfcBridgeEntity> ptr_self_entity )
{
IfcStructuralConnection::setInverseCounterparts( ptr_self_entity );
}
void IfcStructuralSurfaceConnection::unlinkSelf()
{
IfcStructuralConnection::unlinkSelf();
}
} // end namespace IfcBridge
} // end namespace OpenInfraPlatform
| [
"planung.cms.bv@tum.de"
] | planung.cms.bv@tum.de |
67ab3c43481c1720dd07050dc735da11cf118b89 | c69becc1ab6668a261c7c0c5aaebe3e80afac0ee | /c++/euler5bpw/euler5bpw.cpp | 570d495286e208f39313e5a87c59f59624466984 | [] | no_license | walford/euler | ba66fcbd8dbbc517ad4c29d562cba213a946a691 | e1917bafe15d0997d3c6bcc9e84fc1d249bf8d3d | refs/heads/master | 2021-03-12T22:27:53.930911 | 2014-12-19T22:18:33 | 2014-12-19T22:18:33 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 546 | cpp | // 2520 is the smallest number that can be divided by each of the numbers
// from 1 to 10 without any remainder. What is the smallest positive number
// that is evenly divisible by all of the numbers from 1 to 20?
#include "euler5bpw.h"
int main() {
int answer = 0;
int num = 0;
bool divided = false;
while(divided == false) {
num++;
divided = is_divisible(num);
answer = num;
}
cout << answer << endl;
}
bool is_divisible(int num) {
for(int i=1; i<=20; i++) {
if(num % i != 0) {
return false;
}
}
return true;
} | [
"bpwalford@gmail.com"
] | bpwalford@gmail.com |
c6af20256cd78626f8676926aa124e57b603bbfb | 5524a779227c42b6152e7dac5b850669e9b7bdf4 | /testing/schematest.cpp | 5a9b0279a491d5fa27a6826b3cb9ea27cc7ca9eb | [] | no_license | klausschreiber/ERDB | ed7d9856b72cf61e317fe825b410571bec1d1959 | e29e4126791a00e88ca43a5d1c554721cfe7980d | refs/heads/master | 2021-01-25T08:37:47.940230 | 2015-07-03T16:12:49 | 2015-07-03T16:12:49 | 34,250,393 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,244 | cpp | #include <string.h>
#include <iostream>
#include "../schema/SchemaManager.hpp"
int main(int argc, char ** argv) {
std::cout << "Hello :-)" << std::endl;
BufferManager* bm = new BufferManager(20);
SchemaManager* sm = new SchemaManager(*bm);
sm->dropSchema("test");
int size = sizeof(struct Schema) + 1*sizeof(struct Schema::Attribute);
struct Schema * schema = reinterpret_cast<struct Schema *>(malloc(size));
schema->attr_count = 1;
schema->primary_key_index[0] = 0;
schema->primary_key_index[1] = 5;
schema->primary_key_index[2] = 5;
schema->primary_key_index[3] = 5;
schema->primary_key_index[4] = 5;
strncpy(schema->name, "test", 11);
schema->attributes[0].type = Schema::Attribute::Type::Integer;
strncpy(schema->attributes[0].name, "id", 3);
schema->attributes[0].notNull = true;
sm->addSchema(*schema);
int size2 = sizeof(struct Schema) + 2*sizeof(struct Schema::Attribute);
struct Schema * schema2 = reinterpret_cast<struct Schema *>(malloc(size2));
schema2->attr_count = 2;
schema2->primary_key_index[0] = 0;
schema2->primary_key_index[1] = 5;
schema2->primary_key_index[2] = 5;
schema2->primary_key_index[3] = 5;
schema2->primary_key_index[4] = 5;
strncpy(schema2->name, "test-table", 11);
schema2->attributes[0].type = Schema::Attribute::Type::Integer;
strncpy(schema2->attributes[0].name, "id", 3);
schema2->attributes[0].notNull = true;
schema2->attributes[1].type = Schema::Attribute::Type::Varchar;
schema2->attributes[1].length = 20;
strncpy(schema2->attributes[1].name, "name", 5);
schema2->attributes[1].notNull = true;
sm->addSchema(*schema2);
sm->incrementPagesCount("test-table");
sm->incrementPagesCount("test");
const struct Schema * schema3 = sm->getSchema("test");
std::cout << schema3->name << ": " << schema3->page_count << std::endl;
const struct Schema * schema4 = sm->getSchema("test-table");
std::cout << schema4->name << ": " << schema4->page_count << std::endl;
const struct Schema * nullSchema = sm->getSchema("nonexistent");
std::cout << (nullSchema == NULL) << std::endl;
delete sm;
delete bm;
return 0;
}
| [
"sebastian@rueckerlmail.com"
] | sebastian@rueckerlmail.com |
8bae94336bdffbcdb13922864c274c0bc7635950 | 012d280967aae334c63fec3b1983c103efd41cb6 | /robominton/src/disp.cpp | 48320782c2b756462316c781de13348839273829 | [
"MIT"
] | permissive | ukaana99/nhk2015_back_ros | b282068ccb7acaee957c2dfc71f31d1016c555db | abf0bdd81c452c104627c91a9a061d6e33264387 | refs/heads/master | 2021-05-28T19:23:01.846782 | 2015-06-17T04:55:01 | 2015-06-17T04:55:01 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,692 | cpp | #include <ros/ros.h>
#include <std_msgs/Int32.h>
#include <std_msgs/Float32.h>
#include <sensor_msgs/Imu.h>
#include <geometry_msgs/PoseStamped.h>
#include <opencv2/opencv.hpp>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
float motor1 = 0.0f;
float motor2 = 0.0f;
float enc1 = 0.0f;
float enc2 = 0.0f;
void motor1callback(const std_msgs::Float32::ConstPtr& msg){
motor1 = msg->data;
}
void motor2callback(const std_msgs::Float32::ConstPtr& msg){
motor2 = msg->data;
}
void enc1callback(const std_msgs::Float32::ConstPtr& msg){
enc1 = msg->data;
}
void enc2callback(const std_msgs::Float32::ConstPtr& msg){
enc2 = msg->data;
}
void timerCallback(const ros::TimerEvent&){
cv::Mat img = cv::Mat::zeros(300, 600, CV_8UC3);
cv::line(img, cv::Point(300+300*motor1, 150), cv::Point( 300+300*motor1+100*cos(CV_PI/2-motor2) , 150-100*sin(CV_PI/2-motor2) ), cv::Scalar(200,0,0), 10, CV_AA);
cv::line(img, cv::Point(300+300*enc1, 150), cv::Point( 300+300*enc1+100*cos(CV_PI/2-enc2) , 150-100*sin(CV_PI/2-enc2) ), cv::Scalar(0,200,200), 10, CV_AA);
cv::imshow("drawing", img);
cv::waitKey(1);
}
int main(int argc, char **argv)
{
ros::init(argc, argv, "racketDisp");
ros::NodeHandle n;
ros::Subscriber subMotor1 = n.subscribe("/mb1/motor1", 10, motor1callback);
ros::Subscriber subMotor2 = n.subscribe("/mb1/motor2", 10, motor2callback);
ros::Subscriber subEnc1 = n.subscribe("/mb1/enc1", 10, enc1callback);
ros::Subscriber subEnc2 = n.subscribe("/mb1/enc2", 10, enc2callback);
ros::Timer timer = n.createTimer(ros::Duration(0.033), timerCallback);
cv::namedWindow("drawing", CV_WINDOW_AUTOSIZE|CV_WINDOW_FREERATIO);
ros::spin();
return 0;
}
| [
"spiralray@rakusei.net"
] | spiralray@rakusei.net |
c4a330a4ba3b4a37cf340d037639a20d8c3d2425 | 6dee0cf219572dd918e1f422a970a212d6cacd04 | /utls/raster.h | 3786c03bb9c10ce5098c402e81b3a81d87247197 | [] | no_license | clemaitre58/CRD | 0afbf7fa193b0a963e7a43123bac344cb018b7a5 | afdf688d48aa9b695d413596b69655952ebf8929 | refs/heads/master | 2021-01-10T13:06:48.344737 | 2016-01-31T16:50:49 | 2016-01-31T16:50:49 | 50,784,454 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 26,830 | h | #include "elemfun.h"
namespace utls
{
// same as fill_triangle except without optimisation for filling big blocks
template <typename AryBase, typename Point>
void fill_small_triangle(AryBase *im, const Point &v1, const Point &v2, const Point &v3, typename AryBase::value fill)
{
// routine from: Nicolas Capens (http://www.devmaster.net/codespotlight/show.php?id=17)
// 28.4 fixed-point coordinates
const int Y1 = int(16.0f * v1.y);
const int Y2 = int(16.0f * v2.y);
const int Y3 = int(16.0f * v3.y);
const int X1 = int(16.0f * v1.x);
const int X2 = int(16.0f * v2.x);
const int X3 = int(16.0f * v3.x);
// Deltas
const int DX12 = X1 - X2;
const int DX23 = X2 - X3;
const int DX31 = X3 - X1;
const int DY12 = Y1 - Y2;
const int DY23 = Y2 - Y3;
const int DY31 = Y3 - Y1;
// Fixed-point deltas
const int FDX12 = DX12 << 4;
const int FDX23 = DX23 << 4;
const int FDX31 = DX31 << 4;
const int FDY12 = DY12 << 4;
const int FDY23 = DY23 << 4;
const int FDY31 = DY31 << 4;
// Bounding rectangle
int minx = (min(X1, X2, X3) + 0xF) >> 4;
int maxx = (max(X1, X2, X3) + 0xF) >> 4;
int miny = (min(Y1, Y2, Y3) + 0xF) >> 4;
int maxy = (max(Y1, Y2, Y3) + 0xF) >> 4;
// Check image boundaries
minx = min(max(im->lb2, minx), im->ub2+1);
maxx = max(min(maxx, im->ub2+1), im->lb2);
miny = min(max(im->lb1, miny), im->ub1+1);
maxy = max(min(maxy, im->ub1+1), im->lb1);
const int stride = im->cols();
typename AryBase::pointer colorBuffer = &im->el[miny][0];// (char*&)colorBuffer += miny * stride;
// Half-edge constants
int C1 = DY12 * X1 - DX12 * Y1;
int C2 = DY23 * X2 - DX23 * Y2;
int C3 = DY31 * X3 - DX31 * Y3;
// Correct for fill convention
if (DY12 < 0 || (DY12 == 0 && DX12 > 0)) C1++;
if (DY23 < 0 || (DY23 == 0 && DX23 > 0)) C2++;
if (DY31 < 0 || (DY31 == 0 && DX31 > 0)) C3++;
// Evaluate half-space functions
int CY1 = C1 + DX12 * (miny<<4) - DY12 * (minx<<4);
int CY2 = C2 + DX23 * (miny<<4) - DY23 * (minx<<4);
int CY3 = C3 + DX31 * (miny<<4) - DY31 * (minx<<4);
for(int y = miny; y < maxy; y++)
{
int CX1 = CY1;
int CX2 = CY2;
int CX3 = CY3;
for(int x = minx; x < maxx; x++)
{
if(CX1 > 0 && CX2 > 0 && CX3 > 0)
colorBuffer[x] = fill;
CX1 -= FDY12;
CX2 -= FDY23;
CX3 -= FDY31;
}
CY1 += FDX12;
CY2 += FDX23;
CY3 += FDX31;
colorBuffer += stride;
}
}
template <typename AryBase, typename Value, typename Point>
void accumulate_small_triangle(AryBase *im, const Point &v1, const Point &v2, const Point &v3, Value unit)
{
// routine from: Nicolas Capens (http://www.devmaster.net/codespotlight/show.php?id=17)
// 28.4 fixed-point coordinates
const int Y1 = int(16.0f * v1.y);
const int Y2 = int(16.0f * v2.y);
const int Y3 = int(16.0f * v3.y);
const int X1 = int(16.0f * v1.x);
const int X2 = int(16.0f * v2.x);
const int X3 = int(16.0f * v3.x);
// Deltas
const int DX12 = X1 - X2;
const int DX23 = X2 - X3;
const int DX31 = X3 - X1;
const int DY12 = Y1 - Y2;
const int DY23 = Y2 - Y3;
const int DY31 = Y3 - Y1;
// Fixed-point deltas
const int FDX12 = DX12 << 4;
const int FDX23 = DX23 << 4;
const int FDX31 = DX31 << 4;
const int FDY12 = DY12 << 4;
const int FDY23 = DY23 << 4;
const int FDY31 = DY31 << 4;
// Bounding rectangle
int minx = (min(X1, X2, X3) + 0xF) >> 4;
int maxx = (max(X1, X2, X3) + 0xF) >> 4;
int miny = (min(Y1, Y2, Y3) + 0xF) >> 4;
int maxy = (max(Y1, Y2, Y3) + 0xF) >> 4;
// Check image boundaries
minx = min(max(im->lb2, minx), im->ub2+1);
maxx = max(min(maxx, im->ub2+1), im->lb2);
miny = min(max(im->lb1, miny), im->ub1+1);
maxy = max(min(maxy, im->ub1+1), im->lb1);
const int stride = im->cols();
typename AryBase::pointer colorBuffer = &im->el[miny][0];// (char*&)colorBuffer += miny * stride;
// Half-edge constants
int C1 = DY12 * X1 - DX12 * Y1;
int C2 = DY23 * X2 - DX23 * Y2;
int C3 = DY31 * X3 - DX31 * Y3;
// Correct for fill convention
if (DY12 < 0 || (DY12 == 0 && DX12 > 0)) C1++;
if (DY23 < 0 || (DY23 == 0 && DX23 > 0)) C2++;
if (DY31 < 0 || (DY31 == 0 && DX31 > 0)) C3++;
// Evaluate half-space functions
int CY1 = C1 + DX12 * (miny<<4) - DY12 * (minx<<4);
int CY2 = C2 + DX23 * (miny<<4) - DY23 * (minx<<4);
int CY3 = C3 + DX31 * (miny<<4) - DY31 * (minx<<4);
for(int y = miny; y < maxy; y++)
{
int CX1 = CY1;
int CX2 = CY2;
int CX3 = CY3;
for(int x = minx; x < maxx; x++)
{
if(CX1 > 0 && CX2 > 0 && CX3 > 0)
colorBuffer[x].push_back(unit);
CX1 -= FDY12;
CX2 -= FDY23;
CX3 -= FDY31;
}
CY1 += FDX12;
CY2 += FDX23;
CY3 += FDX31;
colorBuffer += stride;
}
}
template <typename AryBase, typename Point>
void fill_triangle(AryBase *im, const Point &v1, const Point &v2, const Point &v3, typename AryBase::value fill)
{
// routine from: Nicolas Capens (http://www.devmaster.net/codespotlight/show.php?id=17)
// 28.4 fixed-point coordinates
const int Y1 = int(16.0f * v1.y);
const int Y2 = int(16.0f * v2.y);
const int Y3 = int(16.0f * v3.y);
const int X1 = int(16.0f * v1.x);
const int X2 = int(16.0f * v2.x);
const int X3 = int(16.0f * v3.x);
// Deltas
const int DX12 = X1 - X2;
const int DX23 = X2 - X3;
const int DX31 = X3 - X1;
const int DY12 = Y1 - Y2;
const int DY23 = Y2 - Y3;
const int DY31 = Y3 - Y1;
// Fixed-point deltas
const int FDX12 = DX12 << 4;
const int FDX23 = DX23 << 4;
const int FDX31 = DX31 << 4;
const int FDY12 = DY12 << 4;
const int FDY23 = DY23 << 4;
const int FDY31 = DY31 << 4;
// Bounding rectangle
int minx = (min(X1, X2, X3) + 0xF) >> 4;
int maxx = (max(X1, X2, X3) + 0xF) >> 4;
int miny = (min(Y1, Y2, Y3) + 0xF) >> 4;
int maxy = (max(Y1, Y2, Y3) + 0xF) >> 4;
// Check image boundaries
minx = min(max(im->lb2, minx), im->ub2+1);
maxx = max(min(maxx, im->ub2+1), im->lb2);
miny = min(max(im->lb1, miny), im->ub1+1);
maxy = max(min(maxy, im->ub1+1), im->lb1);
// Block size, standard 8x8 (must be power of two)
const int q = 8;
// Start in corner of 8x8 block
minx &= ~(q - 1);
miny &= ~(q - 1);
const int stride = im->cols();
typename AryBase::pointer colorBuffer = &im->el[miny][0];// (char*&)colorBuffer += miny * stride;
// Half-edge constants
int C1 = DY12 * X1 - DX12 * Y1;
int C2 = DY23 * X2 - DX23 * Y2;
int C3 = DY31 * X3 - DX31 * Y3;
// Correct for fill convention
if(DY12 < 0 || (DY12 == 0 && DX12 > 0)) C1++;
if(DY23 < 0 || (DY23 == 0 && DX23 > 0)) C2++;
if(DY31 < 0 || (DY31 == 0 && DX31 > 0)) C3++;
// Loop through blocks
for(int y = miny; y < maxy; y += q)
{
for(int x = minx; x < maxx; x += q)
{
// Corners of block
int x0 = x << 4;
int x1 = (x + q - 1) << 4;
int y0 = y << 4;
int y1 = (y + q - 1) << 4;
// Evaluate half-space functions
bool a00 = C1 + DX12 * y0 - DY12 * x0 > 0;
bool a10 = C1 + DX12 * y0 - DY12 * x1 > 0;
bool a01 = C1 + DX12 * y1 - DY12 * x0 > 0;
bool a11 = C1 + DX12 * y1 - DY12 * x1 > 0;
int a = (a00 << 0) | (a10 << 1) | (a01 << 2) | (a11 << 3);
bool b00 = C2 + DX23 * y0 - DY23 * x0 > 0;
bool b10 = C2 + DX23 * y0 - DY23 * x1 > 0;
bool b01 = C2 + DX23 * y1 - DY23 * x0 > 0;
bool b11 = C2 + DX23 * y1 - DY23 * x1 > 0;
int b = (b00 << 0) | (b10 << 1) | (b01 << 2) | (b11 << 3);
bool c00 = C3 + DX31 * y0 - DY31 * x0 > 0;
bool c10 = C3 + DX31 * y0 - DY31 * x1 > 0;
bool c01 = C3 + DX31 * y1 - DY31 * x0 > 0;
bool c11 = C3 + DX31 * y1 - DY31 * x1 > 0;
int c = (c00 << 0) | (c10 << 1) | (c01 << 2) | (c11 << 3);
// Skip block when outside an edge
if(a == 0x0 || b == 0x0 || c == 0x0) continue;
typename AryBase::pointer buffer = colorBuffer;
int limy = min(maxy, y+q); // don't go bellow the border
int limx = min(maxx, x+q); // don't go bellow the border
// Accept whole block when totally covered
if(a == 0xF && b == 0xF && c == 0xF)
{
for(int iy = y; iy < limy; iy++)
{
for(int ix = x; ix < limx; ix++)
buffer[ix] = fill;
buffer += stride;
}
}
else // Partially covered block
{
int CY1 = C1 + DX12 * y0 - DY12 * x0;
int CY2 = C2 + DX23 * y0 - DY23 * x0;
int CY3 = C3 + DX31 * y0 - DY31 * x0;
for(int iy = y; iy < limy; iy++)
{
int CX1 = CY1;
int CX2 = CY2;
int CX3 = CY3;
for(int ix = x; ix < limx; ix++)
{
if(CX1 > 0 && CX2 > 0 && CX3 > 0)
buffer[ix] = fill;
CX1 -= FDY12;
CX2 -= FDY23;
CX3 -= FDY31;
}
CY1 += FDX12;
CY2 += FDX23;
CY3 += FDX31;
buffer += stride;
}
}
}
colorBuffer += q * stride;
}
}
template <typename AryBase, typename Point>
void add_triangle(AryBase *im, const Point &tv1, const Point &tv2, const Point &v3, typename AryBase::value value)
{
Point v1, v2;
// negative => CW, positive => CCW
if (((tv1.x-tv2.x)*(tv2.y-v3.y) - (tv1.y-tv2.y)*(tv2.x-v3.x))<0)
{
v1 = tv1; v2=tv2;
} else {
v1 = tv2; v2=tv1;
}
// routine from: Nicolas Capens (http://www.devmaster.net/codespotlight/show.php?id=17)
// 28.4 fixed-point coordinates
const int Y1 = int(16.0f * v1.y);
const int Y2 = int(16.0f * v2.y);
const int Y3 = int(16.0f * v3.y);
const int X1 = int(16.0f * v1.x);
const int X2 = int(16.0f * v2.x);
const int X3 = int(16.0f * v3.x);
// Deltas
const int DX12 = X1 - X2;
const int DX23 = X2 - X3;
const int DX31 = X3 - X1;
const int DY12 = Y1 - Y2;
const int DY23 = Y2 - Y3;
const int DY31 = Y3 - Y1;
// Fixed-point deltas
const int FDX12 = DX12 << 4;
const int FDX23 = DX23 << 4;
const int FDX31 = DX31 << 4;
const int FDY12 = DY12 << 4;
const int FDY23 = DY23 << 4;
const int FDY31 = DY31 << 4;
// Bounding rectangle
int minx = (min(X1, X2, X3) + 0xF) >> 4;
int maxx = (max(X1, X2, X3) + 0xF) >> 4;
int miny = (min(Y1, Y2, Y3) + 0xF) >> 4;
int maxy = (max(Y1, Y2, Y3) + 0xF) >> 4;
// Check image boundaries
minx = min(max(im->lb2, minx), im->ub2+1);
maxx = max(min(maxx, im->ub2+1), im->lb2);
miny = min(max(im->lb1, miny), im->ub1+1);
maxy = max(min(maxy, im->ub1+1), im->lb1);
// Block size, standard 8x8 (must be power of two)
const int q = 8;
// Start in corner of 8x8 block
minx &= ~(q - 1);
miny &= ~(q - 1);
const int stride = im->cols();
typename AryBase::pointer colorBuffer = &im->el[miny][0]; // (char*&)colorBuffer += miny * stride;
// Half-edge constants
int C1 = DY12 * X1 - DX12 * Y1;
int C2 = DY23 * X2 - DX23 * Y2;
int C3 = DY31 * X3 - DX31 * Y3;
// Correct for fill convention
if(DY12 < 0 || (DY12 == 0 && DX12 > 0)) C1++;
if(DY23 < 0 || (DY23 == 0 && DX23 > 0)) C2++;
if(DY31 < 0 || (DY31 == 0 && DX31 > 0)) C3++;
// Loop through blocks
for(int y = miny; y < maxy; y += q)
{
for(int x = minx; x < maxx; x += q)
{
// Corners of block
int x0 = x << 4;
int x1 = (x + q - 1) << 4;
int y0 = y << 4;
int y1 = (y + q - 1) << 4;
// Evaluate half-space functions
bool a00 = C1 + DX12 * y0 - DY12 * x0 > 0;
bool a10 = C1 + DX12 * y0 - DY12 * x1 > 0;
bool a01 = C1 + DX12 * y1 - DY12 * x0 > 0;
bool a11 = C1 + DX12 * y1 - DY12 * x1 > 0;
int a = (a00 << 0) | (a10 << 1) | (a01 << 2) | (a11 << 3);
bool b00 = C2 + DX23 * y0 - DY23 * x0 > 0;
bool b10 = C2 + DX23 * y0 - DY23 * x1 > 0;
bool b01 = C2 + DX23 * y1 - DY23 * x0 > 0;
bool b11 = C2 + DX23 * y1 - DY23 * x1 > 0;
int b = (b00 << 0) | (b10 << 1) | (b01 << 2) | (b11 << 3);
bool c00 = C3 + DX31 * y0 - DY31 * x0 > 0;
bool c10 = C3 + DX31 * y0 - DY31 * x1 > 0;
bool c01 = C3 + DX31 * y1 - DY31 * x0 > 0;
bool c11 = C3 + DX31 * y1 - DY31 * x1 > 0;
int c = (c00 << 0) | (c10 << 1) | (c01 << 2) | (c11 << 3);
// Skip block when outside an edge
if(a == 0x0 || b == 0x0 || c == 0x0) continue;
typename AryBase::pointer buffer = colorBuffer;
int limy = min(maxy, y+q); // don't go bellow the border
int limx = min(maxx, x+q); // don't go bellow the border
// Accept whole block when totally covered
if(a == 0xF && b == 0xF && c == 0xF)
{
for(int iy = y; iy < limy; iy++)
{
for(int ix = x; ix < limx; ix++)
buffer[ix] += value;
buffer += stride;
}
}
else // Partially covered block
{
int CY1 = C1 + DX12 * y0 - DY12 * x0;
int CY2 = C2 + DX23 * y0 - DY23 * x0;
int CY3 = C3 + DX31 * y0 - DY31 * x0;
for(int iy = y; iy < limy; iy++)
{
int CX1 = CY1;
int CX2 = CY2;
int CX3 = CY3;
for(int ix = x; ix < limx; ix++)
{
if(CX1 > 0 && CX2 > 0 && CX3 > 0)
buffer[ix] += value;
CX1 -= FDY12;
CX2 -= FDY23;
CX3 -= FDY31;
}
CY1 += FDX12;
CY2 += FDX23;
CY3 += FDX31;
buffer += stride;
}
}
}
colorBuffer += q * stride;
}
}
template <typename AryBase, typename Point>
void fill_quad(AryBase *im,
const Point &v1, const Point &v2, const Point &v3, const Point &v4,
typename AryBase::value fill)
{
// routine from: Nicolas Capens (http://www.devmaster.net/codespotlight/show.php?id=17)
// 28.4 fixed-point coordinates
const int Y1 = int(16.0f * v1.y);
const int Y2 = int(16.0f * v2.y);
const int Y3 = int(16.0f * v3.y);
const int Y4 = int(16.0f * v4.y);
const int X1 = int(16.0f * v1.x);
const int X2 = int(16.0f * v2.x);
const int X3 = int(16.0f * v3.x);
const int X4 = int(16.0f * v4.x);
// Deltas
const int DX12 = X1 - X2;
const int DX23 = X2 - X3;
const int DX34 = X3 - X4;
const int DX41 = X4 - X1;
const int DY12 = Y1 - Y2;
const int DY23 = Y2 - Y3;
const int DY34 = Y3 - Y4;
const int DY41 = Y4 - Y1;
// Fixed-point deltas
const int FDX12 = DX12 << 4;
const int FDX23 = DX23 << 4;
const int FDX34 = DX34 << 4;
const int FDX41 = DX41 << 4;
const int FDY12 = DY12 << 4;
const int FDY23 = DY23 << 4;
const int FDY34 = DY34 << 4;
const int FDY41 = DY41 << 4;
// Bounding rectangle
int minx = (utls::min(X1, X2, X3, X4) + 0xF) >> 4;
int maxx = (utls::max(X1, X2, X3, X4) + 0xF) >> 4;
int miny = (utls::min(Y1, Y2, Y3, Y4) + 0xF) >> 4;
int maxy = (utls::max(Y1, Y2, Y3, Y4) + 0xF) >> 4;
// Check image boundaries
minx = min(max(im->lb2, minx), im->ub2+1);
maxx = max(min(maxx, im->ub2+1), im->lb2);
miny = min(max(im->lb1, miny), im->ub1+1);
maxy = max(min(maxy, im->ub1+1), im->lb1);
// Block size, standard 8x8 (must be power of two)
const int q = 8;
// Start in corner of 8x8 block
minx &= ~(q - 1);
miny &= ~(q - 1);
const int stride = im->cols();
typename AryBase::pointer colorBuffer = &im->el[miny][0];// (char*&)colorBuffer += miny * stride;
// Half-edge constants
int C1 = DY12 * X1 - DX12 * Y1;
int C2 = DY23 * X2 - DX23 * Y2;
int C3 = DY34 * X3 - DX34 * Y3;
int C4 = DY41 * X4 - DX41 * Y4;
// Correct for fill convention
if(DY12 < 0 || (DY12 == 0 && DX12 > 0)) C1++;
if(DY23 < 0 || (DY23 == 0 && DX23 > 0)) C2++;
if(DY34 < 0 || (DY34 == 0 && DX34 > 0)) C3++;
if(DY41 < 0 || (DY41 == 0 && DX41 > 0)) C4++;
// Loop through blocks
for(int y = miny; y < maxy; y += q)
{
for(int x = minx; x < maxx; x += q)
{
// Corners of block
int x0 = x << 4;
int x1 = (x + q - 1) << 4;
int y0 = y << 4;
int y1 = (y + q - 1) << 4;
// Evaluate half-space functions
bool a00 = C1 + DX12 * y0 - DY12 * x0 > 0;
bool a10 = C1 + DX12 * y0 - DY12 * x1 > 0;
bool a01 = C1 + DX12 * y1 - DY12 * x0 > 0;
bool a11 = C1 + DX12 * y1 - DY12 * x1 > 0;
int a = (a00 << 0) | (a10 << 1) | (a01 << 2) | (a11 << 3);
bool b00 = C2 + DX23 * y0 - DY23 * x0 > 0;
bool b10 = C2 + DX23 * y0 - DY23 * x1 > 0;
bool b01 = C2 + DX23 * y1 - DY23 * x0 > 0;
bool b11 = C2 + DX23 * y1 - DY23 * x1 > 0;
int b = (b00 << 0) | (b10 << 1) | (b01 << 2) | (b11 << 3);
bool c00 = C3 + DX34 * y0 - DY34 * x0 > 0;
bool c10 = C3 + DX34 * y0 - DY34 * x1 > 0;
bool c01 = C3 + DX34 * y1 - DY34 * x0 > 0;
bool c11 = C3 + DX34 * y1 - DY34 * x1 > 0;
int c = (c00 << 0) | (c10 << 1) | (c01 << 2) | (c11 << 3);
bool d00 = C4 + DX41 * y0 - DY41 * x0 > 0;
bool d10 = C4 + DX41 * y0 - DY41 * x1 > 0;
bool d01 = C4 + DX41 * y1 - DY41 * x0 > 0;
bool d11 = C4 + DX41 * y1 - DY41 * x1 > 0;
int d = (d00 << 0) | (d10 << 1) | (d01 << 2) | (d11 << 3);
// Skip block when outside an edge
if (a == 0x0 || b == 0x0 || c == 0x0 || d == 0x0) continue;
typename AryBase::pointer buffer = colorBuffer;
int limy = min(maxy, y+q); // don't go bellow the border
int limx = min(maxx, x+q); // don't go bellow the border
// Accept whole block when totally covered
if(a == 0xF && b == 0xF && c == 0xF && d == 0xF)
{
for(int iy = y; iy < limy; iy++)
{
for(int ix = x; ix < limx; ix++)
buffer[ix] = fill;
buffer += stride;
}
}
else // Partially covered block
{
int CY1 = C1 + DX12 * y0 - DY12 * x0;
int CY2 = C2 + DX23 * y0 - DY23 * x0;
int CY3 = C3 + DX34 * y0 - DY34 * x0;
int CY4 = C4 + DX41 * y0 - DY41 * x0;
for(int iy = y; iy < limy; iy++)
{
int CX1 = CY1;
int CX2 = CY2;
int CX3 = CY3;
int CX4 = CY4;
for(int ix = x; ix < limx; ix++)
{
if(CX1 > 0 && CX2 > 0 && CX3 > 0 && CX4 > 0)
buffer[ix] = fill;
CX1 -= FDY12;
CX2 -= FDY23;
CX3 -= FDY34;
CX4 -= FDY41;
}
CY1 += FDX12;
CY2 += FDX23;
CY3 += FDX34;
CY4 += FDX41;
buffer += stride;
}
}
}
colorBuffer += q * stride;
}
}
template <typename AryBase, typename Point>
void add_quad(AryBase *im,
const Point &v1, const Point &v2, const Point &v3, const Point &v4,
typename AryBase::value value)
{
// routine from: Nicolas Capens (http://www.devmaster.net/codespotlight/show.php?id=17)
// 28.4 fixed-point coordinates
const int Y1 = int(16.0f * v1.y);
const int Y2 = int(16.0f * v2.y);
const int Y3 = int(16.0f * v3.y);
const int Y4 = int(16.0f * v4.y);
const int X1 = int(16.0f * v1.x);
const int X2 = int(16.0f * v2.x);
const int X3 = int(16.0f * v3.x);
const int X4 = int(16.0f * v4.x);
// Deltas
const int DX12 = X1 - X2;
const int DX23 = X2 - X3;
const int DX34 = X3 - X4;
const int DX41 = X4 - X1;
const int DY12 = Y1 - Y2;
const int DY23 = Y2 - Y3;
const int DY34 = Y3 - Y4;
const int DY41 = Y4 - Y1;
// Fixed-point deltas
const int FDX12 = DX12 << 4;
const int FDX23 = DX23 << 4;
const int FDX34 = DX34 << 4;
const int FDX41 = DX41 << 4;
const int FDY12 = DY12 << 4;
const int FDY23 = DY23 << 4;
const int FDY34 = DY34 << 4;
const int FDY41 = DY41 << 4;
// Bounding rectangle
int minx = (min(X1, X2, X3, X4) + 0xF) >> 4;
int maxx = (max(X1, X2, X3, X4) + 0xF) >> 4;
int miny = (min(Y1, Y2, Y3, Y4) + 0xF) >> 4;
int maxy = (max(Y1, Y2, Y3, Y4) + 0xF) >> 4;
// Check image boundaries
minx = min(max(im->lb2, minx), im->ub2+1);
maxx = max(min(maxx, im->ub2+1), im->lb2);
miny = min(max(im->lb1, miny), im->ub1+1);
maxy = max(min(maxy, im->ub1+1), im->lb1);
// Block size, standard 8x8 (must be power of two)
const int q = 8;
// Start in corner of 8x8 block
minx &= ~(q - 1);
miny &= ~(q - 1);
const int stride = im->cols();
typename AryBase::pointer colorBuffer = &im->el[miny][0];// (char*&)colorBuffer += miny * stride;
// Half-edge constants
int C1 = DY12 * X1 - DX12 * Y1;
int C2 = DY23 * X2 - DX23 * Y2;
int C3 = DY34 * X3 - DX34 * Y3;
int C4 = DY41 * X4 - DX41 * Y4;
// Correct for fill convention
if(DY12 < 0 || (DY12 == 0 && DX12 > 0)) C1++;
if(DY23 < 0 || (DY23 == 0 && DX23 > 0)) C2++;
if(DY34 < 0 || (DY34 == 0 && DX34 > 0)) C3++;
if(DY41 < 0 || (DY41 == 0 && DX41 > 0)) C4++;
// Loop through blocks
for(int y = miny; y < maxy; y += q)
{
for(int x = minx; x < maxx; x += q)
{
// Corners of block
int x0 = x << 4;
int x1 = (x + q - 1) << 4;
int y0 = y << 4;
int y1 = (y + q - 1) << 4;
// Evaluate half-space functions
bool a00 = C1 + DX12 * y0 - DY12 * x0 > 0;
bool a10 = C1 + DX12 * y0 - DY12 * x1 > 0;
bool a01 = C1 + DX12 * y1 - DY12 * x0 > 0;
bool a11 = C1 + DX12 * y1 - DY12 * x1 > 0;
int a = (a00 << 0) | (a10 << 1) | (a01 << 2) | (a11 << 3);
bool b00 = C2 + DX23 * y0 - DY23 * x0 > 0;
bool b10 = C2 + DX23 * y0 - DY23 * x1 > 0;
bool b01 = C2 + DX23 * y1 - DY23 * x0 > 0;
bool b11 = C2 + DX23 * y1 - DY23 * x1 > 0;
int b = (b00 << 0) | (b10 << 1) | (b01 << 2) | (b11 << 3);
bool c00 = C3 + DX34 * y0 - DY34 * x0 > 0;
bool c10 = C3 + DX34 * y0 - DY34 * x1 > 0;
bool c01 = C3 + DX34 * y1 - DY34 * x0 > 0;
bool c11 = C3 + DX34 * y1 - DY34 * x1 > 0;
int c = (c00 << 0) | (c10 << 1) | (c01 << 2) | (c11 << 3);
bool d00 = C4 + DX41 * y0 - DY41 * x0 > 0;
bool d10 = C4 + DX41 * y0 - DY41 * x1 > 0;
bool d01 = C4 + DX41 * y1 - DY41 * x0 > 0;
bool d11 = C4 + DX41 * y1 - DY41 * x1 > 0;
int d = (d00 << 0) | (d10 << 1) | (d01 << 2) | (d11 << 3);
// Skip block when outside an edge
if (a == 0x0 || b == 0x0 || c == 0x0 || d == 0x0) continue;
typename AryBase::pointer buffer = colorBuffer;
int limy = min(maxy, y+q); // don't go bellow the border
int limx = min(maxx, x+q); // don't go bellow the border
// Accept whole block when totally covered
if(a == 0xF && b == 0xF && c == 0xF && d == 0xF)
{
for(int iy = y; iy < limy; iy++)
{
for(int ix = x; ix < limx; ix++)
buffer[ix] += value;
buffer += stride;
}
}
else // Partially covered block
{
int CY1 = C1 + DX12 * y0 - DY12 * x0;
int CY2 = C2 + DX23 * y0 - DY23 * x0;
int CY3 = C3 + DX34 * y0 - DY34 * x0;
int CY4 = C4 + DX41 * y0 - DY41 * x0;
for(int iy = y; iy < limy; iy++)
{
int CX1 = CY1;
int CX2 = CY2;
int CX3 = CY3;
int CX4 = CY4;
for(int ix = x; ix < limx; ix++)
{
if(CX1 > 0 && CX2 > 0 && CX3 > 0 && CX4 > 0)
buffer[ix] += value;
CX1 -= FDY12;
CX2 -= FDY23;
CX3 -= FDY34;
CX4 -= FDY41;
}
CY1 += FDX12;
CY2 += FDX23;
CY3 += FDX34;
CY4 += FDX41;
buffer += stride;
}
}
}
colorBuffer += q * stride;
}
}
}
| [
"c.lemaitre58@gmail.com"
] | c.lemaitre58@gmail.com |
55c6b5344cf48b5aa45abf337f39dd363d802748 | 972adac7d2bb3fc2b52fa4baf66165038e28dc47 | /src/option_parser_util.h | 9424abd68695f5e4bc13d00f245bd288d151bca8 | [] | no_license | Kurorororo/Arvand2011 | e217828d282e7519dcc57acaceccee5a38674995 | 05ca920d349768df9701f4238c6a7dac701328ac | refs/heads/master | 2021-01-25T08:07:34.922459 | 2015-09-18T04:49:51 | 2015-09-18T04:49:51 | 93,720,204 | 0 | 0 | null | 2017-06-08T07:30:51 | 2017-06-08T07:30:51 | null | UTF-8 | C++ | false | false | 9,418 | h | #ifndef OPTION_PARSER_UTIL_H
#define OPTION_PARSER_UTIL_H
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <ios>
#include <tree.hh>
#include <tree_util.hh>
#include <boost/any.hpp>
class LandmarkGraph;
class Heuristic;
class ScalarEvaluator;
class Synergy;
class SearchEngine;
class OptionParser;
// added by Hootan
// begin
class Simulator;
class Analyzer;
class Postprocessor;
// end
template<class Entry>
class OpenList;
struct ParseNode {
ParseNode()
: value(""),
key("") {
}
ParseNode(std::string val, std::string k = "")
: value(val),
key(k) {
}
std::string value;
std::string key;
friend std::ostream & operator<<(std::ostream &out, const ParseNode &pn) {
if (pn.key.compare("") != 0)
out << pn.key << " = ";
out << pn.value;
return out;
}
};
typedef tree<ParseNode> ParseTree;
struct ParseError {
ParseError(std::string m, ParseTree pt);
std::string msg;
ParseTree parse_tree;
friend std::ostream &operator<<(std::ostream &out, const ParseError &pe) {
out << "Parse Error: " << std::endl
<< pe.msg << " at: " << std::endl;
kptree::print_tree_bracketed<ParseNode>(pe.parse_tree, out);
out << std::endl;
return out;
}
};
//a registry<T> maps a string to a T-factory
template <class T>
class Registry {
public:
typedef T (*Factory)(OptionParser &);
static Registry<T> *instance() {
if (!instance_) {
instance_ = new Registry<T>();
}
return instance_;
}
void register_object(std::string k, Factory f) {
transform(k.begin(), k.end(), k.begin(), ::tolower); //k to lowercase
registered[k] = f;
}
bool contains(std::string k) {
return registered.find(k) != registered.end();
}
Factory get(std::string k) {
return registered[k];
}
std::vector<std::string> get_keys() {
std::vector<std::string> keys;
for (typename std::map<std::string, Factory>::iterator it =
registered.begin();
it != registered.end(); ++it) {
keys.push_back(it->first);
}
return keys;
}
private:
Registry() {}
static Registry<T> *instance_;
std::map<std::string, Factory> registered;
};
template <class T>
Registry<T> *Registry<T>::instance_ = 0;
//Predefinitions<T> maps strings to pointers to
//already created Heuristics/LandmarkGraphs
template <class T>
class Predefinitions {
public:
static Predefinitions<T> *instance() {
if (!instance_) {
instance_ = new Predefinitions<T>();
}
return instance_;
}
void predefine(std::string k, T obj) {
transform(k.begin(), k.end(), k.begin(), ::tolower);
predefined[k] = obj;
}
bool contains(std::string k) {
return predefined.find(k) != predefined.end();
}
T get(std::string k) {
return predefined[k];
}
private:
Predefinitions<T>() {}
static Predefinitions<T> *instance_;
std::map<std::string, T> predefined;
};
template <class T>
Predefinitions<T> *Predefinitions<T>::instance_ = 0;
struct Synergy {
std::vector<Heuristic *> heuristics;
};
//TypeNamer prints out names of types.
//There's something built in for this (typeid().name()), but the output is not always very readable
template <class T>
struct TypeNamer {
static std::string name() {
return typeid(T()).name();
}
};
template <>
struct TypeNamer<int> {
static std::string name() {
return "int";
}
};
template <>
struct TypeNamer<bool> {
static std::string name() {
return "bool";
}
};
template <>
struct TypeNamer<double> {
static std::string name() {
return "double";
}
};
template <>
struct TypeNamer<std::string> {
static std::string name() {
return "string";
}
};
template <>
struct TypeNamer<Heuristic *> {
static std::string name() {
return "heuristic";
}
};
template <>
struct TypeNamer<LandmarkGraph *> {
static std::string name() {
return "landmarks graph";
}
};
template <>
struct TypeNamer<ScalarEvaluator *> {
static std::string name() {
return "scalar evaluator";
}
};
// Hootan_edit
// begin
template <>
struct TypeNamer<Simulator *> {
static std::string name() {
return "simulator";
}
};
template <>
struct TypeNamer<Analyzer *> {
static std::string name() {
return "analyzer";
}
};
template <>
struct TypeNamer<Postprocessor *> {
static std::string name() {
return "postprocessor";
}
};
// end
template <>
struct TypeNamer<SearchEngine *> {
static std::string name() {
return "search engine";
}
};
template <>
struct TypeNamer<ParseTree> {
static std::string name() {
return "parse tree (this just means the input is parsed at a later point. The real type is probably a search engine.)";
}
};
template <>
struct TypeNamer<Synergy *> {
static std::string name() {
return "synergy";
}
};
template <class Entry>
struct TypeNamer<OpenList<Entry> *> {
static std::string name() {
return "openlist";
}
};
template <class T>
struct TypeNamer<std::vector<T> > {
static std::string name() {
return "list of " + TypeNamer<T>::name();
}
};
//DefaultValueNamer is for printing default values.
//Maybe a better solution would be to implement "<<" for everything that's needed. Don't know.
template <class T>
struct DefaultValueNamer {
static std::string to_str(T val) {
std::ostringstream strs;
strs << std::boolalpha << val;
return strs.str();
}
};
template <>
struct DefaultValueNamer<ParseTree> {
static std::string to_str(ParseTree val) {
return "implement default value naming for parse trees!"
+ val.begin()->value;
}
};
template <class T>
struct DefaultValueNamer<std::vector<T> > {
static std::string to_str(std::vector<T> val) {
std::string s = "[";
for (size_t i(0); i != val.size(); ++i) {
s += DefaultValueNamer<T>::to_str(val[i]);
}
s += "]";
return s;
}
};
//helper functions for the ParseTree (=tree<ParseNode>)
template<class T>
typename tree<T>::sibling_iterator last_child(
const tree<T> &tr, typename tree<T>::sibling_iterator ti) {
return --tr.end(ti);
}
template<class T>
typename tree<T>::sibling_iterator last_child_of_root(const tree<T> &tr) {
return last_child(tr, tr.begin());
}
template<class T>
typename tree<T>::sibling_iterator first_child(
const tree<T> &tr, typename tree<T>::sibling_iterator ti) {
return tr.begin(ti);
}
template<class T>
typename tree<T>::sibling_iterator first_child_of_root(const tree<T> &tr) {
return first_child(tr, tr.begin());
}
template<class T>
typename tree<T>::sibling_iterator end_of_roots_children(const tree<T> &tr) {
return tr.end(tr.begin());
}
template<class T>
tree<T> subtree(
const tree<T> &tr, typename tree<T>::sibling_iterator ti) {
typename tree<T>::sibling_iterator ti_next = ti;
++ti_next;
return tr.subtree(ti, ti_next);
}
//Options is just a wrapper for map<string, boost::any>
class Options {
public:
Options(bool hm = false)
: help_mode(hm) {
}
void set_help_mode(bool hm) {
help_mode = hm;
}
std::map<std::string, boost::any> storage;
template <class T>
void set(std::string key, T value) {
storage[key] = value;
}
template <class T>
T get(std::string key) const {
std::map<std::string, boost::any>::const_iterator it;
it = storage.find(key);
if (it == storage.end()) {
std::cout << "attempt to retrieve nonexisting object of name "
<< key << " (type: " << TypeNamer<T>::name() << ")"
<< " from Options. Aborting." << std::endl;
exit(1);
}
try {
T result = boost::any_cast<T>(it->second);
return result;
} catch (const boost::bad_any_cast &bac) {
std::cout << "Invalid conversion while retrieving config options!"
<< std::endl
<< key << " is not of type " << TypeNamer<T>::name()
<< std::endl << "exiting" << std::endl;
exit(1);
}
}
template <class T>
void verify_list_non_empty(std::string key) const {
if (!help_mode) {
std::vector<T> temp_vec = get<std::vector<T> >(key);
if (temp_vec.empty()) {
std::cout << "Error: unexpected empty list!"
<< std::endl
<< "List " << key << " is empty"
<< std::endl;
exit(1);
}
}
}
template <class T>
std::vector<T> get_list(std::string key) const {
return get<std::vector<T> >(key);
}
int get_enum(std::string key) const {
return get<int>(key);
}
bool contains(std::string key) const {
return storage.find(key) != storage.end();
}
private:
bool help_mode;
};
struct OptionFlags {
OptionFlags(bool mand = true)
: mandatory(mand) {
}
bool mandatory;
};
#endif
| [
"nhootan@gmail.com"
] | nhootan@gmail.com |
3a678e547c7dbd0212741971419d41eec180d38a | 9b29326bc61126226efd24e76c618c8eccbd14d5 | /test/itkSupportInputPolyDataTypesTest.cxx | 44f8fbe146a913981cddd267f74dc019c2e7c51b | [
"Apache-2.0"
] | permissive | floryst/itk-js | 5ccf2095bc0ddc50373db9a56b98cdcffd56d85d | 7b572ff873947778533d125fb3c94f8b461f9520 | refs/heads/master | 2022-05-06T07:28:20.610621 | 2022-04-06T18:50:28 | 2022-04-06T18:50:28 | 133,382,755 | 0 | 0 | null | 2018-05-14T15:27:58 | 2018-05-14T15:27:57 | null | UTF-8 | C++ | false | false | 1,906 | cxx | /*=========================================================================
*
* Copyright NumFOCUS
*
* 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.txt
*
* 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 "itkPipeline.h"
#include "itkInputPolyData.h"
#include "itkOutputPolyData.h"
#include "itkSupportInputPolyDataTypes.h"
#include "itkWASMMeshIOFactory.h"
template<typename TPolyData>
class PipelineFunctor
{
public:
int operator()(itk::wasm::Pipeline & pipeline)
{
using PolyDataType = TPolyData;
using InputPolyDataType = itk::wasm::InputPolyData<PolyDataType>;
InputPolyDataType inputPolyData;
pipeline.add_option("InputPolyData", inputPolyData, "The input mesh")->required();
using OutputPolyDataType = itk::wasm::OutputPolyData<PolyDataType>;
OutputPolyDataType outputPolyData;
pipeline.add_option("OutputPolyData", outputPolyData, "The output mesh")->required();
ITK_WASM_PARSE(pipeline);
outputPolyData.Set(inputPolyData.Get());
return EXIT_SUCCESS;
}
};
int
itkSupportInputPolyDataTypesTest(int argc, char * argv[])
{
itk::wasm::Pipeline pipeline("Test supporting multiple input mesh types", argc, argv);
itk::WASMMeshIOFactory::RegisterOneFactory();
return itk::wasm::SupportInputPolyDataTypes<PipelineFunctor>
::PixelTypes<uint8_t, float>("InputPolyData", pipeline);
}
| [
"matt.mccormick@kitware.com"
] | matt.mccormick@kitware.com |
6bc6131180fc34d46df26117144587d782a18683 | d63b1b36634b68070f6f3c017c0250a7ea646e6f | /SMC/GEM5/utils/cacti65/arbiter.h | 8e9c82169d5803cd802cdcfa44a0bba50b9258c0 | [
"MIT"
] | permissive | jiwon-choe/Brown-SMCSim | ccf506d34d85fb3d085bf50ed47de8b4eeaee474 | ff3d9334c1d5c8d6a00421848c0d51e50e6b67f8 | refs/heads/master | 2021-06-30T00:15:57.128209 | 2020-11-24T03:11:41 | 2020-11-24T03:11:41 | 192,596,189 | 15 | 8 | MIT | 2019-06-20T15:43:00 | 2019-06-18T18:53:40 | C++ | UTF-8 | C++ | false | false | 3,297 | h | /*------------------------------------------------------------
* CACTI 6.5
* Copyright 2008 Hewlett-Packard Development Corporation
* All Rights Reserved
*
* Permission to use, copy, and modify this software and its documentation is
* hereby granted only under the following terms and conditions. Both the
* above copyright notice and this permission notice must appear in all copies
* of the software, derivative works or modified versions, and any portions
* thereof, and both notices must appear in supporting documentation.
*
* Users of this software agree to the terms and conditions set forth herein, and
* hereby grant back to Hewlett-Packard Company and its affiliated companies ("HP")
* a non-exclusive, unrestricted, royalty-free right and license under any changes,
* enhancements or extensions made to the core functions of the software, including
* but not limited to those affording compatibility with other hardware or software
* environments, but excluding applications which incorporate this software.
* Users further agree to use their best efforts to return to HP any such changes,
* enhancements or extensions that they make and inform HP of noteworthy uses of
* this software. Correspondence should be provided to HP at:
*
* Director of Intellectual Property Licensing
* Office of Strategy and Technology
* Hewlett-Packard Company
* 1501 Page Mill Road
* Palo Alto, California 94304
*
* This software may be distributed (but not offered for sale or transferred
* for compensation) to third parties, provided such third parties agree to
* abide by the terms and conditions of this notice.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND HP DISCLAIMS ALL
* WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL HP
* CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*------------------------------------------------------------*/
#ifndef __ARBITER__
#define __ARBITER__
#include <assert.h>
#include <iostream>
#include "basic_circuit.h"
#include "cacti_interface.h"
#include "component.h"
#include "parameter.h"
#include "mat.h"
#include "wire.h"
class Arbiter : public Component
{
public:
Arbiter(
double Req,
double flit_sz,
double output_len,
TechnologyParameter::DeviceType *dt = &(g_tp.peri_global));
~Arbiter();
void print_arbiter();
double arb_req();
double arb_pri();
double arb_grant();
double arb_int();
void compute_power();
double Cw3(double len);
double crossbar_ctrline();
double transmission_buf_ctrcap();
private:
double NTn1, PTn1, NTn2, PTn2, R, PTi, NTi;
double flit_size;
double NTtr, PTtr;
double o_len;
TechnologyParameter::DeviceType *deviceType;
double TriS1, TriS2;
double min_w_pmos, Vdd;
};
#endif
| [
"brandnew7th@gmail.com"
] | brandnew7th@gmail.com |
3e0a10a7ea87b4394bb8ad24c9a4a7ce55da3b59 | 43334384ff8cc65b29301659bbd5a63f4bfae378 | /fairmq/FairMQConfigurable.h | 1854f404f958fa94ef6400ba7d72845a5f646834 | [] | no_license | yeleisun/SpiRITROOT | b11027e50cfe7e0c9017c24f8cec3db80e73b3a8 | c8717f19547a948400b687c070110c4d67a9ea2d | refs/heads/master | 2021-01-19T20:34:29.012437 | 2014-08-22T02:12:25 | 2014-08-22T02:12:25 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 748 | h | /*
* FairMQConfigurable.h
*
* Created on: Oct 25, 2012
* Author: dklein
*/
#ifndef FAIRMQCONFIGURABLE_H_
#define FAIRMQCONFIGURABLE_H_
#include "Rtypes.h"
#include "TString.h"
class FairMQConfigurable
{
public:
enum {
Last = 1
};
FairMQConfigurable();
virtual void SetProperty(const Int_t& key, const TString& value, const Int_t& slot = 0);
virtual TString GetProperty(const Int_t& key, const TString& default_ = "", const Int_t& slot = 0);
virtual void SetProperty(const Int_t& key, const Int_t& value, const Int_t& slot = 0);
virtual Int_t GetProperty(const Int_t& key, const Int_t& default_ = 0, const Int_t& slot = 0);
virtual ~FairMQConfigurable();
};
#endif /* FAIRMQCONFIGURABLE_H_ */
| [
"geniejhang@majimak.com"
] | geniejhang@majimak.com |
063c7efdfeb5b7bf46919c827e90cf0814f84468 | 37c52162994d595cd0592dc2a5b73b91d61d6313 | /include/Awl/boost/mpl/aux_/has_tag.hpp | c06f3163d365be9dbcf64352377daf9e5eaf4318 | [
"Zlib",
"BSL-1.0"
] | permissive | Yalir/Awl | 47db2b5976ab9f584044287ac1ef36860a3e944e | 92ef5996d8933bf92ceb37357d8cd2b169cb788e | refs/heads/master | 2020-04-05T04:27:16.143511 | 2013-04-12T11:36:51 | 2013-04-12T11:36:51 | 2,344,212 | 5 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 681 | hpp |
#ifndef BOOST_MPL_AUX_HAS_TAG_HPP_INCLUDED
#define BOOST_MPL_AUX_HAS_TAG_HPP_INCLUDED
// Copyright Aleksey Gurtovoy 2002-2004
//
// 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)
//
// See http://www.boost.org/libs/mpl for documentation.
// $Id: has_tag.hpp 49267 2008-10-11 06:19:02Z agurtovoy $
// $Date: 2008-10-11 02:19:02 -0400 (Sat, 11 Oct 2008) $
// $Revision: 49267 $
#include <Awl/boost/mpl/has_xxx.hpp>
namespace boost { namespace mpl { namespace aux {
BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(has_tag, tag, false)
}}}
#endif // BOOST_MPL_AUX_HAS_TAG_HPP_INCLUDED
| [
"soltic.lucas@gmail.com"
] | soltic.lucas@gmail.com |
536d1f0562960cf03059f9bb958c2524b1208365 | ae32a67ea6e9fd590144a22678a863b075d5b3a5 | /libraries/absyn/bnf/item.h | 5dd3de905451d48e64eff5539f62ab6dceb932bd | [] | no_license | annlova/uside | 7be22f7e45f8b2c40b27dbb0e556f7dd53457090 | 97b2f01be198c455dd044f845a555d95703340b9 | refs/heads/master | 2023-06-07T05:06:53.866343 | 2021-06-18T05:38:03 | 2021-06-18T05:38:03 | 369,805,718 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,033 | h | //
// Created by Anton on 2021-05-28.
//
#ifndef USIDE_LIBRARIES_ABSYN_BNF_ITEM_H
#define USIDE_LIBRARIES_ABSYN_BNF_ITEM_H
#include "cat.h"
namespace absyn::bnf {
struct Item {
Item() = default;
virtual ~Item() = default;
Item(Item& grammar) = delete;
Item(Item&& grammar) = delete;
Item& operator=(Item& other) = delete;
Item& operator=(Item&& other) = delete;
virtual void accept(struct ItemVisitor& v) const = 0;
};
class ItemString : public Item {
public:
ItemString() : mV1{nullptr} {}
~ItemString() override { delete[] mV1; }
ItemString(ItemString& itemString) = delete;
ItemString(ItemString&& itemString) = delete;
ItemString& operator=(ItemString& other) = delete;
ItemString& operator=(ItemString&& other) = delete;
void accept(ItemVisitor& v) const override;
[[nodiscard]] const char* v1() const { return mV1; }
private:
const char* mV1;
};
class ItemCat : public Item {
public:
ItemCat() : mV1{nullptr} {}
~ItemCat() override { delete mV1; }
ItemCat(ItemCat& itemCat) = delete;
ItemCat(ItemCat&& itemCat) = delete;
ItemCat& operator=(ItemCat& other) = delete;
ItemCat& operator=(ItemCat&& other) = delete;
void accept(ItemVisitor& v) const override;
[[nodiscard]] const Cat& v1() const { return *mV1; }
private:
const Cat* mV1;
};
struct ItemVisitor {
virtual void visit(const ItemString& token) = 0;
virtual void visit(const ItemCat& token) = 0;
};
typedef void (DestructFn)(void*);
typedef void (ItemAcceptFn)(void*, ItemVisitor& v);
struct ItemVTable {
DestructFn* mDestructFn1;
DestructFn* mDestructFn2;
ItemAcceptFn* mAcceptFn;
};
inline ItemVTable* getVTable(Item* obj) {
auto** vtablePtr = reinterpret_cast<ItemVTable**>(obj); // NOLINT(cppcoreguidelines-pro-type-reinterpret-cast)
return *(vtablePtr);
}
}
#endif //USIDE_LIBRARIES_ABSYN_BNF_ITEM_H
| [
"anton.annlov@gmail.com"
] | anton.annlov@gmail.com |
59598b2c93377c316af083f6e517d611f628c6cd | 27b24f30cb78b22f926d111716ff608003d46e3b | /Practica5/practica_final_material/include/bintree.hxx | 2db1d33e1436866695b54c424aa63b09a5cc99fe | [] | no_license | JJavier98/ED | 9155e9d287caa37f475fca18cdfb836f9e3cf3fa | 3f003d9d47fc0cc959c46bfe1cdfc2622dfbb0f2 | refs/heads/master | 2021-09-03T23:02:19.826675 | 2018-01-12T18:04:26 | 2018-01-12T18:04:26 | 116,848,489 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 27,305 | hxx | //-*-Mode: C++;-*-
/*
************************************************************
* Implementaci��n
************************************************************
*/
/*
Funci��n de Abstracci��n:
----------------------
Dado el objeto del tipo rep r, r = {laraiz}, el objeto
abstracto al que representa es:
a) Arbol nulo, si r.laraiz.null().
b) Arbol con un ��nico nodo de etiqueta *(r.laraiz)
si r.laraiz.left().null() y r.laraiz.dcha().null()
c) *(r.laraiz)
/ \
/ \
Arbol(r.laraiz.left()) Arbol(r.laraiz.right())
Invariante de Representaci��n:
----------------------------
Si !r.laraiz.null(),
- r.laraiz.parent().null().
Para cualquier nodo n del ��rbol:
Si !n.left().null()
n.left().parent() == n;
Si !n.right().null()
n.right().parent() == n;
*/
#include <cassert>
/*____________________________________________________________ */
/*____________________________________________________________ */
// FUNCIONES PRIVADAS
/*____________________________________________________________ */
/*____________________________________________________________ */
template <typename T>
void bintree<T>::destroy(typename bintree<T>::node n)
{
if (!n.null()) {
destroy(n.left());
destroy(n.right());
n.remove();
}
}
/*____________________________________________________________ */
template <typename T>
void bintree<T>::copy(bintree<T>::node & dest, const bintree<T>::node & orig)
{
if (orig.null())
dest = typename bintree<T>::node();
else {
dest = node(*orig);
typename bintree<T>::node aux(dest.left());
copy (aux, orig.left());
dest.left(aux);
if (!dest.left().null())
dest.left().parent(dest);
aux = dest.right();
copy (aux, orig.right());
dest.right(aux);
if (!dest.right().null())
dest.right().parent(dest);
}
}
/*____________________________________________________________ */
template <typename T>
int bintree<T>::count(bintree<T>::node n) const
{
if (n.null())
return 0;
else
return 1 + count(n.left()) + count(n.right());
}
/*____________________________________________________________ */
template <typename T>
bool bintree<T>::equals(bintree<T>::node n1, bintree<T>::node n2) const
{
if (n1.null() && n2.null())
return true;
if (n1.null() || n2.null())
return false;
if (*n1 != *n2)
return false;
if (!equals(n1.left(),n2.left()))
return false;
if (!equals(n1.right(),n2.right()))
return false;
return true;
}
/*____________________________________________________________ */
/*____________________________________________________________ */
// FUNCIONES PUBLICAS
/*____________________________________________________________ */
/*____________________________________________________________ */
template <typename T>
inline
bintree<T>::bintree()
: num_nodos(0)
{
}
/*____________________________________________________________ */
template <typename T>
inline
bintree<T>::bintree(const T & e)
: laraiz(e), num_nodos(1)
{
}
/*____________________________________________________________ */
template <typename T>
inline
bintree<T>::bintree(const bintree<T> & a)
{
copy(laraiz, a.laraiz);
if (!laraiz.null())
laraiz.parent(typename bintree<T>::node());
num_nodos = a.num_nodos;
}
/*____________________________________________________________ */
template <typename T>
void bintree<T>::assign_subtree(const bintree<T> & a,
typename bintree<T>::node n)
{
if (&a != this) {
destroy(laraiz);
num_nodos = count(n);
copy(laraiz, n);
if (!laraiz.null())
laraiz.parent(typename bintree<T>::node());
} else { // Reemplazar el receptor por un sub�rbol suyo.
if (laraiz != n) {
typename bintree<T>::node nod(laraiz);
num_nodos = count(n);
laraiz = n;
if (!n.null()) {
typename bintree<T>::node aux(n.parent());
if (n.parent().left() == n)
aux.left(typename bintree<T>::node());
else
aux.right(typename bintree<T>::node());
}
destroy(nod);
laraiz.parent(typename bintree<T>::node());
}
}
}
/*____________________________________________________________ */
template <typename T>
inline
bintree<T>::~bintree()
{
destroy(laraiz);
}
/*____________________________________________________________ */
template <typename T>
inline
bintree<T> &
bintree<T>::operator=(const bintree<T> & a)
{
if (&a != this) {
destroy(laraiz);
num_nodos = a.num_nodos;
copy(laraiz, a.laraiz);
if (!laraiz.null())
laraiz.parent(typename bintree<T>::node());
}
return *this;
}
/*____________________________________________________________ */
template <typename T>
inline
typename bintree<T>::node bintree<T>::root() const
{
return laraiz;
}
/*____________________________________________________________ */
template <typename T>
inline
void bintree<T>::prune_left(typename bintree<T>::node n,
bintree<T> & orig)
{
assert(!n.null());
destroy(orig.laraiz);
num_nodos = num_nodos - count(n.left());
orig.laraiz = n.left();
if (!orig.laraiz.null())
orig.laraiz.parent(typename bintree<T>::node());
n.left(typename bintree<T>::node());
}
/*____________________________________________________________ */
template <typename T>
inline
void bintree<T>::prune_right(typename bintree<T>::node n,
bintree<T> & orig)
{
assert(!n.null());
destroy(orig.laraiz);
num_nodos = num_nodos - count(n.right());
orig.laraiz = n.right();
num_nodos = num_nodos - count(n.right());
if (!orig.laraiz.null())
orig.laraiz.parent(typename bintree<T>::node());
n.right(typename bintree<T>::node());
}
/*____________________________________________________________ */
template <typename T>
inline
void bintree<T>::insert_left(const typename bintree<T>::node & n, const T & e)
{
bintree<T> aux(e);
insert_left(n, aux);
}
/*____________________________________________________________ */
template <typename T>
inline
void bintree<T>::insert_left(typename bintree<T>::node n,
bintree<T> & rama)
{
assert(!n.null());
num_nodos = num_nodos - count(n.left()) + rama.num_nodos;
typename bintree<T>::node aux(n.left());
destroy(aux);
n.left(rama.laraiz);
if (!n.left().null())
n.left().parent(n);
rama.laraiz = typename bintree<T>::node();
}
/*____________________________________________________________ */
template <typename T>
inline
void bintree<T>::insert_right(typename bintree<T>::node n, const T & e)
{
bintree<T> aux(e);
insert_right(n, aux);
}
/*____________________________________________________________ */
template <typename T>
inline
void bintree<T>::insert_right(typename bintree<T>::node n,
bintree<T> & rama)
{
assert(!n.null());
num_nodos = num_nodos - count(n.right()) + rama.num_nodos;
typename bintree<T>::node aux(n.right());
destroy(aux);
n.right(rama.laraiz);
if (!n.right().null())
n.right().parent(n);
rama.laraiz = typename bintree<T>::node();
}
/*____________________________________________________________ */
template <typename T>
void bintree<T>::clear()
{
destroy(laraiz);
laraiz = bintree<T>::node();
}
/*____________________________________________________________ */
template <typename T>
inline
typename bintree<T>::size_type bintree<T>::size() const
{
return num_nodos;
}
/*____________________________________________________________ */
template <typename T>
inline
bool bintree<T>::empty() const
{
return laraiz == bintree<T>::node();
}
/*____________________________________________________________ */
template <typename T>
inline
bool bintree<T>::operator==(const bintree<T> & a) const
{
return equals(laraiz, a.laraiz);
}
/*____________________________________________________________ */
template <typename T>
inline bool bintree<T>::operator!=(const bintree<T> & a) const
{
return !(*this == a);
}
/*
************************************************************
Iteradores
************************************************************
*/
/*
Iterador para recorrido en Preorden
*/
template <typename T>
inline
bintree<T>::preorder_iterator::preorder_iterator()
{
elnodo = typename bintree<T>::node();
}
template <typename T>
inline
bintree<T>::preorder_iterator::preorder_iterator(
const bintree<T>::preorder_iterator & i)
: elnodo(i.elnodo)
{
}
template <typename T>
inline
bintree<T>::preorder_iterator::preorder_iterator(bintree<T>::node n)
: elnodo(n)
{
}
template <typename T>
inline
bool bintree<T>::preorder_iterator::operator!=(
const bintree<T>::preorder_iterator & i) const
{
return elnodo != i.elnodo;
}
template <typename T>
inline
bool bintree<T>::preorder_iterator::operator==(
const bintree<T>::preorder_iterator & i) const
{
return elnodo == i.elnodo;
}
template <typename T>
inline
typename bintree<T>::preorder_iterator &
bintree<T>::preorder_iterator::operator=( const bintree<T>::preorder_iterator & i)
{
elnodo = i.elnodo;
return *this;
}
template <typename T>
inline
T & bintree<T>::preorder_iterator::operator*()
{
return *elnodo;
}
template <typename T>
typename bintree<T>::preorder_iterator &
bintree<T>::preorder_iterator::operator++()
{
if (elnodo.null())
return *this;
if (!elnodo.left().null())
elnodo = elnodo.left();
else if (!elnodo.right().null())
elnodo = elnodo.right();
else {
while ((!elnodo.parent().null()) &&
(elnodo.parent().right() == elnodo ||
elnodo.parent().right().null()))
elnodo = elnodo.parent();
if (elnodo.parent().null())
elnodo = typename bintree<T>::node();
else
elnodo = elnodo.parent().right();
}
return *this;
}
template <typename T>
inline
typename bintree<T>::preorder_iterator
bintree<T>::begin_preorder()
{
return preorder_iterator(laraiz);
}
template <typename T>
inline
typename bintree<T>::preorder_iterator
bintree<T>::end_preorder()
{
return preorder_iterator(typename bintree<T>::node());
}
/*____________________________________________________________ */
/*
Iterador para recorrido en Inorden
*/
template <typename T>
inline
bintree<T>::inorder_iterator::inorder_iterator()
{
}
template <typename T>
inline bintree<T>::inorder_iterator::inorder_iterator(
bintree<T>::node n)
: elnodo(n)
{
}
template <typename T>
inline bool bintree<T>::inorder_iterator::operator!=(
const typename bintree<T>::inorder_iterator & i) const
{
return elnodo != i.elnodo;
}
template <typename T>
inline bool bintree<T>::inorder_iterator::operator==(
const typename bintree<T>::inorder_iterator & i) const
{
return elnodo == i.elnodo;
}
template <typename T>
inline
typename bintree<T>::inorder_iterator &
bintree<T>::inorder_iterator::operator=(
const bintree<T>::inorder_iterator & i)
{
elnodo = i.elnodo;
return *this;
}
template <typename T>
inline T & bintree<T>::inorder_iterator::operator*()
{
return *elnodo;
}
template <typename T>
typename bintree<T>::inorder_iterator &
bintree<T>::inorder_iterator::operator++()
{
if (elnodo.null())
return *this;
if (!elnodo.right().null()) {
elnodo = elnodo.right();
while (!elnodo.left().null())
elnodo = elnodo.left();
}
else {
while (!elnodo.parent().null() &&
elnodo.parent().right() == elnodo)
elnodo = elnodo.parent();
// Si (padre de elnodo es nodo_nulo), hemos terminado
// En caso contrario, el siguiente node es el padre
elnodo = elnodo.parent();
}
return *this;
}
template <typename T>
typename bintree<T>::inorder_iterator
bintree<T>::begin_inorder()
{
node n(laraiz);
if (!n.null())
while (!n.left().null())
n = n.left();
return inorder_iterator(n);
}
template <typename T>
inline
typename bintree<T>::inorder_iterator
bintree<T>::end_inorder()
{
return inorder_iterator(typename bintree<T>::node());
}
/*____________________________________________________________ */
/*
Iterador para recorrido en Postorden
*/
template <typename T>
inline
bintree<T>::postorder_iterator::postorder_iterator()
{
}
template <typename T>
inline
bintree<T>::postorder_iterator::postorder_iterator(
bintree<T>::node n)
: elnodo(n)
{
}
template <typename T>
inline
bool bintree<T>::postorder_iterator::operator!=(
const bintree<T>::postorder_iterator & i) const
{
return elnodo != i.elnodo;
}
template <typename T>
inline
bool bintree<T>::postorder_iterator::operator==(
const bintree<T>::postorder_iterator & i) const
{
return elnodo == i.elnodo;
}
template <typename T>
inline
typename bintree<T>::postorder_iterator &
bintree<T>::postorder_iterator::operator=(
const bintree<T>::postorder_iterator & i)
{
elnodo = i.elnodo;
return *this;
}
template <typename T>
inline
T & bintree<T>::postorder_iterator::operator*()
{
return *elnodo;
}
template <typename T>
typename bintree<T>::postorder_iterator &
bintree<T>::postorder_iterator::operator++()
{
if (elnodo.null())
return *this;
if (elnodo.parent().null())
elnodo = typename bintree<T>::node();
else
if (elnodo.parent().left() == elnodo) {
if (!elnodo.parent().right().null()) {
elnodo = elnodo.parent().right();
do {
while (!elnodo.left().null())
elnodo = elnodo.left();
if (!elnodo.right().null())
elnodo = elnodo.right();
} while ( !elnodo.left().null() ||
!elnodo.right().null());
}
else
elnodo = elnodo.parent();
}
else // elnodo es hijo a la derecha de su padre
elnodo = elnodo.parent();
return *this;
}
template <typename T>
inline
typename bintree<T>::postorder_iterator bintree<T>::begin_postorder()
{
node n(laraiz);
do {
while (!n.left().null())
n = n.left();
if (!n.right().null())
n = n.right();
} while (!n.left().null() || !n.right().null());
return postorder_iterator(n);
}
template <typename T>
inline
typename bintree<T>::postorder_iterator
bintree<T>::end_postorder()
{
return postorder_iterator(typename bintree<T>::node());
}
/*____________________________________________________________ */
/*
Iterador para recorrido por Niveles
*/
template <typename T>
inline
bintree<T>::level_iterator::level_iterator()
{
}
template <typename T>
inline bintree<T>::level_iterator::level_iterator(
bintree<T>::node n)
{
cola_Nodos.push(n);
}
template <typename T>
inline bool bintree<T>::level_iterator::operator!=(
const bintree<T>::level_iterator & i) const
{
if (cola_Nodos.empty() && i.cola_Nodos.empty())
return false;
if (cola_Nodos.empty() || i.cola_Nodos.empty())
return true;
if (cola_Nodos.front() != i.cola_Nodos.front())
return false;
if (cola_Nodos.size() != i.cola_Nodos.size())
return false;
return (cola_Nodos == i.cola_Nodos);
}
template <typename T>
inline
bool bintree<T>::level_iterator::operator==(
const bintree<T>::level_iterator & i) const
{
return !(*this != i);
}
template <typename T>
inline
typename bintree<T>::level_iterator &
bintree<T>::level_iterator::operator=(
const bintree<T>::level_iterator & i)
{
cola_Nodos = i.cola_Nodos;
return *this;
}
template <typename T>
inline
T & bintree<T>::level_iterator::operator*()
{
return *cola_Nodos.front();
}
template <typename T>
typename bintree<T>::level_iterator &
bintree<T>::level_iterator::operator++()
{
if (!cola_Nodos.empty()) {
typename bintree<T>::node n = cola_Nodos.front();
cola_Nodos.pop();
if (!n.left().null())
cola_Nodos.push(n.left());
if (!n.right().null())
cola_Nodos.push(n.right());
}
return *this;
}
template <typename T>
inline typename bintree<T>::level_iterator
bintree<T>::begin_level()
{
if (!root().null())
return level_iterator(laraiz);
else
return level_iterator();
}
template <typename T>
inline typename bintree<T>::level_iterator
bintree<T>::end_level()
{
return level_iterator();
}
/*
************************************************************
Iteradores constantes
************************************************************
*/
/*
Iterador cosntante para recorrido en Preorder
*/
template <typename T>
inline
bintree<T>::const_preorder_iterator::const_preorder_iterator()
{
}
template <typename T>
inline
bintree<T>::const_preorder_iterator::const_preorder_iterator(bintree<T>::node n) : elnodo(n)
{
}
template <typename T>
bintree<T>::const_preorder_iterator::const_preorder_iterator(const typename bintree<T>::preorder_iterator & i)
{
elnodo = i.elnodo;
}
template <typename T>
inline
bool bintree<T>::const_preorder_iterator::operator!=(
const bintree<T>::const_preorder_iterator & i) const
{
return elnodo != i.elnodo;
}
template <typename T>
inline
bool bintree<T>::const_preorder_iterator::operator==(
const bintree<T>::const_preorder_iterator & i) const
{
return elnodo == i.elnodo;
}
template <typename T>
inline
typename bintree<T>::const_preorder_iterator &
bintree<T>::const_preorder_iterator::operator=(
const bintree<T>::const_preorder_iterator & i)
{
elnodo = i.elnodo;
return *this;
}
template <typename T>
inline
const T & bintree<T>::const_preorder_iterator::operator*() const
{
return *elnodo;
}
template <typename T>
typename bintree<T>::const_preorder_iterator &
bintree<T>::const_preorder_iterator::operator++()
{
if (elnodo.null())
return *this;
if (!elnodo.left().null())
elnodo = elnodo.left();
else if (!elnodo.right().null())
elnodo = elnodo.right();
else {
while ((!elnodo.parent().null()) &&
(elnodo.parent().right() == elnodo
|| elnodo.parent().right().null()))
elnodo = elnodo.parent();
if (elnodo.parent().null())
elnodo = typename bintree<T>::node();
else
elnodo = elnodo.parent().right();
}
return *this;
}
template <typename T>
inline
typename bintree<T>::const_preorder_iterator
bintree<T>::begin_preorder() const
{
return const_preorder_iterator(laraiz);
}
template <typename T>
inline
typename bintree<T>::const_preorder_iterator
bintree<T>::end_preorder() const
{
return const_preorder_iterator(typename bintree<T>::node());
}
/*____________________________________________________________ */
/*
Iterador constante para recorrido en Inorder
*/
template <typename T>
inline
bintree<T>::const_inorder_iterator::const_inorder_iterator()
{
elnodo = typename bintree<T>::node();
}
template <typename T>
inline
bintree<T>::const_inorder_iterator::const_inorder_iterator(const const_inorder_iterator &i)
{
elnodo = i.elnodo;
}
template <typename T>
inline
bintree<T>::const_inorder_iterator::const_inorder_iterator(
bintree<T>::node n)
: elnodo(n)
{
}
template <typename T>
inline
bool bintree<T>::const_inorder_iterator::operator!=(
const bintree<T>::const_inorder_iterator & i) const
{
return elnodo != i.elnodo;
}
template <typename T>
inline
bool bintree<T>::const_inorder_iterator::operator==(
const bintree<T>::const_inorder_iterator & i) const
{
return elnodo == i.elnodo;
}
template <typename T>
inline
typename bintree<T>::const_inorder_iterator &
bintree<T>::const_inorder_iterator::operator=(
const bintree<T>::const_inorder_iterator & i)
{
elnodo = i.elnodo;
return *this;
}
template <typename T>
inline
const T & bintree<T>::const_inorder_iterator::operator*() const
{
return *elnodo;
}
template <typename T>
typename bintree<T>::const_inorder_iterator &
bintree<T>::const_inorder_iterator::operator++()
{
if (elnodo.null())
return *this;
if (!elnodo.right().null()) {
elnodo = elnodo.right();
while (!elnodo.left().null())
elnodo = elnodo.left();
}
else {
while (!elnodo.parent().null() &&
elnodo.parent().right() == elnodo)
elnodo = elnodo.parent();
// Si (el padre de elnodo es nodo_nulo), hemos terminado
// En caso contrario, el siguiente Nodo es el padre
elnodo = elnodo.parent();
}
return *this;
}
template <typename T>
inline
typename bintree<T>::const_inorder_iterator
bintree<T>::begin_inorder() const
{
node n(laraiz);
if (!n.null())
while (!n.left().null())
n = n.left();
return const_inorder_iterator(n);
}
template <typename T>
inline
typename bintree<T>::const_inorder_iterator
bintree<T>::end_inorder() const
{
return const_inorder_iterator(typename bintree<T>::node());
}
/*____________________________________________________________ */
/*
Iterador constante para recorrido en Postorder
*/
template <typename T>
inline
bintree<T>::const_postorder_iterator::const_postorder_iterator()
{
elnodo = typename bintree<T>::node();
}
template <typename T>
inline
bintree<T>::const_postorder_iterator::const_postorder_iterator(
typename bintree<T>::node n)
: elnodo(n)
{
}
template <typename T>
inline
bool bintree<T>::const_postorder_iterator::operator!=(
const bintree<T>::const_postorder_iterator & i) const
{
return elnodo != i.elnodo;
}
template <typename T>
inline
bool bintree<T>::const_postorder_iterator::operator==(
const bintree<T>::const_postorder_iterator & i) const
{
return elnodo == i.elnodo;
}
template <typename T>
inline
typename bintree<T>::const_postorder_iterator &
bintree<T>::const_postorder_iterator::operator=(
const bintree<T>::const_postorder_iterator & i)
{
elnodo = i.elnodo;
return *this;
}
template <typename T>
inline
const T & bintree<T>::const_postorder_iterator::operator*() const
{
return *elnodo;
}
template <typename T>
typename bintree<T>::const_postorder_iterator &
bintree<T>::const_postorder_iterator::operator++()
{
if (elnodo.null())
return *this;
if (elnodo.parent().null())
elnodo = typename bintree<T>::node();
else
if (elnodo.parent().left() == elnodo) {
if (!elnodo.parent().right().null()) {
elnodo = elnodo.parent().right();
do {
while (!elnodo.left().null())
elnodo = elnodo.left();
if (!elnodo.right().null())
elnodo = elnodo.right();
} while ( !elnodo.left().null() ||
!elnodo.right().null());
}
else
elnodo = elnodo.parent();
}
else // elnodo es hijo a la derecha de su padre
elnodo = elnodo.parent();
return *this;
}
template <typename T>
inline
typename bintree<T>::const_postorder_iterator
bintree<T>::begin_postorder() const
{
node n = root();
do {
while (!n.left().null())
n = n.left();
if (!n.right().null())
n = n.right();
} while (!n.left().null() || !n.right().null());
return const_postorder_iterator(n);
}
template <typename T>
inline
typename bintree<T>::const_postorder_iterator
bintree<T>::end_postorder() const
{
return const_postorder_iterator(typename bintree<T>::node());
}
/*____________________________________________________________ */
/*
Iterador cosntante para recorrido por Niveles
*/
template <typename T>
inline
bintree<T>::const_level_iterator::const_level_iterator()
{
}
template <typename T>
inline
bintree<T>::const_level_iterator::const_level_iterator(
bintree<T>::node n)
{
cola_Nodos.push(n);
}
template <typename T>
inline
bool bintree<T>::const_level_iterator::operator!=(
const bintree<T>::const_level_iterator & i) const
{
if (cola_Nodos.empty() && i.cola_Nodos.empty())
return false;
if (cola_Nodos.empty() || i.cola_Nodos.empty())
return true;
return cola_Nodos.front() != i.cola_Nodos.front();
}
template <typename T>
inline
bool bintree<T>::const_level_iterator::operator==(
const bintree<T>::const_level_iterator & i) const
{
return !(*this != i);
}
template <typename T>
inline
typename bintree<T>::const_level_iterator &
bintree<T>::const_level_iterator::operator=(
const bintree<T>::const_level_iterator & i)
{
cola_Nodos = i.cola_Nodos;
return *this;
}
template <typename T>
inline const T & bintree<T>::const_level_iterator::operator*() const
{
return *cola_Nodos.front();
}
template <typename T>
typename bintree<T>::const_level_iterator &
bintree<T>::const_level_iterator::operator++()
{
if (!cola_Nodos.empty()) {
typename bintree<T>::node n = cola_Nodos.front();
cola_Nodos.pop();
if (!n.left().null())
cola_Nodos.push(n.left());
if (!n.right().null())
cola_Nodos.push(n.right());
}
return *this;
}
template <typename T>
inline
typename bintree<T>::const_level_iterator
bintree<T>::begin_level() const
{
if (!root().null())
return const_level_iterator(laraiz);
else
return const_level_iterator();
}
template <typename T>
inline
typename bintree<T>::const_level_iterator
bintree<T>::end_level() const
{
return const_level_iterator();
}
template <typename T>
void bintree<T>::replace_subtree(typename bintree<T>::node pos, const bintree<T>& a, typename bintree<T>::node n)
{
if (&a != this) {
if (pos == laraiz) { // pos es la raiz
destroy(laraiz);
copy(laraiz, n);
if (!laraiz.null())
laraiz.parent(typename bintree<T>::node());
}
else { // Pos no esta en la raiz
typename bintree<T>::node padre = pos.parent(), aux;
if (padre.left()==pos) {
destroy(padre.left());
copy(aux, n);
padre.left(aux);
}
else {
destroy(padre.right());
copy(aux, n);
padre.right(aux);
}
}
}
} | [
"jjavier.ar98@gmail.com"
] | jjavier.ar98@gmail.com |
444f10cd1fec55e2d1ceb2f09b2249dce807ca29 | a8ad6eebd95161d66c39d19f8e36b3b709e32152 | /OpenGL/freeglut/usr-inp-n-cam-ctrl-freeglut-bullet/BulletOpenGLApplication.h | c2cb794784bfba927fb2d015f7cf96e9011b8fe5 | [
"MIT"
] | permissive | gusenov/computer-graphics-examples | 02943c6e773902b2548b14fb813da98ec7885667 | 24ed9855eeac72809d8284e9e1a1f7a5b40fcb5f | refs/heads/master | 2021-10-10T06:19:54.575962 | 2021-09-10T03:21:20 | 2021-09-10T03:21:20 | 178,453,664 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,655 | h | #ifndef _BULLETOPENGLAPP_H_
#define _BULLETOPENGLAPP_H_
#ifdef _MSC_VER
#include <Windows.h>
#include <GL/GL.h>
#elif __APPLE__
#include <OpenGL/GL.h>
#endif
#include <GL/freeglut.h>
#include "BulletDynamics/Dynamics/btDynamicsWorld.h"
class BulletOpenGLApplication {
public:
BulletOpenGLApplication();
~BulletOpenGLApplication();
void Initialize();
// FreeGLUT callbacks //
virtual void Keyboard(unsigned char key, int x, int y);
virtual void KeyboardUp(unsigned char key, int x, int y);
virtual void Special(int key, int x, int y);
virtual void SpecialUp(int key, int x, int y);
virtual void Reshape(int w, int h);
virtual void Idle();
virtual void Mouse(int button, int state, int x, int y);
virtual void PassiveMotion(int x, int y);
virtual void Motion(int x, int y);
virtual void Display();
// camera functions
void UpdateCamera();
void RotateCamera(float &angle, float value);
void ZoomCamera(float distance);
// drawing functions
void DrawBox(const btVector3 &halfSize, const btVector3 &color = btVector3(1.0f, 1.0f, 1.0f));
protected:
// camera control
btVector3 m_cameraPosition; // the camera's current position
btVector3 m_cameraTarget; // the camera's lookAt target
float m_nearPlane; // minimum distance the camera will render
float m_farPlane; // farthest distance the camera will render
btVector3 m_upVector; // keeps the camera rotated correctly
float m_cameraDistance; // distance from the camera to its target
float m_cameraPitch; // pitch of the camera
float m_cameraYaw; // yaw of the camera
int m_screenWidth;
int m_screenHeight;
};
#endif
| [
"gusenov@live.ru"
] | gusenov@live.ru |
7183a9fec914522bc6701772f80c5fe8b5999f1c | c34c351752f14b0398e0ebb2b7541ce2d8cc1aec | /of_v0073_osx_release/apps/theNatureOfCode/natureofcode_1_ex_1_7/src/mover.cpp | 7a630240611a3a0624f7754932ae3dcc8191158d | [
"MIT"
] | permissive | Tobystereo/XCode_Projects | 7f64764e0728ecd1ad274c5526023c4a040bd835 | f0e2657b14d93191ca274bc124c4eb96bce647e6 | refs/heads/master | 2016-09-15T18:40:04.487835 | 2013-07-10T20:29:23 | 2013-07-10T20:29:23 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 814 | cpp | //
// mover.cpp
// natureofcode_1_ex_1_7
//
// Created by Tobias Treppmann on 5/31/13.
//
//
#include "mover.h"
Mover::Mover(){
location.set(ofRandom(ofGetWidth()), ofRandom(ofGetHeight()));
velocity.set(0,0);
acceleration.set(-0.001, 0.01);
topspeed = 10;
}
void Mover::update() {
velocity.operator+=(acceleration);
velocity.limit(topspeed);
location.operator+=(velocity);
}
void Mover::display() {
ofColor color(50);
ofEllipse(location.x, location.y, 16, 16);
}
void Mover::checkEdges() {
if (location.x > ofGetWidth()) {
location.x = 0;
} else if (location.x < 0) {
location.x = ofGetWidth();
}
if (location.y > ofGetHeight()) {
location.y = 0;
} else if (location.y < 0) {
location.y = ofGetHeight();
}
} | [
"hello@tobystereo.com"
] | hello@tobystereo.com |
288d88a6569d2d100058b6a9f40b7baccb5de564 | 4116241c055f8abde9480764ef8b49a68607a994 | /Ex04/tdate.cpp | bd56a50df60c3b6e9ecd2767bc0949291c4e944b | [] | no_license | fussballteammanager/AKT-7-SS-2016 | 88ee5e7fcdda8d60e083c80492c4517a124352dd | 46ad4f764f18a529ff238335553e598767b4152e | refs/heads/master | 2021-01-17T16:22:48.778133 | 2016-07-04T21:33:10 | 2016-07-04T21:33:10 | 56,082,329 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,584 | cpp | #include <iostream>
#include <iomanip>
#include <fstream>
#include <algorithm>
#include <ctime>
#include "tdate.h"
#include "ttools.h"
using namespace std;
TDate::TDate()
{
TDate::setCurrentDate();
}
TDate::TDate(short day, short month, short year)
{
TDate::setDate(day, month, year);
}
TDate::~TDate()
{
#ifdef DEBUG
cout << "Destr: TDate" << endl;
#endif
}
void TDate::setDate(short day, short month, short year)
{
if ( day > 0 and day <=31 and month > 0 and month <=12 and
year > 1900 and year < 3000 )
{
TDate::day = day;
TDate::month = month;
TDate::year = year;
}
else
TDate::setCurrentDate();
}
void TDate::setCurrentDate()
{
time_t now = time(0);
tm *ltm = localtime(&now);
TDate::day = ltm->tm_mday;
TDate::month = 1 + ltm->tm_mon;
TDate::year = 1900 + ltm->tm_year;
}
short TDate::getDay()
{
return TDate::day;
}
short TDate::getMonth()
{
return TDate::month;
}
short TDate::getYear()
{
return TDate::year;
}
void TDate::print()
{
cout << setw(2) << setfill('0') << day
<< "." << setw(2) << month
<< "."<< setw(4) << year;
}
int TDate::load(std::ifstream &ifs)
{
string line;
while(ifs.good())
{
line = TTools::ReadUnspaced(ifs);
if ( TTools::strcontain( line, "</Birthday>" ) )
{
#ifdef DEBUG
cout << line << endl;
#endif
return 1;
}
else if( TTools::strcontain( line,"<Day>" ) )
{
#ifdef DEBUG
cout << line << endl;
#endif
std::string tag1 = "<Day>",tag2 = "</Day>";
line = TTools::tagremove(line, tag1);
line = TTools::tagremove(line, tag2);
this->day = atoi(line.c_str());
}
else if( TTools::strcontain( line, "<Month>" ) )
{
#ifdef DEBUG
cout << line << endl;
#endif
std::string tag1 = "<Month>",tag2 = "</Month>";
line = TTools::tagremove(line, tag1);
line = TTools::tagremove(line, tag2);
this->month = atoi(line.c_str());
}
else if( TTools::strcontain( line, "<Year>" ) )
{
#ifdef DEBUG
cout << line << endl;
#endif
std::string tag1 = "<Year>", tag2 = "</Year>";
line = TTools::tagremove(line, tag1);
line = TTools::tagremove(line, tag2);
this->year = atoi(line.c_str());
}
}
return 0;
}
| [
"ts@ts.de"
] | ts@ts.de |
d8007e77627614b108690e71640908462aeee48b | f894bb6e244daa34067565f375423bd7956782ef | /src/tool/src/TrantorTimestamp.cc | 364ab7d0119929ee5110fd5e7f3043789b3d9fcf | [
"BSD-2-Clause"
] | permissive | chenbk85/TrantorNet | e2dff1efc8564938219c8676cacfe6cc43e9a685 | 74bb920d97353843af339dc8c70810ace2a04353 | refs/heads/master | 2021-01-20T00:05:35.829034 | 2016-07-12T08:25:39 | 2016-07-12T08:25:39 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,261 | cc | #include "TrantorTimestamp.h"
namespace trantor
{
__thread std::stringstream* timestamp_sstr = NULL;
string TrantorTimestamp::transToString() const
{
struct tm tm_time;
int64_t seconds = time_since_epoch_usec_ / 1000000;
localtime_r(&seconds, &tm_time);
string date;
string time;
if(!timestamp_sstr)
{
timestamp_sstr = new std::stringstream;
}
(*timestamp_sstr)<<(tm_time.tm_year + 1900)<<"-"<<(tm_time.tm_mon + 1)<<"-"<<tm_time.tm_mday<<" ";
(*timestamp_sstr)>>date;
(*timestamp_sstr)<<tm_time.tm_hour<<":"<<tm_time.tm_min<<":"<<tm_time.tm_sec<<".";
(*timestamp_sstr)<<time_since_epoch_usec_ - seconds * 1000000;
(*timestamp_sstr)>>time;
return date + " " + time;
}
timeval TrantorTimestamp::getTimeval() const
{
timeval tv;
tv.tv_sec = time_since_epoch_usec_/1000000;
tv.tv_usec = time_since_epoch_usec_ - tv.tv_sec * 1000000;
return tv;
}
timespec TrantorTimestamp::getTimespec() const
{
timespec ts;
ts.tv_sec = time_since_epoch_usec_/1000000;
ts.tv_nsec = time_since_epoch_usec_ * 1000 - ts.tv_sec * 1000000000;
return ts;
}
TrantorTimestamp TrantorTimestamp::now()
{
timeval tv;
if(gettimeofday(&tv, NULL) == 0)
{
return TrantorTimestamp(tv.tv_sec*1000000 + tv.tv_usec);
}
}
}
| [
"chengbb080516@126.com"
] | chengbb080516@126.com |
06cf009d15b614dde923e02c9b906aca438bb642 | f4bbb7466cd386709bc9f5f66d47333ca2b16ed9 | /solutions/213-house-robber-ii/house-robber-ii.cpp | 3f8d5ca142d1d1ef34daa88eace2888e793f5d82 | [] | no_license | fr42k/leetcode | 790d4eeaafeb9f6af8471ee4f245c0bab5d5198a | de3455d82241d142ccb43c9e719defca7bf3ebd5 | refs/heads/master | 2022-11-05T15:47:50.778505 | 2022-10-22T03:38:49 | 2022-10-22T03:38:49 | 133,931,381 | 4 | 0 | null | 2018-05-18T09:12:48 | 2018-05-18T09:12:48 | null | UTF-8 | C++ | false | false | 1,459 | cpp | // You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed. All houses at this place are arranged in a circle. That means the first house is the neighbor of the last one. Meanwhile, adjacent houses have security system connected and it will automatically contact the police if two adjacent houses were broken into on the same night.
//
// Given a list of non-negative integers representing the amount of money of each house, determine the maximum amount of money you can rob tonight without alerting the police.
//
// Example 1:
//
//
// Input: [2,3,2]
// Output: 3
// Explanation: You cannot rob house 1 (money = 2) and then rob house 3 (money = 2),
// because they are adjacent houses.
//
//
// Example 2:
//
//
// Input: [1,2,3,1]
// Output: 4
// Explanation: Rob house 1 (money = 1) and then rob house 3 (money = 3).
// Total amount you can rob = 1 + 3 = 4.
//
class Solution {
public:
int rob(vector<int>& nums) {
if (nums.empty()) return 0;
if (nums.size() == 1) return nums[0];
return max(rob1(nums, 0, nums.size() - 2), rob1(nums, 1, nums.size() - 1));
}
int rob1(vector<int>& nums, int l, int h) {
int f_2 = 0, f_1 = nums[l];
for (int i = l + 1; i <= h; ++i) {
int cur = max(f_2 + nums[i], f_1);
f_2 = f_1;
f_1 = cur;
}
return f_1;
}
};
| [
"fr42k@yahoo.com"
] | fr42k@yahoo.com |
bf122bf64bec060fa119111ea4bb952fcef9c771 | c7d5d4669f0aa992cfa9a1ab2c4764c6d88119c6 | /detail/tuple_size.hpp | 3e91d520b7b962188c983314aba4e40855c83527 | [
"LicenseRef-scancode-nysl-0.9982"
] | permissive | iorate/Egg | 7fbffdd7cd9f887b281dadcb97a3c64eafbe920d | 35ac6674dddc568ebd521cf535bf8c162d93d155 | refs/heads/master | 2018-12-31T11:57:39.998026 | 2012-01-29T09:42:30 | 2012-01-29T09:42:30 | 2,836,627 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 866 | hpp | #ifndef IORATE_EGG_DETAIL_TUPLE_SIZE_HPP
#define IORATE_EGG_DETAIL_TUPLE_SIZE_HPP
#include <tuple>
#include <type_traits>
#include <boost/fusion/include/size.hpp>
#include "./is_fusion_sequence.hpp"
#include "./is_tuple_like.hpp"
namespace iorate { namespace egg { namespace detail {
template <class T, class Dummy = void>
struct tuple_size_impl;
template <class T>
struct tuple_size
: tuple_size_impl<T>
{};
// Tuple-like
//
template <class T>
struct tuple_size_impl<T, typename std::enable_if<is_tuple_like<T>::value>::type>
: std::tuple_size<T>
{};
// FusionSequence
//
template <class T>
struct tuple_size_impl<T, typename std::enable_if<is_fusion_sequence<T>::value>::type>
: boost::fusion::result_of::size<T>::type
{};
} } } // namespace iorate::egg::detail
#endif
| [
"eitaro.kidera@gmail.com"
] | eitaro.kidera@gmail.com |
6c590d072f5e117e9342c14551c72260a9356661 | eb68a195f96b8941e79494ce2c2f88b050e3e2bd | /m16/USB/Usb_Wdm/MFC_App/MFC_AppDlg.cpp | 3fdb3d576130b8a28252bbccfe222aaf7d6578ce | [] | no_license | dumpinfo/mcu128 | 7479dffa04c3050e5e7f458e0ece022aa3a355c3 | c7401190a88a8b59b17f77f9ae20a818bfce1356 | refs/heads/master | 2020-03-30T11:29:55.690708 | 2018-10-02T00:06:54 | 2018-10-02T00:06:54 | 151,177,530 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 9,903 | cpp | // MFC_AppDlg.cpp : implementation file
//
#include "stdafx.h"
#include "MFC_App.h"
#include "MFC_AppDlg.h"
#include <windows.h>
#include <winioctl.h>
#include "..\Usb_Wdmioctl.h"
#include "..\Usb_WdmDeviceinterface.h" // Has class GUID definition
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
// This function is found in module OpenByIntf.cpp
HANDLE OpenByInterface(GUID* pClassGuid, DWORD instance, PDWORD pError);
GUID ClassGuid = Usb_WdmDevice_CLASS_GUID;
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMFC_AppDlg dialog
CMFC_AppDlg::CMFC_AppDlg(CWnd* pParent /*=NULL*/)
: CDialog(CMFC_AppDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CMFC_AppDlg)
m_shuma0 = _T("");
m_shuma1 = _T("");
m_shuma2 = _T("");
m_shuma3 = _T("");
m_shuma4 = _T("");
m_shuma5 = _T("");
m_message = _T("");
m_key0 = FALSE;
m_key1 = FALSE;
m_key2 = FALSE;
m_key3 = FALSE;
m_key4 = FALSE;
m_key5 = FALSE;
m_key6 = FALSE;
m_key7 = FALSE;
m_led0 = FALSE;
m_led1 = FALSE;
m_led2 = FALSE;
m_led3 = FALSE;
m_led4 = FALSE;
m_led5 = FALSE;
m_led6 = FALSE;
m_led7 = FALSE;
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CMFC_AppDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CMFC_AppDlg)
DDX_Text(pDX, IDC_EDIT_SHUMA0, m_shuma0);
DDX_Text(pDX, IDC_EDIT_SHUMA1, m_shuma1);
DDX_Text(pDX, IDC_EDIT_SHUMA2, m_shuma2);
DDX_Text(pDX, IDC_EDIT_SHUMA3, m_shuma3);
DDX_Text(pDX, IDC_EDIT_SHUMA4, m_shuma4);
DDX_Text(pDX, IDC_EDIT_SHUMA5, m_shuma5);
DDX_Text(pDX, IDC_EDIT_Message, m_message);
DDX_Check(pDX, IDC_CHECK_KEY0, m_key0);
DDX_Check(pDX, IDC_CHECK_KEY1, m_key1);
DDX_Check(pDX, IDC_CHECK_KEY2, m_key2);
DDX_Check(pDX, IDC_CHECK_KEY3, m_key3);
DDX_Check(pDX, IDC_CHECK_KEY4, m_key4);
DDX_Check(pDX, IDC_CHECK_KEY5, m_key5);
DDX_Check(pDX, IDC_CHECK_KEY6, m_key6);
DDX_Check(pDX, IDC_CHECK_KEY7, m_key7);
DDX_Check(pDX, IDC_CHECK_LED0, m_led0);
DDX_Check(pDX, IDC_CHECK_LED1, m_led1);
DDX_Check(pDX, IDC_CHECK_LED2, m_led2);
DDX_Check(pDX, IDC_CHECK_LED3, m_led3);
DDX_Check(pDX, IDC_CHECK_LED4, m_led4);
DDX_Check(pDX, IDC_CHECK_LED5, m_led5);
DDX_Check(pDX, IDC_CHECK_LED6, m_led6);
DDX_Check(pDX, IDC_CHECK_LED7, m_led7);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CMFC_AppDlg, CDialog)
//{{AFX_MSG_MAP(CMFC_AppDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_EN_CHANGE(IDC_EDIT_SHUMA0, OnChangeEditShuma)
ON_BN_CLICKED(IDC_CHECK_LED0, OnCheckLed)
ON_EN_CHANGE(IDC_EDIT_SHUMA1, OnChangeEditShuma)
ON_EN_CHANGE(IDC_EDIT_SHUMA2, OnChangeEditShuma)
ON_EN_CHANGE(IDC_EDIT_SHUMA3, OnChangeEditShuma)
ON_EN_CHANGE(IDC_EDIT_SHUMA4, OnChangeEditShuma)
ON_EN_CHANGE(IDC_EDIT_SHUMA5, OnChangeEditShuma)
ON_BN_CLICKED(IDC_CHECK_LED1, OnCheckLed)
ON_BN_CLICKED(IDC_CHECK_LED2, OnCheckLed)
ON_BN_CLICKED(IDC_CHECK_LED3, OnCheckLed)
ON_BN_CLICKED(IDC_CHECK_LED4, OnCheckLed)
ON_BN_CLICKED(IDC_CHECK_LED5, OnCheckLed)
ON_BN_CLICKED(IDC_CHECK_LED6, OnCheckLed)
ON_BN_CLICKED(IDC_CHECK_LED7, OnCheckLed)
ON_WM_TIMER()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMFC_AppDlg message handlers
BOOL CMFC_AppDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Add "About..." menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
CEdit *pedit=(CEdit *)GetDlgItem(IDC_EDIT_SHUMA0);
pedit->SetLimitText(1);
pedit=(CEdit *)GetDlgItem(IDC_EDIT_SHUMA1);
pedit->SetLimitText(1);
pedit=(CEdit *)GetDlgItem(IDC_EDIT_SHUMA2);
pedit->SetLimitText(1);
pedit=(CEdit *)GetDlgItem(IDC_EDIT_SHUMA3);
pedit->SetLimitText(1);
pedit=(CEdit *)GetDlgItem(IDC_EDIT_SHUMA4);
pedit->SetLimitText(1);
pedit=(CEdit *)GetDlgItem(IDC_EDIT_SHUMA5);
pedit->SetLimitText(1);
unsigned char i;
for(i=0;i!=7;i++)ShuMa[i]=0;
/////////////////////////////////////////////////////
hDevice = INVALID_HANDLE_VALUE;
DWORD Error;
hDevice = OpenByInterface( &ClassGuid, 0, &Error);
if (hDevice == INVALID_HANDLE_VALUE)
{
m_message.Format("ERROR opening device: (%0x) returned from CreateFile\n", GetLastError());
}
else
{
m_message.Format("Device found, handle open.\n");
UpdateData(FALSE);
}
SetTimer(1,100,NULL);
UpdateData(FALSE);
return TRUE; // return TRUE unless you set the focus to a control
}
void CMFC_AppDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CMFC_AppDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CMFC_AppDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CMFC_AppDlg::OnChangeEditShuma()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
UpdateData(TRUE);
if(m_shuma0.GetLength()!=0)ShuMa[0]=m_shuma0.GetAt(0)-'0';
if(m_shuma1.GetLength()!=0)ShuMa[1]=m_shuma1.GetAt(0)-'0';
if(m_shuma2.GetLength()!=0)ShuMa[2]=m_shuma2.GetAt(0)-'0';
if(m_shuma3.GetLength()!=0)ShuMa[3]=m_shuma3.GetAt(0)-'0';
if(m_shuma4.GetLength()!=0)ShuMa[4]=m_shuma4.GetAt(0)-'0';
if(m_shuma5.GetLength()!=0)ShuMa[5]=m_shuma5.GetAt(0)-'0';
//////////////////////////////////////////////////////////////////////
CHAR bufOutput[16]; // Output from device
ULONG nOutput; // Count written to bufOutput
// Call device IO Control interface (USB_WDM_IOCTL_Test) in driver
if (!DeviceIoControl(hDevice,
USB_WDM_IOCTL_Test,
ShuMa,
7,
bufOutput,
16,
&nOutput,
NULL)
)
{
m_message.Format("ERROR: DeviceIoControl returns %0x.", GetLastError());
UpdateData(FALSE);
}
}
void CMFC_AppDlg::OnCheckLed()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
ShuMa[6]=0;
if(m_led0==1)ShuMa[6]+= 0x01;
if(m_led1==1)ShuMa[6]+= 0x02;
if(m_led2==1)ShuMa[6]+= 0x04;
if(m_led3==1)ShuMa[6]+= 0x08;
if(m_led4==1)ShuMa[6]+= 0x10;
if(m_led5==1)ShuMa[6]+= 0x20;
if(m_led6==1)ShuMa[6]+= 0x40;
if(m_led7==1)ShuMa[6]+= 0x80;
///////////////////////////////////
CHAR bufOutput[16]; // Output from device
ULONG nOutput; // Count written to bufOutput
// Call device IO Control interface (USB_WDM_IOCTL_Test) in driver
if (!DeviceIoControl(hDevice,
USB_WDM_IOCTL_Test,
ShuMa,
7,
bufOutput,
16,
&nOutput,
NULL)
)
{
m_message.Format("ERROR: DeviceIoControl returns %0x.", GetLastError());
UpdateData(FALSE);
}
}
void CMFC_AppDlg::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
ULONG nRead;
unsigned char key=0xff;
ReadFile(hDevice, &key, 1, &nRead, NULL);
key&=0xff;
m_key0=key%2;key>>=1;
m_key1=key%2;key>>=1;
m_key2=key%2;key>>=1;
m_key3=key%2;key>>=1;
m_key4=key%2;key>>=1;
m_key5=key%2;key>>=1;
m_key6=key%2;key>>=1;
m_key7=key%2;
UpdateData(FALSE);
CDialog::OnTimer(nIDEvent);
}
| [
"twtravel@126.com"
] | twtravel@126.com |
8b9359042e10079df17d032137b7bdb6b31e1100 | 7f4d67bf2d239b580e3ee7ea5e11ebb990ce4a8c | /Framework/Framework/0625/CGaiaArmorChild.cpp | 21e58e7c504e565b235dd884eaf67853ba8e6016 | [] | no_license | batherit/WizardOfLegend | 10d64a7785b9fcaa9506d0cc73a37063f78c5240 | 2b34b3c7d4a43eeb21fab49e00f25b17b99d0aef | refs/heads/master | 2023-03-06T10:44:10.610300 | 2021-02-18T07:26:37 | 2021-02-18T07:26:37 | 278,795,613 | 0 | 0 | null | null | null | null | UHC | C++ | false | false | 2,758 | cpp | #include "stdafx.h"
#include "CGaiaArmorChild.h"
#include "CBitmapMgr.h"
#include "CCamera2D.h"
#include "CScene.h"
#include "CGaiaArmor.h"
#include "CHitEffect.h"
#include "CSpace.h"
CGaiaArmorChild::CGaiaArmorChild(CGameWorld & _rGameWorld, CGaiaArmor * _pGaiaArmorParent)
:
CObj(_rGameWorld, 0.f, 0.f, GAIA_ARMOR_WIDTH, GAIA_ARMOR_HEIGHT),
m_pGaiaArmorParent(_pGaiaArmorParent)
{
SetRenderLayer(1);
SetObjType(OBJ::TYPE_PLAYER_SKILL);
SetDamage(3);
SetDamageOffset(1);
m_hDCKeyAtlas = CBitmapMgr::GetInstance()->GetBitmapMemDC(TEXT("SKILL_GAIA_ARMOR"));
m_pColliders[COLLIDER::TYPE_DAMAGED] = this;
}
CGaiaArmorChild::~CGaiaArmorChild()
{
Release();
}
int CGaiaArmorChild::Update(float _fDeltaTime)
{
// 가이아 아머 자식 위치는 가이아 아머 부모가 결정해줌
return 0;
}
void CGaiaArmorChild::LateUpdate(void)
{
}
void CGaiaArmorChild::Render(HDC & _hdc, CCamera2D * _pCamera)
{
RECT& rcDrawArea = GetRect();
// 그릴 영역을 스크린 좌표로 변환한다.
pair<float, float>& pairLeftTop = _pCamera->GetScreenPoint(rcDrawArea.left, rcDrawArea.top);
pair<float, float>& pairRightBottom = _pCamera->GetScreenPoint(rcDrawArea.right, rcDrawArea.bottom);
RECT rcCollider = { pairLeftTop.first, pairLeftTop.second, pairRightBottom.first, pairRightBottom.second };
if (!IsCollided(GetGameWorld().GetViewSpace()->GetRect(), rcCollider)) return;
GdiTransparentBlt(_hdc,
pairLeftTop.first, // 출력 시작좌표 X
pairLeftTop.second, // 출력 시작좌표 Y
pairRightBottom.first - pairLeftTop.first, // 출력 크기 (1은 빈여백을 없애기 위한 추가 픽셀이다.)
pairRightBottom.second - pairLeftTop.second, // 출력 크기 (1은 빈여백을 없애기 위한 추가 픽셀이다.)
m_hDCKeyAtlas,
GetSpriteIndex() * GAIA_ARMOR_WIDTH,
0,
m_iWidth,
m_iHeight,
RGB(255, 0, 255));
}
void CGaiaArmorChild::Release(void)
{
}
int CGaiaArmorChild::GetSpriteIndex(void)
{
float fToX = GetX() - m_pGaiaArmorParent->GetX();
float fToY = GetY() - m_pGaiaArmorParent->GetY();
float fDegree = GetPositiveDegreeByVector(fToX, fToY);
if (75.f <= fDegree && fDegree < 105.f) return 0;
else if (45.f <= fDegree && fDegree < 75.f) return 1;
else if (15.f <= fDegree && fDegree < 45.f) return 2;
else if (315.f <= fDegree && fDegree < 345.f) return 4;
else if (285.f <= fDegree && fDegree < 315.f) return 5;
else if (255.f <= fDegree && fDegree < 285.f) return 6;
else if (225.f <= fDegree && fDegree < 255.f) return 7;
else if (195.f <= fDegree && fDegree < 225.f) return 8;
else if (165.f <= fDegree && fDegree < 195.f) return 9;
else if (135.f <= fDegree && fDegree < 165.f) return 10;
else if (105.f <= fDegree && fDegree < 135.f) return 11;
else return 3;
}
| [
"batherit0703@naver.com"
] | batherit0703@naver.com |
0fe0ea28f38e9ce8760f271c90cb4d04f6b83baa | b449a3c70fde051f4fcf2c77aab4530d9f4c2e04 | /include/Graphy/Graphables/ColorMap.hpp | 26914dfb2de01c44ce8d829e95d26f0bb3b43ffe | [
"MIT"
] | permissive | dominicprice/Graphy | 6f1e509d831a3ce54908fb7578df08b6ca650add | 4553adf06e9c63365ed2ef994fa76c460f8673f4 | refs/heads/master | 2021-01-13T03:15:34.096361 | 2017-11-07T15:00:10 | 2017-11-07T15:00:10 | 77,609,187 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,559 | hpp | /////////////////////////////////////////////////////////////////////////////////
//MIT License
//
//Copyright(c) 2017 Dominic Price
//
//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 GRAPHY_COLORMAP_H
#define GRAPHY_COLORMAP_H
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <Graphy/Graphable.hpp>
namespace graphy
{
////////////////////////////////////////////////////////////
/// \brief Graphable representing a color map
///
////////////////////////////////////////////////////////////
class ColorMap : public Graphable
{
public:
////////////////////////////////////////////////////////////
/// \brief Constructor
///
/// Constructs a color map from a function defining the
/// color at each point
///
/// \param eq An equation returning a color for each (x, y)
///
////////////////////////////////////////////////////////////
ColorMap(std::function<sf::Color(double, double)> eq);
std::function<sf::Color(double, double)> eq; ///< Equation of the color map
float grain_size; ///< Distance in pixels between points at which the equation is evaluated
protected:
////////////////////////////////////////////////////////////
/// \brief Defines how the graphable is drawn to the graph
///
////////////////////////////////////////////////////////////
void draw();
};
} // namespace graphy
#endif //GRAPHY_COLORMAP_H
| [
"dominicprice@outlook.com"
] | dominicprice@outlook.com |
09708f95e59ed9905a65f374de7a63ad75092b44 | 877fff5bb313ccd23d1d01bf23b1e1f2b13bb85a | /app/src/main/cpp/dir40735/dir40736/file40742.cpp | dc23dc283002e2a36f8ef4fe9f15b64b1a214876 | [] | no_license | tgeng/HugeProject | 829c3bdfb7cbaf57727c41263212d4a67e3eb93d | 4488d3b765e8827636ce5e878baacdf388710ef2 | refs/heads/master | 2022-08-21T16:58:54.161627 | 2020-05-28T01:54:03 | 2020-05-28T01:54:03 | 267,468,475 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 115 | cpp | #ifndef file40742
#error "macro file40742 must be defined"
#endif
static const char* file40742String = "file40742"; | [
"tgeng@google.com"
] | tgeng@google.com |
90c47bc2393f76b0180291168ca48cc4646c2070 | 2159efb9ec8db8f23dddc9fbf1ba52ad6b67551f | /libraries/ArduinoJson/test/Misc/unsigned_char.cpp | b1a76ab848d401063c84763f2c918e604817d7bc | [
"MIT"
] | permissive | ahdemitalug/Arduino | 6004eb84cc6735e48a09a90067014f666048e505 | 17e896790cca3950d4d3ee8cdd848ef3666d7887 | refs/heads/master | 2020-07-27T11:30:07.228695 | 2019-09-18T14:07:57 | 2019-09-18T14:07:57 | 209,075,519 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,937 | cpp | // ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2018
// MIT License
#include <ArduinoJson.h>
#include <catch.hpp>
#if defined(__clang__)
#define CONFLICTS_WITH_BUILTIN_OPERATOR
#endif
TEST_CASE("unsigned char[]") {
SECTION("deserializeJson()") {
unsigned char input[] = "{\"a\":42}";
StaticJsonDocument<JSON_OBJECT_SIZE(1)> doc;
DeserializationError err = deserializeJson(doc, input);
REQUIRE(err == DeserializationError::Ok);
}
SECTION("deserializeMsgPack()") {
unsigned char input[] = "\xDE\x00\x01\xA5Hello\xA5world";
StaticJsonDocument<JSON_OBJECT_SIZE(2)> doc;
DeserializationError err = deserializeMsgPack(doc, input);
REQUIRE(err == DeserializationError::Ok);
}
SECTION("JsonVariant") {
DynamicJsonDocument doc;
SECTION("set") {
unsigned char value[] = "42";
JsonVariant variant = doc.to<JsonVariant>();
variant.set(value);
REQUIRE(42 == variant.as<int>());
}
#ifndef CONFLICTS_WITH_BUILTIN_OPERATOR
SECTION("operator[]") {
unsigned char key[] = "hello";
deserializeJson(doc, "{\"hello\":\"world\"}");
JsonVariant variant = doc.as<JsonVariant>();
REQUIRE(std::string("world") == variant[key]);
}
#endif
#ifndef CONFLICTS_WITH_BUILTIN_OPERATOR
SECTION("operator[] const") {
unsigned char key[] = "hello";
deserializeJson(doc, "{\"hello\":\"world\"}");
const JsonVariant variant = doc.as<JsonVariant>();
REQUIRE(std::string("world") == variant[key]);
}
#endif
SECTION("operator==") {
unsigned char comparand[] = "hello";
JsonVariant variant = doc.to<JsonVariant>();
variant.set("hello");
REQUIRE(comparand == variant);
REQUIRE(variant == comparand);
REQUIRE_FALSE(comparand != variant);
REQUIRE_FALSE(variant != comparand);
}
SECTION("operator!=") {
unsigned char comparand[] = "hello";
JsonVariant variant = doc.to<JsonVariant>();
variant.set("world");
REQUIRE(comparand != variant);
REQUIRE(variant != comparand);
REQUIRE_FALSE(comparand == variant);
REQUIRE_FALSE(variant == comparand);
}
}
SECTION("JsonObject") {
#ifndef CONFLICTS_WITH_BUILTIN_OPERATOR
SECTION("operator[]") {
unsigned char key[] = "hello";
DynamicJsonDocument doc;
JsonObject obj = doc.to<JsonObject>();
obj[key] = "world";
REQUIRE(std::string("world") == obj["hello"]);
}
SECTION("JsonObject::operator[] const") {
unsigned char key[] = "hello";
DynamicJsonDocument doc;
deserializeJson(doc, "{\"hello\":\"world\"}");
JsonObject obj = doc.as<JsonObject>();
REQUIRE(std::string("world") == obj[key]);
}
#endif
SECTION("containsKey()") {
unsigned char key[] = "hello";
DynamicJsonDocument doc;
deserializeJson(doc, "{\"hello\":\"world\"}");
JsonObject obj = doc.as<JsonObject>();
REQUIRE(true == obj.containsKey(key));
}
SECTION("remove()") {
unsigned char key[] = "hello";
DynamicJsonDocument doc;
deserializeJson(doc, "{\"hello\":\"world\"}");
JsonObject obj = doc.as<JsonObject>();
obj.remove(key);
REQUIRE(0 == obj.size());
}
SECTION("createNestedArray()") {
unsigned char key[] = "hello";
DynamicJsonDocument doc;
JsonObject obj = doc.to<JsonObject>();
obj.createNestedArray(key);
}
SECTION("createNestedObject()") {
unsigned char key[] = "hello";
DynamicJsonDocument doc;
JsonObject obj = doc.to<JsonObject>();
obj.createNestedObject(key);
}
}
SECTION("JsonObjectSubscript") {
SECTION("operator=") { // issue #416
unsigned char value[] = "world";
DynamicJsonDocument doc;
JsonObject obj = doc.to<JsonObject>();
obj["hello"] = value;
REQUIRE(std::string("world") == obj["hello"]);
}
SECTION("set()") {
unsigned char value[] = "world";
DynamicJsonDocument doc;
JsonObject obj = doc.to<JsonObject>();
obj["hello"].set(value);
REQUIRE(std::string("world") == obj["hello"]);
}
}
SECTION("JsonArray") {
SECTION("add()") {
unsigned char value[] = "world";
DynamicJsonDocument doc;
JsonArray arr = doc.to<JsonArray>();
arr.add(value);
REQUIRE(std::string("world") == arr[0]);
}
}
SECTION("JsonArraySubscript") {
SECTION("set()") {
unsigned char value[] = "world";
DynamicJsonDocument doc;
JsonArray arr = doc.to<JsonArray>();
arr.add("hello");
arr[0].set(value);
REQUIRE(std::string("world") == arr[0]);
}
SECTION("operator=") {
unsigned char value[] = "world";
DynamicJsonDocument doc;
JsonArray arr = doc.to<JsonArray>();
arr.add("hello");
arr[0] = value;
REQUIRE(std::string("world") == arr[0]);
}
}
}
| [
"medha.gulati@ymail.com"
] | medha.gulati@ymail.com |
f08e25413bc990c5170c75f041b18e4414005c88 | 230b7714d61bbbc9a75dd9adc487706dffbf301e | /media/gpu/android/video_frame_factory.h | ee5e80a359556dedc62d6da94787639ca51fb3b0 | [
"BSD-3-Clause"
] | permissive | byte4byte/cloudretro | efe4f8275f267e553ba82068c91ed801d02637a7 | 4d6e047d4726c1d3d1d119dfb55c8b0f29f6b39a | refs/heads/master | 2023-02-22T02:59:29.357795 | 2021-01-25T02:32:24 | 2021-01-25T02:32:24 | 197,294,750 | 1 | 2 | BSD-3-Clause | 2019-09-11T19:35:45 | 2019-07-17T01:48:48 | null | UTF-8 | C++ | false | false | 2,871 | h | // Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef MEDIA_GPU_ANDROID_VIDEO_FRAME_FACTORY_
#define MEDIA_GPU_ANDROID_VIDEO_FRAME_FACTORY_
#include <memory>
#include "base/memory/ref_counted.h"
#include "base/single_thread_task_runner.h"
#include "base/time/time.h"
#include "media/base/video_decoder.h"
#include "media/gpu/android/promotion_hint_aggregator.h"
#include "media/gpu/media_gpu_export.h"
#include "ui/gfx/geometry/size.h"
namespace media {
class CodecOutputBuffer;
class CodecSurfaceBundle;
class TextureOwner;
class VideoFrame;
// VideoFrameFactory creates CodecOutputBuffer backed VideoFrames. Not thread
// safe. Virtual for testing; see VideoFrameFactoryImpl.
class MEDIA_GPU_EXPORT VideoFrameFactory {
public:
using InitCb = base::RepeatingCallback<void(scoped_refptr<TextureOwner>)>;
using OnceOutputCb = base::OnceCallback<void(scoped_refptr<VideoFrame>)>;
VideoFrameFactory() = default;
virtual ~VideoFrameFactory() = default;
// Initializes the factory and runs |init_cb| on the current thread when it's
// complete. If initialization fails, the returned texture owner will be
// null.
enum class OverlayMode {
// When using java overlays, the compositor can provide hints to the media
// pipeline to indicate whether the video can be promoted to an overlay.
// This indicates whether promotion hints are needed, if framework support
// for overlay promotion is available (requires MediaCodec.setOutputSurface
// support).
kDontRequestPromotionHints,
kRequestPromotionHints,
// When using surface control, the factory should always use a TextureOwner
// since it can directly be promoted to an overlay on a frame-by-frame
// basis. The bits below indicate whether the media uses a secure codec.
kSurfaceControlSecure,
kSurfaceControlInsecure
};
virtual void Initialize(OverlayMode overlay_mode, InitCb init_cb) = 0;
// Notify us about the current surface bundle that subsequent video frames
// should use.
virtual void SetSurfaceBundle(
scoped_refptr<CodecSurfaceBundle> surface_bundle) = 0;
// Creates a new VideoFrame backed by |output_buffer|. Runs |output_cb| on
// the calling sequence to return the frame.
virtual void CreateVideoFrame(
std::unique_ptr<CodecOutputBuffer> output_buffer,
base::TimeDelta timestamp,
gfx::Size natural_size,
PromotionHintAggregator::NotifyPromotionHintCB promotion_hint_cb,
OnceOutputCb output_cb) = 0;
// Runs |closure| on the calling sequence after all previous
// CreateVideoFrame() calls have completed.
virtual void RunAfterPendingVideoFrames(base::OnceClosure closure) = 0;
};
} // namespace media
#endif // MEDIA_GPU_ANDROID_VIDEO_FRAME_FACTORY_
| [
"commit-bot@chromium.org"
] | commit-bot@chromium.org |
4524f746a1c7d60ca506f8f78d02890e0c53a631 | cac1aac0f178c1c8cbc8a1bd2bb2539afbe7ab1a | /CoursCA/CodeEtudiant2019/CodeEtudiant/include/Basic_block.h | d5fad866eecd54a45ff391bab6cf1ac565fd27a5 | [] | no_license | lisuxue/CA | ede6dd812487036ebb1ac16a38fe976367135b0c | c674c949c20b8fdf363c44836c156a0c6538040f | refs/heads/master | 2020-04-20T02:02:46.041410 | 2019-05-13T18:26:29 | 2019-05-13T18:26:29 | 168,561,284 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 6,097 | h | #ifndef _Basic_block_H
#define _Basic_block_H
/** \file Basic_block.h
\brief Basic_block class
\author Hajjem, Heydemann
*/
#include <Line.h>
#include <Instruction.h>
#include <string>
#include <stdio.h>
#include <Enum_type.h>
#include <fstream>
#include <vector>
#include <list>
#include <Dfg.h>
#include <Node_dfg.h>
using namespace std;
#define DEBUG
class Node_dfg;
/** \class Basic_block
\brief class representing a Basic_block of a fonction
*/
class Basic_block{
public:
/** \brief return a string with the basic block content */
string get_content();
/** \brief display the basic block
*/
void display();
/** \brief get the index of the basic block
*/
int get_index();
/** \brief get the line corresponding to the branch
*/
Line* get_branch();
/** \brief set the parameter as a BB successor of this and this as a BB predecessor of the parameter
*/
void set_link_succ_pred(Basic_block*);
/** \brief setter of the successor of the basic block
*/
void set_successor(Basic_block *BB);
/** \brief get the successor of the basic block by its index (0 or 1)
*/
Basic_block *get_successor(int index);
/** \brief setter of the predecessor of the basic block
*/
void set_predecessor(Basic_block *BB);
/** \brief get the ith predecessor of the basic block
*/
Basic_block *get_predecessor(int );
/** \brief returns/gets the number of successors of the basic block
*/
int get_nb_succ();
/** \brief returns/gets the number of predecessors of the basic block
*/
int get_nb_pred();
/** \brief returns the number of instructions
*/
int get_nb_inst();
/** \brief link instructions in the order they appear in the code and set them an index, to be performed to iterate on the instructions
*/
void link_instructions();
/** \brief return the first instruction of the basic block, nullptr if any
*/
Instruction* get_first_instruction();
/** \brief return the last instruction of the basic block, nullptr if any
*/
Instruction* get_last_instruction();
/** \brief returns the instruction at the given index, nullptr if any
*/
Instruction* get_instruction_at_index(int);
/** \brief comput dependances predecessors and successors of each instructions in the BB
*/
void comput_pred_succ_dep();
/** \brief reset dependances predecessors and successors of each instructions in the BB to be able to recompute them
*/
void reset_pred_succ_dep();
/** \brief print dependance successors of each instructions in the BB
*/
void show_succ_dep();
/** \brief restitute the basic block in a file
*/
void restitution(string const);
/** \brief test if the instruction is in the delayed slots of the branch terminating the BB if any
*/
bool is_delayed_slot(Instruction*);
/** \brief compute the number of cycles to execute the instruction of the basic bloc */
int nb_cycles();
/** \brief change the order of instruction with the one given in the parameter list
*/
void apply_scheduling(list<Node_dfg*>*);
/** \brief rename registers in the basic bloc using as available register numbers the ones give in the parameter list
*/
void reg_rename(list<int>*);
/** \brief rename registers in the basic bloc using available registers according to the liveness analysis
*/
void reg_rename();
/** \brief this method is to be used to test other methods
*/
void test();
/**
\brief Compute the Use and Def vectors
*/
void compute_use_def();
/**
\brief Display content of the Use and Def vectors
*/
void show_use_def(void);
/**
\brief Compute the DefLiveOut vector
*/
void compute_def_liveout();
/**
\brief Display content of DefLiveOut vector
*/
void show_def_liveout();
/**
\brief ith element is true is Ri is used in the basic block before any potential read
*/
vector<bool> Use;
/** \brief ith element is true is Ri is defined in the basic block before any potential read
*/
vector<bool> Def;
/** \brief ith element is true is Ri is alived at the enter of the basic block
*/
vector<bool> LiveIn;
/** \brief ith element is true is Ri is alived at the enter of the basic block
*/
vector<bool> LiveOut;
/** \brief ieme element contient l'index de l'instruction qui définit le registreRi s'il est vivant en sortie, -1 sinon
*/
vector<int> DefLiveOut;
/**
\brief ieme element vaut vrai si le basic block i domine this
*/
vector<bool> Domin;
/** \brief prints dependance between both instructions
*/
static void show_dependances(Instruction*, Instruction*);
/** \brief Constructor of a Basic Block
*/
Basic_block();
/** \brief Destructor of a basic block
*/
~Basic_block();
/** \brief setter of the head of the basic block
*/
void set_head(Line *);
/** \brief setter of the end of the basic block
*/
void set_end(Line *);
/** \brief get the head of the basic block
*/
Line* get_head();
/** \brief get the end of the basic block
*/
Line* get_end();
/** \brief setter of line corresponding to the branch
*/
void set_branch(Line *);
/** \brief Returns true if the first line of the block is a label
*/
bool is_labeled();
/** \brief set the index of the basic block
*/
void set_index(int i);
/** \brief returns the size (in lines) of the basic block
*/
int size();
private:
Line *_head;
Line *_end;
Instruction *_firstInst;
Instruction *_lastInst;
Line *_branch;
int _index;
int _nb_instr;
bool use_def_done;
bool dep_done;
list <Basic_block *> _succ;
list <Basic_block *> _pred;
/** \brief return the line associated with the first instruction of the basic block, nullptr if any
*/
Line* get_first_line_instruction();
};
#endif
| [
"3520716@ppti-14-301-06.ufr-info-p6.jussieu.fr"
] | 3520716@ppti-14-301-06.ufr-info-p6.jussieu.fr |
3555be6a88b0b4ac6f25c027942c507aea3e15b5 | 39e2de7e7a83842231e1bc16125b8660c2414413 | /text-game-redux/Game-Object Classes/PhysicalObject.cpp | 77723b546699c66125b41e23893f3a09c9354d2a | [] | no_license | MatthewDulworth/text-game-redux | 0b6c2c1a4f2e7fc84ec0f4d098e2e392d4844d67 | d44c69f087beab3fb208498e3a94bce72a3c7758 | refs/heads/master | 2020-05-02T16:55:59.243563 | 2019-12-10T04:02:57 | 2019-12-10T04:02:57 | 178,083,268 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,499 | cpp | //
// PhysicalObjectClasses.cpp
// text-game-redux
// The methods for the PhysicalObject classes
//
// Created by Matthew Dulworth on 3/27/19.
// Copyright © 2019 Matthew Dulworth. All rights reserved.
//
#include "PhysicalObject.hpp"
#include "Location.hpp"
#include "Passage.hpp"
// ------------------------------------------------------------------------------------------------------
// PhysicalObject classes
// ------------------------------------------------------------------------------------------------------
// ------------------------------------------------
// PhysicalObject methods
// ------------------------------------------------
// ----- setDescription ----- //
void PhysicalObject::setDescription(string new_description){
description = new_description;
}
// ----- setLocation ----- //
void PhysicalObject::setLocation(Location* new_location){
location = new_location;
}
// ----- setDetails ----- //
void PhysicalObject::setDetails(string new_details){
details = new_details;
}
// ----- getDescription ----- //
string PhysicalObject::getDescription(){
return description;
};
// ----- getDetails ----- //
string PhysicalObject::getDetails(){
return details;
};
// ----- getLocation ----- //
Location* PhysicalObject::getLocation(){
return location;
}
// ----- printDescription ----- //
void PhysicalObject::printDescription(){
cout << description << endl;
}
// ------------------------------------------------
// Item methods
// ------------------------------------------------
// ----- moveTo ----- //
void Item::moveTo(Location* location){
this->location = location;
}
// ----- isInInventory ----- //
bool Item::isInInventory(){
if(location->getCode() == INV) return true;
else return false;
}
// ----- overridden ----- //
void Item::overridden(){}
// ------------------------------------------------
// Key methods
// ------------------------------------------------
// ----- canUnlock ----- //
bool Key::canUnlock(Passage* door){
return (code == door->getKey() );
}
// ------------------------------------------------
// Money methods
// ------------------------------------------------
// ----- setValue ----- //
void Money::setValue(double new_value){
value = new_value;
}
// ----- getValue ----- //
double Money::getValue(){
return value;
}
// ------------------------------------------------
// Immovable methods
// ------------------------------------------------
void ImmovableObject::overridden(){}
| [
"mhdulworth@gmail.com"
] | mhdulworth@gmail.com |
8ec0b7556535dc6fe57b519417d6186574088d7e | de05438840161992a4f1badeae134093ebcdbd8a | /ThreadPool.cpp | 8b9053ad433f5dcc0e210b8bde04cc6a99792a24 | [] | no_license | liuanxu/ThreadPool-Cpp11 | 37fe1f1d3a318193eaccc905ec419d9203664c89 | 290dc01fdda127624ce10a55a7bf93f578b2f3fd | refs/heads/main | 2023-04-27T23:42:38.447172 | 2021-05-23T06:36:09 | 2021-05-23T06:36:09 | 369,974,329 | 1 | 0 | null | null | null | null | GB18030 | C++ | false | false | 10,143 | cpp | #include"ThreadPool.h"
#include<iostream>
//工作线程
WorkThread::WorkThread() :m_task{ nullptr }, m_bStop{ false } {
m_bRunning.store(true); //说明该对象创建后就开始运行起来了
//初始化执行线程
m_thread = thread(&WorkThread::run, this);
}
WorkThread::~WorkThread() {
if (!m_bStop) { //停止线程运行,调用stop()函数
stop();
}
if (m_thread.joinable()) { //等待执行任务的线程m_thread = thread(&WorkThread::run, this);结束再销毁该类实例化对象的资源
m_thread.join();
}
}
//给此线程分配任务
bool WorkThread::assign(Task * task) {
m_mutexTask.lock();
if (m_task != nullptr) { //任务不为空,分配失败
m_mutexTask.unlock();
return false;
}
m_task = task;
m_mutexTask.unlock();
m_condition.notify_one(); //通知线程,唤醒创建的工作线程m_thread的入口函数run()(其中使用条件变量m_condition阻塞等待)
return true;
}
//工作线程的入口函数
void WorkThread::run() {
while (true) {
if (!m_bRunning) { //未运行,退出
m_mutexTask.lock();
if (m_task == nullptr) { //并且未分配任务,跳出while循环,结束线程
m_mutexTask.unlock();
break; //break语句的调用,起到跳出循环(while或for)或者分支语句(switch)作用。
}
m_mutexTask.unlock();
}
Task * task = nullptr;
//等待任务,如果线程未退出并且没有任务,则线程阻塞
{
unique_lock<mutex> lock(m_mutexTask); //需要判断m_task,加锁
//等待信号,没有任务并且此线程正在运行,则阻塞此线程
/*
wait()是条件变量的成员函数,用来等一个东西,如果第二个参数lambda表达式返回值是false,那么wait将解锁第一个参数(互斥量),并堵塞到本行。
堵塞到什么时候呢?堵塞到其他某个线程调用notify_one()成员函数为止。如果返回true,那么wait()直接返回。
如果没有第二个参数,就跟默认第二个参数返回false效果一样。
*/
m_condition.wait(lock,
[this]() {
return !((m_task == nullptr) && this->m_bRunning.load()); });
task = m_task;
m_task = nullptr;
if (task == nullptr) { //处理m_bRunning为false时,说明线程暂停或退出,此时若m_task为空,则无任务退出,否则需要执行完已分配的任务再退出
continue; //任务为空,跳过下面的运行代码
}
}
task->run(); //执行任务
delete task; //执行完释放资源
task = nullptr;
}
}
thread::id WorkThread::getThreadID() {
return this_thread::get_id();
}
void WorkThread::stop() {
m_bRunning.store(false); //设置对象的停止标志位,线程停止运行
m_mutexThread.lock();
if (m_thread.joinable()) {
/*
一定要先设置标志位,然后通知唤醒该对象的线程(run()函数中m_condition可能处于等待状态)
*/
m_condition.notify_all(); //唤醒run()函数后,由于m_bRunning设为fasle,则run函数判断能否退出
m_thread.join();
}
m_mutexThread.unlock();
m_bStop = true;
}
//此处无用,该类中只管理一个线程,可不加锁
void WorkThread::notify() {
m_mutexCondition.lock();
m_condition.notify_one();
m_mutexCondition.unlock();
}
//此处无用,该类中只管理一个线程
void WorkThread::notify_all() {
m_mutexCondition.lock();
m_condition.notify_all();
m_mutexCondition.unlock();
}
bool WorkThread::isExecuting() {
//此时将任务分配给工作线程后,实例化对象中的m_task设为nullptr,则可以继续向该对象分配任务设置m_task进行排队,如果m_task已经有排队的则添加失败
bool ret;
m_mutexTask.lock(); //访问m_task时需要加锁
ret = (m_task == nullptr); //不为空则正在运行
m_mutexTask.unlock();
return !ret;
}
//空闲线程列表
LeisureThreadList::LeisureThreadList(const size_t counts) {
assign(counts); //创建多个工作线程
}
LeisureThreadList::~LeisureThreadList() {
//删除线程列表中的所有线程。析构函数不用加锁,因为ThreadPool对象析构前需先调用exit()函数,终止管理线程的运行,会调用此类实例化对象的stop()函数
while (!m_threadList.empty()) { //删除m_threadList中的工作线程类实例化对象
WorkThread * temp = m_threadList.front();
m_threadList.pop_front();
delete temp;
}
}
//创建初始化个数的线程
void LeisureThreadList::assign(const size_t counts) {
for (size_t i = 0u; i < counts; i++) {
m_threadList.push_back(new WorkThread); //创建线程
}
}
//添加线程,向线程列表中添加线程,须加锁
void LeisureThreadList::push(WorkThread *thread) {
if (thread == nullptr) {
return;
}
m_mutexThread.lock();
m_threadList.push_back(thread);
m_mutexThread.unlock();
}
//返回第一个线程指针,涉及对线程列表操作,须加锁
WorkThread * LeisureThreadList::top() {
WorkThread * thread; //需要定义一个指针获取,在解锁之后return
m_mutexThread.lock();
if (m_threadList.empty()) {
thread = nullptr;
}
else {
thread = m_threadList.front();
}
m_mutexThread.unlock();
return thread;
}
void LeisureThreadList::pop() {
m_mutexThread.lock();
if (!m_threadList.empty()) { m_threadList.pop_front(); }
m_mutexThread.unlock();
}
size_t LeisureThreadList::size() {
size_t counts = 0u;
m_mutexThread.lock();
counts = m_threadList.size();
m_mutexThread.unlock();
return counts;
}
//停止运行
void LeisureThreadList::stop() {
m_mutexThread.lock();
for (auto thread : m_threadList) {
thread->stop(); //调用工作线程类对象的内部终止函数,线程退出,但对象还在,也就是LeisureList对象析构时需要调用WorkThread的析构函数即delete命令
}
m_mutexThread.unlock();
}
//线程池类的具体定义,在此类初始化的时候需要同时对成员变量m_leisureThreadList调用其构造函数进行初始化,
/*如果我们有一个类成员,它本身是一个类或者是一个结构,而且这个成员它只有一个带参数的构造函数,
而没有默认构造函数,这时要对这个类成员进行初始化,就必须调用这个类成员的带参数的构造函数,
如果没有初始化列表,那么他将无法完成第一步,就会报错。*/
ThreadPool::ThreadPool(const size_t counts):m_leisureThreadList(counts),m_bExit(false) {
m_threadCounts = counts;
m_bRunning.store(true); //用于暂停管理线程运行
m_bEnd.store(true); //用于终止管理线程运行
m_thread = thread(&ThreadPool::run, this); //线程池对象的任务分配线程,即管理线程
}
ThreadPool::~ThreadPool() {
if (!m_bExit) {
exit(); //析构时调用此函数,会终止管理线程(入口函数run()函数中),调用leisureList的stop()函数(其中调用WorkThread的stop()函数)
}
}
size_t ThreadPool::threadCounts() {
return m_threadCounts.load(); // 原子类型
}
bool ThreadPool::isRunning() {
return m_bRunning.load(); //原子类型
}
//管理线程入口函数
void ThreadPool::run() {
while (true) {
if (!m_bEnd.load()) { //m_bEnd用于终止管理者线程的运行,若没有并且任务队列为空则管理线程退出
m_taskMutex.lock();
if (m_taskList.empty()) {
m_taskMutex.unlock();
break; //运行m_bEnd为false,任务队列为空,终止循环
}
m_taskMutex.unlock();
}
//若管理线程暂停执行,进入阻塞状态
{
unique_lock<mutex> lockRunning(m_runningMutex);
m_condition_running.wait(lockRunning, [this]() { //线程池类对象与管理者线程公用,m_condition_running用于两者间的通信,管理线程暂停
return this->m_bRunning.load(); }); //线程池类对象暂停运行stop()函数将m_bRunning设为false则管理者线程阻塞在此处
}
Task * task = nullptr;
WorkThread * thread = nullptr;
//如果没有任务并且正在运行,则阻塞
{
unique_lock<mutex> lock(m_taskMutex); //需要操作taskList,加锁
m_condition_task.wait(lock, [this]() {
return !(this->m_taskList.empty() && this->m_bEnd.load()); });
//若被唤醒,检查是有新任务进列表还是程序终止
if (!m_taskList.empty()) {
task = m_taskList.front(); //若是有新任务则将任务取出
m_taskList.pop();
}
}
//选择空闲的线程执行任务,m_leisureThreadList内部的操作已经是加锁保证安全的,此处不需要加锁
do {
thread = m_leisureThreadList.top();
m_leisureThreadList.pop();
m_leisureThreadList.push(thread);
} while (thread->isExecuting()); //直到找到一个未运行的线程,m_task不为空则正在运行
//找到后通知线程执行
thread->assign(task); //上一个isExecuting()已经判断m_task为nullptr,若是因为终止m_bEnd=false进入,怎么分配task=nullptr,不影响工作线程
thread->notify();
}
}
//操作任务列表,加锁。添加好任务后需要唤醒消费者管理线程消费
void ThreadPool::addTask(Task * task) {
if (task == nullptr) { return; }
m_taskMutex.lock();
m_taskList.push(task);
m_taskMutex.unlock();
//通知正在等待的线程,也就是唤醒管理者线程run函数中的等待,
m_condition_task.notify_one();
}
void ThreadPool::start() {
m_bRunning.store(true);
m_condition_running.notify_one(); //唤醒因暂停阻塞在run函数中的m_condition_running
}
void ThreadPool::stop() { //此处为暂停执行与start()函数对应,只是让管理者线程处于阻塞状态,并不影响已工作线程
m_bRunning.store(false); //设为false后,由于run函数的循环,会进入m_condition_running的阻塞
}
void ThreadPool::exit() { //!!!此处的exit()函数对应leisureList的stop和WorkThread的stop,真正让线程处理完已分配的任务后终止
m_bEnd.store(false); //置为false后需要唤醒可能处于m_condition_task阻塞的管理者线程
m_condition_task.notify_all();
m_mutexThread.lock();
if (m_thread.joinable()) {
m_thread.join();
}
m_mutexThread.unlock();
m_leisureThreadList.stop(); //工作线程停止,内部实现会把线程中已经存在的任务执行完再退出
m_bExit = true;
} | [
"1322542757@qq.com"
] | 1322542757@qq.com |
a2f58bf501c5b9b123c091391fa3b4ef841341b4 | 6b2a8dd202fdce77c971c412717e305e1caaac51 | /solutions_5706278382862336_1/C++/mkiken/A.cpp | 330879e0fd08a2d3e9d79e70a1b2b7c841de4d4b | [] | no_license | alexandraback/datacollection | 0bc67a9ace00abbc843f4912562f3a064992e0e9 | 076a7bc7693f3abf07bfdbdac838cb4ef65ccfcf | refs/heads/master | 2021-01-24T18:27:24.417992 | 2017-05-23T09:23:38 | 2017-05-23T09:23:38 | 84,313,442 | 2 | 4 | null | null | null | null | UTF-8 | C++ | false | false | 3,935 | cpp | #include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <climits>
#include <sstream>
#include <functional>
#include <complex>
using namespace std;
#define len(array) (sizeof (array) / sizeof *(array))
#define rep(i, s, e) for(int i = (s);i < (e);i++)
#define Rep(i, e) for(int i = 0;i < (e);i++)
#define rrep(i, e, s) for(int i = (e);(s) <= i;i--)
#define Rrep(i, e) for(int i = e;0 <= i;i--)
#define mrep(i, e, t1, t2) for(map<t1, t2>::iterator i = e.begin(); i != e.end(); i++)
#define vrange(v) v.begin(), v.end()
#define vrrange(v) v.rbegin(), v.rend()
#define vsort(v) sort(vrange(v))
#define vrsort(v) sort(vrrange(v))
#define arange(a) a, a + len(a)
#define asort(a) sort(arange(a))
#define arsort(a, t) sort(arange(a), greater<t>())
#define afill(a, v) fill(arange(a), v)
#define afill2(a, v, t) fill((t *)(a), (t *)((a) + len(a)), v)
#define fmax(a, b) ((a) < (b)? (b) : (a))
#define fmin(a, b) ((a) > (b)? (b) : (a))
#define fabs(a) ((a) < 0? -(a) : (a))
#define pb push_back
#define fst(e) (e).first
#define snd(e) (e).second
#define rg(e, s, t) (s <= e && e < t)
#define PQDecl(name, tp) priority_queue< tp, vector<tp>, greater<tp> > name
#define dq(q) q.top();q.pop();
#define sz(v) ((int)(v).size())
#define lg(s) ((int)(s).length())
//#define X real()
//#define Y imag()
//typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
//typedef complex<double> p;
const int INF = (int)2e9;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-10;
//const int dx[] = {1, -1, 0, 0, 1, -1, -1, 1};
//const int dy[] = {0, 0, 1, -1, -1, -1, 1, 1};
//const ll weight[] = {1e0,1e1,1e2,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13};
typedef struct _Datum {
int fst,snd,trd;
_Datum(int arg1 = 0, int arg2 = 0 , int arg3 = 0) {
fst = arg1; snd = arg2; trd = arg3;
}
bool operator <(const struct _Datum &e) const{
return fst == e.fst? (snd == e.snd? trd < e.trd : snd < e.snd) : fst < e.fst;
}
bool operator >(const struct _Datum &e) const{
return fst == e.fst? (snd == e.snd? trd > e.trd : snd > e.snd) : fst > e.fst;
}
}datum;
#define MAX_N 100005
vector<string> split( string s, string c )
{
vector<string> ret;
for(int i = 0, n; i <= s.length(); i = n + 1 ){
n = s.find_first_of( c, i );
if( n == string::npos ) n = s.length();
string tmp = s.substr( i, n-i );
ret.push_back(tmp);
}
return ret;
}
//string to int
ll s2i(string Text){
ll Number;
// if ( ! (stringstream(Text) >> Number) ) Number = -1;
stringstream sstr(Text);
sstr >> Number;
return Number;
}
ll gcd(ll a, ll b){
return b==0? a : gcd(b, a % b);
}
ll rec(ll p, ll q){
// printf("%lld, %lld\n", p, q);
if(p == q){
// printf("eq, %lld, %lld\n", p, q);
return 0;
}
ll g = gcd(p, q);
p /= g;
q /= g;
if(q % 2){
return -1;
}
q /= 2;
if(p > q){
ll tmp = rec(p % q, q);
if(tmp != -1){
return 1;
}
else{
return -1;
}
}
else{
ll tmp = rec(p, q);
if(tmp != -1){
return tmp + 1;
}
else{
return -1;
}
}
return -1;
}
int test_case = 0;
void solve(){
ll p, q;
string s;
cin >> s;
vector<string> v = split(s, "/");
p = s2i(v[0]);
q = s2i(v[1]);
ll g = gcd(p, q);
// printf("gcd = %lld\n", g);
p /= g;
q /= g;
ll ret = rec(p, q);
if(ret == -1) printf("Case #%d: impossible\n", test_case);
else printf("Case #%d: %lld\n", test_case, ret);
}
void doIt(){
int t = 1;
cout << s2i("1000000000000") << endl;
scanf("%d", &t);
while(t--){
test_case++;
solve();
}
}
int main() {
doIt();
return 0;
}
| [
"eewestman@gmail.com"
] | eewestman@gmail.com |
4df9b3fce07b19340a0f8aa288fc74429f120683 | 4f8bb0eaafafaf5b857824397604538e36f86915 | /水题/7.13 F.cpp | 1553b93d589565729b747119afffa148021ed9c6 | [] | no_license | programmingduo/ACMsteps | c61b622131132e49c0e82ad0007227d125eb5023 | 9c7036a272a5fc0ff6660a263daed8f16c5bfe84 | refs/heads/master | 2020-04-12T05:40:56.194077 | 2018-05-10T03:06:08 | 2018-05-10T03:06:08 | 63,032,134 | 1 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 706 | cpp | #include<cstdio>
int a[105];
int main ()
{
int n, pos;
while(~scanf("%d%d", &n, &pos))
{
pos --;
int ans = 0, l, r;
for(int i = 0; i < n; i ++)
{
scanf("%d", &a[i]);
}
for(int i = 1; i < n; i ++)
{
l = pos - i;
r = pos + i;
if(l >= 0 && r < n)
{
if(a[l] && a[r])
ans += 2;
}
else
{
if(r < n)
ans += a[r];
else if(l >= 0)
ans += a[l];
}
}
ans += a[pos];
printf("%d\n", ans);
}
return 0;
}
| [
"wuduotju@163.com"
] | wuduotju@163.com |
075291cb36557fd746c7871c95a398c73c1804f0 | 52a92ef78f39ca1b295c6bf757c6dafb538bad69 | /codeforces/1216/A.cpp | febb8a117e417b606d428ff0e9c485f491c476da | [] | no_license | manujgrover71/cp_codes | 244201f65692ccd0f43b1b73fd76d9ca3a90886e | c801b421be0eca04b19ab01597aabfe73444e84b | refs/heads/master | 2023-02-08T11:15:26.960166 | 2020-12-23T05:30:00 | 2020-12-24T11:14:38 | 323,294,247 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,107 | cpp | #include <algorithm>
#include <iostream>
#include <climits>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <set>
#include <map>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define ll long long
#define mod 1000000007
#define vi vector<int>
#define vll vector<ll>
#define pb push_back
ll power(int x, unsigned int y){
ll res = 1;
while(y > 0){
if(y & 1) res = res * x;
y >>= 1;
x *= x;
}
return res;
}
char change(char ch) {
if(ch == 'a')
return 'b';
return 'a';
}
void solve() {
int n; cin >> n;
string str; cin >> str;
int ans = 0;
for(int i = 0; i < n; i+=2) {
char f = str[i];
char s = str[i+1];
if(f == s) {
str[i] = change(f);
ans++;
}
}
cout << ans << '\n' << str;
}
int main(){
#ifndef ONLINE_JUDGE
freopen("/ATOMCODES/input.txt", "r", stdin);
freopen("/ATOMCODES/output.txt", "w", stdout);
#endif
ios_base::sync_with_stdio(false);
cin.tie(NULL);
solve();
} | [
"manujgrover71@gmail.com"
] | manujgrover71@gmail.com |
dd3476f082f4ca5e7076e126fc498630e465d991 | b4d1fc90b1c88f355c0cc165d73eebca4727d09b | /libcef/browser/browser_contents_delegate.cc | a6fc972da277995eca687cf292182d8166c8c276 | [
"BSD-3-Clause"
] | permissive | chromiumembedded/cef | f03bee5fbd8745500490ac90fcba45616a29be6e | f808926fbda17c7678e21f1403d6f996e9a95138 | refs/heads/master | 2023-09-01T20:37:38.750882 | 2023-08-31T17:16:46 | 2023-08-31T17:28:27 | 87,006,077 | 2,600 | 454 | NOASSERTION | 2023-07-21T11:39:49 | 2017-04-02T18:19:23 | C++ | UTF-8 | C++ | false | false | 24,240 | cc | // Copyright 2020 The Chromium Embedded Framework 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 "libcef/browser/browser_contents_delegate.h"
#include "libcef/browser/browser_host_base.h"
#include "libcef/browser/browser_platform_delegate.h"
#include "libcef/browser/browser_util.h"
#include "libcef/browser/native/cursor_util.h"
#include "libcef/common/frame_util.h"
#include "content/browser/renderer_host/render_widget_host_impl.h"
#include "content/public/browser/focused_node_details.h"
#include "content/public/browser/keyboard_event_processing_result.h"
#include "content/public/browser/native_web_keyboard_event.h"
#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/navigation_handle.h"
#include "content/public/browser/notification_details.h"
#include "content/public/browser/notification_source.h"
#include "content/public/browser/notification_types.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/render_widget_host.h"
#include "content/public/browser/render_widget_host_observer.h"
#include "content/public/browser/render_widget_host_view.h"
#include "third_party/blink/public/mojom/favicon/favicon_url.mojom.h"
#include "third_party/blink/public/mojom/input/focus_type.mojom-blink.h"
#include "third_party/blink/public/mojom/widget/platform_widget.mojom-test-utils.h"
using content::KeyboardEventProcessingResult;
namespace {
class CefWidgetHostInterceptor
: public blink::mojom::WidgetHostInterceptorForTesting,
public content::RenderWidgetHostObserver {
public:
CefWidgetHostInterceptor(CefRefPtr<CefBrowser> browser,
content::RenderWidgetHost* render_widget_host)
: browser_(browser),
render_widget_host_(render_widget_host),
impl_(static_cast<content::RenderWidgetHostImpl*>(render_widget_host)
->widget_host_receiver_for_testing()
.SwapImplForTesting(this)) {
render_widget_host_->AddObserver(this);
}
CefWidgetHostInterceptor(const CefWidgetHostInterceptor&) = delete;
CefWidgetHostInterceptor& operator=(const CefWidgetHostInterceptor&) = delete;
blink::mojom::WidgetHost* GetForwardingInterface() override { return impl_; }
// WidgetHostInterceptorForTesting method:
void SetCursor(const ui::Cursor& cursor) override {
if (cursor_util::OnCursorChange(browser_, cursor)) {
// Don't change the cursor.
return;
}
GetForwardingInterface()->SetCursor(cursor);
}
// RenderWidgetHostObserver method:
void RenderWidgetHostDestroyed(
content::RenderWidgetHost* widget_host) override {
widget_host->RemoveObserver(this);
delete this;
}
private:
CefRefPtr<CefBrowser> const browser_;
content::RenderWidgetHost* const render_widget_host_;
blink::mojom::WidgetHost* const impl_;
};
} // namespace
CefBrowserContentsDelegate::CefBrowserContentsDelegate(
scoped_refptr<CefBrowserInfo> browser_info)
: browser_info_(browser_info) {
DCHECK(browser_info_->browser());
}
void CefBrowserContentsDelegate::ObserveWebContents(
content::WebContents* new_contents) {
WebContentsObserver::Observe(new_contents);
if (new_contents) {
registrar_.reset(new content::NotificationRegistrar);
// When navigating through the history, the restored NavigationEntry's title
// will be used. If the entry ends up having the same title after we return
// to it, as will usually be the case, the
// NOTIFICATION_WEB_CONTENTS_TITLE_UPDATED will then be suppressed, since
// the NavigationEntry's title hasn't changed.
registrar_->Add(this, content::NOTIFICATION_LOAD_STOP,
content::Source<content::NavigationController>(
&new_contents->GetController()));
// Make sure MaybeCreateFrame is called at least one time.
// Create the frame representation before OnAfterCreated is called for a new
// browser.
browser_info_->MaybeCreateFrame(new_contents->GetPrimaryMainFrame(),
false /* is_guest_view */);
// Make sure RenderWidgetCreated is called at least one time. This Observer
// is registered too late to catch the initial creation.
RenderWidgetCreated(new_contents->GetRenderViewHost()->GetWidget());
} else {
registrar_.reset();
}
}
void CefBrowserContentsDelegate::AddObserver(Observer* observer) {
observers_.AddObserver(observer);
}
void CefBrowserContentsDelegate::RemoveObserver(Observer* observer) {
observers_.RemoveObserver(observer);
}
// |source| may be NULL for navigations in the current tab, or if the
// navigation originates from a guest view via MaybeAllowNavigation.
content::WebContents* CefBrowserContentsDelegate::OpenURLFromTab(
content::WebContents* source,
const content::OpenURLParams& params) {
bool cancel = false;
if (auto c = client()) {
if (auto handler = c->GetRequestHandler()) {
// May return nullptr for omnibox navigations.
auto frame = browser()->GetFrame(params.frame_tree_node_id);
if (!frame) {
frame = browser()->GetMainFrame();
}
cancel = handler->OnOpenURLFromTab(
browser(), frame, params.url.spec(),
static_cast<cef_window_open_disposition_t>(params.disposition),
params.user_gesture);
}
}
// Returning nullptr will cancel the navigation.
return cancel ? nullptr : web_contents();
}
void CefBrowserContentsDelegate::LoadingStateChanged(
content::WebContents* source,
bool should_show_loading_ui) {
const int current_index =
source->GetController().GetLastCommittedEntryIndex();
const int max_index = source->GetController().GetEntryCount() - 1;
const bool is_loading = source->IsLoading();
const bool can_go_back = (current_index > 0);
const bool can_go_forward = (current_index < max_index);
// This method may be called multiple times in a row with |is_loading|
// true as a result of https://crrev.com/5e750ad0. Ignore the 2nd+ times.
if (is_loading_ == is_loading && can_go_back_ == can_go_back &&
can_go_forward_ == can_go_forward) {
return;
}
is_loading_ = is_loading;
can_go_back_ = can_go_back;
can_go_forward_ = can_go_forward;
OnStateChanged(State::kNavigation);
if (auto c = client()) {
if (auto handler = c->GetLoadHandler()) {
auto navigation_lock = browser_info_->CreateNavigationLock();
handler->OnLoadingStateChange(browser(), is_loading, can_go_back,
can_go_forward);
}
}
}
void CefBrowserContentsDelegate::UpdateTargetURL(content::WebContents* source,
const GURL& url) {
if (auto c = client()) {
if (auto handler = c->GetDisplayHandler()) {
handler->OnStatusMessage(browser(), url.spec());
}
}
}
bool CefBrowserContentsDelegate::DidAddMessageToConsole(
content::WebContents* source,
blink::mojom::ConsoleMessageLevel log_level,
const std::u16string& message,
int32_t line_no,
const std::u16string& source_id) {
if (auto c = client()) {
if (auto handler = c->GetDisplayHandler()) {
// Use LOGSEVERITY_DEBUG for unrecognized |level| values.
cef_log_severity_t cef_level = LOGSEVERITY_DEBUG;
switch (log_level) {
case blink::mojom::ConsoleMessageLevel::kVerbose:
cef_level = LOGSEVERITY_DEBUG;
break;
case blink::mojom::ConsoleMessageLevel::kInfo:
cef_level = LOGSEVERITY_INFO;
break;
case blink::mojom::ConsoleMessageLevel::kWarning:
cef_level = LOGSEVERITY_WARNING;
break;
case blink::mojom::ConsoleMessageLevel::kError:
cef_level = LOGSEVERITY_ERROR;
break;
}
return handler->OnConsoleMessage(browser(), cef_level, message, source_id,
line_no);
}
}
return false;
}
void CefBrowserContentsDelegate::EnterFullscreenModeForTab(
content::RenderFrameHost* requesting_frame,
const blink::mojom::FullscreenOptions& options) {
OnFullscreenModeChange(/*fullscreen=*/true);
}
void CefBrowserContentsDelegate::ExitFullscreenModeForTab(
content::WebContents* web_contents) {
OnFullscreenModeChange(/*fullscreen=*/false);
}
void CefBrowserContentsDelegate::CanDownload(
const GURL& url,
const std::string& request_method,
base::OnceCallback<void(bool)> callback) {
bool allow = true;
if (auto delegate = platform_delegate()) {
if (auto c = client()) {
if (auto handler = c->GetDownloadHandler()) {
allow = handler->CanDownload(browser(), url.spec(), request_method);
}
}
}
std::move(callback).Run(allow);
}
KeyboardEventProcessingResult
CefBrowserContentsDelegate::PreHandleKeyboardEvent(
content::WebContents* source,
const content::NativeWebKeyboardEvent& event) {
if (auto delegate = platform_delegate()) {
if (auto c = client()) {
if (auto handler = c->GetKeyboardHandler()) {
CefKeyEvent cef_event;
if (browser_util::GetCefKeyEvent(event, cef_event)) {
cef_event.focus_on_editable_field = focus_on_editable_field_;
auto event_handle = delegate->GetEventHandle(event);
bool is_keyboard_shortcut = false;
bool result = handler->OnPreKeyEvent(
browser(), cef_event, event_handle, &is_keyboard_shortcut);
if (result) {
return KeyboardEventProcessingResult::HANDLED;
} else if (is_keyboard_shortcut) {
return KeyboardEventProcessingResult::NOT_HANDLED_IS_SHORTCUT;
}
}
}
}
}
return KeyboardEventProcessingResult::NOT_HANDLED;
}
bool CefBrowserContentsDelegate::HandleKeyboardEvent(
content::WebContents* source,
const content::NativeWebKeyboardEvent& event) {
// Check to see if event should be ignored.
if (event.skip_in_browser) {
return false;
}
if (auto delegate = platform_delegate()) {
if (auto c = client()) {
if (auto handler = c->GetKeyboardHandler()) {
CefKeyEvent cef_event;
if (browser_util::GetCefKeyEvent(event, cef_event)) {
cef_event.focus_on_editable_field = focus_on_editable_field_;
auto event_handle = delegate->GetEventHandle(event);
if (handler->OnKeyEvent(browser(), cef_event, event_handle)) {
return true;
}
}
}
}
}
return false;
}
void CefBrowserContentsDelegate::RenderFrameCreated(
content::RenderFrameHost* render_frame_host) {
browser_info_->MaybeCreateFrame(render_frame_host, false /* is_guest_view */);
if (render_frame_host->GetParent() == nullptr) {
auto render_view_host = render_frame_host->GetRenderViewHost();
auto base_background_color = platform_delegate()->GetBackgroundColor();
if (browser_info_ && browser_info_->is_popup()) {
// force reset page base background color because popup window won't get
// the page base background from web_contents at the creation time
web_contents()->SetPageBaseBackgroundColor(SkColor());
web_contents()->SetPageBaseBackgroundColor(base_background_color);
}
if (render_view_host->GetWidget() &&
render_view_host->GetWidget()->GetView()) {
render_view_host->GetWidget()->GetView()->SetBackgroundColor(
base_background_color);
}
platform_delegate()->RenderViewCreated(render_view_host);
}
}
void CefBrowserContentsDelegate::RenderFrameHostChanged(
content::RenderFrameHost* old_host,
content::RenderFrameHost* new_host) {
// Just in case RenderFrameCreated wasn't called for some reason.
RenderFrameCreated(new_host);
}
void CefBrowserContentsDelegate::RenderFrameHostStateChanged(
content::RenderFrameHost* host,
content::RenderFrameHost::LifecycleState old_state,
content::RenderFrameHost::LifecycleState new_state) {
browser_info_->FrameHostStateChanged(host, old_state, new_state);
}
void CefBrowserContentsDelegate::RenderFrameDeleted(
content::RenderFrameHost* render_frame_host) {
const auto frame_id =
frame_util::MakeFrameId(render_frame_host->GetGlobalId());
browser_info_->RemoveFrame(render_frame_host);
if (focused_frame_ && focused_frame_->GetIdentifier() == frame_id) {
focused_frame_ = nullptr;
OnStateChanged(State::kFocusedFrame);
}
}
void CefBrowserContentsDelegate::RenderWidgetCreated(
content::RenderWidgetHost* render_widget_host) {
new CefWidgetHostInterceptor(browser(), render_widget_host);
}
void CefBrowserContentsDelegate::RenderViewReady() {
platform_delegate()->RenderViewReady();
if (auto c = client()) {
if (auto handler = c->GetRequestHandler()) {
handler->OnRenderViewReady(browser());
}
}
}
void CefBrowserContentsDelegate::PrimaryMainFrameRenderProcessGone(
base::TerminationStatus status) {
cef_termination_status_t ts = TS_ABNORMAL_TERMINATION;
if (status == base::TERMINATION_STATUS_PROCESS_WAS_KILLED) {
ts = TS_PROCESS_WAS_KILLED;
} else if (status == base::TERMINATION_STATUS_PROCESS_CRASHED) {
ts = TS_PROCESS_CRASHED;
} else if (status == base::TERMINATION_STATUS_OOM) {
ts = TS_PROCESS_OOM;
} else if (status != base::TERMINATION_STATUS_ABNORMAL_TERMINATION) {
return;
}
if (auto c = client()) {
if (auto handler = c->GetRequestHandler()) {
auto navigation_lock = browser_info_->CreateNavigationLock();
handler->OnRenderProcessTerminated(browser(), ts);
}
}
}
void CefBrowserContentsDelegate::OnFrameFocused(
content::RenderFrameHost* render_frame_host) {
CefRefPtr<CefFrameHostImpl> frame = static_cast<CefFrameHostImpl*>(
browser_info_->GetFrameForHost(render_frame_host).get());
if (!frame || frame->IsFocused()) {
return;
}
CefRefPtr<CefFrameHostImpl> previous_frame = focused_frame_;
if (frame->IsMain()) {
focused_frame_ = nullptr;
} else {
focused_frame_ = frame;
}
if (!previous_frame) {
// The main frame is focused by default.
previous_frame = browser_info_->GetMainFrame();
}
if (previous_frame->GetIdentifier() != frame->GetIdentifier()) {
previous_frame->SetFocused(false);
frame->SetFocused(true);
}
OnStateChanged(State::kFocusedFrame);
}
void CefBrowserContentsDelegate::PrimaryMainDocumentElementAvailable() {
has_document_ = true;
OnStateChanged(State::kDocument);
if (auto c = client()) {
if (auto handler = c->GetRequestHandler()) {
handler->OnDocumentAvailableInMainFrame(browser());
}
}
}
void CefBrowserContentsDelegate::LoadProgressChanged(double progress) {
if (auto c = client()) {
if (auto handler = c->GetDisplayHandler()) {
handler->OnLoadingProgressChange(browser(), progress);
}
}
}
void CefBrowserContentsDelegate::DidStopLoading() {
// Notify all renderers that loading has stopped. We used to use
// RenderFrameObserver::DidStopLoading in the renderer process but that was
// removed in https://crrev.com/3e37dd0ead. However, that callback wasn't
// necessarily accurate because it wasn't called in all of the cases where
// RenderFrameImpl sends the FrameHostMsg_DidStopLoading message. This adds
// an additional round trip but should provide the same or improved
// functionality.
for (const auto& frame : browser_info_->GetAllFrames()) {
frame->MaybeSendDidStopLoading();
}
}
void CefBrowserContentsDelegate::DidFinishNavigation(
content::NavigationHandle* navigation_handle) {
const net::Error error_code = navigation_handle->GetNetErrorCode();
// Skip calls where the navigation has not yet committed and there is no
// error code. For example, when creating a browser without loading a URL.
if (!navigation_handle->HasCommitted() && error_code == net::OK) {
return;
}
if (navigation_handle->IsInPrimaryMainFrame() &&
navigation_handle->HasCommitted()) {
// A primary main frame navigation has occured.
has_document_ = false;
OnStateChanged(State::kDocument);
}
const bool is_main_frame = navigation_handle->IsInMainFrame();
const auto global_id = frame_util::GetGlobalId(navigation_handle);
const GURL& url =
(error_code == net::OK ? navigation_handle->GetURL() : GURL());
auto browser_info = browser_info_;
if (!browser_info->browser()) {
// Ignore notifications when the browser is closing.
return;
}
// May return NULL when starting a new navigation if the previous navigation
// caused the renderer process to crash during load.
CefRefPtr<CefFrameHostImpl> frame =
browser_info->GetFrameForGlobalId(global_id);
if (!frame) {
if (is_main_frame) {
frame = browser_info->GetMainFrame();
} else {
frame = browser_info->CreateTempSubFrame(frame_util::InvalidGlobalId());
}
}
frame->RefreshAttributes();
if (error_code == net::OK) {
// The navigation has been committed and there is no error.
DCHECK(navigation_handle->HasCommitted());
// Don't call OnLoadStart for same page navigations (fragments,
// history state).
if (!navigation_handle->IsSameDocument()) {
OnLoadStart(frame.get(), navigation_handle->GetPageTransition());
if (navigation_handle->IsServedFromBackForwardCache()) {
// We won't get an OnLoadEnd notification from anywhere else.
OnLoadEnd(frame.get(), navigation_handle->GetURL(), 0);
}
}
if (is_main_frame) {
OnAddressChange(url);
}
} else {
// The navigation failed with an error. This may happen before commit
// (e.g. network error) or after commit (e.g. response filter error).
// If the error happened before commit then this call will originate from
// RenderFrameHostImpl::OnDidFailProvisionalLoadWithError.
// OnLoadStart/OnLoadEnd will not be called.
OnLoadError(frame.get(), navigation_handle->GetURL(), error_code);
}
}
void CefBrowserContentsDelegate::DidFailLoad(
content::RenderFrameHost* render_frame_host,
const GURL& validated_url,
int error_code) {
// The navigation failed after commit. OnLoadStart was called so we also
// call OnLoadEnd.
auto frame = browser_info_->GetFrameForHost(render_frame_host);
frame->RefreshAttributes();
OnLoadError(frame, validated_url, error_code);
OnLoadEnd(frame, validated_url, error_code);
}
void CefBrowserContentsDelegate::DidFinishLoad(
content::RenderFrameHost* render_frame_host,
const GURL& validated_url) {
auto frame = browser_info_->GetFrameForHost(render_frame_host);
frame->RefreshAttributes();
int http_status_code = 0;
if (auto response_headers = render_frame_host->GetLastResponseHeaders()) {
http_status_code = response_headers->response_code();
}
OnLoadEnd(frame, validated_url, http_status_code);
}
void CefBrowserContentsDelegate::TitleWasSet(content::NavigationEntry* entry) {
// |entry| may be NULL if a popup is created via window.open and never
// navigated.
if (entry) {
OnTitleChange(entry->GetTitle());
} else if (web_contents()) {
OnTitleChange(web_contents()->GetTitle());
}
}
void CefBrowserContentsDelegate::DidUpdateFaviconURL(
content::RenderFrameHost* render_frame_host,
const std::vector<blink::mojom::FaviconURLPtr>& candidates) {
if (auto c = client()) {
if (auto handler = c->GetDisplayHandler()) {
std::vector<CefString> icon_urls;
for (const auto& icon : candidates) {
if (icon->icon_type == blink::mojom::FaviconIconType::kFavicon) {
icon_urls.push_back(icon->icon_url.spec());
}
}
if (!icon_urls.empty()) {
handler->OnFaviconURLChange(browser(), icon_urls);
}
}
}
}
void CefBrowserContentsDelegate::OnWebContentsFocused(
content::RenderWidgetHost* render_widget_host) {
if (auto c = client()) {
if (auto handler = c->GetFocusHandler()) {
handler->OnGotFocus(browser());
}
}
}
void CefBrowserContentsDelegate::OnFocusChangedInPage(
content::FocusedNodeDetails* details) {
focus_on_editable_field_ =
details->focus_type != blink::mojom::blink::FocusType::kNone &&
details->is_editable_node;
}
void CefBrowserContentsDelegate::WebContentsDestroyed() {
auto wc = web_contents();
ObserveWebContents(nullptr);
for (auto& observer : observers_) {
observer.OnWebContentsDestroyed(wc);
}
}
void CefBrowserContentsDelegate::Observe(
int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) {
DCHECK_EQ(type, content::NOTIFICATION_LOAD_STOP);
if (type == content::NOTIFICATION_LOAD_STOP) {
OnTitleChange(web_contents()->GetTitle());
}
}
bool CefBrowserContentsDelegate::OnSetFocus(cef_focus_source_t source) {
// SetFocus() might be called while inside the OnSetFocus() callback. If
// so, don't re-enter the callback.
if (is_in_onsetfocus_) {
return true;
}
if (auto c = client()) {
if (auto handler = c->GetFocusHandler()) {
is_in_onsetfocus_ = true;
bool handled = handler->OnSetFocus(browser(), source);
is_in_onsetfocus_ = false;
return handled;
}
}
return false;
}
CefRefPtr<CefClient> CefBrowserContentsDelegate::client() const {
if (auto b = browser()) {
return b->GetHost()->GetClient();
}
return nullptr;
}
CefRefPtr<CefBrowser> CefBrowserContentsDelegate::browser() const {
return browser_info_->browser();
}
CefBrowserPlatformDelegate* CefBrowserContentsDelegate::platform_delegate()
const {
auto browser = browser_info_->browser();
if (browser) {
return browser->platform_delegate();
}
return nullptr;
}
void CefBrowserContentsDelegate::OnAddressChange(const GURL& url) {
if (auto c = client()) {
if (auto handler = c->GetDisplayHandler()) {
// On the handler of an address change.
handler->OnAddressChange(browser(), browser_info_->GetMainFrame(),
url.spec());
}
}
}
void CefBrowserContentsDelegate::OnLoadStart(
CefRefPtr<CefFrame> frame,
ui::PageTransition transition_type) {
if (auto c = client()) {
if (auto handler = c->GetLoadHandler()) {
auto navigation_lock = browser_info_->CreateNavigationLock();
// On the handler that loading has started.
handler->OnLoadStart(browser(), frame,
static_cast<cef_transition_type_t>(transition_type));
}
}
}
void CefBrowserContentsDelegate::OnLoadEnd(CefRefPtr<CefFrame> frame,
const GURL& url,
int http_status_code) {
if (auto c = client()) {
if (auto handler = c->GetLoadHandler()) {
auto navigation_lock = browser_info_->CreateNavigationLock();
handler->OnLoadEnd(browser(), frame, http_status_code);
}
}
}
void CefBrowserContentsDelegate::OnLoadError(CefRefPtr<CefFrame> frame,
const GURL& url,
int error_code) {
if (auto c = client()) {
if (auto handler = c->GetLoadHandler()) {
auto navigation_lock = browser_info_->CreateNavigationLock();
// On the handler that loading has failed.
handler->OnLoadError(browser(), frame,
static_cast<cef_errorcode_t>(error_code),
net::ErrorToShortString(error_code), url.spec());
}
}
}
void CefBrowserContentsDelegate::OnTitleChange(const std::u16string& title) {
if (auto c = client()) {
if (auto handler = c->GetDisplayHandler()) {
handler->OnTitleChange(browser(), title);
}
}
}
void CefBrowserContentsDelegate::OnFullscreenModeChange(bool fullscreen) {
if (fullscreen == is_fullscreen_) {
return;
}
is_fullscreen_ = fullscreen;
OnStateChanged(State::kFullscreen);
if (auto c = client()) {
if (auto handler = c->GetDisplayHandler()) {
handler->OnFullscreenModeChange(browser(), fullscreen);
}
}
}
void CefBrowserContentsDelegate::OnStateChanged(State state_changed) {
for (auto& observer : observers_) {
observer.OnStateChanged(state_changed);
}
}
| [
"magreenblatt@gmail.com"
] | magreenblatt@gmail.com |
f3a03e49da7039a2e548b8fcfc0971738d1eebe1 | 0c8f829d81685604ce28bf6310a77206c172271a | /Metadata/Variant.h | c24a3ebbb1fb1b1b3fe9d5404e0f2a9dafbfed6c | [] | no_license | feliperobledo/Portafolio | 71300db2ace5e3d89557ea58276aad12ffc0912b | c9561afdba26e9f4d39cb8aaa82602fa04ce65ca | refs/heads/master | 2021-05-31T13:09:07.777510 | 2014-10-02T18:25:48 | 2014-10-02T18:25:48 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,169 | h | /********************************************************************
File: Variant.h
Date Created: 11/20/13
Purpose: Defines the interface of a Variant.
A Variant is a generic container that can represent any
sort of data type, be it user defined or primitive.
This is a component of the reflection system, and it is
widely use for script integration.
********************************************************************/
#pragma once
#include "MetaMacros.h"
#include "Metadata.h"
class Variant
{
public:
template <typename Type>
Variant(const Type& data) : m_MetaData(META_TYPE(Type)),
m_Data(NULL)
{
m_Data = m_MetaData->NewCopy<Type>(data);
}
~Variant(void);
template <typename Type>
Type* Cast(void)
{
return reinterpret_cast<Type*>(m_Data);
}
template <typename Type>
Type& GetValue(void)
{
return *Cast<Type*>();
}
template <typename Type>
const Type& GetValue(void) const
{
return *Cast<Type*>();
}
const char* GetType(void) const;
bool GetIsValid(void) const;
template <typename Type>
Variant& operator=(const Type& rhs)
{
if(m_MetaData != META_TYPE(Type))
{
//have an assert here for asserting that we cannot
//create metadata about NULL
//As a possible optimization one could actually avoid
//creating a new buffer if the size of the incoming
//type is less than the size currently held by the
//Variant.
m_MetaData->Delete(m_Data);
m_MetaData = META_TYPE(Type);
m_MetaData = m_MetaData->NewCopy(reinterpret_cast<void*>(rhs));
}
else
{
m_MetaData->Copy(m_Data,rhs);
}
return *this;
}
private:
const Metadata* m_MetaData;
void* m_Data;
bool m_IsValid;
}; | [
"gamedev_fantasy@hotmail.com"
] | gamedev_fantasy@hotmail.com |
47e074bd7086a0a06e7f31af0c1813e366ad2ac2 | 03a486c8efbb766837557eb4dc0790fb52c59cff | /libGUI3D/include/GUI3D/GUI3D.h | 2d6eeeadbcfd8072a67339dac358a7539fc3f511 | [] | no_license | PNeigel/libGUI3D | 958779a2e18aeb4efc511321a66aafa4a2c9e883 | ca7c69eb88ec5ac12c760bbef20111df742cee4f | refs/heads/master | 2023-07-05T17:59:55.939307 | 2021-08-17T17:41:50 | 2021-08-17T17:41:50 | 395,382,271 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,975 | h | #pragma once
#include <functional>
#include "../../../libGUI/GUI.h"
#include "glShader.hpp"
#include "glCamera.hpp"
#include "projection_control.hpp"
#include "glMesh.hpp"
#include "glUtils.hpp"
#include <map>
#include "camera_control.h"
#include "glImageRenderer.h"
#ifdef COMPILE_WITH_FREETYPE
#include <ft2build.h>
#include <memory>
#include FT_FREETYPE_H
#endif
namespace SC{
struct Character {
GLuint TextureID; // ID handle of the glyph texture
glm::ivec2 Size; // Size of glyph
glm::ivec2 Bearing; // Offset from baseline to left/top of glyph
GLuint Advance; // Horizontal offset to advance to next glyph
};
class FPSManager{
public:
explicit FPSManager(double targetFPS = 30.0){
fpsCounter_ = fps_ = targetFPS;
diff_ = 0;
fps_time_pre_ = fps_time_ = lasttime_ = -1;
targetFPS_ = targetFPS;
maxPeriod_ = 1.0 / targetFPS_;
}
/// Prevent unstable image jumpping.
void wait(){
if(lasttime_ > 0)
while (glfwGetTime() < lasttime_ + maxPeriod_);
lasttime_ = glfwGetTime();
}
void updateFPS(){
stop();
if(fps_time_pre_ < 0) { // init
start();
return;
}
checkUpdate();
}
inline void start(){
fps_time_pre_ = glfwGetTime();
}
inline void stop(){
fps_time_ = glfwGetTime();
}
inline void checkUpdate(){
diff_ += fps_time_-fps_time_pre_;
fpsCounter_++;
if (diff_ > 1.0) {
fps_ = double(fpsCounter_) / diff_;
fpsCounter_ = 0;
fps_time_pre_ += diff_;
diff_=0;
}
}
// double getFPS(){return fps_;}
double& getFPS(){return fps_;}
private:
double fps_time_pre_, fps_time_, targetFPS_, fps_;
double maxPeriod_, lasttime_;
unsigned short fpsCounter_;
double diff_;
};
struct task_element_t {
GLFWWindowContainer* window_;
int key_;
const std::function< void() > no_id;
std::string description;
explicit task_element_t(GLFWWindowContainer* window, int key, std::function< void() > f, std::string description) :
window_(window), key_(key), no_id(std::move(f)), description(std::move(description)) { }
};
class GUI3D : public GUI_base{
public:
explicit GUI3D(const std::string &name, int width, int height, bool visible=true);
virtual ~GUI3D();
virtual void drawUI();
virtual void drawGL();
void run() override;
inline void run_once();
/// Adding new key callback
template <typename Task> void registerKeyFunciton(GLFWWindowContainer* window, int key, Task func, const std::string &description = ""){
registeredFunctions_.emplace_back(window,key,static_cast<std::function< void() >>(func), description);
}
void showRegisteredKeyFunction();
// Eigen::Matrix4f getCameraPose() {
// Eigen::Matrix4f newT;
// memcpy(newT.data(), glm::value_ptr(camera_control->GetViewMatrix()), 16 * sizeof(float));
// memcpy(newT.topRightCorner(3, 1).data(), glm::value_ptr(camera_control->Position), 3 * sizeof(float));
// return newT;
// }
void setPlotTracjectory(bool option) {bPlotTrajectory = option;}
glUtil::Camera* GetCam(){return glCam.get();}
void RenderText(const std::string &text, float pos_x, float pos_y, float scale, const glm::vec3 &color);
protected:
std::map<std::string, unsigned int> glBuffers, glVertexArrays, glFrameBuffers, glTextures;
std::map<std::string, glUtil::Shader*> glShaders;
std::map<std::string, glUtil::Model_base*> glObjests;
// std::map<std::string, glUtil::Model*> glModels;
std::map<GLchar, Character> Characters;
std::map<int, bool> bKeyProcessFinished;
FPSManager *fps_;
bool bShowGrid, bShowFPS;
bool bPlotTrajectory;
std::atomic_bool bShouldStop;
struct task_element_t {
GLFWWindowContainer* window_;
int key_;
const std::function< void() > no_id;
std::string description;
explicit task_element_t(GLFWWindowContainer* window, int key, std::function< void() > f, std::string description) :
window_(window), key_(key), no_id(std::move(f)), description(std::move(description)) { }
};
std::vector<task_element_t> registeredFunctions_;
std::vector<glm::vec3> trajectories_;
void RenderText(GLuint VAO, GLuint VBO, glUtil::Shader *shader, std::string text, GLfloat x, GLfloat y, GLfloat scale, glm::vec3 color);
virtual void processInput(GLFWwindow* window);
virtual void basicInputRegistration();
virtual void basicProcess();
virtual void plot_trajectory(const glm::mat4 *projection);
virtual void add_trajectory(float x, float y, float z, float interval=0.002);
void key_callback_impl(GLFWwindow* window, int key, int scancode, int action, int mods) override;
/// return true is something changed
bool mouseControl();
// virtual void scroll_callback_impl(GLFWwindow* window, double xoffset, double yoffset);
// virtual void mouse_callback_impl(GLFWwindow *window, double xpos, double ypos);
void buildScreen();
void buildCamera();
void buildGrid();
void buildText();
void buildFreeType();
void buildTrajectory();
bool bShowCameraUI;
void cameraUI();
std::unique_ptr<glUtil::Camera> glCam;
glm::vec3 camPose, camUp;
float yaw, pitch, fov, fovMax, camSpeed;
private:
int init();
};
}
| [
"shuncheng.wu91@gmail.com"
] | shuncheng.wu91@gmail.com |
2ebf6f9cd80259b366752ec00cb73df62e9801de | 7a138fa71d3e08958d8443992e2d57d504bb593a | /codeforces/round-290/div-2/fox_and_two_dots.cpp | 18db9dbc6f2eda6ac40b065b1133c43fd65b0117 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | sustcoderboy/competitive-programming-archive | 8a254e7542d9f616df73d8aaa9ca23d6242dec9b | 2cd3237f376c609b7c4e87804e36a8cac7ec3402 | refs/heads/master | 2021-01-22T17:38:41.565826 | 2015-11-22T03:50:00 | 2015-11-22T03:50:00 | 46,705,756 | 1 | 0 | null | 2015-11-23T08:10:07 | 2015-11-23T08:10:07 | null | UTF-8 | C++ | false | false | 1,684 | cpp | #include <iostream>
#include <utility>
#include <vector>
using namespace std;
const vector<pair<int, int>> deltas {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
inline
void use_io_optimizations()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
}
bool visit(unsigned int x,
unsigned int y,
unsigned int from_x,
unsigned int from_y,
const vector<vector<char>>& board,
vector<vector<bool>>& visited)
{
visited[x][y] = true;
for (const auto& delta : deltas)
{
unsigned int next_x {x + delta.first};
unsigned int next_y {y + delta.second};
if (board[x][y] == board[next_x][next_y] &&
!(next_x == from_x && next_y == from_y))
{
if (visited[next_x][next_y] ||
visit(next_x, next_y, x, y, board, visited))
{
return true;
}
}
}
return false;
}
int main()
{
use_io_optimizations();
unsigned int rows;
unsigned int columns;
cin >> rows >> columns;
vector<vector<char>> board(rows + 2, vector<char>(columns + 2));
for (unsigned int i {1}; i <= rows; ++i)
{
cin >> board[i].data() + 1;
}
vector<vector<bool>> visited(rows + 2, vector<bool>(columns + 2));
for (unsigned int i {1}; i <= rows; ++i)
{
for (unsigned int j {1}; j <= columns; ++j)
{
if (!visited[i][j])
{
if (visit(i, j, 0, 0, board, visited))
{
cout << "Yes\n";
return 0;
}
}
}
}
cout << "No\n";
return 0;
}
| [
"gsshopov@gmail.com"
] | gsshopov@gmail.com |
888da7fd8d5f6ac9e3f31c1a63919c247a910aad | a1732b958ae73657900585a4e8991a05072212d6 | /2022/day18/main.cpp | b135a4383317c24dace3756b5b0452e33e432033 | [
"MIT"
] | permissive | bielskij/AOC | 97fca8183955caf4d46967ac1bf4b00d9dc04f12 | 270aa757f9025d8da399adbc5db214f47ef0b6de | refs/heads/master | 2023-01-08T10:23:40.667070 | 2022-12-29T07:58:04 | 2022-12-29T07:58:04 | 226,080,843 | 3 | 0 | null | 2020-12-09T08:27:49 | 2019-12-05T10:57:02 | C++ | UTF-8 | C++ | false | false | 4,243 | cpp | #include <cassert>
#include <deque>
#include "common/types.h"
#include "utils/file.h"
#include "utils/utils.h"
#define DEBUG_LEVEL 5
#include "common/debug.h"
struct Side {
Point3d<int> start;
Point3d<int> end;
Side(const Point3d<int> &start, const Point3d<int> &end) : start(start), end(end) {
}
uint64_t getId() const {
uint64_t ret = end.z();
ret <<= 8; ret |= end.y();
ret <<= 8; ret |= end.x();
ret <<= 8; ret |= start.z();
ret <<= 8; ret |= start.y();
ret <<= 8; ret |= start.x();
return ret;
}
};
static uint32_t toId(const Point3d<int> p) {
uint32_t ret = p.z();
ret <<= 8; ret |= p.y();
ret <<= 8; ret |= p.x();
return ret;
}
std::vector<Point3d<int>> getNeighbours(const Point3d<int> &pos) {
return {
{ pos.x() + 1, pos.y() , pos.z() },
{ pos.x() - 1, pos.y() , pos.z() },
{ pos.x() , pos.y() , pos.z() - 1},
{ pos.x() , pos.y() , pos.z() + 1},
{ pos.x() , pos.y() + 1, pos.z() },
{ pos.x() , pos.y() - 1, pos.z() }
};
}
struct Cube {
Cube() : Cube(Point3d<int>()) {
}
Cube(const Point3d<int> &pos) : pos(pos) {
// front
sides.push_back(Side(Point3d<int>(pos.x() , pos.y() , pos.z() ), Point3d<int>(pos.x() + 1, pos.y() + 1, pos.z() )));
// top
sides.push_back(Side(Point3d<int>(pos.x() , pos.y() + 1, pos.z() ), Point3d<int>(pos.x() + 1, pos.y() + 1, pos.z() - 1)));
// back
sides.push_back(Side(Point3d<int>(pos.x() , pos.y() , pos.z() - 1), Point3d<int>(pos.x() + 1, pos.y() + 1, pos.z() - 1)));
// botton
sides.push_back(Side(Point3d<int>(pos.x() , pos.y() , pos.z() ), Point3d<int>(pos.x() + 1, pos.y() , pos.z() - 1)));
// right
sides.push_back(Side(Point3d<int>(pos.x() + 1, pos.y() , pos.z() ), Point3d<int>(pos.x() + 1, pos.y() + 1, pos.z() - 1)));
// left
sides.push_back(Side(Point3d<int>(pos.x() , pos.y() , pos.z() ), Point3d<int>(pos.x() , pos.y() + 1, pos.z() - 1)));
}
uint32_t getId() const {
return toId(pos);
}
Point3d<int> pos;
std::vector<Side> sides;
};
int main(int argc, char *argv[]) {
auto lines = File::readAllLines(argv[1]);
std::map<uint32_t, Cube> cubes;
for (auto &l : lines) {
auto coords = utils::toIntV<int>(utils::strTok(l, ','));
assert(coords.size() == 3);
auto cube = Cube(Point3d<int>(coords[0], coords[1], coords[2]));
cubes[cube.getId()] = cube;
}
{
std::map<uint64_t, int> sides;
for (auto &cube : cubes) {
for (auto &side : cube.second.sides) {
sides[side.getId()]++;
}
}
int partA = 0;
for (auto &s : sides) {
if (s.second == 1) {
partA++;
}
}
PRINTF(("PART_A: %zd", partA));
}
{
Point3d<int> min(std::numeric_limits<int>::max(), std::numeric_limits<int>::max(), std::numeric_limits<int>::max());
Point3d<int> max(std::numeric_limits<int>::min(), std::numeric_limits<int>::min(), std::numeric_limits<int>::min());
for (auto &cube : cubes) {
for (int i = 0; i < 3; i++) {
if (cube.second.pos.get(i) < min.get(i)) {
min.set(i, cube.second.pos.get(i));
}
if (cube.second.pos.get(i) > max.get(i)) {
max.set(i, cube.second.pos.get(i));
}
}
}
for (int i = 0; i < 3; i++) {
min.set(i, min.get(i) - 1);
max.set(i, max.get(i) + 1);
}
{
std::set<uint32_t> visited;
std::deque<Point3d<int>> queue;
queue.push_back(min);
visited.insert(toId(min));
while (! queue.empty()) {
Point3d<int> current = queue.front(); queue.pop_front();
for (auto &n : getNeighbours(current)) {
auto id = toId(n);
bool valid = true;
for (int i = 0; i < 3; i++) {
if (n.get(i) < min.get(i) || n.get(i) > max.get(i)) {
valid = false;
break;
}
}
if (! valid) {
continue;
}
if (visited.find(id) != visited.end()) {
continue;
}
if (cubes.find(id) != cubes.end()) {
continue;
}
queue.push_back(n);
visited.insert(id);
}
}
{
int result = 0;
for (auto &c : cubes) {
for (auto &n : getNeighbours(c.second.pos)) {
if (visited.find(toId(n)) != visited.end()) {
result++;
}
}
}
PRINTF(("PART_B: %d", result));
}
}
}
return 0;
}
| [
"bielski.j@gmail.com"
] | bielski.j@gmail.com |
47e16afc81733148250fe27111b5f79bd93727fc | f889f293e02526c95d7b7aeba441339bb595443b | /Source/Building_Escape_2/Building_Escape_2.cpp | a9cc7167fd2ef40a2dd4d04e693c08dbb7a5d6f6 | [] | no_license | Reetro/Building-Escape-2 | f0749e3d972b5d63658ac70b7ab423c6092f092d | 91703d8d2f73f5436c96e93dfc5cefa5d36e3fd1 | refs/heads/master | 2020-09-30T06:38:49.892930 | 2019-12-11T01:45:07 | 2019-12-11T01:45:07 | 227,230,075 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 244 | cpp | // Fill out your copyright notice in the Description page of Project Settings.
#include "Building_Escape_2.h"
#include "Modules/ModuleManager.h"
IMPLEMENT_PRIMARY_GAME_MODULE( FDefaultGameModuleImpl, Building_Escape_2, "Building_Escape_2" );
| [
"thegamerboy7@gmail.com"
] | thegamerboy7@gmail.com |
77479cdff7b409a9362bd064faaffb4ee496a790 | a9c74b8149cb5706ba0b585c791db6dc0c610ad9 | /src/Editor.cpp | 41336d6a6cfb45351953bf1f6bcf62b148cc2009 | [] | no_license | tschicke/Voxel-Editor | b719ae74096ab5a8e0e282154f5cda5048102bb4 | b94e2fd7f7557970b008619ad3580ee6f263c209 | refs/heads/master | 2020-04-07T16:06:32.848235 | 2013-07-27T03:48:05 | 2013-07-27T03:48:05 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 224 | cpp | /*
* Editor.cpp
*
* Created on: Jun 23, 2013
* Author: Tyler
*/
#include "Editor.h"
Editor::Editor() {
// TODO Auto-generated constructor stub
}
Editor::~Editor() {
// TODO Auto-generated destructor stub
}
| [
"tschicke@optonline.net"
] | tschicke@optonline.net |
dd04de6fee9a7869334d3a633c9642b3a1a3863b | d92f0cc58ba71870f84012ece859eb9cd6d65abf | /gfx_engine/resourcecontainer.h | 793938ddb52d1bfe3deee9095b4cbc11d6770257 | [] | no_license | Arkaniy/SDL | 7537a7941c1ea195444084f52618d7eb74cf5a0c | 628343cd0758f12061a30dd6d075a927c0364b22 | refs/heads/master | 2020-04-06T04:53:10.116284 | 2016-11-14T20:27:50 | 2016-11-14T20:27:50 | 73,748,791 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 302 | h | #ifndef IMAGECONTAINER_H
#define IMAGECONTAINER_H
#include <SDL2/SDL_image.h>
#include <SDL2/SDL_ttf.h>
#include <map>
class ResourceContainer {
public:
static std::map<std::string, SDL_Texture*> imageContainer;
static std::map<std::string, TTF_Font*> fontContainer;
};
#endif // IMAGECONTAINER_H
| [
"qwerty@localhost.localdomain"
] | qwerty@localhost.localdomain |
0f36c7bd0000b837c5a76f5d85b8c005d7bbc3d1 | 0eff74b05b60098333ad66cf801bdd93becc9ea4 | /second/download/squid/gumtree/squid_repos_function_3994_squid-3.4.14.cpp | 3c706ff84873a858e8c5ce2cdb8805f69e3b544f | [] | no_license | niuxu18/logTracker-old | 97543445ea7e414ed40bdc681239365d33418975 | f2b060f13a0295387fe02187543db124916eb446 | refs/heads/master | 2021-09-13T21:39:37.686481 | 2017-12-11T03:36:34 | 2017-12-11T03:36:34 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 757 | cpp | void
Adaptation::Ecap::XactionRep::visitEachMetaHeader(libecap::NamedValueVisitor &visitor) const
{
HttpRequest *request = dynamic_cast<HttpRequest*>(theCauseRep ?
theCauseRep->raw().header : theVirginRep.raw().header);
Must(request);
HttpReply *reply = dynamic_cast<HttpReply*>(theVirginRep.raw().header);
typedef Notes::iterator ACAMLI;
for (ACAMLI i = Adaptation::Config::metaHeaders.begin(); i != Adaptation::Config::metaHeaders.end(); ++i) {
const char *v = (*i)->match(request, reply);
if (v) {
const libecap::Name name((*i)->key.termedBuf());
const libecap::Area value = libecap::Area::FromTempString(v);
visitor.visit(name, value);
}
}
} | [
"993273596@qq.com"
] | 993273596@qq.com |
64e8bdc527ae6ffd6cb005c65a10cb2c36f4cc04 | 17c2b92d214e0de9145c5e73983da729852430dc | /game.cpp | 7002c5e609614cc29b372b9cf8b53776a998323c | [] | no_license | Giowans/Arkanoid_KenGio | fe8567930b93ed58d45c051b9e05a18ffb2895e5 | 42b900b133850c7f7dceee8c3b4347ed884e9b74 | refs/heads/master | 2020-05-26T14:23:44.408077 | 2019-05-23T15:58:42 | 2019-05-23T15:58:42 | 188,262,967 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,547 | cpp | #include "game.h"
#include <fstream>
#include <iostream>
#include <SDL_ttf.h>
using namespace std;
bool Game::getIsRunning() const
{
return isRunning;
}
void Game::setIsRunning(bool value)
{
isRunning = value;
}
SDL_Window *Game::getWindow() const
{
return window;
}
void Game::setWindow(SDL_Window *value)
{
window = value;
}
SDL_Renderer *Game::getRenderer() const
{
return renderer;
}
void Game::setRenderer(SDL_Renderer *value)
{
renderer = value;
}
int Game::getScreenWidth() const
{
return screenWidth;
}
void Game::setScreenWidth(int value)
{
screenWidth = value;
}
int Game::getScreenHeight() const
{
return screenHeight;
}
void Game::setScreenHeight(int value)
{
screenHeight = value;
}
Game::Game()
{
string gt;
isRunning = false;
cout<<"\t\t\t\tEL ARKANOID DEL GIO 7u7"<<endl;
cout<<endl<<"Ingresa tu gamertag: ";
fflush(stdin);
getline(cin, gt);
jugador.setNombre(gt);
jugador.setPuntaje(0);
}
void Game::init(const char *title, int w, int h, bool fullscreen)
{
int flags = 0;
screenWidth = w;
screenHeight = h;
if (fullscreen)
flags = SDL_WINDOW_FULLSCREEN;
//renderer
if (SDL_Init(SDL_INIT_EVERYTHING) == 0)
{
//SDL_CreateWindow(titulo, posX, posY, ancho, alto, banderas)
TTF_Init();
window = SDL_CreateWindow(title,
SDL_WINDOWPOS_CENTERED,
SDL_WINDOWPOS_CENTERED,
screenWidth,
screenHeight,
flags);
font = TTF_OpenFont("comic.ttf", 14);
txtcolor = {221, 247, 113};
txtcolorbg={0, 0, 0};
sprintf(textito, "Jugador: %s \nPuntaje: %i", jugador.getNombre().c_str(), jugador.getPuntaje());
surf = TTF_RenderText_Shaded(font, textito, txtcolor, txtcolorbg);
renderer = SDL_CreateRenderer(window, -1, 0);
if (renderer)
{
//SDL_SetRenderDrawColor(renderer, r, g, b, alpha)
// r, g y b son valores entre 0 y 255
// 0, 0, 0 es color negro
// 255, 255, 255, es color blanco
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
//Inicializamos el texto del renderizador de los records
texture =SDL_CreateTextureFromSurface(renderer, surf);
int texW = 0;
int texH = 0;
SDL_QueryTexture(texture, NULL, NULL, &texW, &texH);
SDL_Rect dstrect = { 0, 0, texW, texH };
SDL_RenderCopy(renderer, texture, NULL, &dstrect);
SDL_RenderPresent(renderer);
}
else
cout <<"couldn't initialize renderer " <<SDL_GetError() <<endl;
isRunning = true;
}
}
void Game::escribirJugadores()
{
ofstream outputFile("jugadores.txt", ios::app);
if (!outputFile.is_open())
{
cout << "No se pudo abrir el archivo de escritura"<<endl;
}
else
{
outputFile<<jugador<<endl;
}
outputFile.close();
}
void Game::leerJugadores()
{
ifstream inputFile("jugadores.txt", ios::app);
if (!inputFile.is_open())
{
cout<<"No se pudo abrir el archivo de lectura..."<<endl;
}
else
{
Jugadores j;
while(inputFile >>j)
{
cout << j <<endl;
}
}
inputFile.close();
}
Jugadores Game::getJugador()
{
return jugador;
}
void Game::setJugador(Jugadores aux)
{
jugador = aux;
} | [
"gio_tails@live.com"
] | gio_tails@live.com |
ed35c040e0a40696f289d4b741e202da923db2cd | 948f4e13af6b3014582909cc6d762606f2a43365 | /testcases/juliet_test_suite/testcases/CWE36_Absolute_Path_Traversal/s01/CWE36_Absolute_Path_Traversal__char_connect_socket_ifstream_42.cpp | ed6855ed88eea15aba33d0cc18133082fdf5c80f | [] | no_license | junxzm1990/ASAN-- | 0056a341b8537142e10373c8417f27d7825ad89b | ca96e46422407a55bed4aa551a6ad28ec1eeef4e | refs/heads/master | 2022-08-02T15:38:56.286555 | 2022-06-16T22:19:54 | 2022-06-16T22:19:54 | 408,238,453 | 74 | 13 | null | 2022-06-16T22:19:55 | 2021-09-19T21:14:59 | null | UTF-8 | C++ | false | false | 5,536 | cpp | /* TEMPLATE GENERATED TESTCASE FILE
Filename: CWE36_Absolute_Path_Traversal__char_connect_socket_ifstream_42.cpp
Label Definition File: CWE36_Absolute_Path_Traversal.label.xml
Template File: sources-sink-42.tmpl.cpp
*/
/*
* @description
* CWE: 36 Absolute Path Traversal
* BadSource: connect_socket Read data using a connect socket (client side)
* GoodSource: Full path and file name
* Sink: ifstream
* BadSink : Open the file named in data using ifstream::open()
* Flow Variant: 42 Data flow: data returned from one function to another in the same source file
*
* */
#include "std_testcase.h"
#ifndef _WIN32
#include <wchar.h>
#endif
#ifdef _WIN32
#include <winsock2.h>
#include <windows.h>
#include <direct.h>
#pragma comment(lib, "ws2_32") /* include ws2_32.lib when linking */
#define CLOSE_SOCKET closesocket
#else /* NOT _WIN32 */
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <unistd.h>
#define INVALID_SOCKET -1
#define SOCKET_ERROR -1
#define CLOSE_SOCKET close
#define SOCKET int
#endif
#define TCP_PORT 27015
#define IP_ADDRESS "127.0.0.1"
#include <fstream>
using namespace std;
namespace CWE36_Absolute_Path_Traversal__char_connect_socket_ifstream_42
{
#ifndef OMITBAD
static char * badSource(char * data)
{
{
#ifdef _WIN32
WSADATA wsaData;
int wsaDataInit = 0;
#endif
int recvResult;
struct sockaddr_in service;
char *replace;
SOCKET connectSocket = INVALID_SOCKET;
size_t dataLen = strlen(data);
do
{
#ifdef _WIN32
if (WSAStartup(MAKEWORD(2,2), &wsaData) != NO_ERROR)
{
break;
}
wsaDataInit = 1;
#endif
/* POTENTIAL FLAW: Read data using a connect socket */
connectSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
if (connectSocket == INVALID_SOCKET)
{
break;
}
memset(&service, 0, sizeof(service));
service.sin_family = AF_INET;
service.sin_addr.s_addr = inet_addr(IP_ADDRESS);
service.sin_port = htons(TCP_PORT);
if (connect(connectSocket, (struct sockaddr*)&service, sizeof(service)) == SOCKET_ERROR)
{
break;
}
/* Abort on error or the connection was closed, make sure to recv one
* less char than is in the recv_buf in order to append a terminator */
/* Abort on error or the connection was closed */
recvResult = recv(connectSocket, (char *)(data + dataLen), sizeof(char) * (FILENAME_MAX - dataLen - 1), 0);
if (recvResult == SOCKET_ERROR || recvResult == 0)
{
break;
}
/* Append null terminator */
data[dataLen + recvResult / sizeof(char)] = '\0';
/* Eliminate CRLF */
replace = strchr(data, '\r');
if (replace)
{
*replace = '\0';
}
replace = strchr(data, '\n');
if (replace)
{
*replace = '\0';
}
}
while (0);
if (connectSocket != INVALID_SOCKET)
{
CLOSE_SOCKET(connectSocket);
}
#ifdef _WIN32
if (wsaDataInit)
{
WSACleanup();
}
#endif
}
return data;
}
void bad()
{
char * data;
char dataBuffer[FILENAME_MAX] = "";
data = dataBuffer;
data = badSource(data);
{
ifstream inputFile;
/* POTENTIAL FLAW: Possibly opening a file without validating the file name or path */
inputFile.open((char *)data);
inputFile.close();
}
}
#endif /* OMITBAD */
#ifndef OMITGOOD
static char * goodG2BSource(char * data)
{
#ifdef _WIN32
/* FIX: Use a fixed, full path and file name */
strcat(data, "c:\\temp\\file.txt");
#else
/* FIX: Use a fixed, full path and file name */
strcat(data, "/tmp/file.txt");
#endif
return data;
}
/* goodG2B() uses the GoodSource with the BadSink */
static void goodG2B()
{
char * data;
char dataBuffer[FILENAME_MAX] = "";
data = dataBuffer;
data = goodG2BSource(data);
{
ifstream inputFile;
/* POTENTIAL FLAW: Possibly opening a file without validating the file name or path */
inputFile.open((char *)data);
inputFile.close();
}
}
void good()
{
goodG2B();
}
#endif /* OMITGOOD */
} /* close namespace */
/* Below is the main(). It is only used when building this testcase on
its own for testing or for building a binary to use in testing binary
analysis tools. It is not used when compiling all the testcases as one
application, which is how source code analysis tools are tested. */
#ifdef INCLUDEMAIN
using namespace CWE36_Absolute_Path_Traversal__char_connect_socket_ifstream_42; /* so that we can use good and bad easily */
int main(int argc, char * argv[])
{
/* seed randomness */
srand( (unsigned)time(NULL) );
#ifndef OMITGOOD
printLine("Calling good()...");
good();
printLine("Finished good()");
#endif /* OMITGOOD */
#ifndef OMITBAD
printLine("Calling bad()...");
bad();
printLine("Finished bad()");
#endif /* OMITBAD */
return 0;
}
#endif
| [
"yzhang0701@gmail.com"
] | yzhang0701@gmail.com |
a18b74fb053e0039ff5eb40c84b78e5a8e9e0963 | 75308d8ced993356014c8e998bd64e71b4c0211c | /Data Structure/tree.h | b10f86b59e5c2371db4176ffa2ee54fb4e9a3953 | [] | no_license | zettt8214/LeetCode | 332b8afe536ed47e7c69625a9056f7feb122b302 | c9ad38f312bd15cabac1dcca7646fb85a5e83ff4 | refs/heads/master | 2023-02-26T20:27:18.996218 | 2021-02-06T05:19:42 | 2021-02-06T05:19:42 | 327,228,442 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,974 | h | #pragma once
#include <iostream>
#include <vector>
#include "list.h"
using std::vector;
struct TreeNode {
int val;
TreeNode* left;
TreeNode* right;
TreeNode() : val(0), left(nullptr), right(nullptr) {}
TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
TreeNode(int x, TreeNode* left, TreeNode* right) : val(x), left(left), right(right) {}
};
TreeNode* createTree(vector<int> nodes);
int maxDepth(TreeNode* root); /// 104. Maximum Depth of Binary Tree
bool isBalanced(TreeNode* root); /// 110. Balanced Binary Tree
int diameterOfBinaryTree(TreeNode* root); /// 543. Diameter of Binary Tree
int pathSum(TreeNode* root, int sum); /// 437. Path Sum III
vector<TreeNode*> delNodes(TreeNode* root, vector<int>& to_delete); /// 1110. Delete Nodes And Return Forest
vector<double> averageOfLevels(TreeNode* root); /// 637. Average of Levels in Binary Tree
TreeNode* buildTree(vector<int>& preorder, vector<int>& inorder); /// 105. Construct Binary Tree from Preorder and Inorder Traversal
vector<int> preorderTraversal(TreeNode* root); /// 144. Binary Tree Preorder Traversal
void recoverTree(TreeNode* root); /// 99. Recover Binary Search Tree
TreeNode* trimBST(TreeNode* root, int low, int high); /// 669. Trim a Binary Search Tree
TreeNode* invertTree(TreeNode* root); /// 226. Invert Binary Tree
TreeNode* mergeTrees(TreeNode* t1, TreeNode* t2); /// 617. Merge Two Binary Trees
bool isSubtree(TreeNode* s, TreeNode* t); /// 572. Subtree of Another Tree
int sumOfLeftLeaves(TreeNode* root); /// 404. Sum of Left Leaves
int findBottomLeftValue(TreeNode* root); /// 513. Find Bottom Left Tree Value
TreeNode* lowestCommonAncestor(TreeNode* root, TreeNode* p, TreeNode* q); /// 235. Lowest Common Ancestor of a Binary Search Tree
int getMinimumDifference(TreeNode* root); /// 530. Minimum Absolute Difference in BST
TreeNode* convertBST(TreeNode* root); /// 538. Convert BST to Greater Tree
TreeNode* increasingBST(TreeNode* root); /// 897. Increasing Order Search Tree
bool findTarget(TreeNode* root, int k); /// 653. Two Sum IV - Input is a BST
TreeNode* constructFromPrePost(vector<int>& pre, vector<int>& post); /// 889. Construct Binary Tree from Preorder and Postorder Traversal
TreeNode* buildTree2(vector<int>& inorder, vector<int>& postorder); /// 106. Construct Binary Tree from Inorder and Postorder Traversal
vector<int> inorderTraversal(TreeNode* root); /// 94. Binary Tree Inorder Traversal
vector<int> postorderTraversal(TreeNode* root); /// 145. Binary Tree Postorder Traversal
TreeNode* lowestCommonAncestor2(TreeNode* root, TreeNode* p, TreeNode* q); /// 236. Lowest Common Ancestor of a Binary Tree
TreeNode* sortedListToBST(ListNode* head); /// 109. Convert Sorted List to Binary Search Tree
TreeNode* deleteNode(TreeNode* root, int key); /// 450. Delete Node in a BST | [
"xiaohao8214@gmail.com"
] | xiaohao8214@gmail.com |
ab5fa3b8a38e1f2dad2eca410dcd51a7383a9365 | fd67a49fcf915b7c9b7ecefcaec7ccdce068a2ba | /trunk/include/net/connection.h | 212d874954fea6f4cda1c335b950025e33020ee6 | [] | no_license | Misery-cn/moth | b369c0ffe65daf17a7281ecf24b2342450d94958 | 0fd6c03c6822e28d4b54a2c13b8b380b880fc3d2 | refs/heads/master | 2021-12-14T14:29:35.469888 | 2021-12-06T15:00:52 | 2021-12-06T15:00:52 | 48,629,699 | 2 | 1 | null | 2016-08-12T09:39:18 | 2015-12-27T02:08:19 | C++ | UTF-8 | C++ | false | false | 3,130 | h | #ifndef _CONNECTION_H_
#define _CONNECTION_H_
#include "time_utils.h"
#include "ref_countable.h"
#include "mutex.h"
class Messenger;
class Message;
class Connection : public RefCountable
{
public:
Connection(Messenger* m) : _lock(), _msgr(m), _priv(NULL), _peer_type(-1), _failed(false), _rx_buffers_version(0)
{
}
virtual ~Connection()
{
if (_priv)
{
_priv->dec();
}
}
Messenger* get_messenger() { return _msgr; }
/**
* 设置引用
*
*/
void set_priv(RefCountable* ref)
{
// MutexGuard(_lock);
Mutex::Locker locker(_lock);
// 之前的引用-1
if (_priv)
{
_priv->dec();
}
_priv = ref;
}
/**
* 获取引用
*
*/
RefCountable* get_priv()
{
// MutexGuard(_lock);
Mutex::Locker locker(_lock);
if (_priv)
{
return _priv->get();
}
return NULL;
}
virtual bool is_connected() = 0;
virtual int send_message(Message* m) = 0;
virtual void send_keepalive() = 0;
virtual void mark_disposable() = 0;
virtual void mark_down() = 0;
int get_peer_type() const { return _peer_type; }
void set_peer_type(int t) { _peer_type = t; }
/**
* 获取连接的地址
*
*/
const entity_addr_t& get_peer_addr() const { return _peer_addr; }
/**
* 设置连接地址
*
*/
void set_peer_addr(const entity_addr_t& a) { _peer_addr = a; }
void post_rx_buffer(uint64_t tid, buffer& buf)
{
Mutex::Locker locker(_lock);
++_rx_buffers_version;
_rx_buffers[tid] = std::pair<buffer, int>(buf, _rx_buffers_version);
}
void revoke_rx_buffer(uint64_t tid)
{
Mutex::Locker l(_lock);
_rx_buffers.erase(tid);
}
/**
* 获取上一次的心跳时间
*
*/
utime_t get_last_keepalive() const
{
Mutex::Locker locker(_lock);
return _last_keepalive;
}
/**
* 设置最新的心跳时间
*
*/
void set_last_keepalive(utime_t t)
{
Mutex::Locker locker(_lock);
_last_keepalive = t;
}
/**
* 获取上一次的心跳ack时间
*
*/
utime_t get_last_keepalive_ack() const
{
Mutex::Locker locker(_lock);
return _last_keepalive_ack;
}
/**
* 设置最新的心跳ack时间
*
*/
void set_last_keepalive_ack(utime_t t)
{
Mutex::Locker locker(_lock);
_last_keepalive_ack = t;
}
public:
mutable Mutex _lock;
Messenger* _msgr;
RefCountable* _priv;
// entity_name_t中的通信实体类型
int _peer_type;
// 连接的地址(对端)
entity_addr_t _peer_addr;
// 最新的心跳时间
utime_t _last_keepalive;
// 最新的心跳ack时间
utime_t _last_keepalive_ack;
// 连接状态
bool _failed;
int _rx_buffers_version;
std::map<uint64_t, std::pair<buffer, int> > _rx_buffers;
friend class SocketConnection;
};
#endif
| [
"shangshi622@163.com"
] | shangshi622@163.com |
ce1409a2f76e69eddb3283890dcdd27210102ed3 | 0456169f170bc28d03eab6876d90ac4075ed7f77 | /src/include/Layers/ExampleLayer3.h | 41adedd95d63d5389b164823d7313d298c7786b6 | [] | no_license | hiplayer/FirstSkiaApp | 7220ba3f7292dde1ca5bf35bf1e9a6738af21eee | 100e6b7a0250fd5b88658a39b863c2600c5f61fd | refs/heads/master | 2023-05-13T23:54:55.876011 | 2021-06-10T14:37:25 | 2021-06-10T14:37:25 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 438 | h | #ifndef EXAMPLELAYER3_H_F0693353_488C_432D_A3D9_D0B3E3BFCD9B
#define EXAMPLELAYER3_H_F0693353_488C_432D_A3D9_D0B3E3BFCD9B
#include "BaseLayer.h"
#include "Utils/RandomShapes.h"
class ExampleLayer3 final : public BaseRandomShapeLayer
{
public:
std::wstring GetTitle() const override { return L"Example #3: Draw random shapes on click"; };
void Draw(SkCanvas* canvas);
};
#endif // EXAMPLELAYER3_H_F0693353_488C_432D_A3D9_D0B3E3BFCD9B
| [
"vyere@softserveinc.com"
] | vyere@softserveinc.com |
3bbae9345dfea8c538dae6d70dbb1f8602b93a5b | 419e55c56c5ed91f82657ae451db4dc5ae3dfcce | /practice/SeniorHigh1/semester2/April/20220410/P3397.cpp | 028c34e391fa4280d8211570b50d98f4c170b834 | [] | no_license | AlexWei061/cpp | 6e267bea4f163f77245fd2b66863b34edb7e64aa | f5f124b0c37b81036932e79290fb5cebcc7f1a5b | refs/heads/master | 2022-07-15T06:17:46.061007 | 2022-07-09T06:55:26 | 2022-07-09T06:55:26 | 216,490,498 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 778 | cpp | #include<bits/stdc++.h>
using namespace std;
#define in read()
#define MAXN 1010
inline int read(){
int x = 0; char c = getchar();
while(c < '0' or c > '9') c = getchar();
while('0' <= c and c <= '9'){
x = x * 10 + c - '0'; c = getchar();
}
return x;
}
int n = 0; int m = 0;
int a[MAXN][MAXN] = { 0 };
int c[MAXN][MAXN] = { 0 };
int main(){
n = in; m = in;
for(int i = 1; i <= m; i++){
int xs = in; int ys = in;
int xe = in; int ye = in;
for(int j = xs; j <= xe; j++)
c[j][ys]++, c[j][ye + 1]--;
}
for(int i = 1; i <= n; i++){
for(int j = 1; j <= n; j++){
a[i][j] = a[i][j - 1] + c[i][j];
cout << a[i][j] << ' ';
}
puts("");
}
return 0;
} | [
"ty.wei@foxmail.com"
] | ty.wei@foxmail.com |
a699344b290e8fac879e20fe6a267097dc17ae58 | c776476e9d06b3779d744641e758ac3a2c15cddc | /examples/litmus/c/run-scripts/tmp_5/Z6.2+dmb.st+dmb.ld+po.c.cbmc_out.cpp | 75ca47936b00602017dab2eb815731b47d379d14 | [] | no_license | ashutosh0gupta/llvm_bmc | aaac7961c723ba6f7ffd77a39559e0e52432eade | 0287c4fb180244e6b3c599a9902507f05c8a7234 | refs/heads/master | 2023-08-02T17:14:06.178723 | 2023-07-31T10:46:53 | 2023-07-31T10:46:53 | 143,100,825 | 3 | 4 | null | 2023-05-25T05:50:55 | 2018-08-01T03:47:00 | C++ | UTF-8 | C++ | false | false | 39,756 | cpp | // Global variabls:
// 4:atom_2_X0_1:1
// 0:vars:3
// 3:atom_1_X0_1:1
// Local global variabls:
// 0:thr0:1
// 1:thr1:1
// 2:thr2:1
#define ADDRSIZE 5
#define LOCALADDRSIZE 3
#define NTHREAD 4
#define NCONTEXT 5
#define ASSUME(stmt) __CPROVER_assume(stmt)
#define ASSERT(stmt) __CPROVER_assert(stmt, "error")
#define max(a,b) (a>b?a:b)
char __get_rng();
char get_rng( char from, char to ) {
char ret = __get_rng();
ASSUME(ret >= from && ret <= to);
return ret;
}
char get_rng_th( char from, char to ) {
char ret = __get_rng();
ASSUME(ret >= from && ret <= to);
return ret;
}
int main(int argc, char **argv) {
// Declare arrays for intial value version in contexts
int local_mem[LOCALADDRSIZE];
// Dumping initializations
local_mem[0+0] = 0;
local_mem[1+0] = 0;
local_mem[2+0] = 0;
int cstart[NTHREAD];
int creturn[NTHREAD];
// declare arrays for contexts activity
int active[NCONTEXT];
int ctx_used[NCONTEXT];
// declare arrays for intial value version in contexts
int meminit_[ADDRSIZE*NCONTEXT];
#define meminit(x,k) meminit_[(x)*NCONTEXT+k]
int coinit_[ADDRSIZE*NCONTEXT];
#define coinit(x,k) coinit_[(x)*NCONTEXT+k]
int deltainit_[ADDRSIZE*NCONTEXT];
#define deltainit(x,k) deltainit_[(x)*NCONTEXT+k]
// declare arrays for running value version in contexts
int mem_[ADDRSIZE*NCONTEXT];
#define mem(x,k) mem_[(x)*NCONTEXT+k]
int co_[ADDRSIZE*NCONTEXT];
#define co(x,k) co_[(x)*NCONTEXT+k]
int delta_[ADDRSIZE*NCONTEXT];
#define delta(x,k) delta_[(x)*NCONTEXT+k]
// declare arrays for local buffer and observed writes
int buff_[NTHREAD*ADDRSIZE];
#define buff(x,k) buff_[(x)*ADDRSIZE+k]
int pw_[NTHREAD*ADDRSIZE];
#define pw(x,k) pw_[(x)*ADDRSIZE+k]
// declare arrays for context stamps
char cr_[NTHREAD*ADDRSIZE];
#define cr(x,k) cr_[(x)*ADDRSIZE+k]
char iw_[NTHREAD*ADDRSIZE];
#define iw(x,k) iw_[(x)*ADDRSIZE+k]
char cw_[NTHREAD*ADDRSIZE];
#define cw(x,k) cw_[(x)*ADDRSIZE+k]
char cx_[NTHREAD*ADDRSIZE];
#define cx(x,k) cx_[(x)*ADDRSIZE+k]
char is_[NTHREAD*ADDRSIZE];
#define is(x,k) is_[(x)*ADDRSIZE+k]
char cs_[NTHREAD*ADDRSIZE];
#define cs(x,k) cs_[(x)*ADDRSIZE+k]
char crmax_[NTHREAD*ADDRSIZE];
#define crmax(x,k) crmax_[(x)*ADDRSIZE+k]
char sforbid_[ADDRSIZE*NCONTEXT];
#define sforbid(x,k) sforbid_[(x)*NCONTEXT+k]
// declare arrays for synchronizations
int cl[NTHREAD];
int cdy[NTHREAD];
int cds[NTHREAD];
int cdl[NTHREAD];
int cisb[NTHREAD];
int caddr[NTHREAD];
int cctrl[NTHREAD];
int r0= 0;
char creg_r0;
char creg__r0__1_;
int r1= 0;
char creg_r1;
char creg__r1__1_;
int r2= 0;
char creg_r2;
int r3= 0;
char creg_r3;
int r4= 0;
char creg_r4;
int r5= 0;
char creg_r5;
int r6= 0;
char creg_r6;
char creg__r6__2_;
int r7= 0;
char creg_r7;
int r8= 0;
char creg_r8;
int r9= 0;
char creg_r9;
int r10= 0;
char creg_r10;
char creg__r10__1_;
int r11= 0;
char creg_r11;
char old_cctrl= 0;
char old_cr= 0;
char old_cdy= 0;
char old_cw= 0;
char new_creg= 0;
buff(0,0) = 0;
pw(0,0) = 0;
cr(0,0) = 0;
iw(0,0) = 0;
cw(0,0) = 0;
cx(0,0) = 0;
is(0,0) = 0;
cs(0,0) = 0;
crmax(0,0) = 0;
buff(0,1) = 0;
pw(0,1) = 0;
cr(0,1) = 0;
iw(0,1) = 0;
cw(0,1) = 0;
cx(0,1) = 0;
is(0,1) = 0;
cs(0,1) = 0;
crmax(0,1) = 0;
buff(0,2) = 0;
pw(0,2) = 0;
cr(0,2) = 0;
iw(0,2) = 0;
cw(0,2) = 0;
cx(0,2) = 0;
is(0,2) = 0;
cs(0,2) = 0;
crmax(0,2) = 0;
buff(0,3) = 0;
pw(0,3) = 0;
cr(0,3) = 0;
iw(0,3) = 0;
cw(0,3) = 0;
cx(0,3) = 0;
is(0,3) = 0;
cs(0,3) = 0;
crmax(0,3) = 0;
buff(0,4) = 0;
pw(0,4) = 0;
cr(0,4) = 0;
iw(0,4) = 0;
cw(0,4) = 0;
cx(0,4) = 0;
is(0,4) = 0;
cs(0,4) = 0;
crmax(0,4) = 0;
cl[0] = 0;
cdy[0] = 0;
cds[0] = 0;
cdl[0] = 0;
cisb[0] = 0;
caddr[0] = 0;
cctrl[0] = 0;
cstart[0] = get_rng(0,NCONTEXT-1);
creturn[0] = get_rng(0,NCONTEXT-1);
buff(1,0) = 0;
pw(1,0) = 0;
cr(1,0) = 0;
iw(1,0) = 0;
cw(1,0) = 0;
cx(1,0) = 0;
is(1,0) = 0;
cs(1,0) = 0;
crmax(1,0) = 0;
buff(1,1) = 0;
pw(1,1) = 0;
cr(1,1) = 0;
iw(1,1) = 0;
cw(1,1) = 0;
cx(1,1) = 0;
is(1,1) = 0;
cs(1,1) = 0;
crmax(1,1) = 0;
buff(1,2) = 0;
pw(1,2) = 0;
cr(1,2) = 0;
iw(1,2) = 0;
cw(1,2) = 0;
cx(1,2) = 0;
is(1,2) = 0;
cs(1,2) = 0;
crmax(1,2) = 0;
buff(1,3) = 0;
pw(1,3) = 0;
cr(1,3) = 0;
iw(1,3) = 0;
cw(1,3) = 0;
cx(1,3) = 0;
is(1,3) = 0;
cs(1,3) = 0;
crmax(1,3) = 0;
buff(1,4) = 0;
pw(1,4) = 0;
cr(1,4) = 0;
iw(1,4) = 0;
cw(1,4) = 0;
cx(1,4) = 0;
is(1,4) = 0;
cs(1,4) = 0;
crmax(1,4) = 0;
cl[1] = 0;
cdy[1] = 0;
cds[1] = 0;
cdl[1] = 0;
cisb[1] = 0;
caddr[1] = 0;
cctrl[1] = 0;
cstart[1] = get_rng(0,NCONTEXT-1);
creturn[1] = get_rng(0,NCONTEXT-1);
buff(2,0) = 0;
pw(2,0) = 0;
cr(2,0) = 0;
iw(2,0) = 0;
cw(2,0) = 0;
cx(2,0) = 0;
is(2,0) = 0;
cs(2,0) = 0;
crmax(2,0) = 0;
buff(2,1) = 0;
pw(2,1) = 0;
cr(2,1) = 0;
iw(2,1) = 0;
cw(2,1) = 0;
cx(2,1) = 0;
is(2,1) = 0;
cs(2,1) = 0;
crmax(2,1) = 0;
buff(2,2) = 0;
pw(2,2) = 0;
cr(2,2) = 0;
iw(2,2) = 0;
cw(2,2) = 0;
cx(2,2) = 0;
is(2,2) = 0;
cs(2,2) = 0;
crmax(2,2) = 0;
buff(2,3) = 0;
pw(2,3) = 0;
cr(2,3) = 0;
iw(2,3) = 0;
cw(2,3) = 0;
cx(2,3) = 0;
is(2,3) = 0;
cs(2,3) = 0;
crmax(2,3) = 0;
buff(2,4) = 0;
pw(2,4) = 0;
cr(2,4) = 0;
iw(2,4) = 0;
cw(2,4) = 0;
cx(2,4) = 0;
is(2,4) = 0;
cs(2,4) = 0;
crmax(2,4) = 0;
cl[2] = 0;
cdy[2] = 0;
cds[2] = 0;
cdl[2] = 0;
cisb[2] = 0;
caddr[2] = 0;
cctrl[2] = 0;
cstart[2] = get_rng(0,NCONTEXT-1);
creturn[2] = get_rng(0,NCONTEXT-1);
buff(3,0) = 0;
pw(3,0) = 0;
cr(3,0) = 0;
iw(3,0) = 0;
cw(3,0) = 0;
cx(3,0) = 0;
is(3,0) = 0;
cs(3,0) = 0;
crmax(3,0) = 0;
buff(3,1) = 0;
pw(3,1) = 0;
cr(3,1) = 0;
iw(3,1) = 0;
cw(3,1) = 0;
cx(3,1) = 0;
is(3,1) = 0;
cs(3,1) = 0;
crmax(3,1) = 0;
buff(3,2) = 0;
pw(3,2) = 0;
cr(3,2) = 0;
iw(3,2) = 0;
cw(3,2) = 0;
cx(3,2) = 0;
is(3,2) = 0;
cs(3,2) = 0;
crmax(3,2) = 0;
buff(3,3) = 0;
pw(3,3) = 0;
cr(3,3) = 0;
iw(3,3) = 0;
cw(3,3) = 0;
cx(3,3) = 0;
is(3,3) = 0;
cs(3,3) = 0;
crmax(3,3) = 0;
buff(3,4) = 0;
pw(3,4) = 0;
cr(3,4) = 0;
iw(3,4) = 0;
cw(3,4) = 0;
cx(3,4) = 0;
is(3,4) = 0;
cs(3,4) = 0;
crmax(3,4) = 0;
cl[3] = 0;
cdy[3] = 0;
cds[3] = 0;
cdl[3] = 0;
cisb[3] = 0;
caddr[3] = 0;
cctrl[3] = 0;
cstart[3] = get_rng(0,NCONTEXT-1);
creturn[3] = get_rng(0,NCONTEXT-1);
// Dumping initializations
mem(4+0,0) = 0;
mem(0+0,0) = 0;
mem(0+1,0) = 0;
mem(0+2,0) = 0;
mem(3+0,0) = 0;
// Dumping context matching equalities
co(0,0) = 0;
delta(0,0) = -1;
mem(0,1) = meminit(0,1);
co(0,1) = coinit(0,1);
delta(0,1) = deltainit(0,1);
mem(0,2) = meminit(0,2);
co(0,2) = coinit(0,2);
delta(0,2) = deltainit(0,2);
mem(0,3) = meminit(0,3);
co(0,3) = coinit(0,3);
delta(0,3) = deltainit(0,3);
mem(0,4) = meminit(0,4);
co(0,4) = coinit(0,4);
delta(0,4) = deltainit(0,4);
co(1,0) = 0;
delta(1,0) = -1;
mem(1,1) = meminit(1,1);
co(1,1) = coinit(1,1);
delta(1,1) = deltainit(1,1);
mem(1,2) = meminit(1,2);
co(1,2) = coinit(1,2);
delta(1,2) = deltainit(1,2);
mem(1,3) = meminit(1,3);
co(1,3) = coinit(1,3);
delta(1,3) = deltainit(1,3);
mem(1,4) = meminit(1,4);
co(1,4) = coinit(1,4);
delta(1,4) = deltainit(1,4);
co(2,0) = 0;
delta(2,0) = -1;
mem(2,1) = meminit(2,1);
co(2,1) = coinit(2,1);
delta(2,1) = deltainit(2,1);
mem(2,2) = meminit(2,2);
co(2,2) = coinit(2,2);
delta(2,2) = deltainit(2,2);
mem(2,3) = meminit(2,3);
co(2,3) = coinit(2,3);
delta(2,3) = deltainit(2,3);
mem(2,4) = meminit(2,4);
co(2,4) = coinit(2,4);
delta(2,4) = deltainit(2,4);
co(3,0) = 0;
delta(3,0) = -1;
mem(3,1) = meminit(3,1);
co(3,1) = coinit(3,1);
delta(3,1) = deltainit(3,1);
mem(3,2) = meminit(3,2);
co(3,2) = coinit(3,2);
delta(3,2) = deltainit(3,2);
mem(3,3) = meminit(3,3);
co(3,3) = coinit(3,3);
delta(3,3) = deltainit(3,3);
mem(3,4) = meminit(3,4);
co(3,4) = coinit(3,4);
delta(3,4) = deltainit(3,4);
co(4,0) = 0;
delta(4,0) = -1;
mem(4,1) = meminit(4,1);
co(4,1) = coinit(4,1);
delta(4,1) = deltainit(4,1);
mem(4,2) = meminit(4,2);
co(4,2) = coinit(4,2);
delta(4,2) = deltainit(4,2);
mem(4,3) = meminit(4,3);
co(4,3) = coinit(4,3);
delta(4,3) = deltainit(4,3);
mem(4,4) = meminit(4,4);
co(4,4) = coinit(4,4);
delta(4,4) = deltainit(4,4);
// Dumping thread 1
int ret_thread_1 = 0;
cdy[1] = get_rng(0,NCONTEXT-1);
ASSUME(cdy[1] >= cstart[1]);
T1BLOCK0:
// call void @llvm.dbg.value(metadata i8* %arg, metadata !36, metadata !DIExpression()), !dbg !45
// br label %label_1, !dbg !46
goto T1BLOCK1;
T1BLOCK1:
// call void @llvm.dbg.label(metadata !44), !dbg !47
// call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 0), metadata !37, metadata !DIExpression()), !dbg !48
// call void @llvm.dbg.value(metadata i64 2, metadata !40, metadata !DIExpression()), !dbg !48
// store atomic i64 2, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 0) monotonic, align 8, !dbg !49
// ST: Guess
iw(1,0) = get_rng(0,NCONTEXT-1);// 1 ASSIGN STIW _l20_c3
old_cw = cw(1,0);
cw(1,0) = get_rng(0,NCONTEXT-1);// 1 ASSIGN STCOM _l20_c3
// Check
ASSUME(active[iw(1,0)] == 1);
ASSUME(active[cw(1,0)] == 1);
ASSUME(sforbid(0,cw(1,0))== 0);
ASSUME(iw(1,0) >= 0);
ASSUME(iw(1,0) >= 0);
ASSUME(cw(1,0) >= iw(1,0));
ASSUME(cw(1,0) >= old_cw);
ASSUME(cw(1,0) >= cr(1,0));
ASSUME(cw(1,0) >= cl[1]);
ASSUME(cw(1,0) >= cisb[1]);
ASSUME(cw(1,0) >= cdy[1]);
ASSUME(cw(1,0) >= cdl[1]);
ASSUME(cw(1,0) >= cds[1]);
ASSUME(cw(1,0) >= cctrl[1]);
ASSUME(cw(1,0) >= caddr[1]);
// Update
caddr[1] = max(caddr[1],0);
buff(1,0) = 2;
mem(0,cw(1,0)) = 2;
co(0,cw(1,0))+=1;
delta(0,cw(1,0)) = -1;
ASSUME(creturn[1] >= cw(1,0));
// call void (...) @dmbst(), !dbg !50
// dumbst: Guess
cds[1] = get_rng(0,NCONTEXT-1);
// Check
ASSUME(cds[1] >= cdy[1]);
ASSUME(cds[1] >= cw(1,4+0));
ASSUME(cds[1] >= cw(1,0+0));
ASSUME(cds[1] >= cw(1,0+1));
ASSUME(cds[1] >= cw(1,0+2));
ASSUME(cds[1] >= cw(1,3+0));
ASSUME(creturn[1] >= cds[1]);
// call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 1), metadata !41, metadata !DIExpression()), !dbg !51
// call void @llvm.dbg.value(metadata i64 1, metadata !43, metadata !DIExpression()), !dbg !51
// store atomic i64 1, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 1) monotonic, align 8, !dbg !52
// ST: Guess
iw(1,0+1*1) = get_rng(0,NCONTEXT-1);// 1 ASSIGN STIW _l22_c3
old_cw = cw(1,0+1*1);
cw(1,0+1*1) = get_rng(0,NCONTEXT-1);// 1 ASSIGN STCOM _l22_c3
// Check
ASSUME(active[iw(1,0+1*1)] == 1);
ASSUME(active[cw(1,0+1*1)] == 1);
ASSUME(sforbid(0+1*1,cw(1,0+1*1))== 0);
ASSUME(iw(1,0+1*1) >= 0);
ASSUME(iw(1,0+1*1) >= 0);
ASSUME(cw(1,0+1*1) >= iw(1,0+1*1));
ASSUME(cw(1,0+1*1) >= old_cw);
ASSUME(cw(1,0+1*1) >= cr(1,0+1*1));
ASSUME(cw(1,0+1*1) >= cl[1]);
ASSUME(cw(1,0+1*1) >= cisb[1]);
ASSUME(cw(1,0+1*1) >= cdy[1]);
ASSUME(cw(1,0+1*1) >= cdl[1]);
ASSUME(cw(1,0+1*1) >= cds[1]);
ASSUME(cw(1,0+1*1) >= cctrl[1]);
ASSUME(cw(1,0+1*1) >= caddr[1]);
// Update
caddr[1] = max(caddr[1],0);
buff(1,0+1*1) = 1;
mem(0+1*1,cw(1,0+1*1)) = 1;
co(0+1*1,cw(1,0+1*1))+=1;
delta(0+1*1,cw(1,0+1*1)) = -1;
ASSUME(creturn[1] >= cw(1,0+1*1));
// ret i8* null, !dbg !53
ret_thread_1 = (- 1);
goto T1BLOCK_END;
T1BLOCK_END:
// Dumping thread 2
int ret_thread_2 = 0;
cdy[2] = get_rng(0,NCONTEXT-1);
ASSUME(cdy[2] >= cstart[2]);
T2BLOCK0:
// call void @llvm.dbg.value(metadata i8* %arg, metadata !56, metadata !DIExpression()), !dbg !66
// br label %label_2, !dbg !48
goto T2BLOCK1;
T2BLOCK1:
// call void @llvm.dbg.label(metadata !65), !dbg !68
// call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 1), metadata !58, metadata !DIExpression()), !dbg !69
// %0 = load atomic i64, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 1) monotonic, align 8, !dbg !51
// LD: Guess
old_cr = cr(2,0+1*1);
cr(2,0+1*1) = get_rng(0,NCONTEXT-1);// 2 ASSIGN LDCOM _l28_c15
// Check
ASSUME(active[cr(2,0+1*1)] == 2);
ASSUME(cr(2,0+1*1) >= iw(2,0+1*1));
ASSUME(cr(2,0+1*1) >= 0);
ASSUME(cr(2,0+1*1) >= cdy[2]);
ASSUME(cr(2,0+1*1) >= cisb[2]);
ASSUME(cr(2,0+1*1) >= cdl[2]);
ASSUME(cr(2,0+1*1) >= cl[2]);
// Update
creg_r0 = cr(2,0+1*1);
crmax(2,0+1*1) = max(crmax(2,0+1*1),cr(2,0+1*1));
caddr[2] = max(caddr[2],0);
if(cr(2,0+1*1) < cw(2,0+1*1)) {
r0 = buff(2,0+1*1);
ASSUME((!(( (cw(2,0+1*1) < 1) && (1 < crmax(2,0+1*1)) )))||(sforbid(0+1*1,1)> 0));
ASSUME((!(( (cw(2,0+1*1) < 2) && (2 < crmax(2,0+1*1)) )))||(sforbid(0+1*1,2)> 0));
ASSUME((!(( (cw(2,0+1*1) < 3) && (3 < crmax(2,0+1*1)) )))||(sforbid(0+1*1,3)> 0));
ASSUME((!(( (cw(2,0+1*1) < 4) && (4 < crmax(2,0+1*1)) )))||(sforbid(0+1*1,4)> 0));
} else {
if(pw(2,0+1*1) != co(0+1*1,cr(2,0+1*1))) {
ASSUME(cr(2,0+1*1) >= old_cr);
}
pw(2,0+1*1) = co(0+1*1,cr(2,0+1*1));
r0 = mem(0+1*1,cr(2,0+1*1));
}
ASSUME(creturn[2] >= cr(2,0+1*1));
// call void @llvm.dbg.value(metadata i64 %0, metadata !60, metadata !DIExpression()), !dbg !69
// %conv = trunc i64 %0 to i32, !dbg !52
// call void @llvm.dbg.value(metadata i32 %conv, metadata !57, metadata !DIExpression()), !dbg !66
// call void (...) @dmbld(), !dbg !53
// dumbld: Guess
cdl[2] = get_rng(0,NCONTEXT-1);
// Check
ASSUME(cdl[2] >= cdy[2]);
ASSUME(cdl[2] >= cr(2,4+0));
ASSUME(cdl[2] >= cr(2,0+0));
ASSUME(cdl[2] >= cr(2,0+1));
ASSUME(cdl[2] >= cr(2,0+2));
ASSUME(cdl[2] >= cr(2,3+0));
ASSUME(creturn[2] >= cdl[2]);
// call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 2), metadata !61, metadata !DIExpression()), !dbg !73
// call void @llvm.dbg.value(metadata i64 1, metadata !63, metadata !DIExpression()), !dbg !73
// store atomic i64 1, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 2) monotonic, align 8, !dbg !55
// ST: Guess
iw(2,0+2*1) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STIW _l30_c3
old_cw = cw(2,0+2*1);
cw(2,0+2*1) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STCOM _l30_c3
// Check
ASSUME(active[iw(2,0+2*1)] == 2);
ASSUME(active[cw(2,0+2*1)] == 2);
ASSUME(sforbid(0+2*1,cw(2,0+2*1))== 0);
ASSUME(iw(2,0+2*1) >= 0);
ASSUME(iw(2,0+2*1) >= 0);
ASSUME(cw(2,0+2*1) >= iw(2,0+2*1));
ASSUME(cw(2,0+2*1) >= old_cw);
ASSUME(cw(2,0+2*1) >= cr(2,0+2*1));
ASSUME(cw(2,0+2*1) >= cl[2]);
ASSUME(cw(2,0+2*1) >= cisb[2]);
ASSUME(cw(2,0+2*1) >= cdy[2]);
ASSUME(cw(2,0+2*1) >= cdl[2]);
ASSUME(cw(2,0+2*1) >= cds[2]);
ASSUME(cw(2,0+2*1) >= cctrl[2]);
ASSUME(cw(2,0+2*1) >= caddr[2]);
// Update
caddr[2] = max(caddr[2],0);
buff(2,0+2*1) = 1;
mem(0+2*1,cw(2,0+2*1)) = 1;
co(0+2*1,cw(2,0+2*1))+=1;
delta(0+2*1,cw(2,0+2*1)) = -1;
ASSUME(creturn[2] >= cw(2,0+2*1));
// %cmp = icmp eq i32 %conv, 1, !dbg !56
creg__r0__1_ = max(0,creg_r0);
// %conv1 = zext i1 %cmp to i32, !dbg !56
// call void @llvm.dbg.value(metadata i32 %conv1, metadata !64, metadata !DIExpression()), !dbg !66
// store i32 %conv1, i32* @atom_1_X0_1, align 4, !dbg !57, !tbaa !58
// ST: Guess
iw(2,3) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STIW _l32_c15
old_cw = cw(2,3);
cw(2,3) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STCOM _l32_c15
// Check
ASSUME(active[iw(2,3)] == 2);
ASSUME(active[cw(2,3)] == 2);
ASSUME(sforbid(3,cw(2,3))== 0);
ASSUME(iw(2,3) >= creg__r0__1_);
ASSUME(iw(2,3) >= 0);
ASSUME(cw(2,3) >= iw(2,3));
ASSUME(cw(2,3) >= old_cw);
ASSUME(cw(2,3) >= cr(2,3));
ASSUME(cw(2,3) >= cl[2]);
ASSUME(cw(2,3) >= cisb[2]);
ASSUME(cw(2,3) >= cdy[2]);
ASSUME(cw(2,3) >= cdl[2]);
ASSUME(cw(2,3) >= cds[2]);
ASSUME(cw(2,3) >= cctrl[2]);
ASSUME(cw(2,3) >= caddr[2]);
// Update
caddr[2] = max(caddr[2],0);
buff(2,3) = (r0==1);
mem(3,cw(2,3)) = (r0==1);
co(3,cw(2,3))+=1;
delta(3,cw(2,3)) = -1;
ASSUME(creturn[2] >= cw(2,3));
// ret i8* null, !dbg !62
ret_thread_2 = (- 1);
goto T2BLOCK_END;
T2BLOCK_END:
// Dumping thread 3
int ret_thread_3 = 0;
cdy[3] = get_rng(0,NCONTEXT-1);
ASSUME(cdy[3] >= cstart[3]);
T3BLOCK0:
// call void @llvm.dbg.value(metadata i8* %arg, metadata !84, metadata !DIExpression()), !dbg !94
// br label %label_3, !dbg !48
goto T3BLOCK1;
T3BLOCK1:
// call void @llvm.dbg.label(metadata !93), !dbg !96
// call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 2), metadata !86, metadata !DIExpression()), !dbg !97
// %0 = load atomic i64, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 2) monotonic, align 8, !dbg !51
// LD: Guess
old_cr = cr(3,0+2*1);
cr(3,0+2*1) = get_rng(0,NCONTEXT-1);// 3 ASSIGN LDCOM _l38_c15
// Check
ASSUME(active[cr(3,0+2*1)] == 3);
ASSUME(cr(3,0+2*1) >= iw(3,0+2*1));
ASSUME(cr(3,0+2*1) >= 0);
ASSUME(cr(3,0+2*1) >= cdy[3]);
ASSUME(cr(3,0+2*1) >= cisb[3]);
ASSUME(cr(3,0+2*1) >= cdl[3]);
ASSUME(cr(3,0+2*1) >= cl[3]);
// Update
creg_r1 = cr(3,0+2*1);
crmax(3,0+2*1) = max(crmax(3,0+2*1),cr(3,0+2*1));
caddr[3] = max(caddr[3],0);
if(cr(3,0+2*1) < cw(3,0+2*1)) {
r1 = buff(3,0+2*1);
ASSUME((!(( (cw(3,0+2*1) < 1) && (1 < crmax(3,0+2*1)) )))||(sforbid(0+2*1,1)> 0));
ASSUME((!(( (cw(3,0+2*1) < 2) && (2 < crmax(3,0+2*1)) )))||(sforbid(0+2*1,2)> 0));
ASSUME((!(( (cw(3,0+2*1) < 3) && (3 < crmax(3,0+2*1)) )))||(sforbid(0+2*1,3)> 0));
ASSUME((!(( (cw(3,0+2*1) < 4) && (4 < crmax(3,0+2*1)) )))||(sforbid(0+2*1,4)> 0));
} else {
if(pw(3,0+2*1) != co(0+2*1,cr(3,0+2*1))) {
ASSUME(cr(3,0+2*1) >= old_cr);
}
pw(3,0+2*1) = co(0+2*1,cr(3,0+2*1));
r1 = mem(0+2*1,cr(3,0+2*1));
}
ASSUME(creturn[3] >= cr(3,0+2*1));
// call void @llvm.dbg.value(metadata i64 %0, metadata !88, metadata !DIExpression()), !dbg !97
// %conv = trunc i64 %0 to i32, !dbg !52
// call void @llvm.dbg.value(metadata i32 %conv, metadata !85, metadata !DIExpression()), !dbg !94
// call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 0), metadata !89, metadata !DIExpression()), !dbg !100
// call void @llvm.dbg.value(metadata i64 1, metadata !91, metadata !DIExpression()), !dbg !100
// store atomic i64 1, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 0) monotonic, align 8, !dbg !54
// ST: Guess
iw(3,0) = get_rng(0,NCONTEXT-1);// 3 ASSIGN STIW _l39_c3
old_cw = cw(3,0);
cw(3,0) = get_rng(0,NCONTEXT-1);// 3 ASSIGN STCOM _l39_c3
// Check
ASSUME(active[iw(3,0)] == 3);
ASSUME(active[cw(3,0)] == 3);
ASSUME(sforbid(0,cw(3,0))== 0);
ASSUME(iw(3,0) >= 0);
ASSUME(iw(3,0) >= 0);
ASSUME(cw(3,0) >= iw(3,0));
ASSUME(cw(3,0) >= old_cw);
ASSUME(cw(3,0) >= cr(3,0));
ASSUME(cw(3,0) >= cl[3]);
ASSUME(cw(3,0) >= cisb[3]);
ASSUME(cw(3,0) >= cdy[3]);
ASSUME(cw(3,0) >= cdl[3]);
ASSUME(cw(3,0) >= cds[3]);
ASSUME(cw(3,0) >= cctrl[3]);
ASSUME(cw(3,0) >= caddr[3]);
// Update
caddr[3] = max(caddr[3],0);
buff(3,0) = 1;
mem(0,cw(3,0)) = 1;
co(0,cw(3,0))+=1;
delta(0,cw(3,0)) = -1;
ASSUME(creturn[3] >= cw(3,0));
// %cmp = icmp eq i32 %conv, 1, !dbg !55
creg__r1__1_ = max(0,creg_r1);
// %conv1 = zext i1 %cmp to i32, !dbg !55
// call void @llvm.dbg.value(metadata i32 %conv1, metadata !92, metadata !DIExpression()), !dbg !94
// store i32 %conv1, i32* @atom_2_X0_1, align 4, !dbg !56, !tbaa !57
// ST: Guess
iw(3,4) = get_rng(0,NCONTEXT-1);// 3 ASSIGN STIW _l41_c15
old_cw = cw(3,4);
cw(3,4) = get_rng(0,NCONTEXT-1);// 3 ASSIGN STCOM _l41_c15
// Check
ASSUME(active[iw(3,4)] == 3);
ASSUME(active[cw(3,4)] == 3);
ASSUME(sforbid(4,cw(3,4))== 0);
ASSUME(iw(3,4) >= creg__r1__1_);
ASSUME(iw(3,4) >= 0);
ASSUME(cw(3,4) >= iw(3,4));
ASSUME(cw(3,4) >= old_cw);
ASSUME(cw(3,4) >= cr(3,4));
ASSUME(cw(3,4) >= cl[3]);
ASSUME(cw(3,4) >= cisb[3]);
ASSUME(cw(3,4) >= cdy[3]);
ASSUME(cw(3,4) >= cdl[3]);
ASSUME(cw(3,4) >= cds[3]);
ASSUME(cw(3,4) >= cctrl[3]);
ASSUME(cw(3,4) >= caddr[3]);
// Update
caddr[3] = max(caddr[3],0);
buff(3,4) = (r1==1);
mem(4,cw(3,4)) = (r1==1);
co(4,cw(3,4))+=1;
delta(4,cw(3,4)) = -1;
ASSUME(creturn[3] >= cw(3,4));
// ret i8* null, !dbg !61
ret_thread_3 = (- 1);
goto T3BLOCK_END;
T3BLOCK_END:
// Dumping thread 0
int ret_thread_0 = 0;
cdy[0] = get_rng(0,NCONTEXT-1);
ASSUME(cdy[0] >= cstart[0]);
T0BLOCK0:
// %thr0 = alloca i64, align 8
// %thr1 = alloca i64, align 8
// %thr2 = alloca i64, align 8
// call void @llvm.dbg.value(metadata i32 %argc, metadata !112, metadata !DIExpression()), !dbg !138
// call void @llvm.dbg.value(metadata i8** %argv, metadata !113, metadata !DIExpression()), !dbg !138
// %0 = bitcast i64* %thr0 to i8*, !dbg !67
// call void @llvm.lifetime.start.p0i8(i64 8, i8* %0) #7, !dbg !67
// call void @llvm.dbg.declare(metadata i64* %thr0, metadata !114, metadata !DIExpression()), !dbg !140
// %1 = bitcast i64* %thr1 to i8*, !dbg !69
// call void @llvm.lifetime.start.p0i8(i64 8, i8* %1) #7, !dbg !69
// call void @llvm.dbg.declare(metadata i64* %thr1, metadata !118, metadata !DIExpression()), !dbg !142
// %2 = bitcast i64* %thr2 to i8*, !dbg !71
// call void @llvm.lifetime.start.p0i8(i64 8, i8* %2) #7, !dbg !71
// call void @llvm.dbg.declare(metadata i64* %thr2, metadata !119, metadata !DIExpression()), !dbg !144
// call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 2), metadata !120, metadata !DIExpression()), !dbg !145
// call void @llvm.dbg.value(metadata i64 0, metadata !122, metadata !DIExpression()), !dbg !145
// store atomic i64 0, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 2) monotonic, align 8, !dbg !74
// ST: Guess
iw(0,0+2*1) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW _l50_c3
old_cw = cw(0,0+2*1);
cw(0,0+2*1) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM _l50_c3
// Check
ASSUME(active[iw(0,0+2*1)] == 0);
ASSUME(active[cw(0,0+2*1)] == 0);
ASSUME(sforbid(0+2*1,cw(0,0+2*1))== 0);
ASSUME(iw(0,0+2*1) >= 0);
ASSUME(iw(0,0+2*1) >= 0);
ASSUME(cw(0,0+2*1) >= iw(0,0+2*1));
ASSUME(cw(0,0+2*1) >= old_cw);
ASSUME(cw(0,0+2*1) >= cr(0,0+2*1));
ASSUME(cw(0,0+2*1) >= cl[0]);
ASSUME(cw(0,0+2*1) >= cisb[0]);
ASSUME(cw(0,0+2*1) >= cdy[0]);
ASSUME(cw(0,0+2*1) >= cdl[0]);
ASSUME(cw(0,0+2*1) >= cds[0]);
ASSUME(cw(0,0+2*1) >= cctrl[0]);
ASSUME(cw(0,0+2*1) >= caddr[0]);
// Update
caddr[0] = max(caddr[0],0);
buff(0,0+2*1) = 0;
mem(0+2*1,cw(0,0+2*1)) = 0;
co(0+2*1,cw(0,0+2*1))+=1;
delta(0+2*1,cw(0,0+2*1)) = -1;
ASSUME(creturn[0] >= cw(0,0+2*1));
// call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 1), metadata !123, metadata !DIExpression()), !dbg !147
// call void @llvm.dbg.value(metadata i64 0, metadata !125, metadata !DIExpression()), !dbg !147
// store atomic i64 0, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 1) monotonic, align 8, !dbg !76
// ST: Guess
iw(0,0+1*1) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW _l51_c3
old_cw = cw(0,0+1*1);
cw(0,0+1*1) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM _l51_c3
// Check
ASSUME(active[iw(0,0+1*1)] == 0);
ASSUME(active[cw(0,0+1*1)] == 0);
ASSUME(sforbid(0+1*1,cw(0,0+1*1))== 0);
ASSUME(iw(0,0+1*1) >= 0);
ASSUME(iw(0,0+1*1) >= 0);
ASSUME(cw(0,0+1*1) >= iw(0,0+1*1));
ASSUME(cw(0,0+1*1) >= old_cw);
ASSUME(cw(0,0+1*1) >= cr(0,0+1*1));
ASSUME(cw(0,0+1*1) >= cl[0]);
ASSUME(cw(0,0+1*1) >= cisb[0]);
ASSUME(cw(0,0+1*1) >= cdy[0]);
ASSUME(cw(0,0+1*1) >= cdl[0]);
ASSUME(cw(0,0+1*1) >= cds[0]);
ASSUME(cw(0,0+1*1) >= cctrl[0]);
ASSUME(cw(0,0+1*1) >= caddr[0]);
// Update
caddr[0] = max(caddr[0],0);
buff(0,0+1*1) = 0;
mem(0+1*1,cw(0,0+1*1)) = 0;
co(0+1*1,cw(0,0+1*1))+=1;
delta(0+1*1,cw(0,0+1*1)) = -1;
ASSUME(creturn[0] >= cw(0,0+1*1));
// call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 0), metadata !126, metadata !DIExpression()), !dbg !149
// call void @llvm.dbg.value(metadata i64 0, metadata !128, metadata !DIExpression()), !dbg !149
// store atomic i64 0, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 0) monotonic, align 8, !dbg !78
// ST: Guess
iw(0,0) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW _l52_c3
old_cw = cw(0,0);
cw(0,0) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM _l52_c3
// Check
ASSUME(active[iw(0,0)] == 0);
ASSUME(active[cw(0,0)] == 0);
ASSUME(sforbid(0,cw(0,0))== 0);
ASSUME(iw(0,0) >= 0);
ASSUME(iw(0,0) >= 0);
ASSUME(cw(0,0) >= iw(0,0));
ASSUME(cw(0,0) >= old_cw);
ASSUME(cw(0,0) >= cr(0,0));
ASSUME(cw(0,0) >= cl[0]);
ASSUME(cw(0,0) >= cisb[0]);
ASSUME(cw(0,0) >= cdy[0]);
ASSUME(cw(0,0) >= cdl[0]);
ASSUME(cw(0,0) >= cds[0]);
ASSUME(cw(0,0) >= cctrl[0]);
ASSUME(cw(0,0) >= caddr[0]);
// Update
caddr[0] = max(caddr[0],0);
buff(0,0) = 0;
mem(0,cw(0,0)) = 0;
co(0,cw(0,0))+=1;
delta(0,cw(0,0)) = -1;
ASSUME(creturn[0] >= cw(0,0));
// store i32 0, i32* @atom_1_X0_1, align 4, !dbg !79, !tbaa !80
// ST: Guess
iw(0,3) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW _l53_c15
old_cw = cw(0,3);
cw(0,3) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM _l53_c15
// Check
ASSUME(active[iw(0,3)] == 0);
ASSUME(active[cw(0,3)] == 0);
ASSUME(sforbid(3,cw(0,3))== 0);
ASSUME(iw(0,3) >= 0);
ASSUME(iw(0,3) >= 0);
ASSUME(cw(0,3) >= iw(0,3));
ASSUME(cw(0,3) >= old_cw);
ASSUME(cw(0,3) >= cr(0,3));
ASSUME(cw(0,3) >= cl[0]);
ASSUME(cw(0,3) >= cisb[0]);
ASSUME(cw(0,3) >= cdy[0]);
ASSUME(cw(0,3) >= cdl[0]);
ASSUME(cw(0,3) >= cds[0]);
ASSUME(cw(0,3) >= cctrl[0]);
ASSUME(cw(0,3) >= caddr[0]);
// Update
caddr[0] = max(caddr[0],0);
buff(0,3) = 0;
mem(3,cw(0,3)) = 0;
co(3,cw(0,3))+=1;
delta(3,cw(0,3)) = -1;
ASSUME(creturn[0] >= cw(0,3));
// store i32 0, i32* @atom_2_X0_1, align 4, !dbg !84, !tbaa !80
// ST: Guess
iw(0,4) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW _l54_c15
old_cw = cw(0,4);
cw(0,4) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM _l54_c15
// Check
ASSUME(active[iw(0,4)] == 0);
ASSUME(active[cw(0,4)] == 0);
ASSUME(sforbid(4,cw(0,4))== 0);
ASSUME(iw(0,4) >= 0);
ASSUME(iw(0,4) >= 0);
ASSUME(cw(0,4) >= iw(0,4));
ASSUME(cw(0,4) >= old_cw);
ASSUME(cw(0,4) >= cr(0,4));
ASSUME(cw(0,4) >= cl[0]);
ASSUME(cw(0,4) >= cisb[0]);
ASSUME(cw(0,4) >= cdy[0]);
ASSUME(cw(0,4) >= cdl[0]);
ASSUME(cw(0,4) >= cds[0]);
ASSUME(cw(0,4) >= cctrl[0]);
ASSUME(cw(0,4) >= caddr[0]);
// Update
caddr[0] = max(caddr[0],0);
buff(0,4) = 0;
mem(4,cw(0,4)) = 0;
co(4,cw(0,4))+=1;
delta(4,cw(0,4)) = -1;
ASSUME(creturn[0] >= cw(0,4));
// %call = call i32 @pthread_create(i64* noundef %thr0, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef @t0, i8* noundef null) #7, !dbg !85
// dumbsy: Guess
old_cdy = cdy[0];
cdy[0] = get_rng(0,NCONTEXT-1);
// Check
ASSUME(cdy[0] >= old_cdy);
ASSUME(cdy[0] >= cisb[0]);
ASSUME(cdy[0] >= cdl[0]);
ASSUME(cdy[0] >= cds[0]);
ASSUME(cdy[0] >= cctrl[0]);
ASSUME(cdy[0] >= cw(0,4+0));
ASSUME(cdy[0] >= cw(0,0+0));
ASSUME(cdy[0] >= cw(0,0+1));
ASSUME(cdy[0] >= cw(0,0+2));
ASSUME(cdy[0] >= cw(0,3+0));
ASSUME(cdy[0] >= cr(0,4+0));
ASSUME(cdy[0] >= cr(0,0+0));
ASSUME(cdy[0] >= cr(0,0+1));
ASSUME(cdy[0] >= cr(0,0+2));
ASSUME(cdy[0] >= cr(0,3+0));
ASSUME(creturn[0] >= cdy[0]);
ASSUME(cstart[1] >= cdy[0]);
// %call5 = call i32 @pthread_create(i64* noundef %thr1, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef @t1, i8* noundef null) #7, !dbg !86
// dumbsy: Guess
old_cdy = cdy[0];
cdy[0] = get_rng(0,NCONTEXT-1);
// Check
ASSUME(cdy[0] >= old_cdy);
ASSUME(cdy[0] >= cisb[0]);
ASSUME(cdy[0] >= cdl[0]);
ASSUME(cdy[0] >= cds[0]);
ASSUME(cdy[0] >= cctrl[0]);
ASSUME(cdy[0] >= cw(0,4+0));
ASSUME(cdy[0] >= cw(0,0+0));
ASSUME(cdy[0] >= cw(0,0+1));
ASSUME(cdy[0] >= cw(0,0+2));
ASSUME(cdy[0] >= cw(0,3+0));
ASSUME(cdy[0] >= cr(0,4+0));
ASSUME(cdy[0] >= cr(0,0+0));
ASSUME(cdy[0] >= cr(0,0+1));
ASSUME(cdy[0] >= cr(0,0+2));
ASSUME(cdy[0] >= cr(0,3+0));
ASSUME(creturn[0] >= cdy[0]);
ASSUME(cstart[2] >= cdy[0]);
// %call6 = call i32 @pthread_create(i64* noundef %thr2, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef @t2, i8* noundef null) #7, !dbg !87
// dumbsy: Guess
old_cdy = cdy[0];
cdy[0] = get_rng(0,NCONTEXT-1);
// Check
ASSUME(cdy[0] >= old_cdy);
ASSUME(cdy[0] >= cisb[0]);
ASSUME(cdy[0] >= cdl[0]);
ASSUME(cdy[0] >= cds[0]);
ASSUME(cdy[0] >= cctrl[0]);
ASSUME(cdy[0] >= cw(0,4+0));
ASSUME(cdy[0] >= cw(0,0+0));
ASSUME(cdy[0] >= cw(0,0+1));
ASSUME(cdy[0] >= cw(0,0+2));
ASSUME(cdy[0] >= cw(0,3+0));
ASSUME(cdy[0] >= cr(0,4+0));
ASSUME(cdy[0] >= cr(0,0+0));
ASSUME(cdy[0] >= cr(0,0+1));
ASSUME(cdy[0] >= cr(0,0+2));
ASSUME(cdy[0] >= cr(0,3+0));
ASSUME(creturn[0] >= cdy[0]);
ASSUME(cstart[3] >= cdy[0]);
// %3 = load i64, i64* %thr0, align 8, !dbg !88, !tbaa !89
r3 = local_mem[0];
// %call7 = call i32 @pthread_join(i64 noundef %3, i8** noundef null), !dbg !91
// dumbsy: Guess
old_cdy = cdy[0];
cdy[0] = get_rng(0,NCONTEXT-1);
// Check
ASSUME(cdy[0] >= old_cdy);
ASSUME(cdy[0] >= cisb[0]);
ASSUME(cdy[0] >= cdl[0]);
ASSUME(cdy[0] >= cds[0]);
ASSUME(cdy[0] >= cctrl[0]);
ASSUME(cdy[0] >= cw(0,4+0));
ASSUME(cdy[0] >= cw(0,0+0));
ASSUME(cdy[0] >= cw(0,0+1));
ASSUME(cdy[0] >= cw(0,0+2));
ASSUME(cdy[0] >= cw(0,3+0));
ASSUME(cdy[0] >= cr(0,4+0));
ASSUME(cdy[0] >= cr(0,0+0));
ASSUME(cdy[0] >= cr(0,0+1));
ASSUME(cdy[0] >= cr(0,0+2));
ASSUME(cdy[0] >= cr(0,3+0));
ASSUME(creturn[0] >= cdy[0]);
ASSUME(cdy[0] >= creturn[1]);
// %4 = load i64, i64* %thr1, align 8, !dbg !92, !tbaa !89
r4 = local_mem[1];
// %call8 = call i32 @pthread_join(i64 noundef %4, i8** noundef null), !dbg !93
// dumbsy: Guess
old_cdy = cdy[0];
cdy[0] = get_rng(0,NCONTEXT-1);
// Check
ASSUME(cdy[0] >= old_cdy);
ASSUME(cdy[0] >= cisb[0]);
ASSUME(cdy[0] >= cdl[0]);
ASSUME(cdy[0] >= cds[0]);
ASSUME(cdy[0] >= cctrl[0]);
ASSUME(cdy[0] >= cw(0,4+0));
ASSUME(cdy[0] >= cw(0,0+0));
ASSUME(cdy[0] >= cw(0,0+1));
ASSUME(cdy[0] >= cw(0,0+2));
ASSUME(cdy[0] >= cw(0,3+0));
ASSUME(cdy[0] >= cr(0,4+0));
ASSUME(cdy[0] >= cr(0,0+0));
ASSUME(cdy[0] >= cr(0,0+1));
ASSUME(cdy[0] >= cr(0,0+2));
ASSUME(cdy[0] >= cr(0,3+0));
ASSUME(creturn[0] >= cdy[0]);
ASSUME(cdy[0] >= creturn[2]);
// %5 = load i64, i64* %thr2, align 8, !dbg !94, !tbaa !89
r5 = local_mem[2];
// %call9 = call i32 @pthread_join(i64 noundef %5, i8** noundef null), !dbg !95
// dumbsy: Guess
old_cdy = cdy[0];
cdy[0] = get_rng(0,NCONTEXT-1);
// Check
ASSUME(cdy[0] >= old_cdy);
ASSUME(cdy[0] >= cisb[0]);
ASSUME(cdy[0] >= cdl[0]);
ASSUME(cdy[0] >= cds[0]);
ASSUME(cdy[0] >= cctrl[0]);
ASSUME(cdy[0] >= cw(0,4+0));
ASSUME(cdy[0] >= cw(0,0+0));
ASSUME(cdy[0] >= cw(0,0+1));
ASSUME(cdy[0] >= cw(0,0+2));
ASSUME(cdy[0] >= cw(0,3+0));
ASSUME(cdy[0] >= cr(0,4+0));
ASSUME(cdy[0] >= cr(0,0+0));
ASSUME(cdy[0] >= cr(0,0+1));
ASSUME(cdy[0] >= cr(0,0+2));
ASSUME(cdy[0] >= cr(0,3+0));
ASSUME(creturn[0] >= cdy[0]);
ASSUME(cdy[0] >= creturn[3]);
// call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 0), metadata !130, metadata !DIExpression()), !dbg !164
// %6 = load atomic i64, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 0) monotonic, align 8, !dbg !97
// LD: Guess
old_cr = cr(0,0);
cr(0,0) = get_rng(0,NCONTEXT-1);// 0 ASSIGN LDCOM _l64_c12
// Check
ASSUME(active[cr(0,0)] == 0);
ASSUME(cr(0,0) >= iw(0,0));
ASSUME(cr(0,0) >= 0);
ASSUME(cr(0,0) >= cdy[0]);
ASSUME(cr(0,0) >= cisb[0]);
ASSUME(cr(0,0) >= cdl[0]);
ASSUME(cr(0,0) >= cl[0]);
// Update
creg_r6 = cr(0,0);
crmax(0,0) = max(crmax(0,0),cr(0,0));
caddr[0] = max(caddr[0],0);
if(cr(0,0) < cw(0,0)) {
r6 = buff(0,0);
ASSUME((!(( (cw(0,0) < 1) && (1 < crmax(0,0)) )))||(sforbid(0,1)> 0));
ASSUME((!(( (cw(0,0) < 2) && (2 < crmax(0,0)) )))||(sforbid(0,2)> 0));
ASSUME((!(( (cw(0,0) < 3) && (3 < crmax(0,0)) )))||(sforbid(0,3)> 0));
ASSUME((!(( (cw(0,0) < 4) && (4 < crmax(0,0)) )))||(sforbid(0,4)> 0));
} else {
if(pw(0,0) != co(0,cr(0,0))) {
ASSUME(cr(0,0) >= old_cr);
}
pw(0,0) = co(0,cr(0,0));
r6 = mem(0,cr(0,0));
}
ASSUME(creturn[0] >= cr(0,0));
// call void @llvm.dbg.value(metadata i64 %6, metadata !132, metadata !DIExpression()), !dbg !164
// %conv = trunc i64 %6 to i32, !dbg !98
// call void @llvm.dbg.value(metadata i32 %conv, metadata !129, metadata !DIExpression()), !dbg !138
// %cmp = icmp eq i32 %conv, 2, !dbg !99
creg__r6__2_ = max(0,creg_r6);
// %conv10 = zext i1 %cmp to i32, !dbg !99
// call void @llvm.dbg.value(metadata i32 %conv10, metadata !133, metadata !DIExpression()), !dbg !138
// %7 = load i32, i32* @atom_1_X0_1, align 4, !dbg !100, !tbaa !80
// LD: Guess
old_cr = cr(0,3);
cr(0,3) = get_rng(0,NCONTEXT-1);// 0 ASSIGN LDCOM _l66_c12
// Check
ASSUME(active[cr(0,3)] == 0);
ASSUME(cr(0,3) >= iw(0,3));
ASSUME(cr(0,3) >= 0);
ASSUME(cr(0,3) >= cdy[0]);
ASSUME(cr(0,3) >= cisb[0]);
ASSUME(cr(0,3) >= cdl[0]);
ASSUME(cr(0,3) >= cl[0]);
// Update
creg_r7 = cr(0,3);
crmax(0,3) = max(crmax(0,3),cr(0,3));
caddr[0] = max(caddr[0],0);
if(cr(0,3) < cw(0,3)) {
r7 = buff(0,3);
ASSUME((!(( (cw(0,3) < 1) && (1 < crmax(0,3)) )))||(sforbid(3,1)> 0));
ASSUME((!(( (cw(0,3) < 2) && (2 < crmax(0,3)) )))||(sforbid(3,2)> 0));
ASSUME((!(( (cw(0,3) < 3) && (3 < crmax(0,3)) )))||(sforbid(3,3)> 0));
ASSUME((!(( (cw(0,3) < 4) && (4 < crmax(0,3)) )))||(sforbid(3,4)> 0));
} else {
if(pw(0,3) != co(3,cr(0,3))) {
ASSUME(cr(0,3) >= old_cr);
}
pw(0,3) = co(3,cr(0,3));
r7 = mem(3,cr(0,3));
}
ASSUME(creturn[0] >= cr(0,3));
// call void @llvm.dbg.value(metadata i32 %7, metadata !134, metadata !DIExpression()), !dbg !138
// %8 = load i32, i32* @atom_2_X0_1, align 4, !dbg !101, !tbaa !80
// LD: Guess
old_cr = cr(0,4);
cr(0,4) = get_rng(0,NCONTEXT-1);// 0 ASSIGN LDCOM _l67_c13
// Check
ASSUME(active[cr(0,4)] == 0);
ASSUME(cr(0,4) >= iw(0,4));
ASSUME(cr(0,4) >= 0);
ASSUME(cr(0,4) >= cdy[0]);
ASSUME(cr(0,4) >= cisb[0]);
ASSUME(cr(0,4) >= cdl[0]);
ASSUME(cr(0,4) >= cl[0]);
// Update
creg_r8 = cr(0,4);
crmax(0,4) = max(crmax(0,4),cr(0,4));
caddr[0] = max(caddr[0],0);
if(cr(0,4) < cw(0,4)) {
r8 = buff(0,4);
ASSUME((!(( (cw(0,4) < 1) && (1 < crmax(0,4)) )))||(sforbid(4,1)> 0));
ASSUME((!(( (cw(0,4) < 2) && (2 < crmax(0,4)) )))||(sforbid(4,2)> 0));
ASSUME((!(( (cw(0,4) < 3) && (3 < crmax(0,4)) )))||(sforbid(4,3)> 0));
ASSUME((!(( (cw(0,4) < 4) && (4 < crmax(0,4)) )))||(sforbid(4,4)> 0));
} else {
if(pw(0,4) != co(4,cr(0,4))) {
ASSUME(cr(0,4) >= old_cr);
}
pw(0,4) = co(4,cr(0,4));
r8 = mem(4,cr(0,4));
}
ASSUME(creturn[0] >= cr(0,4));
// call void @llvm.dbg.value(metadata i32 %8, metadata !135, metadata !DIExpression()), !dbg !138
// %and = and i32 %7, %8, !dbg !102
creg_r9 = max(creg_r7,creg_r8);
r9 = r7 & r8;
// call void @llvm.dbg.value(metadata i32 %and, metadata !136, metadata !DIExpression()), !dbg !138
// %and11 = and i32 %conv10, %and, !dbg !103
creg_r10 = max(creg__r6__2_,creg_r9);
r10 = (r6==2) & r9;
// call void @llvm.dbg.value(metadata i32 %and11, metadata !137, metadata !DIExpression()), !dbg !138
// %cmp12 = icmp eq i32 %and11, 1, !dbg !104
creg__r10__1_ = max(0,creg_r10);
// br i1 %cmp12, label %if.then, label %if.end, !dbg !106
old_cctrl = cctrl[0];
cctrl[0] = get_rng(0,NCONTEXT-1);
ASSUME(cctrl[0] >= old_cctrl);
ASSUME(cctrl[0] >= creg__r10__1_);
if((r10==1)) {
goto T0BLOCK1;
} else {
goto T0BLOCK2;
}
T0BLOCK1:
// call void @__assert_fail(i8* noundef getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* noundef getelementptr inbounds ([106 x i8], [106 x i8]* @.str.1, i64 0, i64 0), i32 noundef 70, i8* noundef getelementptr inbounds ([23 x i8], [23 x i8]* @__PRETTY_FUNCTION__.main, i64 0, i64 0)) #8, !dbg !107
// unreachable, !dbg !107
r11 = 1;
goto T0BLOCK_END;
T0BLOCK2:
// %9 = bitcast i64* %thr2 to i8*, !dbg !110
// call void @llvm.lifetime.end.p0i8(i64 8, i8* %9) #7, !dbg !110
// %10 = bitcast i64* %thr1 to i8*, !dbg !110
// call void @llvm.lifetime.end.p0i8(i64 8, i8* %10) #7, !dbg !110
// %11 = bitcast i64* %thr0 to i8*, !dbg !110
// call void @llvm.lifetime.end.p0i8(i64 8, i8* %11) #7, !dbg !110
// ret i32 0, !dbg !111
ret_thread_0 = 0;
goto T0BLOCK_END;
T0BLOCK_END:
ASSUME(meminit(0,1) == mem(0,0));
ASSUME(coinit(0,1) == co(0,0));
ASSUME(deltainit(0,1) == delta(0,0));
ASSUME(meminit(0,2) == mem(0,1));
ASSUME(coinit(0,2) == co(0,1));
ASSUME(deltainit(0,2) == delta(0,1));
ASSUME(meminit(0,3) == mem(0,2));
ASSUME(coinit(0,3) == co(0,2));
ASSUME(deltainit(0,3) == delta(0,2));
ASSUME(meminit(0,4) == mem(0,3));
ASSUME(coinit(0,4) == co(0,3));
ASSUME(deltainit(0,4) == delta(0,3));
ASSUME(meminit(1,1) == mem(1,0));
ASSUME(coinit(1,1) == co(1,0));
ASSUME(deltainit(1,1) == delta(1,0));
ASSUME(meminit(1,2) == mem(1,1));
ASSUME(coinit(1,2) == co(1,1));
ASSUME(deltainit(1,2) == delta(1,1));
ASSUME(meminit(1,3) == mem(1,2));
ASSUME(coinit(1,3) == co(1,2));
ASSUME(deltainit(1,3) == delta(1,2));
ASSUME(meminit(1,4) == mem(1,3));
ASSUME(coinit(1,4) == co(1,3));
ASSUME(deltainit(1,4) == delta(1,3));
ASSUME(meminit(2,1) == mem(2,0));
ASSUME(coinit(2,1) == co(2,0));
ASSUME(deltainit(2,1) == delta(2,0));
ASSUME(meminit(2,2) == mem(2,1));
ASSUME(coinit(2,2) == co(2,1));
ASSUME(deltainit(2,2) == delta(2,1));
ASSUME(meminit(2,3) == mem(2,2));
ASSUME(coinit(2,3) == co(2,2));
ASSUME(deltainit(2,3) == delta(2,2));
ASSUME(meminit(2,4) == mem(2,3));
ASSUME(coinit(2,4) == co(2,3));
ASSUME(deltainit(2,4) == delta(2,3));
ASSUME(meminit(3,1) == mem(3,0));
ASSUME(coinit(3,1) == co(3,0));
ASSUME(deltainit(3,1) == delta(3,0));
ASSUME(meminit(3,2) == mem(3,1));
ASSUME(coinit(3,2) == co(3,1));
ASSUME(deltainit(3,2) == delta(3,1));
ASSUME(meminit(3,3) == mem(3,2));
ASSUME(coinit(3,3) == co(3,2));
ASSUME(deltainit(3,3) == delta(3,2));
ASSUME(meminit(3,4) == mem(3,3));
ASSUME(coinit(3,4) == co(3,3));
ASSUME(deltainit(3,4) == delta(3,3));
ASSUME(meminit(4,1) == mem(4,0));
ASSUME(coinit(4,1) == co(4,0));
ASSUME(deltainit(4,1) == delta(4,0));
ASSUME(meminit(4,2) == mem(4,1));
ASSUME(coinit(4,2) == co(4,1));
ASSUME(deltainit(4,2) == delta(4,1));
ASSUME(meminit(4,3) == mem(4,2));
ASSUME(coinit(4,3) == co(4,2));
ASSUME(deltainit(4,3) == delta(4,2));
ASSUME(meminit(4,4) == mem(4,3));
ASSUME(coinit(4,4) == co(4,3));
ASSUME(deltainit(4,4) == delta(4,3));
ASSERT(r11== 0);
}
| [
"tuan-phong.ngo@it.uu.se"
] | tuan-phong.ngo@it.uu.se |
1f05bfcc1d42fba136a7bf370df5165237c2b020 | 1250f85f2d17c1bd7a554bd9b7a1c76914223efa | /src/interfaces/ethernet_feeder/EthChangeStateBuilder.cpp | 01d3bfcdf79b2df7249667dca6ca8ad4c8a04a69 | [] | no_license | HBuczynski/AHRS | 0cf015ccb5978fd7ddf1aeccbdd0b9b943c6d31c | 324169c7869b9d69343f6120739ec8e0b9901d4a | refs/heads/master | 2022-02-22T08:22:37.208745 | 2019-09-10T19:36:34 | 2019-09-10T19:36:34 | 111,209,994 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 414 | cpp | #include "EthChangeStateBuilder.h"
#include "EthChangeStateCommand.h"
using namespace std;
using namespace communication;
unique_ptr<EthFeederCommand> EthChangeStateBuilder::create(const vector<uint8_t> &commandInBytes)
{
const auto state = static_cast<FeederStateCode>(commandInBytes[Frame::INITIAL_DATA_POSITION]);
auto command = make_unique<EthChangeStateCommand>(state);
return move(command);
}
| [
"hubert.buczynski94@gmail.com"
] | hubert.buczynski94@gmail.com |
aff3c9aa99af10026a099b95d50aa89d9ae941ed | 406f3195b2396e2c23f51edeeda42dadd8dc5708 | /units/Berserker.h | 9a81c7e3e33384b626f836e0ecabcb982b9c4301 | [] | no_license | IngwarSV/HEROES | 7a1aa899ec3afe587ae00191790a397b32b42493 | 963bc1179df8e1acde18dc64bf64e37fee770118 | refs/heads/master | 2020-12-21T14:29:20.129403 | 2020-02-27T09:11:16 | 2020-02-27T09:11:16 | 236,460,073 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 506 | h | #ifndef BERSERKER_H
#define BERSERKER_H
#include <iostream>
#include "Unit.h"
#include "../states/BerserkerState.h"
#include "../Specifications.h"
class Berserker : public Unit {
public:
Berserker(const std::string& name, const std::string& type = TYPE::BERSERKER, int health = static_cast<int>(HP::BERSERKER), int damage = static_cast<int>(DMG::BERSERKER));
virtual ~Berserker();
};
// std::ostream& operator<<(std::ostream& out, const Berserker& berserker);
#endif // BERSERKER_H
| [
"sviatskyi@gmail.com"
] | sviatskyi@gmail.com |
06e9e9d94214c9acb2e326e43e9176d03f2d704b | 942b7b337019aa52862bce84a782eab7111010b1 | /3rd party/WildMagic/src/WmlVector4.cpp | cf231ceea79f9f8bc036dc3b31304c01797f2bc4 | [] | no_license | galek/xray15 | 338ad7ac5b297e9e497e223e0fc4d050a4a78da8 | 015c654f721e0fbed1ba771d3c398c8fa46448d9 | refs/heads/master | 2021-11-23T12:01:32.800810 | 2020-01-10T15:52:45 | 2020-01-10T15:52:45 | 168,657,320 | 0 | 0 | null | 2019-02-01T07:11:02 | 2019-02-01T07:11:01 | null | UTF-8 | C++ | false | false | 1,195 | cpp | // Magic Software, Inc.
// http://www.magic-software.com
// http://www.wild-magic.com
// Copyright (c) 2004. All Rights Reserved
//
// The Wild Magic Library (WML) source code is supplied under the terms of
// the license agreement http://www.magic-software.com/License/WildMagic.pdf
// and may not be copied or disclosed except in accordance with the terms of
// that agreement.
#include <WildMagic/WmlVector4.h>
using namespace Wml;
template<> const Vector4<float> Vector4<float>::ZERO(0.0f,0.0f,0.0f,0.0f);
template<> const Vector4<float> Vector4<float>::UNIT_X(1.0f,0.0f,0.0f,0.0f);
template<> const Vector4<float> Vector4<float>::UNIT_Y(0.0f,1.0f,0.0f,0.0f);
template<> const Vector4<float> Vector4<float>::UNIT_Z(0.0f,0.0f,1.0f,0.0f);
template<> const Vector4<float> Vector4<float>::UNIT_W(0.0f,0.0f,0.0f,1.0f);
template<> const Vector4<double> Vector4<double>::ZERO(0.0,0.0,0.0,0.0);
template<> const Vector4<double> Vector4<double>::UNIT_X(1.0,0.0,0.0,0.0);
template<> const Vector4<double> Vector4<double>::UNIT_Y(0.0,1.0,0.0,0.0);
template<> const Vector4<double> Vector4<double>::UNIT_Z(0.0,0.0,1.0,0.0);
template<> const Vector4<double> Vector4<double>::UNIT_W(0.0,0.0,0.0,1.0);
| [
"abramcumner@yandex.ru"
] | abramcumner@yandex.ru |
9714fb5c676dd7a1f0119a0703b95864a37ef366 | 893aef755225c6d3637080b04779ee3057e98291 | /source/Platforms/OpenGL/pch.h | e7f15c26f2d7896c8879b53517af55c7453a845a | [] | no_license | sumilly/FIEA-Game-Engine | 356fe9013debe40470118ed380d4bd4cb9e27491 | 430e8eaf0621d6c3dd48118261ab2716ee78c50a | refs/heads/master | 2021-05-28T22:03:14.721927 | 2015-06-14T20:56:18 | 2015-06-14T20:56:18 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 479 | h | /** @file pch.h
* Pre-compiled header file to include necessary header for OpenGL version of the game engine
*/
#pragma once
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <exception>
#include <cassert>
#include <string>
#include <vector>
#include <map>
#include <memory>
#include <stdlib.h>
#include <malloc.h>
#include <memory.h>
#include <tchar.h>
#include "OpenGL.h"
#include "targetver.h"
#include "GL/gl3w.h"
#include "GLFW/glfw3.h"
#include "glm/glm.hpp"
| [
"rsumathijs@gmail.com"
] | rsumathijs@gmail.com |
b1cb20d4c1235e11ad4f3a6cae6ac8667d7bf292 | fcccab20749b35e419dea69a2fa6633275398ba3 | /irrlicht/MyEventReceiver.hpp | 894e751d34343ce73c00f1dd03be11a83c65b5db | [] | no_license | Cashismo/Bomberman | 871298bc52008185bd6f6b0c6d6a701912ce6558 | 33106d0ab2e30deee380e3ed00b26752fe036709 | refs/heads/master | 2021-01-21T20:53:38.311180 | 2018-03-25T20:53:19 | 2018-03-25T20:53:19 | 94,757,883 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 555 | hpp | #ifndef MYEVENTRECEIVER_HPP__
# define MYEVENTRECEIVER_HPP__
#include "include/irrlicht.h"
#include "Keycodes.h"
#include <vector>
class MyEventReceiver : public irr::IEventReceiver {
std::vector<bool> keys;
public:
MyEventReceiver() {
keys.reserve(KEY_KEY_CODES_COUNT);
for (auto i = 0; i < KEY_KEY_CODES_COUNT;++i)
keys.push_back(false);
}
const std::vector<bool> &getKeys() const { return keys; }
void clearKeys() { std::fill(keys.begin(), keys.end(), false); }
virtual bool OnEvent(const irr::SEvent &event);
};
#endif
| [
"aurelien.gassemann@epitech.eu"
] | aurelien.gassemann@epitech.eu |
4bcc0e7d9388ff186baf60887d995fb88539016a | f322a6b03208a0b42ca30f02128b48d57c5377c9 | /include/bounded_buffer.hh | baa7d0955c34b89c493a474b6b9718aca55b077a | [] | no_license | dantrim/test-buffer | cf319bc150c6c1e28011d689658646fcfcb3a0db | 2bae5648f34fd0b58bc5e93b29d3e7f5a8cde8ad | refs/heads/master | 2021-01-11T01:45:42.154542 | 2016-10-19T10:39:38 | 2016-10-19T10:39:38 | 70,645,241 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,634 | hh | #include <boost/circular_buffer.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/thread/condition.hpp>
#include <boost/thread/thread.hpp>
#include <boost/call_traits.hpp>
#include <boost/bind.hpp>
#include <boost/timer/timer.hpp> // for auto_cpu_timer
#include <iostream>
#include <string>
#include <sstream>
template <class T>
class bounded_buffer
{
public:
typedef boost::circular_buffer<T> container_type;
typedef typename container_type::size_type size_type;
typedef typename container_type::value_type value_type;
typedef typename boost::call_traits<value_type>::param_type param_type;
explicit bounded_buffer(size_type capacity) : m_unread(0), m_container(capacity) {}
void push_front(typename boost::call_traits<value_type>::param_type item)
{ // `param_type` represents the "best" way to pass a parameter of type `value_type` to a method.
boost::mutex::scoped_lock lock(m_mutex);
m_container.push_front(item);
lock.unlock();
m_not_empty.notify_one();
/*
boost::mutex::scoped_lock lock(m_mutex);
m_not_full.wait(lock, boost::bind(&bounded_buffer<value_type>::is_not_full, this));
m_container.push_front(item);
++m_unread;
lock.unlock();
m_not_empty.notify_one();
*/
}
void pop_back(value_type* pItem) {
boost::mutex::scoped_lock lock(m_mutex);
while(m_container.empty()) {
m_not_empty.wait(lock);
}
*pItem = m_container.back();
m_not_empty.notify_one();
/*
boost::mutex::scoped_lock lock(m_mutex);
m_not_empty.wait(lock, boost::bind(&bounded_buffer<value_type>::is_not_empty, this));
*pItem = m_container[--m_unread];
//m_container.pop_back();
lock.unlock();
m_not_full.notify_one();
*/
}
int get_capacity() {
return m_container.capacity();
}
int get_size() {
return m_container.size();
}
std::string print() {
std::stringstream sx;
for(int i = 0; i < (int)m_container.size(); i++) {
sx << m_container[i] << " ";
}
return sx.str();
}
bool empty() {
boost::mutex::scoped_lock lock(m_mutex);
return m_container.empty();
}
bool is_not_empty() const { return m_unread > 0; }
private:
bounded_buffer(const bounded_buffer&); // Disabled copy constructor.
bounded_buffer& operator = (const bounded_buffer&); // Disabled assign operator.
bool is_not_full() const { return m_unread < m_container.capacity(); }
size_type m_unread;
container_type m_container;
boost::mutex m_mutex;
boost::condition m_not_empty;
boost::condition m_not_full;
}; //
| [
"daniel.joseph.antrim@cern.ch"
] | daniel.joseph.antrim@cern.ch |
9b8e7640c41b41e5573af9b67edc462fe88969a9 | 3b984fb1a0f84bfe6dc0b4ec34a042581cb53812 | /BlockPos.h | 9c893363f8ae618222722e3fa75fcddd6b938280 | [] | no_license | mackthehobbit/MCPE-Headers | 78cf741bc1081471fab4506cdda4808b0c8417cc | adf073d666cc63dbc640a455c4907da522929307 | refs/heads/master | 2021-01-17T09:35:08.454693 | 2016-08-29T03:28:45 | 2016-08-29T03:28:45 | 66,353,700 | 0 | 0 | null | 2016-08-23T09:36:05 | 2016-08-23T09:36:04 | null | UTF-8 | C++ | false | false | 459 | h | #pragma once
#include <string>
class ChunkPos;
class Vec3;
// Size : 12
struct BlockPos {
static BlockPos MAX, MIN, ONE, ZERO;
int x; // 0
int y; // 4
int z; // 8
BlockPos() : x(0), y(0), z(0) {}
BlockPos(int x, int y, int z) : x(x), y(y), z(z) {}
BlockPos(const ChunkPos &, int);
BlockPos(const Vec3 &);
BlockPos(float, float, float);
void neighbor(signed char) const;
void relative(signed char, int) const;
std::string toString() const;
};
| [
"ksy4362@naver.com"
] | ksy4362@naver.com |
1ffd96b8340b5d7e88f2b0374d88f7741837677d | 2d6a8a21cf01d13c552b82d043561c5c5eb09bbc | /students/orehov_s/lab_1/un_tst.cpp | 41c4bf1662c5d033782cc4cac422f4195276bed6 | [] | no_license | leti-fkti-1381/2013-1381-sem-4 | 1fd42b812ab3e34ff7e49915099111c32715a422 | b40e5985841b73f0661161e71911a590b8801fce | refs/heads/master | 2016-09-11T04:55:28.208734 | 2013-06-11T19:11:53 | 2013-06-11T19:11:53 | 8,007,891 | 0 | 2 | null | 2013-02-04T14:47:36 | 2013-02-04T13:39:58 | null | UTF-8 | C++ | false | false | 578 | cpp | #include "sort.h"
#include "gtest/gtest.h"
#include<stdlib.h>
#include<time.h>
const int N=100000;
bool proverka( vector <T> a)
{
for (unsigned int i=0;i<N-1;i++)
if (a[i]>a[i+1]) return false;
return true;
}
TEST(qsort,first)
{
unsigned int i;
Sortirovka ob;
srand(time(0));
int m;
vector <T> mass;
for (i=0; i<N; i++)
{
m=rand()%256;
mass.push_back((char)m);
}
ob.qSortI(mass,N);
EXPECT_TRUE(proverka(mass));
system("pause");
}
int main(int argc, char **argv) {
setlocale(0,"");
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
| [
"lost9306@gmail.com"
] | lost9306@gmail.com |
8c8c0f18e073dbd61a1af88f01882f4e7525fb1b | 4ef09b833e4682b7c1c205a654874f4b2a7cba82 | /ray casting/source files/Plane.cpp | 51f739d165b69eb3e92aaf8b514df08062db24b2 | [] | no_license | GabrielChan1/sample-code | 87d9f18d3ee10198753918267cd44e88b77e2685 | c344df3a8f3a0f4882a3c2e651552ccf21599fc6 | refs/heads/master | 2020-06-04T01:46:24.465308 | 2019-06-13T20:12:08 | 2019-06-13T20:12:08 | 191,820,773 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 864 | cpp | #include "Plane.h"
#include "Ray.h"
/*
TODO:
- Calculate 't' based on the formula given in the lecture slides
- If there is an intersection, calculate the surface normal at the point of intersection
- ray.direction = s - e
- s = ray.origin + ray.direction
*/
bool Plane::intersect(
const Ray & ray, const double min_t, double & t, Eigen::Vector3d & n) const
{
////////////////////////////////////////////////////////////////////////////
// Replace with your code here:
// Calculate intermediate values
double q = normal.transpose().dot(point);
// Calculate 't1' using formula from lecture slides
double t1 = (q - normal.transpose().dot(ray.origin)) / (normal.transpose().dot(
ray.direction));
if (t1 < min_t) {
return false;
}
t = t1;
n = normal;
return true;
////////////////////////////////////////////////////////////////////////////
}
| [
"neoco@techie.com"
] | neoco@techie.com |
b56eb14dce49f8cb13466efba0d872f651a7eaf2 | 6b9ff1168d700f71748f438a9ff049653a431ae0 | /Stack/2_StackSTL.cpp | 8de2aa0f930ada5edafbc0ab5146d1700516746f | [] | no_license | hemangdtu/DSAlgo | 5c4b61d8c9f71f803d072edea0cc3dae2be30b27 | 6758a97bf7cdcb9761285d3b7b5d097be6ab0c11 | refs/heads/master | 2023-08-18T17:17:21.227397 | 2021-10-14T18:21:53 | 2021-10-14T18:21:53 | 254,940,088 | 5 | 1 | null | 2020-10-17T23:55:28 | 2020-04-11T19:28:49 | C++ | UTF-8 | C++ | false | false | 303 | cpp | #include<bits/stdc++.h>
using namespace std;
int main()
{
stack<int> s;
for(int i = 0; i<5; i++)
s.push(i*i);
while(!s.empty())
cout<<s.top()<<" ";
cout<<"\n";
stack<char> c;
for(char i = 'a'; i<'j'; i++)
c.push(i);
while(!c.empty())
{
cout<<c.top()<<" ";
c.pop();
}
return 0;
} | [
"hemang.dtu@gmail.com"
] | hemang.dtu@gmail.com |
5c90dc3d0972af342d9e7919a091ff26c31e8d76 | 703cf0f8a68cb93478bb7b47956a352ce91f4f04 | /HelloHoloCpp/Content/ShaderStructures.h | 157f011dbd7238a6074af11259b4d34198bf9e70 | [] | no_license | AndyGlaister-MS/HelloHoloCpp | 05224a16b647c572f6a08ddf6e7704f650fb6f19 | 3cbbe657abeefe81a623dfb0eac358dce6d9914b | refs/heads/master | 2020-04-06T04:46:42.257985 | 2017-02-23T19:11:38 | 2017-02-23T19:11:38 | 82,962,134 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 394 | h | #pragma once
namespace HelloHoloCpp
{
// Constant buffer used to send MVP matrices to the vertex shader.
struct ModelViewProjectionConstantBuffer
{
DirectX::XMFLOAT4X4 model;
DirectX::XMFLOAT4X4 view;
DirectX::XMFLOAT4X4 projection;
};
// Used to send per-vertex data to the vertex shader.
struct VertexPositionColor
{
DirectX::XMFLOAT3 pos;
DirectX::XMFLOAT3 color;
};
} | [
"andyg@ANDYG-PC"
] | andyg@ANDYG-PC |
dce14a9937c3d5e0bdeb71a3ed509116f6ace53e | 0eff74b05b60098333ad66cf801bdd93becc9ea4 | /second/download/CMake/CMake-gumtree/Kitware_CMake_repos_basic_block_block_5633.cpp | e20f4a46f6761f0ce492c18f1d3905313746c7d9 | [] | no_license | niuxu18/logTracker-old | 97543445ea7e414ed40bdc681239365d33418975 | f2b060f13a0295387fe02187543db124916eb446 | refs/heads/master | 2021-09-13T21:39:37.686481 | 2017-12-11T03:36:34 | 2017-12-11T03:36:34 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 68 | cpp | do {
*dest++ = Curl_raw_toupper(*src);
} while(*src++ && --n); | [
"993273596@qq.com"
] | 993273596@qq.com |
84af270a2dc8950179c041176f7474973fec5eb1 | f93c3347f4dbac00e93b59130773c9e3f45c9b0a | /code/Pascal's Triangle II.cpp | f9d91b4658ecb00d9ba688770fae851bc57f5f9f | [] | no_license | shizihao123/leetcode | 197301996c5d98d9a99f705074fc558d9c6469e7 | 8f9bb330cbbf9f1bca9b830499d0d0cb76b890c5 | refs/heads/master | 2021-01-23T01:56:50.290540 | 2015-03-07T13:29:52 | 2015-03-07T13:29:52 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 285 | cpp | class Solution {
public:
vector<int> getRow(int rowIndex) {
vector<int> line(rowIndex + 1, 1);
long long c = 1;
for (int i = 1; i < rowIndex; ++i) {
c = c * (rowIndex - i + 1) / i;
line[i] = c;
}
return line;
}
}; | [
"hustsxh@gmail.com"
] | hustsxh@gmail.com |
628c8e1f2fe7d22835de3958ddec5eaa6ca3261f | b3cd4b4d96d177469d89268e4d5251e727cdab1b | /src/gui/transferfunctionwidget.cpp | b4e89d67e7d1be7e7e3947cc9a2c66a58e32682a | [
"MIT"
] | permissive | aalele/MRE | c45cd51df40c236f36dfb4051be0568f6d052248 | f1500c190f9493b6230d237fdf6d21752a45dc4c | refs/heads/master | 2020-05-31T10:46:28.794660 | 2019-04-30T02:09:11 | 2019-04-30T02:09:11 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,695 | cpp |
#include "transferfunctionwidget.h"
namespace ysl
{
namespace imgui
{
TransferFunctionWidget::TransferFunctionWidget(const std::string& fileName):
TransferFunction(fileName)
{
}
void TransferFunctionWidget::BindTexture(const std::shared_ptr<OpenGLTexture>& tex)
{
texFunc = tex;
FetchData(funcData.data(), 256);
texFunc->SetData(OpenGLTexture::RGBA32F,
OpenGLTexture::RGBA,
OpenGLTexture::Float32,
256, 0, 0, funcData.data());
}
void TransferFunctionWidget::Draw()
{
ImGui::Begin("Transfer Function");
// Draw Transfer function widgets
ImDrawList * drawList = ImGui::GetWindowDrawList();
const ImVec2 canvasPos(ImGui::GetCursorScreenPos().x, ImGui::GetCursorScreenPos().y);
const ImVec2 canvasSize(ImGui::GetContentRegionAvail().x, (std::min)(ImGui::GetContentRegionAvail().y, 255.0f));
const ImVec2 canvasBottomRight(canvasPos.x + canvasSize.x, canvasPos.y + canvasSize.y);
drawList->AddRect(canvasPos, canvasBottomRight, IM_COL32_WHITE);
ImGui::InvisibleButton("canvas", canvasSize);
auto & io = ImGui::GetIO();
static int selectedKeyIndex = -1;
// Handle click and drag event
if (ImGui::IsItemHovered())
{
auto xpos = ImGui::GetIO().MousePos.x, ypos = ImGui::GetIO().MousePos.y;
if (ImGui::GetIO().MouseClicked[0])
{
lastMousePos = { io.MousePos.x - canvasPos.x, -io.MousePos.y + canvasPos.y + canvasSize.y };
}
if (ImGui::GetIO().MouseDown[0]) //
{
UpdateMappingKey({ lastMousePos.x,lastMousePos.y },
{ io.MousePos.x - canvasPos.x,-io.MousePos.y + canvasPos.y + canvasSize.y },
{ canvasSize.x,canvasSize.y });
lastMousePos = { io.MousePos.x - canvasPos.x,
-io.MousePos.y + canvasPos.y + canvasSize.y };
}
if (ImGui::GetIO().MouseDoubleClicked[0]) // left button double click
{
const auto x = io.MousePos.x - canvasPos.x;
const auto y = -io.MousePos.y + canvasPos.y + canvasSize.y;
selectedKeyIndex = HitAt({ x,y }, { canvasSize.x,canvasSize.y });
if (selectedKeyIndex != -1)
spec = (*this)[selectedKeyIndex].leftColor;
}
}
// Draw The transfer function
const auto keyCount = KeysCount();
if (keyCount != 0)
{
ysl::Float sx = canvasSize.x, sy = canvasSize.y;
auto p = KeyPosition(0, sx, sy);
ImVec2 first{ p.x,p.y };
p = KeyPosition(keyCount - 1, sx, sy);
ImVec2 last{ p.x,p.y };
ysl::Float x = canvasPos.x, y = canvasPos.y;
// Draw the left-most horizontal line
drawList->AddLine({ x,y + sy - first.y }, { first.x + x,sy - first.y + y }, IM_COL32_WHITE, 2);
for (auto i = 0; i < keyCount - 1; i++)
{
const auto pos1 =KeyPosition(i, sx, sy);
const auto pos2 = KeyPosition(i + 1, sx, sy);
const auto c1 = (*this)[i].leftColor;
const auto c2 = (*this)[i + 1].leftColor;
drawList->AddCircleFilled({ x + pos1.x,y + sy - pos1.y }, 5.f, IM_COL32(c1[0] * 255, c1[1] * 255, c1[2] * 255,255));
drawList->AddCircleFilled({ x + pos2.x,y + sy - pos2.y }, 5.f, IM_COL32(c2[0] * 255, c2[1] * 255, c2[2] * 255,255));
drawList->AddLine({ x + pos1.x ,y + sy - pos1.y }, { x + pos2.x,y + sy - pos2.y }, IM_COL32_WHITE, 2);
}
//Draw The right-most horizontal line
drawList->AddLine({ last.x + x,sy - last.y + y }, { x + canvasSize.x,y + sy - last.y }, IM_COL32_WHITE, 2);
}
/*TransferFunction Widget End*/
ImGui::SetCursorScreenPos(ImVec2(canvasPos.x, canvasPos.y + canvasSize.y + 10));
if (selectedKeyIndex != -1)
{
if (ImGui::ColorEdit4("Edit Color", (reinterpret_cast<float*>(&spec)), ImGuiColorEditFlags_Float));
UpdateMappingKey(selectedKeyIndex, spec);
}
ImGui::End();
}
}
} | [
"yangshuoliu@sina.com"
] | yangshuoliu@sina.com |
c2a26b2bb300045a4d9419f11edb60d62d940a66 | 0994cd2cf791d68635e6f4ad8a3ca2b3266dd787 | /site.h | faa574b126f9392d8ec73dc090b30b7ae8b843f6 | [] | no_license | kikuznetsov/konstpro | 7f8be03e66014408aaf3a42ec4fd7319bd59322d | 572dcd860d36b4b30bae50dbed8bc8178c7c1313 | refs/heads/master | 2020-09-22T12:50:11.695638 | 2017-01-21T20:53:14 | 2017-01-21T20:53:14 | 66,449,073 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 547 | h | #ifndef HOME_H
#define HOME_H
#include <Wt/WApplication>
#include <Wt/WLineEdit>
#include <Wt/WMenu>
#include <Wt/WMessageBox>
#include <Wt/WNavigationBar>
#include <Wt/WPopupMenu>
#include <Wt/WPopupMenuItem>
#include <Wt/WStackedWidget>
#include <Wt/WText>
#include <Wt/WBootstrapTheme>
using namespace Wt;
class Site : public WApplication
{
public:
Site(const WEnvironment& env);
private:
Wt::WContainerWidget *bodyContainer;
Wt::WNavigationBar *navigation;
Wt::WMenu *leftMenuNav;
//Wt::WMenu *menuModule;
};
#endif // HOME_H
| [
"konstantin.kouznetsov@gmail.com"
] | konstantin.kouznetsov@gmail.com |
4ddb5c4669b89fce1bd4c77ae7857421df44070f | 8cfd7b8994b41b0978730a4d4fed3b8ea40449dd | /PersonMgrTreeView.h | 71e6c4ad841d7b609b637ac1893765ad9a143112 | [] | no_license | shinbochen/personMgr | a73df395d26ac6bb3f162555c5356b1809f62b6d | 16aaea9848dc2fc70cc9caf4b3f4a1e787b9458b | refs/heads/master | 2020-03-11T20:25:46.593841 | 2018-04-19T15:26:15 | 2018-04-19T15:26:15 | 127,729,220 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,844 | h | // PersonMgrTreeView.h : interface of the CPersonMgrTreeView class
//
/////////////////////////////////////////////////////////////////////////////
// include file declare
#include "PersonMgrDoc.h"
#include "CtrlExt.h"
/////////////////////////////////////////////////////////////////////////////
// CONSTANTS declare
#if !defined(AFX_PERSONMGRTREEVIEW_H__AAFD4417_5CD3_4F7C_8AC8_C959EDEFB1AD__INCLUDED_)
#define AFX_PERSONMGRTREEVIEW_H__AAFD4417_5CD3_4F7C_8AC8_C959EDEFB1AD__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
class CPersonMgrTreeView : public CTreeView
{
protected: // create from serialization only
CPersonMgrTreeView();
DECLARE_DYNCREATE(CPersonMgrTreeView)
// Attributes
public:
// save the root item
CTreeCursor m_tRoot;
CTreeCursor m_tAccount;
CTreeCursor m_tPlan;
CTreeCursor m_tContact;
CTreeCursor m_tFamily;
CTreeCursor m_tCall;
CTreeCursor m_tOther;
// save the current select item
CTreeCursor m_tItemSel;
COLORREF m_crBack;
COLORREF m_crText;
// Operations
public:
CPersonMgrDoc* GetDocument();
BOOL CompareStringOnID( UINT nID, LPCTSTR lpStr1, LPCTSTR lpStr2 );
CTreeCursor FindTreeCurByStrID( UINT nID );
void AddItem( CString strFunc, UINT nID, BOOL bFlag );
BOOL IsBePartOf( LPCTSTR lpszValue, UINT nID );
void AddItem( CString strFunc, BOOL bFlag );
void PopulateTree( );
virtual ~CPersonMgrTreeView();
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CPersonMgrTreeView)
public:
virtual void OnDraw(CDC* pDC); // overridden to draw this view
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
protected:
virtual void OnInitialUpdate(); // called first time after construct
virtual BOOL OnPreparePrinting(CPrintInfo* pInfo);
virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo);
virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo);
virtual void OnPrint(CDC* pDC, CPrintInfo* pInfo);
//}}AFX_VIRTUAL
// Implementation
public:
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
protected:
// Generated message map functions
protected:
//{{AFX_MSG(CPersonMgrTreeView)
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnSelchanged(NMHDR* pNMHDR, LRESULT* pResult);
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
#ifndef _DEBUG // debug version in PersonMgrTreeView.cpp
inline CPersonMgrDoc* CPersonMgrTreeView::GetDocument()
{ return (CPersonMgrDoc*)m_pDocument; }
#endif
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_PERSONMGRTREEVIEW_H__AAFD4417_5CD3_4F7C_8AC8_C959EDEFB1AD__INCLUDED_)
| [
"58430351@qq.com"
] | 58430351@qq.com |
a20578e667472503ad7fbfd85409b1fa3bda77ed | e773931bdeb9317a5ff7c7e2e6b1012b2645642a | /chromeos/services/libassistant/display_controller.cc | 6d43a92f835397d055d50884ce5f431cfa33ed58 | [
"BSD-3-Clause"
] | permissive | SelyanKab/chromium | 21780bcaf7a21d67e3a4fe902aa8fd5d653b374b | ee248e9797404ad1cfcafdc3c0a58729b0f8f88d | refs/heads/master | 2023-03-14T15:02:38.903591 | 2021-03-10T10:21:05 | 2021-03-10T10:21:05 | 234,272,861 | 0 | 0 | BSD-3-Clause | 2020-01-16T08:36:12 | 2020-01-16T08:36:12 | null | UTF-8 | C++ | false | false | 3,267 | cc | // Copyright 2021 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chromeos/services/libassistant/display_controller.h"
#include <memory>
#include "chromeos/services/assistant/public/cpp/features.h"
#include "chromeos/services/libassistant/display_connection_impl.h"
#include "chromeos/services/libassistant/public/mojom/speech_recognition_observer.mojom.h"
#include "libassistant/shared/internal_api/assistant_manager_internal.h"
namespace chromeos {
namespace libassistant {
namespace {
assistant::AndroidAppInfo ToAndroidAppInfo(
const mojom::AndroidAppInfoPtr& app) {
assistant::AndroidAppInfo result;
result.package_name = app->package_name;
result.version = app->version;
result.localized_app_name = app->localized_app_name;
return result;
}
std::vector<assistant::AndroidAppInfo> ToAndroidAppInfoList(
const std::vector<mojom::AndroidAppInfoPtr>& apps) {
std::vector<assistant::AndroidAppInfo> result;
for (const auto& app : apps)
result.push_back(ToAndroidAppInfo(app));
return result;
}
} // namespace
class DisplayController::EventObserver : public DisplayConnectionObserver {
public:
explicit EventObserver(DisplayController* parent) : parent_(parent) {}
EventObserver(const EventObserver&) = delete;
EventObserver& operator=(const EventObserver&) = delete;
~EventObserver() override = default;
void OnSpeechLevelUpdated(const float speech_level) override {
for (auto& observer : parent_->speech_recognition_observers_)
observer->OnSpeechLevelUpdated(speech_level);
}
private:
DisplayController* const parent_;
};
DisplayController::DisplayController(
mojo::RemoteSet<mojom::SpeechRecognitionObserver>*
speech_recognition_observers)
: event_observer_(std::make_unique<EventObserver>(this)),
display_connection_(std::make_unique<DisplayConnectionImpl>(
event_observer_.get(),
/*feedback_ui_enabled=*/true,
assistant::features::IsMediaSessionIntegrationEnabled())),
speech_recognition_observers_(*speech_recognition_observers) {
DCHECK(speech_recognition_observers);
}
DisplayController::~DisplayController() = default;
void DisplayController::Bind(
mojo::PendingReceiver<mojom::DisplayController> receiver) {
receiver_.Bind(std::move(receiver));
}
void DisplayController::SetArcPlayStoreEnabled(bool enabled) {
display_connection_->SetArcPlayStoreEnabled(enabled);
}
void DisplayController::SetDeviceAppsEnabled(bool enabled) {
display_connection_->SetDeviceAppsEnabled(enabled);
}
void DisplayController::SetRelatedInfoEnabled(bool enabled) {
display_connection_->SetAssistantContextEnabled(enabled);
}
void DisplayController::SetAndroidAppList(
std::vector<mojom::AndroidAppInfoPtr> apps) {
display_connection_->OnAndroidAppListRefreshed(ToAndroidAppInfoList(apps));
}
void DisplayController::OnAssistantManagerCreated(
assistant_client::AssistantManager* assistant_manager,
assistant_client::AssistantManagerInternal* assistant_manager_internal) {
assistant_manager_internal->SetDisplayConnection(display_connection_.get());
}
} // namespace libassistant
} // namespace chromeos
| [
"chromium-scoped@luci-project-accounts.iam.gserviceaccount.com"
] | chromium-scoped@luci-project-accounts.iam.gserviceaccount.com |
9d39853ecd34b276b983ebe5412459a456660658 | 88ae8695987ada722184307301e221e1ba3cc2fa | /third_party/tflite/src/tensorflow/compiler/mlir/tools/kernel_gen/ir/tf_framework_ops.h | c5f011f25cf94379feeee8042a1150fe40cebeb3 | [
"BSD-3-Clause",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-generic-cla",
"BSD-2-Clause",
"LGPL-2.0-or-later",
"MIT",
"GPL-1.0-or-later"
] | permissive | iridium-browser/iridium-browser | 71d9c5ff76e014e6900b825f67389ab0ccd01329 | 5ee297f53dc7f8e70183031cff62f37b0f19d25f | refs/heads/master | 2023-08-03T16:44:16.844552 | 2023-07-20T15:17:00 | 2023-07-23T16:09:30 | 220,016,632 | 341 | 40 | BSD-3-Clause | 2021-08-13T13:54:45 | 2019-11-06T14:32:31 | null | UTF-8 | C++ | false | false | 2,458 | h | /* Copyright 2020 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
// This file defines the operations used in the TFFramework dialect.
//
#ifndef TENSORFLOW_COMPILER_MLIR_TOOLS_KERNEL_GEN_IR_TF_FRAMEWORK_OPS_H_
#define TENSORFLOW_COMPILER_MLIR_TOOLS_KERNEL_GEN_IR_TF_FRAMEWORK_OPS_H_
#include "absl/status/status.h"
#include "mlir/Dialect/Bufferization/IR/AllocationOpInterface.h" // from @llvm-project
#include "mlir/IR/Attributes.h" // from @llvm-project
#include "mlir/IR/BuiltinTypes.h" // from @llvm-project
#include "mlir/IR/Dialect.h" // from @llvm-project
#include "mlir/IR/MLIRContext.h" // from @llvm-project
#include "mlir/IR/OpDefinition.h" // from @llvm-project
#include "mlir/IR/OpImplementation.h" // from @llvm-project
#include "mlir/Interfaces/ControlFlowInterfaces.h" // from @llvm-project
#include "mlir/Interfaces/SideEffectInterfaces.h" // from @llvm-project
#include "tensorflow/compiler/mlir/tools/kernel_gen/ir/tf_status.h.inc"
#include "tensorflow/core/protobuf/error_codes.pb.h"
namespace mlir {
namespace kernel_gen {
namespace tf_framework {
/// OpKernelContextType corresponds to C++ class OpKernelContext defined in
/// tensorflow/core/framework/op_kernel.h
class OpKernelContextType
: public Type::TypeBase<OpKernelContextType, Type, TypeStorage> {
public:
using Base::Base;
};
class JITCallableType
: public Type::TypeBase<JITCallableType, Type, TypeStorage> {
public:
using Base::Base;
};
absl::StatusCode ConvertAttrToEnumValue(ErrorCode error_code);
} // namespace tf_framework
} // namespace kernel_gen
} // namespace mlir
#define GET_OP_CLASSES
#include "tensorflow/compiler/mlir/tools/kernel_gen/ir/tf_framework_dialect.h.inc"
#include "tensorflow/compiler/mlir/tools/kernel_gen/ir/tf_framework_ops.h.inc"
#endif // TENSORFLOW_COMPILER_MLIR_TOOLS_KERNEL_GEN_IR_TF_FRAMEWORK_OPS_H_
| [
"jengelh@inai.de"
] | jengelh@inai.de |
2ed30f339de237b939dcb9b7a1b82e8f04135cfd | 986fe09e081b04a36de45fe0f0530a61b9dcdfc4 | /basis/output_string.cpp | b57455b3ea96d101951060b3463a9cd5ce78b8d4 | [] | no_license | Muriam/cpp_and_other | d6097b702f05d9942617063fb33246415331dab5 | 3a1a90d56d55980b19e9b9e937d5ec322ea1b1fb | refs/heads/master | 2023-03-24T13:04:57.968521 | 2021-03-23T11:07:15 | 2021-03-23T11:07:15 | 100,115,225 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 362 | cpp | #include <iostream>
using namespace std;
void func1(char arr1[]);
int main()
{
setlocale(LC_ALL, "rus");
char arr1[] = "абвгдеёжзийклмнопрстуфхцчшщъыьэюя";
func1(arr1);
return 0;
}
void func1(char arr1[])
{
for (int i = 0; arr1[i] != '\0'; i++)
{
cout << arr1[i];
}
}
| [
"d_muriam@inbox.ru"
] | d_muriam@inbox.ru |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.