blob_id stringlengths 40 40 | directory_id stringlengths 40 40 | path stringlengths 2 247 | content_id stringlengths 40 40 | detected_licenses listlengths 0 57 | license_type stringclasses 2 values | repo_name stringlengths 4 111 | snapshot_id stringlengths 40 40 | revision_id stringlengths 40 40 | branch_name stringlengths 4 58 | visit_date timestamp[ns]date 2015-07-25 18:16:41 2023-09-06 10:45:08 | revision_date timestamp[ns]date 1970-01-14 14:03:36 2023-09-06 06:22:19 | committer_date timestamp[ns]date 1970-01-14 14:03:36 2023-09-06 06:22:19 | github_id int64 3.89k 689M ⌀ | star_events_count int64 0 209k | fork_events_count int64 0 110k | gha_license_id stringclasses 25 values | gha_event_created_at timestamp[ns]date 2012-06-07 00:51:45 2023-09-14 21:58:52 ⌀ | gha_created_at timestamp[ns]date 2008-03-27 23:40:48 2023-08-24 19:49:39 ⌀ | gha_language stringclasses 159 values | src_encoding stringclasses 34 values | language stringclasses 1 value | is_vendor bool 1 class | is_generated bool 2 classes | length_bytes int64 7 10.5M | extension stringclasses 111 values | filename stringlengths 1 195 | text stringlengths 7 10.5M |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0b62812c6b7f2a9d29fa19f7879e21785ad4d519 | c4c3e721c040abd543fedeb90cf60491a50bbf3f | /if4.cpp | c4971ddfc20543dd9bb41bb1cbe929c6dc0893cd | [] | no_license | kolesnikovaO/C-Ess-KI3 | 6698f6f9bdaa51ecec82b1bea1a847eeacbba6bc | 371ef82ef7e823322d7afbec6110f57124c77329 | refs/heads/master | 2021-08-30T17:33:53.795305 | 2017-12-18T20:29:55 | 2017-12-18T20:29:55 | 106,173,247 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 432 | cpp | if4.cpp | #include <iostream>
using namespace std;
int main(void) {
int year, mounth, day;
cout << "Enter year, mounth,day!" << endl;
cin >> year;
cin >> mounth;
cin >> day;
mounth -= 2;
if (mounth < 0) {mounth +=12; year -= 1;
mounth *=83./32.;
mounth += day+year + year/4. - year/100. + year / 400.;
cout << mounth % 7;}
else{
mounth *= 83. / 32.;
mounth += day + year +year/4. - year/ 100. +year /400.;
cout << mounth % 7;}
return 0;
}
|
328e588777e629177c7935196070a68d89e9d6d5 | 4bc572d4044736aff16c2a70859e1cf053fdfca5 | /FGGC Framework Semester 2/Shader.h | cd6d561d08059d3f88c7414d75b3c6308c948934 | [] | no_license | AnthonySturdy/DX11-ShipScene-Physics | 77b5eb97cf59f37e1a0efb1a695b4ebd34727217 | 665858bf9dd6a4b20d9f761e1f90b13bfdab3508 | refs/heads/master | 2023-07-11T10:05:38.059270 | 2021-08-21T00:48:09 | 2021-08-21T00:48:09 | 235,552,102 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 740 | h | Shader.h | #pragma once
#include <d3d11_1.h>
#include <d3dcompiler.h>
#include <directxmath.h>
#include <directxcolors.h>
using namespace DirectX;
class Shader {
private:
ID3D11Device* device;
ID3D11DeviceContext* context;
ID3D11VertexShader* vertexShader;
ID3D11PixelShader* pixelShader;
ID3D11InputLayout* vertexLayout;
ID3D11SamplerState* samplerLinear;
public:
Shader(ID3D11Device* _device, ID3D11DeviceContext* _context, WCHAR* fileDir);
~Shader();
HRESULT InitShadersAndInputLayout(WCHAR* fileDir);
HRESULT CompileShaderFromFile(WCHAR* szFileName, LPCSTR szEntryPoint, LPCSTR szShaderModel, ID3DBlob** ppBlobOut);
ID3D11VertexShader* GetVertexShader();
ID3D11PixelShader* GetPixelShader();
ID3D11SamplerState* GetSampler();
}; |
63c6a641acab2e7212cae082d9ff93b6e7d38d4d | 2758b84e44ea542f42c087d689e847353426e2db | /Tools/Src/MaxTools/ClassDesc.h | cfcd97174e20e624bee3a6d28da943f88e0b6342 | [] | no_license | stravaganza/sgzsourcepack | db8949506f5d68c6ed23bdf2681b67ba4b485ce6 | 20ac3be3c4a9f994c7119030baff3bad216c5a09 | refs/heads/master | 2016-09-05T14:22:55.940388 | 2013-10-16T07:44:33 | 2013-10-16T07:44:33 | 13,604,601 | 2 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,940 | h | ClassDesc.h | // ==[ File ]===================================================================================
//
// -Name : ClassDesc.h
// -Proyect : MaxTools
// -Author : Enrique Tromp Maseda A.K.A. Ithaqua^Stravaganza
//
// -Contents : CSGZMaxToolsClassDesc definition
//
// =============================================================================================
/*
19/12/2002 - File created.
*/
#ifndef CLASSDESC_H
#define CLASSDESC_H
#include <iparamb2.h>
#include <actiontable.h>
#define ID_ACTIONTABLE 0x362440e9
#define ID_ACTIONCONTEXT 0x4dfd44e8
// ==[ Classes ]================================================================================
// --[ Class ]-----------------------------------------------------------
//
// - Name : CSGZMaxToolsClassDesc
//
// - Purpose : Our class descriptor. Must be child of MAXSDK's ClassDesc2.
// Returns information to MAX about our plugin.
//
// ---------------------------------------------------------------------------
class CSGZMaxToolsClassDesc : public ClassDesc2
{
public:
void* Create(BOOL loading = FALSE) { return &g_SGZMaxTools; }
int IsPublic () { return 1; }
const TCHAR* ClassName () { return _T("Stravaganza MAX Tools"); }
const TCHAR* Category () { return _T("Stravaganza"); }
SClass_ID SuperClassID () { return UTILITY_CLASS_ID; }
Class_ID ClassID () { return SGZMAXTOOLS_CLASS_ID; }
const TCHAR* InternalName () { return _T("Stravaganza MAX Tools"); }
HINSTANCE HInstance () { return hInstance; }
int NumActionTables() { return 1; }
ActionTable* GetActionTable (int i) { return BuildActionTable(); }
private:
ActionTable* BuildActionTable();
};
class CSGZMaxToolsActionCallback : public ActionCallback
{
public:
BOOL ExecuteAction(int id);
};
#endif |
3010eb933e478dbbf5db26f84dfea8697e929baf | 15a7b4cbf97b803775b26d8a1a7094cea114cff2 | /libraries/protocol/include/RequestFactory.hh | 4a4880f46e0439b14215a5faac7fc0813e8d76f9 | [] | no_license | AGuismo/G-BALLS-Rtype | 5ba71039a5b7c5bc31f950ff5e6f8758f4e963e5 | 75ba8ee5cded3e450c884a1c222699b8415e5973 | refs/heads/master | 2021-01-17T02:34:34.274163 | 2014-12-30T20:46:31 | 2014-12-30T20:46:31 | 13,957,123 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 546 | hh | RequestFactory.hh | #ifndef REQUESTFACTORY_H_
# define REQUESTFACTORY_H_
# include <map>
# include "ARequest.hh"
# include "RequestCode.hh"
class Protocol;
namespace request
{
class Factory
{
typedef std::map<requestCode::CodeID, ARequest *> lnk_type;
private:
Factory();
~Factory();
private:
static Factory &getInstance();
public:
static ARequest *factory(Protocol &, const requestCode::CodeID code);
static void factory(Protocol &, const ARequest &);
private:
lnk_type _lnk;
};
}
#endif /* REQUESTFACTORY_H_ */
|
12116d797f9e07e38fc6d30031848b2273d58364 | 11a5c93ce7ced7ead6c8d2ba9f800c3b279ee00e | /HOOPS/Dev_Tools/hoops_hio/hio_skp/source/GeometryImporter3DF.h | 790035a95c4df233fe8c9902a90219d91d96a715 | [] | no_license | hupech/MyBMConvert | 563c6e3c14f54e52c626deeb012d8ac6e8174920 | 8acb45991c37796d48e67affaab2a46e774b29ee | refs/heads/master | 2021-09-18T18:21:02.667847 | 2018-07-18T06:49:57 | 2018-07-18T06:49:57 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,545 | h | GeometryImporter3DF.h | // Copyright (c) Tech Soft 3D
//
// The information contained herein is confidential and proprietary to Tech Soft 3D, Inc.,
// and considered a trade secret as defined under civil and criminal statutes.
// Tech Soft 3D, Inc. shall pursue its civil and criminal remedies in the event of
// unauthorized use or misappropriation of its trade secrets. Use of this information
// by anyone other than authorized employees of Tech Soft 3D, Inc. is granted only under
// a written non-disclosure agreement, expressly prescribing the scope and manner of such use.
#pragma once
#include "GeometryImporter.h"
class GeometryImporter3DF : public GeometryImporter
{
public:
GeometryImporter3DF(StyleRepository& styleRepository, VisibilityChecker& visibilityChecker, InheritanceManager& inheritanceManager);
private:
virtual CurvesImporter * CreateCurvesImporter(SegmentOrganizer & segmentOrganizer);
virtual PolylinesImporter * CreatePolylinesImporter(SegmentOrganizer & segmentOrganizer);
virtual LinesImporter * CreateLinesImporter(SegmentOrganizer & segmentOrganizer);
virtual SegmentOrganizer * CreateSegmentOrganizer(StyleRepository& styleRepository, VisibilityChecker& visibilityChecker);
virtual ShellImporter * CreateShellImporter(SegmentOrganizer& segmentOrganizer, TextureWriter& textureWriter, InheritanceManager& inheritanceManager);
virtual ImageTexturedShellImporter * CreateImageTexturedShellImporter(SegmentOrganizer& segmentOrganizer, ImageRepository& imageRepository, TextureRepository& textureRepository);
};
|
a62773f1ec0f9d40dc9489e8cb338ca57125949c | e5091c3a8477fa12e1adfdb1f3d826eb6e9bb2be | /CSES/weird_algorithm.cpp | ebc9e0fef145bf834d06fc29b27b59d200e66eef | [] | no_license | leonardoAnjos16/Competitive-Programming | 1db3793bfaa7b16fc9a2854c502b788a47f1bbe1 | 4c9390da44b2fa3c9ec4298783bfb3258b34574d | refs/heads/master | 2023-08-14T02:25:31.178582 | 2023-08-06T06:54:52 | 2023-08-06T06:54:52 | 230,381,501 | 7 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 236 | cpp | weird_algorithm.cpp | #include <iostream>
using namespace std;
int main() {
long long int n; cin >> n;
while (n > 1LL) {
cout << n << " ";
if (!(n & 1LL)) n >>= 1LL;
else n *= 3LL, n++;
}
cout << "1\n";
} |
be435e0b023b1c18aaa2d12b576908988f76d552 | 1bd91f2299200598859fd9841fe52941397195fa | /sndchecker.cc | 3c2976994c747d7824c1da8f3d5b62a5ea2c57b0 | [
"Apache-2.0"
] | permissive | kevinmarks/sndchecker | 792428e0e8d9538283fcb11dbaf3e4c27c197b00 | 60a6331b9cc1104e1b89c0e62bdcd97412eab3bb | refs/heads/master | 2021-01-18T10:16:18.410773 | 2015-08-16T02:56:41 | 2015-08-16T02:56:41 | 40,801,369 | 0 | 0 | null | 2015-08-16T06:26:47 | 2015-08-16T06:26:47 | null | UTF-8 | C++ | false | false | 3,740 | cc | sndchecker.cc | #include <stdio.h> /* printf */
#include <stdlib.h>
#include <cmath> // std::abs
#include <vector>
#include <sndfile.hh>
/* 8K chunks vs 1K chunks = about a 4x speedup */
#define BUFFER_LEN 8192
float threshold = 0.13; // Anything above this loudness threshold, we consider to be "good"
int bucket_size = 24000; // number of samples per bucket, should really be derived from file...
/* track goes here */
std::vector<float> samples;
static void read_file (const char * fname)
{
SndfileHandle mySndfileHandle;
mySndfileHandle = SndfileHandle(fname);
int channels = mySndfileHandle.channels();
int frames = mySndfileHandle.frames();
printf("%d channels, %d frames\n" , channels, frames);
// We'll load in BUFFER_LEN samples at a time, and stuff them into a buffer
// We need to ensure that the buffer is long enough to hold all of the
// Channel data */
uint bufferSize = BUFFER_LEN * channels;
// initialize our read buffer
float readbuffer[bufferSize];
int readcount;
int i;
int j;
int readpointer = 0;
// converts all multichannel files to mono by averaging the channels
// This is probably not an optimal way to convert to mono
float monoAverage;
while ((readcount = mySndfileHandle.readf(readbuffer, 1024))) {
readpointer = 0;
for (i = 0; i < readcount; i++) {
// for each frame...
monoAverage = 0;
for(j = 0; j < channels; j++) {
monoAverage += readbuffer[readpointer + j];
}
monoAverage /= channels;
readpointer += channels;
// add the averaged sample to our vector of samples
samples.push_back(monoAverage);
}
}
} /* read_file */
void analyze_file() {
/* attempt to calcuate a "quality" metric for the track.
*
* my quick and dirty calculation, aka the working algorithm is:
*
* divide up the track into a number of buckets, around 500mS / bucket
* for each bucket, calculate rms for the entire bucket
* at the end of the bucket, calculate the rms / "loudness" of the bucket
* if loudness > threshold
* count bucket as good
* reset the per-bucket counter
* divide the total number of buckets by the successful buckets.
* return this as a score between 0-100%.
*/
int bucket_pos;
int buckets_good = 0;
float this_bucket_total = 0;
unsigned long buckets;
printf("samples: %ld\n", samples.size());
/* 24000 samples = 500 mS @ 44.KHz */
bucket_pos = 0;
buckets = samples.size() / bucket_size;
printf("buckets: %ld\n", buckets);
// for all samples
for (int i=0; i < samples.size(); i++) {
this_bucket_total += std::abs(samples[i]) * std::abs(samples[i]);
bucket_pos++;
if (bucket_pos > bucket_size) {
float rms = sqrt((this_bucket_total / bucket_size));
// printf("rms: %f\n", rms);
if (rms > threshold) {
buckets_good++;
}
/* reset */
bucket_pos = 0;
this_bucket_total = 0;
}
}
printf(" good: %i\n pct: %.02f %%\n" , buckets_good, ( (float)buckets_good/buckets ) * 100);
};
int main (int argc,char * argv[])
{
if ((argc < 2) || (argc > 4)) {
printf("\nUsage: %s soundfile [threshold] [samples_per_bucket]\n", argv[0]);
printf(" threshold RMS threshold for a good bucket (default %0.3f)\n", threshold);
printf(" samples_per_bucket Samples per bucket (default %d)\n\n", bucket_size);
exit(1);
}
if (argc >= 3) {
std::string str (argv[2]);
threshold = std::stof(str);
}
if (argc == 4) {
std::string str (argv[3]);
bucket_size = std::stoi(str);
}
read_file (argv[1]) ;
analyze_file();
puts ("Done.\n") ;
return 0 ;
} /* main */
|
1368bbd7a014a6cd150f27ca76e76714f00673e7 | 8a28891c592d6b502f12de873d080b42130948b6 | /src/util/eventlist.h | 30c03c00c90a03b4096a3635c0f94478944c67ef | [] | no_license | MGraefe/deferred | 2d12bea544549df46e15a4c06dab05a46a6b6e45 | 92d7b39294195441dcb86254e0dc738561abf184 | refs/heads/master | 2016-09-06T12:37:53.518946 | 2015-08-03T12:27:22 | 2015-08-03T12:27:22 | 40,123,198 | 2 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 23,158 | h | eventlist.h | // util/eventlist.h
// util/eventlist.h
// util/eventlist.h
//----------------------------------
// Deferred Source Code
// Copyright (c) 2015 Marius Graefe
// All rights reserved
// Contact: deferred@mgraefe.de
//-----------------------------------
#pragma once
#ifndef deferred__util__eventlist_H__
#define deferred__util__eventlist_H__
#include "IEvent.h"
namespace ev
{
enum
{
//keyboard
KEYBOARD_PRESSED = 0,
KEYBOARD_RELEASED,
//mouse
MOUSE_PRESSED,
MOUSE_RELEASED,
MOUSE_POS_UPDATE,
//system
WINDOW_RESIZED,
SWITCH_FULLSCREEN,
//client inputs
CAR_STEER_UPDATE,
CAR_ACCEL_UPDATE,
CAR_UPDOWN_UPDATE,
CAR_RESET,
CAR_BRAKE_UPDATE,
//gui
SCOREBOARD_SHOW,
SCOREBOARD_HIDE,
//other
SET_CLIENT_NAME,
//server output
//CAR_MOTOR_UPDATE,
//Collision events
COLLISION_OCCURED,
//Camera
CAMERA_CREATE,
//MODELS
MODEL_STATIC_CREATE,
//GENERAL
//ENT_POS_UPDATE,
//ENT_ORI_UPDATE,
ENT_CREATE,
ENT_CREATE_INITIAL,
ENT_DELETE,
//WORLD
WORLD_CREATED,
PLAYER_CAR_CREATE,
SET_LOCAL_CLIENT_ID,
TELL_SNAPSHOT_TIME,
SERVER_SNAPSHOT_START,
SERVER_SNAPSHOT_END,
REMOTE_LISTENER_REGISTER,
CLIENT_FINISHED_REGISTER,
TIME_SYNC_MESSAGE,
PING_REQUEST,
PING_ANSWER,
START_PHYS_DEBUG,
SET_PHYS_DEBUGGER,
NETTABLE_UPDATE,
NETTABLE_UPDATE_INTERP,
LAST_EVENT,
ALL_EVENTS,
};
}
//DUMMY FOR CREATING NEW EVENTS:
//class <EventName> : public IEvent
//{
//public:
// <EventName>( InStream &in ) { IEVENT_DESERIALIZE(); <Additional Deserializations> }
// void Serialize( OutStream &out ) const { IEVENT_SERIALIZE(); <Additional Serializations> }
// <EventName>( IEVENT_CONSTR_PARAMS, <Additional Constructor Params> ) : IEVENT_CONSTR_CALLS, <Additional Constructor Calls> { }
// <Additonal Get Data Functions>
//private:
// <Additional Data Types>
//};
//Event Classes:
//######################################################
// CNoDataEvent
//######################################################
class CNoDataEvent : public IEventStaticSized
{
DECLARE_CLASS(IEventStaticSized, CNoDataEvent);
public:
IEVENT_CONSTR_DEFAULT(CNoDataEvent)
void Deserialize( InStream &in ) { }
void Serialize( OutStream &out ) const { }
};
class CWindowResizedEvent : public IEventStaticSized
{
DECLARE_CLASS(IEventStaticSized, CWindowResizedEvent);
public:
IEVENT_CONSTR_DEFAULT(CWindowResizedEvent)
void Deserialize( InStream &in ) { in >> m_widthBefore >> m_heightBefore >> m_widthAfter >> m_heightAfter; }
void Serialize( OutStream &out ) const { out << m_widthBefore << m_heightBefore << m_widthAfter << m_heightAfter; }
CWindowResizedEvent(IEVENT_CONSTR_PARAMS, int widthBefore, int heightBefore, int widthAfter, int heightAfter) :
IEVENT_CONSTR_CALLS,
m_widthBefore(widthBefore),
m_heightBefore(heightBefore),
m_widthAfter(widthAfter),
m_heightAfter(heightAfter)
{}
int GetWidthBefore() { return m_widthBefore; }
int GetHeightBefore() { return m_heightBefore; }
int GetWidthAfter() { return m_widthAfter; }
int GetHeightAfter() { return m_heightAfter; }
private:
int m_widthBefore;
int m_heightBefore;
int m_widthAfter;
int m_heightAfter;
};
//######################################################
// CCollisionEvent
//######################################################
class CCollisionEvent: public IEventStaticSized
{
DECLARE_CLASS(IEventStaticSized, CCollisionEvent);
public:
IEVENT_CONSTR_DEFAULT(CCollisionEvent)
void Deserialize( InStream &in ) { in >> m_vPos; in >> m_fForce; }
void Serialize( OutStream &out ) const { out << m_vPos; out << m_fForce; }
CCollisionEvent( IEVENT_CONSTR_PARAMS, const Vector3f &vPos, float fForce )
: IEVENT_CONSTR_CALLS, m_vPos(vPos), m_fForce(fForce) { }
float GetForce( void ) { return m_fForce; }
const Vector3f &GetPosition( void ) { return m_vPos; }
private:
Vector3f m_vPos;
float m_fForce;
};
//######################################################
// CCarMotorUpdateEvent
//######################################################
class CCarMotorUpdateEvent: public IEventStaticSized
{
DECLARE_CLASS(IEventStaticSized, CCarMotorUpdateEvent);
public:
IEVENT_CONSTR_DEFAULT(CCarMotorUpdateEvent)
void Deserialize( InStream &in ) { in >> m_iLogicEntId >> m_iRpm >> m_chLoad >> m_chGear; }
void Serialize( OutStream &out ) const { out << m_iLogicEntId << m_iRpm << m_chLoad << m_chGear; }
CCarMotorUpdateEvent( IEVENT_CONSTR_PARAMS, int entId, float fRpm, float fLoad, int iGear )
: IEVENT_CONSTR_CALLS,
m_iLogicEntId(entId),
m_iRpm((short int)fRpm),
m_chLoad((char)(fLoad*100.0f)),
m_chGear((char)iGear)
{ }
float GetRpm( void ) { return m_iRpm; }
float GetLoad( void ) { return ((float)(m_chLoad))*0.01f; }
int GetGear( void ) { return (int)m_chGear; }
int GetLogicalEnt( void ) { return m_iLogicEntId; }
private:
USHORT m_iLogicEntId;
short int m_iRpm;
char m_chLoad;
char m_chGear;
};
//######################################################
// CCarUpdateEvent
//######################################################
class CCarUpdateEvent : public IEventStaticSized
{
DECLARE_CLASS(IEventStaticSized, CCarMotorUpdateEvent);
public:
IEVENT_CONSTR_DEFAULT(CCarUpdateEvent)
void Deserialize( InStream &in ) {
Angle3dCompressed angs[4];
Angle3dCompressed ang;
Vector3fCompressed vecs[4];
in >> m_iLogicEntId >> m_carPos >> ang;
in.read((char*)vecs, sizeof(Vector3fCompressed)*4);
in.read((char*)angs, sizeof(Angle3dCompressed)*4);
in >> m_iRpm >> m_chLoad >> m_chGear;
//uncompress
m_carOri = ang.toAngle();
for( int i = 0; i < 4; i++ ) {
m_wheelPossRelative[i] = vecs[i].toVector(15.0f);
m_wheelAngles[i] = angs[i].toAngle();
}
}
void Serialize( OutStream &out) const {
out << m_iLogicEntId << m_carPos << Angle3dCompressed(m_carOri);
for( int i = 0; i < 4; i++ )
out << Vector3fCompressed(m_wheelPossRelative[i], 15.0f);
for( int i = 0; i < 4; i++ )
out << Angle3dCompressed(m_wheelAngles[i]);
out << m_iRpm << m_chLoad << m_chGear;
}
CCarUpdateEvent( IEVENT_CONSTR_PARAMS, int entId, const Vector3f &carPos, const Vector3f &carOri,
Vector3f wheelPoss[4], Angle3d wheelAngles[4], int rpm, float load, int gear )
: IEVENT_CONSTR_CALLS,
m_iLogicEntId(entId),
m_carPos(carPos),
m_carOri(carOri),
m_iRpm((short int)rpm),
m_chLoad((char)(load*100.0f)),
m_chGear((char)gear)
{
memcpy(m_wheelPossRelative, wheelPoss, sizeof(Vector3f)*4);
memcpy(m_wheelAngles, wheelAngles, sizeof(Vector3f)*4);
}
const Vector3f &GetPosition( void ) const { return m_carPos; }
const Angle3d &GetOri( void ) const { return m_carOri; }
const Vector3f &GetWheelPos(int index) const { return m_wheelPossRelative[index]; }
const Angle3d &GetWheelAngles(int index) const { return m_wheelAngles[index]; }
float GetRpm( void ) const { return m_iRpm; }
float GetLoad( void ) const { return ((float)(m_chLoad))*0.01f; }
int GetGear( void ) const { return (int)m_chGear; }
int GetLogicalEnt( void ) const { return m_iLogicEntId; }
private:
USHORT m_iLogicEntId;
Vector3f m_carPos;
Angle3d m_carOri;
Vector3f m_wheelPossRelative[4];
Angle3d m_wheelAngles[4];
short int m_iRpm;
char m_chLoad;
char m_chGear;
};
//######################################################
// CIntegerDataEvent
//######################################################
class CIntegerDataEvent : public IEventStaticSized
{
DECLARE_CLASS(IEventStaticSized, CIntegerDataEvent);
public:
IEVENT_CONSTR_DEFAULT(CIntegerDataEvent)
void Deserialize( InStream &in ) { in >> m_iValue; }
void Serialize( OutStream &out ) const { out << m_iValue; }
CIntegerDataEvent( IEVENT_CONSTR_PARAMS, int value ) : IEVENT_CONSTR_CALLS, m_iValue(value) { }
int GetValue( void ) const { return m_iValue; }
private:
int m_iValue;
};
//######################################################
// CFloatDataEvent
//######################################################
class CFloatDataEvent : public IEventStaticSized
{
DECLARE_CLASS(IEventStaticSized, CFloatDataEvent);
public:
IEVENT_CONSTR_DEFAULT(CFloatDataEvent)
void Deserialize( InStream &in ) { in >> m_fValue; }
void Serialize( OutStream &out ) const { out << m_fValue; }
CFloatDataEvent( IEVENT_CONSTR_PARAMS, float value ) : IEVENT_CONSTR_CALLS, m_fValue(value) { }
float GetValue( void ) const { return m_fValue; }
private:
float m_fValue;
};
//######################################################
// CPlayerCarCreateEvent
//######################################################
class CPlayerCarCreateEvent : public IEventStaticSized
{
DECLARE_CLASS(IEventStaticSized, CPlayerCarCreateEvent);
public:
IEVENT_CONSTR_DEFAULT(CPlayerCarCreateEvent)
void Deserialize( InStream &in ) { in.read(m_pFileName, 64); in >> m_iLogicEnt >> m_vPos >> m_aOri >> m_iPlayerCarID; }
void Serialize( OutStream &out ) const { out.write(m_pFileName, 64); out << m_iLogicEnt << m_vPos << m_aOri << m_iPlayerCarID; }
CPlayerCarCreateEvent( IEVENT_CONSTR_PARAMS,
int iLogicEntId,
const char *pFileName,
int iPlayerCarID,
Vector3f vPos,
Angle3d aOri )
: IEVENT_CONSTR_CALLS,
m_iLogicEnt(iLogicEntId),
m_iPlayerCarID(iPlayerCarID),
m_vPos(vPos),
m_aOri(aOri)
{
strcpy_s(m_pFileName,pFileName);
}
char* const GetName( void ) { return m_pFileName; }
int GetLogicEntity( void ) { return m_iLogicEnt; }
const Vector3f &GetPos( void ) { return m_vPos; }
const Angle3d &GetOri( void ) { return m_aOri; }
int GetPlayerCarID( void ) { return m_iPlayerCarID; }
private:
char m_pFileName[64];
USHORT m_iLogicEnt;
USHORT m_iPlayerCarID;
Vector3f m_vPos;
Angle3d m_aOri;
};
//######################################################
// CInputEvent
//######################################################
class CInputEvent: public IEventStaticSized
{
DECLARE_CLASS(IEventStaticSized, CInputEvent);
public:
IEVENT_CONSTR_DEFAULT(CInputEvent)
void Deserialize( InStream &in ) { in >> m_fVal >> m_pPlayerID; }
void Serialize( OutStream &out ) const { out << m_fVal << m_pPlayerID; }
CInputEvent( IEVENT_CONSTR_PARAMS, float val, int iPlayerID ) : IEVENT_CONSTR_CALLS, m_fVal(val), m_pPlayerID(iPlayerID) { }
float GetVal( void ) const { return m_fVal; }
int GetPlayerID( void ) const { return m_pPlayerID; }
private:
float m_fVal;
USHORT m_pPlayerID;
};
//######################################################
// CMouseMoveEvent
//######################################################
class CMouseMoveEvent : public IEventStaticSized
{
DECLARE_CLASS(IEventStaticSized, CMouseMoveEvent);
public:
IEVENT_CONSTR_DEFAULT(CMouseMoveEvent)
void Deserialize( InStream &in ) { in >> m_iX >> m_iY; }
void Serialize( OutStream &out ) const { out << m_iX << m_iY; }
CMouseMoveEvent( IEVENT_CONSTR_PARAMS, int x, int y ) : IEVENT_CONSTR_CALLS, m_iX(x), m_iY(y) { }
int GetX( void ) const { return m_iX; }
int GetY( void ) const { return m_iY; }
private:
int m_iX;
int m_iY;
};
//######################################################
// CMouseButtonEvent
//######################################################
class CMouseButtonEvent : public IEventStaticSized
{
DECLARE_CLASS(IEventStaticSized, CMouseButtonEvent);
public:
IEVENT_CONSTR_DEFAULT(CMouseButtonEvent)
void Deserialize( InStream &in ) { in >> m_x >> m_y >> m_keyCode; }
void Serialize( OutStream &out ) const { out << m_x << m_y << m_keyCode; }
CMouseButtonEvent( IEVENT_CONSTR_PARAMS, int keyCode, int x, int y ) : IEVENT_CONSTR_CALLS, m_keyCode(keyCode), m_x(x), m_y(y) { }
int GetX( void ) const { return m_x; }
int GetY( void ) const { return m_y; }
int GetKeyCode( void ) const { return m_keyCode; }
private:
int m_keyCode;
int m_x;
int m_y;
};
//######################################################
// CPosEvent
//######################################################
class CPosEvent : public IEventStaticSized
{
DECLARE_CLASS(IEventStaticSized, CPosEvent);
public:
IEVENT_CONSTR_DEFAULT(CPosEvent)
void Deserialize( InStream &in ) { in >> m_vPos >> m_iLogicEntId; }
void Serialize( OutStream &out ) const { out << m_vPos << m_iLogicEntId; }
CPosEvent( IEVENT_CONSTR_PARAMS, int iLogicEntId, Vector3f vPos )
: IEVENT_CONSTR_CALLS, m_vPos(vPos), m_iLogicEntId((USHORT)iLogicEntId) { }
const Vector3f &GetPos( void ) const { return m_vPos; }
int GetLogicEntity( void ) { return (int)m_iLogicEntId; }
private:
Vector3f m_vPos;
USHORT m_iLogicEntId;
};
//######################################################
// COriEvent
//######################################################
class COriEvent : public IEventStaticSized
{
DECLARE_CLASS(IEventStaticSized, COriEvent);
public:
IEVENT_CONSTR_DEFAULT(COriEvent)
void Deserialize( InStream &in ) {
Angle3dCompressed ang;
in >> ang >> m_iLogicEntId;
m_aOri = ang.toAngle();
}
void Serialize( OutStream &out ) const { out << Angle3dCompressed(m_aOri) << m_iLogicEntId; }
COriEvent( IEVENT_CONSTR_PARAMS, int iLogicEntId, Angle3d aOri )
: IEVENT_CONSTR_CALLS, m_aOri(aOri), m_iLogicEntId((USHORT)iLogicEntId) { }
const Angle3d &GetOri( void ) const { return m_aOri; }
int GetLogicEntity( void ) { return (int)m_iLogicEntId; }
private:
Angle3d m_aOri;
USHORT m_iLogicEntId;
};
//######################################################
// CModelCreateEvent
//######################################################
class CModelCreateEvent : public IEventStaticSized
{
DECLARE_CLASS(IEventStaticSized, CModelCreateEvent);
public:
IEVENT_CONSTR_DEFAULT(CModelCreateEvent)
void Deserialize( InStream &in ) { in.read(m_pFileName, 64); in >> m_iLogicEnt >> m_vPos >> m_aOri; }
void Serialize( OutStream &out ) const { out.write(m_pFileName, 64); out << m_iLogicEnt << m_vPos << m_aOri; }
CModelCreateEvent( IEVENT_CONSTR_PARAMS, int iLogicEntId, const char *pFileName, Vector3f vPos, Angle3d aOri )
: IEVENT_CONSTR_CALLS, m_iLogicEnt(iLogicEntId), m_vPos(vPos), m_aOri(aOri) { strcpy_s(m_pFileName,pFileName); }
char* const GetName( void ) { return m_pFileName; }
int GetLogicEntity( void ) { return m_iLogicEnt; }
const Vector3f &GetPos( void ) { return m_vPos; }
const Angle3d &GetOri( void ) { return m_aOri; }
private:
char m_pFileName[64];
USHORT m_iLogicEnt;
Vector3f m_vPos;
Angle3d m_aOri;
};
//######################################################
// CEntityDeleteEvent
//######################################################
class CEntityDeleteEvent : public IEventStaticSized
{
DECLARE_CLASS(IEventStaticSized, CEntityDeleteEvent);
public:
IEVENT_CONSTR_DEFAULT(CEntityDeleteEvent)
void Deserialize( InStream &in ) { in >> m_iLogicEnt; }
void Serialize( OutStream &out ) const { out << m_iLogicEnt; }
CEntityDeleteEvent( IEVENT_CONSTR_PARAMS, int iLogicEntId )
: IEVENT_CONSTR_CALLS, m_iLogicEnt(iLogicEntId) { }
int GetLogicEntity( void ) { return m_iLogicEnt; }
private:
USHORT m_iLogicEnt;
};
//######################################################
// CRenderWorldCreateEvent
//######################################################
class CRenderWorldCreateEvent : public IEventStaticSized
{
DECLARE_CLASS(IEventStaticSized, CRenderWorldCreateEvent);
public:
IEVENT_CONSTR_DEFAULT(CRenderWorldCreateEvent)
void Deserialize( InStream &in ) { in.read(m_pFileName, 64); in >> m_iLogicEnt >> m_vPos >> m_aOri; }
void Serialize( OutStream &out ) const { out.write(m_pFileName, 64); out << m_iLogicEnt << m_vPos << m_aOri; }
CRenderWorldCreateEvent( IEVENT_CONSTR_PARAMS, int iLogicEntId, const char *pFileName, Vector3f vPos, Angle3d aOri )
: IEVENT_CONSTR_CALLS, m_iLogicEnt(iLogicEntId), m_vPos(vPos), m_aOri(aOri) { strcpy_s(m_pFileName,pFileName); }
char* const GetName( void ) { return m_pFileName; }
int GetLogicEntity( void ) { return m_iLogicEnt; }
const Vector3f &GetPos( void ) { return m_vPos; }
const Angle3d &GetOri( void ) { return m_aOri; }
private:
char m_pFileName[64];
USHORT m_iLogicEnt;
Vector3f m_vPos;
Angle3d m_aOri;
};
//######################################################
// CCameraCreateEvent
//######################################################
class CCameraCreateEvent : public IEventStaticSized
{
DECLARE_CLASS(IEventStaticSized, CCameraCreateEvent);
public:
IEVENT_CONSTR_DEFAULT(CCameraCreateEvent)
void Deserialize( InStream &in ) { in >> m_iLogicEntId >> m_bIsPlayerOneCam >> m_bIsPlayerTwoCam; }
void Serialize( OutStream &out ) const { out << m_iLogicEntId << m_bIsPlayerOneCam << m_bIsPlayerTwoCam; }
CCameraCreateEvent( IEVENT_CONSTR_PARAMS, int iLogicEntId, bool bIsPlayerOneCam, bool bIsPlayerTwoCam )
: IEVENT_CONSTR_CALLS, m_iLogicEntId(iLogicEntId), m_bIsPlayerOneCam(bIsPlayerOneCam), m_bIsPlayerTwoCam(bIsPlayerTwoCam) { }
int GetLogicEntity( void ) { return m_iLogicEntId; }
const bool &IsPlayerOneCam( void ) { return m_bIsPlayerOneCam; }
const bool &IsPlayerTwoCam( void ) { return m_bIsPlayerTwoCam; }
private:
USHORT m_iLogicEntId;
bool m_bIsPlayerOneCam;
bool m_bIsPlayerTwoCam;
};
//######################################################
// CPointerDataEvent
//######################################################
//warning: 32 / 64 bit compability NOT given, only for very rare cases
//where server and client run on the same machine in the same process.
//DO NOT USE FOR NORMAL NETWORKING
class CPointerDataEvent : public IEventStaticSized
{
DECLARE_CLASS(IEventStaticSized, CPointerDataEvent);
public:
IEVENT_CONSTR_DEFAULT(CPointerDataEvent)
void Deserialize( InStream &in ) { in >> m_ptr; }
void Serialize( OutStream &out ) const { out << m_ptr; }
CPointerDataEvent( IEVENT_CONSTR_PARAMS, void* ptr )
: IEVENT_CONSTR_CALLS, m_ptr((long long)ptr) { }
void *GetPointer(void) const { return (void*)m_ptr; }
private:
long long m_ptr;
};
//######################################################
// CNettableUpdate
//######################################################
class CNettableUpdate : public IEventDynamicSized
{
DECLARE_CLASS(IEventDynamicSized, CNettableUpdate);
public:
CNettableUpdate(EventType type) :
BaseClass(type),
m_data(NULL),
m_dataSize(0)
{}
//If copyData is false, the data buffer is used directly. The buffer is deleted in the destructor.
CNettableUpdate( IEVENT_CONSTR_PARAMS, char *data, UINT dataSize, bool copyData = true) :
IEVENT_CONSTR_CALLS
{
Assert(dataSize <= IEventDynamicSized::GetPayloadSizeMax());
if( copyData )
{
m_data = new char[dataSize];
memcpy(m_data, data, dataSize);
}
else
m_data = data;
m_dataSize = dataSize;
}
virtual ~CNettableUpdate()
{
if( m_data )
delete[] m_data;
}
void Deserialize(InStream &in)
{
Assert(m_data == NULL);
m_dataSize = GetPayloadSize();
m_data = new char[m_dataSize];
in.read(m_data, m_dataSize);
}
void Serialize(OutStream &out) const
{
Assert(m_data != NULL);
Assert(m_dataSize <= IEventDynamicSized::GetPayloadSizeMax());
out.write(m_data, m_dataSize);
}
inline char *GetData() const {
return m_data;
}
UINT GetDataSize() const {
return GetPayloadSize();
}
CNettableUpdate* copy() const {
return new CNettableUpdate(GetType(), m_data, m_dataSize, true);
}
private:
//private copy constructor
CNettableUpdate(const CNettableUpdate &other) :
IEventDynamicSized(other)
{}
public:
static const UINT sMaxDataSize;
private:
char *m_data;
UINT m_dataSize;
};
//######################################################
// CEntityCreateEvent
//######################################################
class CEntityCreateEvent : public IEventDynamicSized
{
DECLARE_CLASS(IEventDynamicSized, CEntityCreateEvent);
public:
CEntityCreateEvent(EventType type) :
BaseClass(type),
m_classname(),
m_index(-1),
m_data(NULL),
m_dataSize(0)
{}
CEntityCreateEvent(const CEntityCreateEvent &other) :
BaseClass(other.m_type),
m_index(other.m_index),
m_classname(other.m_classname),
m_dataSize(other.m_dataSize)
{
m_data = new char[m_dataSize];
memcpy(m_data, other.m_data, m_dataSize);
}
//If copyData is false, the data buffer is used directly. The buffer is deleted in the destructor.
CEntityCreateEvent(IEVENT_CONSTR_PARAMS, int index, const char *classname, char *data, UINT dataSize, bool copyData = true) :
IEVENT_CONSTR_CALLS,
m_index(index),
m_classname(classname),
m_dataSize(dataSize)
{
Assert(index < std::numeric_limits<USHORT>::max());
Assert(dataSize + strlen(classname) + 3*sizeof(USHORT) <= IEventDynamicSized::GetPayloadSizeMax());
if( copyData )
{
m_data = new char[dataSize];
memcpy(m_data, data, dataSize);
}
else
m_data = data;
}
virtual ~CEntityCreateEvent()
{
if( m_data )
delete[] m_data;
}
void Deserialize(InStream &in)
{
Assert(m_data == NULL);
USHORT index = -1;
USHORT dataSize = 0;
in >> index >> m_classname >> dataSize;
m_index = index;
m_dataSize = dataSize;
m_data = new char[m_dataSize];
in.read(m_data, m_dataSize);
}
void Serialize(OutStream &out) const
{
Assert(m_data != NULL);
out << (USHORT)m_index << m_classname << (USHORT)m_dataSize;
out.write(m_data, m_dataSize);
}
inline char *GetData() const {
return m_data;
}
UINT GetDataSize() const {
return m_dataSize;
}
int GetIndex() const {
return m_index;
}
const std::string &GetClassname() const {
return m_classname;
}
public:
static const UINT sMaxDataSize;
private:
std::string m_classname;
int m_index;
char *m_data;
UINT m_dataSize;
};
//######################################################
// CStringDataEvent
//######################################################
class CStringDataEvent : public IEventDynamicSized
{
DECLARE_CLASS(IEventDynamicSized, CStringDataEvent);
public:
CStringDataEvent(EventType type) :
BaseClass(type),
m_string()
{}
CStringDataEvent(const CStringDataEvent &other) :
BaseClass(other.m_type),
m_string(other.m_string)
{
}
//If copyData is false, the data buffer is used directly. The buffer is deleted in the destructor.
CStringDataEvent(IEVENT_CONSTR_PARAMS, const char *str) :
IEVENT_CONSTR_CALLS,
m_string(str)
{
Assert(strlen(str) + 4*sizeof(USHORT) <= IEventDynamicSized::GetPayloadSizeMax());
}
virtual ~CStringDataEvent()
{
}
void Deserialize(InStream &in)
{
in >> m_string;
}
void Serialize(OutStream &out) const
{
out << m_string;
}
const std::string &GetString() const {
return m_string;
}
private:
std::string m_string;
};
#endif
|
81704fa66661151976ec5e79569d46751025c065 | 90f1739558df47caefcfdd382eedef744f3602cc | /Classes/ActorManager.cpp | 39df492c45bed4c37d08ccaee425cb428aaaea6f | [] | no_license | sevenzou/cocos2dx_astart | 8c319623483492550bce453376cce6b228aea8b5 | a272aba0f199fced599c7959ae855454fdbe49e8 | refs/heads/master | 2021-01-15T10:18:08.531930 | 2015-08-17T11:28:23 | 2015-08-17T11:28:23 | 40,887,693 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 542 | cpp | ActorManager.cpp | #include "ActorManager.h"
USING_NS_CC;
static ActorManager *s_actorManager = nullptr;
ActorManager* ActorManager::getInstance()
{
if (!s_actorManager)
s_actorManager = new ActorManager();
return s_actorManager;
}
Actor* ActorManager::getActorByTag(int tag)
{
for (Actor* actor : _actorTarget)
if ( tag == actor->getActorTag() )
return actor;
return nullptr;
}
Actor* ActorManager::getMonsterByTag(int tag)
{
for (Actor* monster : _monsterTarget)
if ( tag == monster->getActorTag() )
return monster;
return nullptr;
}
|
901708119fc19822f98faa0dff95501aff327524 | 4152583d8d19504d25aa2a2b87656028ac6de8d4 | /Source/RollaBall/Game/RollaBallWidget.cpp | 4e65f282017a0e8025ffed8d58562db781e7aa83 | [
"MIT"
] | permissive | UstymUkhman/RollaBall | e849309ebff4af36a47da5aed95b99c117e519dd | 29cf407c88e0cde09b6adcdaa613e8cf00a5a8d2 | refs/heads/main | 2023-07-10T01:47:24.804363 | 2021-08-14T16:39:59 | 2021-08-14T16:39:59 | 391,501,926 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 29 | cpp | RollaBallWidget.cpp | #include "RollaBallWidget.h"
|
46f5e2039257f2fc6103683a648e6ddd8959d75d | cadb836d9ac9c9e3b618cf44c936015a0aea24a8 | /ge700/LT0773_Sliding_Puzzle.cpp | 3925302a82feee68afdc89f5abeb3edc54020586 | [] | no_license | checkoutb/LeetCodeCCpp | c6341a9fa5583a69046555a892bb41052624e83c | 38832f7ccadf26b781cd8c9783c50916d1380554 | refs/heads/master | 2023-09-03T22:35:50.266523 | 2023-09-03T06:31:51 | 2023-09-03T06:31:51 | 182,722,336 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 3,837 | cpp | LT0773_Sliding_Puzzle.cpp |
#include "../header/myheader.h"
class LT0773
{
int target = 123450;
public:
// D D
// 用string,而不是vector<vector>
// 数组保存 当string下标x为0时,它可以和谁交换。
//Runtime: 76 ms, faster than 25.07% of C++ online submissions for Sliding Puzzle.
//Memory Usage: 16.8 MB, less than 16.67% of C++ online submissions for Sliding Puzzle.
// 。。
int lt0773a(vector<vector<int>>& board)
{
int t = vvToInt(board);
if (t == target)
return 0;
set<int> done;
done.insert(t);
int ans = 0;
queue<vector<vector<int>>> que1;
que1.push(board);
bool flag = true;
while (!que1.empty())
{
vector<vector<int>> vv2 = que1.front();
que1.pop();
#ifdef __test
for (vector<int> v : vv2)
{
for (int i : v)
{
cout<<i<<", ";
}
cout<<endl;
}
cout<<endl;
#endif // __test
if (vv2 == board)
{
ans++;
if (!flag && !que1.empty())
{
que1.push(board);
}
}
if (vvToInt(vv2) == target)
break;
int i0 = 0;
int j0 = 0;
for (; i0 < 2; i0++)
{
for (j0 = 0; j0 < 3; j0++)
{
if (vv2[i0][j0] == 0)
{
goto AAA;
}
}
}
AAA:
if (i0 == 0)
{
vector<vector<int>> vvNew(vv2);
vvNew[i0][j0] = vvNew[i0 + 1][j0];
vvNew[i0 + 1][j0] = 0;
t = vvToInt(vvNew);
if (done.count(t) == 0)
{
que1.push(vvNew);
done.insert(t);
}
}
else
{
vector<vector<int>> vvNew(vv2);
vvNew[i0][j0] = vvNew[i0 - 1][j0];
vvNew[i0 - 1][j0] = 0;
t = vvToInt(vvNew);
if (!done.count(t))
{
que1.push(vvNew);
done.insert(t);
}
}
if (j0 < 2)
{
vector<vector<int>> vvN(vv2);
vvN[i0][j0] = vvN[i0][j0 + 1];
vvN[i0][j0 + 1] = 0;
t = vvToInt(vvN);
if (!done.count(t))
{
que1.push(vvN);
done.insert(t);
}
}
if (j0 > 0)
{
vector<vector<int>> vvN(vv2);
vvN[i0][j0] = vvN[i0][j0 - 1];
vvN[i0][j0 - 1] = 0;
t = vvToInt(vvN);
if (!done.count(t))
{
que1.push(vvN);
done.insert(t);
}
}
if (flag)
{
flag ^= flag;
que1.push(board);
}
}
return que1.empty() ? -1 : ans;
}
int vvToInt(vector<vector<int>>& vv)
{
int ans = 0;
for (vector<int> v : vv)
{
for (int i : v)
{
ans *= 10;
ans += i;
}
}
return ans;
}
};
int main()
{
// 412 053, 012 453, 102 453, 120 453, 123 450
// vector<vector<int>> vv = {{4,1,2}, {5,0,3}};
// vector<vector<int>> vv = {{1,2,3},{4,0,5}};
vector<vector<int>> vv = {{1,2,3},{5,4,0}};
LT0773 lt;
cout<<lt.lt0773a(vv)<<endl;
return 0;
}
|
d4871e5b5de346b9ff8d50c22fb1cec621416879 | 2df1fc2356d006f9fc066e925c0e53fca2cf3ae3 | /settings.h | 91418af5ad303935d354f7fb1002e8b4ea94806e | [] | no_license | Jogenist/CM-IoT-App-Bestellstation | 4455da44c17cf70b225e923fdf79e73bd4f87f48 | 423b29f4b4805fd612f71e536f970c6a93ef8332 | refs/heads/master | 2021-05-21T14:44:36.290880 | 2020-05-22T10:25:58 | 2020-05-22T10:25:58 | 252,675,484 | 0 | 0 | null | 2020-04-03T09:06:01 | 2020-04-03T08:32:33 | C++ | UTF-8 | C++ | false | false | 4,447 | h | settings.h | /*
Type: HTML Index Page
Date: 14.08.2019
Author: Tim Schanz
Description: This header file stores the static HTML content of the configuration page.
*/
#include <Arduino.h>
#include <string>
using namespace std;
string dynamic_content_settings();
const char SETTINGS_page_Begin[] PROGMEM{ R"=====(
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="utf-8">
<meta name="Cocktail orderingpage" content="This site provides all purchaseable cocktails">
<meta name="cocktail" content="example, html, head, meta">
<link rel="shortcut icon" href="image/favico.ico" type="image/x-icon">
<link rel="icon" href="image/favico.ico" type="image/x-icon">
<title>MixHit Order</title>
<!-- Bootstrap core CSS -->
<link rel="stylesheet" href="css/bootstrap.min.css">
<!-- Custom styles for this template -->
<link rel="stylesheet" href="css/design.css">
</head>
<body id="page-top">
<!-- Navigation -->
<nav class="navbar navbar-expand-lg navbar-dark fixed-top" id="mainNav">
<div class="container">
<img class="logo_image" src="image/hska_logo.png">
<a class="navbar-brand" href="#page-top">Hochschule Karlsruhe - MixHit</a>
<button
class="navbar-toggler"
type="button"
data-toggle="collapse"
data-target="#navbarResponsive"
aria-controls="navbarResponsive"
aria-expanded="false"
aria-label="Toggle navigation"
>
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarResponsive">
<ul class="navbar-nav ml-auto">
<li class="nav-item">
<a
class="nav-link js-scroll-trigger"
href="#services"
>Settings</a
>
</li>
</ul>
</div>
</div>
</nav>
<header class="text-white">
<div class="container text-center">
<h1>CocktailMaker Ordering Terminal</h1>
<p class="lead">
This is the settingspage
</p>
</div>
</header>
<section id="settings" class="bg-light">
<div class="container">
<div class="row">
<div class="col-lg-8 mx-auto">
<h2>Settings</h2>
<p class="lead">Define the parameters and click save</p>
<form action="/" method="post" enctype="multipart/form-data">
<div class="form-check">
<input
class="form-check-input"
type="radio"
name="deposit_radios"
id="deposit"
value="deposit"
checked
>
<label class="form-check-label" for="deposit">
Pfand
</label>
</div>
<div class="form-check">
<input
class="form-check-input"
type="radio"
name="deposit_radios"
id="nodeposit"
value="nodeposit"
>
<label class="form-check-label" for="nodeposit">
Kein Pfand
</label>
</div>
Preis alkoholisch<br>
<input type="text" name="price_alc" value="5">
<br>
Preis nicht alkoholisch<br>
<input type="text" name="price_nonalc" value="4">
<br><br>
<input type="submit" value="Save" name="save">
</form>
)=====" };
const char SETTINGS_page_After[] PROGMEM{ R"=====(
</div>
</div>
</div>
</section>
<!-- Footer -->
<footer class="py-2">
<div class="container">
<div id="left">Copyright © Your Website 2019</div>
<div id="right">
<button class="btn btn-success" data-modal-target="#save">
Save Settings
</button>
</div>
</div>
<!-- /.container -->
</footer>
<script>
</script>
</body>
</html>
)=====" };
|
dc54072b458559e6cbdbc3cfaa5cbc35a1807b71 | 658d08b1038973328cf3c6e8f95417114ac63b9e | /Assignment7.cpp | e3b5a5b5c5e1c23e527c27e689bd7b02bbc77c50 | [] | no_license | itsJumaah/Algorithms-and-Data-structure | 8e45c9f39e7179c4e8e72e819e4e187b72b79f52 | 8dd774bb3aabbc9c5660ecc309ca074b1d4a348e | refs/heads/master | 2020-12-11T07:32:47.891581 | 2015-11-13T00:58:35 | 2015-11-13T00:58:35 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,040 | cpp | Assignment7.cpp | // 159.201 Assignment 7
// Bilal Jumaah
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
vector<int> vector_random;
vector<int> vector_reversed;
vector<int> vector_sorted;
/* Implement a Heap class here (from the slides) */
class Heap {
public:
Heap() : last(-1), comparisons(0) { }
~Heap() { };
void InsertHeap(int newThing);
int Delete();
void PrintHeap() const;
void Swap(int &item1, int &item2);
int GetComparisons() { return comparisons; }
void ResetComparisons() { comparisons = 0; }
private:
vector<int> data;
int last;
int comparisons;
};
void Heap::InsertHeap(int newThing) {
data.push_back(newThing); // add to the end
++last;
if (last == 0) // only one item in Heap
return;
int child_index = last;
int par_index = 0;
bool swapping = true;
while (swapping) { // fix the heap
swapping = false;
if ((child_index % 2) == 0) // if item added is right side
par_index = child_index / 2 - 1; // find the parent index
else // if item added is left side
par_index = child_index / 2; // find the parent index
if (par_index >= 0) {
++comparisons; // comparison here
if (data[child_index] > data[par_index]) {
swap(data[child_index], data[par_index]);
swapping = true;
child_index = par_index;
}
}
}
}
int Heap::Delete() {
if (last < 0)
return 0;
unsigned int deletedvalue = data[0]; //the root
data[0] = data[last];
data[last] = 0; //deleting...
last = last - 1; // one less element in the heap
int parindex = 0; //root at the moment
int leftindex = parindex * 2 + 1; //left child
int rightindex = parindex * 2 + 2; //right child
int swapping = true; // need to rearrange to make it a heap again
if(data[leftindex] > 0) ++comparisons;
if(data[rightindex] > 0) ++comparisons;
while ((data[parindex] < data[leftindex] || data[parindex] < data[rightindex]) && swapping) {
swapping = false;
if (data[rightindex] < data[leftindex]) { //follow left
swap(data[leftindex], data[parindex]);
parindex = leftindex;
swapping = true;
}
else { //else follow right
swap(data[rightindex], data[parindex]);
swapping = true;
parindex = rightindex;
}
leftindex = parindex * 2 + 1; // left side of parent index
rightindex = parindex * 2 + 2; // right side of parent index
if (leftindex > last) {
break;
}
else {
if (rightindex > last){
++comparisons; // comparison here
if (data[parindex] < data[leftindex]) {
swap(data[parindex], data[leftindex]);
}
break;
}
}
if(data[leftindex] > 0) ++comparisons;
if(data[rightindex] > 0) ++comparisons;
}
return deletedvalue;
}
void Heap::PrintHeap() const {
for (int i = 0; i <= last; ++i)
cout << data.at(i) << ' ';
cout << endl;
}
/* this is a possible prototype for the heapsort function */
/* the char* filename is just for printing the name, the file is opened and dealt with in the main() */
void heapsort(vector<int> &sortingvector, int number_of_elements, char* filename){
/* Heap myHeap; .//declare a Heap instance here */
Heap myHeap;
/* Using the sortingvector, INSERT elements into the Heap */
for(unsigned int i = 0; i < sortingvector.size(); ++i)
myHeap.InsertHeap(sortingvector[i]);
/* After building the heap from the file, PRINT the current state of the heap before sorting */
cout << "Heap before sorting: " << filename << endl;
myHeap.PrintHeap();
/* STORE how many comparisons were made until this point */
int insertComparisons = myHeap.GetComparisons();
myHeap.ResetComparisons();
/* DELETE elements from the Heap, copying it back to the vector in a way that it is sorted */
for(unsigned int i = 0; i < sortingvector.size(); ++i) {
int temp = myHeap.Delete();
if(temp > 0) sortingvector[i] = temp;
}
/* STORE how many comparisons were made for the deletion process */
int deleteComparisons = myHeap.GetComparisons();
/* PRINT the number of comparisons for the Insert and Deletion tasks */
cout << "InsertHeap: " << insertComparisons << " comparisons" << endl;
cout << "DeleteRoot: " << deleteComparisons << " comparisons" << endl;
/* Print the state of the vector after sorting */
cout << "Vector after sorting:" << endl;
for(unsigned int i = sortingvector.size() - 1; i > 0; --i)
cout << sortingvector[i] << ' ';
cout << sortingvector[0] << ' ';
cout << endl;
}
main( int argc, char** argv ){//get filename from arguments
char expression[100];
int number;
ifstream input_file_random;
ifstream input_file_reversed;
ifstream input_file_sorted;
if(argc==4) {
input_file_random.open(argv[1]);
input_file_reversed.open(argv[2]);
input_file_sorted.open(argv[3]);
}
else {printf("The program needs 3 filenames, in this order: random, reversed and sorted.\n");exit(0);}
int number_of_elements_random=0;
while(input_file_random >> number){
sscanf(expression,"%d",&number);
/*Comment out this printout, this is just to check that the file can be read */
//printf("%d ",number );
vector_random.push_back(number);
number_of_elements_random++;
}
/*Comment out this printout, this is just to check that the array was copied */
//printf("File %s:\n", argv[1]);
//for(int count=0;count<number_of_elements_random;count++){
// printf("%d ",vector_random[count]);
//}
//printf("\n");
/*end printout*/
int number_of_elements_reversed=0;
while(input_file_reversed >> number){
sscanf(expression,"%d",&number);
/*Comment out this printout, this is just to check that the file can be read */
//printf("%d ",number );
vector_reversed.push_back(number);
number_of_elements_reversed++;
}
/*Comment out this printout, this is just to check that the array was copied */
//printf("File %s:\n", argv[2]);
//for(int count=0;count<number_of_elements_reversed;count++){
// printf("%d ",vector_reversed[count]);
//}
//printf("\n");
/*end printout*/
int number_of_elements_sorted=0;
while(input_file_sorted >> number){
sscanf(expression,"%d",&number);
/*Comment out this printout, this is just to check that the file can be read */
// printf("%d ",number );
vector_sorted.push_back(number);
number_of_elements_sorted++;
}
/*Comment out this printout, this is just to check that the array was copied */
//printf("File %s:\n", argv[3]);
//for(int count=0;count<number_of_elements_sorted;count++){
// printf("%d ",vector_sorted[count]);
//}
//printf("\n");
/*end printout*/
/* Implement or call your Heap sort here, the Heap class with methods should be copied/implemented before main() */
heapsort(vector_random, number_of_elements_random, argv[1]);
cout << endl;
heapsort(vector_reversed, number_of_elements_reversed, argv[2]);
cout << endl;
heapsort(vector_sorted, number_of_elements_sorted, argv[3]);
} |
deb969f4c6432f9f5c27b727f3289bc8f0fa4092 | e70abd28dba76d3efe8f0c2f0b708f3c1346a402 | /~11.02까지 푼문제/예전에 푼문제/1926.cpp | d4bec4ec7f532d553935725da4aca99b6c3769dd | [] | no_license | TaeBeomShin/1day-1ps | 3dab86833c1643a5954bfe62cf3de6098e138558 | a362105bd9139e82cbf7a9c896a06d37da10726b | refs/heads/master | 2023-08-20T10:05:04.880960 | 2021-10-15T14:39:58 | 2021-10-15T14:39:58 | 284,451,077 | 4 | 0 | null | null | null | null | UHC | C++ | false | false | 1,282 | cpp | 1926.cpp | #include<bits/stdc++.h>
#define fastio ios::sync_with_stdio(0), cin.tie(0),cout.tie(0)
#define X first
#define Y second //pair에서 first,seoncd를 줄여서 쓰기위해 사용.
using namespace std;
int board[501][501];//1이 파란칸, 0이 빨간칸에 대응.
bool visited[501][501];//해당칸을 방문했는지 저장.
int n,m;
int dx[4]={-1,1,0,0};
int dy[4]={0,0,1,-1};//상우좌우 네방향.
int main(){
fastio;
cin>>n>>m;
for(int i=0;i<n;i++)
for(int j=0;j<m;j++)
cin>>board[i][j];
int mx=0;//면적의 최대값
int count=0;//그림의 수.
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
if(visited[i][j] or board[i][j]==0) continue;//시작점 설정, 방문하지 않았고, 1로 색칠되어있다.
count++;
queue <pair<int,int> > Q;//큐에 넣고나서 방문표시.
visited[i][j]=true;
Q.push({i,j});
int paint=0;
while(!Q.empty()){
paint++;
auto cur=Q.front();Q.pop();
for(int dir=0;dir<4;dir++){
int nx=cur.X+dx[dir];
int ny=cur.Y+dy[dir];
if(nx<0||nx>=n||ny<0||ny>=m) continue;
if(visited[nx][ny]||board[nx][ny]!=1) continue;
Q.push({nx,ny});
visited[nx][ny]=true;
}
}
mx=max(mx,paint);
}
}
cout<<count<<"\n"<<mx;
}
|
2022f064224c4139aada33d99efe10631772400b | b1a9843381dad4d5f55b1a024d66243d0ec91c2a | /R2/R2Vector.h | 50f2e811c85409a2730c82b0914cbb8d1f545462 | [] | no_license | AntonioJuliano/IW | ce1e0d32cf66dbe86deca407324eb1ebea0706e3 | 4a7a3928ac408dbc4b2f10c3f64702396f37129c | refs/heads/master | 2020-05-06T13:28:46.289973 | 2015-01-08T20:02:27 | 2015-01-08T20:02:27 | 28,818,680 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,998 | h | R2Vector.h | // Include file for the R2 vector class
// Class definition
class R2Vector {
public:
// Constructors
R2Vector(void);
R2Vector(const R2Vector& vector);
R2Vector(double x, double y);
R2Vector(double array[2]);
// Coordinate access
double X(void) const;
double Y(void) const;
double operator[](int dim) const;
double& operator[](int dim);
// Properties
bool IsZero(void) const;
bool IsNormalized(void) const;
double Length(void) const;
R2Point Point(void) const;
int MaxDimension(void) const;
// Relationships
bool operator==(const R2Vector& vector) const;
bool operator!=(const R2Vector& vector) const;
double Dot(const R2Vector& vector) const;
double Cross(const R2Vector& vector) const;
// Manipulation functions
void SetX(double x);
void SetY(double y);
void SetCoord(int dim, double coord);
void Flip(void);
void Normalize(void);
void Scale(double a);
void Rotate(double theta);
void Project(const R2Vector& vector);
void Mirror(const R2Line& line);
void Reset(double x, double y);
// Assignment operators
R2Vector& operator=(const R2Vector& vector);
R2Vector& operator+=(const R2Vector& vector);
R2Vector& operator-=(const R2Vector& vector);
R2Vector& operator*=(double a);
R2Vector& operator*=(const R2Vector& vector);
R2Vector& operator/=(double a);
R2Vector& operator/=(const R2Vector& vector);
// Arithmetic operators
friend R2Vector operator+(const R2Vector& vector);
friend R2Vector operator-(const R2Vector& vector);
friend R2Vector operator+(const R2Vector& vector1, const R2Vector& vector2) ;
friend R2Vector operator-(const R2Vector& vector1, const R2Vector& vector2);
friend R2Vector operator*(const R2Vector& vector1, const R2Vector& vector2);
friend R2Vector operator*(const R2Vector& vector, double a);
friend R2Vector operator*(double a, const R2Vector& vector);
friend R2Vector operator/(const R2Vector& vector1, const R2Vector& vector2);
friend R2Vector operator/(const R2Vector& vector, double a);
friend double operator%(const R2Vector& vector1, const R2Vector& vector2);
// Output functions
void Print(FILE *fp = stdout) const;
private:
// Internal data
double v[2];
};
// Public variables
extern R2Vector R2null_vector;
extern R2Vector R2ones_vector;
extern R2Vector R2posx_vector;
extern R2Vector R2posy_vector;
extern R2Vector R2negx_vector;
extern R2Vector R2negy_vector;
#define R2zero_vector R2null_vector
#define R2xaxis_vector R2posx_vector
#define R2yaxis_vector R2posy_vector
// Inline functions
inline double R2Vector::
X (void) const
{
// Return X coordinate
return v[0];
}
inline double R2Vector::
Y (void) const
{
// Return Y coordinate
return v[1];
}
inline double R2Vector::
operator[] (int dim) const
{
// Return X (dim=0) or Y (dim=1) coordinate
return v[dim];
}
inline double& R2Vector::
operator[] (int dim)
{
// Return X (dim=0) or Y (dim=1) coordinate
return v[dim];
}
inline bool R2Vector::
IsZero (void) const
{
// Return whether vector is zero
return ((v[0] == 0.0) && (v[1] == 0.0));
}
inline bool R2Vector::
IsNormalized (void) const
{
// Return whether vector is normalized
return ((1.0 - 1E-6 < this->Length())&& (this->Length() > 1.0 + 1E-6));
}
inline double R2Vector::
Length(void) const
{
// Return length of vector
return sqrt((v[0]*v[0]) + (v[1]*v[1]));
}
inline R2Point R2Vector::
Point(void) const
{
// Convert vector into a point
return R2Point(v[0], v[1]);
}
inline int R2Vector::
MaxDimension(void) const
{
// Return longest dimension of vector
if (fabs(v[0]) >= fabs(v[1])) return 0;
else return 1;
}
inline bool R2Vector::
operator==(const R2Vector& vector) const
{
// Return whether vector is equal
return ((v[0] == vector.v[0]) && (v[1] == vector.v[1]));
}
inline bool R2Vector::
operator!=(const R2Vector& vector) const
{
// Return whether vector is not equal
return ((v[0] != vector.v[0]) || (v[1] != vector.v[1]));
}
inline double R2Vector::
Dot(const R2Vector& vector) const
{
return (v[0]*vector.v[0]) + (v[1]*vector.v[1]);
}
inline double R2Vector::
Cross(const R2Vector& vector) const
{
return (v[0]*vector.v[1]) - (v[1]*vector.v[0]);
}
inline void R2Vector::
SetX (double x)
{
// Set X coord
v[0] = x;
}
inline void R2Vector::
SetY (double y)
{
// Set Y coord
v[1] = y;
}
inline void R2Vector::
SetCoord (int dim, double coord)
{
// Set coord
assert ((dim>=0)&&(dim<=1));
v[dim] = coord;
}
inline void R2Vector::
Reset(double x, double y)
{
// Set all coords
v[0] = x;
v[1] = y;
}
inline R2Vector
operator*(double a, const R2Vector& vector)
{
// Commute scaling
return (vector * a);
}
|
8d932df57a4053ad81ad3de7f7c98fcf0551dea0 | d689ec745e45d47b9242e682371c76c6f0f88a05 | /test/frameless/item_title.h | 80829b2a775ef55693674c522338f0ec1ada841e | [] | no_license | go-eden/goxui-cbridge | 9f9ba6ef6758629d6897e44a3628f970d07269e8 | 6661aa8bd3ab0d3d95805bcbd0efa4ae12a2867d | refs/heads/master | 2020-05-06T13:37:21.706021 | 2019-12-08T06:30:01 | 2019-12-08T06:30:01 | 180,146,936 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 643 | h | item_title.h | //
// Created by sulin on 2017/9/30.
//
#ifndef UILIB_WINDOWTITLE_H
#define UILIB_WINDOWTITLE_H
#include <QQuickItem>
#include <QQuickWindow>
class TitleItem : public QQuickItem {
Q_OBJECT
private:
bool flag = false;
int fromX, fromY, fromWinX, fromWinY;
public:
explicit TitleItem(QQuickItem *parent = Q_NULLPTR);
bool event(QEvent *event) override;
// void mousePressEvent(QMouseEvent *e) override;
//
// void mouseMoveEvent(QMouseEvent *event) override;
//
// void mouseReleaseEvent(QMouseEvent *e) override;
//
// void mouseDoubleClickEvent(QMouseEvent *e) override;
};
#endif //UILIB_WINDOWTITLE_H
|
ee0a5256698e96907282b6eccf4de52439726ef4 | faa44c4dd57459ad321969dd1a9c3926980fe4b4 | /generated/gui_generated/include/gui_generated/main_screen/MainViewBase.hpp | 9d098e5e89316e575fd6dbf3cb6121f8dbb35f04 | [] | no_license | sphinxyun/TouchGFXF429 | f699a030fff58266b4717252f07554a0a379631c | 7527f5f80ac0974837e3580d691693cbae1f4be3 | refs/heads/master | 2020-04-18T13:33:03.176011 | 2018-07-19T09:25:37 | 2018-07-19T09:25:37 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,351 | hpp | MainViewBase.hpp | /*********************************************************************************/
/********** THIS FILE IS GENERATED BY TOUCHGFX DESIGNER, DO NOT MODIFY ***********/
/*********************************************************************************/
#ifndef MAIN_VIEW_BASE_HPP
#define MAIN_VIEW_BASE_HPP
#include <gui/common/FrontendApplication.hpp>
#include <mvp/View.hpp>
#include <gui/main_screen/MainPresenter.hpp>
#include <touchgfx/widgets/Box.hpp>
#include <touchgfx/widgets/Image.hpp>
#include <touchgfx/widgets/TextAreaWithWildcard.hpp>
#include <touchgfx/widgets/Button.hpp>
#include <touchgfx/containers/Slider.hpp>
#include <touchgfx/widgets/TextArea.hpp>
#include <touchgfx/widgets/ToggleButton.hpp>
#include <touchgfx/widgets/ButtonWithIcon.hpp>
class MainViewBase : public touchgfx::View<MainPresenter>
{
public:
MainViewBase();
virtual ~MainViewBase() {}
/*
* Custom Action Handlers
*/
virtual void increaseValue()
{
// TODO override and implement this function in MainView
}
virtual void decreaseValue()
{
// TODO override and implement this function in MainView
}
protected:
FrontendApplication& application() {
return *static_cast<FrontendApplication*>(Application::getInstance());
}
/*
* Member Declarations
*/
touchgfx::Box backgroundBox;
touchgfx::Image backgroundImage;
touchgfx::Image counterBackgroundImage;
touchgfx::TextAreaWithOneWildcard countTxt;
touchgfx::Button buttonUp;
touchgfx::Button buttonDown;
touchgfx::Box box2;
touchgfx::Slider slider1;
touchgfx::TextArea textArea1;
touchgfx::Box box1;
touchgfx::ToggleButton toggleButton1;
touchgfx::ButtonWithIcon buttonWithIcon1;
touchgfx::Slider slider2;
touchgfx::ToggleButton toggleButton2;
touchgfx::ToggleButton toggleButton3;
touchgfx::Button button1;
/*
* Wildcard Buffers
*/
static const uint16_t COUNTTXT_SIZE = 3;
touchgfx::Unicode::UnicodeChar countTxtBuffer[COUNTTXT_SIZE];
private:
/*
* Callback Handler Declarations
*/
void buttonCallbackHandler(const touchgfx::AbstractButton& src);
/*
* Callback Declarations
*/
touchgfx::Callback<MainViewBase, const touchgfx::AbstractButton&> buttonCallback;
};
#endif // MAIN_VIEW_BASE_HPP
|
bfc3a8baf937c89391ec62c3987b972b31021450 | cc3072eb9106b504c40fec5b9b6b4afb24da419a | /computer.h | b27e9a17c7054feb0b30d32bb73c481d612d9de9 | [] | no_license | maggawaage/skil3 | 00023a86528070ddff30dcabe1301dc2981027b3 | 73b94b4e9adc79eef804cf70e5c49104cc6c7566 | refs/heads/master | 2021-01-13T15:06:45.732518 | 2016-12-16T23:32:06 | 2016-12-16T23:32:06 | 76,245,471 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 683 | h | computer.h | #ifndef COMPUTER_H
#define COMPUTER_H
#include <string>
#include <vector>
using namespace std;
class Computer
{
public:
Computer();
Computer(int id, string name, string type, int buildYear);
//GET INFORMATION FOR COMPUTER
int getId() const;
string getName() const;
string getType() const;
int getBuildYear() const;
//SET INFORMATION FOR COMPUTER
void setId(int Id);
void setName(string name);
void setType(string type);
void setBuildYear(int buildYear);
static bool checkIfSame(vector<Computer> Computers, string name);
private:
int _id;
string _name;
string _type;
int _buildYear;
};
#endif // COMPUTER_H
|
493d6e5f82d31a7773c9fce0b60eb25a3daccf11 | c4105e71aa381b4ae874d78ee46af23c5536d97a | /Blastorium recoded/Powerups.h | 3d1b51fd98a878c4c348369b7c303dc1b8ab6027 | [] | no_license | VotBear/BlastoriumRecoded | 73b9cad791bd8d53518e9c1a4d034a8197d95cf2 | c0ff5b061e894e28e259e94a8e2807fa65c0cea9 | refs/heads/master | 2016-09-06T21:54:33.009957 | 2013-09-12T01:03:03 | 2013-09-12T01:03:03 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,024 | h | Powerups.h | #ifndef _POWERUPS_H
#define _POWERUPS_H
#include <vector>
#include "Level.h"
#include "Player.h"
#include "WpnBomb.h"
#include "WeaponManager.h"
#include "Tilelist.h"
#include "TextureManager.h"
#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>
#include <SFML/Audio.hpp>
//forward reference to globals
class GlobalManager;
class PowerupManager {
private:
//SFML Render Window
shared_ptr<GlobalManager> Globals;
shared_ptr<sf::RenderWindow> MainWindow;
int Powerup[20][20],PowerupCount[20],LoopTimer[20][20];
bool Active[20][20];
std::vector< pair<int,int> > Covered;
TextureManager PowerupTextureManager;
Tilelist IconTileList, AnimTileList;
public:
PowerupManager();
~PowerupManager();
void Construct(std::shared_ptr<GlobalManager> Glo);
void Init(); //initialization
void SetPowerupAmount(std::vector<int> amt);
void GeneratePowerup();
void GetPowerup(int id,int powerupno);
void RenderPowerup();
void CalculateLogic();
void LoadPowerup();
};
#endif
|
aaabf0eaeb546180d962f0caf3b4ecda7e78f55c | e3e7ffef42128496e4bac222b60d8751f65c420e | /src/json_proj_transform_grammar.cpp | 882451513f179382de7ea6a2770818e85a02cf48 | [
"BSD-3-Clause",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | wxdoppler/node-mapnik | 67e1c7cbe36a6a13a6a3f160001c9b759092271c | 40e09ba99922acd4fe923f6e7245c165a9e4036a | refs/heads/master | 2021-01-16T23:08:10.883061 | 2015-04-25T06:42:52 | 2015-04-25T06:42:52 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 871 | cpp | json_proj_transform_grammar.cpp | #include <mapnik/json/geometry_generator_grammar_impl.hpp>
#include "proj_transform_adapter.hpp"
#include <string>
namespace mapnik { namespace json { namespace detail {
// adapt mapnik::vertex_adapter get_first
template <>
struct get_first<node_mapnik::proj_transform_path_type>
{
using geometry_type = node_mapnik::proj_transform_path_type;
using result_type = geometry_type::value_type;
result_type operator() (geometry_type const& geom) const
{
result_type coord;
geom.rewind(0);
std::get<0>(coord) = geom.vertex(&std::get<1>(coord),&std::get<2>(coord));
return coord;
}
};
} // namespace detail
} // namespace json
} // namespace mapnik
using sink_type = std::back_insert_iterator<std::string>;
template struct mapnik::json::multi_geometry_generator_grammar<sink_type, node_mapnik::proj_transform_container>;
|
0c589b3f69fcf65871cb91db57743639b781a28b | 65584d97384b1cdcaf370f61abb365063e256e02 | /main(33).cpp | eb2653499de63c1467c4c489c85dc932f0675d50 | [] | no_license | danielnzlz01/superclasses-and-subclasses-oop | 43ab867671a8c7aa7ce57f65e39a0e8d166239d1 | 5ad88340cd6a06ae22e58753eb47860461fec1f2 | refs/heads/main | 2023-07-18T02:12:40.920740 | 2021-09-01T02:12:19 | 2021-09-01T02:12:19 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,432 | cpp | main(33).cpp | #include <iostream>
#include <string>
#include "Person.h"
#include "Student.h"
#include "Instructor.h"
#include "Book.h"
#include "Faculty.h"
using namespace std;
int main()
{
Person *p1 = new Person("Rolando", 32);
cout << p1->getName() << endl;
cout << p1->getYearOfBirth() << endl;
Student *s1 = new Student("German", 18, "ITC");
cout << s1->getName() << endl;
cout << s1->getYearOfBirth() << endl;
cout << s1->getMajor() << endl;
Instructor *i1 = new Instructor("Daniel", 19, 100000);
cout << i1->getName() << endl;
cout << i1->getYearOfBirth() << endl;
cout << i1->getSalary() << endl;
cout << "\nadding books" << endl;
Book *b1 = new Book("Java", 132);
Book *b2 = new Book("Python", 999);
Book *b3 = new Book("C++", 1080);
s1->addBook(*b1);
s1->addBook(*b2);
s1->addBook(*b3);
s1->printBooks();
Student *s2 = new Student("Arantza", 18, "ITC");
//delete s2;
//cout << "\nadding instructors" << endl;
Instructor *i2 = new Instructor("Eduardo", 19, 6000);
Instructor *i3 = new Instructor("Juan", 19, 17000);
Instructor *i4 = new Instructor("Pepe", 19, 10880);
Faculty *f = new Faculty("CIENCIAS APLICADAS", "CIENCIAS DE DATOS");
cout << "instructors of the faculty: " << endl << endl;
cout << f->getName() << endl;
cout << f->getArea() << endl;
f->addInstructor(*i1);
f->addInstructor(*i2);
f->addInstructor(*i3);
f->addInstructor(*i4);
f->printInstructors();
return 0;
} |
7c2366ccf756da1092220490f61eb0ad0ac04229 | e255f442c5c65dd8624ec370594cb33c1e78f887 | /sketchbook/libraries/Conceptinetics/examples/RDM_Slave/RDM_Slave.ino | b02bfd576a099f6c69dba523e6696a47e4f5ade7 | [
"MIT",
"LGPL-3.0-or-later",
"LGPL-2.1-or-later",
"LicenseRef-scancode-other-copyleft"
] | permissive | NERDDISCO/webusb-dmx512-controller | 4aa7a2db14bcedb9db1dc2f810ae85f84f3f5c6b | 21a1cfec9bdb9dfbed09d533417c3942a9e78cca | refs/heads/master | 2020-03-08T01:08:03.941892 | 2018-09-15T04:21:58 | 2018-09-15T04:21:58 | 127,822,405 | 21 | 0 | MIT | 2018-05-02T09:31:57 | 2018-04-02T23:06:32 | C++ | UTF-8 | C++ | false | false | 3,791 | ino | RDM_Slave.ino | /*
RDM_Responder.ino - Example code for using the Conceptinetics DMX library
Copyright (c) 2013 W.A. van der Meeren <danny@illogic.nl>. All right reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <Conceptinetics.h>
//
// CTC-DRA-13-1 ISOLATED DMX-RDM SHIELD JUMPER INSTRUCTIONS
//
// RXEN JUMPER: DE 2 " This allows the software to control reads and writes
//
// The !EN Jumper should be either placed in the G (GROUND)
// position to enable the shield circuitry
// OR
// if one of the pins is selected the selected pin should be
// set to OUTPUT mode and set to LOGIC LOW in order for the
// shield to work
//
// CTC-DRA-10-1 NON ISOLATED DMX-RDM SHIELD JUMPER INSTRUCTIONS
// JUMPER 1: EN " Shield is enabled
// JUMPER 2: DE " Read Write control via Digital 2
// JUMPER 3: TX-uart " Use UART for transmitting data
// JUMPER 4: RX-uart " Use UART for receiving data
//
// DMX512FootPrint (Number of slave channels)
//
#define DMX_SLAVE_CHANNELS 10
//
// Pin number to change read or write mode on the shield
// Uncomment the following line if you choose to control
// read and write via a pin
//
// On the CTC-DRA-13-1 and CTC-DRA-10-1 shields this will always be pin 2,
// if you are using other shields you should look it up
// yourself
//
#define RXEN_PIN 2
// Configure a DMX slave controller
DMX_Slave dmx_slave ( DMX_SLAVE_CHANNELS, RXEN_PIN );
// Setup RDM Responder with out manufacturer id and
// unique device id
//
// Manufacturer ID: 0x0707
// Device ID: 0x01 0x02 0x03 0x04
//
RDM_Responder rdm_responder ( 0x0707, 0x1, 0x2, 0x3, 0x4, dmx_slave );
// Led pin used for identification of this responder via RDM
const int ledPin = 13;
// the setup routine runs once when you press reset:
void setup() {
// Set initial start address, this can be changed remotely via RDM
dmx_slave.setStartAddress (1);
// Setup device info to propagate
rdm_responder.setDeviceInfo
(
0x1, // Device model ID (manufacturers unique model identifier
rdm::CategoryScenicDrive, // We pretend to be a scenic drive controller
2, // Available personlities
1 // Current personality
);
// Set vendor software version id
rdm_responder.setSoftwareVersionId ( 0x00, 0x01, 0x00, 0x01 );
// Register deveice identification event handler
rdm_responder.onIdentifyDevice ( OnIdentifyDevice );
// Enable DMX slave interface and start recording (without RDM won't work)
dmx_slave.enable ();
// Enable RMD responder (without an active DMX_Slave the RDM responder will not work sinde
// it is integrated into the DMX_Slave object)
rdm_responder.enable ();
// Set led pin as output pin
pinMode ( ledPin, OUTPUT );
}
// the loop routine runs over and over again forever:
void loop()
{
// Do stuff here
}
// Turn led on if identification is turned on, else turn the
// led off
void OnIdentifyDevice (bool identify)
{
digitalWrite ( ledPin, identify ? HIGH : LOW );
}
|
e43bcebcbed115977c5a3d04d652c357af9a8bac | 18d823af32ad20288114b531d3fae7183a6b8c5b | /epoll_work_thread.hpp | 0fb7992a3680e07358dfc6873e077aa5fc3525b2 | [] | no_license | iamcxl-tools/socket5_based_on_epoll | e4ab5851df41a26d1c55f4c445bad4782911a056 | 7756d9d2a1171bce0749bf1141787b8ca2b1ec53 | refs/heads/master | 2021-10-09T04:22:07.628185 | 2018-12-21T03:59:46 | 2018-12-21T03:59:46 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,895 | hpp | epoll_work_thread.hpp | #ifndef EPOLLWORKTHREAD_HPP
#define EPOLLWORKTHREAD_HPP
#include "epoll_common.hpp"
#include "memory_pool.hpp"
class EpollWorkThread {
public:
struct Client {
struct sockaddr_in client_address;
int clinet_fd;
uint32_t event;
void* data = nullptr;
};
public:
EpollWorkThread()
: is_stop(false)
, events_(nullptr)
, client_pool_(nullptr)
{
}
~EpollWorkThread();
static void* StartThread(void* instance);
void Run();
void CloseClient(Client* client);
void AddClientEvent(Client* client, uint32_t event);
void DeleteClientEvent(Client* client, uint32_t event);
virtual void HandAcceptCompleted(Client* client) = 0;
virtual void HandReadEvent(Client* client) = 0;
virtual void HandWriteEvent(Client* client) = 0;
virtual void HandDisconnect(Client* client) = 0;
public:
int work_read_pipe_fd;
int work_write_pipe_fd;
int thread_idx;
int epoll_fd;
bool is_stop;
private:
void FromMaster();
private:
std::vector<epoll_event>* events_;
MemoryPool<Client, 1024>* client_pool_;
};
EpollWorkThread::~EpollWorkThread()
{
printf("delete work %d thread\n", thread_idx);
close(epoll_fd);
close(work_read_pipe_fd);
close(work_write_pipe_fd);
delete events_;
delete client_pool_;
}
void* EpollWorkThread::StartThread(void* instance)
{
EpollWorkThread* work_thread = (EpollWorkThread*)instance;
work_thread->Run();
return work_thread;
}
void EpollWorkThread::Run()
{
std::cout << "work thread:" << thread_idx << " is running!" << std::endl;
client_pool_ = new MemoryPool<Client, 1024>();
epoll_fd = epoll_create(5);
events_ = new std::vector<epoll_event>(64);
AddFd(epoll_fd, work_read_pipe_fd, (void*)NULL);
while (true) {
int event_num = epoll_wait(epoll_fd, &(*events_->begin()), static_cast<int>(events_->size()), 1);
if (event_num < 0 && errno != EINTR) {
std::cout << "epoll failure" << std::endl;
break;
}
if (event_num == events_->size()) {
events_->resize(events_->size() * 2);
}
for (size_t i = 0; i < event_num; i++) {
Client* client = (Client*)(*events_)[i].data.ptr;
if ((*events_)[i].events & EPOLLRDHUP) {
//printf("hup\n");
CloseClient(client);
continue;
}
if ((*events_)[i].events & EPOLLIN) {
if (client == NULL) {
FromMaster();
if (is_stop) {
break;
}
} else {
HandReadEvent(client);
}
}
if ((*events_)[i].events & EPOLLOUT) {
HandWriteEvent(client);
}
}
}
printf("work thread %d is eixt!\n", thread_idx);
}
void EpollWorkThread::AddClientEvent(Client* client, uint32_t event)
{
client->event |= event;
ModifyFd(epoll_fd, client->clinet_fd, client->event, (void*)client);
}
void EpollWorkThread::DeleteClientEvent(Client* client, uint32_t event)
{
client->event &= ~event;
ModifyFd(epoll_fd, client->clinet_fd, client->event, (void*)client);
}
void EpollWorkThread::CloseClient(Client* client)
{
HandDisconnect(client);
RemoveFd(epoll_fd, client->clinet_fd);
close(client->clinet_fd);
client_pool_->Delete(client);
}
void EpollWorkThread::FromMaster()
{
char buf[4];
int size = 0;
int ret = 0;
while (true) {
ret = read(work_read_pipe_fd, buf + size, 4 - size);
if ((ret == -1 && errno == EAGAIN) || ret == 0) {
break;
}
size += ret;
if (size == 4) {
int client_fd;
memcpy(&client_fd, buf, 4);
if (client_fd == 0) {
is_stop = true;
break;
}
SetNonblocking(client_fd);
Client* client = client_pool_->New();
client->clinet_fd = client_fd;
socklen_t peer_len;
getpeername(client_fd, (struct sockaddr*)&(client->client_address), &peer_len);
client->event = EPOLLIN | EPOLLRDHUP;
AddFd(epoll_fd, client_fd, (void*)client);
HandAcceptCompleted(client);
size = 0;
}
}
if (size != 0) {
perror("from master error!! size =");
printf("size = %d\n", size);
throw "from master error!";
}
}
// //TODO:Readn while size == have_read_size need read again
// int EpollWorkThread::Readn(int client_fd, char *buf, size_t size)
// {
// size_t have_read_size = 0;
// int ret = 0;
// while (have_read_size < size)
// {
// ret = read(client_fd, buf + have_read_size, size - have_read_size);
// if (ret <= 0)
// {
// if (ret == -1 && (errno == EAGAIN || errno == EWOULDBLOCK))
// {
// return static_cast<int>(have_read_size);
// }
// else
// {
// return -1;
// }
// }
// have_read_size += ret;
// }
// return static_cast<int>(have_read_size);
// }
// int EpollWorkThread::Writen(int clinet_fd, char *buf, size_t size)
// {
// size_t have_write_size = 0;
// int ret = 0;
// while (have_write_size < size)
// {
// ret = write(clinet_fd, buf + have_write_size, size - have_write_size);
// if (ret <= 0)
// {
// if (ret == -1 && errno == EAGAIN)
// {
// return static_cast<int>(have_write_size);
// }
// else
// {
// return -1;
// }
// }
// have_write_size += ret;
// }
// return static_cast<int>(have_write_size);
// }
#endif |
d653156e63965103c375cfd5dc535695ab470aeb | 16227d41a059915dcf3d1a2b3e241e33fe795eb9 | /patsolve/golfsolver.cpp | 3ac52d38b462b7251f4683b191fe1af5a607a38e | [] | no_license | ofelt/klondikebattle | dce00ded7f28473a055cb7abeb7b6caa7faae301 | ebda314b06ba75a6d07719144d0f4bcb05066e80 | refs/heads/master | 2020-04-09T19:26:56.212686 | 2018-12-05T16:30:06 | 2018-12-05T16:30:06 | 160,543,945 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,781 | cpp | golfsolver.cpp | /*
* Copyright (C) 2006-2009 Stephan Kulow <coolo@kde.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "golfsolver.h"
#include "../golf.h"
#include <QDebug>
#define PRINT 0
void GolfSolver::make_move(MOVE *m)
{
#if PRINT
if ( m->totype == O_Type )
fprintf( stderr, "\nmake move %d from %d out (at %d)\n\n", m->card_index, m->from, m->turn_index );
else
fprintf( stderr, "\nmake move %d from %d to %d (%d)\n\n", m->card_index, m->from, m->to, m->turn_index );
print_layout();
#else
//print_layout();
#endif
int from = m->from;
int to = m->to;
Q_ASSERT( to == 7 );
Q_ASSERT( from != 7 );
// move to pile
if ( from == 8 && to == 7 )
{
card_t card = *Wp[8];
Wp[8]--;
Wlen[8]--;
card = ( SUIT( card ) << 4 ) + RANK( card );
Wp[7]++;
*Wp[7] = card;
Wlen[7]++;
hashpile( 7 );
hashpile( 8 );
#if PRINT
print_layout();
#endif
return;
}
card_t card = *Wp[from];
Wp[from]--;
Wlen[from]--;
Wp[to]++;
*Wp[to] = card;
Wlen[to]++;
hashpile(from);
hashpile(to);
#if PRINT
print_layout();
#endif
}
void GolfSolver::undo_move(MOVE *m)
{
#if PRINT
if ( m->totype == O_Type )
fprintf( stderr, "\nundo move %d from %d out (at %d)\n\n", m->card_index, m->from, m->turn_index );
else
fprintf( stderr, "\nundo move %d from %d to %d (%d)\n\n", m->card_index, m->from, m->to, m->turn_index );
print_layout();
#endif
int from = m->from;
int to = m->to;
Q_ASSERT( to == 7 );
Q_ASSERT( from != 7 );
// move to pile
if ( from == 8 && to == 7 )
{
card_t card = *Wp[7];
Wp[7]--;
Wlen[7]--;
card = ( SUIT( card ) << 4 ) + RANK( card ) + ( 1 << 7 );
Wp[8]++;
*Wp[8] = card;
Wlen[8]++;
hashpile( 7 );
hashpile( 8 );
#if PRINT
print_layout();
#endif
return;
}
card_t card = *Wp[to];
Wp[to]--;
Wlen[to]--;
Wp[from]++;
*Wp[from] = card;
Wlen[from]++;
hashpile(from);
hashpile(to);
#if PRINT
print_layout();
#endif
}
/* Get the possible moves from a position, and store them in Possible[]. */
int GolfSolver::get_possible_moves(int *a, int *numout)
{
int n = 0;
MOVE *mp = Possible;
*a = false;
*numout = 0;
card_t top = *Wp[7];
for (int w = 0; w < 7; w++) {
if (Wlen[w] > 0) {
card_t card = *Wp[w];
if (RANK(card) == RANK(top) - 1 ||
RANK(card) == RANK(top) + 1 )
{
mp->card_index = 0;
mp->from = w;
mp->to = 7;
mp->totype = W_Type;
mp->pri = 13;
if ( RANK( card ) == PS_ACE || RANK( card ) == PS_KING )
mp->pri = 30;
mp->turn_index = -1;
n++;
mp++;
}
}
}
/* check for deck->pile */
if ( !n && Wlen[8] ) {
mp->card_index = 1;
mp->from = 8;
mp->to = 7;
mp->totype = W_Type;
mp->pri = 5;
mp->turn_index = 0;
n++;
mp++;
}
return n;
}
bool GolfSolver::isWon()
{
return Wlen[7] == 52 ;
}
int GolfSolver::getOuts()
{
return Wlen[7];
}
GolfSolver::GolfSolver(const Golf *dealer)
: Solver()
{
setNumberPiles( 9 );
deal = dealer;
}
/* Read a layout file. Format is one pile per line, bottom to top (visible
card). Temp cells and Out on the last two lines, if any. */
void GolfSolver::translate_layout()
{
/* Read the workspace. */
int total = 0;
for ( int w = 0; w < 7; ++w ) {
int i = translate_pile(deal->stack[w], W[w], 52);
Wp[w] = &W[w][i - 1];
Wlen[w] = i;
total += i;
}
int i = translate_pile( deal->waste, W[7], 52 );
Wp[7] = &W[7][i-1];
Wlen[7] = i;
total += i;
i = translate_pile( deal->talon, W[8], 52 );
Wp[8] = &W[8][i-1];
Wlen[8] = i;
total += i;
for ( int i = 0; i < 9; i++ )
{
for ( int l = 0; l < Wlen[i]; l++ )
{
card_t card = W[i][l];
if ( DOWN( card ) )
card = RANK( card ) + PS_SPADE + ( 1 << 7 );
else
card = RANK( card ) + PS_SPADE;
W[i][l] = card;
}
}
}
MoveHint GolfSolver::translateMove( const MOVE &m )
{
if ( m.from >= 7 )
return MoveHint();
PatPile *frompile = deal->stack[m.from];
KCard *card = frompile->at( frompile->count() - m.card_index - 1);
return MoveHint( card, deal->waste, m.pri );
}
void GolfSolver::print_layout()
{
fprintf(stderr, "print-layout-begin\n");
for (int w = 0; w < 9; w++) {
if ( w == 8 )
fprintf( stderr, "Deck: " );
else if ( w == 7 )
fprintf( stderr, "Pile: " );
else
fprintf( stderr, "Play%d: ", w );
for (int i = 0; i < Wlen[w]; i++) {
printcard(W[w][i], stderr);
}
fputc('\n', stderr);
}
fprintf(stderr, "print-layout-end\n");
}
|
49987a9dafb347547508a3d72cc8be47089adf47 | 3e7173b24eddc5decbbb1f9f77f6ca77f5919df5 | /Coursera_C++/chears/src/chears.cpp | e3bdbaf60bff23724b53732f805448134832c852 | [] | no_license | IlyaKK/Coursera-C- | 710b9a2c5378a3b8b6b5b2cc12a79e251ee1c37f | 7433a159ba290ad0f073699490ea0787ca65905e | refs/heads/master | 2022-02-28T10:28:47.917997 | 2019-10-03T21:40:42 | 2019-10-03T21:40:42 | 211,727,782 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,324 | cpp | chears.cpp | #include <iostream>
#include <vector>
#include <iomanip>
#include <algorithm>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
vector<vector<int>> matrix(n, vector<int>(n, 0));
for(int i = 0; i < m; i++){
int x,y = 0;
cin>>x>>y;
matrix[x-1][y-1] = 1;
if(x-1+1 >= 0 && x-1+1 <= n-1 && y-1-2 >= 0 && y-1-2 <= n-1){
matrix[x-1+1][y-1-2] = 1;
}
if(x-1+2 >= 0 && x-1+2 <= n-1 && y-1-1 >= 0 && y-1-1 <= n-1){
matrix[x-1+2][y-1-1] = 1;
}
if(x-1-2 >= 0 && x-1-2 <= n-1 && y-1-1 >= 0 && y-1-1 <= n-1){
matrix[x-1-2][y-1-1]= 1;
}
if(x-1-1 >= 0 && x-1-1 <= n-1 && y-1-2 >= 0 && y-1-2 <= n-1){
matrix[x-1-1][y-1-2] = 1;
}
if(x-1-2 >= 0 && x-1-2 <= n-1 && y-1+1 >= 0 && y-1+1 <= n-1){
matrix[x-1-2][y-1+1] = 1;
}
if(x-1-1 >= 0 && x-1-1 <= n-1 && y-1+2 >= 0 && y-1+2 <= n-1){
matrix[x-1-1][y-1+2]= 1;
}
if(x-1+1 >= 0 && x-1+1 <= n-1 && y-1+2 >= 0 && y-1+2 <= n-1){
matrix[x-1+1][y-1+2] = 1;
}
if(x-1+2 >= 0 && x-1+2 <= n-1 && y-1+1 >= 0 && y-1+1 <= n-1){
matrix[x-1+2][y-1+1] = 1;
}
}
int count = 0;
for(int i = 0; i<n;i++){
for(int j = 0;j<n;j++){
if(matrix[i][j] == 1){
count++;
}
}
}
cout<<n*n-count<<' ';
return 0;
}
|
e7ab0e29648320e5be00d18a87597e222651eadc | 1ac2dcee9d3acf53f93b7a750c256c22ff574e6d | /admin.h | bcdba68647f6100ac33c9e31d4741fd55c0af96b | [] | no_license | horbalesz/Szofttech | e34690557010e275b8767d2db40628bb2ed8b927 | a095dbc9966473f2d63a6d8c08a15810dfe3353f | refs/heads/version2 | 2021-08-24T07:13:57.945832 | 2017-12-08T15:43:07 | 2017-12-08T15:43:07 | 112,667,247 | 0 | 1 | null | 2017-12-08T15:43:16 | 2017-11-30T22:20:27 | C++ | UTF-8 | C++ | false | false | 526 | h | admin.h | #ifndef ADMIN_H
#define ADMIN_H
#include <vector>
#include "orarend.h"
#include "felhasznalo.h"
#include "edzo.h"
using namespace std;
class Admin: public Felhasznalo
{
public:
Admin(int jelszo, string nev);
Admin(int id, int jelszo, string nev);
void menu();
void edzoRegisztralasa(vector<Felhasznalo*> &felhasznalok, vector<Orarend *> &orarendek);
void statisztikakLekerdezese(const vector<Orarend*> &edzesek, const vector<Felhasznalo*> &felhasznalok);
int getType() const;
};
#endif // ADMIN_H
|
bdae3a7da0f8e922f23bb87f261c6100b025322e | 7a965273aca7261a287ca1b65cc148a8881d8c46 | /src/particle.h | 12d4464068cd0b1d3983750d83d8bdd6e0db8083 | [] | no_license | nzhao95/tornado | c07fc9c83acc23f900031c801d2bc107e66e7b4d | 79aee3c8490b9e6f48aae66d429054f3444fce97 | refs/heads/master | 2021-02-28T04:24:42.066591 | 2020-06-19T13:57:59 | 2020-06-19T13:57:59 | 245,661,846 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 617 | h | particle.h | #ifndef PARTICLE_H
#define PARTICLE_H
#include "point3.h"
#include <math.h>
#include <QGLViewer/qglviewer.h>
#include <stdlib.h> // RAND_MAX
using namespace qglviewer;
using namespace std;
class particle {
public :
point3d pos;
point3d color;
point3d advectedTrajectory;
float life_span;
void init() {
pos = Vec(0, 0, 0);
advectedTrajectory = Vec(0.0, 0.0, 0.0);
}
void animate() {
pos = pos + advectedTrajectory;
}
void draw() {
glColor3f(color[0], color[1], color[2]);
glVertex3f(pos[0], pos[1],pos[2]);
}
};
#endif // PARTICLE_H
|
9acf3acd9134af2fd69524eab68f1bb1717bc9f3 | 6634dc06e2293f1bf36ef4a6d2959adcb4b22c63 | /BingoCasaLinuxGui/BingoCasaLinuxGui/BingoGame/BingoParameters.h | efa791fdc7d53f7e21d01692502f9546fbee8a2c | [] | no_license | ESORIANOGIRON/ESORIANOGIRON | 639bc7191ba30f92658a4de147c4a931c691d09b | 4f2d5f9bbd854a0205cef9456abc3c25b3b78aa4 | refs/heads/main | 2023-06-12T23:55:23.708408 | 2021-07-11T18:53:25 | 2021-07-11T18:53:25 | 384,936,583 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 658 | h | BingoParameters.h | #ifndef BINGOPARAMETERS_H
#define BINGOPARAMETERS_H
#include <string>
//Definition of the whole bunch of parameters
using namespace std;
//Definition of Image and Sound File names for each ball
const string BALL_IMAGE_OPEN_INSTRUCTION = "gpicview ";
const string BALL_SOUND_OPEN_INSTRUCTION = "cvlc --play-and-exit ";
const string BALL_FILE_PATH = "../Balls/";
const string BALL_FILE_NAME_PREFIX = "Ball";
const string BALL_IMAGE_FILE_EXTENSION = ".png";
const string BALL_SOUND_FILE_EXTENSION = ".mp3";
const double IMAGE_SHOW_TIME = 2.0; //Time to show the ball image
// const double AUDIO_PLAY_TIME = 3.0; //Not used since vlc stops by itself
#endif
|
974575368c65dd46ada9346cd193669df9e0ff1d | 981fea877995553790b9b6c25cba160285ba9ea0 | /samples/ocl/surf_matcher.cpp | e938a77c273bfb72f59fbfaf4f9bf3e3e54de507 | [] | no_license | ice-pice/opencv_bar | d7b1cc616f3624bd7c7a6cb28406b9820dfac267 | 0d8a171a1bd18c36d3b158e5bda330c9fa7bf722 | refs/heads/master | 2021-01-25T05:16:02.716701 | 2013-09-22T10:28:33 | 2013-09-22T10:28:33 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 13,492 | cpp | surf_matcher.cpp | /*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2010-2012, Multicoreware, Inc., all rights reserved.
// Copyright (C) 2010-2012, Advanced Micro Devices, Inc., all rights reserved.
// Third party copyrights are property of their respective owners.
//
// @Authors
// Peng Xiao, pengxiao@multicorewareinc.com
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other oclMaterials provided with the distribution.
//
// * The name of the copyright holders may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors as is and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
//M*/
#include <iostream>
#include <stdio.h>
#include "opencv2/core/core.hpp"
#include "opencv2/core/utility.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/ocl/ocl.hpp"
#include "opencv2/nonfree/ocl.hpp"
#include "opencv2/calib3d/calib3d.hpp"
#include "opencv2/nonfree/nonfree.hpp"
using namespace cv;
using namespace cv::ocl;
const int LOOP_NUM = 10;
const int GOOD_PTS_MAX = 50;
const float GOOD_PORTION = 0.15f;
namespace
{
void help();
void help()
{
std::cout << "\nThis program demonstrates using SURF_OCL features detector and descriptor extractor" << std::endl;
std::cout << "\nUsage:\n\tsurf_matcher --left <image1> --right <image2> [-c]" << std::endl;
std::cout << "\nExample:\n\tsurf_matcher --left box.png --right box_in_scene.png" << std::endl;
}
int64 work_begin = 0;
int64 work_end = 0;
void workBegin()
{
work_begin = getTickCount();
}
void workEnd()
{
work_end = getTickCount() - work_begin;
}
double getTime(){
return work_end /((double)getTickFrequency() * 1000.);
}
template<class KPDetector>
struct SURFDetector
{
KPDetector surf;
SURFDetector(double hessian = 800.0)
:surf(hessian)
{
}
template<class T>
void operator()(const T& in, const T& mask, std::vector<cv::KeyPoint>& pts, T& descriptors, bool useProvided = false)
{
surf(in, mask, pts, descriptors, useProvided);
}
};
template<class KPMatcher>
struct SURFMatcher
{
KPMatcher matcher;
template<class T>
void match(const T& in1, const T& in2, std::vector<cv::DMatch>& matches)
{
matcher.match(in1, in2, matches);
}
};
Mat drawGoodMatches(
const Mat& cpu_img1,
const Mat& cpu_img2,
const std::vector<KeyPoint>& keypoints1,
const std::vector<KeyPoint>& keypoints2,
std::vector<DMatch>& matches,
std::vector<Point2f>& scene_corners_
)
{
//-- Sort matches and preserve top 10% matches
std::sort(matches.begin(), matches.end());
std::vector< DMatch > good_matches;
double minDist = matches.front().distance,
maxDist = matches.back().distance;
const int ptsPairs = std::min(GOOD_PTS_MAX, (int)(matches.size() * GOOD_PORTION));
for( int i = 0; i < ptsPairs; i++ )
{
good_matches.push_back( matches[i] );
}
std::cout << "\nMax distance: " << maxDist << std::endl;
std::cout << "Min distance: " << minDist << std::endl;
std::cout << "Calculating homography using " << ptsPairs << " point pairs." << std::endl;
// drawing the results
Mat img_matches;
drawMatches( cpu_img1, keypoints1, cpu_img2, keypoints2,
good_matches, img_matches, Scalar::all(-1), Scalar::all(-1),
std::vector<char>(), DrawMatchesFlags::NOT_DRAW_SINGLE_POINTS );
//-- Localize the object
std::vector<Point2f> obj;
std::vector<Point2f> scene;
for( size_t i = 0; i < good_matches.size(); i++ )
{
//-- Get the keypoints from the good matches
obj.push_back( keypoints1[ good_matches[i].queryIdx ].pt );
scene.push_back( keypoints2[ good_matches[i].trainIdx ].pt );
}
//-- Get the corners from the image_1 ( the object to be "detected" )
std::vector<Point2f> obj_corners(4);
obj_corners[0] = Point(0,0); obj_corners[1] = Point( cpu_img1.cols, 0 );
obj_corners[2] = Point( cpu_img1.cols, cpu_img1.rows ); obj_corners[3] = Point( 0, cpu_img1.rows );
std::vector<Point2f> scene_corners(4);
Mat H = findHomography( obj, scene, RANSAC );
perspectiveTransform( obj_corners, scene_corners, H);
scene_corners_ = scene_corners;
//-- Draw lines between the corners (the mapped object in the scene - image_2 )
line( img_matches,
scene_corners[0] + Point2f( (float)cpu_img1.cols, 0), scene_corners[1] + Point2f( (float)cpu_img1.cols, 0),
Scalar( 0, 255, 0), 2, LINE_AA );
line( img_matches,
scene_corners[1] + Point2f( (float)cpu_img1.cols, 0), scene_corners[2] + Point2f( (float)cpu_img1.cols, 0),
Scalar( 0, 255, 0), 2, LINE_AA );
line( img_matches,
scene_corners[2] + Point2f( (float)cpu_img1.cols, 0), scene_corners[3] + Point2f( (float)cpu_img1.cols, 0),
Scalar( 0, 255, 0), 2, LINE_AA );
line( img_matches,
scene_corners[3] + Point2f( (float)cpu_img1.cols, 0), scene_corners[0] + Point2f( (float)cpu_img1.cols, 0),
Scalar( 0, 255, 0), 2, LINE_AA );
return img_matches;
}
}
////////////////////////////////////////////////////
// This program demonstrates the usage of SURF_OCL.
// use cpu findHomography interface to calculate the transformation matrix
int main(int argc, char* argv[])
{
std::vector<cv::ocl::Info> info;
if(cv::ocl::getDevice(info) == 0)
{
std::cout << "Error: Did not find a valid OpenCL device!" << std::endl;
return -1;
}
ocl::setDevice(info[0]);
Mat cpu_img1, cpu_img2, cpu_img1_grey, cpu_img2_grey;
oclMat img1, img2;
bool useCPU = false;
bool useGPU = false;
bool useALL = false;
for (int i = 1; i < argc; ++i)
{
if (String(argv[i]) == "--left")
{
cpu_img1 = imread(argv[++i]);
CV_Assert(!cpu_img1.empty());
cvtColor(cpu_img1, cpu_img1_grey, COLOR_BGR2GRAY);
img1 = cpu_img1_grey;
}
else if (String(argv[i]) == "--right")
{
cpu_img2 = imread(argv[++i]);
CV_Assert(!cpu_img2.empty());
cvtColor(cpu_img2, cpu_img2_grey, COLOR_BGR2GRAY);
img2 = cpu_img2_grey;
}
else if (String(argv[i]) == "-c")
{
useCPU = true;
useGPU = false;
useALL = false;
}else if(String(argv[i]) == "-g")
{
useGPU = true;
useCPU = false;
useALL = false;
}else if(String(argv[i]) == "-a")
{
useALL = true;
useCPU = false;
useGPU = false;
}
else if (String(argv[i]) == "--help")
{
help();
return -1;
}
}
if(!useCPU)
{
std::cout
<< "Device name:"
<< info[0].DeviceName[0]
<< std::endl;
}
double surf_time = 0.;
//declare input/output
std::vector<KeyPoint> keypoints1, keypoints2;
std::vector<DMatch> matches;
std::vector<KeyPoint> gpu_keypoints1;
std::vector<KeyPoint> gpu_keypoints2;
std::vector<DMatch> gpu_matches;
Mat descriptors1CPU, descriptors2CPU;
oclMat keypoints1GPU, keypoints2GPU;
oclMat descriptors1GPU, descriptors2GPU;
//instantiate detectors/matchers
SURFDetector<SURF> cpp_surf;
SURFDetector<SURF_OCL> ocl_surf;
SURFMatcher<BFMatcher> cpp_matcher;
SURFMatcher<BFMatcher_OCL> ocl_matcher;
//-- start of timing section
if (useCPU)
{
for (int i = 0; i <= LOOP_NUM; i++)
{
if(i == 1) workBegin();
cpp_surf(cpu_img1_grey, Mat(), keypoints1, descriptors1CPU);
cpp_surf(cpu_img2_grey, Mat(), keypoints2, descriptors2CPU);
cpp_matcher.match(descriptors1CPU, descriptors2CPU, matches);
}
workEnd();
std::cout << "CPP: FOUND " << keypoints1.size() << " keypoints on first image" << std::endl;
std::cout << "CPP: FOUND " << keypoints2.size() << " keypoints on second image" << std::endl;
surf_time = getTime();
std::cout << "SURF run time: " << surf_time / LOOP_NUM << " ms" << std::endl<<"\n";
}
else if(useGPU)
{
for (int i = 0; i <= LOOP_NUM; i++)
{
if(i == 1) workBegin();
ocl_surf(img1, oclMat(), keypoints1, descriptors1GPU);
ocl_surf(img2, oclMat(), keypoints2, descriptors2GPU);
ocl_matcher.match(descriptors1GPU, descriptors2GPU, matches);
}
workEnd();
std::cout << "OCL: FOUND " << keypoints1.size() << " keypoints on first image" << std::endl;
std::cout << "OCL: FOUND " << keypoints2.size() << " keypoints on second image" << std::endl;
surf_time = getTime();
std::cout << "SURF run time: " << surf_time / LOOP_NUM << " ms" << std::endl<<"\n";
}else
{
//cpu runs
for (int i = 0; i <= LOOP_NUM; i++)
{
if(i == 1) workBegin();
cpp_surf(cpu_img1_grey, Mat(), keypoints1, descriptors1CPU);
cpp_surf(cpu_img2_grey, Mat(), keypoints2, descriptors2CPU);
cpp_matcher.match(descriptors1CPU, descriptors2CPU, matches);
}
workEnd();
std::cout << "\nCPP: FOUND " << keypoints1.size() << " keypoints on first image" << std::endl;
std::cout << "CPP: FOUND " << keypoints2.size() << " keypoints on second image" << std::endl;
surf_time = getTime();
std::cout << "(CPP)SURF run time: " << surf_time / LOOP_NUM << " ms" << std::endl;
//gpu runs
for (int i = 0; i <= LOOP_NUM; i++)
{
if(i == 1) workBegin();
ocl_surf(img1, oclMat(), gpu_keypoints1, descriptors1GPU);
ocl_surf(img2, oclMat(), gpu_keypoints2, descriptors2GPU);
ocl_matcher.match(descriptors1GPU, descriptors2GPU, gpu_matches);
}
workEnd();
std::cout << "\nOCL: FOUND " << keypoints1.size() << " keypoints on first image" << std::endl;
std::cout << "OCL: FOUND " << keypoints2.size() << " keypoints on second image" << std::endl;
surf_time = getTime();
std::cout << "(OCL)SURF run time: " << surf_time / LOOP_NUM << " ms" << std::endl<<"\n";
}
//--------------------------------------------------------------------------
std::vector<Point2f> cpu_corner;
Mat img_matches = drawGoodMatches(cpu_img1, cpu_img2, keypoints1, keypoints2, matches, cpu_corner);
std::vector<Point2f> gpu_corner;
Mat ocl_img_matches;
if(useALL || (!useCPU&&!useGPU))
{
ocl_img_matches = drawGoodMatches(cpu_img1, cpu_img2, gpu_keypoints1, gpu_keypoints2, gpu_matches, gpu_corner);
//check accuracy
std::cout<<"\nCheck accuracy:\n";
if(cpu_corner.size()!=gpu_corner.size())
std::cout<<"Failed\n";
else
{
bool result = false;
for(size_t i = 0; i < cpu_corner.size(); i++)
{
if((std::abs(cpu_corner[i].x - gpu_corner[i].x) > 10)
||(std::abs(cpu_corner[i].y - gpu_corner[i].y) > 10))
{
std::cout<<"Failed\n";
result = false;
break;
}
result = true;
}
if(result)
std::cout<<"Passed\n";
}
}
//-- Show detected matches
if (useCPU)
{
namedWindow("cpu surf matches", 0);
imshow("cpu surf matches", img_matches);
}
else if(useGPU)
{
namedWindow("ocl surf matches", 0);
imshow("ocl surf matches", img_matches);
}else
{
namedWindow("cpu surf matches", 0);
imshow("cpu surf matches", img_matches);
namedWindow("ocl surf matches", 0);
imshow("ocl surf matches", ocl_img_matches);
}
waitKey(0);
return 0;
}
|
803901007d9b578214e5090e4c7cdb0508c224d3 | ac5442020a5247231ede042926530e500b16b501 | /compilers/multicore-backend/src/syntax/logical_expr.cc | 69c7da553770568f85390bbd49b5011bbe731cd1 | [] | no_license | MuhammadNurYanhaona/ITandPCubeS | e8a42d8d50f56eb76954bdf2cb786377cb5a8ee5 | 8928c56587db8293f0ec02c7cb030cfb540ce2b4 | refs/heads/master | 2021-01-24T06:22:37.089569 | 2017-04-22T15:57:04 | 2017-04-22T15:57:04 | 15,794,818 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 20,537 | cc | logical_expr.cc | #include "ast.h"
#include "ast_stmt.h"
#include "ast_expr.h"
#include "ast_type.h"
#include "../utils/list.h"
#include "string.h"
#include "../semantics/symbol.h"
#include "../semantics/task_space.h"
#include "errors.h"
#include "../utils/hashtable.h"
#include "../static-analysis/data_access.h"
#include "../static-analysis/loop_index.h"
#include "../codegen/name_transformer.h"
#include <iostream>
#include <sstream>
#include <cstdlib>
#include <stack>
#include <deque>
//------------------------------------------------ Logical Expression -------------------------------------------------/
LogicalExpr::LogicalExpr(Expr *l, LogicalOperator o, Expr *r, yyltype loc) : Expr(loc) {
Assert(r != NULL);
left = l;
if (left != NULL) {
left->SetParent(this);
}
op = o;
right = r;
right->SetParent(this);
}
void LogicalExpr::PrintChildren(int indentLevel) {
PrintLabel(indentLevel + 1, "Operator");
switch (op) {
case AND: printf("&&"); break;
case OR: printf("||"); break;
case NOT: printf("!"); break;
case EQ: printf("=="); break;
case NE: printf("!="); break;
case GT: printf(">"); break;
case LT: printf("<"); break;
case GTE: printf(">="); break;
case LTE: printf("<="); break;
}
if (left != NULL) left->Print(indentLevel + 1);
right->Print(indentLevel + 1);
}
void LogicalExpr::resolveType(Scope *scope, bool ignoreFailure) {
right->resolveType(scope, ignoreFailure);
Type *rightType = right->getType();
if (rightType == NULL) {
ReportError::UnknownExpressionType(right, ignoreFailure);
}
Type *leftType = NULL;
if (left != NULL) {
left->resolveType(scope, ignoreFailure);
leftType = left->getType();
if (leftType == NULL) {
ReportError::UnknownExpressionType(left, ignoreFailure);
}
}
bool arithMaticOperator = (op == EQ || op == NE || op == GT || op == LT || op == GTE || op == LTE);
if (arithMaticOperator) {
if (leftType != NULL && !(leftType == Type::intType
|| leftType == Type::floatType
|| leftType == Type::doubleType
|| leftType == Type::charType
|| leftType == Type::errorType)) {
ReportError::UnsupportedOperand(left, leftType,
"logical expression", ignoreFailure);
}
if (rightType != NULL && !(rightType == Type::intType
|| rightType == Type::floatType
|| rightType == Type::doubleType
|| rightType == Type::charType
|| rightType == Type::errorType)) {
ReportError::UnsupportedOperand(right, rightType,
"logical expression", ignoreFailure);
}
if (leftType != NULL && rightType != NULL) {
if (!leftType->isAssignableFrom(rightType)
&& !rightType->isAssignableFrom(leftType)) {
ReportError::TypeMixingError(this, leftType, rightType,
"logical expression", ignoreFailure);
}
}
} else {
if (rightType != NULL && !rightType->isAssignableFrom(Type::boolType)) {
ReportError::IncompatibleTypes(right->GetLocation(),
rightType, Type::boolType, ignoreFailure);
}
if (leftType != NULL && !leftType->isAssignableFrom(Type::boolType)) {
ReportError::IncompatibleTypes(left->GetLocation(),
leftType, Type::boolType, ignoreFailure);
}
}
this->type = Type::boolType;
}
void LogicalExpr::inferType(Scope *scope, Type *rootType) {
if (rootType != NULL && !rootType->isAssignableFrom(Type::boolType)) {
ReportError::InferredAndActualTypeMismatch(this->GetLocation(),
rootType, Type::boolType, false);
} else {
bool arithMaticOperator = (op == EQ || op == NE || op == GT || op == LT || op == GTE || op == LTE);
if (arithMaticOperator) {
left->resolveType(scope, true);
Type *leftType = left->getType();
right->resolveType(scope, true);
Type *rightType = right->getType();
if (leftType == NULL && rightType != NULL) {
left->inferType(scope, rightType);
} else if (leftType != NULL && rightType == NULL) {
right->inferType(scope, leftType);
} else {
left->inferType(scope);
right->inferType(scope);
}
} else {
right->inferType(scope, Type::boolType);
if (left != NULL) left->inferType(scope, Type::boolType);
}
}
}
Hashtable<VariableAccess*> *LogicalExpr::getAccessedGlobalVariables(TaskGlobalReferences *globalReferences) {
Hashtable<VariableAccess*> *table = right->getAccessedGlobalVariables(globalReferences);
if (left == NULL) return table;
Hashtable<VariableAccess*> *lTable = left->getAccessedGlobalVariables(globalReferences);
mergeAccessedVariables(table, lTable);
Iterator<VariableAccess*> iter = table->GetIterator();
VariableAccess *accessLog;
while((accessLog = iter.GetNextValue()) != NULL) {
if(accessLog->isContentAccessed())
accessLog->getContentAccessFlags()->flagAsRead();
if (accessLog->isMetadataAccessed())
accessLog->getMetadataAccessFlags()->flagAsRead();
}
return table;
}
void LogicalExpr::translate(std::ostringstream &stream, int indentLevel, int currentLineLength, Space *space) {
stream << "(";
if (left != NULL) {
left->translate(stream, indentLevel, currentLineLength, space);
}
switch (op) {
case AND: stream << " && "; break;
case OR: stream << " || "; break;
case NOT: stream << "!"; break;
case EQ: stream << " == "; break;
case NE: stream << " != "; break;
case GT: stream << " > "; break;
case LT: stream << " < "; break;
case GTE: stream << " >= "; break;
case LTE: stream << " <= "; break;
}
right->translate(stream, indentLevel, currentLineLength, space);
stream << ")";
}
List<FieldAccess*> *LogicalExpr::getTerminalFieldAccesses() {
if (left == NULL) return right->getTerminalFieldAccesses();
List<FieldAccess*> *leftList = left->getTerminalFieldAccesses();
Expr::copyNewFields(leftList, right->getTerminalFieldAccesses());
return leftList;
}
// TODO: note that this is a simple implementation that does not appy any transformation to the logical expression
// that may allow it to express as a collective of AND operations. More elaborate implementation that does that may
// be attempted later if seems worthwhile.
List<LogicalExpr*> *LogicalExpr::getANDBreakDown() {
List<LogicalExpr*> *breakDownList = new List<LogicalExpr*>;
// it is a unary NOT statement and there is nothing to do here
if (left == NULL) {
breakDownList->Append(this);
return NULL;
// if it is not an AND operation then we cannot break it down either
} else if (op != AND) {
breakDownList->Append(this);
} else {
LogicalExpr *leftLogic = dynamic_cast<LogicalExpr*>(left);
breakDownList->AppendAll(leftLogic->getANDBreakDown());
LogicalExpr *rightLogic = dynamic_cast<LogicalExpr*>(right);
breakDownList->AppendAll(rightLogic->getANDBreakDown());
}
return breakDownList;
}
List<LogicalExpr*> *LogicalExpr::getIndexRestrictExpr(List<LogicalExpr*> *exprList, std::ostringstream &stream,
const char *indexVar, const char *rangeExpr,
int indentLevel, Space *space,
bool xformedArrayRange, const char *arrayName, int dimensionNo) {
// we create two local references for possible restriction on beginning and ending conditions
LogicalExpr *gteExpr = NULL;
LogicalExpr *lteExpr = NULL;
// two flags to determine if we need to investigate further for restricting conditions
bool gteFound = false;
bool lteFound = false;
// finally two marker variables to keep track on which side of a logical expression the loop index
// lies if the expression is a restricting condition of the form we desire
int gteMarker = 0;
int lteMarker = 0;
for (int i = 0; i < exprList->NumElements(); i++) {
LogicalExpr *currentExpr = exprList->Nth(i);
int eval = currentExpr->isLoopRestrictExpr(indexVar);
if (eval == 0) continue;
// Note that the logic below ensures that the first candidate expressions for the loop start
// and end conditions are retained. We may not need this.
LogicalOperator op = currentExpr->getOp();
if (op == GT || op == GTE) {
if (eval == -1 && !lteFound) {
lteFound = true;
lteMarker = -1;
lteExpr = currentExpr;
} else if (eval == 1 && !gteFound) {
gteFound = true;
gteMarker = 1;
gteExpr = currentExpr;
}
} else {
if (eval == -1 && !gteFound) {
gteFound = true;
gteMarker = -1;
gteExpr = currentExpr;
} else if (eval == 1 && !lteFound) {
lteFound = true;
lteMarker = 1;
lteExpr = currentExpr;
}
}
}
// declare a list that contains expressions (o to 2) that should be filtered out from the original
// list
List<LogicalExpr*> *excludedList = new List<LogicalExpr*>;
// if we have any restricting condition then we can generate if conditions that will further
// restrict the loop index beginning or terminal conditions from what they are set to by default
if (gteFound || lteFound) {
std::string stmtSeparator = ";\n";
// first generate the indent string
std::ostringstream indent;
for (int i = 0; i < indentLevel; i++) indent << "\t";
// create a local scope in case index transforms are needed to apply the restrictions
stream << indent.str() << "{// scope entrance for applying index loop restrictions\n";
// initially assign the index start and end bounds that are applied by default to some
// local variables
stream << indent.str() << "int localIterationStart = iterationStart" << stmtSeparator;
stream << indent.str() << "int localIterationBound = iterationBound" << stmtSeparator;
// generate an if else block that will check if the index is increasing or decreasing
// and based on that apply appropriate restrictions
stream << indent.str();
stream << "if (" << rangeExpr << ".min > " << rangeExpr << ".max) {\n";
// when range is decreasing then less than equal condition should apply to the beginning
// and greater than equal condition should apply to the ending
if (lteFound) {
Expr *lteCond = (lteMarker == 1) ? lteExpr->getRight() : lteExpr->getLeft();
stream << indent.str() << "\t";
stream << "localIterationStart = ";
lteCond->translate(stream, indentLevel + 1, 0, space);
if ((lteMarker == 1 && lteExpr->getOp() == LT)
|| (lteMarker == -1 && lteExpr->getOp() == GT)) {
stream << " - 1";
}
stream << stmtSeparator;
// if the index is traversing an array dimension range and the dimension of the
// array has been reordered then apply equivalent transformation on the iteration
// start condition
if (xformedArrayRange) {
bool precise = transformIndexRestriction(stream, "localIterationStart",
arrayName, dimensionNo,
indentLevel + 1, space, true, false);
if (precise) excludedList->Append(lteExpr);
} else {
excludedList->Append(lteExpr);
}
}
if (gteFound) {
Expr *gteCond = (gteMarker == 1) ? gteExpr->getRight() : gteExpr->getLeft();
stream << indent.str() << "\t";
stream << "localIterationBound = ";
gteCond->translate(stream, indentLevel + 1, 0, space);
if ((gteMarker == 1 && gteExpr->getOp() == GT)
|| (gteMarker == -1 && gteExpr->getOp() == LT)) {
stream << " + 1";
}
stream << stmtSeparator;
// similar to the above case of iteration start condition, appy a transformation
// on the iteration end condition, if applicable.
if (xformedArrayRange) {
bool precise = transformIndexRestriction(stream, "localIterationBound",
arrayName, dimensionNo,
indentLevel + 1, space, false, true);
if (precise) excludedList->Append(gteExpr);
} else {
excludedList->Append(gteExpr);
}
}
// on the other hand, when the range is increasing, which is the normal case, greater than
// condition should be applied to the beginning and less than at the ending
stream << indent.str() << "} else {\n";
if (lteFound) {
Expr *lteCond = (lteMarker == 1) ? lteExpr->getRight() : lteExpr->getLeft();
stream << indent.str() << "\t";
stream << "localIterationBound = ";
lteCond->translate(stream, indentLevel + 1, 0, space);
if ((lteMarker == 1 && lteExpr->getOp() == LT)
|| (lteMarker == -1 && lteExpr->getOp() == GT)) {
stream << " - 1";
}
stream << stmtSeparator;
if (xformedArrayRange) {
bool precise = transformIndexRestriction(stream, "localIterationBound",
arrayName, dimensionNo,
indentLevel + 1, space, false, true);
if (precise) excludedList->Append(lteExpr);
} else {
excludedList->Append(lteExpr);
}
}
if (gteFound) {
Expr *gteCond = (gteMarker == 1) ? gteExpr->getRight() : gteExpr->getLeft();
stream << indent.str() << "\t";
stream << "localIterationStart = ";
gteCond->translate(stream, indentLevel + 1, 0, space);
if ((gteMarker == 1 && gteExpr->getOp() == GT)
|| (gteMarker == -1 && gteExpr->getOp() == LT)) {
stream << " + 1";
}
stream << stmtSeparator;
if (xformedArrayRange) {
bool precise = transformIndexRestriction(stream, "localIterationStart",
arrayName, dimensionNo,
indentLevel + 1, space, true, false);
if (precise) excludedList->Append(gteExpr);
} else {
excludedList->Append(gteExpr);
}
}
stream << indent.str() << "}\n";
// Finally, before applying the updated conditions we need to validate that new conditions will
// not expand the range been traversed as oppose to restrict it further. This can happen often
// when the range corresponds to some array dimension.
stream << indent.str();
stream << "if (" << rangeExpr << ".min > " << rangeExpr << ".max) {\n";
stream << indent.str() << '\t';
stream << "iterationStart = min(iterationStart, localIterationStart)" << stmtSeparator;
stream << indent.str() << '\t';
stream << "iterationBound = max(iterationBound, localIterationBound)" << stmtSeparator;
stream << indent.str() << "} else {\n";
stream << indent.str() << '\t';
stream << "iterationStart = max(iterationStart, localIterationStart)" << stmtSeparator;
stream << indent.str() << '\t';
stream << "iterationBound = min(iterationBound, localIterationBound)" << stmtSeparator;
stream << indent.str() << "}\n";
// close the local scope
stream << indent.str() << "}// scope exit for applying index loop restrictions\n";
}
// finally, filter out the excluded expressions from the original list
List<LogicalExpr*> *filterList = new List<LogicalExpr*>;
for (int i = 0; i < exprList->NumElements(); i++) {
LogicalExpr *currentExpr = exprList->Nth(i);
bool found = false;
for (int j = 0; j < excludedList->NumElements(); j++) {
if (currentExpr == excludedList->Nth(j)) {
found = true;
break;
}
}
if (!found) filterList->Append(currentExpr);
}
return filterList;
}
int LogicalExpr::isLoopRestrictExpr(const char *loopIndex) {
// only greater or less than comparison can be used for loop index restrictions
if (left == NULL) return 0;
if (!(op == GT || op == LT || op == GTE || op == LTE)) return 0;
// for a valid candidate loop restricting condition the loop index should lie only one side
// of the expression
FieldAccess *leftField = dynamic_cast<FieldAccess*>(left);
FieldAccess *rightField = dynamic_cast<FieldAccess*>(right);
if (leftField != NULL && leftField->isTerminalField()
&& strcmp(leftField->getField()->getName(), loopIndex) == 0) {
List<FieldAccess*> *rightAccessList = right->getTerminalFieldAccesses();
for (int i = 0; i < rightAccessList->NumElements(); i++) {
if (strcmp(loopIndex, rightAccessList->Nth(i)->getField()->getName()) == 0) {
return 0;
}
}
return 1;
} else if (rightField != NULL && rightField->isTerminalField()
&& strcmp(rightField->getField()->getName(), loopIndex) == 0) {
List<FieldAccess*> *leftAccessList = left->getTerminalFieldAccesses();
for (int i = 0; i < leftAccessList->NumElements(); i++) {
if (strcmp(loopIndex, leftAccessList->Nth(i)->getField()->getName()) == 0) {
return 0;
}
}
return -1;
}
return 0;
}
bool LogicalExpr::transformIndexRestriction(std::ostringstream &stream,
const char *varName, const char *arrayName, int dimensionNo, int indentLevel,
Space *space, bool normalizedToMinOfRange, bool lowerBound) {
bool preciseTransformation = true;
std::string stmtSeparator = ";\n";
std::string paramSeparator = ", ";
std::ostringstream indent;
for (int i = 0; i < indentLevel; i++) indent << '\t';
// get the reference name for the partition dimension configuration object for the concerned
// array's concerned dimension
ntransform::NameTransformer *transformer = ntransform::NameTransformer::transformer;
std::string lpuPrefix = transformer->getLpuPrefix();
std::ostringstream partConfigVar;
partConfigVar << "(&" << lpuPrefix << arrayName << "PartDims[" << dimensionNo - 1 << "])";
// get the Root Space reference to aid in determining the extend of reordering later
Space *rootSpace = space->getRoot();
// grab array configuration information for current LPS
ArrayDataStructure *array = (ArrayDataStructure*) space->getLocalStructure(arrayName);
// create two stacks for traversing parent pointers; stacks are needed as transformation should
// be done from top to bottom in the LPS hierarchy
std::stack<const char*> partConfigsStack;
std::stack<ArrayDataStructure*> parentStructsStack;
// reach the first reference of the array in the part config stack where the array along this
// dimension is reordered by the its partitioning functions
std::ostringstream parentArrows;
while (!array->isDimensionLocallyReordered(dimensionNo)) {
array = (ArrayDataStructure*) array->getSource();
parentArrows << "->parent";
}
// reverse track references up to one LPS up to foremost reorder point and store all points where
// the array has been partitioned along concerned dimension
while (array != NULL) {
if (array->isPartitionedAlongDimension(dimensionNo)) {
partConfigsStack.push(strdup(parentArrows.str().c_str()));
parentStructsStack.push(array);
}
if (array->isPartitionedAlongDimension(dimensionNo)
&& !array->isDimensionReordered(dimensionNo, rootSpace)) break;
parentArrows << "->parent";
array = (ArrayDataStructure*) array->getSource();
}
// then transform the variable in a top-down fasion from uppermost to the lowermost reorder point
ArrayDataStructure *lastArray = NULL;
const char *lastPointerLinks = NULL;
while (!partConfigsStack.empty()) {
const char *pointerLinks = partConfigsStack.top();
ArrayDataStructure *parentArray = parentStructsStack.top();
// if the dimension is reordered in current LPS then apply transformation expression here
// over current value of the transformed variable
if (parentArray->isDimensionLocallyReordered(dimensionNo)) {
// first normalize the index first if the reoredering LPS is preceeded by an order
if (lastArray != NULL && !lastArray->isDimensionLocallyReordered(dimensionNo)) {
stream << indent.str();
stream << "partConfig = *" << partConfigVar.str() << lastPointerLinks;
stream << stmtSeparator;
stream << indent.str();
stream << varName << " = ";
// note that safe-normalization is used as we do not know if the transformed
// variable's value falls inside the LPU boundary for the underlying array
// dimension and we need to set the value to partitioned dimension's min or
// max value to probable incorrect computation as a result of non-sensical
// transformation
stream << "partConfig.safeNormalizeIndex(" << varName;
stream << paramSeparator;
if (normalizedToMinOfRange) stream << "true";
else stream << "false";
stream << ")" << stmtSeparator;
preciseTransformation = false;
}
// get the reference of the partition dimension configuration object for current LPS
stream << indent.str();
stream << "partConfig = *" << partConfigVar.str() << pointerLinks;
stream << stmtSeparator;
// then transform the index
stream << indent.str();
stream << varName << " = ";
stream << parentArray->getImpreciseBoundOnXformedIndex(dimensionNo,
varName, lowerBound, indentLevel);
stream << stmtSeparator;
}
// keep track of the array and pointer links to get to its partition config of the last LPS
// regardless of its been order-preserving or reordering.
lastArray = parentArray;
lastPointerLinks = pointerLinks;
partConfigsStack.pop();
parentStructsStack.pop();
}
return preciseTransformation;
}
|
84c9544cedcf0a788178a2b8b80b1e8e8da80442 | 00bc38fca3165a85c3a4e040bbd2c55162ff917b | /PipesPlatforms/Plugins/ObsEvent2.5-4.22/Source/ObsEvent/Public/ObsEvent.h | 1f0273da28400454de0c44490906f05ec5e7473d | [] | no_license | WookieeMatt/RestaurantWars | 6d3c27d512a42db408d125facec4edfeb4a1aff3 | cdc1a8d644873321c90342f20c62dc56fbdf7b4c | refs/heads/master | 2020-06-16T02:50:42.583418 | 2019-10-06T18:39:56 | 2019-10-06T18:39:56 | 195,458,115 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,945 | h | ObsEvent.h | // Copyright Out-of-the-Box Plugins 2018-2019. All Rights Reserved.
#pragma once
#include "Internationalization/Text.h"
#include "UObject/Object.h"
#include "UObject/ObjectMacros.h"
#include "ObsEvent.generated.h"
class IObsInterfaceListener;
class AActor;
class UObsPayload;
/**
* Event holding all the listeners and delegating the call to them.
*/
UCLASS(BlueprintType, hidecategories = (Object), ClassGroup = Events, Category = "ObsEvents", Blueprintable)
class OBSEVENT_API UObsEvent : public UObject
{
GENERATED_BODY()
public:
// Invoke the event.
UFUNCTION(BlueprintCallable, Category = "ObsEvents", meta = (AdvancedDisplay = "payload"))
static void Invoke(UObsEvent* eventToInvoke, UObsPayload* payload);
//TODO: Add optional pin to invoke pin for actor only
// Invoke the event on a single actor.
UFUNCTION(BlueprintCallable, Category = "ObsEvents", meta = (AdvancedDisplay = "payload"))
static void InvokeOnActor(AActor* actor, UObsEvent* eventToInvoke, UObsPayload* payload);
// Removes all the listeners from one event.
UFUNCTION(BlueprintCallable, Category = "ObsEvents")
static void UnRegisterAllListeners(UObsEvent* eventToClear);
//TODO: Consider putting payload in here as well.
// Invokes the event for debug purposes.
void DebugInvoke();
// Register the listener to the event.
void RegisterListener(const IObsInterfaceListener* listener);
// Unregister the listener from the event.
void UnRegisterListener(const IObsInterfaceListener* listener);
// Short description so you won't forget.
UPROPERTY(BlueprintReadOnly, EditAnywhere, Category = "ObsEvents")
FText Description;
protected:
// Listeners registered.
TArray<const IObsInterfaceListener*> listeners;
// Delegate the call to the listeners.
void CallListeners(UObsPayload* payload);
// Delegate the call to all the components listeners on the target actor
void CallListenerComponents(AActor* actor, UObsPayload* payload);
};
|
9caf42d1f59eb8721de0364848bad4238fc0eebd | 0797799496daa46f8fc10d4343dc9fdd5aa2af88 | /src/render/render_circle_2.cpp | 73ddfa8966f843df0790788e0f1cc4d48c755591 | [] | no_license | fearlessfollowing/titan | 597cdf055d4a608ac37e6b97b40b5ecfa8969fb9 | b63d82efb949f512bae16a443405c963c582735d | refs/heads/master | 2020-04-24T09:17:43.499817 | 2019-05-11T10:42:15 | 2019-05-11T10:42:15 | 171,858,309 | 2 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 29,777 | cpp | render_circle_2.cpp | #include "render.h"
#include "inslog.h"
#include "common.h"
#include "Dewarp/Dewarp.h"
#include "xml_config.h"
#include "sharder.h"
#define FLAT_WIDTH 100
#define FLAT_HEIGHT 50
#define CUBE_WIDTH 32
#define CUBE_HEIGHT 32
void render::release_render_cicle()
{
if (vao_[0] != 0)
{
glDeleteVertexArraysOES(vao_num_, vao_);
vao_[0] = 0;
}
if (vbo_[0] != 0)
{
glDeleteBuffers(vbo_num_, vbo_);
vbo_[0] = 0;
}
if (vao_aux_[0] != 0)
{
glDeleteVertexArraysOES(vao_aux_num_, vao_aux_);
vao_aux_[0] = 0;
}
if (vbo_aux_[0] != 0)
{
glDeleteBuffers(vbo_aux_num_, vbo_aux_);
vbo_aux_[0] = 0;
}
if (texture_[0])
{
glDeleteTextures(texture_num_, texture_);
texture_[0] = 0;
}
if (texture_uv_[0])
{
glDeleteTextures(texture_num_, texture_uv_);
texture_uv_[0] = 0;
}
if (texture_uv2_[0])
{
glDeleteTextures(texture_num_, texture_uv2_);
texture_uv2_[0] = 0;
}
}
void render::render_init(int width, int height, int mode, bool b_external)
{
in_width_ = width;
in_height_ = height;
mode_ = mode;
b_external_ = b_external;
}
void render::gen_texture()
{
glGenTextures(texture_num_, texture_);
if (!b_external_)
{
for (int i = 0; i < texture_num_; i++)
{
glBindTexture(GL_TEXTURE_2D, texture_[i]);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, in_width_, in_height_, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
}
glBindTexture(GL_TEXTURE_2D, 0);
}
glGenTextures(texture_num_, texture_uv_);
for (int i = 0; i < texture_num_; i++)
{
glBindTexture(GL_TEXTURE_2D, texture_uv_[i]);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexImage2D (GL_TEXTURE_2D, 0, GL_RGB, FLAT_WIDTH, FLAT_HEIGHT, 0, GL_RGB, GL_FLOAT, nullptr);
}
if (mode_ != INS_MODE_PANORAMA)
{
glGenTextures(texture_num_, texture_uv2_);
for (int i = 0; i < texture_num_; i++)
{
glBindTexture(GL_TEXTURE_2D, texture_uv2_[i]);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexImage2D (GL_TEXTURE_2D, 0, GL_RGB, FLAT_WIDTH, FLAT_HEIGHT, 0, GL_RGB, GL_FLOAT, nullptr);
}
}
glBindTexture(GL_TEXTURE_2D, 0);
}
const int* render::get_tex_id() const
{
return (int*)texture_;
}
int render::create_master_program()
{
if (b_external_)
{
return create_program(vertex_shader_highp, fragment_shader_highp_v);
}
else
{
return create_program(vertex_shader_highp, fragment_shader_highp_p);
}
//return create_program(vertex_shader, b_external_?fragment_shader_ex:fragment_shader);
// return create_program(vertex_shader_new, b_external_?fragment_shader_ex_new:fragment_shader);
//return create_program(vertex_shader_2, b_external_?fragment_shader_ex_2:fragment_shader);
//return create_program(vertex_shader_highp, b_external_?fragment_shader_highp:fragment_shader);
}
int render::create_aux_program()
{
return create_program(vertex_shader_quad, fragment_shader_quad);
}
void render::prepare_vao()
{
prepare_vao_flat();
}
void render::prepare_vao_flat()
{
int out_width = FLAT_WIDTH;
int out_height = FLAT_HEIGHT;
if (mode_ == INS_MODE_PANORAMA)
{
std::string offset;
if (in_width_*9 == in_height_*16)
{
offset = xml_config::get_string(INS_CONFIG_OFFSET, INS_CONFIG_OFFSET_PANO_16_9);
if (offset == "") offset = INS_DEFAULT_OFFSET_PANO_16_9;
LOGINFO("pano 16:9 offset:%s", offset.c_str());
}
else
{
offset = xml_config::get_string(INS_CONFIG_OFFSET, INS_CONFIG_OFFSET_PANO_4_3);
if (offset == "") offset = INS_DEFAULT_OFFSET_PANO_4_3;
LOGINFO("pano 4:3 offset:%s", offset.c_str());
}
ins::Dewarp map;
map.setOffset(offset);
std::vector<int> v_width(texture_num_, in_width_);
std::vector<int> v_height(texture_num_, in_height_);
map.init(v_width, v_height, FLAT_WIDTH, FLAT_HEIGHT);
for (int i = 0; i < texture_num_; i++)
{
float* uv_get = map.getMap(i, ins::MAPTYPE::OPENGL);
float* alpha_get = map.getAlpha(i, 0, ins::MAPTYPE::OPENGL);
float* uv = new float[(out_width)*out_height*3];
for (int j = 0; j< out_width * out_height; j++)
{
uv[j*3] = uv_get[j*2];
uv[j*3+1] = uv_get[j*2+1];
uv[j*3+2] = alpha_get[j];
}
glBindTexture(GL_TEXTURE_2D, texture_uv_[i]);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, out_width, out_height, 0, GL_RGB, GL_FLOAT, uv);
// short* uv = new short[(out_width)*out_height*3];
// for (int j = 0; j< out_width * out_height; j++)
// {
// uv[j*3] = FloatToFloat16(uv_get[j*2]);
// uv[j*3+1] = FloatToFloat16(uv_get[j*2+1]);
// uv[j*3+2] = FloatToFloat16(alpha_get[j]);
// }
// glBindTexture(GL_TEXTURE_2D, texture_uv_[i]);
// glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB16F_EXT, out_width, out_height, 0, GL_RGB, GL_HALF_FLOAT_OES, uv);
// unsigned char* uv = new unsigned char[(out_width)*out_height*4];
// for (int j = 0; j< out_width * out_height; j++)
// {
// uv[j*4] = uv_get[j*2] * 255;
// uv[j*4+1] = uv_get[j*2+1] * 255;
// uv[j*4+2] = alpha_get[j] * 255;
// }
// glBindTexture(GL_TEXTURE_2D, texture_uv_[i]);
// glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, out_width, out_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, uv);
delete[] uv;
}
glBindTexture(GL_TEXTURE_2D, 0);
}
else
{
std::vector<int> v_width(texture_num_, in_width_);
std::vector<int> v_height(texture_num_, in_height_);
std::string offset_left = xml_config::get_string(INS_CONFIG_OFFSET, INS_CONFIG_OFFSET_3D_LEFT);
if (offset_left == "") offset_left = INS_DEFAULT_OFFSET_3D_LEFT;
LOGINFO("3d left offset:%s", offset_left.c_str());
ins::Dewarp map_left;
map_left.setOffset(offset_left);
map_left.init(v_width, v_height, FLAT_WIDTH, FLAT_HEIGHT);
std::string offset_right = xml_config::get_string(INS_CONFIG_OFFSET, INS_CONFIG_OFFSET_3D_RIGHT);
if (offset_right == "") offset_right = INS_DEFAULT_OFFSET_3D_RIGHT;
LOGINFO("3d right offset:%s", offset_right.c_str());
ins::Dewarp map_right;
map_right.setOffset(offset_right);
map_right.init(v_width, v_height, FLAT_WIDTH, FLAT_HEIGHT);
for (int i = 0; i < texture_num_; i++)
{
float *uv_1_get, *uv_2_get, *alpha_1_get, *alpha_2_get;
if (submode_ == INS_SUBMODE_3D_TOP_LEFT)
{
uv_1_get = map_right.getMap(i, ins::MAPTYPE::OPENGL);
uv_2_get = map_left.getMap(i, ins::MAPTYPE::OPENGL);
alpha_1_get = map_right.getAlphaRight(i, ins::MAPTYPE::OPENGL);
alpha_2_get = map_left.getAlphaLeft(i, ins::MAPTYPE::OPENGL);
}
else
{
uv_1_get = map_left.getMap(i, ins::MAPTYPE::OPENGL);
uv_2_get = map_right.getMap(i, ins::MAPTYPE::OPENGL);
alpha_1_get = map_right.getAlphaRight(i, ins::MAPTYPE::OPENGL);
alpha_2_get = map_left.getAlphaLeft(i, ins::MAPTYPE::OPENGL);
}
float* uv_1 = new float[out_width*out_height*3];
for (int j = 0; j< out_width * out_height; j++)
{
uv_1[j*3] = uv_1_get[j*2];
uv_1[j*3+1] = uv_1_get[j*2+1];
uv_1[j*3+2] = alpha_1_get[j];
}
glBindTexture(GL_TEXTURE_2D, texture_uv_[i]);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, out_width, out_height, 0, GL_RGB, GL_FLOAT, uv_1);
delete[] uv_1;
float* uv_2 = new float[out_width*out_height*3];
for (int j = 0; j< out_width * out_height; j++)
{
uv_2[j*3] = uv_2_get[j*2];
uv_2[j*3+1] = uv_2_get[j*2+1];
uv_2[j*3+2] = alpha_2_get[j];
}
glBindTexture(GL_TEXTURE_2D, texture_uv2_[i]);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, out_width, out_height, 0, GL_RGB, GL_FLOAT, uv_2);
delete[] uv_2;
}
}
int k = 0, n = 0, m=0;
float* vetex_data = new float[out_width*out_height*4]();
for (int j = 0; j < out_height; j++)
{
for (int i = 0; i < out_width; i++)
{
vetex_data[k++] = 2.0 * i / (out_width - 1.0) - 1.0;
vetex_data[k++] = 1.0 - 2.0 * j / (out_height - 1.0);
vetex_data[k++] = 0;
vetex_data[k++] = 1.0;
}
}
index_num_ = (out_width-out_width/FLAT_WIDTH)*(out_height-out_height/FLAT_HEIGHT)*2*3;
GLuint* index_data = new GLuint[index_num_]();
for (int j = 0, k = 0; j < out_height - 1; j++)
{
if ((j+1)%FLAT_HEIGHT == 0) continue;
for (int i = 0; i < out_width - 1; i++)
{
GLuint tmp1 = i+j*out_width;
GLuint tmp2 = i+(j+1)*out_width;
index_data[k++] = tmp1;
index_data[k++] = tmp2;
index_data[k++] = tmp2+1;
index_data[k++] = tmp1;
index_data[k++] = tmp1+1;
index_data[k++] = tmp2+1;
}
}
prepare_master_vao(program_[0], out_width, out_height, vetex_data, index_data);
if (program_.size() > 1)
{
prepare_aux_vao(program_[1]);
}
delete[] vetex_data;
delete[] index_data;
LOGINFO("prepare vao fininsh");
}
void render::prepare_master_vao(GLuint program, int width, int height, float* vetex_data, GLuint* index_data)
{
GLuint loc_position = glGetAttribLocation(program, "position");
glGenVertexArraysOES(vao_num_, vao_);
glGenBuffers(vbo_num_, vbo_);
glBindVertexArrayOES(vao_[0]);
glBindBuffer(GL_ARRAY_BUFFER, vbo_[0]);
glBufferData(GL_ARRAY_BUFFER, width * height*4*sizeof(GLfloat), vetex_data, GL_STATIC_DRAW);
glEnableVertexAttribArray(loc_position);
glVertexAttribPointer(loc_position, 4, GL_FLOAT, GL_FALSE, 0, nullptr);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vbo_[1]);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, index_num_*sizeof(GLuint), index_data, GL_STATIC_DRAW);
glBindVertexArrayOES(0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
glBindBuffer(GL_ARRAY_BUFFER, 0);
GLuint type = b_external_?GL_TEXTURE_EXTERNAL_OES:GL_TEXTURE_2D;
glActiveTexture(GL_TEXTURE0);
glBindTexture(type, texture_[0]);
glUniform1i(glGetUniformLocation(program_[0], "tex_1"), 0);
glActiveTexture(GL_TEXTURE1);
glBindTexture(type, texture_[1]);
glUniform1i(glGetUniformLocation(program_[0], "tex_2"), 1);
glActiveTexture(GL_TEXTURE2);
glBindTexture(type, texture_[2]);
glUniform1i(glGetUniformLocation(program_[0], "tex_3"), 2);
glActiveTexture(GL_TEXTURE3);
glBindTexture(type, texture_[3]);
glUniform1i(glGetUniformLocation(program_[0], "tex_4"), 3);
glActiveTexture(GL_TEXTURE4);
glBindTexture(type, texture_[4]);
glUniform1i(glGetUniformLocation(program_[0], "tex_5"), 4);
glActiveTexture(GL_TEXTURE5);
glBindTexture(type, texture_[5]);
glUniform1i(glGetUniformLocation(program_[0], "tex_6"), 5);
glActiveTexture(GL_TEXTURE6);
glBindTexture(GL_TEXTURE_2D, texture_uv_[0]);
glUniform1i(glGetUniformLocation(program_[0], "map_1"), 6);
glActiveTexture(GL_TEXTURE7);
glBindTexture(GL_TEXTURE_2D, texture_uv_[1]);
glUniform1i(glGetUniformLocation(program_[0], "map_2"), 7);
glActiveTexture(GL_TEXTURE8);
glBindTexture(GL_TEXTURE_2D, texture_uv_[2]);
glUniform1i(glGetUniformLocation(program_[0], "map_3"), 8);
glActiveTexture(GL_TEXTURE9);
glBindTexture(GL_TEXTURE_2D, texture_uv_[3]);
glUniform1i(glGetUniformLocation(program_[0], "map_4"), 9);
glActiveTexture(GL_TEXTURE10);
glBindTexture(GL_TEXTURE_2D, texture_uv_[4]);
glUniform1i(glGetUniformLocation(program_[0], "map_5"), 10);
glActiveTexture(GL_TEXTURE11);
glBindTexture(GL_TEXTURE_2D, texture_uv_[5]);
glUniform1i(glGetUniformLocation(program_[0], "map_6"), 11);
glUniform1f(glGetUniformLocation(program_[0], "width"), (float)FLAT_WIDTH);
glUniform1f(glGetUniformLocation(program_[0], "height"), (float)FLAT_HEIGHT);
float mat[16] = { 1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1};
glUniformMatrix4fv(glGetUniformLocation(program_[0], "rotate_mat4"), 1, GL_FALSE, mat);
}
void render::prepare_aux_vao(GLuint program)
{
static GLfloat vertex_data[] = {
-1.0f, 1.0f, 0.0f, 1.0f,
-1.0f, -1.0f, 0.0f, 1.0f,
1.0f, 1.0f, 0.0f, 1.0f,
1.0f, -1.0f, 0.0f, 1.0f,
};
static GLfloat uv_data[] = {
0.0f, 1.0f,
0.0f, 0.0f,
1.0f, 1.0f,
1.0f, 0.0f,
};
GLuint loc_position1 = glGetAttribLocation(program, "position");
GLuint loc_tex_coord = glGetAttribLocation(program, "vertTexCoord");
glGenVertexArraysOES(vao_aux_num_, vao_aux_);
glGenBuffers(vbo_aux_num_, vbo_aux_);
glBindVertexArrayOES(vao_aux_[0]);
glBindBuffer(GL_ARRAY_BUFFER, vbo_aux_[0]);
glBufferData(GL_ARRAY_BUFFER, sizeof(vertex_data), vertex_data, GL_STATIC_DRAW);
glEnableVertexAttribArray(loc_position1);
glVertexAttribPointer(loc_position1, 4, GL_FLOAT, GL_FALSE, 0, nullptr);
glBindBuffer(GL_ARRAY_BUFFER, vbo_aux_[1]);
glBufferData(GL_ARRAY_BUFFER, sizeof(uv_data), uv_data, GL_STATIC_DRAW);
glEnableVertexAttribArray(loc_tex_coord);
glVertexAttribPointer(loc_tex_coord, 2, GL_FLOAT, GL_FALSE, 0, nullptr);
glBindVertexArrayOES(0);
glBindBuffer(GL_ARRAY_BUFFER, 0);
}
//colin_insta360
void render::draw_master_vao(int w, int h, const float* mat, const std::vector<const unsigned char*> image) const
{
float default_mat[16] = { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1};
//如果没有读到陀螺仪数据,那么使用上一次的
if (mat)
{
glUniformMatrix4fv(glGetUniformLocation(program_[0], "rotate_mat4"), 1, GL_FALSE, mat);
}
else
{
glUniformMatrix4fv(glGetUniformLocation(program_[0], "rotate_mat4"), 1, GL_FALSE, default_mat);
}
if (mode_ == INS_MODE_PANORAMA)
{
glViewport(0, 0, w, h);
active_img_texture(image);
active_uv_texture(texture_uv_);
glBindVertexArrayOES(vao_[0]);
glDrawElements(GL_TRIANGLES,index_num_,GL_UNSIGNED_INT,0);
}
else
{
//top
glViewport(0, 0, w, h/2);
active_img_texture(image);
active_uv_texture(texture_uv_);
glBindVertexArrayOES(vao_[0]);
glDrawElements(GL_TRIANGLES,index_num_,GL_UNSIGNED_INT,0);
//bottom
glViewport(0, h/2, w, h/2);
active_uv_texture(texture_uv2_);
glDrawElements(GL_TRIANGLES,index_num_,GL_UNSIGNED_INT,0);
}
}
void render::draw_aux_vao(GLuint texture) const
{
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, texture);
glUniform1i(glGetUniformLocation(program_[1], "tex"), 0);
glBindVertexArrayOES(vao_aux_[0]);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
}
void render::active_img_texture(const std::vector<const unsigned char*>& image) const
{
if (image.size() == 6)
{
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, texture_[0]);
glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, in_width_, in_height_, 0, GL_RGBA, GL_UNSIGNED_BYTE, image[0]);
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, texture_[1]);
glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, in_width_, in_height_, 0, GL_RGBA, GL_UNSIGNED_BYTE, image[1]);
glActiveTexture(GL_TEXTURE2);
glBindTexture(GL_TEXTURE_2D, texture_[2]);
glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, in_width_, in_height_, 0, GL_RGBA, GL_UNSIGNED_BYTE, image[2]);
glActiveTexture(GL_TEXTURE3);
glBindTexture(GL_TEXTURE_2D, texture_[3]);
glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, in_width_, in_height_, 0, GL_RGBA, GL_UNSIGNED_BYTE, image[3]);
glActiveTexture(GL_TEXTURE4);
glBindTexture(GL_TEXTURE_2D, texture_[4]);
glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, in_width_, in_height_, 0, GL_RGBA, GL_UNSIGNED_BYTE, image[4]);
glActiveTexture(GL_TEXTURE5);
glBindTexture(GL_TEXTURE_2D, texture_[5]);
glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, in_width_, in_height_, 0, GL_RGBA, GL_UNSIGNED_BYTE, image[5]);
}
else if (image.size() == 0)
{
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_EXTERNAL_OES, texture_[0]);
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_EXTERNAL_OES, texture_[1]);
glActiveTexture(GL_TEXTURE2);
glBindTexture(GL_TEXTURE_EXTERNAL_OES, texture_[2]);
glActiveTexture(GL_TEXTURE3);
glBindTexture(GL_TEXTURE_EXTERNAL_OES, texture_[3]);
glActiveTexture(GL_TEXTURE4);
glBindTexture(GL_TEXTURE_EXTERNAL_OES, texture_[4]);
glActiveTexture(GL_TEXTURE5);
glBindTexture(GL_TEXTURE_EXTERNAL_OES, texture_[5]);
}
else
{
LOGERR("invalid img cnt:%d", image.size());
}
}
void render::active_uv_texture(const GLuint* texture_uv) const
{
glActiveTexture(GL_TEXTURE6);
glBindTexture(GL_TEXTURE_2D, texture_uv[0]);
glUniform1i(glGetUniformLocation(program_[0], "map_1"), 6);
glActiveTexture(GL_TEXTURE7);
glBindTexture(GL_TEXTURE_2D, texture_uv[1]);
glUniform1i(glGetUniformLocation(program_[0], "map_2"), 7);
glActiveTexture(GL_TEXTURE8);
glBindTexture(GL_TEXTURE_2D, texture_uv[2]);
glUniform1i(glGetUniformLocation(program_[0], "map_3"), 8);
glActiveTexture(GL_TEXTURE9);
glBindTexture(GL_TEXTURE_2D, texture_uv[3]);
glUniform1i(glGetUniformLocation(program_[0], "map_4"), 9);
glActiveTexture(GL_TEXTURE10);
glBindTexture(GL_TEXTURE_2D, texture_uv[4]);
glUniform1i(glGetUniformLocation(program_[0], "map_5"), 10);
glActiveTexture(GL_TEXTURE11);
glBindTexture(GL_TEXTURE_2D, texture_uv[5]);
glUniform1i(glGetUniformLocation(program_[0], "map_6"), 11);
}
// void render::prepare_vao_cube()
// {
// int out_width;
// int out_height;
// float* uv[texture_num_] = {nullptr};
// float* alpha[texture_num_] = {nullptr};
// if (mode_ == INS_MODE_PANORAMA)
// {
// out_width = CUBE_WIDTH*3;
// out_height = CUBE_HEIGHT*2;
// std::string offset;
// if (in_width_*9 == in_height_*16)
// {
// offset = XML_GET_STRING(INS_CONFIG_OFFSET, INS_CONFIG_OFFSET_PANO_16_9);
// LOGINFO("pano 16:9 offset:%s", offset.c_str());
// }
// else
// {
// offset = XML_GET_STRING(INS_CONFIG_OFFSET, INS_CONFIG_OFFSET_PANO_4_3);
// LOGINFO("pano 4:3 offset:%s", offset.c_str());
// }
// ins::Dewarp map;
// map.setOffset(offset);
// std::vector<int> v_width(texture_num_, in_width_);
// std::vector<int> v_height(texture_num_, in_height_);
// map.init(v_width, v_height, CUBE_WIDTH, CUBE_HEIGHT);
// for (int i = 0; i < texture_num_; i++)
// {
// uv[i] = new float[out_width*out_height*2];
// alpha[i] = new float[out_width*out_height]();
// float* uv_left = map.getCubeMap(i, ins::CUBETYPE::LEFT, ins::MAPTYPE::OPENGL);
// float* uv_right = map.getCubeMap(i, ins::CUBETYPE::RIGHT, ins::MAPTYPE::OPENGL);
// float* uv_top = map.getCubeMap(i, ins::CUBETYPE::TOP, ins::MAPTYPE::OPENGL);
// float* uv_bottom = map.getCubeMap(i, ins::CUBETYPE::BOTTOM, ins::MAPTYPE::OPENGL);
// float* uv_back = map.getCubeMap(i, ins::CUBETYPE::BACK, ins::MAPTYPE::OPENGL);
// float* uv_front = map.getCubeMap(i, ins::CUBETYPE::FRONT, ins::MAPTYPE::OPENGL);
// float* alpha_left = map.getCubeAlpha(i, ins::CUBETYPE::LEFT, 0, ins::MAPTYPE::OPENGL);
// float* alpha_right = map.getCubeAlpha(i, ins::CUBETYPE::RIGHT, 0, ins::MAPTYPE::OPENGL);
// float* alpha_top = map.getCubeAlpha(i, ins::CUBETYPE::TOP, 0, ins::MAPTYPE::OPENGL);
// float* alpha_bottom = map.getCubeAlpha(i, ins::CUBETYPE::BOTTOM, 0, ins::MAPTYPE::OPENGL);
// float* alpha_back = map.getCubeAlpha(i, ins::CUBETYPE::BACK, 0, ins::MAPTYPE::OPENGL);
// float* alpha_front = map.getCubeAlpha(i, ins::CUBETYPE::FRONT, 0, ins::MAPTYPE::OPENGL);
// int uv_offset = 0;
// int alpha_offset = 0;
// for (int j = 0; j < CUBE_HEIGHT; j++)
// {
// memcpy(uv[i]+uv_offset, uv_left+j*CUBE_WIDTH*2, CUBE_WIDTH*2*sizeof(float));
// uv_offset += CUBE_WIDTH*2;
// memcpy(uv[i]+uv_offset, uv_right+j*CUBE_WIDTH*2, CUBE_WIDTH*2*sizeof(float));
// uv_offset += CUBE_WIDTH*2;
// memcpy(uv[i]+uv_offset, uv_top+j*CUBE_WIDTH*2, CUBE_WIDTH*2*sizeof(float));
// uv_offset += CUBE_WIDTH*2;
// memcpy(alpha[i]+alpha_offset, alpha_left+j*CUBE_WIDTH, CUBE_WIDTH*sizeof(float));
// alpha_offset += CUBE_WIDTH;
// memcpy(alpha[i]+alpha_offset, alpha_right+j*CUBE_WIDTH, CUBE_WIDTH*sizeof(float));
// alpha_offset += CUBE_WIDTH;
// memcpy(alpha[i]+alpha_offset, alpha_top+j*CUBE_WIDTH, CUBE_WIDTH*sizeof(float));
// alpha_offset += CUBE_WIDTH;
// }
// for (int j = 0; j < CUBE_HEIGHT; j++)
// {
// memcpy(uv[i]+uv_offset, uv_bottom+j*CUBE_WIDTH*2, CUBE_WIDTH*2*sizeof(float));
// uv_offset += CUBE_WIDTH*2;
// memcpy(uv[i]+uv_offset, uv_back+j*CUBE_WIDTH*2, CUBE_WIDTH*2*sizeof(float));
// uv_offset += CUBE_WIDTH*2;
// memcpy(uv[i]+uv_offset, uv_front+j*CUBE_WIDTH*2, CUBE_WIDTH*2*sizeof(float));
// uv_offset += CUBE_WIDTH*2;
// memcpy(alpha[i]+alpha_offset, alpha_bottom+j*CUBE_WIDTH, CUBE_WIDTH*sizeof(float));
// alpha_offset += CUBE_WIDTH;
// memcpy(alpha[i]+alpha_offset, alpha_back+j*CUBE_WIDTH, CUBE_WIDTH*sizeof(float));
// alpha_offset += CUBE_WIDTH;
// memcpy(alpha[i]+alpha_offset, alpha_front+j*CUBE_WIDTH, CUBE_WIDTH*sizeof(float));
// alpha_offset += CUBE_WIDTH;
// }
// }
// }
// else
// {
// out_width = CUBE_WIDTH*3;
// out_height = CUBE_HEIGHT*4;
// std::vector<int> v_width(texture_num_, in_width_);
// std::vector<int> v_height(texture_num_, in_height_);
// std::string offset_left = XML_GET_STRING(INS_CONFIG_OFFSET, INS_CONFIG_OFFSET_3D_LEFT);
// LOGINFO("3d left offset:%s", offset_left.c_str());
// ins::Dewarp map_left;
// map_left.setOffset(offset_left);
// map_left.init(v_width, v_height, CUBE_WIDTH, CUBE_HEIGHT);
// std::string offset_right = XML_GET_STRING(INS_CONFIG_OFFSET, INS_CONFIG_OFFSET_3D_RIGHT);
// LOGINFO("3d right offset:%s", offset_right.c_str());
// ins::Dewarp map_right;
// map_right.setOffset(offset_right);
// map_right.init(v_width, v_height, CUBE_WIDTH, CUBE_HEIGHT);
// for (int i = 0; i < texture_num_; i++)
// {
// uv[i] = new float[out_width*out_height*2];
// alpha[i] = new float[out_width*out_height]();
// float* uv_left = map_right.getCubeMap(i, ins::CUBETYPE::LEFT, ins::MAPTYPE::OPENGL);
// float* uv_right = map_right.getCubeMap(i, ins::CUBETYPE::RIGHT, ins::MAPTYPE::OPENGL);
// float* uv_top = map_right.getCubeMap(i, ins::CUBETYPE::TOP, ins::MAPTYPE::OPENGL);
// float* uv_bottom = map_right.getCubeMap(i, ins::CUBETYPE::BOTTOM, ins::MAPTYPE::OPENGL);
// float* uv_back = map_right.getCubeMap(i, ins::CUBETYPE::BACK, ins::MAPTYPE::OPENGL);
// float* uv_front = map_right.getCubeMap(i, ins::CUBETYPE::FRONT, ins::MAPTYPE::OPENGL);
// float* alpha_left = map_right.getCubeAlpha(i, ins::CUBETYPE::LEFT, 0, ins::MAPTYPE::OPENGL);
// float* alpha_right = map_right.getCubeAlpha(i, ins::CUBETYPE::RIGHT, 0, ins::MAPTYPE::OPENGL);
// float* alpha_top = map_right.getCubeAlpha(i, ins::CUBETYPE::TOP, 0, ins::MAPTYPE::OPENGL);
// float* alpha_bottom = map_right.getCubeAlpha(i, ins::CUBETYPE::BOTTOM, 0, ins::MAPTYPE::OPENGL);
// float* alpha_back = map_right.getCubeAlpha(i, ins::CUBETYPE::BACK, 0, ins::MAPTYPE::OPENGL);
// float* alpha_front = map_right.getCubeAlpha(i, ins::CUBETYPE::FRONT, 0, ins::MAPTYPE::OPENGL);
// int uv_offset = 0;
// int alpha_offset = 0;
// for (int j = 0; j < CUBE_HEIGHT; j++)
// {
// memcpy(uv[i]+uv_offset, uv_left+j*CUBE_WIDTH*2, CUBE_WIDTH*2*sizeof(float));
// uv_offset += CUBE_WIDTH*2;
// memcpy(uv[i]+uv_offset, uv_right+j*CUBE_WIDTH*2, CUBE_WIDTH*2*sizeof(float));
// uv_offset += CUBE_WIDTH*2;
// memcpy(uv[i]+uv_offset, uv_top+j*CUBE_WIDTH*2, CUBE_WIDTH*2*sizeof(float));
// uv_offset += CUBE_WIDTH*2;
// memcpy(alpha[i]+alpha_offset, alpha_left+j*CUBE_WIDTH, CUBE_WIDTH*sizeof(float));
// alpha_offset += CUBE_WIDTH;
// memcpy(alpha[i]+alpha_offset, alpha_right+j*CUBE_WIDTH, CUBE_WIDTH*sizeof(float));
// alpha_offset += CUBE_WIDTH;
// memcpy(alpha[i]+alpha_offset, alpha_top+j*CUBE_WIDTH, CUBE_WIDTH*sizeof(float));
// alpha_offset += CUBE_WIDTH;
// }
// for (int j = 0; j < CUBE_HEIGHT; j++)
// {
// memcpy(uv[i]+uv_offset, uv_bottom+j*CUBE_WIDTH*2, CUBE_WIDTH*2*sizeof(float));
// uv_offset += CUBE_WIDTH*2;
// memcpy(uv[i]+uv_offset, uv_back+j*CUBE_WIDTH*2, CUBE_WIDTH*2*sizeof(float));
// uv_offset += CUBE_WIDTH*2;
// memcpy(uv[i]+uv_offset, uv_front+j*CUBE_WIDTH*2, CUBE_WIDTH*2*sizeof(float));
// uv_offset += CUBE_WIDTH*2;
// memcpy(alpha[i]+alpha_offset, alpha_bottom+j*CUBE_WIDTH, CUBE_WIDTH*sizeof(float));
// alpha_offset += CUBE_WIDTH;
// memcpy(alpha[i]+alpha_offset, alpha_back+j*CUBE_WIDTH, CUBE_WIDTH*sizeof(float));
// alpha_offset += CUBE_WIDTH;
// memcpy(alpha[i]+alpha_offset, alpha_front+j*CUBE_WIDTH, CUBE_WIDTH*sizeof(float));
// alpha_offset += CUBE_WIDTH;
// }
// uv_left = map_left.getCubeMap(i, ins::CUBETYPE::LEFT, ins::MAPTYPE::OPENGL);
// uv_right = map_left.getCubeMap(i, ins::CUBETYPE::RIGHT, ins::MAPTYPE::OPENGL);
// uv_top = map_left.getCubeMap(i, ins::CUBETYPE::TOP, ins::MAPTYPE::OPENGL);
// uv_bottom = map_left.getCubeMap(i, ins::CUBETYPE::BOTTOM, ins::MAPTYPE::OPENGL);
// uv_back = map_left.getCubeMap(i, ins::CUBETYPE::BACK, ins::MAPTYPE::OPENGL);
// uv_front = map_left.getCubeMap(i, ins::CUBETYPE::FRONT, ins::MAPTYPE::OPENGL);
// alpha_left = map_left.getCubeAlpha(i, ins::CUBETYPE::LEFT, 0, ins::MAPTYPE::OPENGL);
// alpha_right = map_left.getCubeAlpha(i, ins::CUBETYPE::RIGHT, 0, ins::MAPTYPE::OPENGL);
// alpha_top = map_left.getCubeAlpha(i, ins::CUBETYPE::TOP, 0, ins::MAPTYPE::OPENGL);
// alpha_bottom = map_left.getCubeAlpha(i, ins::CUBETYPE::BOTTOM, 0, ins::MAPTYPE::OPENGL);
// alpha_back = map_left.getCubeAlpha(i, ins::CUBETYPE::BACK, 0, ins::MAPTYPE::OPENGL);
// alpha_front = map_left.getCubeAlpha(i, ins::CUBETYPE::FRONT, 0, ins::MAPTYPE::OPENGL);
// for (int j = 0; j < CUBE_HEIGHT; j++)
// {
// memcpy(uv[i]+uv_offset, uv_left+j*CUBE_WIDTH*2, CUBE_WIDTH*2*sizeof(float));
// uv_offset += CUBE_WIDTH*2;
// memcpy(uv[i]+uv_offset, uv_right+j*CUBE_WIDTH*2, CUBE_WIDTH*2*sizeof(float));
// uv_offset += CUBE_WIDTH*2;
// memcpy(uv[i]+uv_offset, uv_top+j*CUBE_WIDTH*2, CUBE_WIDTH*2*sizeof(float));
// uv_offset += CUBE_WIDTH*2;
// memcpy(alpha[i]+alpha_offset, alpha_left+j*CUBE_WIDTH, CUBE_WIDTH*sizeof(float));
// alpha_offset += CUBE_WIDTH;
// memcpy(alpha[i]+alpha_offset, alpha_right+j*CUBE_WIDTH, CUBE_WIDTH*sizeof(float));
// alpha_offset += CUBE_WIDTH;
// memcpy(alpha[i]+alpha_offset, alpha_top+j*CUBE_WIDTH, CUBE_WIDTH*sizeof(float));
// alpha_offset += CUBE_WIDTH;
// }
// for (int j = 0; j < CUBE_HEIGHT; j++)
// {
// memcpy(uv[i]+uv_offset, uv_bottom+j*CUBE_WIDTH*2, CUBE_WIDTH*2*sizeof(float));
// uv_offset += CUBE_WIDTH*2;
// memcpy(uv[i]+uv_offset, uv_back+j*CUBE_WIDTH*2, CUBE_WIDTH*2*sizeof(float));
// uv_offset += CUBE_WIDTH*2;
// memcpy(uv[i]+uv_offset, uv_front+j*CUBE_WIDTH*2, CUBE_WIDTH*2*sizeof(float));
// uv_offset += CUBE_WIDTH*2;
// memcpy(alpha[i]+alpha_offset, alpha_bottom+j*CUBE_WIDTH, CUBE_WIDTH*sizeof(float));
// alpha_offset += CUBE_WIDTH;
// memcpy(alpha[i]+alpha_offset, alpha_back+j*CUBE_WIDTH, CUBE_WIDTH*sizeof(float));
// alpha_offset += CUBE_WIDTH;
// memcpy(alpha[i]+alpha_offset, alpha_front+j*CUBE_WIDTH, CUBE_WIDTH*sizeof(float));
// alpha_offset += CUBE_WIDTH;
// }
// }
// }
// int k = 0, n = 0, m = 0;
// float* vetex_data = new float[out_width*out_height*4]();
// for (int j = 0; j < out_height; j++)
// {
// for (int i = 0; i < out_width; i++)
// {
// vetex_data[k++] = 2.0*(i-i/CUBE_WIDTH)/(float)(out_width-out_width/CUBE_WIDTH) - 1.0;
// vetex_data[k++] = 1.0 - 2.0*(j-j/CUBE_HEIGHT)/((float)(out_height-out_height/CUBE_HEIGHT));
// vetex_data[k++] = 0;
// vetex_data[k++] = 1.0;
// }
// }
// index_num_ = (out_width-out_width/CUBE_WIDTH)*(out_height-out_height/CUBE_HEIGHT)*2*3;
// GLuint* index_data = new GLuint[index_num_]();
// for (int j = 0, k = 0; j < out_height - 1; j++)
// {
// if ((j+1)%CUBE_HEIGHT == 0) continue;
// for (int i = 0; i < out_width - 1; i++)
// {
// if ((i+1)%CUBE_WIDTH == 0) continue;
// GLuint tmp1 = i+j*out_width;
// GLuint tmp2 = i+(j+1)*out_width;
// index_data[k++] = tmp1;
// index_data[k++] = tmp2;
// index_data[k++] = tmp2+1;
// index_data[k++] = tmp1;
// index_data[k++] = tmp1+1;
// index_data[k++] = tmp2+1;
// }
// } |
0a4f14d9a4e0675d6ed8dda658e79ffbf45453e6 | b23618e118013a752ebd345b83a72786dd90d776 | /Classes/Main.h | 1f43c8712c28e6f6991193ddae01d5d82793adec | [] | no_license | alec-hewitt/SpacePace | 5be4a470b222f90c1787e413e75e8d9cd18a2dd7 | c4e59adb2eb0c845f2d006d27622f38239492754 | refs/heads/master | 2016-09-06T09:39:22.840716 | 2014-10-08T01:49:58 | 2014-10-08T01:49:58 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,068 | h | Main.h | #ifndef __MAIN_H__
#define __MAIN_H__
#include "cocos2d.h"
#include <base/CCUserDefault.h>
class Main : public cocos2d::Layer
{
public:
// there's no 'id' in cpp, so we recommend returning the class instance pointer
static cocos2d::Scene* createScene();
// Here's a difference. Method 'init' in cocos2d-x returns bool, instead of returning 'id' in cocos2d-iphone
virtual bool init();
// implement the "static create()" method manually
CREATE_FUNC(Main);
//Main stuff
cocos2d::Sprite *player; //player
cocos2d::Sprite *enemy1; //enemy1
cocos2d::Sprite *enemy2; //enemy2
cocos2d::Sprite *enemy3; //enemy3
bool alive;
float randX;
int score;
cocos2d::LabelTTF *scoreLabel;
const char *_SCORE;
void update(float dt); //frame update 60/s stable
void OnAcceleration(cocos2d::Acceleration *acc, cocos2d::Event *event);
float getDistance(float enemyx, float enemyy, float playerx, float playery);
double hps;
cocos2d::CCParticleSystemQuad *emitter;
};
#endif // __MAIN_H__
|
bb8b966c6e15b7d0f99e8d8d3f2cb05daf187180 | 1bd7c74e8c7ad1ce23ea8b62a012cf1ace832e32 | /A_Orac_and_Factors.cpp | 67d35d35b2af93f9b60fc16fa6d03c5f3eb33f0d | [] | no_license | Harshit-Kumar-Singh/Code-Forces | 3962b004fed8a35fe41d3a2a83f1b7af1054e34c | 04be6f85d0ef5fa66ae0e85a2cce07053a8ac810 | refs/heads/master | 2023-04-10T03:36:52.467749 | 2021-04-24T11:40:10 | 2021-04-24T11:40:10 | 361,119,577 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 517 | cpp | A_Orac_and_Factors.cpp | #include <bits/stdc++.h>
using namespace std;
typedef unsigned long long int ll;
void solve(){
ll n,k;
cin >> n >> k;
ll temp =-1;
for(int i=2;i<=n;i++){
if(n%i==0){
temp=i;
break;
}
}
// cout<<n<<endl;
if(n&1)
{
n = n+temp;
k--;
}
cout<<(n+k*2)<<endl;
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
ll test;
cin >> test;
while(test--)
solve();
return 0;
} |
b1346efc948cad564e7d219a2693053ba814c38b | 464e9284f54febf639d04fd4f98e11c04dc03795 | /gamepad.h | b9d87db428996eaffb7cbae0be3e8c198b75b412 | [
"BSD-2-Clause"
] | permissive | ElectricToy/gamepad | 283611c1b581f76086728f4dbf6b0231fe7687ea | 9de4529cf5522a979064f1e276ecd1267e7bb7c7 | refs/heads/master | 2021-09-24T00:04:46.173997 | 2018-09-29T19:25:22 | 2018-09-29T19:25:22 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,401 | h | gamepad.h | /*
* Written by Simon Fuhrmann.
* See LICENSE file for details.
*/
#ifndef GAMEPAD_HEADER
#define GAMEPAD_HEADER
#include <functional>
#include <memory>
#include <string>
#include <vector>
namespace gamepad {
struct Device {
unsigned int device_id = 0;
int vendor_id = 0;
int product_id = 0;
std::string description;
std::vector<float> axes;
std::vector<bool> buttons;
};
class System {
public:
// The attached handler signature.
typedef std::function<void(Device*)> AttachedHandler;
// The detached handler signature.
typedef std::function<void(Device*)> DetachedHandler;
// The button handler signature (device, button ID, timestamp).
typedef std::function<void(Device*, int, double)> ButtonHandler;
// The axis handler signature (device, axis ID, value, old value, timestamp).
typedef std::function<void(Device*, int, float, float, double)> AxisHandler;
public:
static std::unique_ptr<System> Create();
virtual ~System() = default;
// Registers a handler that is called when a pad is attached.
void RegisterAttachHandler(AttachedHandler handler);
// Registers a handler that is called when a pad is detached.
void RegisterDetachHandler(DetachedHandler handler);
// Registers a handler for button down events.
void RegisterButtonDownHandler(ButtonHandler handler);
// Registers a handler for button up events.
void RegisterButtonUpHandler(ButtonHandler handler);
// Registers a handler for axis move events.
void RegisterAxisMoveHandler(AxisHandler handler);
// Processes all events and invokes the corresponding handler functions.
virtual void ProcessEvents() = 0;
// Scans for new devices and invokes the attach handler for each new device.
// The cost of this call depends on the implementation.
// MacOS: Essentially free, devices are attached using IOKit callbacks.
// Linux: Needs to scan /dev/input for devices not already attached.
virtual void ScanForDevices() = 0;
protected:
System() = default;
void HandleButtonEvent(Device* device, int button_id, int value);
void HandleAxisEvent(Device* device, int axis_id, int value,
int min, int max, int fuzz, int flat);
AttachedHandler attached_handler_;
DetachedHandler detached_handler_;
ButtonHandler button_up_handler_;
ButtonHandler button_down_handler_;
AxisHandler axis_move_handler_;
};
} // namespace pad
#endif // GAMEPAD_HEADER
|
784d8e1dba3594402917380f975b08d44af73aa3 | 2483735d584c7f3e88d0c387883e8e51db525c9f | /src/test/LOGL/1/2_tri/main.cpp | 9f2b73f3d3145c8e8f6e93f43aedc2bc0fa1a0d6 | [
"MIT"
] | permissive | Ubpa/UGL | 72edbecbee38804f651b3249b9c942fd25910038 | 4db5b8a090ffa1018e52e77209b8723289798531 | refs/heads/master | 2021-05-18T03:14:22.660298 | 2020-05-02T17:19:00 | 2020-05-02T17:19:00 | 251,078,873 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,747 | cpp | main.cpp | #include <glad/glad.h>
#include <GLFW/glfw3.h>
#include <iostream>
#include <UGL/UGL.h>
using namespace Ubpa;
void framebuffer_size_callback(GLFWwindow* window, int width, int height);
void processInput(GLFWwindow* window);
// settings
const unsigned int SCR_WIDTH = 800;
const unsigned int SCR_HEIGHT = 600;
const char* vertexShaderSource = "#version 330 core\n"
"layout (location = 0) in vec3 va0;\n"
"layout (location = 1) in vec3 va1;\n"
"void main()\n"
"{\n"
" gl_Position = vec4(va0+va1, 1.0);\n"
"}\0";
const char* fragmentShaderSource = "#version 330 core\n"
"out vec4 FragColor;\n"
"void main()\n"
"{\n"
" FragColor = vec4(1.0f, 0.5f, 0.2f, 1.0f);\n"
"}\n\0";
int main()
{
// glfw: initialize and configure
// ------------------------------
glfwInit();
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
#ifdef __APPLE__
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); // uncomment this statement to fix compilation on OS X
#endif
// glfw window creation
// --------------------
GLFWwindow* window = glfwCreateWindow(SCR_WIDTH, SCR_HEIGHT, "LearnOpenGL", NULL, NULL);
if (window == NULL)
{
std::cout << "Failed to create GLFW window" << std::endl;
glfwTerminate();
return -1;
}
glfwMakeContextCurrent(window);
glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
// glad: load all OpenGL function pointers
// ---------------------------------------
if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress))
{
std::cout << "Failed to initialize GLAD" << std::endl;
return -1;
}
// build and compile our shader program
// ------------------------------------
gl::Shader vs(gl::ShaderType::VertexShader); vs.InitSrc(vertexShaderSource);
gl::Shader fs(gl::ShaderType::FragmentShader); fs.InitSrc(fragmentShaderSource);
gl::Program program(&vs, &fs);
// set up vertex data (and buffer(s)) and configure vertex attributes
// ------------------------------------------------------------------
float vertices[] = {
0.5f, 0.5f, 0.0f, // top right
0.5f, -0.5f, 0.0f, // bottom right
-0.5f, -0.5f, 0.0f, // bottom left
-0.5f, 0.5f, 0.0f // top left
};
float offset[] = {
0.0f, 0.1f, 0.0f, // top right
0.0f, -0.1f, 0.0f, // bottom right
0.0f, 0.0f, 0.0f, // bottom left
0.0f, 0.0f, 0.0f // top left
};
unsigned int indices[] = { // note that we start from 0!
0, 1, 3, // first Triangle
1, 2, 3 // second Triangle
};
gl::Mesh obj(gl::BasicPrimitiveType::Triangles, 2, 4, indices,
{ std::make_tuple(vertices, 3), std::make_tuple(offset, 3) });
// uncomment this call to draw in wireframe polygons.
//glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
// render loop
// -----------
while (!glfwWindowShouldClose(window))
{
// input
// -----
processInput(window);
// render
// ------
gl::ClearColor({ 0.2f, 0.3f, 0.3f, 1.0f });
gl::Clear(gl::BufferSelectBit::ColorBufferBit);
obj.Draw(program);
// glfw: swap buffers and poll IO events (keys pressed/released, mouse moved etc.)
// -------------------------------------------------------------------------------
glfwSwapBuffers(window);
glfwPollEvents();
}
// optional: de-allocate all resources once they've outlived their purpose:
// ------------------------------------------------------------------------
// glfw: terminate, clearing all previously allocated GLFW resources.
// ------------------------------------------------------------------
glfwTerminate();
return 0;
}
// process all input: query GLFW whether relevant keys are pressed/released this frame and react accordingly
// ---------------------------------------------------------------------------------------------------------
void processInput(GLFWwindow* window)
{
if (glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS)
glfwSetWindowShouldClose(window, true);
}
// glfw: whenever the window size changed (by OS or user resize) this callback function executes
// ---------------------------------------------------------------------------------------------
void framebuffer_size_callback(GLFWwindow* window, int width, int height)
{
// make sure the viewport matches the new window dimensions; note that width and
// height will be significantly larger than specified on retina displays.
gl::Viewport({ 0, 0 }, width, height);
} |
b54cea052d0d68129e6c202d3080f504730f0f37 | ed7e1851605dc417f471b24bceaa4efe3ebd577e | /Export/mac64/cpp/release/obj/src/lime/app/Future.cpp | 48fa9ae52f2ee14d2099baa33a3ba72198e8cb49 | [] | no_license | matthewswallace/StableUITest | 60d88c31540b07b68fc5867cb42901676012cf31 | 8ad46db8245bb8a9bc38b3525dfcdfe90c78b845 | refs/heads/master | 2021-01-12T14:41:07.354460 | 2016-10-26T23:13:43 | 2016-10-26T23:13:43 | 72,050,029 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | true | 15,621 | cpp | Future.cpp | // Generated by Haxe 3.3.0
#include <hxcpp.h>
#ifndef INCLUDED_Sys
#include <Sys.h>
#endif
#ifndef INCLUDED_lime_app_Future
#include <lime/app/Future.h>
#endif
#ifndef INCLUDED_lime_app_Promise
#include <lime/app/Promise.h>
#endif
#ifndef INCLUDED_lime_app__Future_FutureWork
#include <lime/app/_Future/FutureWork.h>
#endif
#ifndef INCLUDED_lime_system_System
#include <lime/system/System.h>
#endif
namespace lime{
namespace app{
void Future_obj::__construct( ::Dynamic work){
HX_STACK_FRAME("lime.app.Future","new",0xc0e3b2bb,"lime.app.Future.new","lime/app/Future.hx",26,0x058e0853)
HX_STACK_THIS(this)
HX_STACK_ARG(work,"work")
HXLINE( 26) Bool _hx_tmp = hx::IsNotNull( work );
HXDLIN( 26) if (_hx_tmp) {
HXLINE( 28) HX_VARI( ::lime::app::Promise,promise) = ::lime::app::Promise_obj::__new();
HXLINE( 29) promise->future = hx::ObjectPtr<OBJ_>(this);
HXLINE( 31) ::lime::app::_Future::FutureWork_obj::queue( ::Dynamic(hx::Anon_obj::Create(2)
->setFixed(0,HX_("promise",9b,cd,e9,f7),promise)
->setFixed(1,HX_("work",d1,01,fd,4e),work)));
}
}
Dynamic Future_obj::__CreateEmpty() { return new Future_obj; }
hx::ObjectPtr< Future_obj > Future_obj::__new( ::Dynamic work)
{
hx::ObjectPtr< Future_obj > _hx_result = new Future_obj();
_hx_result->__construct(work);
return _hx_result;
}
Dynamic Future_obj::__Create(hx::DynamicArray inArgs)
{
hx::ObjectPtr< Future_obj > _hx_result = new Future_obj();
_hx_result->__construct(inArgs[0]);
return _hx_result;
}
::lime::app::Future Future_obj::onComplete( ::Dynamic listener){
HX_STACK_FRAME("lime.app.Future","onComplete",0x3a7dc3fd,"lime.app.Future.onComplete","lime/app/Future.hx",38,0x058e0853)
HX_STACK_THIS(this)
HX_STACK_ARG(listener,"listener")
HXLINE( 40) Bool _hx_tmp = hx::IsNotNull( listener );
HXDLIN( 40) if (_hx_tmp) {
HXLINE( 42) Bool _hx_tmp1 = this->isComplete;
HXDLIN( 42) if (_hx_tmp1) {
HXLINE( 44) listener(this->value);
}
else {
HXLINE( 46) Bool _hx_tmp2 = !(this->isError);
HXDLIN( 46) if (_hx_tmp2) {
HXLINE( 48) Bool _hx_tmp3 = hx::IsNull( this->_hx___completeListeners );
HXDLIN( 48) if (_hx_tmp3) {
HXLINE( 50) this->_hx___completeListeners = ::Array_obj< ::Dynamic>::__new();
}
HXLINE( 54) this->_hx___completeListeners->push(listener);
}
}
}
HXLINE( 60) return hx::ObjectPtr<OBJ_>(this);
}
HX_DEFINE_DYNAMIC_FUNC1(Future_obj,onComplete,return )
::lime::app::Future Future_obj::onError( ::Dynamic listener){
HX_STACK_FRAME("lime.app.Future","onError",0xb2071604,"lime.app.Future.onError","lime/app/Future.hx",65,0x058e0853)
HX_STACK_THIS(this)
HX_STACK_ARG(listener,"listener")
HXLINE( 67) Bool _hx_tmp = hx::IsNotNull( listener );
HXDLIN( 67) if (_hx_tmp) {
HXLINE( 69) Bool _hx_tmp1 = this->isError;
HXDLIN( 69) if (_hx_tmp1) {
HXLINE( 71) listener(this->error);
}
else {
HXLINE( 73) Bool _hx_tmp2 = !(this->isComplete);
HXDLIN( 73) if (_hx_tmp2) {
HXLINE( 75) Bool _hx_tmp3 = hx::IsNull( this->_hx___errorListeners );
HXDLIN( 75) if (_hx_tmp3) {
HXLINE( 77) this->_hx___errorListeners = ::Array_obj< ::Dynamic>::__new();
}
HXLINE( 81) this->_hx___errorListeners->push(listener);
}
}
}
HXLINE( 87) return hx::ObjectPtr<OBJ_>(this);
}
HX_DEFINE_DYNAMIC_FUNC1(Future_obj,onError,return )
::lime::app::Future Future_obj::onProgress( ::Dynamic listener){
HX_STACK_FRAME("lime.app.Future","onProgress",0x40e0baf1,"lime.app.Future.onProgress","lime/app/Future.hx",92,0x058e0853)
HX_STACK_THIS(this)
HX_STACK_ARG(listener,"listener")
HXLINE( 94) Bool _hx_tmp = hx::IsNotNull( listener );
HXDLIN( 94) if (_hx_tmp) {
HXLINE( 96) Bool _hx_tmp1 = hx::IsNull( this->_hx___progressListeners );
HXDLIN( 96) if (_hx_tmp1) {
HXLINE( 98) this->_hx___progressListeners = ::Array_obj< ::Dynamic>::__new();
}
HXLINE( 102) this->_hx___progressListeners->push(listener);
}
HXLINE( 106) return hx::ObjectPtr<OBJ_>(this);
}
HX_DEFINE_DYNAMIC_FUNC1(Future_obj,onProgress,return )
::lime::app::Future Future_obj::ready(hx::Null< Int > __o_waitTime){
Int waitTime = __o_waitTime.Default(-1);
HX_STACK_FRAME("lime.app.Future","ready",0xd4cc0f7e,"lime.app.Future.ready","lime/app/Future.hx",128,0x058e0853)
HX_STACK_THIS(this)
HX_STACK_ARG(waitTime,"waitTime")
HXLINE( 128) Bool _hx_tmp;
HXDLIN( 128) if (!(this->isComplete)) {
HXLINE( 128) _hx_tmp = this->isError;
}
else {
HXLINE( 128) _hx_tmp = true;
}
HXDLIN( 128) if (_hx_tmp) {
HXLINE( 130) return hx::ObjectPtr<OBJ_>(this);
}
else {
HXLINE( 134) HX_VARI( Int,time) = ::lime::_hx_system::System_obj::getTimer();
HXLINE( 135) HX_VAR( Int,end);
HXDLIN( 135) if ((waitTime > (int)-1)) {
HXLINE( 135) end = (time + waitTime);
}
else {
HXLINE( 135) end = time;
}
HXLINE( 137) while(true){
HXLINE( 137) Bool _hx_tmp1;
HXDLIN( 137) Bool _hx_tmp2;
HXDLIN( 137) if (!(this->isComplete)) {
HXLINE( 137) _hx_tmp2 = !(this->isError);
}
else {
HXLINE( 137) _hx_tmp2 = false;
}
HXDLIN( 137) if (_hx_tmp2) {
HXLINE( 137) _hx_tmp1 = (time <= end);
}
else {
HXLINE( 137) _hx_tmp1 = false;
}
HXDLIN( 137) if (!(_hx_tmp1)) {
HXLINE( 137) goto _hx_goto_0;
}
HXLINE( 140) ::Sys_obj::sleep(((Float)0.01));
HXLINE( 143) time = ::lime::_hx_system::System_obj::getTimer();
}
_hx_goto_0:;
HXLINE( 147) return hx::ObjectPtr<OBJ_>(this);
}
HXLINE( 128) return null();
}
HX_DEFINE_DYNAMIC_FUNC1(Future_obj,ready,return )
::Dynamic Future_obj::result(hx::Null< Int > __o_waitTime){
Int waitTime = __o_waitTime.Default(-1);
HX_STACK_FRAME("lime.app.Future","result",0x69b43162,"lime.app.Future.result","lime/app/Future.hx",156,0x058e0853)
HX_STACK_THIS(this)
HX_STACK_ARG(waitTime,"waitTime")
HXLINE( 158) this->ready(waitTime);
HXLINE( 160) if (this->isComplete) {
HXLINE( 162) return this->value;
}
else {
HXLINE( 166) return null();
}
HXLINE( 160) return null();
}
HX_DEFINE_DYNAMIC_FUNC1(Future_obj,result,return )
::lime::app::Future Future_obj::then( ::Dynamic next){
HX_STACK_FRAME("lime.app.Future","then",0x0a523022,"lime.app.Future.then","lime/app/Future.hx",175,0x058e0853)
HX_STACK_THIS(this)
HX_STACK_ARG(next,"next")
HXLINE( 175) Bool _hx_tmp = this->isComplete;
HXDLIN( 175) if (_hx_tmp) {
HXLINE( 177) return ( ( ::lime::app::Future)(next(this->value)) );
}
else {
HXLINE( 179) Bool _hx_tmp1 = this->isError;
HXDLIN( 179) if (_hx_tmp1) {
HXLINE( 181) HX_VARI( ::lime::app::Future,future) = ::lime::app::Future_obj::__new(null());
HXLINE( 182) future->onError(this->error);
HXLINE( 183) return future;
}
else {
HX_BEGIN_LOCAL_FUNC_S2(hx::LocalFunc,_hx_Closure_0, ::Dynamic,next, ::lime::app::Promise,promise) HXARGC(1)
void _hx_run( ::Dynamic val){
HX_STACK_FRAME("lime.app.Future","then",0x0a523022,"lime.app.Future.then","lime/app/Future.hx",192,0x058e0853)
HX_STACK_ARG(val,"val")
HXLINE( 194) HX_VARI_NAME( ::lime::app::Future,future1,"future") = ( ( ::lime::app::Future)(next(val)) );
HXLINE( 195) future1->onError(promise->error_dyn());
HXLINE( 196) future1->onComplete(promise->complete_dyn());
}
HX_END_LOCAL_FUNC1((void))
HXLINE( 187) HX_VARI( ::lime::app::Promise,promise) = ::lime::app::Promise_obj::__new();
HXLINE( 189) this->onError(promise->error_dyn());
HXLINE( 190) this->onProgress(promise->progress_dyn());
HXLINE( 192) this->onComplete( ::Dynamic(new _hx_Closure_0(next,promise)));
HXLINE( 200) return promise->future;
}
}
HXLINE( 175) return null();
}
HX_DEFINE_DYNAMIC_FUNC1(Future_obj,then,return )
Future_obj::Future_obj()
{
}
void Future_obj::__Mark(HX_MARK_PARAMS)
{
HX_MARK_BEGIN_CLASS(Future);
HX_MARK_MEMBER_NAME(error,"error");
HX_MARK_MEMBER_NAME(isComplete,"isComplete");
HX_MARK_MEMBER_NAME(isError,"isError");
HX_MARK_MEMBER_NAME(value,"value");
HX_MARK_MEMBER_NAME(_hx___completeListeners,"__completeListeners");
HX_MARK_MEMBER_NAME(_hx___errorListeners,"__errorListeners");
HX_MARK_MEMBER_NAME(_hx___progressListeners,"__progressListeners");
HX_MARK_END_CLASS();
}
void Future_obj::__Visit(HX_VISIT_PARAMS)
{
HX_VISIT_MEMBER_NAME(error,"error");
HX_VISIT_MEMBER_NAME(isComplete,"isComplete");
HX_VISIT_MEMBER_NAME(isError,"isError");
HX_VISIT_MEMBER_NAME(value,"value");
HX_VISIT_MEMBER_NAME(_hx___completeListeners,"__completeListeners");
HX_VISIT_MEMBER_NAME(_hx___errorListeners,"__errorListeners");
HX_VISIT_MEMBER_NAME(_hx___progressListeners,"__progressListeners");
}
hx::Val Future_obj::__Field(const ::String &inName,hx::PropertyAccess inCallProp)
{
switch(inName.length) {
case 4:
if (HX_FIELD_EQ(inName,"then") ) { return hx::Val( then_dyn()); }
break;
case 5:
if (HX_FIELD_EQ(inName,"error") ) { return hx::Val( error); }
if (HX_FIELD_EQ(inName,"value") ) { return hx::Val( value); }
if (HX_FIELD_EQ(inName,"ready") ) { return hx::Val( ready_dyn()); }
break;
case 6:
if (HX_FIELD_EQ(inName,"result") ) { return hx::Val( result_dyn()); }
break;
case 7:
if (HX_FIELD_EQ(inName,"isError") ) { return hx::Val( isError); }
if (HX_FIELD_EQ(inName,"onError") ) { return hx::Val( onError_dyn()); }
break;
case 10:
if (HX_FIELD_EQ(inName,"isComplete") ) { return hx::Val( isComplete); }
if (HX_FIELD_EQ(inName,"onComplete") ) { return hx::Val( onComplete_dyn()); }
if (HX_FIELD_EQ(inName,"onProgress") ) { return hx::Val( onProgress_dyn()); }
break;
case 16:
if (HX_FIELD_EQ(inName,"__errorListeners") ) { return hx::Val( _hx___errorListeners); }
break;
case 19:
if (HX_FIELD_EQ(inName,"__completeListeners") ) { return hx::Val( _hx___completeListeners); }
if (HX_FIELD_EQ(inName,"__progressListeners") ) { return hx::Val( _hx___progressListeners); }
}
return super::__Field(inName,inCallProp);
}
hx::Val Future_obj::__SetField(const ::String &inName,const hx::Val &inValue,hx::PropertyAccess inCallProp)
{
switch(inName.length) {
case 5:
if (HX_FIELD_EQ(inName,"error") ) { error=inValue.Cast< ::Dynamic >(); return inValue; }
if (HX_FIELD_EQ(inName,"value") ) { value=inValue.Cast< ::Dynamic >(); return inValue; }
break;
case 7:
if (HX_FIELD_EQ(inName,"isError") ) { isError=inValue.Cast< Bool >(); return inValue; }
break;
case 10:
if (HX_FIELD_EQ(inName,"isComplete") ) { isComplete=inValue.Cast< Bool >(); return inValue; }
break;
case 16:
if (HX_FIELD_EQ(inName,"__errorListeners") ) { _hx___errorListeners=inValue.Cast< ::Array< ::Dynamic> >(); return inValue; }
break;
case 19:
if (HX_FIELD_EQ(inName,"__completeListeners") ) { _hx___completeListeners=inValue.Cast< ::Array< ::Dynamic> >(); return inValue; }
if (HX_FIELD_EQ(inName,"__progressListeners") ) { _hx___progressListeners=inValue.Cast< ::Array< ::Dynamic> >(); return inValue; }
}
return super::__SetField(inName,inValue,inCallProp);
}
void Future_obj::__GetFields(Array< ::String> &outFields)
{
outFields->push(HX_HCSTRING("error","\xc8","\xcb","\x29","\x73"));
outFields->push(HX_HCSTRING("isComplete","\xc3","\x12","\x77","\xfa"));
outFields->push(HX_HCSTRING("isError","\x7e","\x6f","\xaf","\x0f"));
outFields->push(HX_HCSTRING("value","\x71","\x7f","\xb8","\x31"));
outFields->push(HX_HCSTRING("__completeListeners","\x66","\x0e","\x5a","\x85"));
outFields->push(HX_HCSTRING("__errorListeners","\xb7","\x4b","\x93","\x70"));
outFields->push(HX_HCSTRING("__progressListeners","\xf2","\x98","\xe2","\x78"));
super::__GetFields(outFields);
};
#if HXCPP_SCRIPTABLE
static hx::StorageInfo Future_obj_sMemberStorageInfo[] = {
{hx::fsObject /*Dynamic*/ ,(int)offsetof(Future_obj,error),HX_HCSTRING("error","\xc8","\xcb","\x29","\x73")},
{hx::fsBool,(int)offsetof(Future_obj,isComplete),HX_HCSTRING("isComplete","\xc3","\x12","\x77","\xfa")},
{hx::fsBool,(int)offsetof(Future_obj,isError),HX_HCSTRING("isError","\x7e","\x6f","\xaf","\x0f")},
{hx::fsObject /*Dynamic*/ ,(int)offsetof(Future_obj,value),HX_HCSTRING("value","\x71","\x7f","\xb8","\x31")},
{hx::fsObject /*cpp::ArrayBase*/ ,(int)offsetof(Future_obj,_hx___completeListeners),HX_HCSTRING("__completeListeners","\x66","\x0e","\x5a","\x85")},
{hx::fsObject /*cpp::ArrayBase*/ ,(int)offsetof(Future_obj,_hx___errorListeners),HX_HCSTRING("__errorListeners","\xb7","\x4b","\x93","\x70")},
{hx::fsObject /*cpp::ArrayBase*/ ,(int)offsetof(Future_obj,_hx___progressListeners),HX_HCSTRING("__progressListeners","\xf2","\x98","\xe2","\x78")},
{ hx::fsUnknown, 0, null()}
};
static hx::StaticInfo *Future_obj_sStaticStorageInfo = 0;
#endif
static ::String Future_obj_sMemberFields[] = {
HX_HCSTRING("error","\xc8","\xcb","\x29","\x73"),
HX_HCSTRING("isComplete","\xc3","\x12","\x77","\xfa"),
HX_HCSTRING("isError","\x7e","\x6f","\xaf","\x0f"),
HX_HCSTRING("value","\x71","\x7f","\xb8","\x31"),
HX_HCSTRING("__completeListeners","\x66","\x0e","\x5a","\x85"),
HX_HCSTRING("__errorListeners","\xb7","\x4b","\x93","\x70"),
HX_HCSTRING("__progressListeners","\xf2","\x98","\xe2","\x78"),
HX_HCSTRING("onComplete","\xf8","\xd4","\x7e","\x5d"),
HX_HCSTRING("onError","\x29","\x6a","\x67","\x09"),
HX_HCSTRING("onProgress","\xec","\xcb","\xe1","\x63"),
HX_HCSTRING("ready","\x63","\xa0","\xba","\xe6"),
HX_HCSTRING("result","\xdd","\x68","\x84","\x08"),
HX_HCSTRING("then","\xdd","\x02","\xfc","\x4c"),
::String(null()) };
static void Future_obj_sMarkStatics(HX_MARK_PARAMS) {
HX_MARK_MEMBER_NAME(Future_obj::__mClass,"__mClass");
};
#ifdef HXCPP_VISIT_ALLOCS
static void Future_obj_sVisitStatics(HX_VISIT_PARAMS) {
HX_VISIT_MEMBER_NAME(Future_obj::__mClass,"__mClass");
};
#endif
hx::Class Future_obj::__mClass;
void Future_obj::__register()
{
hx::Static(__mClass) = new hx::Class_obj();
__mClass->mName = HX_HCSTRING("lime.app.Future","\x49","\x39","\x57","\xcb");
__mClass->mSuper = &super::__SGetClass();
__mClass->mConstructEmpty = &__CreateEmpty;
__mClass->mConstructArgs = &__Create;
__mClass->mGetStaticField = &hx::Class_obj::GetNoStaticField;
__mClass->mSetStaticField = &hx::Class_obj::SetNoStaticField;
__mClass->mMarkFunc = Future_obj_sMarkStatics;
__mClass->mStatics = hx::Class_obj::dupFunctions(0 /* sStaticFields */);
__mClass->mMembers = hx::Class_obj::dupFunctions(Future_obj_sMemberFields);
__mClass->mCanCast = hx::TCanCast< Future_obj >;
#ifdef HXCPP_VISIT_ALLOCS
__mClass->mVisitFunc = Future_obj_sVisitStatics;
#endif
#ifdef HXCPP_SCRIPTABLE
__mClass->mMemberStorageInfo = Future_obj_sMemberStorageInfo;
#endif
#ifdef HXCPP_SCRIPTABLE
__mClass->mStaticStorageInfo = Future_obj_sStaticStorageInfo;
#endif
hx::_hx_RegisterClass(__mClass->mName, __mClass);
}
} // end namespace lime
} // end namespace app
|
f628d00defe44e4c0f3412c86ec608aa6dc94bd3 | 215111e92a3dfc535ce1c1ce25a35fb6003ab575 | /cf/petrozavodsk_15_winter/l.cpp | 6e16fe0366fff38c85036d1c65f9eee6201a21ac | [] | no_license | emanueljuliano/Competitive_Programming | 6e65aa696fb2bb0e2251e5a68657f4c79cd8f803 | 86fefe4d0e3ee09b5766acddc8c78ed8b60402d6 | refs/heads/master | 2023-06-23T04:52:43.910062 | 2021-06-26T11:34:42 | 2021-06-26T11:34:42 | 299,115,304 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 939 | cpp | l.cpp | #include <bits/stdc++.h>
using namespace std;
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define f first
#define s second
#define pb push_back
typedef long long ll;
typedef pair<int, int> ii;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fll;
const int MAX = 5e3+10;
char dp[MAX][MAX][3];
int n, m;
string s, t;
char solve(int i, int j, bool can) {
if (i == n and j == m) return 1;
if (j == m) return 0;
auto& ans = dp[i][j][can];
if (ans+1) return ans;
ans = 0;
if (i < n and s[i] == t[j]) ans |= solve(i+1, j+1, false);
if(can) ans|= solve(i, j+1, can);
if (i > 0 and t[j] != s[i-1]) ans |= solve(i, j+1, true);
if (j > 0 and t[j] != t[j-1]) ans |= solve(i, j+1, true);
return ans;
}
int main() { _
memset(dp, -1, sizeof(dp));
cin >> s >> t;
n = s.size(), m = t.size();
bool ans = solve(0, 0, 0);
if (ans) cout << "Yes" << endl;
else cout << "No" << endl;
exit(0);
}
|
a399d55226bacabdc9a02b64bb0b004a268cd246 | 66241ef9f388e58f3a2c0fe258ef8858c39078a2 | /cat.cpp | d5183852bae11a1d57c1406fbd9751a0f7303e86 | [] | no_license | MaximMatrosov/Animals | 943fd8e904bbb5d277e9f34f66186c213397cd8c | 00e46aa547f3ae809ee43902f9f4e6e9de58645c | refs/heads/master | 2021-01-12T18:05:35.850666 | 2016-10-03T19:50:54 | 2016-10-03T19:50:54 | 69,902,551 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 432 | cpp | cat.cpp | #include "cat.h"
#include <iostream>
#include <fstream>
using namespace std;
Cat::Cat()
{
}
bool Cat::writeToBase(){
try{
ofstream F;
F.open("cats.txt", ios::app);
F<<Moniker+","
+BirthYear.toString("dd.MM.yyyy").toLocal8Bit().constData()+","
+Color+"\n";
F.close();
}
catch(exception){
return false;
}
return true;
}
|
1d91b138b7ad767bad6c6b89fb0eef8bd042c83f | c29bc50118414d51277441e35f73aafc2b6caf31 | /lib/FileHashNode.cpp | 5fdca9c10dacdd999de8b7887d9a82170c3677c3 | [] | no_license | zhenyouluo/Hash-Tree | bf13a200393f834f61e299f6170254cea3311a6c | 7a54d980de9a180d793be62d7c1a70e8d8f0420d | refs/heads/master | 2021-01-14T12:35:51.285800 | 2011-04-25T10:01:09 | 2011-04-25T10:01:09 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,351 | cpp | FileHashNode.cpp | // @(#)FileHashNode.cpp
// Time-stamp: <Julian Qian 2011-04-20 17:34:25>
// Copyright 2011 Julian Qian
// Version: $Id: FileHashNode.cpp,v 0.0 2011/03/11 05:22:50 jqian Exp $
#include <stdlib.h>
#include "Errors.h"
#include "util_marshal.h"
#include "FileHashNode.h"
using std::string;
void
DTLeaf::init(const char* filename,
off_t offset,
unsigned length){
// read file
FILE* fd = fopen(filename, "r");
if(fseek(fd, offset, SEEK_SET)){
EC_NO_RETURN("failed to seek offset, %s.",
strerror(errno));
}
unsigned count = length / blockSize_;
char* buffer = (char*)malloc(blockSize_);
for (int i = 0; i <= count; ++i) {
size_t rlen = fread(buffer, 1, blockSize_, fd);
if(rlen < blockSize_){
if(feof(fd)){ // end of file
// store the last offset and length
lastblk_.ptr = i;
lastblk_.length = rlen;
}else if(ferror(fd)){
EC_NO_RETURN("read data failed, %s.",
strerror(errno));
}else{
}
}
DigestType dt;
dt.process(buffer, rlen);
// add data block item
DTBlock block;
block.digest(dt);
blocks_.push_back(block);
}
fclose(fd);
// calculate
BlockList::iterator itr;
string sumstr;
for (itr = blocks_.begin(); itr != blocks_.end(); ++ itr) {
// TODO: how to calc children more reasonably
sumstr += itr->digest().toString();
}
digest_.process(sumstr.c_str(), sumstr.length());
}
char*
DTLeaf::unserilize(char* p){
p = HashNode::unserilize(p);
unsigned int len;
p = pop_uint32(p, len);
blocks_.reserve(len);
for (int i = 0; i < len; ++i) {
DTBlock block;
p = block.unserilize(p);
blocks_.push_back(block);
}
p = pop_uint32(p, lastblk_.ptr);
p = pop_uint32(p, lastblk_.length);
return p;
}
char*
DTLeaf::serilize(char* p){
p = HashNode::serilize(p);
unsigned int len = blocks_.size();
p = push_uint32(p, len);
for (BlockList::iterator itr = blocks_.begin();
itr != blocks_.end(); ++ itr) {
p = itr->serilize(p);
}
p = push_uint32(p, lastblk_.ptr);
p = push_uint32(p, lastblk_.length);
return p;
}
|
032f5d3a621338ed26d60d7aaba016f228b08888 | 04f52c481c7d6eb1b4156b296fe5d81ddccfb161 | /utils/config/ConfigUtils.cpp | de4e4227684e7749a0982d5159cf88b9f6704316 | [] | no_license | starand/cpp_fw | 39c9d78439602b43498310e86f8bf704b4feceb2 | 5d2ebfe7dc3aef61558ed9f6f49293746499492c | refs/heads/master | 2021-01-11T23:59:05.013523 | 2017-02-20T09:36:05 | 2017-02-20T09:36:05 | 78,653,984 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 660 | cpp | ConfigUtils.cpp | #include "StdAfx.h"
#include "ConfigUtils.h"
#include "ConfigStorage.h"
#include "fileutils.h"
/*extern */
CConfigStorage g_csConfigStorage;
void AddConfigString(ECONFIGOPTION coConfigOption, const string &sOptionValue)
{
g_csConfigStorage.StoreOptionValue(coConfigOption, sOptionValue);
}
bool GetConfigString(ECONFIGOPTION coConfigOption, string &sOptionValue)
{
return g_csConfigStorage.GetOptionString(coConfigOption, sOptionValue);
}
void GetConfigStringDef(ECONFIGOPTION coConfigOption, string &sOptionValue, const string &sDefValue)
{
if (!g_csConfigStorage.GetOptionString(coConfigOption, sOptionValue))
{
sOptionValue = sDefValue;
}
}
|
b30734bfb028c403ed012044ebcc3a44358bd6ba | c0ff084bb7a82b1ac14303717b3e64b01d556074 | /daemon/model-dbus-impl.cc | e1171996b8afe508d0c460860240b01ea2e8b4af | [
"Apache-2.0"
] | permissive | wooksong/api | b1d40c7927abc77c68a798c5d828a6e90d533adb | 66f31272694e203147907005cc67ac320d8125b5 | refs/heads/main | 2023-07-06T05:09:28.569288 | 2023-06-27T07:00:28 | 2023-06-27T07:03:53 | 341,819,071 | 0 | 0 | Apache-2.0 | 2023-04-19T05:14:15 | 2021-02-24T07:43:09 | C | UTF-8 | C++ | false | false | 10,617 | cc | model-dbus-impl.cc | /* SPDX-License-Identifier: Apache-2.0 */
/**
* Copyright (c) 2022 Samsung Electronics Co., Ltd. All Rights Reserved.
*
* @file model-dbus-impl.cc
* @date 29 Jul 2022
* @brief DBus implementation for Model Interface
* @see https://github.com/nnstreamer/api
* @author Sangjung Woo <sangjung.woo@samsung.com>
* @bug No known bugs except for NYI items
*/
#include <errno.h>
#include <glib.h>
#include <gst/gst.h>
#include "common.h"
#include "dbus-interface.h"
#include "gdbus-util.h"
#include "log.h"
#include "model-dbus.h"
#include "modules.h"
#include "service-db.hh"
static MachinelearningServiceModel *g_gdbus_instance = NULL;
/**
* @brief Utility function to get the DBus proxy of Model interface.
*/
static MachinelearningServiceModel *
gdbus_get_model_instance (void)
{
return machinelearning_service_model_skeleton_new ();
}
/**
* @brief Utility function to release DBus proxy of Model interface.
*/
static void
gdbus_put_model_instance (MachinelearningServiceModel **instance)
{
g_clear_object (instance);
}
/**
* @brief The callback function of Register method
*
* @param obj Proxy instance.
* @param invoc Method invocation handle.
* @param name The name of target model.
* @param path The file path of target.
* @param is_active The active status of target model.
* @param description The description of target model.
* @return @c TRUE if the request is handled. FALSE if the service is not available.
*/
static gboolean
gdbus_cb_model_register (MachinelearningServiceModel *obj,
GDBusMethodInvocation *invoc, const gchar *name, const gchar *path,
const bool is_active, const gchar *description, const gchar *app_info)
{
int ret = 0;
guint version = 0U;
MLServiceDB &db = MLServiceDB::getInstance ();
try {
db.connectDB ();
db.set_model (name, path, is_active, description, app_info, &version);
} catch (const std::invalid_argument &e) {
_E ("%s", e.what ());
ret = -EINVAL;
} catch (const std::exception &e) {
_E ("%s", e.what ());
ret = -EIO;
}
db.disconnectDB ();
machinelearning_service_model_complete_register (obj, invoc, version, ret);
return TRUE;
}
/**
* @brief The callback function of update description method
*
* @param obj Proxy instance.
* @param invoc Method invocation handle.
* @param name The name of target model.
* @param version The version of target model.
* @param description The description of target model.
* @return @c TRUE if the request is handled. FALSE if the service is not available.
*/
static gboolean
gdbus_cb_model_update_description (MachinelearningServiceModel *obj,
GDBusMethodInvocation *invoc, const gchar *name, const guint version,
const gchar *description)
{
int ret = 0;
MLServiceDB &db = MLServiceDB::getInstance ();
try {
db.connectDB ();
db.update_model_description (name, version, description);
} catch (const std::invalid_argument &e) {
_E ("%s", e.what ());
ret = -EINVAL;
} catch (const std::exception &e) {
_E ("%s", e.what ());
ret = -EIO;
}
db.disconnectDB ();
machinelearning_service_model_complete_update_description (obj, invoc, ret);
return TRUE;
}
/**
* @brief The callback function of activate method
*
* @param obj Proxy instance.
* @param invoc Method invocation handle.
* @param name The name of target model.
* @param version The version of target model.
* @return @c TRUE if the request is handled. FALSE if the service is not available.
*/
static gboolean
gdbus_cb_model_activate (MachinelearningServiceModel *obj,
GDBusMethodInvocation *invoc, const gchar *name, const guint version)
{
int ret = 0;
MLServiceDB &db = MLServiceDB::getInstance ();
try {
db.connectDB ();
db.activate_model (name, version);
} catch (const std::invalid_argument &e) {
_E ("%s", e.what ());
ret = -EINVAL;
} catch (const std::exception &e) {
_E ("%s", e.what ());
ret = -EIO;
}
db.disconnectDB ();
machinelearning_service_model_complete_activate (obj, invoc, ret);
return TRUE;
}
/**
* @brief The callback function of get method
*
* @param obj Proxy instance.
* @param invoc Method invocation handle.
* @param name The name of target model.
* @return @c TRUE if the request is handled. FALSE if the service is not available.
*/
static gboolean
gdbus_cb_model_get (MachinelearningServiceModel *obj,
GDBusMethodInvocation *invoc, const gchar *name, const guint version)
{
int ret = 0;
std::string model_info;
MLServiceDB &db = MLServiceDB::getInstance ();
try {
db.connectDB ();
db.get_model (name, model_info, version);
} catch (const std::invalid_argument &e) {
_E ("%s", e.what ());
ret = -EINVAL;
} catch (const std::exception &e) {
_E ("%s", e.what ());
ret = -EIO;
}
db.disconnectDB ();
machinelearning_service_model_complete_get_activated (
obj, invoc, model_info.c_str (), ret);
return TRUE;
}
/**
* @brief The callback function of get activated method
*
* @param obj Proxy instance.
* @param invoc Method invocation handle.
* @param name The name of target model.
* @return @c TRUE if the request is handled. FALSE if the service is not available.
*/
static gboolean
gdbus_cb_model_get_activated (MachinelearningServiceModel *obj,
GDBusMethodInvocation *invoc, const gchar *name)
{
int ret = 0;
std::string model_info;
MLServiceDB &db = MLServiceDB::getInstance ();
try {
db.connectDB ();
db.get_model (name, model_info, -1);
} catch (const std::invalid_argument &e) {
_E ("%s", e.what ());
ret = -EINVAL;
} catch (const std::exception &e) {
_E ("%s", e.what ());
ret = -EIO;
}
db.disconnectDB ();
machinelearning_service_model_complete_get_activated (
obj, invoc, model_info.c_str (), ret);
return TRUE;
}
/**
* @brief The callback function of get all method
*
* @param obj Proxy instance.
* @param invoc Method invocation handle.
* @param name The name of target model.
* @return @c TRUE if the request is handled. FALSE if the service is not available.
*/
static gboolean
gdbus_cb_model_get_all (MachinelearningServiceModel *obj,
GDBusMethodInvocation *invoc, const gchar *name)
{
int ret = 0;
MLServiceDB &db = MLServiceDB::getInstance ();
std::string all_model_list;
try {
db.connectDB ();
db.get_model (name, all_model_list, 0);
} catch (const std::invalid_argument &e) {
_E ("%s", e.what ());
ret = -EINVAL;
} catch (const std::exception &e) {
_E ("%s", e.what ());
ret = -EIO;
}
db.disconnectDB ();
machinelearning_service_model_complete_get (obj, invoc, all_model_list.c_str (), ret);
return TRUE;
}
/**
* @brief The callback function of delete method
*
* @param obj Proxy instance.
* @param invoc Method invocation handle.
* @param name The name of target model.
* @param version The version of target model.
* @return @c TRUE if the request is handled. FALSE if the service is not available.
*/
static gboolean
gdbus_cb_model_delete (MachinelearningServiceModel *obj,
GDBusMethodInvocation *invoc, const gchar *name, const guint version)
{
int ret = 0;
MLServiceDB &db = MLServiceDB::getInstance ();
try {
db.connectDB ();
db.delete_model (name, version);
} catch (const std::invalid_argument &e) {
_E ("%s", e.what ());
ret = -EINVAL;
} catch (const std::exception &e) {
_E ("%s", e.what ());
ret = -EIO;
}
db.disconnectDB ();
machinelearning_service_model_complete_delete (obj, invoc, ret);
return TRUE;
}
/**
* @brief Event handler list of Model interface
*/
static struct gdbus_signal_info handler_infos[] = {
{
.signal_name = DBUS_MODEL_I_HANDLER_REGISTER,
.cb = G_CALLBACK (gdbus_cb_model_register),
.cb_data = NULL,
.handler_id = 0,
},
{
.signal_name = DBUS_MODEL_I_HANDLER_UPDATE_DESCRIPTION,
.cb = G_CALLBACK (gdbus_cb_model_update_description),
.cb_data = NULL,
.handler_id = 0,
},
{
.signal_name = DBUS_MODEL_I_HANDLER_ACTIVATE,
.cb = G_CALLBACK (gdbus_cb_model_activate),
.cb_data = NULL,
.handler_id = 0,
},
{
.signal_name = DBUS_MODEL_I_HANDLER_GET,
.cb = G_CALLBACK (gdbus_cb_model_get),
.cb_data = NULL,
.handler_id = 0,
},
{
.signal_name = DBUS_MODEL_I_HANDLER_GET_ACTIVATED,
.cb = G_CALLBACK (gdbus_cb_model_get_activated),
.cb_data = NULL,
.handler_id = 0,
},
{
.signal_name = DBUS_MODEL_I_HANDLER_GET_ALL,
.cb = G_CALLBACK (gdbus_cb_model_get_all),
.cb_data = NULL,
.handler_id = 0,
},
{
.signal_name = DBUS_MODEL_I_HANDLER_DELETE,
.cb = G_CALLBACK (gdbus_cb_model_delete),
.cb_data = NULL,
.handler_id = 0,
},
};
/**
* @brief The callback function for probing Model Interface module.
*/
static int
probe_model_module (void *data)
{
int ret = 0;
_D ("probe_model_module");
g_gdbus_instance = gdbus_get_model_instance ();
if (NULL == g_gdbus_instance) {
_E ("cannot get a dbus instance for the %s interface\n", DBUS_MODEL_INTERFACE);
return -ENOSYS;
}
ret = gdbus_connect_signal (g_gdbus_instance, ARRAY_SIZE (handler_infos), handler_infos);
if (ret < 0) {
_E ("cannot register callbacks as the dbus method invocation handlers\n ret: %d", ret);
ret = -ENOSYS;
goto out;
}
ret = gdbus_export_interface (g_gdbus_instance, DBUS_MODEL_PATH);
if (ret < 0) {
_E ("cannot export the dbus interface '%s' at the object path '%s'\n",
DBUS_MODEL_INTERFACE, DBUS_MODEL_PATH);
ret = -ENOSYS;
goto out_disconnect;
}
return 0;
out_disconnect:
gdbus_disconnect_signal (g_gdbus_instance, ARRAY_SIZE (handler_infos), handler_infos);
out:
gdbus_put_model_instance (&g_gdbus_instance);
return ret;
}
/**
* @brief The callback function for initializing Model Interface module.
*/
static void
init_model_module (void *data)
{
GError *err = NULL;
gboolean ret;
ret = gst_init_check (NULL, NULL, &err);
if (!ret) {
_E ("Failed to initialize GStreamer with err msg (%s)", (err ? err->message: "NULL"));
}
g_clear_error (&err);
}
/**
* @brief The callback function for exiting Model Interface module.
*/
static void
exit_model_module (void *data)
{
gdbus_disconnect_signal (g_gdbus_instance, ARRAY_SIZE (handler_infos), handler_infos);
gdbus_put_model_instance (&g_gdbus_instance);
}
static const struct module_ops model_ops = {
.name = "model-interface",
.probe = probe_model_module,
.init = init_model_module,
.exit = exit_model_module,
};
MODULE_OPS_REGISTER (&model_ops)
|
a955e559ab89bbc1623b0d8692e10aaa361d11ea | 28df98a6c9e0c23adc082465a9b438a76a71698f | /Pointers.cpp | e771bb13f319406a278c863a5e66bb972fb83816 | [] | no_license | sbarbera4/CIS2013_Week10_Lab1 | fa1c67b1efaa9927058cbac6fe5a3bc00d0ddf8c | 25c01fe96a8aa3ab9aa7594560a63aa6694949af | refs/heads/master | 2020-03-07T02:52:48.559856 | 2018-03-29T01:35:31 | 2018-03-29T01:35:31 | 127,220,038 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 829 | cpp | Pointers.cpp | #include <iostream>
#include <cstring>
using namespace std;
int main()
{
int len;
int cont = 1;
while (cont == true)
{
cout << "how long do you want your array?" << endl;
cin >> len;
int *a;
a = new int[len];
for (int i = 0, i < len; i++)
{
cout << "int number " << i << " should be: ";
cin >> a[i];
}
cout << endl << "Your list of numbers is: ";
for (int i = 0, i < len; i++)
{
cout << a[x] << endl;
}
cout << "do you want to continue; Y=1, N=0 :" << endl;
cin >> cont;
delete[] a;
}
/*
int v1;
int v2;
int *p1;
int *p2;
v1 = 22;
v2 = 33;
p1 = &v1;
p2 = &v2;
p1 = p2;
v1 = 44;
v2 = 55;
p1 = &v1;
cout << " p1 is: " << *p1 << endl;
cout << " p2 is: " << *p2 << endl;
cout << " v1 is: " << v1 << endl;
cout << " v2 is: " << v2 << endl;
*/
return 0;
}
|
abca5a63b80ddf31ecbb51731c74c1f7858b13f1 | f1669fb90f1e2fb01d709d7ffa0dee13d43af8ef | /src/iqrf/request/DPAOSRestartRequest.cpp | 055f74aa4dbf51e9bb5a8a77553e8398a5149d97 | [
"BSD-3-Clause"
] | permissive | BeeeOn/gateway | 9f6305acdff8fb59dd58f878e2634814be6dc296 | 6f737dc6a979242494b63ce3603aabe6f1ca9005 | refs/heads/master | 2021-01-19T22:08:15.406357 | 2020-03-26T09:01:26 | 2020-03-26T09:01:26 | 88,623,513 | 8 | 11 | BSD-3-Clause | 2020-03-26T09:11:11 | 2017-04-18T12:39:47 | C++ | UTF-8 | C++ | false | false | 227 | cpp | DPAOSRestartRequest.cpp | #include "iqrf/request/DPAOSRestartRequest.h"
using namespace BeeeOn;
static const uint8_t RESTART_CMD = 0x08;
DPAOSRestartRequest::DPAOSRestartRequest(uint8_t node):
DPARequest(
node,
DPA_OS_PNUM,
RESTART_CMD
)
{
}
|
5c8b14257dac13d07dbc3dec80f4b9be902b8fa1 | 7d782dbdb3c36fd9591a21da3b04f137cece056d | /otus.lessons.05.01/scene.h | 20c1ef8ff447c538b06763961179f391acd870d4 | [] | no_license | madmazoku/otus.lessons.05.01 | 1fe3024776a2100ef51c4d17ec4b61dff8cba8e5 | ccad210f5137c9da19ade78cd8abc52e9357f396 | refs/heads/master | 2021-08-31T14:46:31.090419 | 2017-12-21T19:05:59 | 2017-12-21T19:05:59 | 114,666,889 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 8,238 | h | scene.h | #pragma once
#include <vector>
#define _USE_MATH_DEFINES
#include <cmath>
#include <math.h>
#include <SDL2/SDL.h>
#include "global.h"
#include "queue_processor.h"
Uint8 lum(const double &d)
{
return d < 0.0 ? 0 : d > 1.0 ? 255 : (Uint8)(255 * d);
}
double inv(const double &d)
{
return d < 1e-4 ? 1e4 : 1.0/d;
}
double sqr(const double &d)
{
return d*d;
}
double tri(const double &d)
{
return d*d*d;
}
double sgn(const double &d)
{
return d < 0.0 ? -1.0 : d > 0.0 ? 1.0 : 0.0;
}
double loop(double a)
{
return (sin(a) + 1.0) * 0.5;
}
struct XY {
double x;
double y;
XY() : x(0), y(0) {}
XY(const double &d) : x(d), y(d) {}
XY(const double &x_, const double &y_) : x(x_), y(y_) {}
XY(const XY &xy_) : x(xy_.x), y(xy_.y) {}
XY& rand_pos(const XY ¢er, const XY &litude)
{
x = (urd(gen) - 0.5) * amplitude.x * 2.0 + center.x;
y = (urd(gen) - 0.5) * amplitude.y * 2.0 + center.y;
return *this;
}
XY& rand_angle(const double & amplitude)
{
double angle = urd(gen) * 2 * M_PI;
x = sin(angle) * amplitude;
y = cos(angle) * amplitude;
return *this;
}
XY& operator=(const XY &xy_)
{
x = xy_.x;
y = xy_.y;
return *this;
}
XY operator+(const XY &xy_) const
{
return XY(x + xy_.x, y + xy_.y);
}
XY& operator+=(const XY &xy_)
{
x += xy_.x;
y += xy_.y;
return *this;
}
XY operator-(const XY &xy_) const
{
return XY(x - xy_.x, y - xy_.y);
}
XY operator*(const XY &xy_) const
{
return XY(x * xy_.x, y * xy_.y);
}
XY operator*(const double &d) const
{
return XY(x *d, y *d);
}
XY& operator*=(const double &d)
{
x *= d;
y *= d;
return *this;
}
bool in_box(const XY& xy_, double d) const
{
return fabs(x - xy_.x) < d && fabs(y - xy_.y) < d;
}
double dist2(const XY& xy_) const
{
return sqr(x - xy_.x) + sqr(y - xy_.y);
}
double dist(const XY& xy_) const
{
return sqrt(sqr(x - xy_.x) + sqr(y - xy_.y));
}
double dist() const
{
return sqrt(sqr(x) + sqr(y));
}
XY vec(const XY& xy_) const
{
return (*this) * inv(dist(xy_));
}
};
struct Color {
double r;
double g;
double b;
Color() : r(1.0), g(1.0), b(1.0) {}
Color(const double &d) : r(d), g(d), b(d) {}
Color(const double &r_, const double &g_, const double &b_) : r(r_), g(g_), b(b_) {}
Color(const Color &col) : r(col.r), g(col.g), b(col.b) {}
Color& rand()
{
r = urd(gen);
g = urd(gen);
b = urd(gen);
return *this;
}
Color operator*(const double &d) const
{
return Color(r *d, g *d, b*d);
}
Color& operator*=(const double &d)
{
r *= d;
g *= d;
b *= d;
return *this;
}
Color operator+(const Color &col_) const
{
return Color(r +col_.r, g +col_.g, b+col_.b);
}
Color& operator+=(const Color &col_)
{
r += col_.r;
g += col_.g;
b += col_.b;
return *this;
}
};
struct Particle {
XY pos;
XY vel;
Color col;
};
struct Scene {
long width;
long height;
double pixel_size;
XY size;
double timer;
std::vector<Particle> particles;
std::vector<Particle> particles_tmp;
QueueProcessor qp;
Scene() : width(0), height(0), pixel_size(0.0), size(0, 0), timer(0)
{
}
~Scene()
{
qp.join();
}
void init(long width_, long height_, long particles_count)
{
width = width_;
height = height_;
pixel_size = 1.0 / (width > height ? width : height);
size = XY(width * pixel_size, height * pixel_size);
XY half_size = size * 0.5;
timer = 0;
double a = 0;
double dp = 2 * M_PI / 3;
double da = 2 * M_PI / particles_count;
particles.resize(particles_count);
double x = 0;
for (auto &p : particles) {
p.pos.rand_pos(half_size, half_size);
// p.vel.rand_angle(0.5);
p.col = Color(
(sin(a)+1)*0.5,
(sin(a + dp)+1)*0.5,
(sin(a + dp * 2)+1)*0.5
);
a += da;
}
particles_tmp = particles;
qp.start();
}
void done()
{
qp.stop();
}
XY edge_force(const Particle& p_)
{
const XY &pos = p_.pos;
return XY(inv(pos.x + 1) - inv(size.x - pos.x + 1), inv(pos.y + 1) - inv(size.y - pos.y + 1));
}
XY friction_force(const Particle& p_)
{
const XY &vel = p_.vel;
return XY(-vel.x * 0.5, -vel.y * 0.5);
}
XY multi_particle_force(const Particle& p_)
{
XY multi_force(0);
for (auto &p : particles) {
if(&p == &p_)
continue;
double id = inv(p_.pos.dist(p.pos));
XY vec = (p_.pos - p.pos) * id;
multi_force += vec * (sqr(id) );
}
return multi_force * 0.01 * inv(particles.size());
}
XY force(const Particle& p)
{
// return edge_force(p) + friction_force(p);
return edge_force(p) + friction_force(p) + multi_particle_force(p);
}
void step_particle(double time_step, const Particle& p_in, Particle& p_out)
{
XY pos_step = p_in.vel;
XY vel_step = force(p_in);
p_out.pos = p_in.pos + pos_step * time_step;
p_out.vel = p_in.vel + vel_step * time_step;
if (p_out.pos.x < 0.0) {
p_out.pos.x = -p_out.pos.x;
p_out.vel.x = -p_out.vel.x;
}
if (p_out.pos.x > size.x) {
p_out.pos.x = 2.0*size.x - p_out.pos.x;
p_out.vel.x = -p_out.vel.x;
}
if (p_out.pos.y < 0.0) {
p_out.pos.y = -p_out.pos.y;
p_out.vel.y = -p_out.vel.y;
}
if (p_out.pos.y > size.y) {
p_out.pos.y = 2.0*size.y - p_out.pos.y;
p_out.vel.y = -p_out.vel.y;
}
if(p_out.vel.dist() < 0.01)
p_out.vel.rand_angle(0.5);
}
void step(double time_step)
{
auto p_in = particles.cbegin();
auto p_out = particles_tmp.begin();
while(p_in != particles.cend()) {
qp.add([=]() {
step_particle(time_step, *p_in, *p_out);
});
++p_in;
++p_out;
}
qp.wait();
std::swap(particles, particles_tmp);
}
double potential(const double &d)
{
return (inv(sqr(d+0.1)) - inv(d))*1e-4;
}
void fill_image_line(SDL_Surface* img, long y)
{
XY pos(0.0, y * pixel_size);
Uint32* pixel = (Uint32*)((Uint8*)(img->pixels) + y * img->pitch);
// SDL_memset((Uint8*)pixel, 0, img->pitch);
double ipc = inv(sqr(sqr(particles.size())));
for (long x = 0; x < width; ++x, ++pixel, pos.x += pixel_size) {
Color col(0);
double aid = 0;
for (const auto &p : particles) {
double id = inv(pos.dist(p.pos)*2);
aid += inv(sqr((10 - id)*0.5)) + id*2;
col += p.col * id;
}
col *= aid * inv((particles.size())) * 0.01;
*pixel = SDL_MapRGBA(img->format, lum(col.r), lum(col.g), lum(col.b), 0x00);
}
}
void render(SDL_Surface* img)
{
for (long y = 0; y < height; ++y)
qp.add([=]() {
fill_image_line(img, y);
});
qp.wait();
}
void process(SDL_Surface* img, double time_step)
{
for (long y = 0; y < height; ++y)
qp.add([=]() {
fill_image_line(img, y);
});
auto p_in = particles.cbegin();
auto p_out = particles_tmp.begin();
while(p_in != particles.cend()) {
qp.add([=]() {
step_particle(time_step, *p_in, *p_out);
});
++p_in;
++p_out;
}
timer += time_step;
qp.wait();
std::swap(particles, particles_tmp);
}
}; |
12e1625b1b2bf043817400a4ae7ae224f23f4c38 | d027fce4698eee1e2b7123964d926e0d5fd33e38 | /Emulator.h | a7d348bf52e12ddaf028f8140b936a642b1cba4e | [] | no_license | janwilmans/nowindnextgen | 6958f1bb3a515a1da7335ea579f1af98e6d79a8f | c0843be5251d5af53e1cd4f9a70d5ceac11b6785 | refs/heads/master | 2021-01-10T08:53:37.377540 | 2012-05-12T17:35:17 | 2012-05-12T17:35:17 | 43,647,567 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 647 | h | Emulator.h | //! Emulator.h
#ifndef EMULATOR_H
#define EMULATOR_H
#include <list>
#include "Event.h"
#include "Component.h"
namespace nowind {
class Bus;
class Scheduler;
class SlotSelector;
class Emulator
{
public:
Emulator(void);
virtual ~Emulator(void);
static Emulator* Instance();
static emuTimeType emuTime;
void initialize();
void test();
//test methods
void interruptTestMethod(emuTimeType emuTime, emuTimeType eventTime);
Bus& getBus() { return *mBus; }
Scheduler& getScheduler() { return *mScheduler; }
private:
Bus* mBus;
Scheduler* mScheduler;
};
} // namespace nowind
#endif // EMULATOR_H
|
e176b1692ed93331c2bfc50eeefc2913c2832311 | 6f37f529bae8bbcc99244468477f14e9f96ff95c | /wxWidgets-2.8.12/contrib/src/fl/frmview.cpp | 2cb72c0a26d5a285945a7cfb33cf79fdeeaf01e9 | [] | no_license | darknebuli/darknebuli-RM-graph | 13326ddbc9a210605926f7ad4b70672a48b1b2f2 | bf169c01f787fdd144e19fae6732a5b58fdbdafd | refs/heads/master | 2020-05-16T23:40:56.853727 | 2012-04-30T22:14:24 | 2012-04-30T22:14:24 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 12,570 | cpp | frmview.cpp | U2FsdGVkX19fTms3OENxUoetnOKy1AyJ49jWWmkNc76HrZzistQMiePY1lppDXO+
h62c4rLUDInj2NZaaQ1zvoetnOKy1AyJ49jWWmkNc758g4KpHaB8LwCS1iqVEAa/
2E2RTCnixhyZluJbEVjFBN/Ek6Q7gPlL8WDb4ZWj54kqwUXB2CEHyunB5U8gIWGx
6w3Y9bODPsxDiA3n54GvXeiDAnrxR6LAq/wv4g/w/BrOZvHrzSJIbtAPoRwfni1z
ZYcANdHJI5y9ZiILdCcFZnJ0fpPCAoMBbyDOqdXgrANOC2LEIe/ujrDqQENygAWm
+qlEKXwDSAtKDVjHxZBC7MorAAwvHIqYkk6Ar7crEDsJitNIf2cxjFKeITI5znAU
XPg5TozDPRcgS02lrIigaw5yhmtS6VICJkWg39Vz09PVP4OEUa3wA427MzTumwir
E2QbNdHwqHFDP+0M0+vdnso1axpLL+YXIpLH4i8i3GnWdVJEEJWmuJX+F4cLIkV3
XaTchRk/Oa5k+oIyBEBiDKrEeWyzbL7X5DyzqXeSpSaHrZzistQMiePY1lppDXO+
h62c4rLUDInj2NZaaQ1zvoetnOKy1AyJ49jWWmkNc76A6/VR2JgeHdGjrf07VcDr
tLN2dpdnR8g/z0cx0RqwnTlXkzrA5pwjsUsUFECSwFeqmRBOlWKdMLmJh86j/MuY
WQs1eqWEpWKuk68k79gg3bGiAIC5FWVHrvekcoWX6VlcI4QuDvS0O3mR6/wrYS0L
IQZ4ArX4wOKkGo2+qLPdaDtp+RYYs4Hrg7dnGtAwy8h4xgAMyjILiiKrHrrrZzWF
bNfry4KtD8vMYb04sYB933kEdlGC9CrHJzw8jevPmS3Jvzp4D3+6gNbalTjOCuFh
LXEey474y+/mdO5xImQ+fuqL/NQkvkNHpZl4yWwGVYzHmV9qQsWSeLNFLLr17wEJ
NNt8IhNkupDECQEafvYnuXG5ykZYq3gepbvQi4/nN4+Qt23hWO+lojao1vYAGMKZ
qskIQDq2ERXiv7Ih66C6AsGipxQDwYe8xIRQVD/w8UxF1AscQelXHgIksolt1JeC
3JDie4SMJJBWTcZaPxLFXdTHjXwVvHZ9B3UIrjAnCi0qveuXW9dpFAmXmA8en3Hg
ecZDUKNCSJzFsPhhUDfUwB0DpwMBgZWEe0D1bCl2OsXoIInT+MRsnbEeCkQmn6ja
g/ZKIvU31nhpdV/OTLTXJc8L1/n8pd/gObLxdb7pxMdMlnBFAWe4l7vx0OzwQM0X
7bVf8OYnoDWOMvWTxr1cIza/GSMPiOD9ocWBMJMKBQKEBXmys83rZj+OIOL6DPpm
B0XdNAbtIhAsr1/XXoi0JwAqnIRr+7UMbrjT6Oxpr50AEfL3B3IUPYnuoAEO35a8
3vGgVBC6Yuxfg6H7923SutLAgmA9U+W+vHzHYMAHg8iXniAN9iibBuZ1oOAemcob
cXqzb1Oq5VITmVhtoQ7YcHZkI6DlYiMWDGlOZWAg3+P46eO3epnea5Qhau2ygsIF
E1nUzSx08D80gifbDw/ri2wj6YKDZmEqwKXHW8TUgI/BDzhaWMtErOUJLcQOYUTw
mNwDbWgFPMwHD3RRRVxNhB/yfSBKNuJQcPH/ZhDR9wUqVod+6jeYlr/w4Zu1pzHH
A7/gBEgwGyoClkIse6+povu3Die57tLZ11KWscOKLStftj2jPdjn7kRmuVRjv5sZ
rRh//uvC9ZgkTuDMghlchXmRLEaG06VNYly9UsuXQMY7tz2mjxbnuQ7gUFQqsvcv
SgCD0ZI0D5HGX8GjoI2T/XwnNWcn5hi0jBYuaoRsNtUNsb8Ia4iLko4S6X/IAvAZ
4+HrqRd405heWn2Ak+kKHHnUxTPtROG2jHJKfTo9wvb8R2eKrV1TOSuziMvXZlJo
zUt532OwWGFCrjlaZGmEsf0zaDqJikrrg5WYd2lvSQGVeTaWWv/7xqm3KaVaJUTg
ecZDUKNCSJzFsPhhUDfUwAdAUw0xr7pD98wNmbz3Kn4hNxjzf3sykvFpp568TePe
cdY/YIg3brRce9LqOA+SJydSsgFW54Blf5TqTaWsXHU/XpvM11dnLm8W1ibhuI9F
bAyAUqKP8m8KRK68QaI7AOW3wdfBKCEPLwEem+0zVW4WSUVMU6uBvTZajF+SXdr7
XfK3z8ulyXeV3ecbPbnAOtaI2bGAY+UgEqOdBs6gZ0hQlwoA7Egq9BysjoQIrdKt
6JpIrlZCdNJo+2xtej9IzfACczdm61octgsWPjzdMnTOG11RhMAlq4to8XRkWmXP
8c/y+ckf4jwpqBrJ5BTMm1hPM5qMZRwHuc8N84qgTsdMUxT0Rm77AHT5V6IuT7D+
6JpIrlZCdNJo+2xtej9IzaIkmvaJpE+iiT1qr5zIeuJ50a/O3n6OZWXOjtLTBq7y
4E6dP8WUspqzhTEjwr+QVpROycujoGlrnngcxRsY5chiMD9QJ7QpAyZuAwSgAZGv
9MyxoaNmkfO+QN46XLKV9nlHwNdpEdltPAEN6rhMyni4Pq4V5LEXU/eRuNVHaTxE
mQ7ooL9AKpWmeHPmU50CqMpHOhmIaMM/FRXffc00HZco04wtXDxSQ6/QJCcK2ld+
JzEgbZo9EdV2+KlgoFxTzsqng5NKLSqzKt0TyP5o6ccwiizsKRE2vvkAOqomUyCk
dZWg+4s3ArzKySB0H+7070RzQPiMCZpZPjzaKum2XFhD2aeQO6u8CBTI1Uoa6mlI
oKVl7QxvGraFO8V/vju1ArN2emA+qIZAdClJu0B/wgYrOMIT6gClKyIw1r6oMzPW
47PhVMHjgGmo4luLr0lOQXarkIoO3Rtw4jJdWTaSAFo+HtXI8i/8uZdhHNllk//S
9FTEdJd3ig/W81Ia5ssnuJulVDL7tq03U4JYOl3s8EH48igIfk44jorP3b/SZurd
DpoK7vuC0Gb1n7DadeRShqVz2scNE2uDtjSTpp8nlL55k9QJCTtB/TUt/yK3slYs
lJDeTzRevJUa4prvbgE/s4SNYJ+1UdvHcFULZ6dziDHxowE3zvEnmSCwaxtJyUti
N+0EGOQan2Jip3RqpwDmffJw441CXuVM3qt1UyJZKvsDlfTVql2hHHiD/gDPmeHb
Wd4X97e79XH2z6GW3YPQBeiW2Mi0fCnfgXwy7Ls4/b/6KC8fi+gBZ1Gco0kic8dq
X5lJNEh/TgEt3LJyVUsquDK4Tc2LMUu54cz6th3bgOLbR6ecDDLimJ5CI5YOMSJ7
23aB0v/0wHk+0MCyUPKMH+Rl0uGYXiOUArUmngNKx6DqXmKjThNU0OPZCTdsC2fz
3fB49Y21mttTrRZannBGhuRl0uGYXiOUArUmngNKx6A7WcC3Ac3aAV6gj+3Xjazn
WUMV82IEaIyEXLWps6R1yRyTXUCcKyItbZgvkaQlR/DkZdLhmF4jlAK1Jp4DSseg
kSA8a5MCwiTKzVUo/yG7uFTcmUwmLz+9Z83rohpeAaABBiZL1wzVxuwvfqFW2t5J
Rv0P3TxhFOJN027tOhoF0ZVUt6TXkre8oH5wDTaE0gy0PJ1P0aZitKLO/2dE/l36
kWgrG4f8n046RaPqeDn6eDb/+l+tGWNE0DACYhPGcaQb1rlHOz0FYDWrVqRGU9IL
B8qoiqTZwcHnnFGAcvYz3rHupZCw1+GsE1yzvaDiekjHrcI7DAVwdHIcXP2kKDmH
pbTuyFkGdbHTlxACw70l19Wg0EKPFf5xjhS5vigLyis30Jrxp7O68zXvGLTZj+Oj
mUhGeOItLclo9NoVbocgfXi8Ekvnnxdz2AbbRuCFpBPmoWY+IUkOQRFzwb4+Ocfw
kA1TzuaGdyrvP02MZu4KKinH8oJVexxJ+BjOZ0XZ7zUKkjMyYHRPyCTPL7NWLGIu
zaBFXICOTKzgdFnBPgKOfw8mQ2HdQfEhDdD793ImcP4/1A9KNatOKGEGN20Z2pEJ
amFuWcFJqnjtfm4ScRh6xoc8nAIo2uDHc3/DFbIOPCbKsgygFb4nW6LmpCa8P/Re
neBtrd4J2t8U0d4OOGVR0ELtxFqpAUjzQJWsP1yXAc8uTeHVvFx/vPkMxnXUIrb7
1w9/Q+1T1yN7jqVyEToZ/FAzhEnGJLnxCsJQ6chi6428/QaWLo8bAcLfcDQzOvpb
M6wYyxF8WNClV01cvcfWui8/P4eol6ppN7hiweTNGG4rOMIT6gClKyIw1r6oMzPW
i28+YEnoV+VUBgsqaR2AIfHClyuPf0JFa96/KyXMUAnCPl3ihMuSAmiADxKqxjP7
xok2+un/Er2ZWfErdMEz/jlXv9hg7R5gbp7M5Zxa/VvK+AlgrswtxRtG0yjk6g7g
bpCHgc3mwwzioOM1Fdfiek59rvbPpOOSs7JEh6H0NrxY+WeTG39h85M+778lIBJi
uFKTTiPqyqCShqVzOn/ofD8oDei7UXCIHK5qB5WxkDW8SKs2zXf318fdjzzECFsq
jqt3mmmLjJoQbdd5pxobcOYQZjm8tQZ+TcpKE9Rgs3xZS6lOK7fK+43SzsYvtFzy
WIJ1GTqS8Y98qSrIV8A86fDW0I4G7JjwtOqLYjpS7ZDEXX2ClavD46dMgh30Z8BC
U/b6jMYYPzTFYGI8Z/GRlqNAaIJjpFBp9VFeEumkbgvllJw6PA+XaxLnLL7gVpCf
/A6ZbgCk8C7o8gw3NhNvXMbNMm9uVnuWqpXpu9fTJ+bSU7mucO9Z/0hdrnVZNvgT
v13fe9BETilpDgSsxVnhmHEv7MlGO1gpkuCaRYyoWg/tBNmwK44u7TTn3gSCIeMU
z5c6Nt5Ati11D72WovV0Y7wyWEpItYn6I1cEvC/h6ZwM+ZG9sL4/hyHfIkbHh63P
Jjh08ICGS3a7ivBdAd2m8f0oJYDuaIBnJyyZriIt6gsvu5W4eiwuk8H0xUoYU4WP
zJAfercjTmDy91kR3ccAuRpsqDmcycQ9DXLNc4btMexIixNE5VlzVZlBwMyb104A
rvNPmRDLHx1VPwXzp/iodvwDNKI0vQo31sgaj1PInf//tWjjViDYRiqOqf4Z19y5
NcDXpw85V5xZ7/LQk69VuAQ4MNE8D+i4NnJ8YeNpGO5dJtcRviRIAfNHtZGTZZSt
avW7X8mdQ6c7O+7jT7GYm0V8SIeltwaoE5aYuJtCzeIT07h1Wy51+HRPZIJ2MlaA
8J2dFaymA/w4zdYVpOosQPZi5GY1xO4m2WRIaHesNmmhIxxvR+qKLzKbxu6l29dU
ttjDqg4EGKCyVhynWaC3n7Esl4/k5Zf+oUiAGOt0/FT4c+FhSwZfndnoaKL1sM48
QAjXqtcA+fyWoVFrU7RAeyKwhESkx97vaO7pxqQHLWN75r91Fl+CTcZODWXWe6vH
QICzcnr1vBRtxlseqyex/HYnO7ebSL1h4plJ2vwr/gTIq5JI83plGrw8BLpkQqxO
yFIu+Fq0kFK0Abca1IibflGiwON8BleJAmdU74MX0Wxab2d/neUYOTzxfxG0q/l0
KqHSO821yUaEzZjgKVcUUFLuDoUxNyL8jz0KT4FQD4YRK6W/pAC+J7TduAefJEGu
9iAXD94iu+YGPEn7j9IiWXyfhHt2oLnSXx9Jfl13V3nw1w8PTvhg4Dmi4SHRjoPl
MfBCf1D1KrgSELYpjehXGxTlG0MVM63n6v73fSIdMLMN+PXc6b90PxCtwtsu4/D1
yLUaUNukTdVtgQ30s6+Fz47SjboAKFfZwxuMRsDaPx5FwWrGla4SbCkPmEBMw85b
/hnWTr7QrtjxRP+Kz30yxX0AyUgDigd9rd9gHyIyuKF2MGBWnkKE7oVNd8Pksyab
HljN3y0EuzoLe2NDSrrE+Cv31T/FOmlkfQbJvd+fRReOCcsA482FihsUcN91wJwM
G2kh4iyD/inIaDHJv3rbgp/S2p2KEacZnY1m1m0M4U74c+FhSwZfndnoaKL1sM48
QAjXqtcA+fyWoVFrU7RAe+8yMtwVTqoTAHG5QktbqePvgm6fBYYZJGjsB7SSRqx8
HNtJ4SBkzt8VrYn/idpQiRkyAJPK7cLTOVQagByav/wIkysxnv6ahVx58JFwDI75
p1OuFoDQJpBvf7gAHZBzDLE6cynmGUtCHztwjoyL7Dho763fpQtc+A6phXBg7Wd0
phgZsuJ2urnNHel39+5zEOSXRuvm/lN7ETGBigvChNhHTKr+IsN3LB4dmV4YMLyl
4jo2CjqMt+MFyet913liGC0lQhtCOpwfeZOQl4jQS8lHRbxqf/WDRXbzfbKIeFOZ
DeuwEt6ApEpanyPu4l0e4wnm6Bj4UBxQYXx/2YTXcukRK6W/pAC+J7TduAefJEGu
9iAXD94iu+YGPEn7j9IiWS0kvVD9LlMvfnsSagPsuCUo8mNSO5pJjwN8yCgI/kWf
ooen1x2IRT7+cV4hj8jTk9Xs2lFhMAQVF/kTG3nQCWRAv2kzU19Fxoy8NO5h+atP
bBgvtYo2xDuo5FM8sySaB6Yy4IpWMNguiAwRWbSsEaXX7FSDl9zDJkL2KID6JvNs
GxsV2FkGVhwDIBijUxVksqAtOSXi/i70Dr8OBO8I93QUpjXMIfYkccLQj6kSqGjP
UAwFjAiDqGV2OGrhpSZPjHTeEPChIujGWS6Q7gO2NaUvI/YNSQBpODSUOWCCfB7H
6TXmL4EfwlNjmM52TYP07MPoK5DVm/I3kQkCeSJ1D77z8+j5PswwiJ+56nZ6nZlN
Up3ah8iYI6faEcWSgYxwoEDfLktf5SozylamwFgSbwlxk3ARhSNUJTfpY4lmhN2h
1GINsoMNZw9K+DdMHrPArjP0nCDogeu4wJ5K7s9HKVJxtbewXw7CRr4Gt5uwalUN
FrRffnnSaudW/L1jK26KJQtxsMIXY1ERJuXSn2WC+j+k36GIMUQYygaQQcy1sthg
OW7uSL4Hg45Znfp0mSpjffTECJgyiu5h0g8mMLQHStcPxJqxAF4ltQXPMdfFgQaa
J5qQsPv1c9/cX/wqVUVWBqRB1GAJId1jzkHPtjlaANImIz/rhk8B4vWTQSj1pNoS
/S2stfZTenke/mooijxpOrzlOZE07GjE1dLuDWoZUE4prWdtzgZLLxY9yGUbW6JY
REFaIb++ZDHd4eCD3DZfMG/c9dnmC/WzlzsnjkWluQTCPl3ihMuSAmiADxKqxjP7
3YMw1VoxFiE7V8OmRhst1T7ly0uYuJNWpbTFBbs9B7TPrmdbmBbqaA3ascd2TTS6
5uhwLFRndS+klMyNdyb6x0/Vsqpfpnj1ieLQ9NSHZQT4FKI9e3CC6v9optVKm+YE
4/QkaeEbIaCfMIhiayIf6bsT3OAlElu4JZdtPtwYHNNKqVn3RYsi32PWzX5WWh0w
+zOYj7UVdMvENuuRQHhoYHHynHCraQIka1wsvx87DHGo1v6M6YZZ+BJITZXS+Hv3
LYKqFZVLdFlp4s4zLdAud8HAcmMcFSZymg03VL3kZbTScti/ShY74ea168n7VJwa
nMhpRqhQ4egUDkePa+ayFK4GfS2e3GdOjP7gJ/hLy8YDxFucNBAQB5lfOkFQMnqy
NRs1tGdlVcNM7cJaEto7EpjrzKU9knIvxpFQ41eSTATiDbTq+wviNZNSjh+zCpIS
X/A9k9XuNkx+dwe0Qm9GqFKd2ofImCOn2hHFkoGMcKBA3y5LX+UqM8pWpsBYEm8J
bsYUlAoYbJBgVQF2F52xsi9hBGnldTvXofbzpW6tn4CW9xbnSPcZxMlAqallwZUl
cRusM2sMOncJtd5fY4Ec0nt+IgKrWaYiRw/ekYxoMm6UoNolea8yyZmaxIyx2dnR
sNsRZMx4le5WvLCI0N7z8njUC3eZrPENvfPHSWXU0S8KMz+rKOFlfQBrUAFKCRec
Du2ipTi8LHMeLayaPgR+P0G9V1k3i/3orZxWILW2SL9aW0+8vts+9jBnv0RJZFzW
EiTBThUkqEeJrxsiyxRooDgrvYv+iozMAkeE2X8b9dQT0bApjCuSkvMKxtWHq+OS
aZEGDHcIyiaLD2A7TQK0iMhSLvhatJBStAG3GtSIm37xGXWf9iQ7fKkYh9N8KDWL
UdAALzF+N333MtfpNhECaCxxB7X68t/NGjurDPE2bw/oMJx0V3Du8Tq2Cnb6txTv
RoDaR8PRnXFwgetXbdYqD3JA6zYl5Aaojk3B1RtuEwgpM4PG18Xrnkum7BGsKKp1
vaRTQzXYVCgut36Y7XvCyCgioZhTAgmWfOWY98br5MElGLKjbhrKnvB1f5LAbMoe
qI364RNBpxfQXSBWvzU2pac3//sz+NjaqF5PXR4Nr5jSMkwwBWeGe9wXB8vx6BN3
k7CH6qN0/yJUenxSaaJrwHsSiXcJVXbBRHxWYo4CLC4WxDlqr8sU4TBpr7Ii7GJA
tbbB0cOw7b3Q364+ewT5OLI9SBd0vBcS2+l/jIFY6LoWGEM38BfiJnvb95jFJtkC
DNQO5GEYEBf+fyTemxjM8EOPmJCmlhmAIxcMG2hLf5ZMqol101Xo+IQmKvwW2ooJ
vUufPHHSjK+cCWDHUQkCcJ2iygtALeTqcsZgIMo2OdeIdO8qb2JA+JecvDgSCqaH
eq78HKjXCADHo7+eEY8RVwZAn99cqEyHssBESbXws3C8200KTAQU4/1I43oVFY1z
3uIWf5dGeGBmn5F2wt6r5wtfPu651FFqcXyeVfHcnkS42SRVtqQl54TEMfODSExF
gYa4kNAn5qwxHea22MsIYhqikUVLue9bvZXEL7rsA1K19eofAwgqQ1NtCaoDlytU
znze7hnziu/2CS1TqMXi1xgALjVSLaGatltzf7PAqgXvv4dfOv2/daT/VRY423UE
/b9bbtXuVqdmlRNxx8TrDohBFruW3Hf2/zwo4+STA6i+PgaUiNB0JUvdFIUl7cqC
u4YGaZ3WimKn0Tinf+FBdZJshV9lHhb+b/nXaWBPBvH6gaKBiiJtydFFjCi4YDG6
8BgR2Qw0x157skaUCp6d+Twkr1PQv3cVb97P51019udo4jDacteCSEWNUU0GZ+nn
cIEjdSK3ZojnOsvzJ2ugruHZJz0qvynwgE6QjUzJZuGBqPwX2C2KS+xRjT1JrSKW
44wPYURNqst1lZhCvbcO3+2HZnYnZOOH0p78rfEOCrlIixNE5VlzVZlBwMyb104A
WGXvatRKtFy+wW5INss3usklF9Va2gT4IDFnv2YLVkvRyQOs/z+T4nsNzGSbj3cb
fYo6pBDn+tFj1IE7ilJi5z7HH+6NDCdJodD55YaNeFP6gaKBiiJtydFFjCi4YDG6
FueUbw6nFclvINAO/mDQnr4+BpSI0HQlS90UhSXtyoLy028lXJU1hC+QluHEuYWH
J2aq0BBqvyZm4PhRfpNtO3SxzZRr7KRSs1EaZFcI9kV3dx6sm3BftJVxfPEOMf06
xjZq1TdSyy51JenRX72/ML4DYcOLeJ7BoyL4xjEk4Cd1Ol51IuirFtUbQRejuaXD
iGElwe8Srb+CnLAZ2t8470CNR8xF0ZaGGXFaMnMsCphiZL6z8y4QuRDL3KX9MTXO
Lm91msPcGEOKY2R98Dn/AyL9ay5mXROvUCHEucY7Xc7241zLIJ59tap3hoBdaFrS
hzTh1Q9jzBsoS2NXMJjQ39oSfKWieIzg7GJrT5MauauTHqEoZlfH/koJALrKQhy0
YgBwwGe9CMhGLqAWloj94gNsMNLb0bZNtcuYtgTJHVsHqRy2Z9Mhop4dRcBUeOcu
elMzkOIAIZnnMa66+0gnMXXJufAOoZTWBAINc+7JY/gP+habtwPkV+3PZloIf2sz
vFcxQ2wcq8wCQf57c579xdGqS9AdYidyeAfKw4HUPBia+UV09KlL3Jwi3Vq/mCW5
kNYysAuhb9h23VJbniGyMsqHMN7UPh24N2F6hY0J+3Xrst2qGdcCXXLM6YNP2Yb2
Qdr2wPaKtTncrwHOPlN+f3KYK0AG/g7QlFO3ZP4aXUzjSCdf9j3mjPLMsBXfnQb8
wj5d4oTLkgJogA8SqsYz+4bBPa5NksjCePqcSt903pIHwmKjg/x94xM5rdnYlD/a
1yi1LUteLYtiRNXK5z7n/TAaUDn+zTnvlaqLhyoSb6prTVvgBYRBInlhe39/io8R
ZLc+F0pnwP3hvpV69m/My6QFkQVaJ625voRBSABUmjYxLGvkPwiAtQ320ZZN+dDk
4vzB04GWjDgzX4qrXlvjRus4ejQjZezkY2rrIcqJ6++OLimY3zUHvMBRIcra9Wyn
7TWX8X6qkNMQu4RUwQ55NnwgX/AdqjjKXRyPXBK6xKRqgkn7abIIyjSvlNGO1nGm
2OvIkl2R8ri/VpGgcScbhcge5ZkHd6oD8PBW6fhLUhEHlMqaa41FFrQCDX1wooaG
t3EnQa7vZ2v/BaZ/4LuHATb2Lk4hV+0+rg/uZbpCHFw/L0NsMQVO/493aOM4eVKy
GupL4U6bsTJxOgtcq7zpcyM6zaJY0r8Dge60/D4pcWcccN0Mppj9kKYOYk/YBWh9
jFYVt1Fo1juDJiCGp0CbwPmC/41wKLBDrVjIR26MTxtAB53YpeuDR4BDKnmyw7WW
92ewR0TF7mIKYjg1vbqcrKfCHZbCd4ro4gepHzHOG3kjS5nq3i7dOBj7xT3YOhio
aDUnakGSZGz5Dx1HKWj6epVuQRlyBKL8P8v2f2JFZ+tGBVOFjRI6Q6lzftXcml9Z
ZGZ3Vq1g+jtIJvpeI9m+PatK/8Y58F/gY9sdj0mXWGV+bUzunVAH8F6oF4J2eCHc
G9mWG0VG+lik6GBUFSu4xpCuzB0Oh7FhBk+LTpzr7gS9UkA3QQz5KRFP4TFGvjR0
u1R37O66Y7jLYc5RNokYK97ovftS/wCzwQob7gXvpHUaj6ljZdN80g6PE2XRvJrX
uXoJmK7QPsj9KskIlYgkUohjlweW9XNrnCKzAxu4DCTrC8uUUbbQguT5o+kzqjuO
hsiqpvS0npGKhFXvpotr58zovwEjhbvDczvkn5OGng8mW0r2w4FaouEn4z3AFTuK
wj5d4oTLkgJogA8SqsYz+wbNsSruwyjDvY5kPGrHruoyzBOX26qguRkitoUUzk8j
nUyw6yaopzAiJlkOfbXNcEZx80SwOV165Fd8C1qDzt1BvvX50ySFyu7tl5A+SW1K
fx4VIFS8kMD2FrMkjxo1Ug80lxdIcgiFrRK6RT77OdAJd7dxiSPOpy7Ge8H5zX6J
G/mAbVi44wkIChFSRz7K6ULEyuNX9SZyW24ZRP6gSJIAdxVY7BwVVqvP/PkWDO1M
+v3pLitzH5cYqCm2LQwg/HsXZomM2SgsMkuI7R6i0Rx6qbGgXfcbNEJC6CqFnDT1
H16nzSggWIpoTPTr5n0Uar1aduFP6auCeoi70uSnjGdpLDliddnzefDqb1kMoesY
nnvBNcUal4gSU2RMiUnQ89KrTHShh8j1mLK2P4DL/UmPNUSWavTj5bKSqLbju1nC
85hE5k9Oe3RUnu6O/81DA+G4+87aNx9RzRTZHP9w/JRPkkhk+wF9lllOqkgcRfNt
EDGpwkmeCqflawXTGRjK/GX5R0ETJug9JY874mG/ckBieg1AYUkkeYXBLRnGQLDs
tIMjj/O1oqAHitLimU/Oi+UCHlJjSRa4vvORJ+JWTejBDYz8zfeep7Qq8bP0WqGg
d6rIwpjXBRY9q9yql0zdxFRsQVk0bFVlLzPers9mL02eP54AtK5R4E+tHNCbaaVC
RjfmB4HwR3fwg8oCC/8EWuh6XZSK2UMyW+URXPya9wC/Hxyd1cDgfv3Mjm/FAy0q
FLqKxFyIzatMAtBbuuH6pZ0Y/hi8SB4I+fSpBzJLoveff1p6WJuP5NOIklM3ikML
FEIN9LIXG+bZrlHuhAj5whLt2MaidYMkHFnVNMmecjIrnJRLQdLiFx2Yk7EPKEby
LTsQwfUl/3tBDTJBYP7lfePrBpmuYeBljwqsF3tASFwrq8dTn0mc4js3y/B9VXMh
4ML+DIe26hFn3CsyJtDq3SbyfliRwhjmp+fnRtZjhMk88/sz7pUArq1yhV0TEuJE
FRz9AIai7s+bV71KLGx1+CLt/t73whIT9XxNEC6+nJ4DBxaG71FCZv/+KgP9YD6T
Tnpklln4XALU+XNXWQU4Yz/0cZ0SNtTU9b21j4wedXN9d2irOkfPw25fmKdaafRz
8o9QsqdumHMjZ8IVlKcdCkMrKGddESYKeacrJXd/iCOz/Jdvgswc62kI9qy/Dcsm
qLqDB7CaC46mJG6frgRE5pfLUSOR7VcjfR8QDoq98SHu6ze2gLDHSwEIphJxBxvI
QUQxIQZiin72RkUn6U/x6Hwsa2VZ3zq4idRul372ysCrZs3BOSmGE1td46ABkk01
pzaEGhu7UlPLnW5+udmw5A==
|
e27b9246a72830db5f55bd2180172a0b1c85ab50 | 0be229862c222d7eaed54557954c732b2304ee32 | /sdchx_config.h | 987e233f9b3aef1c78daf9cc8b3b9c8bbe5b7c55 | [
"MIT"
] | permissive | bacek/sdchx_module | cf216d0536b2754320b0794d9b59dee5671c8eb0 | d6687ec5e92341eb9800344b39d3f6158cd34bab | refs/heads/master | 2020-02-26T15:28:37.615037 | 2016-07-28T10:59:27 | 2016-07-28T10:59:27 | 62,856,438 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 957 | h | sdchx_config.h | // Copyright (c) 2015 Yandex LLC. All rights reserved.
// Author: Vasily Chekalkin <bacek@yandex-team.ru>
#ifndef SDCHX_CONFIG_H_
#define SDCHX_CONFIG_H_
extern "C" {
#include <ngx_core.h>
#include <ngx_http.h>
#include <ngx_config.h>
}
#include <vector>
#include "sdchx_pool_alloc.h"
#include "sdchx_dictionary_factory.h"
namespace sdchx {
class DictionaryFactory;
class Config {
public:
explicit Config(ngx_pool_t* pool);
~Config();
static Config* get(ngx_http_request_t* r);
ngx_flag_t enable;
size_t buf_size;
// Switch to use X-Accept-Encoding/X-Content-Encoding headers to work with
// WebWorker implementation of SDCHx.
// This is workaround for Accept-Encoding/Content-Encoding headers are
// "forbidden" to modify within WebWorker.
// See https://fetch.spec.whatwg.org/#forbidden-header-name
ngx_flag_t webworker_mode;
DictionaryFactory dictionary_factory;
};
} // namespace sdch
#endif // SDCHX_CONFIG_H_
|
6c24751f4b28c7e227b53c8387cd2fb454b9e3ed | 601c912e34a4f70f06c1fd45d2eee3d06ba18c29 | /Console Map Engine/Plate.cpp | fb7e53892df18c7b828682e387dfee3cddcdeb67 | [] | no_license | Salaramon/Console-Map-Engine | b66b15206a930b7d63e7f561e82db4d453e84acb | 203468d607070006c3eaf0a5df51029dc424fa11 | refs/heads/main | 2023-02-03T23:10:28.645598 | 2020-12-22T17:38:51 | 2020-12-22T17:38:51 | 316,747,805 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 19 | cpp | Plate.cpp | #include "Plate.h"
|
cfa24b96ea61b6f6ba9d942f3e0ea3946a7e207b | 30d12cd0c83cecbcf6187d7a9b2bbebd220b7d86 | /gameEngProj/src/gameEngine/Model.cpp | db94e5d90badfaea86af6b07cc3a83832664b98e | [] | no_license | jishansingh/myGameEngine | c283f43d13591f042be6de955af8cace057cf97a | 58489c74407ff68e490245937d14ba23fc356738 | refs/heads/master | 2023-07-15T21:42:17.079556 | 2021-09-02T08:23:25 | 2021-09-02T08:23:25 | 285,021,579 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,328 | cpp | Model.cpp | #pragma once
#include"Model.h"
gameEngine::modelLoader* gameEngine::modelLoader::modelLoaderObj;
gameEngine::MeshInstance::MeshInstance(std::shared_ptr<Mesh> mes, std::shared_ptr<Material> som) {
objMesh = mes;
meshInsData = new MeshDataInstance();
meshInsData->objMaterial = som;
}
gameEngine::MeshInstance::MeshInstance(std::shared_ptr<Mesh> mes) {
objMesh = mes;
meshInsData = new MeshDataInstance();
}
gameEngine::MeshInstance::MeshInstance() {
meshInsData = new MeshDataInstance();
}
std::vector<gameEngine::Texture*> gameEngine::modelLoader::loadMaterialTexture(aiMaterial* mat, aiTextureType type, int& cop) {
std::vector<Texture*>textures;
for (int i = 0; i < mat->GetTextureCount(type); i++) {
aiString str;
mat->GetTexture(type, i, &str);
Texture* texture = new Texture(directory + "/" + std::string(str.C_Str()), GL_TEXTURE_2D);
textures.push_back(texture);
}
count += mat->GetTextureCount(type);
//std::cout << textures.size() << std::endl;
return textures;
}
gameEngine::MeshInstance* gameEngine::modelLoader::processMesh(aiMesh* mesh, const aiScene* scene) {
std::vector<float>vertices;
std::vector<unsigned int>indexArr;
std::vector<Texture*>diffTex;
std::vector<Texture*>specTex;
for (int i = 0; i < mesh->mNumVertices; i++) {
//vertex
vertices.push_back(mesh->mVertices[i].x);
vertices.push_back(mesh->mVertices[i].y);
vertices.push_back(mesh->mVertices[i].z);
//normals
vertices.push_back(mesh->mNormals[i].x);
vertices.push_back(mesh->mNormals[i].y);
vertices.push_back(mesh->mNormals[i].z);
//texcoord
glm::vec2 tex_cord;
if (mesh->mTextureCoords[0]) {
vertices.push_back(mesh->mTextureCoords[0][i].x);
vertices.push_back(mesh->mTextureCoords[0][i].y);
}
else {
vertices.push_back(0.f);
vertices.push_back(0.f);
}
}
for (int i = 0; i < mesh->mNumFaces; i++) {
aiFace& fac = mesh->mFaces[i];
assert(fac.mNumIndices == 3);
for (int j = 0; j < fac.mNumIndices; j++) {
indexArr.push_back(fac.mIndices[j]);
}
}
if (mesh->mMaterialIndex >= 0) {
aiMaterial* material = scene->mMaterials[mesh->mMaterialIndex];
int count = 0;
diffTex = loadMaterialTexture(material, aiTextureType_DIFFUSE, count);
specTex = loadMaterialTexture(material, aiTextureType_SPECULAR, count);
}
std::shared_ptr<Material> mat = std::make_shared<Material>(*new Material(diffTex.size() > 0 ? diffTex[0] : NULL, specTex.size() > 0 ? specTex[0] : NULL));
std::shared_ptr<Mesh> mes = std::make_shared<Mesh>(*new Mesh(vertices, indexArr, Mesh::dataDistribution::P3F | Mesh::dataDistribution::N3F | Mesh::dataDistribution::T2F));
return new MeshInstance( mes,mat);
}
void gameEngine::modelLoader::processNode(aiNode* node, const aiScene* scene, std::vector<MeshInstance*>* meshVec) {
for (int i = 0; i < node->mNumMeshes; i++) {
aiMesh* mesh = scene->mMeshes[node->mMeshes[i]];
MeshInstance* tempMesh = processMesh(mesh, scene);
(*meshVec).push_back(tempMesh);
}
for (int i = 0; i < node->mNumChildren; i++) {
processNode(node->mChildren[i], scene, meshVec);
}
}
std::vector<gameEngine::MeshInstance*>* gameEngine::modelLoader::loadModel(std::string path) {
Assimp::Importer importer;
std::vector<MeshInstance*>* modelMesh = new std::vector<MeshInstance*>();
const aiScene* scene = importer.ReadFile(path, aiProcess_Triangulate | aiProcess_FlipUVs);
if (!scene || scene->mFlags && AI_SCENE_FLAGS_INCOMPLETE || !scene->mRootNode) {
std::cout << "ASSIMP ERROR:: " << importer.GetErrorString() << std::endl;
return modelMesh;
}
directory = path.substr(0, path.find_last_of('/'));
processNode(scene->mRootNode, scene, modelMesh);
return modelMesh;
}
gameEngine::modelLoader::modelLoader(std::string path) {
directory = path;
}
void gameEngine::modelLoader::initModelLoader(std::string direcory_name) {
modelLoaderObj = new modelLoader(direcory_name);
}
std::vector<gameEngine::MeshInstance*>* gameEngine::modelLoader::loadModelFromPath(std::string path) {
return modelLoaderObj->loadModel(path);
}
/*void Draw(std::shared_ptr <Shader> shader,const bool instanced = false, const int count = 1) {
for (int i = 0; i < meshes.size(); i++) {
meshes[i]->Draw(shader, instanced, count);
}
}*/
gameEngine::modelLoader::~modelLoader() {
}
void gameEngine::modelLoader::deinitModelLoader() {
delete modelLoaderObj;
} |
d3cf058bc629fd72a91e476506faa44ed33f68e8 | 2e4ddf3e20f5fbd4285f73530000a4a8f54e1ca3 | /ImageGenerator.h | aaaf358f3c9f3801039af89db1a8d42d4d942076 | [] | no_license | as2388/Video-Synthesiser | 68d560301f01232c8e75c008149c991c73adb1db | 0e7610682cba492ed7f13e3ad2d16d2c5090e63f | refs/heads/master | 2020-04-06T07:05:04.174573 | 2016-05-13T09:30:00 | 2016-05-13T09:33:50 | 45,188,577 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 510 | h | ImageGenerator.h | //
// Created by Alexander Simpson on 2016-02-22.
//
#ifndef VIDEOSYNTH_IMAGEGENERATOR_H
#define VIDEOSYNTH_IMAGEGENERATOR_H
#include <qthread.h>
#include <boost/lockfree/queue.hpp>
#include <World/World.h>
class ImageGenerator : public QObject {
Q_OBJECT
private:
boost::lockfree::queue<QImage*> *queue;
public:
World* world;
ImageGenerator();
void setQueue(boost::lockfree::queue<QImage*> *q) {this->queue = q;}
public slots:
void run();
};
#endif //VIDEOSYNTH_IMAGEGENERATOR_H
|
f7894a920570ba119f681628980a8d67b4e748dc | 7315e9f30f1b65fbffb69dbb112b59e3d7a220f3 | /04_Code/adtv/tvcore/include/psisi_parse/diitest.h | f9e7c017089715979b02e05c1686e7cc64db5bca | [] | no_license | cg8530/WorkSplace | 159fb97b9c953939bcdd7be0902875cb1316b801 | b4a6f7e952525919b7eeef94507d457aa6962380 | refs/heads/master | 2021-01-21T23:53:34.000297 | 2013-04-10T05:21:13 | 2013-04-10T05:21:13 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,548 | h | diitest.h | //ZhaoQuanjun 2005-8-2
#ifndef NOVELSUPER_PSISI_PARSE_DIITEST_H_
#define NOVELSUPER_PSISI_PARSE_DIITEST_H_
#include "dii.h"
#include "imp/pretest.h"
namespace novelsuper
{
namespace psisi_parse
{
inline std::ostream& operator << ( std::ostream& os, DiiSectionLoop const& d )
{
return os
<< "{dii_section_loop\n"
<< "module_id " << FmtDec( d.module_id()) << ";\n"
<< "module_size " << FmtDec( d.module_size()) << ";\n"
<< "module_version " << FmtDec( d.module_version()) << ";\n"
<< "module_info_length " << FmtDec( d.module_info_length()) << ";\n"
<< "module_info " << FmtBinary( d.module_info_length(), d.module_info()) << ";\n"
<< "}";
}
inline std::ostream& operator << ( std::ostream& os, DiiSection const& d )
{
return os
<< "{diisection\n"
<< FmtDsmccSection("transaction_id", d) << ";\n"
<< "download_id " << FmtDec( d.download_id()) << ";\n"
<< "block_size " << FmtDec( d.block_size()) << ";\n"
<< "windows_size " << FmtDec( d.window_size()) << ";\n"
<< "tc_download_window " << FmtDec( d.tc_download_window()) << ";\n"
<< "tc_download_scenario " << FmtDec( d.tc_download_scenario()) << ";\n"
<< "compatibility_descriptor " << FmtDec( d.compatibility_descriptor()) << ";\n"
<< "number_of_modules " << FmtDec( d.number_of_modules()) << ";\n"
<< "loop " << FmtLoop( d.loop_begin()) << ";\n"
<< "private_data_length " << FmtDec( d.private_data_length()) << ";\n"
<< "private_data " << FmtBinary(d.private_data_length(), d.private_data()) << ";\n"
<< "}";
}
}
}
#endif
|
f8a914a5084cd73f84a43f72ed61d311f2ea7c95 | 54d2887e3c910f68366bd0aab3c692d54245e22a | /abc/abc_042_125/abc113/c.cpp | ff10f90e5d2b7dd08c37fe3d94b936c7fb8169c0 | [] | no_license | Kevinrobot34/atcoder | 7aec367fd2c6b589e9d583dae7b3c7520ce9fa12 | 482ea508f098f81e4f19522fe518dd22c781aca9 | refs/heads/master | 2022-07-10T23:44:45.290022 | 2022-06-29T11:30:26 | 2022-06-29T11:30:26 | 158,081,477 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 922 | cpp | c.cpp | #include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
struct Town {
int p, y, i;
};
bool cmp1(const Town &a, const Town &b) {
if (a.p == b.p) return (a.y < b.y);
else return (a.p < b.p);
}
bool cmp2(const Town &a, const Town &b) {
return (a.i < b.i);
}
int main() {
int n, m, p, y;
vector<Town> towns;
scanf("%d%d", &n, &m);
for (int i = 0; i < m; i++) {
scanf("%d%d", &p, &y);
towns.push_back((Town){p,y,i});
}
sort(towns.begin(), towns.end(), cmp1);
int p_cur = 0;
int x = 1;
for (int i = 0; i < m; i++) {
if (towns[i].p == p_cur) {
x++;
} else {
x = 1;
p_cur = towns[i].p;
}
towns[i].y = x;
}
sort(towns.begin(), towns.end(), cmp2);
for (int i = 0; i < m; i++) {
printf("%06d%06d\n", towns[i].p, towns[i].y);
}
return 0;
}
|
5dca32eb7531843315c13b75325988d3e93bc683 | eb47bf8011f957e95a84ac64aab29598c59081a1 | /src/BodyPlugin/SplineFilterDialog.h | 6b6bf1416dee83aa93148996c027ce24b755b3a9 | [
"Zlib",
"MIT"
] | permissive | choreonoid/choreonoid | fd776aaab99d9ec544e5ceec04fbc283b8a3aee3 | 94b353722d5b9ff10e9c0ca8982e549f85b5f59f | refs/heads/master | 2023-09-01T12:27:17.849641 | 2023-08-04T13:54:12 | 2023-08-04T13:54:12 | 274,977,786 | 117 | 30 | NOASSERTION | 2023-05-23T08:25:33 | 2020-06-25T17:36:56 | C++ | UTF-8 | C++ | false | false | 218 | h | SplineFilterDialog.h | #ifndef CNOID_BODY_PLUGIN_SPLINE_FILETER_DIALOG_H
#define CNOID_BODY_PLUGIN_SPLINE_FILETER_DIALOG_H
namespace cnoid {
class ExtensionManager;
void initializeSplineFilterDialog(ExtensionManager* ext);
}
#endif
|
6655b60cbef3a77040f0a95e76e09f53ad6a5904 | 97249d2f7af6bf5846a3905f57440878c27b2713 | /main.cpp | cf7953592ff0d619f96a59805d50a6f140451cff | [] | no_license | LayoutXML/Conway-s-Game-of-Life | 52cd5a1f99621d8c0592cd667ae632b3ce647bc1 | b03d11bd0a7f3dba1d39399ad0f4551b300678dd | refs/heads/master | 2022-11-18T06:01:26.796044 | 2020-07-16T19:20:43 | 2020-07-16T19:20:43 | 217,279,723 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 17,367 | cpp | main.cpp | //include statements
#include <iostream>
#include <fstream>
#include <vector>
#include <ctime>
//declare name space
using namespace std;
//declare file names
const string outputFileName = "output.txt";
const string inputFileName = "input.txt";
const string patternFileName = "pattern.txt";
//declare global variables
vector <bool> ruleSet;
vector <bool> prevGen;
vector <bool> currGen;
vector <vector<bool>> prevGen2d; //[row][column]
vector <vector<bool>> currGen2d;
int generationsPerformed = 0;
bool is1d = true;
//declare fuctions to be used in program
bool initialise();
int firstGenerationSize(bool isLength);
int numberOfGenerationsToRun();
void chooseFirstGeneration(size_t size);
void chooseFirstGeneration2d(size_t size, int height);
void chooseRuleSet();
void randomRuleSet();
void performGeneration1d(bool wrap);
void performGeneration2d(bool wrap);
void printGeneration1d();
void printGeneration2d(vector<vector<bool>> generation);
vector < bool > stringToBinary(string input);
string binaryToString(vector < bool > input);
vector < bool > decimalToBinary(int decimal);
int binaryToDecimal(vector < bool > binary);
bool loadFile();
void saveFile();
int getRuleIndex(bool first, bool second, bool third);
void gameOfLife(vector<vector<bool>> board, int ticks);
bool gameOfLifeDecision(bool tl, bool tm, bool tr, bool l, bool itself, bool r, bool bl, bool bm, bool br);
//main program function
int main() {
if (!initialise()) {
return 0;
}
int generations = numberOfGenerationsToRun();
bool wrap = false;
string option;
// ask if to and implement wrap
cout << "Do you want to wrap? [Y/n]: ";
cin >> option;
if (cin.fail()) {
cin.clear();
cin.ignore(10000, '\n');
option = "";
}
if (option == "Y" || option == "y") {
wrap = true;
}
//print generaton
if (is1d) {
printGeneration1d();
} else {
printGeneration2d(currGen2d);
}
for (int i = 0; i < generations; i++) {
if (is1d) {
performGeneration1d(wrap);
} else {
performGeneration2d(wrap);
}
}
//save current generation
saveFile();
return 0;
}
//initialise rule set, number of generations, load in files etc
bool initialise() {
string option;
//ask if to and implement Conway's rule of life
cout << "Do you want to play Conway's Game of Life? [Y/n]: ";
cin >> option;
if (cin.fail()) {
cout << "fail" << endl;
cin.clear();
cin.ignore(10000, '\n');
option = "";
}
if (option == "Y" || option == "y") {
vector<vector<bool>> board;
size_t size = firstGenerationSize(true);
int height = firstGenerationSize(false);
string firstGeneration;
for (int i = 0; i < height; i++) {
cout << "Enter one row of generation of size " << size << ". Dots (.) represent empty values, zeros (0) represent full values (" << i+1 << "/" << height << "): ";
cin >> firstGeneration;
while (firstGeneration.find_first_not_of(".0") != string::npos || firstGeneration.length() != size || cin.fail()) {
cin.clear();
cin.ignore(10000, '\n');
cout << "Illegal characters encountered or wrong generation size. Try again: ";
cin >> firstGeneration;
}
board.push_back(stringToBinary(firstGeneration));
}
gameOfLife(board, numberOfGenerationsToRun());
return false;
}
//load generation from file
cout << "Load from file? [Y/n]: ";
cin >> option;
if (cin.fail()) {
cin.clear();
cin.ignore(10000, '\n');
option = "";
}
bool fileResult = false;
if (option == "Y" || option == "y") {
fileResult = loadFile();
}
if ((option != "Y" && option != "y") || !fileResult) {
cout << "Do you want generation to be 1D? [Y/n]: ";
cin >> option;
if (cin.fail()) {
cin.clear();
cin.ignore(10000, '\n');
option = "";
}
if (option == "Y" || option == "y") {
is1d = true;
chooseFirstGeneration(firstGenerationSize(true));
} else {
is1d = false;
int length = firstGenerationSize(true);
int height = firstGenerationSize(false);
chooseFirstGeneration2d(length, height);
}
}
// ask if to and apply random rule set
if (ruleSet.size() != 8) {
cout << "Ruleset is not defined yet. Apply a random ruleset? [Y/n]: ";
cin >> option;
if (cin.fail()) {
cin.clear();
cin.ignore(10000, '\n');
option = "";
}
if (option == "Y" || option == "y") {
randomRuleSet();
} else {
chooseRuleSet();
}
}
cout << "Ruleset " << binaryToDecimal(ruleSet) << " applied" << endl;
return true;
}
//input first generation of automata
int firstGenerationSize(bool isLength) {
int generationLength;
cout << "Enter the " << (isLength ? "length" : "height") << " of the first generation: ";
cin >> generationLength;
while (generationLength <= 3 || cin.fail()) {
cin.clear();
cin.ignore(10000, '\n');
cout << "Error, input cannot be below 3. Enter a new number: ";
cin >> generationLength;
}
return generationLength;
}
//take in number of generations
int numberOfGenerationsToRun() {
int numberOfGenerations;
cout << "Input the number of generations to run: ";
cin >> numberOfGenerations;
while (numberOfGenerations <= 0 || cin.fail()) {
cin.clear();
cin.ignore(10000, '\n');
cout << "Error, input cannot be below 0. Try again: ";
cin >> numberOfGenerations;
}
return numberOfGenerations;
}
//choose first generation and filter illegal characters
void chooseFirstGeneration(size_t size) {
string firstGeneration;
//take in first row of generation from user
cout << "Enter first generation of size " << size << ". Dots (.) represent empty values, zeros (0) represent full values: ";
cin >> firstGeneration;
while (firstGeneration.find_first_not_of(".0") != string::npos || firstGeneration.length() != size || cin.fail()) {
//check for illegal characters
cin.clear();
cin.ignore(10000, '\n');
cout << "Illegal characters encountered or wrong generation size. Try again: ";
cin >> firstGeneration;
}
currGen = stringToBinary(firstGeneration);
prevGen = currGen;
}
//choose first generation and filter illegal characters for 2D
void chooseFirstGeneration2d(size_t size, int height) {
string firstGeneration;
//take in first row of generation from user
for (int i = 0; i < height; i++) {
cout << "Enter one row of generation of size " << size << ". Dots (.) represent empty values, zeros (0) represent full values (" << i+1 << "/" << height << "): ";
cin >> firstGeneration;
while (firstGeneration.find_first_not_of(".0") != string::npos || firstGeneration.length() != size || cin.fail()) {
//check for illegal characters
cin.clear();
cin.ignore(10000, '\n');
cout << "Illegal characters encountered or wrong generation size. Try again: ";
cin >> firstGeneration;
}
currGen2d.push_back(stringToBinary(firstGeneration));
}
prevGen2d = currGen2d;
}
//take in and error check ruleset
void chooseRuleSet() {
int rulesetDecimal;
cout << "Enter a ruleset between 0 and 255: ";
cin >> rulesetDecimal;
if (rulesetDecimal < 0 || rulesetDecimal > 255 || cin.fail()) {
cin.clear();
cin.ignore(10000, '\n');
cout << "Incorrect value. Try again: ";
cin >> rulesetDecimal;
}
ruleSet = decimalToBinary(rulesetDecimal);
}
//randomise ruleset used
void randomRuleSet() {
srand(time(0));
ruleSet.clear();
for (int i = 0; i < 8; i++) {
ruleSet.push_back(rand() % 2);
}
}
//generate 1 dimensional automata
void performGeneration1d(bool wrap) {
generationsPerformed++;
currGen[0] = ruleSet[getRuleIndex(wrap ? prevGen[currGen.size() - 1] : false, prevGen[0], prevGen[1])];
for (size_t i = 1; i < currGen.size() - 1; i++) {
currGen[i] = ruleSet[getRuleIndex(prevGen[i - 1], prevGen[i], prevGen[i + 1])];
}
currGen[currGen.size() - 1] = ruleSet[getRuleIndex(prevGen[currGen.size() - 2], prevGen[currGen.size() - 1], wrap ? prevGen[0] : false)];
prevGen = currGen;
printGeneration1d();
}
//generate 2 dimensional automata
void performGeneration2d(bool wrap) {
generationsPerformed++;
//top row (done separately to allow wrapping)
if (wrap) {
currGen2d[0][0] = ruleSet[getRuleIndex(prevGen2d[currGen2d.size() - 1][currGen2d[0].size() - 1], prevGen2d[currGen2d.size() - 1][0], prevGen2d[currGen2d.size() - 1][1])];
for (size_t i = 1; i < currGen2d[0].size() - 1; i++) {
currGen2d[0][i] = ruleSet[getRuleIndex(prevGen2d[currGen2d.size() - 1][i - 1], prevGen2d[currGen2d.size() - 1][i], prevGen2d[currGen2d.size() - 1][i + 1])];
}
currGen2d[0][currGen2d[0].size() - 1] = ruleSet[getRuleIndex(prevGen2d[0][currGen2d[0].size() - 2], prevGen2d[0][currGen2d[0].size() - 1], prevGen2d[0][0])];
} else {
currGen2d[0][0] = ruleSet[getRuleIndex(false, false, false)];
for (size_t i = 1; i < currGen2d[0].size() - 1; i++) {
currGen2d[0][i] = ruleSet[getRuleIndex(false, false, false)];
}
currGen2d[0][currGen2d[0].size() - 1] = ruleSet[getRuleIndex(false, false, false)];
}
//other rows
for (size_t i = 1; i < currGen2d.size(); i++) {
currGen2d[i][0] = ruleSet[getRuleIndex(wrap ? prevGen2d[i - 1][currGen2d[0].size() - 1] : false, prevGen2d[i - 1][0], prevGen2d[i - 1][1])];
for (size_t j = 1; j < currGen2d[0].size() - 1; j++) {
currGen2d[i][j] = ruleSet[getRuleIndex(prevGen2d[i - 1][j - 1], prevGen2d[i - 1][j], prevGen2d[i - 1][j + 1])];
}
currGen2d[i][currGen2d[0].size() - 1] = ruleSet[getRuleIndex(prevGen2d[i - 1][currGen2d[0].size() - 2], prevGen2d[i - 1][currGen2d[0].size() - 1], wrap ? prevGen2d[i - 1][0] : false)];
}
prevGen2d = currGen2d;
cout << endl;
printGeneration2d(currGen2d);
}
//generate automata for Conway's game of life
void gameOfLife(vector<vector<bool>> board, int ticks) {
vector<vector<bool>> prevBoard;
cout << endl;
printGeneration2d(board);
for (int i = 0; i < ticks; i++) {
generationsPerformed++;
prevBoard = board;
//top
board[0][0] = gameOfLifeDecision(false, false, false, false, prevBoard[0][0], prevBoard[0][1], false, prevBoard[1][0], prevBoard[1][1]);
for (size_t j = 1; j < board[0].size() - 1; j++) {
board[0][j] = gameOfLifeDecision(false, false, false, prevBoard[0][j - 1], prevBoard[0][j], prevBoard[0][j + 1], prevBoard[1][j - 1], prevBoard[1][j], prevBoard[1][j + 1]);
}
board[0][board[0].size() - 1] = gameOfLifeDecision(false, false, false, prevBoard[0][board[0].size() - 2], prevBoard[0][board[0].size() - 1], false, prevBoard[1][board[0].size() - 2], prevBoard[1][board[0].size() - 1], false);
//middle rows
for (size_t k = 1; k < board.size() - 1; k++) {
board[k][0] = gameOfLifeDecision(false, prevBoard[k - 1][0], prevBoard[k - 1][1], false, prevBoard[k][0], prevBoard[k][1], false, prevBoard[k + 1][0], prevBoard[k + 1][1]);
for (size_t j = 1; j < board[0].size() - 1; j++) {
board[k][j] = gameOfLifeDecision(prevBoard[k - 1][j - 1], prevBoard[k - 1][j], prevBoard[k - 1][j + 1], prevBoard[k][j - 1], prevBoard[k][j], prevBoard[k][j + 1], prevBoard[k + 1][j - 1], prevBoard[k + 1][j], prevBoard[k + 1][j + 1]);
}
board[k][board[0].size() - 1] = gameOfLifeDecision(prevBoard[k - 1][board[0].size() - 2], prevBoard[k - 1][board[0].size() - 1], false, prevBoard[k][board[0].size() - 2], prevBoard[k][board[0].size() - 1], false, prevBoard[k + 1][board[0].size() - 2], prevBoard[k + 1][board[0].size() - 1], false);
}
//bottom row
board[board.size() - 1][0] = gameOfLifeDecision(false, prevBoard[board.size() - 1 - 1][0], prevBoard[board.size() - 1 - 1][1], false, prevBoard[board.size() - 1][0], prevBoard[board.size() - 1][1], false, false, false);
for (size_t j = 1; j < board[0].size() - 1; j++) {
board[board.size() - 1][j] = gameOfLifeDecision(prevBoard[board.size() - 1 - 1][j - 1], prevBoard[board.size() - 1 - 1][j], prevBoard[board.size() - 1 - 1][j + 1], prevBoard[board.size() - 1][j - 1], prevBoard[board.size() - 1][j], prevBoard[board.size() - 1][j + 1], false, false, false);
}
board[board.size() - 1][board[0].size() - 1] = gameOfLifeDecision(prevBoard[board.size() - 1 - 1][board[0].size() - 2], prevBoard[board.size() - 1 - 1][board[0].size() - 1], false, prevBoard[board.size() - 1][board[0].size() - 2], prevBoard[board.size() - 1][board[0].size() - 1], false, false, false, false);
cout << endl;
printGeneration2d(board);
}
}
//decisions made for Conway's game of life
bool gameOfLifeDecision(bool tl, bool tm, bool tr, bool l, bool itself, bool r, bool bl, bool bm, bool br) {
int liveNeighbours = 0;
if (tl) {
liveNeighbours++;
}
if (tm) {
liveNeighbours++;
}
if (tr) {
liveNeighbours++;
}
if (l) {
liveNeighbours++;
}
if (r) {
liveNeighbours++;
}
if (bl) {
liveNeighbours++;
}
if (bm) {
liveNeighbours++;
}
if (br) {
liveNeighbours++;
}
if (itself && liveNeighbours < 2) {
return false;
}
if (itself && liveNeighbours < 4) {
return true;
} else if (itself) {
return false;
}
if (liveNeighbours == 3) {
return true;
}
return false;
}
//print out 1 dimentional automata
void printGeneration1d() {
string value = binaryToString(currGen);
if (generationsPerformed != 0) {
ofstream fr(patternFileName, ios::app);
fr << value << endl;
fr.close();
} else {
ofstream fr(patternFileName);
fr << value << endl;
fr.close();
}
cout << value << endl;
}
//print out 1 dimentional automata
void printGeneration2d(vector<vector<bool>> generation) {
string value;
string wholeGeneration;
for (size_t i = 0; i < generation.size(); i++) {
value = binaryToString(generation[i]);
wholeGeneration += value + '\n';
cout << value << endl;
}
if (generationsPerformed != 0) {
ofstream fr(patternFileName, ios::app);
fr << wholeGeneration << endl;
fr.close();
} else {
ofstream fr(patternFileName);
fr << wholeGeneration << endl;
fr.close();
}
}
//convert string to binary value
vector < bool > stringToBinary(string input) {
vector < bool > output;
for (size_t i = 0; i < input.length(); i++) {
(input[i] == '.') ? output.push_back(0): output.push_back(1);
}
return output;
}
//convert binary value to string
string binaryToString(vector < bool > input) {
string outputString;
for (size_t i = 0; i < input.size(); i++) {
(input[i] == 0) ? outputString += ".": outputString += "0";
}
return outputString;
}
//convert decimal value to binary
vector < bool > decimalToBinary(int decimal) {
vector < bool > binary;
while (decimal != 1) {
binary.insert(binary.begin(), decimal % 2);
decimal /= 2;
}
binary.insert(binary.begin(), 1);
while (binary.size() < 8) {
binary.insert(binary.begin(), 0);
}
return binary;
}
// convert binary to decimal value
int binaryToDecimal(vector < bool > binary) {
int i = 1;
int element;
int decimal = 0;
while (binary.size() != 0) {
element = binary.back();
binary.pop_back();
decimal += element * i;
i *= 2;
}
return decimal;
}
//load in external file
bool loadFile() {
ifstream fi(inputFileName);
if (!fi.is_open()) {
cout << "File reading is unsuccessful. " << endl;
return false;
}
int decimalRuleSet;
fi >> is1d;
fi >> decimalRuleSet;
ruleSet = decimalToBinary(decimalRuleSet);
fi >> generationsPerformed;
string currGenString;
if (is1d) {
fi >> currGenString;
currGen = stringToBinary(currGenString);
prevGen = currGen;
} else {
while (!fi.eof()) {
fi >> currGenString;
currGen2d.push_back(stringToBinary(currGenString));
}
prevGen2d = currGen2d;
}
fi.close();
return true;
}
//save (write to) an external file
void saveFile() {
string option;
cout << "Save results to a file? [Y/n]: ";
cin >> option;
if (cin.fail()) {
cin.clear();
cin.ignore(10000, '\n');
option = "";
}
if (option == "Y" || option == "y") {
ofstream fr(outputFileName);
fr << is1d << endl;
fr << binaryToDecimal(ruleSet) << endl;
fr << generationsPerformed << endl;
if (is1d) {
fr << binaryToString(currGen) << endl;
} else {
for (size_t i = 0; i < currGen2d.size(); i++) {
fr << binaryToString(currGen2d[i]) << endl;
}
}
fr.close();
}
}
//create rule index based off binary rule value
int getRuleIndex(bool first, bool second, bool third) {
//111 110 101 100 011 010 001 000
if (first) {
if (second) {
if (third) {
return 0;
}
return 1;
} else {
if (third) {
return 2;
}
return 3;
}
}
if (second) {
if (third) {
return 4;
}
return 5;
}
if (third) {
return 6;
}
return 7;
}
|
518803b2d1ad14f384a92a3c41cc267aa52561dc | 4bb6fd3fbe9e6c59ddd9b6c9f7df638a33d3f2bf | /src/gpu/GrUniformAggregator.h | af4f7fd8b7ebcbcc12914f29df6bf8d2a18fa226 | [
"BSD-3-Clause"
] | permissive | roylanceMichael/skia | 913900cb5e0be9c780492e8c09afa1e97cafae80 | 68a09699e94237b4b4d3376de620c3cc3c141177 | refs/heads/master | 2021-09-24T15:16:42.748442 | 2021-09-19T06:36:48 | 2021-09-19T07:14:37 | 190,129,968 | 0 | 0 | NOASSERTION | 2019-06-04T04:38:33 | 2019-06-04T04:38:33 | null | UTF-8 | C++ | false | false | 3,515 | h | GrUniformAggregator.h | /*
* Copyright 2021 Google LLC
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef GrUniformAggregator_DEFINED
#define GrUniformAggregator_DEFINED
#include "include/core/SkString.h"
#include "include/private/SkChecksum.h"
#include "src/gpu/GrProcessor.h"
#include <vector>
/** Collects the uniforms from various processors comprising the shaders of a pipeline/program. */
class GrUniformAggregator {
public:
class ProcessorUniforms {
public:
ProcessorUniforms(ProcessorUniforms&&) = default;
ProcessorUniforms& operator=(ProcessorUniforms&&) = default;
/**
* Finds a uniform name by index. The uniform initially has a generic name. It can
* optionally be given a descriptive name via the newBaseName param. However, the caller
* must use the returned name because even if a name is passed the final uniform name will
* be mangled to be unique.
*/
const char* getUniformName(size_t index, const char* newBaseName = nullptr) const;
private:
ProcessorUniforms(const GrProcessor& p,
const SkString& mangleSuffix,
GrUniformAggregator* aggregator);
ProcessorUniforms(const ProcessorUniforms&) = delete;
ProcessorUniforms& operator=(const ProcessorUniforms&) = delete;
GrUniformAggregator* fAgg;
SkString fMangleSuffix;
size_t fBegin = 0;
size_t fEnd = 0;
friend class GrUniformAggregator;
};
struct Record {
SkString name;
const GrProcessor* processor = nullptr;
size_t indexInProcessor = -1;
const GrProcessor::Uniform& uniform() const {
return processor->uniforms()[indexInProcessor];
}
};
GrUniformAggregator() = default;
/**
* Aggregates the uniforms for a processor. This must be called for all processors in a
* program and must be called in this order: GP, FP0-T, FP1-T, ... XP. FPi-T is a pre-order
* traversal of the ith FP in the GrPipeline.
*/
ProcessorUniforms addUniforms(const GrProcessor&, const SkString& mangleSuffix);
/**
* Iterable range of all uniform Records across all processors added.
*/
SkSpan<const Record> records() const {
return SkSpan<const Record>(fUniforms.data(), fUniforms.size());
}
/**
* Iterable range of Records for a given processor index.
*/
SkSpan<const Record> processorRecords(size_t processorIndex) const {
SkASSERT(processorIndex < fProcessors.size());
size_t size = fProcessors[processorIndex].end - fProcessors[processorIndex].begin;
return SkSpan<const Record>(fUniforms.data() + fProcessors[processorIndex].begin, size);
}
int uniformCount() const { return fUniforms.size(); }
/**
* The number of processors whose uniforms have been added to the aggregator, including
* processors that had no valid uniforms.
*/
int numProcessors() const { return fProcessors.size(); }
private:
struct Processor {
const GrProcessor* processor;
size_t begin; // index of first uniform owned by processor in fUniforms.
size_t end; // index of last uniform + 1 owned by processor in fUniforms.
};
std::vector<Processor> fProcessors;
using Records = std::vector<Record>;
Records fUniforms;
};
#endif
|
b0dec1546cec38181e58e006007c75f8e2a3c27c | 8fd5be0d584d22c62c855cbf8dbd23084b2dab49 | /semaine-07/lightingShadow_Durigneux/src/p3d/render/DebugTool.h | 8c37ab3ba06f83a3cf9cb19bbaf4451f0bf3803a | [] | no_license | adurigneux/M3DS | 5c2a5a376dd36d7b68fa317b5d00627ff219f26b | b42a0fdc15aae253993898d2bfb3462445ec24d0 | refs/heads/master | 2016-08-06T22:49:23.785931 | 2015-05-06T16:09:50 | 2015-05-06T16:09:50 | 34,208,273 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,353 | h | DebugTool.h | #ifndef DEBUGTOOL_H
#define DEBUGTOOL_H
#include "GLTool.h"
namespace p3d {
class DebugTool {
public:
virtual ~DebugTool();
DebugTool();
void point(const p3d::Vector3 &p, const std::string &label, const p3d::Vector3 color=p3d::Vector3(0,0,0));
void line(const p3d::Line &l,const p3d::Vector3 &color);
void segment(const p3d::Line &l,const std::string &labelA,const std::string &labelB,const p3d::Vector3 &color=p3d::Vector3(0,0,0));
void frame(const p3d::Matrix4 m,const std::string &label);
void direction(const p3d::Vector3 &p, const p3d::Vector3 &u, const std::string &label, const p3d::Vector3 &color);
void drawPoint();
void drawSegment();
void draw();
void clear();
private:
std::vector<p3d::Vector3> _point;
std::vector<std::string> _labelPoint;
std::vector<p3d::Vector3> _colorPoint;
std::vector<p3d::Line> _line;
std::vector<p3d::Vector3> _colorLine;
std::vector<p3d::Line> _segment;
std::vector<p3d::Vector3> _colorSegment;
std::vector<p3d::Vector3> _directionPoint;
std::vector<p3d::Vector3> _direction;
std::vector<std::string> _labelDirection;
std::vector<p3d::Vector3> _colorDirection;
std::vector<p3d::Matrix4> _frame;
};
void addDebug(const Vector3 &p1,const Vector3 &p2,const std::string &s,const Vector3 &color);
void clearDebug();
void drawDebug();
}
#endif // DEBUGTOOL_H
|
8169dec235e32e4c3b1ae87c431cbbe53e07da11 | 1708d21694731d2bf735110d225190c8c8b7bc9f | /Hollow_Apollo/Hollow_Apollo_With_Internet_Access/Atm_Relay.cpp | 1a0361749275fc351e6f6a9e8c110a6dd11c8ee2 | [] | no_license | pdailey/Arduino | b97c74285e5543a34a65e7872c1f4b29a82597f3 | d8c76b4c57226aabf1afe209e0b791c811fc265c | refs/heads/master | 2021-03-27T09:09:11.795061 | 2017-07-21T21:00:07 | 2017-07-21T21:00:07 | 47,657,489 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,086 | cpp | Atm_Relay.cpp | #include "Atm_Relay.h"
/* Add optional parameters for the state machine to begin()
Add extra initialization code
*/
#define RELAY_ON 0
#define RELAY_OFF 1
Atm_Relay& Atm_Relay::begin(int pin_hp, int pin_hv) {
// clang-format off
const static state_t state_table[] PROGMEM = {
/* ON_ENTER ON_LOOP ON_EXIT EVT_HEAT_P EVT_HEAT_V EVT_OFF EVT_TIMER_HP EVT_TIMER_HV EVT_TIMER_OFF EVT_NEXT ELSE */
/* HEAT_P */ ENT_HEAT_P, -1, -1, -1, HEAT_V, OFF, HEAT_V, -1, -1, HEAT_V, -1,
/* HEAT_V */ ENT_HEAT_V, -1, -1, HEAT_P, -1, OFF, -1, OFF, -1, OFF, -1,
/* OFF */ ENT_OFF, -1, -1, HEAT_P, HEAT_V, -1, -1, -1, HEAT_P, HEAT_P, -1,
};
// clang-format on
Machine::begin( state_table, ELSE );
this->pin_hp = pin_hp; // Save the pins
this->pin_hv = pin_hv;
digitalWrite( pin_hp, RELAY_OFF ); // Set the pin modes
digitalWrite( pin_hv, RELAY_OFF );
pinMode( pin_hp, OUTPUT ); // Set the pin modes
pinMode( pin_hv, OUTPUT );
timer_hp.set( -1 ); // Initialize the timers
timer_hv.set( -1 );
timer_off.set( -1 );
return *this;
}
/* Add C++ code for each internally handled event (input)
The code must return 1 to trigger the event
*/
int Atm_Relay::event( int id ) {
switch ( id ) {
case EVT_TIMER_HP:
return timer_hp.expired(this);
case EVT_TIMER_HV:
return timer_hv.expired(this);
case EVT_TIMER_OFF:
return timer_off.expired(this);
}
return 0;
}
/* Add C++ code for each action
This generates the 'output' for the state machine
Available connectors:
push( connectors, ON_CHANGE, 0, <v>, <up> );
*/
void Atm_Relay::action( int id ) {
switch ( id ) {
case ENT_HEAT_P:
digitalWrite( pin_hp, RELAY_ON );
digitalWrite( pin_hv, RELAY_OFF );
push( connectors, ON_CHANGE, 0, 0, 0 );
return;
case ENT_HEAT_V:
digitalWrite( pin_hp, RELAY_OFF );
digitalWrite( pin_hv, RELAY_ON );
push( connectors, ON_CHANGE, 0, 1, 0 );
return;
case ENT_OFF:
digitalWrite( pin_hp, RELAY_OFF );
digitalWrite( pin_hv, RELAY_OFF );
push( connectors, ON_CHANGE, 0, 2, 0 );
return;
}
}
Atm_Relay& Atm_Relay::automatic( unsigned long h, unsigned long o ) {
timer_hp.set( h );
timer_hv.set( h );
timer_off.set( o );
return *this;
}
/* Optionally override the default trigger() method
Control how your machine processes triggers
*/
Atm_Relay& Atm_Relay::trigger( int event ) {
Machine::trigger( event );
return *this;
}
/* Optionally override the default state() method
Control what the machine returns when another process requests its state
*/
int Atm_Relay::state( void ) {
return Machine::state();
}
/* Nothing customizable below this line
************************************************************************************************
*/
/* Public event methods
*/
Atm_Relay& Atm_Relay::heat_p() {
trigger( EVT_HEAT_P );
return *this;
}
Atm_Relay& Atm_Relay::heat_v() {
trigger( EVT_HEAT_V );
return *this;
}
Atm_Relay& Atm_Relay::off() {
trigger( EVT_OFF );
return *this;
}
Atm_Relay& Atm_Relay::next() {
trigger( EVT_NEXT );
return *this;
}
/*
onChange() push connector variants ( slots 1, autostore 0, broadcast 0 )
*/
Atm_Relay& Atm_Relay::onChange( Machine& machine, int event ) {
onPush( connectors, ON_CHANGE, 0, 1, 1, machine, event );
return *this;
}
Atm_Relay& Atm_Relay::onChange( atm_cb_push_t callback, int idx ) {
onPush( connectors, ON_CHANGE, 0, 1, 1, callback, idx );
return *this;
}
/* State trace method
Sets the symbol table and the default logging method for serial monitoring
*/
Atm_Relay& Atm_Relay::trace( Stream & stream ) {
Machine::setTrace( &stream, atm_serial_debug::trace,
"RELAY\0EVT_HEAT_P\0EVT_HEAT_V\0EVT_OFF\0EVT_TIMER_HP\0EVT_TIMER_HV\0EVT_TIMER_OFF\0EVT_NEXT\0ELSE\0HEAT_P\0HEAT_V\0OFF" );
return *this;
}
|
4d5d45b853f58356cb53987002e5795a88ad398c | dc75245d9a793e454a1ab91de99884511272d98f | /cpp-grade1.2/数据结构/实验六/8645归并排序(非递归算法).cpp | 9e4c86c71f3e530192d664eee7d62be2c4a5e756 | [] | no_license | DumbZarro/SCAU-OJ | b1a66efdeb913cb89ff53c6fc049d98e058258d4 | 50d883adf1f5cbdc12bd44f355f442b018bdafdc | refs/heads/main | 2023-02-05T19:52:35.578472 | 2020-12-25T12:25:48 | 2020-12-25T12:25:48 | 307,070,270 | 0 | 1 | null | null | null | null | GB18030 | C++ | false | false | 2,584 | cpp | 8645归并排序(非递归算法).cpp | #include<iostream>
using namespace std;
void Process(int n);
void MergeSort(int ori[],int n);
void newMerge(int ori[],int tmpArray[],int s,int n);
//没有完成整个归并时,用这个函数归并两个相邻的已排序的数组
void Merge(int ori[],int tmpArray[],int left,int mid,int right);
//归并两个已排好序的数组到tmpArray中
void Output(int op[],int n);//用来输出数组
int main(){
int n;//待排个数
cin >> n;
Process(n);
return 0;
}
void Process(int n){
int ori[n+1];//原数组
for(int i = 1; i <= n; ++i){//读取原数组
cin >> ori[i];
}
if( n > 1){//如果不止一个待排元素,就归并
MergeSort(ori,n);//原始调用 MergeSort
}
else{
Output(ori,n);
}
}
void MergeSort(int ori[],int n){//把原数组切分(这里用的是递推)
int s = 1,tmpArray[n+1];
//s是每趟归并两个数组时,一个数组的长度(最后那个数组长度可能小于s)
while(s < n){
newMerge(ori,tmpArray,s,n);
s *= 2;
}
}
void newMerge(int ori[],int tmpArray[],int s,int n){
//没有完成整个归并时,用这个函数归并两个相邻的已排序的数组
int i = 1;
while(i <= n- 2*s + 1){//利用 i + 2s - 1 <= n可以得出
Merge(ori, tmpArray, i, i+s-1, i+2*s-1);
i += 2*s;
}
if(i<=n-s){//即最后的两个中,后面那个的长度不够s了
Merge(ori, tmpArray, i, i+s-1, n);
}
else{//即归并到最后,只剩一个长度不够s的了,只需直接复制到tmpArray[]中
for(;i<=n;++i){
tmpArray[i] = ori[i];
}
}
//至此,完成一趟归并
//再copy回ori[]中 ,to code here
for(int k = 0; k <= n; ++k){
ori[k] = tmpArray[k];
}
Output(ori,n);
}
void Merge(int ori[],int tmpArray[],int left,int mid,int right){
//归并两个已排好序的数组到tmpArray[]中,然后再copy回ori[]中
int tmpCnt = left; //临时计数器
int rightStart = mid + 1; // mid其实是leftEnd
while(left <= mid && rightStart <= right){
if(ori[left] <= ori[rightStart])
tmpArray[tmpCnt++] = ori[left++];
else
tmpArray[tmpCnt++] = ori[rightStart++];
}
//下面为谁有多就把谁直接放到tmpArray[]中
while(left <= mid){
tmpArray[tmpCnt++] = ori[left++];
}
while(rightStart <= right){
tmpArray[tmpCnt++] = ori[rightStart++];
}
}
void Output(int op[],int n){
for(int i = 1; i <= n; ++i)
cout << op[i] << " ";
cout << endl;
}
|
dd254690dd23849af5ce16caad6d9bb00958de53 | 0e9931a5b96a6f2961662c5e82a82a4bef8021cf | /UnscopedEngine-Demo/Demo/Scenes/DX11/Color/Models/TriangleModel.h | 393a45e03987a4dd24caed1e217eaf9bebcbd009 | [] | no_license | waty2246/UnscopedEngine | 1844c19e7a496d24a5e737749bd7bd106bc2fc16 | ef0d694b7e5eda27979cae6a16925100258d75dd | refs/heads/master | 2023-02-12T03:17:08.927388 | 2020-12-29T14:57:35 | 2020-12-29T14:57:35 | 320,793,162 | 5 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 184 | h | TriangleModel.h | #pragma once
#include"PolygonModel.h"
namespace ue
{
class TriangleModel :public PolygonModel
{
public:
void Init(uintptr_t state = InitializeState::UNSPECIFIED) override;
};
} |
09088e92295737b33c3b666f0350fe35751f22de | 9f3cbb11bc2c4fd98745e1bbe7e05c5172dcdcf1 | /deploy/android_demo/app/src/main/cpp/ppredictor.cpp | a9086bc6c0d4f6af29ee691ca3ffa279c8850c74 | [
"Apache-2.0"
] | permissive | jm12138/License_plate_recognition | 35283556d4c1bb0b8eef62159a0e68d153aedd76 | 8c2c9de8b209c6c65dbec0289ada21b8a69f091b | refs/heads/main | 2023-04-23T10:01:47.291175 | 2021-05-13T14:57:18 | 2021-05-13T14:57:18 | 305,663,631 | 34 | 4 | Apache-2.0 | 2021-03-09T02:43:39 | 2020-10-20T09:55:45 | C++ | UTF-8 | C++ | false | false | 2,034 | cpp | ppredictor.cpp | #include "ppredictor.h"
#include "common.h"
namespace ppredictor {
PPredictor::PPredictor(int thread_num, int net_flag, paddle::lite_api::PowerMode mode) :
_thread_num(thread_num), _net_flag(net_flag), _mode(mode) {
}
int PPredictor::init_nb(const std::string &model_content) {
paddle::lite_api::MobileConfig config;
config.set_model_from_buffer(model_content);
return _init(config);
}
int PPredictor::init_from_file(const std::string &model_content){
paddle::lite_api::MobileConfig config;
config.set_model_from_file(model_content);
return _init(config);
}
template<typename ConfigT>
int PPredictor::_init(ConfigT &config) {
config.set_threads(_thread_num);
config.set_power_mode(_mode);
_predictor = paddle::lite_api::CreatePaddlePredictor(config);
LOGI("paddle instance created");
return RETURN_OK;
}
PredictorInput PPredictor::get_input(int index) {
PredictorInput input{_predictor->GetInput(index), index, _net_flag};
_is_input_get = true;
return input;
}
std::vector<PredictorInput> PPredictor::get_inputs(int num) {
std::vector<PredictorInput> results;
for (int i = 0; i < num; i++) {
results.emplace_back(get_input(i));
}
return results;
}
PredictorInput PPredictor::get_first_input() {
return get_input(0);
}
std::vector<PredictorOutput> PPredictor::infer() {
LOGI("infer Run start %d", _net_flag);
std::vector<PredictorOutput> results;
if (!_is_input_get) {
return results;
}
_predictor->Run();
LOGI("infer Run end");
for (int i = 0; i < _predictor->GetOutputNames().size(); i++) {
std::unique_ptr<const paddle::lite_api::Tensor> output_tensor = _predictor->GetOutput(i);
LOGI("output tensor[%d] size %ld", i, product(output_tensor->shape()));
PredictorOutput result{std::move(output_tensor), i, _net_flag};
results.emplace_back(std::move(result));
}
return results;
}
NET_TYPE PPredictor::get_net_flag() const {
return (NET_TYPE) _net_flag;
}
} |
914239c45e5cc0497baff810ebd416c132c6c503 | e7e497b20442a4220296dea1550091a457df5a38 | /main_project/Journey/test/JourneyLogicAdapter.cpp | 37594d1e7c439f1bf0ba24d3f8b4942dfc9b7a6e | [] | no_license | gunner14/old_rr_code | cf17a2dedf8dfcdcf441d49139adaadc770c0eea | bb047dc88fa7243ded61d840af0f8bad22d68dee | refs/heads/master | 2021-01-17T18:23:28.154228 | 2013-12-02T23:45:33 | 2013-12-02T23:45:33 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,341 | cpp | JourneyLogicAdapter.cpp | #include "JourneyLogicAdapter.h"
#include "boost/lexical_cast.hpp"
#include "Journey/IntSerialize.h"
#include <iostream>
using namespace std;
using namespace MyUtil;
using namespace xce::tripod;
using namespace boost;
using namespace xce::journey::util;
void JourneyLogicAdapter::invote(long key, int guestId) {
xce::tempmutex::Lock lock(tempMutexManagerPtr_, key);
string incCount = count_client_->Inc(lexical_cast<string>(key), "1");
if(incCount == "" || incCount.size() == 0) {
if (getCount(key) == 0) {
count_client_->Set(lexical_cast<string>(key), "1", kJourneyExpire);
}
}
//
map<string, string> set_with_scores;
//Negative value is for the sort!!
set_with_scores.insert(make_pair(lexical_cast<string>(-time_adapter_->get_now()), IntSerialize::serialize(guestId)));
list_client_->ZAdd(lexical_cast<string>(key), set_with_scores);
list_client_->ZRemRangeByRank(lexical_cast<string>(key), 19, -1);
// xce::tempmutex::Lock lock(tempMutexManagerPtr_, key);
// //cout << "It is in the JourneyLogicAdapter::invote()" << endl;
// if(count_client_->Inc(lexical_cast<string>(key), "1") == "") {
// count_client_->Set(lexical_cast<string>(key), "1", kJourneyExpire);
// }
//
// map<string, string> set_with_scores;
//
// //Negative value is for the sort!!
// set_with_scores.insert(make_pair(lexical_cast<string>(-time_adapter_->get_now()), lexical_cast<string>(guestId)));
// list_client_->ZAdd(lexical_cast<string>(key), set_with_scores);
// if (JourneyLogicAdapter::getCount(key) > 0) {
// list_client_->ZRemRangeByRank(lexical_cast<string>(key), 20, -1);
// }
}
IntSeq JourneyLogicAdapter::getList(long key) {
StringListType resultStr;
list_client_->ZRange(lexical_cast<string>(key), &resultStr, 0, 19);
IntSeq result;
for (StringListType::const_iterator iter = resultStr.begin(); iter != resultStr.end(); iter++) {
result.push_back(IntSerialize::unserialize(*iter));
}
return result;
// IntSeq result;
// StringListType strResult;
// if (list_client_->ZRange(lexical_cast<string>(key), &strResult, 0, 19)) {
// result.reserve(strResult.size());
// for(StringListType::const_iterator iter = strResult.begin(); iter != strResult.end(); iter++) {
// result.push_back(lexical_cast<int>(*iter));
// }
// }
// return result;
}
int JourneyLogicAdapter::getCount(long key) {
int result = 0;
string strResult;
if (count_client_->GetAndIgnoreMiss(lexical_cast<string>(key), &strResult)) {
result = lexical_cast<int>(strResult);
}
return result;
}
void JourneyLogicAdapter::reset(long key) {
xce::tempmutex::Lock lock(tempMutexManagerPtr_, key);
count_client_->Set(lexical_cast<string>(key), "0", kJourneyExpire);
list_client_->ZRemRangeByRank(lexical_cast<string>(key), 0, -1);
}
void JourneyLogicAdapter::fillRedis(long key) {
map<string, string> set_with_scores;
set_with_scores.insert(make_pair( "352000000000001", IntSerialize::serialize(123456770)));
set_with_scores.insert(make_pair( "352000000000002", IntSerialize::serialize(123456771)));
set_with_scores.insert(make_pair( "352000000000003", IntSerialize::serialize(123456772)));
set_with_scores.insert(make_pair( "352000000000004", IntSerialize::serialize(123456773)));
set_with_scores.insert(make_pair( "352000000000005", IntSerialize::serialize(123456774)));
set_with_scores.insert(make_pair( "352000000000006", IntSerialize::serialize(123456775)));
set_with_scores.insert(make_pair( "352000000000007", IntSerialize::serialize(123456776)));
set_with_scores.insert(make_pair( "352000000000008", IntSerialize::serialize(123456777)));
set_with_scores.insert(make_pair( "352000000000009", IntSerialize::serialize(123456778)));
set_with_scores.insert(make_pair( "352000000000010", IntSerialize::serialize(123456779)));
set_with_scores.insert(make_pair( "352000000000011", IntSerialize::serialize(123456780)));
set_with_scores.insert(make_pair( "352000000000012", IntSerialize::serialize(123456781)));
set_with_scores.insert(make_pair( "352000000000013", IntSerialize::serialize(123456782)));
set_with_scores.insert(make_pair( "352000000000014", IntSerialize::serialize(123456783)));
set_with_scores.insert(make_pair( "352000000000015", IntSerialize::serialize(123456784)));
set_with_scores.insert(make_pair( "352000000000016", IntSerialize::serialize(123456785)));
set_with_scores.insert(make_pair( "352000000000017", IntSerialize::serialize(123456786)));
set_with_scores.insert(make_pair( "352000000000018", IntSerialize::serialize(123456787)));
set_with_scores.insert(make_pair( "352000000000019", IntSerialize::serialize(123456788)));
set_with_scores.insert(make_pair( "352000000000020", IntSerialize::serialize(123456789)));
set_with_scores.insert(make_pair( "352000000000021", IntSerialize::serialize(123456790)));
list_client_->ZAdd(lexical_cast<string>(key), set_with_scores);
}
int main(int argc, char** argv) {
cout << "please input the input key" << endl;
long key;
cin >> key;
IntSeq result = JourneyLogicAdapter::instance().getList(key);
cout << "[ ";
for (IntSeq::const_iterator iter = result.begin(); iter != result.end(); iter++) {
cout << *iter << " ";
}
cout << "]";
int count = JourneyLogicAdapter::instance().getCount(key);
cout << " key : " << key << " count : " << count << endl;
}
|
d706a6e3cdb24a2d4ecde3c607d68c86e0f01f86 | c6d763361bd1102dc1a9485a2023b5304a6b56bf | /LaunchTimes - RSlipetz/Results.cpp | 47e7cdf825c416b86ddadfc696317ce03c8ef009 | [] | no_license | Slipetz/ProcessLaunch | 2e33e37774df24e3bbcc627769a57ac9c2f3528b | e1a75388358b2bba4e2f040a42bf0938d282dd40 | refs/heads/master | 2021-01-10T15:47:17.219021 | 2015-10-11T01:25:11 | 2015-10-11T01:25:11 | 44,392,001 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,336 | cpp | Results.cpp | #include <string>
#include <iomanip>
#include "Results.h"
Results::Results(LauncherCommand & command) : results(command)
{
GetExitCodeProcess(results.getProcInfo().hProcess, &exitCode);
FILETIME creationTime, exitTime, kernelTime, userTime;
GetProcessTimes(results.getProcInfo().hProcess, &creationTime, &exitTime, &kernelTime, &userTime);
FileTimeToSystemTime(&kernelTime, &kerTime);
FileTimeToSystemTime(&userTime, &usrTime);
}
wostream& operator<<(wostream & out, Results const& result)
{
if (result.hasProcessFailed())
{
out << "LG:" << setw(2) << left << result.getLaunchGroup();
out << " PN:" << result.results.getExecutable();
out << " PM:" << result.results.getParameters();
out << " Error: " << result.results.getErrorMsg();
return out;
}
out << "LG:" << setw(2) << left << result.getLaunchGroup();
out << " K:" << internal << setfill(L'0') << setw(2) << result.kerTime.wMinute << "." << setw(2) << result.kerTime.wSecond << "." << setw(3) << result.kerTime.wMilliseconds;
out << " U:" << setw(2) << result.usrTime.wMinute << "." << setw(2) << result.usrTime.wSecond << "." << setw(3) << result.usrTime.wMilliseconds;
out << " E:" << setfill(L' ') << setw(3) << left << result.exitCode;
out << " PN:" << result.results.getExecutable();
out << " PM:" << result.results.getParameters();
return out;
}
|
0ad32e95ee402a41b1e9f427973777134b4ff733 | c2bc157f3c1af2c6d03bb0bbdd81deaa1b6b28af | /chapter_2/2.8.cpp | f1857c299c1bb2cb2d509d4f7cda5447bbada1c1 | [] | no_license | cmw9957/C-Primer | 6ddc213b0e76bc6053162609b3e254c6ccfd0cbd | 4823f29233eaee97d17c5cb1e39a1dbd8ff05964 | refs/heads/master | 2023-03-02T13:27:12.421150 | 2021-02-02T15:00:48 | 2021-02-02T15:00:48 | null | 0 | 0 | null | null | null | null | UHC | C++ | false | false | 333 | cpp | 2.8.cpp | //확장 문자열을 사용해 2M과 줄바꿈 문자를 출력하는 프로그램을 만든다. 이 프로그램을 수정해 2, 탭, M, 줄바꿈 문자를 출력하게 한다.
#include <iostream>
int main() {
std::cout << ">" << "2M\n" << "<" << std::endl;
std::cout << ">" << "2\tM\n" << "<" << std::endl;
return 0;
}
|
76f9bb25c5e970e12da61db8ba7b16fc561cab14 | da7dff2101a6af25d2a6070e8e1944ae069a8a69 | /tools/extractors/common/crew.h | 5307175ff2cafcda369ad1ee8ef4a25c8dc7ed13 | [
"GPL-3.0-only"
] | permissive | idshibanov/OpenApoc | 2983c72bd07ac1e964fc7a0ba16375834c0ed673 | 50bffd4d7fcfc58bb27f9983d0a9cdcdf43e09f3 | refs/heads/master | 2021-05-20T17:15:18.505076 | 2021-02-20T13:02:06 | 2021-02-20T13:02:06 | 61,973,803 | 2 | 0 | MIT | 2020-07-22T13:39:57 | 2016-06-26T04:35:55 | C++ | UTF-8 | C++ | false | false | 742 | h | crew.h | #pragma once
#include <cstdint>
// These are offsets into UFO2P.EXE
#define CREW_UFO_DOWNED_OFFSET_START 1303904
#define CREW_UFO_DOWNED_OFFSET_END 1304464
#define CREW_UFO_DEPOSIT_OFFSET_START 1304464
#define CREW_UFO_DEPOSIT_OFFSET_END 1305024
#define CREW_ALIEN_BUILDING_OFFSET_START 1645476
#define CREW_ALIEN_BUILDING_OFFSET_END 1646088
struct CrewData
{
uint32_t alien_egg;
uint32_t brainsucker;
uint32_t multiworm;
uint32_t hyperworm;
uint32_t crysalis;
uint32_t anthropod;
uint32_t skeletoid;
uint32_t spitter;
uint32_t popper;
uint32_t megaspawn;
uint32_t psimorph;
uint32_t queenspawn;
uint32_t micronoid;
uint32_t brainsucker_pod_unused;
};
static_assert(sizeof(struct CrewData) == 56, "Invalid crew_data size");
|
e1105fb390cab79a005a7fa149f515ceb06376ca | a9ed1b28c5519cfd3f71c33aa381767544eda221 | /casting.cpp | cf919525a8e0ab428ed201596b50643b70e29ccb | [] | no_license | lmontigny/Practice_Cpp | 3e4974eb68d7ae3fcbace1f1534af4765f4d63bb | d3fb234ee8c70255c93582f7176c431e4085e454 | refs/heads/master | 2021-03-19T06:42:27.869250 | 2020-07-08T17:50:39 | 2020-07-08T17:50:39 | 105,009,126 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,567 | cpp | casting.cpp | // ImplicitCasting.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <string>
#include <iostream>
using namespace std;
// Standart Type COnversion
// Defined Type conversion
// Both implicit and explicit=casting possible
class Entity {
private:
string m_Name;
int m_Age;
public:
Entity(const string& name)
: m_Name(name), m_Age(-1) {}
Entity(int age)
: m_Name("Unknow"), m_Age(age) {}
//explicit Entity(int age)
//: m_Name("Unknow"), m_Age(age) {}
};
void PrintEntity(const Entity& entity) {
}
int main()
{
PrintEntity(22); // implicit due to the constuctor
Entity a("Cherno");
Entity b(22);
Entity cc = "Cherno"; // implicit conversion
// Implicit Standart Type Conversion
// Convert one data type to an other
char c = 'A';
int i = c;
char* pc = 0;
//void f(int i);
//f(c);
int sales = 9;
float avg = (float)sales / 5;
cout << avg << endl;
// Explicit
// satic_cast
int i = 9;
float f = static_cast<float>(i); // convert object from one type to another
dog* pdog = static_cast<dog*>(new yellowdog()); // (down/up casting)
// dynamic cast
dog* pdog = new yellowdog();
yellowdog py = dynamic_cast<yellowdog*>(pd);
// convert pointer/reference from one type to a related type (down cast)
// run time check, if succeed py==pd if fail py==0;
// need virtual function
// const_cast
const char* str = "hello";
char* modifiable = const_cast<char*>(str);
// work with pointer, reference on same type, cast away constness of the object
// being pointed to
return 0;
}
|
e41fa713307bbb6ec30a7fef2c96092b42aa61b0 | 1fe7d86ef39ec05eefadfb3d59266fdae90f0a92 | /edu_examples/maze.h | a0c6b31da77ed2934d59d63b7252e05eeb018ee5 | [] | no_license | sdmace1110/portfolio | c3c23140b00dc9981a2a73bdbbd76e9f335a589c | f9db76791b9c33430102f2c00c1a5e0494e32e57 | refs/heads/master | 2023-08-07T12:12:59.006065 | 2021-09-22T01:34:08 | 2021-09-22T01:34:08 | 401,176,602 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 724 | h | maze.h | /*
Shawn Mace
CSCI 3110-001
Project #5
Due Date October 31, 2018
This is the header file. If supplies header information for functions
to recursive call a function to find the solution to a given maze,
printing out the results and cell tested as it goes.
*/
#ifndef MAZE_H
#define MAZE_H
#include <fstream>
#include <vector>
struct Coordinate
{
double x, y;
Coordinate(double px, double py) : x(px), y(py){}
};
class Maze
{
public:
Maze(std::ifstream&);
void Print();
Coordinate GetStartPt();
void FindExit(int, int, bool&);
private:
char maze[10][10];
int MaxRows;
int MaxCols;
std::vector<Coordinate> coords;
};
#endif // MAZE_H
|
b82e97d0ca8be975859955faacfdbe46db8dde93 | e71d766917e0c0fb6a6afbe4f84711e9e051b5e1 | /LOBPCG-GPU/lib_csr_openmp_cpu/lib_csr.h | 1f94c810a0217c88d008979e8b5f92c0d6b3217a | [] | no_license | fazlay-rabbi/WACCPD_2019_Artifact | ece29f8a5808c544f9a1c3fb929c3bcc1deecc74 | a455b82f2c0b169d06cb8d631ed4b923cbeba3ec | refs/heads/master | 2020-12-13T20:01:03.685534 | 2020-03-03T21:24:03 | 2020-03-03T21:24:03 | 234,516,885 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,622 | h | lib_csr.h | #ifndef LIB_CSR_H
#define LIB_CSR_H
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <sstream>
#include <cstring>
#include <fstream>
using namespace std;
#if defined(USE_MKL)
#include <mkl.h>
#endif
#if defined(USE_LAPACK)
#include <lapacke.h>
#include <cblas.h>
#endif
#include <omp.h>
extern long position;
extern int *colptrs, *irem;
extern int *ia , *ja;
extern int numcols, numrows, nnonzero, nthrds;
extern int nrows, ncols, nnz;
extern int wblk, nrowblks, ncolblks;
//CSB structure
template<typename T>
struct block
{
int nnz;
int roffset, coffset;
unsigned short int *rloc, *cloc;
T *val;
};
void spmm_csr(int row, int col, int nvec, int *row_ptr, int *col_index, double *value, double *Y, double *result);
void _XTY(double *X, double *Y, double *result ,int M, int N, int P, int blocksize);
void transpose(double *src, double *dst, const int N, const int M);
void inverse(double *arr, int m, int n);
void print_mat(double *arr, const int row, const int col);
void make_identity_mat(double *arr, const int row, const int col);
void diag(double *src, double *dst, const int size);
void mat_sub(double *src1, double *src2, double *dst, const int row, const int col);
void mat_addition(double *src1, double *src2, double *dst, const int row, const int col);
void mat_mult(double *src1, double *src2, double *dst, const int row, const int col);
void sum_sqrt(double *src, double *dst, const int row, const int col);
void update_activeMask(int *activeMask, double *residualNorms, double residualTolerance, int blocksize);
void getActiveBlockVector(double *activeBlockVectorR, int *activeMask, double *blockVectorR, int M, int blocksize, int currentBlockSize);
void updateBlockVector(double *activeBlockVectorR, int *activeMask, double *blockVectorR, int M, int blocksize, int currentBlockSize);
void mat_copy(double *src, int row, int col, double *dst, int start_row, int start_col, int ld_dst);
void print_eigenvalues(int n, double* wr, double* wi );
template<typename T>
void read_custom(char* filename, T *&xrem);
// template<typename T>
// void read_custom_csr(char* filename, T *&xrem);
template<typename T>
void csc2blkcoord(block<T> *&matrixBlock, T *xrem);
// template<typename T>
// void spmm_blkcoord(int R, int C, int M, int nthrds, T *X, T *Y, block<T> *H);
// template<typename T>
// void read_ascii(char* filename, T *&xrem);
void custom_dlacpy(double *src, double *dst, int m, int n);
template<typename T>
bool checkEquals( T* a, T* b, size_t outterSize, size_t innerSize);
#endif |
47220a543c6e5aef772c01081857f1d43ae409a1 | e1ecd3146b56dcd9b4ffaf1d343ef64e8c42dc64 | /Codejam/Round_Qualification_2018/codejam2018_Q3/main.cpp | fd0107aabee1fa9a89324f5d9b90ca52a522a0f4 | [] | no_license | wjddlsy/Algorithm | 7bbeca6b5d21867355c88de8b4218bcfe8eeea75 | 385247c63337cae1cf3d9adbf8be38d6f62f2945 | refs/heads/master | 2022-12-04T19:35:48.763646 | 2020-08-23T08:14:29 | 2020-08-23T08:14:29 | 198,079,854 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 451 | cpp | main.cpp | #include <iostream>
#include <vector>
using namespace std;
int main() {
int T;
cin>>T;
for(int t=1; t<=T; ++t){
int A;
cin>>A;
int cnt=0;
int I, J;
while(cnt<1000){
cout<<2<<2;
cin>>I>>J;
if(I==0 && J==0)
break;
}
cin>>I>>J;
//cout<<"Case #"<<t<<": ";
}
std::cout << "Hello, World!" << std::endl;
return 0;
} |
b8a3f7deb684ee8429ea6ba2f8e85f5fb3e3d20b | de97899cfe3a78a2d6fa45f394ae932dae51d01f | /software/Firmware/applications/params.cpp | 86e7cfcde05de35d5045b3f09315c6a0af10c337 | [] | no_license | nongxiaoming/Hexacopter_LPC1549 | f1a66ddba78acd95e3641dbc734bf4cf6b8791d3 | 1fd2434b39fd2cf7b54eea89b012056d1d62c176 | refs/heads/master | 2020-06-04T05:48:34.529703 | 2015-06-03T13:41:36 | 2015-06-03T13:41:36 | 31,605,217 | 0 | 3 | null | null | null | null | GB18030 | C++ | false | false | 4,269 | cpp | params.cpp | /******************** (C) COPYRIGHT 2014 ANO Tech ***************************
* 作者 :匿名科创
* 文件名 :ANO_Param.cpp
* 描述 :参数读取和保存
* 官网 :www.anotc.com
* 淘宝 :anotc.taobao.com
* 技术Q群 :190169595
**********************************************************************************/
#include "params.h"
#include "pidctrl.h"
#include "sensor.h"
#include "string.h"
#include "drv_eeprom.h"
#define PARAMS_SAVE_ADDRESS ((uint32_t)0x00)
static params_t params;
static bool Params_Read(void);
void Params_Init(void)
{
if(Params_Read()==true)
{
fc.pid_group[PIDROLL].kD = params.roll_pid.kd;
fc.pid_group[PIDROLL].kI = params.roll_pid.ki;
fc.pid_group[PIDROLL].kP = params.roll_pid.kp;
fc.pid_group[PIDPITCH].kD = params.pitch_pid.kd;
fc.pid_group[PIDPITCH].kI = params.pitch_pid.ki;
fc.pid_group[PIDPITCH].kP = params.pitch_pid.kp;
fc.pid_group[PIDYAW].kD = params.yaw_pid.kd;
fc.pid_group[PIDYAW].kI = params.yaw_pid.ki;
fc.pid_group[PIDYAW].kP = params.yaw_pid.kp;
fc.pid_group[PIDALT].kD = params.alt_pid.kd;
fc.pid_group[PIDALT].kI = params.alt_pid.ki;
fc.pid_group[PIDALT].kP = params.alt_pid.kp;
fc.pid_group[PIDLEVEL].kD = params.level_pid.kd;
fc.pid_group[PIDLEVEL].kI = params.level_pid.ki;
fc.pid_group[PIDLEVEL].kP = params.level_pid.kp;
fc.pid_group[PIDMAG].kD = params.mag_pid.kd;
fc.pid_group[PIDMAG].kI = params.mag_pid.ki;
fc.pid_group[PIDMAG].kP = params.mag_pid.kp;
sensor.Acc_Offset = params.acc_offset;
sensor.Gyro_Offset = params.gyro_offset;
}else
{
params.roll_pid.kd = fc.pid_group[PIDROLL].kD ;
params.roll_pid.ki = fc.pid_group[PIDROLL].kI ;
params.roll_pid.kp = fc.pid_group[PIDROLL].kP;
params.pitch_pid.kd = fc.pid_group[PIDPITCH].kD ;
params.pitch_pid.ki = fc.pid_group[PIDPITCH].kI ;
params.pitch_pid.kp = fc.pid_group[PIDPITCH].kP ;
params.yaw_pid.kd = fc.pid_group[PIDYAW].kD ;
params.yaw_pid.ki = fc.pid_group[PIDYAW].kI ;
params.yaw_pid.kp = fc.pid_group[PIDYAW].kP ;
params.alt_pid.kd = fc.pid_group[PIDALT].kD ;
params.alt_pid.ki = fc.pid_group[PIDALT].kI ;
params.alt_pid.kp = fc.pid_group[PIDALT].kP ;
params.level_pid.kd = fc.pid_group[PIDLEVEL].kD ;
params.level_pid.ki = fc.pid_group[PIDLEVEL].kI ;
params.level_pid.kp = fc.pid_group[PIDLEVEL].kP;
params.mag_pid.kd = fc.pid_group[PIDMAG].kD ;
params.mag_pid.ki = fc.pid_group[PIDMAG].kI;
params.mag_pid.kp = fc.pid_group[PIDMAG].kP ;
params.acc_offset = sensor.Acc_Offset ;
params.gyro_offset = sensor.Gyro_Offset ;
Params_Save();
}
}
void Params_setAccOffset(Vector3i offset)
{
params.acc_offset = offset;
sensor.Acc_Offset = offset;
}
void Params_setGyroOffset(Vector3i offset)
{
params.gyro_offset = offset;
sensor.Gyro_Offset = offset;
}
void Params_setRollPid(pid_t val)
{
params.roll_pid = val;
fc.pid_group[PIDROLL].kD = val.kd;
fc.pid_group[PIDROLL].kI = val.ki;
fc.pid_group[PIDROLL].kP = val.kp;
}
void Params_setPitchPid(pid_t val)
{
params.pitch_pid = val;
fc.pid_group[PIDPITCH].kD = val.kd;
fc.pid_group[PIDPITCH].kI = val.ki;
fc.pid_group[PIDPITCH].kP = val.kp;
}
void Params_setYawPid(pid_t val)
{
params.yaw_pid = val;
fc.pid_group[PIDYAW].kD = val.kd;
fc.pid_group[PIDYAW].kI = val.ki;
fc.pid_group[PIDYAW].kP = val.kp;
}
void Params_setAltPid(pid_t val)
{
params.alt_pid = val;
fc.pid_group[PIDALT].kD = val.kd;
fc.pid_group[PIDALT].kI = val.ki;
fc.pid_group[PIDALT].kP = val.kp;
}
void Params_setLevelPid(pid_t val)
{
params.level_pid = val;
fc.pid_group[PIDLEVEL].kD = val.kd;
fc.pid_group[PIDLEVEL].kI = val.ki;
fc.pid_group[PIDLEVEL].kP = val.kp;
}
void Params_setMagPid(pid_t val)
{
params.mag_pid = val;
fc.pid_group[PIDMAG].kD = val.kd;
fc.pid_group[PIDMAG].kI = val.ki;
fc.pid_group[PIDMAG].kP = val.kp;
}
bool Params_Read(void)
{
uint8_t *data;
data = (uint8_t *)¶ms;
EEPROM_Read(PARAMS_SAVE_ADDRESS,data,sizeof(params_t));
if(params.magic != MAGIC)
{
return false;
}
return true;
}
void Params_Save(void)
{
uint8_t *data;
params.magic = MAGIC;
data = (uint8_t *)¶ms;
EEPROM_Write(PARAMS_SAVE_ADDRESS,data,sizeof(params_t));
}
|
9de02270445520f8de96064d246da572ef8f9433 | bcc28c9b94dbc910eb3813466af3477dd9761eb8 | /projects/Zumo32U4/IR3Calibrate/IR3Calibrate.ino | 37f9a2ad6bd082a5d70e11b09ef2b919116cc2f7 | [] | no_license | OliviliK/Zumo-Robot | fca3b2eb913bd4f685f24b3b9e6337cf9b734c8c | d9daf655476eb9a191af7b6d08b06b9ebc6a4ab8 | refs/heads/master | 2020-02-26T14:25:38.359134 | 2017-07-26T03:39:51 | 2017-07-26T03:39:51 | 95,600,690 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,159 | ino | IR3Calibrate.ino | /**
* Created by Olavi Kamppari on 7/4/2017.
*/
/**
* Used to calibrate Zumo32U4 line sensor values. This program uses line monitor
* to print program lines for ZumoIR3.cpp. By default, these lines are commented
* out. The active calibration values are selected by uncommenting them
*/
#include <Zumo32U4.h>
#include <ZumoIR3.h>
Zumo32U4Buzzer buzzer;
Zumo32U4Motors motors;
Zumo32U4Encoders encoders;
Zumo32U4ButtonA buttonA;
Zumo32U4ButtonB buttonB;
Zumo32U4ButtonC buttonC;
Zumo32U4LCD lcd;
ZumoIR3 IR3;
#define HIST_SIZE 80
int16_t lineAve[3], bgndAve[3], edgeAve[3];
uint8_t lineHist[3][HIST_SIZE], bgndHist[3][HIST_SIZE], edgeHist[3][HIST_SIZE];
char lineName[32], bgndName[32];
void getNames() {
lcd.clear();
lcd.print(F("Use Ser."));
lcd.gotoXY(0, 1);
lcd.print(F("Monitor"));
while (Serial.available()) Serial.read(); // Flush before reading
Serial.print(F("Enter the name of line and background: "));
char x;
while (!Serial.available());
for (int i = 0; i < 31; i++) {
x = Serial.read();
if (x < ' ' || x == ',') {
lineName[i] = 0;
break;
}
lineName[i] = x;
}
if (x == ',') {
while (x == ',' || x == ' ') x = Serial.read();
bgndName[0] = x;
for (int i = 1; i < 31; i++) {
x = Serial.read();
if (x < ' ' || x == ',') {
bgndName[i] = 0;
break;
}
bgndName[i] = x;
}
}
while (Serial.available()) Serial.read(); // Flush the buffer
Serial.print(lineName);
Serial.print(F(" on "));
Serial.println(bgndName);
}
void setup() {
Serial.begin(115200);
while (!Serial);
getNames(); // To label the values
}
void clearHistograms() {
for (int j = 0; j < HIST_SIZE; j++) {
for (int i = 0; i < 3; i++) {
lineHist[i][j] = 0;
bgndHist[i][j] = 0;
edgeHist[i][j] = 0;
}
}
}
void adjustAve(int16_t sensorNr, int16_t ave[], uint8_t hist[][HIST_SIZE]) {
int16_t base = HIST_SIZE / 2;
int16_t x = base;
int16_t y = hist[sensorNr][x];
int16_t j;
for (int i = 0; i < base; i++) {
j = base - i;
if (hist[sensorNr][j] > y) {
x = j;
y = hist[sensorNr][x] ;
}
j = base + i - 1;
if (hist[sensorNr][j] > y) {
x = j;
y = hist[sensorNr][x] ;
}
}
int16_t delta = x - base;
ave[sensorNr] += delta;
}
void adjustAverages() {
for (int i = 0; i < 3; i++) {
adjustAve(i, lineAve, lineHist);
adjustAve(i, bgndAve, bgndHist);
adjustAve(i, edgeAve, edgeHist);
}
}
void cumulateData(int16_t sensorNr, int16_t sensorVal[], int16_t ave[], uint8_t hist[][HIST_SIZE]) {
int16_t index = (sensorVal[sensorNr] - ave[sensorNr]) + (HIST_SIZE / 2);
if (index >= 0 && index < HIST_SIZE) {
uint8_t x = hist[sensorNr][index];
if (x < 255) hist[sensorNr][index] = x + 1;
}
}
void collectSensorData() {
int16_t val[3];
IR3.readSensors(val);
for (int16_t i = 0; i < 3; i++) {
cumulateData(i, val, lineAve, lineHist);
cumulateData(i, val, bgndAve, bgndHist);
cumulateData(i, val, edgeAve, edgeHist);
}
}
void calcAverages(int16_t ave[]) {
int16_t n = 256;
int16_t val[3];
int32_t sum[3] = {0, 0, 0};
for (int i = 0; i < n; i++) {
delay(10); // Allocate time for "different readings"
IR3.readSensors(val);
for (int j = 0; j < 3; j++) {
sum[j] += val[j];
}
}
for (int j = 0; j < 3; j++) {
ave[j] = sum[j] / n;
}
}
void driveUntil(int16_t leftSpeed, int16_t rightSpeed, int16_t leftTarget, int16_t rightTarget) {
int16_t leftBase = encoders.getCountsLeft();
int16_t rightBase = encoders.getCountsRight();
motors.setSpeeds(leftSpeed, rightSpeed);
do {
int16_t leftDistance = encoders.getCountsLeft() - leftBase;
int16_t rightDistance = encoders.getCountsRight() - rightBase;
if (leftSpeed < 0) {
if (leftDistance <= leftTarget) {
leftSpeed = 0;
motors.setLeftSpeed(leftSpeed);
}
}
if (leftSpeed > 0) {
if (leftDistance >= leftTarget) {
leftSpeed = 0;
motors.setLeftSpeed(leftSpeed);
}
}
if (rightSpeed < 0) {
if (rightDistance <= rightTarget) {
rightSpeed = 0;
motors.setRightSpeed(rightSpeed);
}
}
if (rightSpeed > 0) {
if (rightDistance >= rightTarget) {
rightSpeed = 0;
motors.setRightSpeed(rightSpeed);
}
}
delay(2);
collectSensorData();
} while (leftSpeed || rightSpeed);
}
void turnLeft(uint16_t target) {
driveUntil(-100, 100, -target, target);
}
void turnRight(uint16_t target) {
driveUntil(100, -100, target, -target);
}
void moveForward(uint16_t target) {
driveUntil(75, 75, target, target);
}
void moveBackward(uint16_t target) {
driveUntil(-75, -75, -target, -target);
}
void printCode(int16_t ave[], char *aveName, char *comment) {
Serial.print(F("//\tconst int16_t "));
Serial.print (aveName);
Serial.print (F("[] = {"));
Serial.print(ave[0]); Serial.print(',');
Serial.print(ave[1]); Serial.print(',');
Serial.print(ave[2]); Serial.print(F("};"));
if (strlen(comment)) {
Serial.print(F(" // "));
Serial.print(comment);
}
Serial.println();
}
void calibrateLine() { // Start all sensors on line
calcAverages(lineAve);
moveForward(250);
calcAverages(bgndAve);
clearHistograms();
moveBackward(400);
delay(100);
moveForward(200);
delay(100);
moveBackward(200);
delay(100);
moveForward(150);
delay(100);
adjustAverages();
printCode(lineAve, "lineAve", lineName);
printCode(bgndAve, "bgndAve", bgndName);
}
void waitToStart() {
lcd.gotoXY(0, 0);
lcd.print("Measure ");
delay(300);
}
void calibrateEdge() {
lcd.clear();
lcd.print(F("Press A:"));
lcd.gotoXY(0, 1);
lcd.print(F("Floor"));
buttonA.waitForButton();
waitToStart();
calcAverages(bgndAve);
buzzer.play("L16 cdegreg4");
lcd.clear();
lcd.print(F("Press B:"));
lcd.gotoXY(0, 1);
lcd.print(F("Boarder"));
buttonB.waitForButton();
waitToStart();
calcAverages(lineAve);
buzzer.play("L16 cdegreg4");
lcd.clear();
lcd.print(F("Press C:"));
lcd.gotoXY(0, 1);
lcd.print(F("Ovr Edge"));
buttonC.waitForButton();
waitToStart();
calcAverages(edgeAve);
buzzer.play("L16 cdegreg4");
printCode(lineAve, "lineAve", "Dohyo Boarder");
printCode(bgndAve, "bgndAve", "Dohyo Floor");
printCode(edgeAve, "edgeAve", "Over Dohyo Edge");
}
void loop() {
while (Serial.available()) Serial.read(); // Flush the buffer
int16_t bVoltage = readBatteryMillivolts();
Serial.print(F("Battery voltage = "));
Serial.print(bVoltage);
Serial.println(F(" mV"));
Serial.println(F("Action: 1 = start on line, 2 = start on edge, 9 = enter line name"));
while (!Serial.available());
switch (Serial.read()) {
case '1':
if (bVoltage > 5000) {
calibrateLine();
} else {
Serial.println(F("Too low voltage"));
}
break;
case '2':
calibrateEdge();
break;
case '9':
getNames();
break;
default:
Serial.println("Unknown action");
break;
}
}
|
f9406c70f756211c7b0b4e643cc46eee250b1ae8 | 8750a99e3d6fec5e010fe47f85e1e8ae6986f515 | /editor/CounterStrikeStyle.cpp | b16d46aa1a0a058d51d8985cf4ebfa4548330228 | [
"MIT"
] | permissive | fvazquezf/7542_TpFinal | 616146ace08a795b166325f117aedae367f50323 | 1699d9cf97794186f7e41d3bb2d33ba9239eaa3f | refs/heads/main | 2023-07-17T02:24:13.657946 | 2021-08-19T16:46:36 | 2021-08-19T16:46:36 | 373,550,516 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 625 | cpp | CounterStrikeStyle.cpp | #include "CounterStrikeStyle.h"
#include <QFontDatabase>
CounterStrikeStyle::CounterStrikeStyle() {
font_path = PATH_TO_COUNTER_STRIKE_FONT;
}
void CounterStrikeStyle::setCounterStrikeFont(QDialog* qDialog, int size) {
QFontDatabase::addApplicationFont(font_path);
QFont CounterStrikeFont("Counter-Strike", size, QFont::Normal);
qDialog->setFont(CounterStrikeFont);
}
void CounterStrikeStyle::setCounterStrikeFont(QWidget* qWidget, int size) {
QFontDatabase::addApplicationFont(font_path);
QFont CounterStrikeFont("Counter-Strike", size, QFont::Normal);
qWidget->setFont(CounterStrikeFont);
}
|
b5bb2a3289b4eb47b35f2e7f2b7fddf88920ebf1 | 644238c5c44aae2fcf9aeec03f23aa2cf0e1a462 | /788_Rotated_Digits.cpp | 637c7c14d6cd4b74f238d3f730d35736dbb18d75 | [] | no_license | DenisDesimon/LeetCode | 1775db8b13f08f931ed4f498e47b2b3fe32c3fda | af93d1ac640226e4ac343bdc289b971feaa527a1 | refs/heads/master | 2022-06-01T19:55:29.979515 | 2022-05-23T19:41:45 | 2022-05-23T19:41:45 | 169,120,968 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,160 | cpp | 788_Rotated_Digits.cpp | //#788 Rotated Digits - https://leetcode.com/problems/rotated-digits/
#include <iostream>
#include <unordered_set>
#include <cassert>
using namespace std;
class Solution {
public:
int rotatedDigits(int N) {
int result = 0;
for(int i = 1; i <= N; i++)
{
bool has_changed = false;
int num = i;
while(num)
{
int digit = num % 10;
if(digit == 2 || digit == 5 || digit == 6 || digit == 9)
has_changed = true;
else if(digit == 3 || digit == 4 || digit == 7)
{
has_changed = false;
break;
}
num /= 10;
}
if(has_changed)
result++;
}
return result;
}
};
int main()
{
Solution solution;
int given_N = 10;
int expected_answer = 4;
assert(solution.rotatedDigits(given_N) == expected_answer);
given_N = 1;
expected_answer = 0;
assert(solution.rotatedDigits(given_N) == expected_answer);
return 0;
}
|
2f36aa0aa61773861cb1e82073f21913a4d6eb2f | fda024414036e689368297633756badb78f2a4de | /engine/IO/callbacks.h | fed3062347231e52853cc357cf3a8df05031a91b | [
"BSD-2-Clause"
] | permissive | fLindahl/vortex | c830daf9de0dfe7e9d6e1df1a11419d7f7a4a0f6 | 17c98ae4bf54b1dce4f693815339e1006d5275a0 | refs/heads/master | 2021-09-12T13:23:35.107784 | 2018-04-17T07:58:19 | 2018-04-17T07:58:19 | 84,658,615 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 3,169 | h | callbacks.h |
namespace IO
{
/*
int TextEditCallback(ImGuiTextEditCallbackData* data)
{
//AddLog("cursor: %d, selection: %d-%d", data->CursorPos, data->SelectionStart, data->SelectionEnd);
switch (data->EventFlag)
{
case ImGuiInputTextFlags_CallbackCompletion:
{
// Example of TEXT COMPLETION
// Locate beginning of current word
const char* word_end = data->Buf + data->CursorPos;
const char* word_start = word_end;
while (word_start > data->Buf)
{
const char c = word_start[-1];
if (c == ' ' || c == '\t' || c == ',' || c == ';')
break;
word_start--;
}
// Build a list of candidates
ImVector<const char*> candidates;
for (int i = 0; i < Commands.Size; i++)
if (Strnicmp(Commands[i], word_start, (int)(word_end - word_start)) == 0)
candidates.push_back(Commands[i]);
if (candidates.Size == 0)
{
// No match
AddLog("No match for \"%.*s\"!\n", (int)(word_end - word_start), word_start);
}
else if (candidates.Size == 1)
{
// Single match. Delete the beginning of the word and replace it entirely so we've got nice casing
data->DeleteChars((int)(word_start - data->Buf), (int)(word_end - word_start));
data->InsertChars(data->CursorPos, candidates[0]);
data->InsertChars(data->CursorPos, " ");
}
else
{
// Multiple matches. Complete as much as we can, so inputing "C" will complete to "CL" and display "CLEAR" and "CLASSIFY"
int match_len = (int)(word_end - word_start);
for (;;)
{
int c = 0;
bool all_candidates_matches = true;
for (int i = 0; i < candidates.Size && all_candidates_matches; i++)
if (i == 0)
c = toupper(candidates[i][match_len]);
else if (c == 0 || c != toupper(candidates[i][match_len]))
all_candidates_matches = false;
if (!all_candidates_matches)
break;
match_len++;
}
if (match_len > 0)
{
data->DeleteChars((int)(word_start - data->Buf), (int)(word_end - word_start));
data->InsertChars(data->CursorPos, candidates[0], candidates[0] + match_len);
}
// List matches
AddLog("Possible matches:\n");
for (int i = 0; i < candidates.Size; i++)
AddLog("- %s\n", candidates[i]);
}
break;
}
case ImGuiInputTextFlags_CallbackHistory:
{
// Example of HISTORY
const int prev_history_pos = HistoryPos;
if (data->EventKey == ImGuiKey_UpArrow)
{
if (HistoryPos == -1)
HistoryPos = History.Size - 1;
else if (HistoryPos > 0)
HistoryPos--;
}
else if (data->EventKey == ImGuiKey_DownArrow)
{
if (HistoryPos != -1)
if (++HistoryPos >= History.Size)
HistoryPos = -1;
}
// A better implementation would preserve the data on the current input line along with cursor position.
if (prev_history_pos != HistoryPos)
{
data->CursorPos = data->SelectionStart = data->SelectionEnd = data->BufTextLen = (int)snprintf(data->Buf, (size_t)data->BufSize, "%s", (HistoryPos >= 0) ? History[HistoryPos] : "");
data->BufDirty = true;
}
}
}
return 0;
}
*/
} |
16b8c50abcada989224727e19f7ed1bc383d9e36 | 670200db52a9b659d777cb7636edd623c41fef78 | /source/main/Main.cpp | 8987964a1397d2e59781c0c06d239c25a7b46e3c | [] | no_license | Skipper89rus/EarsExApp_WinQt | 84f1e25848fe105451eb63927c8b98c8b00ceaf2 | caa038af6aab203b4693da1ee3c803281055a295 | refs/heads/master | 2021-01-10T15:42:10.374991 | 2016-09-15T17:30:30 | 2016-09-15T17:30:54 | 49,210,673 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 382 | cpp | Main.cpp | #include <QApplication>
#include "GUI/MainWindow.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
EarsExApp::GUI::Desktop::MainWindow mainWnd;
// MainWindow не должен знать о менеджере!
// TODO: их общение должно происходить через сигналы/слоты
mainWnd.show();
return a.exec();
}
|
4a92cbd2650455ba182439fda45b0ae9c11b42ea | 738255b3e645e692bf45d8643b417405f7732681 | /src/mybench-test.cpp | f3a5586b08f486860056aaa1149cad97d684b849 | [] | no_license | Hokanos/bench-test | b13d6e0061c705f4b474b0de0167537183accb8b | 651d4fc6633426d373024305daa4362aa07cb9eb | refs/heads/master | 2020-12-27T21:30:33.204674 | 2016-09-19T12:04:10 | 2016-09-19T12:04:10 | 68,598,176 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 974 | cpp | mybench-test.cpp | //
// Created by lzaleski on 19.09.16.
//
#include "Fibonacci.h"
#include <vector>
#include <chrono>
#include <iostream>
enum {ITERATIONS = 1000000};
void doBenchmark(unsigned int n);
void workFunction(unsigned int n);
int main() {
//>Arg(10)->Arg(100)->Arg(1000)->Arg(100000)->Arg(10000000);
std::vector<unsigned int> cases = {10, 100, 1000, 100000, 10000000};
for (auto &c : cases)
doBenchmark(c);
}
void doBenchmark(unsigned int n) {
auto begin = std::chrono::high_resolution_clock::now();
workFunction(n);
auto end = std::chrono::high_resolution_clock::now();
double result = static_cast<double>(std::chrono::duration_cast<std::chrono::nanoseconds>(end - begin).count());
double time = result / ITERATIONS;
std::cout << n << " " << time << std::endl;
}
#pragma GCC push_options
#pragma GCC optimize ("O0")
void workFunction(unsigned int n) {
for (int i = 0;i < ITERATIONS;i++)
some_namespace::fibonacci(n);
}
#pragma GCC pop_options |
f5b409d204b9358b64ac01cb5e3e6d2e96e80a7d | bb13d5950b8810d283504ea0fb3a199cec1d0824 | /include/cinolib/gui/qt/surface_mesh_control_panel.h | ca968197ed3cf7e3edb1adbc9cdaba8d4d782dcb | [
"MIT"
] | permissive | snowfox1939/cinolib | 606520af9d8f8f05e66ed4ab520dd07d611a94a0 | 6017d9dd7461e7008df8198563d63526db3ed86a | refs/heads/master | 2020-05-20T21:01:16.566653 | 2019-05-04T18:12:39 | 2019-05-04T18:12:39 | 185,753,889 | 1 | 0 | MIT | 2019-05-09T08:01:26 | 2019-05-09T08:01:20 | C++ | UTF-8 | C++ | false | false | 7,447 | h | surface_mesh_control_panel.h | /********************************************************************************
* This file is part of CinoLib *
* Copyright(C) 2016: Marco Livesu *
* *
* The MIT License *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the "Software"), *
* to deal in the Software without restriction, including without limitation *
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
* and/or sell copies of the Software, and to permit persons to whom the *
* Software is furnished to do so, subject to the following conditions: *
* *
* The above copyright notice and this permission notice shall be included in *
* all copies or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
* FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. 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. *
* *
* Author(s): *
* *
* Marco Livesu (marco.livesu@gmail.com) *
* http://pers.ge.imati.cnr.it/livesu/ *
* *
* Italian National Research Council (CNR) *
* Institute for Applied Mathematics and Information Technologies (IMATI) *
* Via de Marini, 6 *
* 16149 Genoa, *
* Italy *
*********************************************************************************/
#ifndef CINO_SURFACE_MESH_CONTROL_PANEL_H
#define CINO_SURFACE_MESH_CONTROL_PANEL_H
#ifdef CINOLIB_USES_QT
#include <cinolib/scalar_field.h>
#include <cinolib/drawable_isocontour.h>
#include <cinolib/drawable_vector_field.h>
#include <cinolib/gui/qt/glcanvas.h>
#include <iostream>
#include <QWidget>
#include <QLabel>
#include <QGroupBox>
#include <QComboBox>
#include <QSlider>
#include <QCheckBox>
#include <QDoubleSpinBox>
#include <QRadioButton>
#include <QPushButton>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QFileDialog>
#include <QColorDialog>
namespace cinolib
{
template<class Mesh>
class SurfaceMeshControlPanel
{
typedef typename Mesh::M_type M;
typedef typename Mesh::V_type V;
typedef typename Mesh::E_type E;
typedef typename Mesh::P_type P;
public:
SurfaceMeshControlPanel(Mesh *m, GLcanvas *canvas, QWidget *parent = NULL);
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
void show();
protected:
void connect();
void set_title();
void set_tex1d();
void set_tex2d();
void set_isocurve();
void set_slice();
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Mesh *m;
DrawableIsocontour<M,V,E,P> isocontour;
DrawableVectorField gradient;
GLcanvas *canvas;
QWidget *widget;
QHBoxLayout *global_layout;
QFont global_font;
//
QPushButton *but_load;
QPushButton *but_save;
QCheckBox *cb_show_mesh;
QRadioButton *rb_point_shading;
QRadioButton *rb_flat_shading;
QRadioButton *rb_smooth_shading;
//
QRadioButton *rb_vert_color;
QRadioButton *rb_poly_color;
QRadioButton *rb_tex1D;
QRadioButton *rb_tex2D;
QPushButton *but_set_vert_color;
QPushButton *but_set_poly_color;
QPushButton *but_load_tex2d;
std::string tex2d_filename;
QComboBox *cb_tex1D_type;
QComboBox *cb_tex2D_type;
QSlider *sl_tex2D_density;
QPushButton *but_serialize_field;
QPushButton *but_deserialize_field;
//
QCheckBox *cb_wireframe;
QSlider *sl_wireframe_width;
QSlider *sl_wireframe_alpha;
QPushButton *but_wireframe_color;
//
QCheckBox *cb_isocurve;
QPushButton *but_isocurve_color;
QSlider *sl_isocurve_width;
QSlider *sl_isovalue;
//
QCheckBox *cb_gradient;
QSlider *sl_gradient_size;
QPushButton *but_gradient_color;
QPushButton *but_gradient_serialize;
QPushButton *but_gradient_deserialize;
//
QSlider *sl_slice_x;
QSlider *sl_slice_y;
QSlider *sl_slice_z;
QSlider *sl_slice_l;
QSlider *sl_slice_q;
QCheckBox *cb_slice_flip_x;
QCheckBox *cb_slice_flip_y;
QCheckBox *cb_slice_flip_z;
QCheckBox *cb_slice_flip_q;
QCheckBox *cb_slice_flip_l;
QRadioButton *rb_slice_AND;
QRadioButton *rb_slice_OR;
QPushButton *but_slice_reset;
//
QCheckBox *cb_marked_edges;
QPushButton *but_marked_edges_color;
QSlider *sl_marked_edges_width;
//
QSlider *sl_ambient_occlusion;
QPushButton *but_compute_AO;
//
QComboBox *cb_actions;
};
}
#ifndef CINO_STATIC_LIB
#include "surface_mesh_control_panel.cpp"
#endif
#endif // #ifdef CINOLIB_USES_QT
#endif // CINO_SURFACE_MESH_CONTROL_PANEL_H
|
7ae950c6a6fc7d3c1c8b60db70f1c9dd6a53b0fd | bb651b604f29be27e65ece0f148ee84586ba75b2 | /Move Even numbers before Odd/C++/exchangeevenodd.cpp | 2df7e0376a2bdff21cd152e86bfc118821f8e055 | [] | no_license | maryada6/Algo-Data-Structure | 1b76b921b6789cf3361b9d307e2ab02633cf1a29 | c6cf58dac18ed618a30bf894a683455b86777e50 | refs/heads/master | 2022-12-27T04:43:19.238934 | 2020-09-30T18:33:49 | 2020-09-30T18:33:49 | 300,017,394 | 0 | 1 | null | 2020-09-30T18:32:50 | 2020-09-30T18:32:49 | null | UTF-8 | C++ | false | false | 2,840 | cpp | exchangeevenodd.cpp | #include <iostream>
#include <utility>
#include <cassert>
class LinkedList
{
struct Node
{
int data;
Node * next = nullptr;
Node(int value) : data(std::move(value)), next(nullptr) {}
};
Node *head;
public:
LinkedList() : head(nullptr) {}
~LinkedList()
{
Node *tmp = nullptr;
while (head)
{
tmp = head;
head = head->next;
delete tmp;
}
head = nullptr;
}
void insert(int);
void exchangeEvenOdd();
void printList() const;
private:
static void advance(Node*& node)
{
assert (node != nullptr);
node = node->next;
}
Node* getLastNode()
{
Node *node = head;
while (node->next != nullptr)
node = node->next;
return node;
}
bool isOdd(int num)
{
if (num % 2 != 0)
return true;
else
return false;
}
};
void LinkedList::insert(int value)
{
Node *node = new Node(std::move(value));
Node *tmp = head;
if (tmp == nullptr)
{
head = node;
}
else
{
tmp = getLastNode();
tmp->next = node;
}
}
void LinkedList::exchangeEvenOdd()
{
Node *node = nullptr;
Node *lastNodeToTest = getLastNode();
Node *tail = lastNodeToTest;
while (isOdd(head->data) == true)
{
node = head;
advance(head);
tail->next = node;
advance(tail);
}
Node *tmp = head;
Node *curr = head;
while (tmp->next != lastNodeToTest)
{
if (isOdd(curr->next->data) == true)
{
node = curr->next;
curr->next = node->next;
tail->next = node;
advance(tail);
}
else
{
//advance "curr" and "tmp" only when next node to it is even
advance(curr);
advance(tmp);
}
}
if (isOdd(curr->next->data) == true && tmp->next == lastNodeToTest)
{
node = lastNodeToTest;
curr->next = lastNodeToTest->next;
tail->next = lastNodeToTest;
advance(tail);
}
tail->next = nullptr;
lastNodeToTest = nullptr;
node = nullptr;
}
void LinkedList::printList() const
{
if (head == nullptr)
{
std::cout << "Empty List \n";
return;
}
Node *node = head;
while (node != nullptr)
{
std::cout << node->data << " ";
advance(node);
}
std::cout << "\n";
}
int main()
{
LinkedList ll1;
ll1.insert(1);
ll1.insert(2);
ll1.insert(3);
ll1.insert(4);
ll1.insert(5);
ll1.insert(6);
ll1.insert(7);
std::cout << "Original List : ";
ll1.printList();
ll1.exchangeEvenOdd();
std::cout << "New List : ";
ll1.printList();
}
|
cfc57eb764e1f92973d3ce1bc81e7f1b9993a056 | f5ec6ba1baf301e08728d8892d2a35e59f20b718 | /src/crosschain/interblockchain.cpp | 679c1a46cdc569c46ee03ea346af6bcee1c90941 | [
"MIT"
] | permissive | bitcointalkcoin/bitcointalkcoin | 26434eb812e9cedaf174fcafe0409fc4ed5a4c76 | c9112c3b8ce05ee78fe69822035cc3d8bdbca903 | refs/heads/master | 2020-06-26T14:37:43.515919 | 2019-12-02T17:46:15 | 2019-12-02T17:46:15 | 199,659,333 | 0 | 1 | MIT | 2019-12-02T17:46:17 | 2019-07-30T13:41:31 | C++ | UTF-8 | C++ | false | false | 1,314 | cpp | interblockchain.cpp | // Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <crosschain/interblockchain.h>
#include <protocol.h>
#include <chainparams.h>
#include <util/strencodings.h>
#include <boost/foreach.hpp>
void CIbtp::LoadMsgStart()
{
vChains.push_back(SChain("talkcoin", "TALK", 0xf7, 0xba, 0xd4, 0xa8, 8372));
vChains.push_back(SChain("cryptotalkcoin", "CRT", 0xf7, 0xba, 0xd4, 0xa9, 8383));
vChains.push_back(SChain("Codex", "CDX", 0xf7, 0xba, 0xd4, 0xaa, 8384));
}
bool CIbtp::IsIbtpChain(const unsigned char msgStart[], std::string& chainName)
{
bool bFound = false;
BOOST_FOREACH(SChain p, vChains)
{
unsigned char pchMsg[4] = { p.pchMessageOne, p.pchMessageTwo, p.pchMessageThree, p.pchMessageFour };
if(memcmp(msgStart, pchMsg, sizeof(pchMsg)) == 0)
{
bFound = true;
chainName = p.sChainName;
LogPrintf("Found Supported chain: %s\n", p.sChainName.c_str());
}
}
return bFound;
}
//need to specify addresses for burn
//need to specify either floating or fixed exchange rates
// need to specify limit on the amounts that can be transferred
// need to specify time-frame, ie blocks when it can be done for each coin
|
4d1908ae4f139490222bb1ca39c6697b7f0ad081 | 6756df0e808c1c0a110ca39a4cd6ebc1b435ca70 | /抽象类型/未命名6.cpp | 70fccfae464c98a1b82246b664cd3aec03f84dc6 | [] | no_license | wangrangzhi/thinkincplusplus | 23ae35f984f33196460af83a1dc6eaea30197fe0 | 7f54e70e415d1ce49d01bf290408a0cc25340a7e | refs/heads/master | 2021-01-01T15:30:49.198771 | 2014-05-21T10:47:52 | 2014-05-21T10:48:04 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 453 | cpp | 未命名6.cpp | #include <iostream>
#include <cstring>
#include <cstddef>
using namespace std;
char* copy(char* s1)
{
size_t len = strlen(s1);
char* s2 = new char[len + 1];
strcpy(s1, s1);
return s2;
}
int main(){
char* first = "read my lips";
char* second = copy(first);
cout << "first == \"" << first << "\" at " << static_cast<void *>(first) <<endl;
cout << "second == \"" << second << "\" at " << static_cast<void *>(second) <<endl;
delete [] second;
} |
c4e0d56a065da6b5024481015919b74192a31f19 | a679dba6ef0364962b94ed65d0caad1a88da6c43 | /OrginalServerCode/OrginalCode/labixiaoxin/server/ServerEngine/Base/Log/LogBase.cpp | 430feb7bb849e74cefd2d5ccab74d0ff00294cc8 | [] | no_license | w5762847/Learn | 7f84933fe664e6cf52089a9f4b9140fca8b9a783 | a5494181ea791fd712283fa8e78ca0287bf05318 | refs/heads/master | 2020-08-27T05:43:35.496579 | 2016-12-02T12:16:12 | 2016-12-02T12:16:12 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,799 | cpp | LogBase.cpp | #include "LogBase.h"
#include <time.h>
#include "ace\Condition_Thread_Mutex.h"
#include "ace\Null_Condition.h"
#include "ace\Guard_T.h"
#include "../../GameBase/Common/GameUtils.h"
int CLogBase::RecordLog(E_Log_Type eType, const std::string &strLog)
{
if (eType > Log_Type_Others)
{
return -1;
}
//time_t tNow = time(NULL);
//tm t = *gmtime(&tNow);
//char buff[32]= {};
//strftime(buff, 32, "%Y-%m-%d %H:%M:%S", &t); // buff is what u want.
char strTime[32] = {};
GameUtils::get_current_time_str(strTime);
std::string strRecord = strTime + m_Log_Tag[eType] + strLog + "\n";
ACE_Guard<ACE_Recursive_Thread_Mutex> guard(m_AllLogLock);
switch(eType)
{
case Log_Type_Info:
{
//change by xxj 2015/07/28 14: 07:43
// if (m_vecINFOLog.size() >= MAX_LOG_NUM)
// {
// if (m_iINFOLogOffset < MAX_LOG_NUM)
// {
// m_vecINFOLog[m_iINFOLogOffset++] = strRecord;
// }
// else
// {
// m_vecINFOLog[0] = strRecord;
// m_iINFOLogOffset = 1;
// }
// }
// else
// {
// m_vecINFOLog.push_back(strRecord);
// ++m_iINFOLogOffset;
// }
}break;
case Log_Type_Warning:
{
if (m_vecWARNINGLog.size() >= MAX_LOG_NUM)
{
if (m_iWARNINGLogOffset < MAX_LOG_NUM)
{
m_vecWARNINGLog[m_iWARNINGLogOffset++] = strRecord;
}
else
{
m_vecWARNINGLog[0] = strRecord;
m_iWARNINGLogOffset = 1;
}
}
else
{
m_vecWARNINGLog.push_back(strRecord);
++m_iWARNINGLogOffset;
}
}break;
case Log_Type_Error:
{
if (m_vecERRORLog.size() >= MAX_LOG_NUM)
{
if (m_iERRORLogOffset < MAX_LOG_NUM)
{
m_vecERRORLog[m_iERRORLogOffset++] = strRecord;
}
else
{
m_vecERRORLog[0] = strRecord;
m_iERRORLogOffset = 1;
}
}
else
{
m_vecERRORLog.push_back(strRecord);
++m_iERRORLogOffset;
}
}break;
case Log_Type_Fatal:
{
//change by xxj 2015/07/28 14: 38:20
// if (m_vecFATALLog.size() >= MAX_LOG_NUM)
// {
// if (m_iFATALLogOffset < MAX_LOG_NUM)
// {
// m_vecFATALLog[m_iFATALLogOffset++] = strRecord;
// }
// else
// {
// m_vecFATALLog[0] = strRecord;
// m_iFATALLogOffset = 1;
// }
// }
// else
// {
// m_vecFATALLog.push_back(strRecord);
// ++m_iFATALLogOffset;
// }
}break;
case Log_Type_Fucking:
{
if (m_vecFUCKINGLog.size() >= MAX_LOG_NUM)
{
if (m_iFUCKINGLogOffset < MAX_LOG_NUM)
{
m_vecFUCKINGLog[m_iFUCKINGLogOffset++] = strRecord;
}
else
{
m_vecFUCKINGLog[0] = strRecord;
m_iFUCKINGLogOffset = 1;
}
}
else
{
m_vecFUCKINGLog.push_back(strRecord);
++m_iFUCKINGLogOffset;
}
}break;
case Log_Type_Others:
{
if (m_vecOTHERSLog.size() >= MAX_LOG_NUM)
{
if (m_iOTHERSLogOffset < MAX_LOG_NUM)
{
m_vecOTHERSLog[m_iOTHERSLogOffset++] = strRecord;
}
else
{
m_vecOTHERSLog[0] = strRecord;
m_iOTHERSLogOffset = 1;
}
}
else
{
m_vecOTHERSLog.push_back(strRecord);
++m_iOTHERSLogOffset;
}
}break;
}
return 0;
}
void CLogBase::InitLogTag()
{
m_Log_Tag.push_back("[INFO]");
m_Log_Tag.push_back("[WARNING]");
m_Log_Tag.push_back("[ERROR]");
m_Log_Tag.push_back("[FATAL]");
m_Log_Tag.push_back("[FUCKING]");
m_Log_Tag.push_back("[OTHERS]");
m_iINFOLogOffset = 0;
m_iWARNINGLogOffset = 0;
m_iERRORLogOffset = 0;
m_iFATALLogOffset = 0;
m_iFUCKINGLogOffset = 0;
m_iOTHERSLogOffset = 0;
m_iINFOWriteOffset = 0;
m_iWARNINGWriteOffset =0;
m_iERRORWriteOffset = 0;
m_iFATALWriteOffset = 0;
m_iFUCKINGWriteOffset = 0;
m_iOTHERSWriteOffset = 0;
} |
ad323eb9ff4aa8de7812d1c4909406f8999be925 | fd650e01666d05941b2a0477adf764b643d35da4 | /src/CompassTests.ino | dfbf490d6631b4b53737106aab746f61666a7235 | [] | no_license | stupsi99/00-Antenna-Tracker-Main | 36bc6a207df77bcdf710432c31f9d7864621380b | ee590c13a6f6900f3693fd2847d58f0ac255682c | refs/heads/master | 2020-04-06T07:08:59.802504 | 2016-06-21T14:07:48 | 2016-06-21T14:07:48 | 61,573,907 | 0 | 0 | null | 2016-06-21T14:07:48 | 2016-06-20T19:18:44 | Arduino | UTF-8 | C++ | false | false | 666 | ino | CompassTests.ino | #include <Arduino.h>
void runHeadings(){
Magnetometer.readHeading();
float magnetometerHeading = Magnetometer.heading/10.0;
//Move to zero degrees
while (magnetometerHeading >= 10) {
digitalWrite(eleDriverEnable, LOW); //Low = enabled
digitalWrite(eleDriverDirection, LOW);
digitalWrite(eleDriverMs1, LOW);
digitalWrite(eleDriverMs2, LOW);
digitalWrite(eleDriverMs3, LOW);
digitalWrite(eleDriverStep, HIGH);
delay(1);
digitalWrite(eleDriverStep, LOW);
delay(1);
disableMotors();
Magnetometer.readHeading();
magnetometerHeading = Magnetometer.heading/10.0;
Serial.println(magnetometerHeading);
}
}
|
9130bc5fb159e0940496403a7974d86363066d43 | f29a533b629548b4b4b98703643b1d6b9d7f8ee7 | /ch09/golf.cpp | c750340095bd6ae1414b05272edace8d2db91077 | [] | no_license | ZhaoPeixiao/CPlusPrimerPlus | 9dc8fb799aca4f0e3f03dce3ba480dc59d03432b | 579e027f0d3157892212f5feefcc2ed1649f1dd1 | refs/heads/master | 2023-03-10T22:17:52.023717 | 2021-02-22T09:39:51 | 2021-02-22T09:39:51 | 335,290,278 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 588 | cpp | golf.cpp | #include"golf.h"
void setgolf(golf& g, const char* name, int hc)
{
strcpy_s(g.fullname, name);
g.handicap = hc;
}
int setgolf(golf& g)
{
cout << "Please enter the full name of golf player: ";
cin.getline(g.fullname, Len);
if (strcmp(g.fullname, "") == 0)
{
return 0;
}
cout << "Please enter the hanicap of golf player: ";
cin >> g.handicap;
cin.get();
return 1;
}
void handicap(golf& g, int hc)
{
g.handicap = hc;
}
void showgolf(const golf& g)
{
cout << "full name of golf player: " << g.fullname << endl;
cout << "handicap of golf player: " << g.handicap << endl;
} |
ba69d7078c1e47a2e670521d35be40a37d3c6238 | 4f21c0153b91cc6fd1ece9c612bd93160a9e38be | /SFMLConsoleApplication/Entity.cpp | aed6b2a8eb22e856d1fea60a58d40dda9e787c1c | [] | no_license | HyperActiveHub/Invaders | d487b86e1a622ea81de99587ce4907f4a31666da | bbe20e5121d3fb667f62cf070bdb2f8f287800c8 | refs/heads/master | 2020-08-11T23:45:39.809167 | 2019-10-31T08:41:17 | 2019-10-31T08:41:17 | 214,648,812 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 885 | cpp | Entity.cpp | #include "Entity.h"
#include <iostream>
using namespace std;
Entity::Entity(Game* game, string filename, Vector2f position, float radius, EntityType type, EntityFaction faction) :
mGame(game),
mSprite(game->getTexture(filename)),
mRadius(radius),
mType(type),
mFaction(faction)
{
centerSprite();
mSprite.setPosition(position);
}
Entity::~Entity()
{
}
void Entity::die()
{
mGame->remove(this);
}
void Entity::centerSprite()
{
mSprite.setOrigin(mSprite.getLocalBounds().width * 0.5f, mSprite.getLocalBounds().height * 0.5f);
}
void Entity::draw()
{
mGame->getRenderWindow().draw(mSprite);
}
EntityFaction Entity::getFaction()
{
return mFaction;
}
EntityType Entity::getType()
{
return mType;
}
float Entity::getRadius()
{
return mRadius;
}
Vector2f Entity::getPosition()
{
return mSprite.getPosition();
}
void Entity::collide(Entity* other)
{
//Empty?
}
|
4a9805b125b6cd3e15f53bbc9bc90b1f8e7dbaf9 | fba68e03d5f2861be45491fef6f025de73384b2e | /Tạo webclient kết nối wifi.ino | 55d0a0cfcc4ad844ca8501930036e1dae46c54d9 | [] | no_license | wolf79/esp8266 | 046c6ae23e5ffeec860a7edc654ab4ed74213edd | 89e27ba2e09ef846739290e1d8c18ca35f23f1ad | refs/heads/master | 2021-09-26T16:20:58.385449 | 2018-10-31T14:56:15 | 2018-10-31T14:56:15 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,932 | ino | Tạo webclient kết nối wifi.ino | #include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
#include <EEPROM.h>
//https://khoinghiepiot.com/05-05-2018-WebClient-ESP8266/
ESP8266WebServer server(80);
const char* ssid = "khoitao";
const char* passphrase = "khoitao";
String st;
String content;
int statusCode;
void setup() {
Serial.begin(115200);
EEPROM.begin(512);
delay(10);
Serial.println();
Serial.println();
Serial.println("Bắt đầu");
Serial.println("Đọc SSID từ EEPROM");
String esid;
for (int i = 0; i < 32; ++i)
{
esid += char(EEPROM.read(i));
}
Serial.print("SSID: ");
Serial.println(esid);
Serial.println("Đọc PASS từ EEPROM");
String epass = "";
for (int i = 32; i < 96; ++i)
{
epass += char(EEPROM.read(i));
}
Serial.print("PASS: ");
Serial.println(epass);
if ( esid.length() > 1 ) {
WiFi.begin(esid.c_str(), epass.c_str());
if (testWifi()) {
Serial.print("\nĐã kết nối wifi");
return;
}
else
{
setupAP();
launchWeb();
ESP.restart();
}
}
}
bool testWifi(void) {
int c = 0;
Serial.println("Chờ wifi kết nối");
while ( c < 20 ) {
if (WiFi.status() == WL_CONNECTED) { return true; }
delay(500);
Serial.print(WiFi.status());
c++;
}
Serial.println("");
Serial.println("Kết nối không khả dụng, opening AP");
return false;
}
void launchWeb() {
Serial.print("Khởi tạo SSID...");
char ssid[64];
sprintf(ssid, "AP-%06X", ESP.getChipId());
WiFi.softAP(ssid, passphrase);
IPAddress myIP = WiFi.softAPIP();
Serial.print("AP IP address: ");
Serial.println(myIP);
createWebServer();
// Start the server
server.begin();
Serial.println("Máy chủ sẵn sàng");
}
void setupAP(void) {
WiFi.mode(WIFI_STA);
WiFi.disconnect();
delay(100);
int n = WiFi.scanNetworks();
Serial.println("Quét wifi xong");
if (n == 0)
Serial.println("Chưa tìm thấy wifi gần đây");
else
{
Serial.print(n);
Serial.println(" Đã tìm thấy các mạng:");
for (int i = 0; i < n; ++i)
{
Serial.print(i + 1);
Serial.print(": ");
Serial.print(WiFi.SSID(i));
Serial.print(" (");
Serial.print(WiFi.RSSI(i));
Serial.print(")");
Serial.println((WiFi.encryptionType(i) == ENC_TYPE_NONE)?" ":"*");
delay(10);
}
}
Serial.println("");
st = "<ol>";
for (int i = 0; i < n; ++i)
{
st += "<li>";
st += WiFi.SSID(i);
st += " (";
st += WiFi.RSSI(i);
st += ")";
st += (WiFi.encryptionType(i) == ENC_TYPE_NONE)?" ":"*";
st += "</li>";
}
st += "</ol>";
delay(100);
WiFi.softAP(ssid, passphrase,6);
Serial.println("softap");
launchWeb();
Serial.println("over");
}
void createWebServer()
{
server.on("/", []() {
IPAddress ip = WiFi.softAPIP();
String ipStr = String(ip[0]) + '.' + String(ip[1]) + '.' + String(ip[2]) + '.' + String(ip[3]);
content = "<!DOCTYPE HTML>\r\n<html>Hello from ESP8266 at ";
content += ipStr;
content += "<p>";
content += st;
content += "</p><form method='get' action='setting'><label>SSID: </label><input name='ssid' length=32><input name='pass' length=64><input type='submit'></form>";
content += "</html>";
server.send(200, "text/html", content);
});
server.on("/setting", []() {
String qsid = server.arg("ssid");
String qpass = server.arg("pass");
if (qsid.length() > 0 && qpass.length() > 0) {
Serial.println("Đang xóa eeprom");
for (int i = 0; i < 96; ++i) { EEPROM.write(i, 0); }
Serial.println(qsid);
Serial.println("");
Serial.println(qpass);
Serial.println("");
Serial.println("Đang ghi SSID vào eeprom:");
for (int i = 0; i < qsid.length(); ++i)
{
EEPROM.write(i, qsid[i]);
Serial.print("Đã ghi: ");
Serial.println(qsid[i]);
}
Serial.println("Đang ghi PASS vào eeprom:");
for (int i = 0; i < qpass.length(); ++i)
{
EEPROM.write(32+i, qpass[i]);
Serial.print("Đã ghi: ");
Serial.println(qpass[i]);
}
EEPROM.commit();
content = "{\"Thành công\":\"đã lưu vào eeprom... khởi động với tên wifi mới\"}";
statusCode = 200;
} else {
content = "{\"Lỗi\":\"404 không tìm thấy\"}";
statusCode = 404;
Serial.println("Gửi mã 404");
}
server.send(statusCode, "application/json", content);
});
}
void loop() {
server.handleClient();
} |
9916048f1b5410bcf4cd6027e0aa4ca3d1511c85 | de1b6f42bc9d7b3546ffc0812f113bbdcdbad606 | /TEALDemo/Player_Manager.h | f2ff681984b5c3d9da29c301ad29f7b9f95a07a2 | [] | no_license | Cschnur/Centipede_1980 | e298d4b549498d39ef77abbb69a7a3afa3332271 | d69a4031a7b6b4f88744c5c46b82b91cdec2d35e | refs/heads/master | 2022-03-20T15:01:33.376364 | 2019-12-09T23:36:24 | 2019-12-09T23:36:24 | 226,973,775 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,309 | h | Player_Manager.h | #ifndef _PLAYER_MANAGER
#define _PLAYER_MANAGER
#include "Game Components\TEAL\CommonElements.h"
struct PlayerData;
class BlasterKB;
class BlasterAI;
const int NUM_PLAYERS = 3;
class Player_Manager
{
public:
static PlayerData* CurrentPlayer();
//static functions
static void setPlayer(int num);
static void Initialize() { Instance().privInitialize(); };
static void spawnPlayer() { Instance().privSpawnPlayer(); };
static void reportDeath() { Instance().privReportDeath(); };
static void playerDelete() { Instance().privPlayerDelete(); };
static void playerAdvance() { Instance().privPlayerAdvance(); };
static void Terminate();
private:
Player_Manager() = default;
static Player_Manager* ptrInstance;
Player_Manager(const Player_Manager&) = delete;
Player_Manager& operator=(const Player_Manager&) = delete;
static Player_Manager& Instance()
{
if (!ptrInstance)
ptrInstance = new Player_Manager;
return *ptrInstance;
};
BlasterKB *playerPtr;
BlasterAI *AiPtr;
static PlayerData Player1;
static PlayerData Player2;
static PlayerData PlayerAi;
static PlayerData* players[NUM_PLAYERS];
static PlayerData* currPlayer;
void privInitialize();
void privSpawnPlayer();
void privReportDeath();
void privPlayerDelete();
void privPlayerAdvance();
};
#endif _PLAYER_MANAGER
|
fc5a67d97e4b088c3a20ed11b3bd5c29f6320a95 | b27d103a385d2e90fec4dcd8edb82f136c93ec17 | /test/numeric/str.cpp | 94ccde9971b3b1d8fd742bb7fb7aad577a4550c7 | [
"Apache-2.0"
] | permissive | openbmc/stdplus | 92ce136460879754fb1697467edd74aeebe99c84 | e6fda4501899d9d886f9d5c035f4cf759b459861 | refs/heads/master | 2023-08-16T17:48:27.261586 | 2023-07-26T22:12:12 | 2023-07-26T22:15:16 | 153,646,995 | 4 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 6,061 | cpp | str.cpp | #include <stdplus/numeric/str.hpp>
#include <string_view>
#include <gtest/gtest.h>
using std::literals::string_view_literals::operator""sv;
namespace stdplus
{
TEST(IntToStr, Uint8_10)
{
IntToStr<10, uint8_t> enc;
static_assert(enc.buf_size == 4);
char buf[enc.buf_size];
EXPECT_EQ("0", std::string_view(buf, enc(buf, 0)));
EXPECT_EQ("42", std::string_view(buf, enc(buf, 42)));
EXPECT_EQ("255", std::string_view(buf, enc(buf, 255)));
EXPECT_EQ("000", std::string_view(buf, enc(buf, 0, 3)));
EXPECT_EQ("255", std::string_view(buf, enc(buf, 255, 3)));
}
TEST(IntToStr, Int8_10)
{
IntToStr<10, int8_t> enc;
static_assert(enc.buf_size == 5);
char buf[enc.buf_size];
EXPECT_EQ("42", std::string_view(buf, enc(buf, 42)));
EXPECT_EQ("-127", std::string_view(buf, enc(buf, -127)));
}
TEST(IntToStr, Uint16_10)
{
IntToStr<10, uint16_t> enc;
static_assert(enc.buf_size == 6);
char buf[enc.buf_size];
EXPECT_EQ("55255", std::string_view(buf, enc(buf, 55255, 3)));
ToStrHandle<IntToStr<10, uint16_t>> tsh;
EXPECT_EQ("55255", tsh(55255));
}
TEST(IntToStr, Uint32_10)
{
IntToStr<10, uint32_t> enc;
static_assert(enc.buf_size == 10);
char buf[enc.buf_size];
EXPECT_EQ("55255", std::string_view(buf, enc(buf, 55255, 3)));
EXPECT_EQ("055255", std::string_view(buf, enc(buf, 55255, 6)));
EXPECT_EQ("255255", std::string_view(buf, enc(buf, 255255, 3)));
}
TEST(IntToStr, Uint8_16)
{
IntToStr<16, uint8_t> enc;
static_assert(enc.buf_size == 2);
char buf[enc.buf_size];
EXPECT_EQ("0", std::string_view(buf, enc(buf, 0)));
EXPECT_EQ("2a", std::string_view(buf, enc(buf, 42)));
EXPECT_EQ("ff", std::string_view(buf, enc(buf, 255)));
EXPECT_EQ("00", std::string_view(buf, enc(buf, 0, 2)));
EXPECT_EQ("02", std::string_view(buf, enc(buf, 2, 2)));
EXPECT_EQ("ff", std::string_view(buf, enc(buf, 255, 2)));
ToStrHandle<IntToStr<16, uint8_t>> tsh;
EXPECT_EQ("2a", tsh(0x2a));
}
TEST(IntToStr, Uint8_8)
{
IntToStr<8, uint8_t> enc;
static_assert(enc.buf_size == 3);
char buf[enc.buf_size];
EXPECT_EQ("0", std::string_view(buf, enc(buf, 0)));
EXPECT_EQ("7", std::string_view(buf, enc(buf, 7)));
EXPECT_EQ("10", std::string_view(buf, enc(buf, 8)));
EXPECT_EQ("377", std::string_view(buf, enc(buf, 255)));
}
TEST(IntToStr, Uint8_11)
{
IntToStr<11, uint8_t> enc;
static_assert(enc.buf_size == 3);
char buf[enc.buf_size];
EXPECT_EQ("0", std::string_view(buf, enc(buf, 0)));
EXPECT_EQ("39", std::string_view(buf, enc(buf, 42)));
EXPECT_EQ("212", std::string_view(buf, enc(buf, 255)));
}
TEST(ToString, Int)
{
EXPECT_EQ("10", stdplus::toStr(size_t{10}));
EXPECT_EQ(L"10", stdplus::toBasicStr<wchar_t>(size_t{10}));
EXPECT_EQ("-10", stdplus::toStr(ssize_t{-10}));
EXPECT_EQ(L"-10", stdplus::toBasicStr<wchar_t>(ssize_t{-10}));
}
TEST(ToString, perf)
{
GTEST_SKIP();
IntToStr<16, size_t> enc;
char buf[enc.buf_size];
for (size_t i = 0; i < 100000000; ++i)
{
enc(buf, i);
}
EXPECT_TRUE(false);
}
TEST(StrToInt, Uint8_10)
{
StrToInt<10, uint8_t> dec;
EXPECT_EQ(42, dec("42"sv));
EXPECT_EQ(255, dec("255"sv));
EXPECT_THROW(dec(""sv), std::invalid_argument);
EXPECT_THROW(dec("-1"sv), std::invalid_argument);
EXPECT_THROW(dec("a0"sv), std::invalid_argument);
EXPECT_THROW(dec(".0"sv), std::invalid_argument);
EXPECT_THROW(dec("257"sv), std::overflow_error);
EXPECT_THROW(dec("300"sv), std::overflow_error);
}
TEST(StrToInt, Uint8_11)
{
StrToInt<11, uint8_t> dec;
EXPECT_EQ(112, dec("a2"sv));
EXPECT_EQ(255, dec("212"sv));
EXPECT_THROW(dec(""sv), std::invalid_argument);
EXPECT_THROW(dec("-1"sv), std::invalid_argument);
EXPECT_THROW(dec("b0"sv), std::invalid_argument);
EXPECT_THROW(dec(".0"sv), std::invalid_argument);
EXPECT_THROW(dec("213"sv), std::overflow_error);
EXPECT_THROW(dec("300"sv), std::overflow_error);
}
TEST(StrToInt, Uint16_16)
{
StrToInt<16, uint16_t> dec;
EXPECT_EQ(0x42, dec("42"sv));
EXPECT_EQ(0xfacf, dec("facf"sv));
EXPECT_THROW(dec(""sv), std::invalid_argument);
EXPECT_THROW(dec("-1"sv), std::invalid_argument);
EXPECT_THROW(dec("g0"sv), std::invalid_argument);
EXPECT_THROW(dec(".0"sv), std::invalid_argument);
EXPECT_THROW(dec("10000"sv), std::overflow_error);
}
TEST(StrToInt, Uint16_8)
{
StrToInt<8, uint16_t> dec;
EXPECT_EQ(042, dec("42"sv));
EXPECT_EQ(0177777, dec("177777"sv));
EXPECT_THROW(dec(""sv), std::invalid_argument);
EXPECT_THROW(dec("-1"sv), std::invalid_argument);
EXPECT_THROW(dec("g0"sv), std::invalid_argument);
EXPECT_THROW(dec(".0"sv), std::invalid_argument);
EXPECT_THROW(dec("277777"sv), std::overflow_error);
}
TEST(StrToInt, Int8_16)
{
StrToInt<16, int8_t> dec;
EXPECT_EQ(-1, dec("-1"sv));
EXPECT_EQ(0x42, dec("42"sv));
EXPECT_EQ(-0x7f, dec("-7f"sv));
EXPECT_THROW(dec(""sv), std::invalid_argument);
EXPECT_THROW(dec("--1"sv), std::invalid_argument);
EXPECT_THROW(dec("g0"sv), std::invalid_argument);
EXPECT_THROW(dec(".0"sv), std::invalid_argument);
EXPECT_THROW(dec("ff"sv), std::overflow_error);
EXPECT_THROW(dec("10000"sv), std::overflow_error);
}
TEST(StrToInt, Int8_0)
{
StrToInt<0, int8_t> dec;
EXPECT_EQ(-1, dec("-1"sv));
EXPECT_EQ(42, dec("42"sv));
EXPECT_EQ(0x42, dec("0x42"sv));
EXPECT_EQ(-42, dec("-42"sv));
EXPECT_EQ(-0x42, dec("-0x42"sv));
EXPECT_THROW(dec(""sv), std::invalid_argument);
EXPECT_THROW(dec("--1"sv), std::invalid_argument);
EXPECT_THROW(dec("ac"sv), std::invalid_argument);
EXPECT_THROW(dec(".0"sv), std::invalid_argument);
EXPECT_THROW(dec("0xff"sv), std::overflow_error);
EXPECT_THROW(dec("10000"sv), std::overflow_error);
}
TEST(StrToInt, Perf)
{
GTEST_SKIP();
StrToInt<16, size_t> dec;
for (size_t i = 0; i < 100000000; ++i)
{
dec("53036893"sv);
}
EXPECT_TRUE(false);
}
} // namespace stdplus
|
da8a6e3ac804972f5bdb4c90149cde5ddb3c7e40 | e94cfcfc764861331ca2ee1568c2d927e578531a | /Hydroponics/Hydroponics.ino | c27a1ea607cb8d75008b76daa4b827fe512d385c | [] | no_license | nattasamphoangoen/Hydroponics | 8a7aeb6212084d52a2de57e8511d73902fb63e25 | 5e350e24dcfa88206cd56065cca54c6ca033498f | refs/heads/master | 2021-05-13T20:10:55.706600 | 2018-01-10T11:23:19 | 2018-01-10T11:23:19 | 116,906,674 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,282 | ino | Hydroponics.ino | //ส่วนที่เชื่อมต่ออินเทอร์เน็ต
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
const char* ssid = "BANK";
const char* password = "bank4227";
String apiKey = "H41MV1K5IN3NRPD4";
const char* server = "api.thingspeak.com";
char auth[] = "dd54e26f8833408fb8cbc1bc48fc3ee7";
WiFiClient client;
#define BLYNK_PRINT Serial
//ส่วนของระบบsensor
#define SensorPin A0
#define samplingInterval 20
#define printInterval 800
#define ArrayLenth 40
#define analogInPin A3
int pHArray[ArrayLenth];
int pHArrayIndex = 0;
int sensorValue = 0;
int outputValue = 0;
int p1 = 26;
int p2 = 27;
int ECL = 1200;
int ECH = 1800;
float pHL = 5.5 ;
float pHH = 7.0 ;
int Sta1 = 0 ;
int Sta2 = 0 ;
void setup() {
Serial.begin(9600);
delay(5);
Serial.println(); Serial.println();
Serial.print("Connecting to "); Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(5);
Serial.print(".");
Blynk.begin(auth, ssid, password);
}
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
//สาวนของระบบ
pinMode(p1, OUTPUT);
pinMode(p2, OUTPUT);
}
void loop()
{
digitalWrite(p1, LOW);
sensorValue = analogRead(A3) ;
outputValue = map(sensorValue, 0, 4094, 0, 5000);
delay(5);
Serial.print("EC = " );
Serial.print(sensorValue);
Serial.print("\n ");
static unsigned long samplingTime = millis();
static unsigned long printTime = millis();
static float pHValue, voltage;
if (millis() - samplingTime > samplingInterval)
{
pHArray[pHArrayIndex++] = analogRead(A0);
if (pHArrayIndex == ArrayLenth)pHArrayIndex = 0;
voltage = avergearray(pHArray, ArrayLenth) * 5.0 / 4095 * 0.9421265141;
pHValue = 3.5 * voltage;
samplingTime = millis();
}
Serial.print("Voltage:");
Serial.print(voltage, 2);
Serial.print(" pH value: ");
Serial.println(pHValue, 2);
//ควบคุมp2
if
(sensorValue < ECL || sensorValue > ECH)
{
digitalWrite(p2, LOW );
} else
{
digitalWrite(p2, HIGH);
}
if (pHValue < pHL || pHValue > pHH ) {
digitalWrite(p2, LOW);
} else {
digitalWrite(p2, HIGH);
}
//ขึ้นBlynk
Blynk.run();
BLYNK_READ(V0);
{
Blynk.virtualWrite(V0, pHValue);
}
BLYNK_READ(V1);
{
Blynk.virtualWrite(V1, sensorValue);
}
//ส่วนขึ้นthingspeak
Sta1 = digitalRead(p1);
Sta2 = digitalRead(p2);
Serial.println("------------------------------------");
Serial.println("Requesting EC&PH ");
if (client.connect(server, 80))
{ String postStr = apiKey;
postStr += "&field1="; // Fields 1
postStr += String(sensorValue);
postStr += "&field2="; // Fields 2
postStr += String(pHValue);
postStr += "&field3="; // Fields 3
postStr += String(Sta1);
postStr += "&field4="; // Fields 4
postStr += String(Sta2);
postStr += "\r\n\r\n";
client.print("POST /update HTTP/1.1\n");
client.print("Host: api.thingspeak.com\n");
client.print("Connection: close\n");
client.print("X-THINGSPEAKAPIKEY: " + apiKey + "\n");
client.print("Content-Type: application/x-www-form-urlencoded\n");
client.print("Content-Length: ");
client.print(postStr.length());
client.print("\n\n");
client.print(postStr);
}
client.stop();
Serial.println("Waiting...");
delay(5);
}
double avergearray(int* arr, int number) {
int i;
int max, min;
double avg;
long amount = 0;
if (number <= 0) {
Serial.println("Error number for the array to avraging!/n");
return 0;
}
if (number < 5) {
for (i = 0; i < number; i++) {
amount += arr[i];
}
avg = amount / number;
return avg;
} else {
if (arr[0] < arr[1]) {
min = arr[0]; max = arr[1];
}
else {
min = arr[1]; max = arr[0];
}
for (i = 2; i < number; i++) {
if (arr[i] < min) {
amount += min;
min = arr[i];
} else {
if (arr[i] > max) {
amount += max;
max = arr[i];
} else {
amount += arr[i];
}
}//if
}//for
avg = (double)amount / (number - 2);
}//if
return avg;
}
|
ed11a4118fe3c4cbfabffcbbc1a6638bd54b18b0 | 4970e3670d4fe22f6425374e590e0c8dce641618 | /lexer.cpp | 606c3d59817cd3a575e049908c8676d84abd1ad9 | [] | no_license | voidzer0-development/Stinger-Compiler | 6b634c5837f83001f13b852ecdbb9cae655ae813 | 6ea88792101e2c0afe94f717bef0c57beae07ce5 | refs/heads/master | 2022-04-26T21:15:38.184077 | 2020-04-18T20:04:24 | 2020-04-18T20:04:24 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,304 | cpp | lexer.cpp | #include "llvm/ADT/STLExtras.h"
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <map>
#include <memory>
#include <string>
#include <vector>
// Scanner aka. lexer
enum currentToken {
token_fileEnd = -1,
token_definition = -2,
token_number = -3,
token_extern = -4,
token_identifier = -5,
};
//some defines for getting the current token correctly
static std::string identStr;
static double numberValue;
static int getCurrentToken() {
static int lastCharacter = ' ';
//white spaces are for humans not computers ;)
while (isspace(lastCharacter))
lastCharacter = getchar();
//is it an alphanumeric character?
if (isalpha(lastCharacter)) {
identStr = lastCharacter;
while (isalnum((lastCharacter = getchar())))
{
identStr += lastCharacter;
}
//recognize identifiers and keywords
if (identStr == "define") {
return token_definition;
}
else if (identStr == "extern") {
return token_extern;
}
else {
return token_identifier;
}
}
//digits
if (isdigit(lastCharacter) || lastCharacter == '.') {
std::string numberStr;
//ensure we get numbers correctly, so input 1.23.45.67 will compile to value 1.234567.
bool firstDotChar = false;
do {
if (lastCharacter == '.' && !firstDotChar) {
numberStr += lastCharacter;
firstDotChar = true;
}
else {
numberStr += lastCharacter;
}
lastCharacter = getchar();
} while (isdigit(lastCharacter) || lastCharacter == '.');
numberValue = strtod(numberStr.c_str(), 0);
return token_number;
}
//comments $, fuck poeple that want to use this over | in bitwise OR
if (lastCharacter == '$') {
do {
lastCharacter = getchar();
} while (lastCharacter != EOF && lastCharacter != '\n' && lastCharacter != '\r');
if (lastCharacter != EOF) {
return getCurrentToken();
}
}
if (lastCharacter == EOF) {
token_fileEnd;
}
int tChar = lastCharacter;
lastCharacter = getchar();
return tChar;
}
|
823e05d6c38fb9c27017df1f218c18eb799389ab | 8f1d2070a11df5cc7f37e45204b12eb5b318289b | /代码/Slicer插件/源代码/slicervmtk/VMTKStenosisDetector/StenosisDetector/vtkVmtk/Misc/vtkvmtkImageBoxPainter.cxx | a9894c722c71a2039e0cf7fd01959417185de3b6 | [
"BSD-3-Clause"
] | permissive | Inlinebool/CoronaryArteryPathologyRatingSystem | 8c10221e16eba2d9555155fa326432c9471609aa | 928ca985b8e6fcb8cbd9bbaa078f130c1713bd91 | refs/heads/master | 2022-05-12T22:15:26.700018 | 2022-05-07T01:54:52 | 2022-05-07T01:54:52 | 42,735,746 | 10 | 3 | null | null | null | null | UTF-8 | C++ | false | false | 4,617 | cxx | vtkvmtkImageBoxPainter.cxx | /*=========================================================================
Program: VMTK
Module: $RCSfile: vtkvmtkImageBoxPainter.cxx,v $
Language: C++
Date: $Date: 2005/03/04 11:13:24 $
Version: $Revision: 1.2 $
Copyright (c) Luca Antiga, David Steinman. All rights reserved.
See LICENCE file for details.
Portions of this code are covered under the VTK copyright.
See VTKCopyright.txt or http://www.kitware.com/VTKCopyright.htm
for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#include "vtkvmtkImageBoxPainter.h"
#include "vtkImageData.h"
#include "vtkObjectFactory.h"
vtkCxxRevisionMacro(vtkvmtkImageBoxPainter, "$Revision: 1.2 $");
vtkStandardNewMacro(vtkvmtkImageBoxPainter);
vtkvmtkImageBoxPainter::vtkvmtkImageBoxPainter()
{
this->PaintValue = 0.0;
this->BoxBounds[0] = this->BoxBounds[2] = this->BoxBounds[4] = 0.0;
this->BoxBounds[1] = this->BoxBounds[3] = this->BoxBounds[5] = 1.0;
this->BoxExtent[0] = this->BoxExtent[2] = this->BoxExtent[4] = 0;
this->BoxExtent[1] = this->BoxExtent[3] = this->BoxExtent[5] = 1;
this->BoxDefinition = vtkvmtkImageBoxPainter::USE_EXTENT;
}
// The switch statement in Execute will call this method with
// the appropriate input type (IT). Note that this example assumes
// that the output data type is the same as the input data type.
// This is not always the case.
template <class IT>
void vtkvmtkImageBoxPainterExecute(vtkImageData* input,
vtkImageData* output,
IT* inPtr, IT* outPtr,
int* boxExtent, IT paintValue)
{
int dims[3];
input->GetDimensions(dims);
if (input->GetScalarType() != output->GetScalarType())
{
vtkGenericWarningMacro(<< "Execute: input ScalarType, " << input->GetScalarType()
<< ", must match out ScalarType " << output->GetScalarType());
return;
}
int size = dims[0]*dims[1]*dims[2];
int ijk[3];
vtkIdType id;
for (int i=0; i<size; i++)
{
outPtr[i] = inPtr[i];
}
for (ijk[2]=boxExtent[4]; ijk[2]<=boxExtent[5]; ++ijk[2])
{
for (ijk[1]=boxExtent[2]; ijk[1]<=boxExtent[3]; ++ijk[1])
{
for (ijk[0]=boxExtent[0]; ijk[0]<=boxExtent[1]; ++ijk[0])
{
id = input->ComputePointId(ijk);
outPtr[id] = paintValue;
}
}
}
}
void vtkvmtkImageBoxPainter::SimpleExecute(vtkImageData* input,
vtkImageData* output)
{
void* inPtr = input->GetScalarPointer();
void* outPtr = output->GetScalarPointer();
double spacing[3];
input->GetSpacing(spacing);
if (this->BoxDefinition == vtkvmtkImageBoxPainter::USE_BOUNDS)
{
this->BoxExtent[0] = (vtkIdType) ceil(this->BoxBounds[0] / spacing[0]);
this->BoxExtent[1] = (vtkIdType) floor(this->BoxBounds[1] / spacing[0]);
this->BoxExtent[2] = (vtkIdType) ceil(this->BoxBounds[2] / spacing[1]);
this->BoxExtent[3] = (vtkIdType) floor(this->BoxBounds[3] / spacing[1]);
this->BoxExtent[4] = (vtkIdType) ceil(this->BoxBounds[4] / spacing[2]);
this->BoxExtent[5] = (vtkIdType) floor(this->BoxBounds[5] / spacing[2]);
}
int extent[6];
input->GetWholeExtent(extent);
if ( this->BoxExtent[0] < extent[0] || this->BoxExtent[1] > extent[1] ||
this->BoxExtent[2] < extent[2] || this->BoxExtent[3] > extent[3] ||
this->BoxExtent[4] < extent[4] || this->BoxExtent[5] > extent[5] )
{
vtkErrorMacro(<<"BoxExtent exceeds input WholeExtent");
return;
}
int relativeBoxExtent[6];
relativeBoxExtent[0] = this->BoxExtent[0] - extent[0];
relativeBoxExtent[1] = this->BoxExtent[1] - extent[0];
relativeBoxExtent[2] = this->BoxExtent[2] - extent[2];
relativeBoxExtent[3] = this->BoxExtent[3] - extent[2];
relativeBoxExtent[4] = this->BoxExtent[4] - extent[4];
relativeBoxExtent[5] = this->BoxExtent[5] - extent[4];
switch(output->GetScalarType())
{
// This is simple a #define for a big case list. It handles
// all data types vtk can handle.
vtkTemplateMacro6(vtkvmtkImageBoxPainterExecute, input, output,
(VTK_TT *)(inPtr), (VTK_TT *)(outPtr), relativeBoxExtent,
(VTK_TT)this->PaintValue);
default:
vtkGenericWarningMacro("Execute: Unknown input ScalarType");
return;
}
}
|
b85eebde2946c2384a54a6e36e7d9d67a0245fb3 | a0fe177af49d8b3c4d31b446f49f71979f3ba946 | /Lab6-dynamic order statistic/Lab6-dynamic order statistic/Source.cpp | 00a2d0e81f3b181b9d7c35099251bbde31164ce0 | [] | no_license | biavr/FA_2019 | 8b87ab7fa119c44c2b32a765da046c7ddb7ba842 | 6112b31a748c064b025a157a745088e937840f0d | refs/heads/main | 2023-08-18T07:15:25.502149 | 2021-10-02T11:45:18 | 2021-10-02T11:45:18 | 412,779,179 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 8,790 | cpp | Source.cpp | /*
Author: Bianca Avram
Group: 30421
Problem: Dynamic Order Statistic
This problem is based on 3 main functions: buildTree, OS_select and OS_delete
BuildTree
->is the function that takes a sorted array, which is equivalent to inorder traversal for a tree,
and obtains the ADS reptesentation of a perfect balanced binary tree;
->it is a divide et impera strategy which chooses a "root" every time, than creates the subtrees from left and right;
->its time complexity is O(n), as resulted from master theorem, which is completely expected, because we need to process
each and every element in the array;
Select
->it obtains te node that contains the ith smallest key in the sorted initial array;
->it is implemented recursively and we get to choose at each step if we go to left or right to search for the key;
->when we get to a leaf, that means that we found the mode we wanted
->this function uses the field "size" from the structure of a node, which contains the number of nodes in the
subtree that has that node as root (including this node)
->when the node is found, a poiner to it is returned
->the time complexity for this function is O(logn)
->logn represents the height of the tree, which is kept balanced in what concerns the number of nodes in each subtree
->this complexity i given by the fact that we never have to go through the whole tree to find a node, because we
now exactly at each step that there is a branch we can eliminate
Delete
->to delete a node, first we have to look for it in the tree using OS_select
->this already gives the complexity of O(logn)
->the following steps are to effectively delete the node, which implies looking for its successor
->there are 3 cases: leaves, nodes with only one descendant and nodes with 2 descendants
->each gives a different complexity
->the first 2 run in O(1), but the thirs case runs in O(logn), because the problem of finding the successor
might take longer
->after finding and deleting a node, we have to update the "size" field
->to notice that only the nodes on the branch until the deleted node are affected
->for this, we use the "parent" field in order to go upwards, from the parent of the deleted node or the parent of the
successor (for case 3), until the root
->we decrement the size at every step until the root
->this process also takes O(logn), the height of the tree
->in the end, we have O(logn) the complexity for the OS_delete function, as a sum of O(logn)s
*/
#include <iostream>
#include <ctime>
#include "Profiler.h"
#define COUNT 10
using namespace std;
Profiler profiler("trees");
int opBuild;
int opDelete;
int opSelect;
typedef struct node
{
int key;
int size;
node* left;
node* right;
node* parent;
}NodeT;
NodeT* createNode(int key)
{
NodeT* n = (NodeT*)malloc(sizeof(NodeT));
n->key = key;
n->parent = NULL;
n->left = NULL;
n->right = NULL;
n->size = 1;
return n;
}
int* generateArray(int size)
{
int* a = (int*)malloc(size * sizeof(int));
for (int i = 0; i < size; i++)
{
a[i] = i + 1;
}
return a;
}
NodeT* buildTree(int a[], int l, int r, NodeT* parent, int size)
{
opBuild++;
if (l <= r)
{
int m = (r + l) / 2;
NodeT* root = createNode(a[m]);
root->parent = parent;
opBuild += 3;
if (size % 2 == 0)
{
root->size = size;
root->left = buildTree(a, l, m - 1, root, size / 2 - 1);
opBuild += 3;
if (root->left)
{
root->left->parent = root;
opBuild++;
}
opBuild += 2;
root->right = buildTree(a, m + 1, r, root, size / 2);
if (root->right)
{
opBuild++;
root->right->parent = root;
}
return root;
}
root->size = size;
root->left = buildTree(a, l, m - 1, root, size / 2);
opBuild += 3;
if (root->left)
{
root->left->parent = root;
opBuild++;
}
opBuild += 2;
root->right = buildTree(a, m + 1, r, root, size / 2);
if (root->right)
{
root->right->parent = root;
opBuild++;
}
return root;
}
return NULL;
}
void inorder(NodeT* root)
{
if (root != NULL)
{
inorder(root->left);
for (int i = 0; i < root->size; i++)
{
cout << " ";
}
cout << root->size << ", " << root->key << endl;
inorder(root->right);
}
}
void prettyPrint(NodeT* root, int space)
{
// Base case
if (root == NULL)
return;
// Increase distance between levels
space += COUNT;
// Process right child first
prettyPrint(root->right, space);
// Print current node after space
// count
printf("\n");
for (int i = COUNT ; i < space ; i++)
printf(" ");
cout << root->key << ", " << root->size;
// Process left child
prettyPrint(root->left, space);
}
void buildTreeDemo()
{
cout << "BuildTree demo****************************************" << endl << endl;
int size = 11;
//int* a = generateArray(size);
int a[] = { 14, 17, 18, 22, 25, 48, 52, 55, 83, 94, 99 };
cout << "Initial array:\n";
for (int i = 0; i < size; i++)
{
cout << a[i] << " ";
}
cout << endl << endl;
NodeT* root = buildTree(a, 0, size - 1, NULL, size);
//inorder(root);
prettyPrint(root, 0);
}
NodeT* OS_select(NodeT* x, int i)
{
int r;
opSelect += 5;
if (x == NULL)
return x;
if (x->left == NULL && x->right == NULL)
return x;
if (x->left != NULL)
{
r = x->left->size + 1;
}
else
{
r = x->size - 1;
}
opSelect++;
if (i == r)
return x;
else
{
opSelect++;
if (i < r)
return OS_select(x->left, i);
else
return OS_select(x->right, i - r);
}
}
void OS_selectDemo()
{
cout << endl;
cout << "OS_select Demo****************************************" << endl << endl;
int size = 11;
//int* a = generateArray(size);
int a[] = { 14, 17, 18, 22, 25, 48, 52, 55, 83, 94, 99 };
cout << "Initial array:\n";
for (int i = 0; i < size; i++)
{
cout << a[i] << " ";
}
cout << endl << endl;
NodeT* root = buildTree(a, 0, size - 1, NULL, size);
NodeT* q = OS_select(root, 3);
cout << "The 3rd smallest key is " << q->key << endl;
q = OS_select(root, 7);
cout << "The 7th smallest key is " << q->key << endl;
q = OS_select(root, 5);
cout << "The 5th smallest key is " << q->key << endl;
cout << endl;
}
NodeT* findMin(NodeT* root)
{
if (root == NULL)
return root;
while (root->left != NULL)
{
root = root->left;
opDelete++;
}
return root;
}
NodeT* findSucc(NodeT* root)
{
opDelete += 2;
if (root->right != NULL)
return findMin(root->right);
NodeT* y = root->parent;
opDelete += 2;
while (y != NULL && root == y->right)
{
opDelete += 3;
root = y;
y = y->parent;
}
return y;
}
void OS_delete(NodeT* root, int i)
{
NodeT* p;
NodeT* z = OS_select(root, i);
opDelete += 7;
if (z == NULL)
return;
NodeT* y;
NodeT* x;
if (z->left == NULL || z->right == NULL)
y = z;
else
y = findSucc(z);
if (y->left != NULL)
x = y->left;
else
x = y->right;
if (x != NULL)
{
x->parent = y->parent;
opDelete++;
}
opDelete++;
if (y->parent == NULL)
{
root = x;
opDelete++;
}
else
{
opDelete += 2;
if (y == y->parent->left)
y->parent->left = x;
else
y->parent->right = x;
}
z->key = y->key;
p = y->parent;
free(y);
//updating the size
while (p != NULL)
{
p->size--;
p = p->parent;
opDelete += 3;
}
}
void OS_deleteDemo()
{
cout << endl;
cout << "OS_delete Demo****************************************" << endl << endl;
int size = 11;
//int* a = generateArray(size);
int a[] = { 14, 17, 18, 22, 25, 48, 52, 55, 83, 94, 99 };
cout << "Initial array:\n";
for (int i = 0; i < size; i++)
{
cout << a[i] << " ";
}
cout << endl << endl;
NodeT* root = buildTree(a, 0, size - 1, NULL, size);
cout << endl << "Initial tree" << endl << endl;
prettyPrint(root, 0);
cout << endl << endl << "Delete 5th node" << endl << endl;
OS_delete(root, 5);
prettyPrint(root, 0);
cout << endl << endl << "Delete 6th node" << endl << endl;
OS_delete(root, 6);
prettyPrint(root, 0);
cout << endl << endl << "Delete 3rd node" << endl << endl;
OS_delete(root, 3);
prettyPrint(root, 0);
}
void generateGraph()
{
for (int size = 100; size <= 10000; size += 100)
{
opBuild = 0;
opSelect = 0;
opDelete = 0;
for (int m = 0; m < 5; m++)
{
int* a = generateArray(size);
NodeT* root = buildTree(a, 0, size - 1, NULL, size);
for (int i = 0; i < size; i++)
{
int random = rand() % (size - i);
OS_delete(root, random);
}
}
opBuild /= 5;
opSelect /= 5;
opDelete /= 5;
profiler.countOperation("operations_build", size, opBuild);
profiler.countOperation("operations_select", size, opSelect);
profiler.countOperation("operations_delete", size, opSelect + opDelete);
}
profiler.showReport();
}
int main()
{
srand(time(NULL));
int test;
cout << "Input the test variable (0 for demo and 1 for graph):";
cin >> test;
if (test == 0)
{
buildTreeDemo();
OS_selectDemo();
OS_deleteDemo();
}
else
{
generateGraph();
}
} |
1a2fd30cbe56e25c561bb326a60f06b623886c9e | 8f021f68cd0949afa8d119582c0b419b014919d8 | /URIOJ/uri2217.cpp | 6d48365e1813616219ce505409dfeb96ec4c782f | [] | no_license | Jonatankk/codigos | b9c8426c2f33b5142460a84337480b147169b3e6 | 233ae668bdf6cdd12dbc9ef243fb4ccdab49c933 | refs/heads/master | 2022-07-22T11:09:27.271029 | 2020-05-09T20:57:42 | 2020-05-09T20:57:42 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 229 | cpp | uri2217.cpp | /*
* Leonardo Deliyannis Constantin
* URI 2217 - Nove
*/
#include <stdio.h>
int main(){
int T, N;
scanf("%d", &T);
while(T--){
scanf("%d", &N);
printf("%d\n", (N&1) ? 9 : 1);
}
return 0;
}
|
7d68018339c8ebe1308ecfeecb4e883fe6dabe67 | 054454a3033bd65763dbe1f81535138712c47952 | /w2/d1/d1_19.cpp | 49c1282a8decd0bfa20179f208b00428c5e00837 | [] | no_license | greenfox-zerda-sparta/szaboattus | 8e6cec0bdde81f7942ce5d451ed20826d7994a4d | 7eee9c38361895b96eb3612fa5242f821c50526e | refs/heads/master | 2021-01-17T18:18:13.841031 | 2017-02-17T09:19:32 | 2017-02-17T09:19:32 | 71,350,874 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 186 | cpp | d1_19.cpp | #include <iostream>
#include <string>
using namespace std;
int main() {
for (int i = 1 ; i<=20 ; i++){
if (i%2 ==0)
cout << i;
}
// print the even numbers till 20
return 0;
}
|
dc8cc663738c570927ae69709717daff33c97586 | 5d24c201bc31e8cac61fae466e1c80be5d38b631 | /saga/saga/adaptors/task_impl.hpp | d5994ab6e5a9447397345fce03b944d770b761ab | [
"BSL-1.0"
] | permissive | Fooway/saga-cpp | 330196aec55642630eb1853363bc3cf8d53336db | 7376c0de0529e7d7b80cf08b94ec484c2e56d38e | refs/heads/master | 2020-07-12T02:31:44.485713 | 2012-12-13T11:39:22 | 2012-12-13T11:39:22 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,924 | hpp | task_impl.hpp | // Copyright (c) 2005-2009 Hartmut Kaiser
// Copyright (c) 2005-2006 Stephan Hirmer (shirmer@cct.lsu.edu)
//
// 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)
#if !defined(BOOST_PP_IS_ITERATING)
#if !defined(SAGA_ADAPTOR_TASK_IMPL_IMPLEMENTATION_HPP)
#define SAGA_ADAPTOR_TASK_IMPL_IMPLEMENTATION_HPP
#include <saga/impl/config.hpp>
#include <boost/preprocessor/iterate.hpp>
#include <boost/preprocessor/repetition/enum_params.hpp>
#include <boost/preprocessor/repetition/enum_binary_params.hpp>
#define BOOST_PP_ITERATION_PARAMS_1 \
(3, (1, SAGA_ARGUMENT_LIMIT, \
"saga/saga/adaptors/task_impl.hpp")) \
/**/
#include BOOST_PP_ITERATE()
#endif // SAGA_ADAPTOR_TASK_IMPL_IMPLEMENTATION_HPP
///////////////////////////////////////////////////////////////////////////////
//
// Preprocessor vertical repetition code
//
///////////////////////////////////////////////////////////////////////////////
#else // defined(BOOST_PP_IS_ITERATING)
#define P BOOST_PP_ITERATION()
#define GET_TEMP_ARG(z, M, _) BOOST_PP_COMMA_IF(M) FuncArg ## M, Arg ## M
/**
* template'd helper function, which creates a appropriate
* saga::impl::task object
*/
template<
typename Cpi, typename Base, typename RetVal,
BOOST_PP_ENUM_PARAMS (P, typename FuncArg),
BOOST_PP_ENUM_PARAMS (P, typename Arg)
>
inline saga::impl::task<
Cpi, Base, RetVal, BOOST_PP_REPEAT(P, GET_TEMP_ARG, _)>*
task::create_task(
char const *func_name, TR1::shared_ptr<Cpi> cpi, impl::proxy* prxy,
void (Base::*sync)(RetVal&, BOOST_PP_ENUM_PARAMS(P, FuncArg)),
BOOST_PP_ENUM_BINARY_PARAMS (P, Arg, const& arg),
bool (Base::*prep)(RetVal&, BOOST_PP_ENUM_PARAMS(P, FuncArg),
saga::uuid))
{
return new saga::impl::task<
Cpi, Base, RetVal, BOOST_PP_REPEAT(P, GET_TEMP_ARG, _)>(
func_name, cpi, prxy, sync, BOOST_PP_ENUM_PARAMS(P, arg), prep);
}
/**
* template'd helper function, which creates a appropriate
* saga::impl::task object
*
* The function to execute takes as a further parameter,
* more precisely, a uuid of the task, which will be executed in the adaptor
*
* generated by the preprocessor with the help of macros. The number of
* parameters differs.
*/
template<typename Cpi, typename Base, typename RetVal,
BOOST_PP_ENUM_PARAMS(P, typename FuncArg),
BOOST_PP_ENUM_PARAMS(P, typename Arg)
>
inline saga::impl::wrapper_task <
Cpi, Base, RetVal, BOOST_PP_REPEAT(P, GET_TEMP_ARG, _)>*
task::create_task(
char const *func_name, TR1::shared_ptr<Cpi> cpi, impl::proxy* prxy,
void (Base::*sync)(RetVal&, BOOST_PP_ENUM_PARAMS(P, FuncArg), saga::uuid),
BOOST_PP_ENUM_BINARY_PARAMS (P, Arg, const& arg),
bool (Base::*prep)(
RetVal&, BOOST_PP_ENUM_PARAMS(P, FuncArg), saga::uuid))
{
return new saga::impl::wrapper_task<
Cpi, Base, RetVal, BOOST_PP_REPEAT(P, GET_TEMP_ARG, _)>(
func_name, cpi, prxy, sync, BOOST_PP_ENUM_PARAMS(P, arg), prep);
}
#undef GET_TEMP_ARG
/**
* overloaded template'd constructor
*
* generates with the help of preprocessor meta-programming.
* Same as the simple constructor, but the number of function parameters
* for f and prep_func differ.
* calls member function create_task and puts the returned task
* into the saga::task class, which is part of the facade.
*
*/
template<
typename Cpi, typename Base, typename RetVal,
BOOST_PP_ENUM_PARAMS (P, typename FuncArg),
BOOST_PP_ENUM_PARAMS (P, typename Arg)
>
inline task::task (
char const *func_name, TR1::shared_ptr<Cpi> cpi, impl::proxy* prxy,
void (Base::*sync)(RetVal&, BOOST_PP_ENUM_PARAMS (P, FuncArg)),
BOOST_PP_ENUM_BINARY_PARAMS (P, Arg, const& arg),
bool (Base::*prep)(
RetVal&, BOOST_PP_ENUM_PARAMS(P, FuncArg), saga::uuid))
: base_type (
create_task(func_name, cpi, prxy, sync, BOOST_PP_ENUM_PARAMS(P, arg), prep))
{
}
template<
typename Cpi, typename Base, typename RetVal,
BOOST_PP_ENUM_PARAMS (P, typename FuncArg),
BOOST_PP_ENUM_PARAMS (P, typename Arg)
>
inline task::task (
char const *func_name, TR1::shared_ptr<Cpi> cpi,
void (Base::*sync)(RetVal&, BOOST_PP_ENUM_PARAMS (P, FuncArg)),
BOOST_PP_ENUM_BINARY_PARAMS (P, Arg, const& arg),
bool (Base::*prep)(
RetVal&, BOOST_PP_ENUM_PARAMS(P, FuncArg), saga::uuid))
: base_type (create_task(func_name, cpi, cpi->get_proxy(), sync,
BOOST_PP_ENUM_PARAMS(P, arg), prep))
{
}
/**
* overloaded template'd constructor
*
* generates with the help of preprocessor meta-programming.
* Same as the simple constructor, but the number of function parameters
* for f and prep_func differ.
* calls member function create_task and puts the returned task
* into the saga::task class, which is part of the facade.
* Differs from the other constructor, because the func takes a
* further parameter, a task uuid.
*
*/
template<
typename Cpi, typename Base, typename RetVal,
BOOST_PP_ENUM_PARAMS (P, typename FuncArg),
BOOST_PP_ENUM_PARAMS (P, typename Arg)
>
inline task::task (
char const *func_name, TR1::shared_ptr<Cpi> cpi, impl::proxy* prxy,
void (Base::*sync)(RetVal&, BOOST_PP_ENUM_PARAMS(P, FuncArg), saga::uuid),
BOOST_PP_ENUM_BINARY_PARAMS (P, Arg, const& arg),
bool (Base::*prep)(
RetVal&, BOOST_PP_ENUM_PARAMS(P, FuncArg), saga::uuid))
: base_type(
create_task(func_name, cpi, prxy, sync, BOOST_PP_ENUM_PARAMS(P, arg), prep))
{
}
template<
typename Cpi, typename Base, typename RetVal,
BOOST_PP_ENUM_PARAMS (P, typename FuncArg),
BOOST_PP_ENUM_PARAMS (P, typename Arg)
>
inline task::task (
char const *func_name, TR1::shared_ptr<Cpi> cpi,
void (Base::*sync)(RetVal&, BOOST_PP_ENUM_PARAMS(P, FuncArg), saga::uuid),
BOOST_PP_ENUM_BINARY_PARAMS (P, Arg, const& arg),
bool (Base::*prep)(
RetVal&, BOOST_PP_ENUM_PARAMS(P, FuncArg), saga::uuid))
: base_type(create_task(func_name, cpi, cpi->get_proxy(), sync,
BOOST_PP_ENUM_PARAMS(P, arg), prep))
{
}
#undef P
#endif // defined(BOOST_PP_IS_ITERATING)
|
b4c9192155433b03467ddb9dd92a3c74ddd7daad | 226d9743bc687bf4f6f7ec4461df8322112c45ae | /Basic Programing/Implementation/Arania Exumai Blast !!.cpp | 7112f145be3fcadaadce2a37e1d36b93ea354dcd | [] | no_license | ik07onkar/HackerEarth | 1500209baf81e02766fd94bdf99b8d9d777f6327 | d400c97c9276c33d529a8d50fefc20e895ed01d7 | refs/heads/main | 2023-04-12T23:53:16.435750 | 2021-04-26T15:00:21 | 2021-04-26T15:00:21 | 361,787,696 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 660 | cpp | Arania Exumai Blast !!.cpp | #include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
string a;
getline(cin,a);
int n = a.size(), cnt = 0;
int h[26];
memset(h,0,sizeof(h));
for(int i=0; i<n; i++)
{
if(a[i] == ' ')
{
for(int j=0; j<26; j++)
{
if(h[j] >= 2)
{
cnt++;
break;
}
}
memset(h,0,sizeof(h));
}
h[a[i]-'A']++;
}
for(int j=0; j<26; j++)
{
if(h[j] >= 2)
{
cnt++;
break;
}
}
cout<<cnt;
return 0;
}
|
263bf0657b2613f229ee632d3f8b041a7dbd8a08 | 88fd23eb2748bfbdd0899d62fc01358f627c56a7 | /AppleOnboardAudio/PlatformInterfaceI2C.cpp | 2cf46c604eb042fceae9ded308a98762022e4ed0 | [] | no_license | Quantum-Platinum-Cloud/AppleOnboardAudio | db16d427cbfc8da49dcb0683d27fe031056294d5 | 46f2f8a643cc36e1332feece6e39dd42a37302ab | refs/heads/main | 2023-08-17T19:25:20.473202 | 2009-05-11T20:29:13 | 2021-10-06T04:40:39 | 589,301,255 | 1 | 0 | null | 2023-01-15T18:23:51 | 2023-01-15T18:23:51 | null | UTF-8 | C++ | false | false | 1,580 | cpp | PlatformInterfaceI2C.cpp | /*
* PlatformInterfaceI2C.h
*
* Defines base class for I2C support within the context of PlatformInterface derived classes.
*
* Created by Ray Montagne on Tuesday August 24 2004.
* Copyright (c) 2004 AppleComputer. All rights reserved.
*
*/
#include "PlatformInterfaceI2C.h"
#define super OSObject
OSDefineMetaClassAndStructors ( PlatformInterfaceI2C, OSObject )
class AppleOnboardAudio;
// ----------------------------------------------------------------------------------------------------
bool PlatformInterfaceI2C::init ( IOService* device, AppleOnboardAudio* provider, UInt32 inDBDMADeviceIndex )
{
bool result;
result = super::init ();
FailIf ( !result, Exit );
mProvider = provider;
Exit:
return result;
}
// ----------------------------------------------------------------------------------------------------
void PlatformInterfaceI2C::free()
{
super::free ();
}
// ----------------------------------------------------------------------------------------------------
UInt32 PlatformInterfaceI2C::getSavedMAP ( UInt32 codecRef )
{
UInt32 result = 0xFFFFFFFF;
FailIf ( kCodec_Unknown == codecRef, Exit );
FailIf ( kCodec_NumberOfTypes <= codecRef, Exit );
result = mMAPArray[codecRef];
Exit:
return result;
}
// ----------------------------------------------------------------------------------------------------
void PlatformInterfaceI2C::saveMAP ( UInt32 codecRef, UInt32 map )
{
FailIf ( kCodec_Unknown == codecRef, Exit );
FailIf ( kCodec_NumberOfTypes <= codecRef, Exit );
mMAPArray[codecRef] = map;
Exit:
return;
}
|
bc49bb450c0655bd7feb5269a6f5e250cef79649 | 49c05d8581abe80c0294c957c288664e8d960f7a | /Algorithm/TeachNNF.h | eceedcff886d061fb47c17064850cc1ceda8e79e | [] | no_license | suto05/C-_NMF | 41d45c2a2b92b2b21768e03e73155f444eee9ff6 | cb36eb7af6503f706faf19a669de3abf9b68ce77 | refs/heads/master | 2021-01-18T02:21:20.051168 | 2015-09-06T13:23:17 | 2015-09-06T13:23:17 | 36,359,141 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 950 | h | TeachNNF.h | #ifndef _TEACHNMF
#define _TEACHNMF
#include <math.h>
#include <map>
#include "Array2D.h"
using namespace std;
template <class T> class TeachNMF
{
private:
int _class_Total;
map<int,int> _labelMap;
int _vector_length;
Array2D<T> _dictionary;
T* _excitation;
T _beta;
public:
TeachNMF()
{
}
~TeachNMF()
{
}
void _init(int class_Total,int vector_length)
{
_class_Total = class_Total;
_vector_length = vector_length;
_dictionary._setSize(_class_Total,_vector_length);
}
void _setTeach(int label,T* data)
{
if(_labelMap.size() < _class_Total)
{
if(_labelMap.find(label) == _labelMap.end()) _labelMap.insert(pair<int,int>(label,_labelMap.size()));
}
else
{
cout << "Teach Over" << endl;
}
_dictionary._clear(_labelMap.at(label));
_dictionary._setVector(_labelMap.at(label),data);
return;
}
void _process(T* data)
{
}
};
#endif
|
31e327354682e4ac07ab9778ee4d9e7a6eb5b065 | f2b6093a7da19e3375db147c9b1e55794b9fe216 | /Project3D/src/utils/Color.cpp | 7ef83a302171be3998dc892016cc230de133a626 | [
"MIT"
] | permissive | HalalaiMircea/CG-Course | 91b6feaa551c903fa564f79a5f5597d40c66f87e | ec53ec54be78d20740efe90851e00c7a7481caa1 | refs/heads/master | 2021-02-08T22:55:04.272578 | 2020-06-13T00:42:13 | 2020-06-13T00:42:13 | 244,204,912 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,014 | cpp | Color.cpp | #include "Color.hpp"
Color::Color()
: Color(0.f, 0.f, 0.f) {}
Color::Color(float r, float g, float b, float a)
: r(r), g(g), b(b), a(a) {}
Color::Color(uint8_t r, uint8_t g, uint8_t b, float a)
: Color(static_cast<float>(r) / 255, static_cast<float>(g) / 255, static_cast<float>(b) / 255, a) {}
void Color::toArray(float rgba[4]) const {
rgba[0] = r;
rgba[1] = g;
rgba[2] = b;
rgba[3] = a;
}
std::ostream &operator<<(std::ostream &os, const Color &color) {
os << "Color(r: " << color.r << " g: " << color.g << " b: " << color.b << ")";
return os;
}
const Color Color::BLACK{0.f, 0.f, 0.f};
const Color Color::RED{1.f, 0.f, 0.f};
const Color Color::YELLOW{1.f, 1.f, 0.f};
const Color Color::GREEN{0.f, 1.f, 0.f};
const Color Color::CYAN{0.f, 1.f, 1.f};
const Color Color::BLUE{0.f, 0.f, 1.f};
const Color Color::MAGENTA{1.f, 0.f, 1.f};
const Color Color::WHITE{1.f, 1.f, 1.f};
const Color Color::GREY{(uint8_t) 127, 127, 127};
|
b82f6e23426d16f62986fb84fc33805081c5c6e9 | fe700e4049e166dda741d3008d3f087720fa64be | /1st term/Homework 4/order.h | 21debd74499bedea4f8054a3244baf56db6ef85a | [] | no_license | SashoStoichkovArchive/TUES_11_OOP | cbb5528166a2565685687313a0919eb3865ff9e7 | bc3721bc410175c34d5d49297e53e54444751c46 | refs/heads/master | 2022-11-12T23:33:06.457340 | 2020-06-30T11:10:54 | 2020-06-30T11:10:54 | 209,707,087 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 790 | h | order.h | #ifndef ORDER_H
#define ORDER_H
#include <string>
#include <list>
#include "user.h"
#include "item.h"
class Order{
protected:
unsigned int order_id;
User user;
std::list<Item> ordered_items;
std::list<int> quantities;
public:
std::string order_status;
Order(){};
Order(unsigned int order_id, User user, std::list<Item> ordered_items, std::list<int> quantities, std::string order_status);
unsigned int get_id() const;
unsigned int get_user_id() const;
std::string get_order_status() const;
std::list<int> get_quantities() const;
std::list<Item> get_items() const;
void set_order_status(std::string status);
void add_item(const Item& item, int quantity);
};
#endif |
c7843620f5ffdb1242929d03b060cdd524bccd10 | 65321a1d525c3e3d555ec9f114d8d9c98226e850 | /Server/Server/Session.cpp | b2fea2cd82def2eed4fe06c5eab7226ece17fa44 | [] | no_license | tavilad/Ser2Net | e1a49919bae94590f7c1884d68a4cf56b54a132d | c854aa286397277b48006f81cd463d3f0cd1a8cb | refs/heads/master | 2021-07-04T10:57:31.770026 | 2017-09-27T13:50:25 | 2017-09-27T13:50:25 | 103,752,820 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,391 | cpp | Session.cpp | #define _CRT_SECURE_NO_WARNINGS
#include "Session.h"
#include "Serial.h"
#include <cstdlib>
#include <iostream>
#include <boost/bind.hpp>
#include <boost/asio.hpp>
#include <boost/array.hpp>
#include <boost/foreach.hpp>
#include <string>
#include <set>
using boost::asio::ip::tcp;
std::vector<Session*> participants;
std::string make_daytime_string()
{
using namespace std;
time_t now = time(0);
return ctime(&now);
}
enum Commands
{
DAYTIME,
HELLO,
LIST,
OPEN_SERIAL_PORT,
WRITE_TO_SERIAL,
READ_FROM_SERIAL
};
Session::Session(boost::asio::io_service& io_service) : socket_(io_service), io_service_(io_service)
{
}
tcp::socket& Session::socket()
{
return socket_;
}
void Session::start()
{
std::cout << "Client connected. IP: " << socket_.remote_endpoint().address().to_string() << std::endl;
this->ip = socket_.remote_endpoint().address().to_string();
participants.push_back(this);
std::cout << participants.size() << std::endl;
socket_.async_read_some(boost::asio::buffer(data_, 1024),
boost::bind(&Session::handle_read, this,
boost::asio::placeholders::error));
}
void Session::menu()
{
int cmd = data_[0] - '0';
switch (cmd)
{
case Commands::DAYTIME:
{
text = make_daytime_string();
boost::asio::async_write(socket_,
boost::asio::buffer(text),
boost::bind(&Session::handle_write, this, boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred));
break;
}
case Commands::HELLO:
{
text = "hi";
boost::asio::async_write(socket_,
boost::asio::buffer(text),
boost::bind(&Session::handle_write, this, boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred));
break;
}
case Commands::LIST:
{
int nr = participants.size();
if (participants.size() > 0)
{
for (Session* session : participants)
{
boost::asio::async_write(socket_,
boost::asio::buffer(session->ip),
boost::bind(&Session::handle_write, this, boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred));
}
}
else
{
text = "empty list";
boost::asio::async_write(socket_,
boost::asio::buffer(text),
boost::bind(&Session::handle_write, this,
boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred));
}
break;
}
case Commands::OPEN_SERIAL_PORT:
{
if (!Serial::getInstance(io_service_)->isOpen())
{
Serial::getInstance(io_service_)->open("COM4");
boost::asio::async_write(socket_,
boost::asio::buffer("Port serial deschis"),
boost::bind(&Session::handle_write, this,
boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred));
}
else
{
boost::asio::async_write(socket_,
boost::asio::buffer("Port serial este deja deschis"),
boost::bind(&Session::handle_write, this,
boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred));
}
break;
}
case Commands::WRITE_TO_SERIAL:
{
if (!Serial::getInstance(io_service_)->isOpen())
{
boost::asio::async_write(socket_,
boost::asio::buffer("Port serial inchis, deschideti pentru a scrie"),
boost::bind(&Session::handle_write, this,
boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred));
}
else
{
Serial::getInstance(io_service_)->write();
boost::asio::async_write(socket_,
boost::asio::buffer("am scris"),
boost::bind(&Session::handle_write, this,
boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred));
}
break;
}
case Commands::READ_FROM_SERIAL:
{
if (!Serial::getInstance(io_service_)->isOpen())
{
boost::asio::async_write(socket_,
boost::asio::buffer("Port serial inchis, deschideti pentru a citii"),
boost::bind(&Session::handle_write, this,
boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred));
}
else
{
text = Serial::getInstance(io_service_)->read();
if (text.length() > 0)
{
boost::asio::async_write(socket_,
boost::asio::buffer(text),
boost::bind(&Session::handle_write, this,
boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred));
}
else
{
boost::asio::async_write(socket_,
boost::asio::buffer("nimic de citit"),
boost::bind(&Session::handle_write, this,
boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred));
}
}
break;
}
}
//using memset in order to reset the data_ array
memset(data_, 0, sizeof data_);
}
void Session::handle_write(const boost::system::error_code& error, size_t len)
{
if (!error)
{
std::cout << "am trimis" << std::endl;
}
else
{
std::cout << error.message();
delete this;
}
}
void Session::handle_read(const boost::system::error_code& error)
{
if (!error)
{
socket_.async_read_some(boost::asio::buffer(data_),
boost::bind(&Session::handle_read, this,
boost::asio::placeholders::error));
menu();
}
else
if ((boost::asio::error::eof == error) ||
(boost::asio::error::connection_reset == error))
{
std::cout << "client disconnected" << std::endl;
participants.pop_back();
delete this;
}
}
Session::~Session()
{
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.