blob_id stringlengths 40 40 | directory_id stringlengths 40 40 | path stringlengths 4 201 | content_id stringlengths 40 40 | detected_licenses listlengths 0 85 | license_type stringclasses 2
values | repo_name stringlengths 7 100 | snapshot_id stringlengths 40 40 | revision_id stringlengths 40 40 | branch_name stringclasses 260
values | visit_date timestamp[us] | revision_date timestamp[us] | committer_date timestamp[us] | github_id int64 11.4k 681M ⌀ | star_events_count int64 0 209k | fork_events_count int64 0 110k | gha_license_id stringclasses 17
values | gha_event_created_at timestamp[us] | gha_created_at timestamp[us] | gha_language stringclasses 80
values | src_encoding stringclasses 28
values | language stringclasses 1
value | is_vendor bool 1
class | is_generated bool 2
classes | length_bytes int64 8 9.86M | extension stringclasses 52
values | content stringlengths 8 9.86M | authors listlengths 1 1 | author stringlengths 0 119 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
6410c79cde6d277956cd7e3b097c4001401557d0 | 1c6987e83ccb529ca69eb7669fa27e5c09ee74af | /c++11Server/.svn/pristine/64/6410c79cde6d277956cd7e3b097c4001401557d0.svn-base | 70da125b7352a6625e98dbb32326f348cfe7e021 | [] | no_license | tsrmtrue/jiwangzhengba | f92d2da51f50ef3168fe8c94774b5c962cbd11f5 | 98d528a3406594f6edb33bb7c539de4755e83e59 | refs/heads/master | 2020-03-17T21:32:03.537799 | 2018-05-18T14:19:21 | 2018-05-18T14:19:21 | 133,963,226 | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 876 | #ifndef __TEST_CLIENT_NETWORK_H__
#define __TEST_CLIENT_NETWORK_H__
#include "logic/networkThread.h"
#include "test/testPeer.h"
class CTestClientNetwork :public CNetworkThread
{
typedef CNetworkThread BASECLASS;
public:
using CNetworkThread::CNetworkThread;
bool initThread() override
{
setNeedTimer(true);
return BASECLASS::initThread();
}
void addNewPeer(CLEPeer*p) override
{
if (p)
{
m_mpPeers[p->getSocket()] = p;
//发送登陆消息,表明自己身份
}
}
bool addConnector(const char* ip, short port) override;
void onRun(unsigned long long nMsNow) override
{
auto iter = m_mpPeers.begin();
for (; iter != m_mpPeers.end(); iter++)
{
CTestPeerCompactSender* p = (CTestPeerCompactSender*)iter->second;
p->doTestSend();
}
};
};
#endif // ! __TEST_CLIENT_NETWORK_H__
| [
"tsrmtrue@163.com"
] | tsrmtrue@163.com | |
6a94b719719ede2d171f6c1be10c951808dc063c | fe6015a20a76b7b08f6f9da51b9c45d641f888ac | /detaileddifferences.cpp | 10fc4aff32e4f04577893fcac908882ed980e7c3 | [] | no_license | basilroy1/Kattis | 3a68b1627fb081989579682c05cbedb0037cc740 | 34a4fe92a7f5d7c6ef325f2707070ba9fd011f4a | refs/heads/master | 2020-03-19T14:37:24.171606 | 2019-01-30T18:32:21 | 2019-01-30T18:32:21 | 136,632,164 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 460 | cpp | #include <iostream>
using namespace std;
int main(){
int n;
string a,b;
cin >> n;
while (n--){
cin >> a >> b;
cout << a << "\n" << b << "\n";
for (int i=0;i<a.size();i++){
if (a[i] == b[i]){
cout << ".";
}
else {
cout << "*";
}
}
cout << "\n\n";
}
return 0;
} | [
"noreply@github.com"
] | noreply@github.com |
b630af185c29cfd35c081d07ebbc06f32b8bbf1c | 7e805f36261debf27d43c4718266f272b57c923f | /Binary_search/kth_division.cpp | cb25b027ceb8a9a96802a309e88d0f5e995ed9b7 | [] | no_license | ShivaBansfore-JGEC/CompetitiveProgrammingQuestions | 2c8356d6047d2c5915e361334421d9072a50eb48 | 44b2c2437aea29e6988e1dab23fa8f4f58ec76ad | refs/heads/main | 2023-01-23T19:13:18.792009 | 2020-12-08T20:25:40 | 2020-12-08T20:25:40 | 319,751,900 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 414 | cpp | #include<bits/stdc++.h>
using namespace std;
void solve(){
long long n,k;
cin>>n>>k;
long long need=(k-1)/(n-1);
cout<<k+need<<endl;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
#ifndef ONLINE_JUDGE
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
#endif
int t;
cin>>t;
while (t--)
{
solve();
}
return 0;
} | [
"shivabansfore123@gmail.com"
] | shivabansfore123@gmail.com |
bae656fc01cc5bd7ab28752b24153935c7c04572 | 739b1a6dfb57c122545c866c9e05cfecaf3592a6 | /ideone_RrBDAs.cpp | 6222102cebf12737a9f58cc025e2816f2cddbdf7 | [] | no_license | harisfi/repo1 | 074c871f7472411bd1c572facb874bff0a8aeebc | e53863e3b2e5f97714777410f36e398753af20d8 | refs/heads/master | 2022-11-26T03:25:40.097097 | 2020-08-11T14:20:41 | 2020-08-11T14:20:41 | 286,757,586 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 268 | cpp | #include <bits/stdc++.h>
using namespace std;
int bagi(int x){
int y=0;
for(int i=1;i<=x;i++){
if(x%i==0) y++;
}
return y;
}
int main() {
int n,x;
cin>>n;
for(int i=0;i<n;i++){
cin>>x;
if(bagi(x)<=4) cout<<"YA\n";
else cout<<"BUKAN\n";
}
return 0;
}
| [
"acc.cp.haris@gmail.com"
] | acc.cp.haris@gmail.com |
75970a52ef46c6a62160520e37736a6ddd8cfefc | 913a3acee9ec82ea3b69805c2a2d36604e5e6237 | /SDLTutorial/CEvent.h | 31836259d1788e62f51f8e45bfb5c648d357a53b | [] | no_license | asandriss/SDLGameEngine | 89fbcadb1dc536e03a067800079bc8d2fc84b37c | cb9de8d5e21ebcfa4fa1ff932451d5fb1a3e319d | refs/heads/master | 2020-05-29T09:39:23.798846 | 2012-09-13T07:23:47 | 2012-09-13T07:23:47 | 5,782,384 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,646 | h | #pragma once
#include <SDL.h>
class CEvent {
public:
CEvent();
virtual ~CEvent();
virtual void OnEvent(SDL_Event* Event);
virtual void OnInputFocus();
virtual void OnInputBlur();
virtual void OnKeyDown(SDLKey sym, SDLMod mod, Uint16 unicode);
virtual void OnKeyUp(SDLKey sym, SDLMod mod, Uint16 unicode);
virtual void OnMouseFocus();
virtual void OnMouseBlur();
virtual void OnMouseMove(int mX, int mY, int relX, int relY, bool Left,bool Right,bool Middle);
virtual void OnMouseWheel(bool Up, bool Down); //Not implemented
virtual void OnLButtonDown(int mX, int mY);
virtual void OnLButtonUp(int mX, int mY);
virtual void OnRButtonDown(int mX, int mY);
virtual void OnRButtonUp(int mX, int mY);
virtual void OnMButtonDown(int mX, int mY);
virtual void OnMButtonUp(int mX, int mY);
virtual void OnJoyAxis(Uint8 which, Uint8 axis, Sint16 value);
virtual void OnJoyButtonDown(Uint8 which, Uint8 button);
virtual void OnJoyButtonUp(Uint8 which, Uint8 button);
virtual void OnJoyHat(Uint8 which, Uint8 hat, Uint8 value);
virtual void OnJoyBall(Uint8 which, Uint8 ball, Sint16 xrel, Sint16 yrel);
virtual void OnMinimize();
virtual void OnRestore();
virtual void OnResize(int w,int h);
virtual void OnExpose();
virtual void OnExit();
virtual void OnUser(Uint8 type, int code, void* data1, void* data2);
}; | [
"fedorhajdu@gmail.com"
] | fedorhajdu@gmail.com |
90d6ef2f57bd2cf159d77b95b22cc77ad5e06112 | a3683a22d7855307b0cbf897cc3de3a72edd95c2 | /practice/quicksort.cpp | 33f2121eeee441c97599a4338aae849f06d5cd95 | [] | no_license | hari-kadumuri/coding | d066abd43d5dea7dac1dc0e6d7c37d752807bd9e | 776c778a2da478d631ae8b9a866fa1b32d5ca449 | refs/heads/master | 2022-11-08T09:02:47.895519 | 2020-06-17T11:25:35 | 2020-06-17T11:25:35 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 842 | cpp | #include<iostream>
using namespace std;
int partition(int* a, int l, int r) {
int pivot = a[r],temp;
int i=l-1,j=l;
for(j=l;j<=r;j++) {
if(a[j]<pivot) {
i++;
temp = a[i];
a[i] = a[j];
a[j] = temp;
}
}
temp = a[i+1];
a[i+1] = pivot;
a[r] = temp;
return i;
}
void quicksort(int* a, int l, int r) {
if(l<r) {
int q = partition(a, l, r);
quicksort(a, l, q);
quicksort(a, q+1, r);
}
}
/*int main() {
int n,*a;
cout<<"Enter n value :\n";
cin>>n;
a = new int[n];
for(int i=0;i<n;i++)
cin>>a[i];
quicksort(a, 0, n-1);
cout<<endl<<"Quick Sorted array :\t";
for(int i=0;i<n;i++)
cout<<a[i]<<"\t";
delete []a;
return 0;
}*/
| [
"hari.kadumuri@gmail.com"
] | hari.kadumuri@gmail.com |
ceb7c442866d5b8d473babdb295dcc0bfe128cbf | 8a359cf909f3ed99d0995b190671904c9e9b176e | /UVA/10014.cpp | fb80f4eda561a087ee3b42c54f048295125cff6c | [] | no_license | andreqi/programming | b7249fb5434f964274b9c04da7310a6237799f14 | df01d7cfc1a17e7f7fccf7360a4056c7b5b3e51a | refs/heads/master | 2021-01-15T09:32:22.033834 | 2013-09-12T15:39:39 | 2013-09-12T15:39:39 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,485 | cpp | #include <iostream>
#include <cstdio>
#include <algorithm>
#include <set>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <map>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <numeric>
#define repn( i , a , b ) for( int i = ( int ) a ; i < ( int ) b ; i ++ )
#define rep( i , n ) repn( i , 0 , n )
#define all( x ) x.begin() , x.end()
#define rall( x ) x.rbegin() , x.rend()
#define mp make_pair
#define fst first
#define snd second
#define MAXN 3010
using namespace std;
typedef long long int64;
typedef long double ldouble;
typedef pair< int , int > pii;
double c[ MAXN ];
double a[ MAXN ], b[ MAXN ], r[ MAXN ];
// 2 ai-1 + 2 ci-1 - ai-2 = ai
int main(){
int test;
scanf("%d" ,& test );
while( test-- ){
int n; scanf("%d", &n );
double an1 , a0 ;
scanf("%lf%lf" , &a0 , &an1 );
rep( i , n ) scanf("%lf" , c + i + 1 );
if( n == 1 ){
printf("%.2lf\n" , ( an1 + a0 ) / 2. - c[ 1 ] );
}
else{
a[ 0 ] = 1, b[ 0 ] = 0 , r[ 0 ] = 0;
a[ 1 ] = 0, b[ 1 ] = 1 , r[ 1 ] = 0;
repn( i , 2, n + 1 ){
a[ i ] = 2. * a[ i - 1 ] - a[ i - 2 ];
b[ i ] = 2. * b[ i - 1 ] - b[ i - 2 ];
r[ i ] = 2. * r[ i - 1 ] - r[ i - 2 ] + 2. * c[ i - 1 ];
}
double sum = 0;
rep( i , n ) sum += c[ i + 1 ];
double ans = an1 + a0 - 2. * sum - a0 * a[ n ] - r[ n ];
ans /= ( b[ n ] + 1. );
printf("%.2lf\n" , ans );
}
if( test ) printf("\n");
}
return 0;
}
| [
"drol.005@gmail.com"
] | drol.005@gmail.com |
88410ef6c8c313ceafbfdfc00cf29a8c44f2ced1 | fd7a802ff482231123b6adb48b3f5fa11bdc406b | /building.h | 490fcf2cfd101ae163c99008b10ea6574230b90c | [] | no_license | erikhallin/Kragzhor | 7ffff43836b72fbe7be6c0fb257f9eeba320baf4 | 54d68ce57228285997d9783a8847bea5717ceab4 | refs/heads/master | 2020-07-03T05:18:52.404002 | 2019-08-11T17:44:19 | 2019-08-11T17:44:19 | 201,796,415 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 744 | h | #ifndef BUILDING_H
#define BUILDING_H
#include <gl/gl.h>
#include "definitions.h"
class building
{
public:
building();
building(const st_pos& pos,int texture);
bool m_selected;
float m_hp_curr;
bool init(const st_pos& pos,int texture);
bool update(void);
bool draw(void) ;
bool is_pos_inside(const st_pos& pos) const;
bool is_pos_inside_rect(const st_pos& pos_top_left, const st_pos& pos_low_right) const;
bool is_pos_inside_circle2(st_pos pos,float radius2);
st_pos get_curr_pos(void);
bool take_damage(float damage);
private:
st_pos m_pos;
float m_size;
int m_texture,m_tex_type;
};
#endif // BUILDING_H
| [
"erik-hallin@hotmail.com"
] | erik-hallin@hotmail.com |
d1aac121de7289316f1b8c44fb55bcb958ddae80 | b967295eb531575eb39ef0b2f0d83c4297808fd8 | /packages/eigen-eigen-323c052e1731/test/zerosized.cpp | 262af2d09ac3143918ba577c952096c472f9f7f5 | [
"Apache-2.0",
"MPL-2.0",
"Minpack",
"LGPL-2.1-only",
"BSD-3-Clause",
"GPL-3.0-only",
"LGPL-2.0-or-later",
"LGPL-2.1-or-later"
] | permissive | ai-techsystems/dnnc-operators | de9dc196db343003b6f3506dc0e502d59df2689f | 55e682c0318091c4ee87a8e67134a31042c393e1 | refs/heads/master | 2020-07-02T16:08:37.965213 | 2019-08-29T14:38:52 | 2019-08-29T14:38:52 | 201,582,638 | 5 | 7 | Apache-2.0 | 2019-09-06T18:31:19 | 2019-08-10T05:06:16 | C++ | UTF-8 | C++ | false | false | 3,486 | cpp | // This file is part of Eigen, a lightweight C++ template library
// for linear algebra.
//
// Copyright (C) 2011 Benoit Jacob <jacob.benoit.1@gmail.com>
//
// This Source Code Form is subject to the terms of the Mozilla
// Public License v. 2.0. If a copy of the MPL was not distributed
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
#include "main.h"
template<typename MatrixType> void zeroReduction(const MatrixType& m) {
// Reductions that must hold for zero sized objects
VERIFY(m.all());
VERIFY(!m.any());
VERIFY(m.prod()==1);
VERIFY(m.sum()==0);
VERIFY(m.count()==0);
VERIFY(m.allFinite());
VERIFY(!m.hasNaN());
}
template<typename MatrixType> void zeroSizedMatrix()
{
MatrixType t1;
typedef typename MatrixType::Scalar Scalar;
if (MatrixType::SizeAtCompileTime == Dynamic || MatrixType::SizeAtCompileTime == 0)
{
zeroReduction(t1);
if (MatrixType::RowsAtCompileTime == Dynamic)
VERIFY(t1.rows() == 0);
if (MatrixType::ColsAtCompileTime == Dynamic)
VERIFY(t1.cols() == 0);
if (MatrixType::RowsAtCompileTime == Dynamic && MatrixType::ColsAtCompileTime == Dynamic)
{
MatrixType t2(0, 0), t3(t1);
VERIFY(t2.rows() == 0);
VERIFY(t2.cols() == 0);
zeroReduction(t2);
VERIFY(t1==t2);
}
}
if(MatrixType::MaxColsAtCompileTime!=0 && MatrixType::MaxRowsAtCompileTime!=0)
{
Index rows = MatrixType::RowsAtCompileTime==Dynamic ? internal::random<Index>(1,10) : Index(MatrixType::RowsAtCompileTime);
Index cols = MatrixType::ColsAtCompileTime==Dynamic ? internal::random<Index>(1,10) : Index(MatrixType::ColsAtCompileTime);
MatrixType m(rows,cols);
zeroReduction(m.template block<0,MatrixType::ColsAtCompileTime>(0,0,0,cols));
zeroReduction(m.template block<MatrixType::RowsAtCompileTime,0>(0,0,rows,0));
zeroReduction(m.template block<0,1>(0,0));
zeroReduction(m.template block<1,0>(0,0));
Matrix<Scalar,Dynamic,Dynamic> prod = m.template block<MatrixType::RowsAtCompileTime,0>(0,0,rows,0) * m.template block<0,MatrixType::ColsAtCompileTime>(0,0,0,cols);
VERIFY(prod.rows()==rows && prod.cols()==cols);
VERIFY(prod.isZero());
prod = m.template block<1,0>(0,0) * m.template block<0,1>(0,0);
VERIFY(prod.size()==1);
VERIFY(prod.isZero());
}
}
template<typename VectorType> void zeroSizedVector()
{
VectorType t1;
if (VectorType::SizeAtCompileTime == Dynamic || VectorType::SizeAtCompileTime==0)
{
zeroReduction(t1);
VERIFY(t1.size() == 0);
VectorType t2(DenseIndex(0)); // DenseIndex disambiguates with 0-the-null-pointer (error with gcc 4.4 and MSVC8)
VERIFY(t2.size() == 0);
zeroReduction(t2);
VERIFY(t1==t2);
}
}
void test_zerosized()
{
zeroSizedMatrix<Matrix2d>();
zeroSizedMatrix<Matrix3i>();
zeroSizedMatrix<Matrix<float, 2, Dynamic> >();
zeroSizedMatrix<MatrixXf>();
zeroSizedMatrix<Matrix<float, 0, 0> >();
zeroSizedMatrix<Matrix<float, Dynamic, 0, 0, 0, 0> >();
zeroSizedMatrix<Matrix<float, 0, Dynamic, 0, 0, 0> >();
zeroSizedMatrix<Matrix<float, Dynamic, Dynamic, 0, 0, 0> >();
zeroSizedMatrix<Matrix<float, 0, 4> >();
zeroSizedMatrix<Matrix<float, 4, 0> >();
zeroSizedVector<Vector2d>();
zeroSizedVector<Vector3i>();
zeroSizedVector<VectorXf>();
zeroSizedVector<Matrix<float, 0, 1> >();
zeroSizedVector<Matrix<float, 1, 0> >();
}
| [
"gunjan@localhost.localdomain"
] | gunjan@localhost.localdomain |
c1b3c89b41550bc7c6938db542dcf28f391c9ddc | 37bf5c6d30974be8101ceb16363181a905c0fcba | /Classes/UIControls/LockedButton.h | 2075e8f4a621dab6730b8010dca63c4a5301ffa3 | [] | no_license | BlitzModder/SceneViewer | 396f8b04ecc2bd85190f54ba12c86ccba27d4e6d | 3917e4ad924a7061700b0add78c19573f8b66bfd | refs/heads/master | 2021-01-20T13:03:01.613859 | 2017-05-06T05:31:18 | 2017-05-06T05:31:18 | 90,439,774 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 567 | h | #pragma once
#include <UI/UIButton.h>
class LockedButton;
class LockedButtonHolder
{
public:
virtual ~LockedButtonHolder()
{
}
virtual void OnButtonPressed(LockedButton*) = 0;
};
class LockedButton : public DAVA::UIButton
{
public:
explicit LockedButton(LockedButtonHolder& holder, DAVA::Font* font, const DAVA::WideString& text, const DAVA::Rect& rect);
bool IsLocked() const;
void SetLocked(bool selected);
private:
void OnPressed(DAVA::BaseObject* caller, void* param, void* callerData);
LockedButtonHolder& holder;
};
| [
"subdiox@gmail.com"
] | subdiox@gmail.com |
865775478b9380d60970cfc418558b9d1386b672 | d2e640d0131676e0d6f35135ab3474ff699f272b | /libs/semanticsearch/include/semanticsearch/schema/semantic_reducer.hpp | 4b06d0d161cd3dbaecbd8ce84fc070710233182a | [
"Apache-2.0",
"LicenseRef-scancode-unknown",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | engineerkatie/ledger | dbb1e062c18db99a96b3d24252953d7103075b81 | 044d118994cfc53e749ce1d1ed22dad5723067b0 | refs/heads/master | 2020-07-24T00:23:13.572676 | 2019-12-09T09:19:20 | 2019-12-09T09:19:20 | 207,748,084 | 1 | 1 | Apache-2.0 | 2019-09-11T07:17:54 | 2019-09-11T07:17:54 | null | UTF-8 | C++ | false | false | 2,328 | hpp | #pragma once
//------------------------------------------------------------------------------
//
// Copyright 2018-2019 Fetch.AI Limited
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
//------------------------------------------------------------------------------
#include "semanticsearch/index/base_types.hpp"
#include "semanticsearch/schema/vocabulary_instance.hpp"
#include <functional>
#include <memory>
#include <vector>
namespace fetch {
namespace semanticsearch {
class SemanticReducer
{
public:
using Vocabulary = std::shared_ptr<VocabularyInstance>;
template <typename T>
using Reducer = std::function<SemanticPosition(T const &)>;
template <typename T>
using Validator = std::function<bool(T const &)>;
SemanticReducer() = default;
SemanticReducer(SemanticReducer const &other) = default;
SemanticReducer &operator=(SemanticReducer const &other) = default;
template <typename T>
void SetReducer(int32_t rank, Reducer<T> reducer)
{
rank_ = rank;
reducer_ = [reducer](void *data) { return reducer(*reinterpret_cast<T *>(data)); };
if (reducer_ == nullptr)
{
rank_ = 0;
}
}
template <typename T>
void SetValidator(Validator<T> validator)
{
constraints_validation_ = [validator](void *data) {
return validator(*reinterpret_cast<T *>(data));
};
}
bool Validate(void *data);
SemanticPosition Reduce(void *data);
int32_t rank() const;
private:
using InternalReducer = std::function<SemanticPosition(void *)>;
using InternalValidator = std::function<bool(void *)>;
int32_t rank_{0};
InternalReducer reducer_{nullptr};
InternalValidator constraints_validation_{nullptr};
};
} // namespace semanticsearch
} // namespace fetch
| [
"42541508+fetch-bot@users.noreply.github.com"
] | 42541508+fetch-bot@users.noreply.github.com |
b527a12c921829217fbb96d40ee1661c67399e5c | 54b2aa8455fe674d5ae2d3559264f57a39a042c7 | /src/scenes/TerrainScene.h | bee0f5ba409e5430d76a6848c9409f378749a23b | [
"MIT"
] | permissive | maksmaisak/Saxion_Y2Q2_Rendering | 04db607954b2c8f25d75aeb344ecfbef6c111f48 | 14cf23c4e333599f16d200879301e8d5548e562b | refs/heads/master | 2020-04-11T00:50:50.427362 | 2019-03-19T18:07:49 | 2019-03-19T18:07:49 | 161,398,495 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 324 | h | //
// Created by Maksym Maisak on 2019-01-16.
//
#ifndef SAXION_Y2Q2_RENDERING_TERRAINSCENE_H
#define SAXION_Y2Q2_RENDERING_TERRAINSCENE_H
#include "Engine.h"
#include "Scene.h"
#include <vector>
class TerrainScene : public en::Scene {
public:
void open() override;
};
#endif //SAXION_Y2Q2_RENDERING_TERRAINSCENE_H
| [
"max.maisak@gmail.com"
] | max.maisak@gmail.com |
244ed7cb81c9a3ac3c0c0f04c725a04222aa69a0 | 0ff3fd877d869d54c2c33c8477cd256e0e1e521b | /M5StickC_Watch_RSSI/M5StickC_Watch_RSSI.ino | 8b9a645298f66b2346963e2209af42286fe07a59 | [] | no_license | vivian-ng/M5StickC_Watch_RSSI | 8ef68673da3a1616e001073c59aa996923f62c30 | b72226303ce2cf5b3e4ce0d6a282faab41f442cb | refs/heads/main | 2023-02-20T10:14:59.122917 | 2021-01-18T23:49:28 | 2021-01-18T23:49:28 | 330,391,040 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,441 | ino | /***
* Arduino sketch for M5StickC that displays the current time, date,
* and WiFi signal strength of the connected SSID.
*
* Adapted from this sketch: https://github.com/LordLeXaT/m5StickC-Clock
*
* Shortpress button A (large button with 'M5') disables LCD (powersaving)
* Longpress (2sec) button B (small button at top) forces resync with NTP-Server
*
* Change from good to moderate signal is set at -60 dBm and from moderate to poor
* at -70 dBm.
* Reference used: https://eyesaas.com/wi-fi-signal-strength/
*
* Put configuration settings in a separate config.h file that contains
* #define TIMEZONE 9
* #define WIFI_SSID "your_wifi_ssid"
* #define WIFI_PASSWORD "your_wifi_password"
*
* where
* TIMEZONE is the number of hours ahead of GMT (use negative number if behind GMT)
* WIFI_SSID is SSID to connect to
* WIFI_PASSWORD is password for SSID
***/
#include <Arduino.h>
#include <M5StickC.h>
#include <ESPmDNS.h>
#include <WiFi.h>
#include "time.h"
#include "config.h"
#include <ArduinoOTA.h>
// default hostname if not defined in config.h
#ifndef HOSTNAME
#define HOSTNAME "m5stickc"
#endif
// default hostname if not defined in config.h
#ifndef RESYNC_SECONDS
#define RESYNC_SECONDS 100000
#endif
// use the WiFi settings in config.h file
char* ssid = WIFI_SSID;
char* password = WIFI_PASSWORD;
// define the NTP server to use
char* ntpServer = "ntp.nict.jp";
// define what timezone you are in
int timeZone = TIMEZONE * 3600;
// time in seconds since last resync
long timeSinceResync = 0;
// delay workarround
int tcount = 0;
// LCD Status
bool LCD = true;
RTC_TimeTypeDef RTC_TimeStruct;
RTC_DateTypeDef RTC_DateStruct;
//delays stopping usualy everything using this workarround
bool timeToDo(int tbase) {
tcount++;
if (tcount == tbase) {
tcount = 0;
return true;
} else {
return false;
}
}
// Syncing time from NTP Server
void timeSync() {
M5.Lcd.setTextSize(1);
Serial.println("Syncing Time");
Serial.printf("Connecting to %s ", ssid);
M5.Lcd.fillScreen(BLACK);
M5.Lcd.setCursor(20, 15);
M5.Lcd.println("connecting WiFi");
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println(" CONNECTED");
M5.Lcd.fillScreen(BLACK);
M5.Lcd.setCursor(20, 15);
M5.Lcd.println("Connected");
// Set ntp time to local
configTime(timeZone, 0, ntpServer);
// Get local time
struct tm timeInfo;
if (getLocalTime(&timeInfo)) {
// Set RTC time
RTC_TimeTypeDef TimeStruct;
TimeStruct.Hours = timeInfo.tm_hour;
TimeStruct.Minutes = timeInfo.tm_min;
TimeStruct.Seconds = timeInfo.tm_sec;
M5.Rtc.SetTime(&TimeStruct);
RTC_DateTypeDef DateStruct;
DateStruct.WeekDay = timeInfo.tm_wday;
DateStruct.Month = timeInfo.tm_mon + 1;
DateStruct.Date = timeInfo.tm_mday;
DateStruct.Year = timeInfo.tm_year + 1900;
M5.Rtc.SetData(&DateStruct);
Serial.println("Time now matching NTP");
M5.Lcd.fillScreen(BLACK);
M5.Lcd.setCursor(20, 15);
M5.Lcd.println("S Y N C");
delay(500);
M5.Lcd.fillScreen(BLACK);
}
timeSinceResync = 0;
}
void buttons_code() {
// Button A control the LCD (ON/OFF)
if (M5.BtnA.wasPressed()) {
if (LCD) {
M5.Lcd.writecommand(ST7735_DISPOFF);
M5.Axp.ScreenBreath(0);
LCD = !LCD;
} else {
M5.Lcd.writecommand(ST7735_DISPON);
M5.Axp.ScreenBreath(255);
LCD = !LCD;
}
}
// Button B doing a time resync if pressed for 2 sec
if (M5.BtnB.pressedFor(2000)) {
timeSync();
}
}
// Printing WiFi RSSI and time to LCD
void doTime() {
//if (timeToDo(1000)) {
timeSinceResync++;
if(timeSinceResync > RESYNC_SECONDS)
timeSync();
vTaskDelay(1000 / portTICK_PERIOD_MS);
M5.Lcd.setCursor(10, 10);
M5.Lcd.setTextSize(1);
M5.Lcd.printf("%s: ", WiFi.SSID());
long strength = WiFi.RSSI();
if(strength < -70) M5.Lcd.setTextColor(RED, BLACK);
else if(strength < -60) M5.Lcd.setTextColor(YELLOW, BLACK);
else M5.Lcd.setTextColor(GREEN, BLACK);
M5.Lcd.printf("%02d\n", strength);
M5.Lcd.setTextSize(3);
M5.Lcd.setTextColor(WHITE, BLACK);
M5.Rtc.GetTime(&RTC_TimeStruct);
M5.Rtc.GetData(&RTC_DateStruct);
M5.Lcd.setCursor(10, 25);
M5.Lcd.printf("%02d:%02d:%02d\n", RTC_TimeStruct.Hours, RTC_TimeStruct.Minutes, RTC_TimeStruct.Seconds);
M5.Lcd.setCursor(15, 60);
M5.Lcd.setTextSize(1);
M5.Lcd.setTextColor(WHITE, BLACK);
M5.Lcd.printf("Date: %04d-%02d-%02d\n", RTC_DateStruct.Year, RTC_DateStruct.Month, RTC_DateStruct.Date);
//}
}
void setup() {
M5.begin();
M5.Lcd.setRotation(1);
M5.Lcd.fillScreen(BLACK);
M5.Lcd.setTextSize(1);
M5.Lcd.setTextColor(WHITE,BLACK);
timeSync(); //uncomment if you want to have a timesync everytime you turn device on (if no WIFI is avail mostly bad)
// Port defaults to 3232
// ArduinoOTA.setPort(3232);
// Hostname defaults to esp3232-[MAC]
ArduinoOTA.setHostname(HOSTNAME);
// No authentication by default
// ArduinoOTA.setPassword("admin");
// Password can be set with it's md5 value as well
// MD5(admin) = 21232f297a57a5a743894a0e4a801fc3
// ArduinoOTA.setPasswordHash("21232f297a57a5a743894a0e4a801fc3");
ArduinoOTA
.onStart([]() {
String type;
if (ArduinoOTA.getCommand() == U_FLASH)
type = "sketch";
else // U_SPIFFS
type = "filesystem";
// NOTE: if updating SPIFFS this would be the place to unmount SPIFFS using SPIFFS.end()
Serial.println("Start updating " + type);
})
.onEnd([]() {
Serial.println("\nEnd");
})
.onProgress([](unsigned int progress, unsigned int total) {
Serial.printf("Progress: %u%%\r", (progress / (total / 100)));
})
.onError([](ota_error_t error) {
Serial.printf("Error[%u]: ", error);
if (error == OTA_AUTH_ERROR) Serial.println("Auth Failed");
else if (error == OTA_BEGIN_ERROR) Serial.println("Begin Failed");
else if (error == OTA_CONNECT_ERROR) Serial.println("Connect Failed");
else if (error == OTA_RECEIVE_ERROR) Serial.println("Receive Failed");
else if (error == OTA_END_ERROR) Serial.println("End Failed");
});
ArduinoOTA.begin();
}
void loop() {
M5.update();
buttons_code();
doTime();
ArduinoOTA.handle();
}
| [
"vivian@maplerain.com"
] | vivian@maplerain.com |
6590ad262f9f4df5c285a8ff589a2878d9ef2fc0 | c2949509575b3085464a79d61beb7279b635a2d3 | /HW6/[CS380 HW6] 20160385 오진영/rigtform.h | 4a6aa38402d69daf417abae5b3f24c32dcd9bdfa | [
"BSD-2-Clause"
] | permissive | EEngblo/18S_CS380 | 86ffcac69ca0bdc50eddf34782abb0346e92ad2d | 63c724c2271678c021a3ed5de095b1d52ef73182 | refs/heads/master | 2020-03-08T04:39:22.227869 | 2018-05-31T13:19:34 | 2018-05-31T13:19:34 | 127,928,252 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,315 | h | #ifndef RIGTFORM_H
#define RIGTFORM_H
#include <iostream>
#include <cassert>
#include "matrix4.h"
#include "quat.h"
class RigTForm {
Cvec3 t_; // translation component
Quat r_; // rotation component represented as a quaternion
public:
RigTForm() : t_(0) {
assert(norm2(Quat(1,0,0,0) - r_) < CS175_EPS2);
}
RigTForm(const Cvec3& t, const Quat& r) {
// TODO
this->t_ = t;
this->r_ = r;
}
explicit RigTForm(const Cvec3& t) {
// TODO
this->t_ = t;
this->r_ = Quat();
}
explicit RigTForm(const Quat& r) {
// TODO
this->t_ = Cvec3();
this->r_ = r;
}
Cvec3 getTranslation() const {
return t_;
}
Quat getRotation() const {
return r_;
}
RigTForm& setTranslation(const Cvec3& t) {
t_ = t;
return *this;
}
RigTForm& setRotation(const Quat& r) {
r_ = r;
return *this;
}
Cvec4 operator * (const Cvec4& a) {
// TODO
return (this->r_) * a + Cvec4(this->t_,0);
}
RigTForm operator * (const RigTForm& a) const {
Cvec3 t = Cvec3(this -> t_);
t += Cvec3(this->r_ * Cvec4(a.getTranslation(),0));
Quat r = this->r_ * a.getRotation();
return RigTForm(t,r);
// TODO
}
};
inline RigTForm inv(const RigTForm& tform) {
// TODO
Quat newR = inv(tform.getRotation());
Cvec4 newT4 = newR * Cvec4(tform.getTranslation()[0], tform.getTranslation()[1], tform.getTranslation()[2], 0) * -1.0;
Cvec3 newT = Cvec3(newT4);
return RigTForm(newT, newR);
}
inline RigTForm transFact(const RigTForm& tform) {
return RigTForm(tform.getTranslation());
}
inline RigTForm linFact(const RigTForm& tform) {
return RigTForm(tform.getRotation());
}
static Matrix4 makeTranslation_rig(const Cvec3& t) {
Matrix4 r;
for (int i = 0; i < 3; ++i) {
r(i,3) = t[i];
}
return r;
}
inline Matrix4 rigTFormToMatrix(const RigTForm& tform) {
// TODO
Matrix4 T = makeTranslation_rig(tform.getTranslation());
Matrix4 R = quatToMatrix(tform.getRotation());
return T * R;
}
inline RigTForm slerp(const RigTForm& startRbt, const RigTForm& endRbt, const float alpha){
Cvec3 trans = lerp(startRbt.getTranslation(), endRbt.getTranslation(), alpha);
Quat rot = slerp(startRbt.getRotation(), endRbt.getRotation(), alpha);
// while(1){};
return RigTForm(trans, rot);
}
#endif
| [
"sheogorath0213@kaist.ac.kr"
] | sheogorath0213@kaist.ac.kr |
e7aafb19ce753637849838b92a29d1cbecfaa32c | 2464d2667453811a4e48edb8590c34a1e47542f1 | /M0426_Arduino.ino | 380526737c5bf795d9bf519e584be07f5383725d | [] | no_license | myarduinosale/sensor1 | 149b0426a8c6b97df7e7223498bb39289aa48e1f | 12508230e74bb427d0f58810ad21a80f68be8755 | refs/heads/master | 2022-12-23T21:33:30.916404 | 2022-12-19T10:31:34 | 2022-12-19T10:31:34 | 126,945,591 | 0 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 1,132 | ino | #include "Arduino.h"
#include <DHT12.h>
DHT12 dht12;
void setup()
{
Serial.begin(112560);
dht12.begin();
}
int timeSinceLastRead = 0;
void loop()
{
if(timeSinceLastRead > 2000) {
float t12 = dht12.readTemperature();
float f12 = dht12.readTemperature(true);
float h12 = dht12.readHumidity();
bool dht12Read = true;
if (isnan(h12) || isnan(t12) || isnan(f12)) {
Serial.println("Failed to read from DHT12 sensor!");
dht12Read = false;
}
if (dht12Read){
float hif12 = dht12.computeHeatIndex(f12, h12);
float hic12 = dht12.computeHeatIndex(t12, h12, false);
float dpf12 = dht12.dewPoint(f12, h12);
float dpc12 = dht12.dewPoint(t12, h12, false);
Serial.print("ค่าความชื้น: ");
Serial.print(h12);
Serial.print(" %\t");
Serial.print("ค่าอุณหภูมิ: ");
Serial.print(t12);
Serial.print(" *C ");
Serial.print(f12);
Serial.println(" *F\t");
}
timeSinceLastRead = 0;
}
delay(100);
timeSinceLastRead += 100;
}
| [
"noreply@github.com"
] | noreply@github.com |
ec05f650301323e04d804fd0544a2efad7a9d74b | 8cf32b4cbca07bd39341e1d0a29428e420b492a6 | /contracts/libc++/upstream/test/std/containers/associative/multimap/multimap.cons/iter_iter_comp.pass.cpp | 3f7885df8f98ae666287e03aaa0b21dbf462c3a0 | [
"MIT",
"NCSA"
] | permissive | cubetrain/CubeTrain | e1cd516d5dbca77082258948d3c7fc70ebd50fdc | b930a3e88e941225c2c54219267f743c790e388f | refs/heads/master | 2020-04-11T23:00:50.245442 | 2018-12-17T16:07:16 | 2018-12-17T16:07:16 | 156,970,178 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,487 | cpp | //===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <map>
// class multimap
// template <class InputIterator>
// multimap(InputIterator first, InputIterator last,
// const key_compare& comp);
#include <map>
#include <cassert>
#include "../../../test_compare.h"
#include "min_allocator.h"
int main()
{
{
typedef std::pair<const int, double> V;
V ar[] =
{
V(1, 1),
V(1, 1.5),
V(1, 2),
V(2, 1),
V(2, 1.5),
V(2, 2),
V(3, 1),
V(3, 1.5),
V(3, 2),
};
typedef test_compare<std::less<int> > C;
std::multimap<int, double, C> m(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5));
assert(m.key_comp() == C(5));
assert(m.size() == 9);
assert(distance(m.begin(), m.end()) == 9);
assert(*m.begin() == V(1, 1));
assert(*next(m.begin()) == V(1, 1.5));
assert(*next(m.begin(), 2) == V(1, 2));
assert(*next(m.begin(), 3) == V(2, 1));
assert(*next(m.begin(), 4) == V(2, 1.5));
assert(*next(m.begin(), 5) == V(2, 2));
assert(*next(m.begin(), 6) == V(3, 1));
assert(*next(m.begin(), 7) == V(3, 1.5));
assert(*next(m.begin(), 8) == V(3, 2));
}
#if TEST_STD_VER >= 11
{
typedef std::pair<const int, double> V;
V ar[] =
{
V(1, 1),
V(1, 1.5),
V(1, 2),
V(2, 1),
V(2, 1.5),
V(2, 2),
V(3, 1),
V(3, 1.5),
V(3, 2),
};
typedef test_compare<std::less<int> > C;
std::multimap<int, double, C, min_allocator<V>> m(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5));
assert(m.key_comp() == C(5));
assert(m.size() == 9);
assert(distance(m.begin(), m.end()) == 9);
assert(*m.begin() == V(1, 1));
assert(*next(m.begin()) == V(1, 1.5));
assert(*next(m.begin(), 2) == V(1, 2));
assert(*next(m.begin(), 3) == V(2, 1));
assert(*next(m.begin(), 4) == V(2, 1.5));
assert(*next(m.begin(), 5) == V(2, 2));
assert(*next(m.begin(), 6) == V(3, 1));
assert(*next(m.begin(), 7) == V(3, 1.5));
assert(*next(m.begin(), 8) == V(3, 2));
}
#endif
}
| [
"1848@shanchain.com"
] | 1848@shanchain.com |
eeabed7f5e4e1378374c5b5c1d1904d558dba622 | efb416524a5e01f25594f2dd5cdeb646489f93e1 | /leetcode_5366/leetcode_5366.cpp | 32e815fb8812b78c74a2fdd869c5f43d7a6a1a11 | [] | no_license | whosxavierwu/LeetCodeSolution | fcb0d7efb9414acc91cfe7272bb4ddf23900d73f | 5925901375c9b1e43e8d65a64ff31564c42dfdf1 | refs/heads/master | 2023-08-11T01:20:25.934236 | 2023-07-23T10:00:34 | 2023-07-23T10:00:34 | 195,152,346 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,427 | cpp | // leetcode_5366.cpp : This file contains the 'main' function. Program execution begins and ends there.
// https://leetcode.com/contest/weekly-contest-181/problems/check-if-there-is-a-valid-path-in-a-grid/
#include <iostream>
#include <vector>
using namespace std;
class Solution {
int di[4] = { 1, -1, 0, 0 };
int dj[4] = { 0, 0, 1, -1 };
int t[6] = { 4 | 8, 1 | 2, 8 | 1, 4 | 1, 8 | 2, 4 | 2 };
public:
bool dfs(const vector<vector<int>>& grid, vector<vector<bool>>& visited,
int i, int j, const int& n, const int& m) {
if (i == n - 1 && j == m - 1)
return true;
visited[i][j] = true;
for (int k = 0; k < 4; ++k) {
if (t[grid[i][j] - 1] >> k & 1 ^ 1)
continue;
int ni = i + di[k];
int nj = j + dj[k];
if (ni < 0 || nj < 0 || ni >= n || nj >= m || visited[ni][nj])
continue;
int k2 = k ^ 1;
if (t[grid[ni][nj] - 1] >> k2 & 1 ^ 1)
continue;
if (dfs(grid, visited, ni, nj, n, m))
return true;
}
return false;
}
bool hasValidPath(vector<vector<int>>& grid) {
int n = grid.size();
int m = grid[0].size();
vector<vector<bool>> visited(n, vector<bool>(m, false));
return dfs(grid, visited, 0, 0, n, m);
}
};
int main()
{
std::cout << "Hello World!\n";
}
| [
"whosxavierwu@gmail.com"
] | whosxavierwu@gmail.com |
e465fa831296e9e0e85669e4701d9fdee00bdbea | bfb309eb37957370f1f386e7636db34190f03cc5 | /struct1.cpp | 35b107579d3a9a21682be6955abd3083b7f765ea | [] | no_license | Elmo524/C- | 0c7b88ad5a6f60f131a8beba8f5971ab7b8a6967 | 46363e79e994fa3945d9d6a5fbc2ca7a2772b952 | refs/heads/master | 2018-07-09T02:35:13.852614 | 2018-06-01T03:58:48 | 2018-06-01T03:58:48 | 124,491,235 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 643 | cpp | #include <iostream>
using namespace std;
struct PointXY
{
//fields x and y, alsoo known as member variables
double x; // could also do: double x, y;
double y;
};
PointXY getXY_FromKeyboard()
{
PointXY temp;
cout << "Enter a value for X: ";
cin >> temp.x;
cout << "Enter a value for Y: ";
cin >> temp.y;
return temp;
}
int main()
{
PointXY p1;
PointXY p2;
cout << " P1: "<< endl;
p1 = getXY_FromKeyboard();
cout << "P2: " << endl;
p2 = getXY_FromKeyboard();
double slope = ( p2.y - p1.y) / ( p2.x - p1.x );
cout << "Slope of the line is: " << slope << endl;
return 0;
}
| [
"noreply@github.com"
] | noreply@github.com |
07b9d054dc17c012d80742bd18c2deccb26eb38e | dd80a584130ef1a0333429ba76c1cee0eb40df73 | /art/runtime/gc/collector/garbage_collector.h | 0f566c954bee91cb2fea163019bd006032d21d34 | [
"MIT",
"Apache-2.0"
] | permissive | karunmatharu/Android-4.4-Pay-by-Data | 466f4e169ede13c5835424c78e8c30ce58f885c1 | fcb778e92d4aad525ef7a995660580f948d40bc9 | refs/heads/master | 2021-03-24T13:33:01.721868 | 2017-02-18T17:48:49 | 2017-02-18T17:48:49 | 81,847,777 | 0 | 2 | MIT | 2020-03-09T00:02:12 | 2017-02-13T16:47:00 | null | UTF-8 | C++ | false | false | 3,112 | h | /*
* Copyright (C) 2012 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ART_RUNTIME_GC_COLLECTOR_GARBAGE_COLLECTOR_H_
#define ART_RUNTIME_GC_COLLECTOR_GARBAGE_COLLECTOR_H_
#include "gc_type.h"
#include "locks.h"
#include "base/timing_logger.h"
#include <stdint.h>
#include <vector>
namespace art {
namespace gc {
class Heap;
namespace collector {
class GarbageCollector {
public:
// Returns true iff the garbage collector is concurrent.
virtual bool IsConcurrent() const = 0;
GarbageCollector(Heap* heap, const std::string& name);
virtual ~GarbageCollector() { }
const char* GetName() const {
return name_.c_str();
}
virtual GcType GetGcType() const = 0;
// Run the garbage collector.
void Run();
Heap* GetHeap() const {
return heap_;
}
// Returns how long the mutators were paused in nanoseconds.
const std::vector<uint64_t>& GetPauseTimes() const {
return pause_times_;
}
// Returns how long the GC took to complete in nanoseconds.
uint64_t GetDurationNs() const {
return duration_ns_;
}
void RegisterPause(uint64_t nano_length);
base::TimingLogger& GetTimings() {
return timings_;
}
CumulativeLogger& GetCumulativeTimings() {
return cumulative_timings_;
}
void ResetCumulativeStatistics();
// Swap the live and mark bitmaps of spaces that are active for the collector. For partial GC,
// this is the allocation space, for full GC then we swap the zygote bitmaps too.
void SwapBitmaps() EXCLUSIVE_LOCKS_REQUIRED(Locks::heap_bitmap_lock_);
protected:
// The initial phase. Done without mutators paused.
virtual void InitializePhase() = 0;
// Mark all reachable objects, done concurrently.
virtual void MarkingPhase() = 0;
// Only called for concurrent GCs. Gets called repeatedly until it succeeds.
virtual bool HandleDirtyObjectsPhase() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
// Called with mutators running.
virtual void ReclaimPhase() = 0;
// Called after the GC is finished. Done without mutators paused.
virtual void FinishPhase() = 0;
Heap* const heap_;
std::string name_;
const bool verbose_;
uint64_t duration_ns_;
base::TimingLogger timings_;
// Cumulative statistics.
uint64_t total_time_ns_;
uint64_t total_paused_time_ns_;
uint64_t total_freed_objects_;
uint64_t total_freed_bytes_;
CumulativeLogger cumulative_timings_;
std::vector<uint64_t> pause_times_;
};
} // namespace collector
} // namespace gc
} // namespace art
#endif // ART_RUNTIME_GC_COLLECTOR_GARBAGE_COLLECTOR_H_
| [
"karun.matharu@gmail.com"
] | karun.matharu@gmail.com |
466890f87454d85d2ae8ff32ad07262ecaff39ef | 145caa22a58e0cb156daa2834fbf945c3597fba1 | /Release_3 -versio݁n moodle/ConsoleApplication/Snake.h | 7bd28e36fecbed9768a78ffa7e1c6b3a7ecddb86 | [] | no_license | LouGPombo/Snake19 | aef16d1fbfe0409625273dfd69de631725d00688 | 3ead666df5e543154214f657e5b060d377f56162 | refs/heads/master | 2020-05-23T07:50:33.626702 | 2017-02-27T10:22:16 | 2017-02-27T10:22:16 | 80,451,557 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,437 | h | #pragma once
#include "Cell.h"
#include "GameConstants.h"
#include <time.h>
#include <vector>
class Snake
{
private:
int _lives;
Cell _snake; //Anteriormente utilizamos unos sprites distintos, por eso creamos dos cell para mantener sprites distintos en la cabeza y la cola
Cell _bodySprite;
//Cell _tail;
int _snakeSize;
int _headXPos;
int _headYPos;
//int _tailXPos;
//int _tailYPos;
int _direction;
float _snakeSpeed;
public:
int n;
int _body[MAX_COLUMN*MAX_ROW][2];
clock_t beginT = clock()*CLK_TCK;
//tiempo que transcurre entre movimiento y movimiento (puesto en 0.5segs y cada manzana disminuye ese tiempo en 0.01)
//std::vector<Snake> cuerpo;
//struct Seguir {
// Cell _body = 0;
// int x=0;
// int y=0;
//};
//std::vector<Seguir> cuerpo;
//Seguir tmpsnake;
Snake();
Snake(Cell _body, int headXPos, int headYPos, int direction);
~Snake();
//void saveLastPosition();
void setArrayPosition(int x,int y);
void setSprite();
void setLive(int l);
//void setTailXPosition(int x);
//void setTailYPosition(int y);
void setXPosition(int x);
void setYPosition(int y);
void setDirection(int d);
void setSize(int s);
void changeSpeed(float s);
//int getLastX();
//int getLastY();
int getLive();
int getSize();
int getDirection();
int getSnakeSprite();
int getXPosition();
int getYPosition();
float getSpeed();
};
| [
"queiroga.pombo@gmail.com"
] | queiroga.pombo@gmail.com |
0bc3dd682be13b7e11022f27c55e31535ab3265d | 59c8b48d14ee6a3a57f81559dad07df116283b8d | /table/table_view_hand.cpp | a79df7bf1f18ecee7ca2ad8bedc5f5ae8ca4a519 | [
"MIT"
] | permissive | rolevax/libsaki | 63a6f5d268e0ddef0ee61e993b29305a5df403a2 | 399ea22c45fe033b011b511c65610f9405fee709 | refs/heads/develop | 2021-06-02T10:12:51.409894 | 2020-09-28T07:19:32 | 2020-09-28T07:19:32 | 84,523,709 | 8 | 18 | MIT | 2018-12-31T03:02:00 | 2017-03-10T05:43:32 | C++ | UTF-8 | C++ | false | false | 430 | cpp | #include "table_view_hand.h"
namespace saki
{
TableViewHand::TableViewHand(const Table &table, const Hand &hand, Who self)
: TableViewReal(table, self)
, mHand(hand)
{
Choices::ModeDrawn mode;
mode.swapOut = true;
mChoices.setDrawn(mode);
}
const Choices &TableViewHand::myChoices() const
{
return mChoices;
}
const Hand &TableViewHand::myHand() const
{
return mHand;
}
} // namespace saki
| [
"rolevax@gmail.com"
] | rolevax@gmail.com |
9d34b448d244b6aed0131ed45326d88aeab7ecf7 | dd1385ee93b0135f53c705f9d89f7936390a8fd8 | /src/delegate/delegate.h | ac34fdfaffaf4dd710bcc8bd990d098b52c79c15 | [] | no_license | catompiler/celestial-battle | fcceff6d1551398bda97a62930295986d1217281 | 1998c50867317d71326caec54ecbc47749f71445 | refs/heads/master | 2016-09-05T09:51:32.493447 | 2015-05-09T16:47:44 | 2015-05-09T16:47:44 | 35,336,270 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,952 | h | #ifndef _DELEGATE_H
#define _DELEGATE_H
#include <utility>
#include <functional>
#include <stddef.h>
//#if defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L
template <typename Ret, typename... Args>
class Delegate
:public std::function<Ret(Args...)>
{
public:
Delegate();
template<typename Obj>
Delegate(Obj* obj_, Ret (Obj::*func_)(Args...));
operator bool() const;
bool operator==(const Delegate<Ret, Args...>& d_) const;
template <typename Obj>
bool compareObject(const Obj* obj_) const;
template <typename Obj>
bool compare(const Obj* obj_, Ret (Obj::*func_)(Args...)) const;
Delegate<Ret, Args...>& operator=(const Delegate<Ret, Args...>& d_);
//Ret operator()(Args&&... args_);
Ret operator()(Args... args_);
private:
struct obj_t{};
typedef Ret (obj_t::*func_t)(Args...);
obj_t* _obj;
func_t _func;
};
template <typename Ret, typename... Args>
Delegate<Ret, Args...>::Delegate()
{
_obj = nullptr;
_func = nullptr;
}
template <typename Ret, typename... Args>
template <typename Obj>
Delegate<Ret, Args...>::Delegate(Obj* obj_, Ret (Obj::*func_)(Args...))
{
_obj = reinterpret_cast<obj_t*>(obj_);
_func = reinterpret_cast<func_t>(func_);
}
template <typename Ret, typename... Args>
Delegate<Ret, Args...>::operator bool() const
{
return _obj != nullptr && _func != nullptr;
}
template <typename Ret, typename... Args>
bool Delegate<Ret, Args...>::operator==(const Delegate<Ret, Args...>& d_) const
{
return _obj == d_._obj && _func == d_._func;
}
template <typename Ret, typename... Args>
template <typename Obj>
bool Delegate<Ret, Args...>::compareObject(const Obj* obj_) const
{
return _obj == reinterpret_cast<const obj_t*>(obj_);
}
template <typename Ret, typename... Args>
template <typename Obj>
bool Delegate<Ret, Args...>::compare(const Obj* obj_, Ret (Obj::*func_)(Args...)) const
{
return _obj == reinterpret_cast<const obj_t*>(obj_) &&
_func == reinterpret_cast<func_t>(func_);
}
template <typename Ret, typename... Args>
Delegate<Ret, Args...>& Delegate<Ret, Args...>::operator=(const Delegate<Ret, Args...>& d_)
{
_obj = d_._obj;
_func = d_._func;
return *this;
}
/*template <typename Ret, typename... Args>
Ret Delegate<Ret, Args...>::operator()(Args&&... args_)
{
return (_obj->*_func)(std::forward<Args>(args_)...);
}*/
template <typename Ret, typename... Args>
Ret Delegate<Ret, Args...>::operator()(Args... args_)
{
return (_obj->*_func)(args_...);
}
template <typename Ret, typename Arg>
using UnaryDelegate = Delegate<Ret, Arg>;
template <typename Ret, typename Arg0, typename Arg1>
using BinaryDelegate = Delegate<Ret, Arg0, Arg1>;
template <typename Obj, typename Ret, typename... Args>
Delegate<Ret, Args...> make_delegate(Obj* obj_, Ret (Obj::*func_)(Args...))
{
return Delegate<Ret, Args...>(obj_, func_);
}
#endif //_DELEGATE_H
| [
"artem.lab@localhost"
] | artem.lab@localhost |
35d10c58b29d98f63198f5825c2f4685cea3159b | fd959af9e88ea105c9ea63f9c71f1af48fff5cc7 | /src/ParseManager.cpp | 4e8d61bb7620816d41c2eb9d56acb3c2775da190 | [] | no_license | dianaRusak/interpreterJS | d07dd36a87561719b9376b7390c87340efd602a2 | 8c0867182e06cf14db8c922a2204a746e14496d9 | refs/heads/master | 2022-11-05T10:51:31.957267 | 2020-06-26T09:50:04 | 2020-06-26T09:50:04 | 249,892,921 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,373 | cpp | #include <iostream>
#include "gen/JavaScriptLexer.h"
#include "gen/JavaScriptParser.h"
#include "antlr4-runtime.h"
#include "string"
#include "Visitor.h"
#include "ParseManager.h"
#include <fstream>
using namespace antlr4;
std::string ParseManager::Parse() {
std::ifstream fin(this->inPath);
std::string buf((std::istreambuf_iterator<char>(fin)), std::istreambuf_iterator<char>());
ANTLRInputStream input(buf);
JavaScriptLexer lexer(&input);
CommonTokenStream tokens(&lexer);
JavaScriptParser parser(&tokens);
try {
tokens.fill();
Visitor visitor;
tree::ParseTree *tree = parser.program();
visitor.visit(tree);
auto result = visitor.getTreeString().str();
// auto result = tree->toStringTree(&parser, true);
if (!outPath.empty()) {
std::ofstream fout(this->outPath);
fout << result;
}
return result;
}catch(LexerNoViableAltException &lexerNoViableAltException) {
std::cout << "Error" << &lexerNoViableAltException;
return "";
}catch (ParseCancellationException &parseCancellationException){
std::cout << "Error" << &parseCancellationException;
return "";
}
}
ParseManager::ParseManager(const std::string &input, const std::string &output) {
this->inPath = input;
this->outPath = output;
}
| [
"dianka23@inbox.ru"
] | dianka23@inbox.ru |
cf7aec49abde2d565f21e2dc0e3a315cdf668bd9 | d6258ae3c0fd9f36efdd859a2c93ab489da2aa9b | /fulldocset/add/codesnippet/CPP/m-system.diagnostics.sta_7_1.cpp | a4533be9284ced9a053a24a332a974df08bc9966 | [
"CC-BY-4.0",
"MIT"
] | permissive | OpenLocalizationTestOrg/ECMA2YamlTestRepo2 | ca4d3821767bba558336b2ef2d2a40aa100d67f6 | 9a577bbd8ead778fd4723fbdbce691e69b3b14d4 | refs/heads/master | 2020-05-26T22:12:47.034527 | 2017-03-07T07:07:15 | 2017-03-07T07:07:15 | 82,508,764 | 1 | 0 | null | 2017-02-28T02:14:26 | 2017-02-20T02:36:59 | Visual Basic | UTF-8 | C++ | false | false | 700 | cpp | // Display the stack frame properties.
StackFrame^ sf = st->GetFrame( i );
Console::WriteLine( " File: {0}", sf->GetFileName() );
Console::WriteLine( " Line Number: {0}", sf->GetFileLineNumber().ToString() );
// Note that the column number defaults to zero
// when not initialized.
Console::WriteLine( " Column Number: {0}", sf->GetFileColumnNumber().ToString() );
Console::WriteLine( " Intermediate Language Offset: {0}", sf->GetILOffset().ToString() );
Console::WriteLine( " Native Offset: {0}", sf->GetNativeOffset().ToString() );
| [
"tianzh@microsoft.com"
] | tianzh@microsoft.com |
78b44ef9b11c44cf3b3de53288a0535370793b41 | 1d928c3f90d4a0a9a3919a804597aa0a4aab19a3 | /c++/ClickHouse/2016/4/InterpreterDescribeQuery.h | c6f782ab62fe9c46b1a4159cfbbd0ad6ae5f5420 | [] | no_license | rosoareslv/SED99 | d8b2ff5811e7f0ffc59be066a5a0349a92cbb845 | a062c118f12b93172e31e8ca115ce3f871b64461 | refs/heads/main | 2023-02-22T21:59:02.703005 | 2021-01-28T19:40:51 | 2021-01-28T19:40:51 | 306,497,459 | 1 | 1 | null | 2020-11-24T20:56:18 | 2020-10-23T01:18:07 | null | UTF-8 | C++ | false | false | 2,828 | h | #pragma once
#include <DB/Storages/IStorage.h>
#include <DB/Parsers/TablePropertiesQueriesASTs.h>
#include <DB/Interpreters/Context.h>
#include <DB/Interpreters/IInterpreter.h>
#include <DB/DataStreams/OneBlockInputStream.h>
#include <DB/DataStreams/BlockIO.h>
#include <DB/DataStreams/copyData.h>
#include <DB/DataTypes/DataTypesNumberFixed.h>
#include <DB/DataTypes/DataTypeString.h>
#include <DB/Columns/ColumnString.h>
#include <DB/Parsers/formatAST.h>
namespace DB
{
/** Вернуть названия и типы столбцов указанной таблицы.
*/
class InterpreterDescribeQuery : public IInterpreter
{
public:
InterpreterDescribeQuery(ASTPtr query_ptr_, const Context & context_)
: query_ptr(query_ptr_), context(context_) {}
BlockIO execute() override
{
BlockIO res;
res.in = executeImpl();
res.in_sample = getSampleBlock();
return res;
}
private:
ASTPtr query_ptr;
Context context;
Block getSampleBlock()
{
Block block;
ColumnWithTypeAndName col;
col.name = "name";
col.type = new DataTypeString;
col.column = col.type->createColumn();
block.insert(col);
col.name = "type";
block.insert(col);
col.name = "default_type";
block.insert(col);
col.name = "default_expression";
block.insert(col);
return block;
}
BlockInputStreamPtr executeImpl()
{
const ASTDescribeQuery & ast = typeid_cast<const ASTDescribeQuery &>(*query_ptr);
NamesAndTypesList columns;
ColumnDefaults column_defaults;
{
StoragePtr table = context.getTable(ast.database, ast.table);
auto table_lock = table->lockStructure(false);
columns = table->getColumnsList();
columns.insert(std::end(columns), std::begin(table->alias_columns), std::end(table->alias_columns));
column_defaults = table->column_defaults;
}
ColumnWithTypeAndName name_column{new ColumnString, new DataTypeString, "name"};
ColumnWithTypeAndName type_column{new ColumnString, new DataTypeString, "type" };
ColumnWithTypeAndName default_type_column{new ColumnString, new DataTypeString, "default_type" };
ColumnWithTypeAndName default_expression_column{new ColumnString, new DataTypeString, "default_expression" };;
for (const auto column : columns)
{
name_column.column->insert(column.name);
type_column.column->insert(column.type->getName());
const auto it = column_defaults.find(column.name);
if (it == std::end(column_defaults))
{
default_type_column.column->insertDefault();
default_expression_column.column->insertDefault();
}
else
{
default_type_column.column->insert(toString(it->second.type));
default_expression_column.column->insert(queryToString(it->second.expression));
}
}
return new OneBlockInputStream{
{name_column, type_column, default_type_column, default_expression_column}
};
}
};
}
| [
"rodrigosoaresilva@gmail.com"
] | rodrigosoaresilva@gmail.com |
7a9ac86c6aac8d34ceed16f1aee72ed09e2884ec | 2a28269fc852b8f21d6cb5a9816bf32b2a9a72ed | /Minimum_product.cpp | fc21df97d77908b7dcaea5ce47f9cc4ffb6c00b8 | [] | no_license | raghav2805/Codeforces | 0d717f82401798017ef19e48093c286b58d1f641 | e8a63bd763d903c34d2cd0fcc3121d62bb5bd99e | refs/heads/master | 2023-07-10T09:26:56.409203 | 2021-08-26T12:54:43 | 2021-08-26T12:54:43 | 291,687,316 | 1 | 3 | null | 2020-10-01T08:31:58 | 2020-08-31T10:41:02 | C++ | UTF-8 | C++ | false | false | 546 | cpp |
#include<bits/stdc++.h>
using namespace std;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t;
cin>>t;
while(t--){
long long a,b,x,y,n,ans=1e18;
cin>>a>>b>>x>>y>>n;
for(int i=0;i<2;i++){
long long da=min(n,a-x);
long long db=min(n-da,b-y);
ans=min(ans,(a-da)*(b-db)*1LL );
swap(a,b);
swap(x,y);
}
cout<<ans<<endl;
}
//return removed
}
| [
"noreply@github.com"
] | noreply@github.com |
8f3cc5898c76d6a3437ae53009767d97bac190a3 | e41e78cc4b8d010ebdc38bc50328e7bba2d5a3fd | /SDK/Mordhau_BP_Rapier_FineBlade_classes.hpp | 09631ce9431b632b7324797d455919c628c9fea2 | [] | no_license | Mentos-/Mordhau_SDK | a5e4119d60988dca9063e75e2563d1169a2924b8 | aacf020e6d4823a76787177eac2f8f633f558ec2 | refs/heads/master | 2020-12-13T10:36:47.589320 | 2020-01-03T18:06:38 | 2020-01-03T18:06:38 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,081 | hpp | #pragma once
// Mordhau (Dumped by Hinnie) SDK
#ifdef _MSC_VER
#pragma pack(push, 0x8)
#endif
namespace SDK
{
//---------------------------------------------------------------------------
//Classes
//---------------------------------------------------------------------------
// BlueprintGeneratedClass BP_Rapier_FineBlade.BP_Rapier_FineBlade_C
// 0x0008 (0x0080 - 0x0078)
class UBP_Rapier_FineBlade_C : public UBP_MordhauEquipmentPart_C
{
public:
struct FPointerToUberGraphFrame UberGraphFrame; // 0x0078(0x0008) (Transient, DuplicateTransient)
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("BlueprintGeneratedClass BP_Rapier_FineBlade.BP_Rapier_FineBlade_C");
return ptr;
}
void UserConstructionScript();
void ReceiveBeginPlay();
void ReceiveActorBeginOverlap(class AActor* OtherActor);
void ReceiveTick(float DeltaSeconds);
void ExecuteUbergraph_BP_Rapier_FineBlade(int EntryPoint);
};
}
#ifdef _MSC_VER
#pragma pack(pop)
#endif
| [
"hsibma02@gmail.com"
] | hsibma02@gmail.com |
4fefdc31ccce3354055e8e2d68ac4d2ebeefe490 | 339ba3ab82e03576638779e7240812c3eccff894 | /neo/Source/SceneNode.cpp | bae0e70d8608782298f4c9d3dfd2b665c33504e0 | [] | no_license | Philosjay/OpenGL | 070b44f44f83fc9f309cd005b2296c816e523631 | 31984ad2e383cd9900a8c3190d14857d5fc8f362 | refs/heads/master | 2021-05-08T05:19:56.166787 | 2017-12-05T07:23:03 | 2017-12-05T07:23:03 | 108,499,458 | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 3,838 | cpp | #include "../Include/SceneNode.h"
#include <iostream>
SceneNode::SceneNode() :
next(NULL),
isLineVisible(false),
isTextureEnable(false),
isFilled(false),
defaultCenter(true)
{
}
void SceneNode::setSize(float x, float y)
{
}
void SceneNode::moveTo(int x, int y)
{
startPosX = x;
startPosY = y;
}
void SceneNode::move(int x, int y)
{
startPosX += x;
startPosY += y;
endPosX += x;
endPosY += y;
}
void SceneNode::setEndPos(int x, int y)
{
endPosX = x;
endPosY = y;
}
inline void SceneNode::setLineWidth(int width)
{
mLineWidth = width;
}
void SceneNode::applyColor()
{ //设置颜色
glColor3f(mColor.r, mColor.g, mColor.b);
}
void SceneNode::applyLineWidth()
{
glLineWidth(mLineWidth * 2);
}
void SceneNode::setLineVisible(bool is)
{
this->isLineVisible = is;
}
void SceneNode::setCenterPos(int x, int y)
{
centerX = x;
centerY = y;
defaultCenter = false;
}
void SceneNode::setStartPos(int x, int y)
{
startPosX = x;
startPosY = y;
}
Point SceneNode::getCenterPos()
{
Point tmp;
tmp.x = centerX;
tmp.y = centerY;
return tmp;
}
Point SceneNode::getStartPos()
{
Point tmp;
tmp.x = startPosX;
tmp.y = startPosY;
return tmp;
}
Point SceneNode::getEndPos()
{
Point tmp;
tmp.x = endPosX;
tmp.y = endPosY;
return tmp;
}
Color SceneNode::getColor()
{
return mColor;
}
bool SceneNode::getFillStatus()
{
return isFilled;
}
int SceneNode::getLineWidth()
{
return mLineWidth;
}
void SceneNode::draw()
{
//do nothing by default
}
void SceneNode::loadTexture(char *file)
{
GLint width, height, total_bytes;
GLubyte* pixels = 0;
GLuint last_texture_ID, texture_ID = 0;
//打开文件,如果失败,返回
FILE* pFile;
fopen_s(&pFile, file, "rb");
if (pFile == 0)
{
printf("Can not open file %s...", file);
return;
}
//读取文件中图象的宽度和高度
fseek(pFile, 0x0012, SEEK_SET);
fread(&width, 4, 1, pFile);
fread(&height, 4, 1, pFile);
fseek(pFile, BMP_Header_Length, SEEK_SET);
//计算每行像素所占字节数,并根据此数据计算总像素字节数
{
GLint line_bytes = width * 3;
while (line_bytes % 4 != 0)
{
++line_bytes;
}
total_bytes = line_bytes * height;
}
//根据总像素字节数分配内存
pixels = (GLubyte*)malloc(total_bytes);
if (pixels == 0)
{
printf("Pixeles in file %s is NULL...", file);
fclose(pFile);
return;
}
//读取像素数据
if (fread(pixels, total_bytes, 1, pFile) <= 0)
{
free(pixels);
fclose(pFile);
return;
}
// 分配一个新的纹理编号
glGenTextures(1, &texture_ID);
if (texture_ID == 0)
{
free(pixels);
fclose(pFile);
return;
}
// 绑定新的纹理,载入纹理并设置纹理参数
// 在绑定前,先获得原来绑定的纹理编号,以便在最后进行恢复
glGetIntegerv(GL_TEXTURE_BINDING_2D, (GLint*)&last_texture_ID);
glBindTexture(GL_TEXTURE_2D, texture_ID);
//纹理过滤设定
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);
//颜色混合模式
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_BGR_EXT, GL_UNSIGNED_BYTE, pixels);
glBindTexture(GL_TEXTURE_2D, last_texture_ID);
// 之前为pixels分配的内存可在使用glTexImage2D以后释放
// 因为此时像素数据已经被OpenGL另行保存了一份(可能被保存到专门的图形硬件中)
free(pixels);
isTextureEnable = true;
texture = texture_ID;
}
void SceneNode::setFill(bool isFill)
{
isFilled = isFill;
}
bool SceneNode::isDefaultCenter()
{
return defaultCenter;
}
void SceneNode::setColor(float r, float g, float b)
{
mColor.r = r;
mColor.g = g;
mColor.b = b;
}
| [
"305546044@qq.com"
] | 305546044@qq.com |
320f7fc9de3830141a6a77776a4242cd63471cc7 | 96c56ebeb52898f7a16275244662a0c5e460fbd4 | /FoofLevelEditor (C++)/FoofLevelEditor/Renderer.cpp | b5ec20ef97a1c15856fc9e77922038190a4716b0 | [] | no_license | JIoffe/Flame-Broiled-Fury-BETA | 2bcd25caaa8e6985fd22eb4c42a7a297b89318a1 | 0c4582a221f30a6d74f346a03c6c56a40753969d | refs/heads/master | 2021-01-02T08:19:39.667221 | 2014-08-12T17:34:01 | 2014-08-12T17:34:01 | 22,886,301 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 20,782 | cpp | #include "Renderer.h"
#include "GDIImageLoader.h"
#include "PropStruct.h"
#include "Globals.h"
#include "StaticDeco.h"
const float FullTexUV[] = {
0.0f, 0.0f,
0.0f, 1.0f,
1.0f, 1.0f,
1.0f, 0.0f,
};
const float CollectibleWidths[] = { 0, 0.082f,0.095f,0.095f, 0.08f, 0.08f, 0.08f, 0.08f, 0.1f, 0.082f};
Renderer::Renderer(void)
{
hDC = NULL;
hRC = NULL;
pGridLinesVB = NULL;
GridPoints = 0;
SmallPoints = 0;
MediumPoints = 0;
pSmallSpotGridVB = NULL;
pMediumSpotGridVB = NULL;
}
Renderer::~Renderer(void)
{
}
bool Renderer::Initialize(const HWND hwnd, int w, int h){
GDIImageLoader::Initialize();
if(!(hDC = GetDC(hwnd))){
return false;
}
PIXELFORMATDESCRIPTOR pfd;
WORD uSize = sizeof(PIXELFORMATDESCRIPTOR);
ZeroMemory(&pfd, uSize);
pfd.nSize = uSize;
pfd.nVersion = 1;
pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
pfd.iPixelType = PFD_TYPE_RGBA;
pfd.iLayerType = PFD_MAIN_PLANE;
pfd.cColorBits = 32;
const int PixelFormat = ChoosePixelFormat(hDC, &pfd);
if(PixelFormat < 1 || !SetPixelFormat(hDC, PixelFormat, &pfd)){
return false;
}
if (!(hRC=wglCreateContext(hDC)) || !wglMakeCurrent(hDC,hRC)){
return false;
}
Width = w;
Height = h;
ResizeFrame(w, h);
PixelWidth = (Ratio * 2) / Width;
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
//Set up some things that are good for a 2D sprite engine...
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST);
glShadeModel(GL_FLAT);
glDisable(GL_DITHER);
glDisable(GL_LIGHTING); // We definitely don't need lighting
glDisable(GL_DEPTH_TEST); // or Z-Buffer in 2D
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_TEXTURE_2D);
SetTexture("lala");
//Use Linear filtering
//Use arrays / VBOs
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
return true;
}
void Renderer::PushColor(float R, float G, float B, float A, GLfloat * pColorBuffer, int RenderCount){
int CBufferIndex = RenderCount * 16;
for(int i = 0; i < 4; i++){
pColorBuffer[CBufferIndex++] = R;
pColorBuffer[CBufferIndex++] = G;
pColorBuffer[CBufferIndex++] = B;
pColorBuffer[CBufferIndex++] = A;
}
return;
}
void Renderer::PushQuadToVertexBuffer(float Left, float Right, float Top, float Bottom, GLfloat * pVertexBuffer, int RenderCount){
int VBufferIndex = RenderCount * 12;
pVertexBuffer[VBufferIndex++] = Left;
pVertexBuffer[VBufferIndex++] = Top;
pVertexBuffer[VBufferIndex++] = 1.0f;
pVertexBuffer[VBufferIndex++] = Left;
pVertexBuffer[VBufferIndex++] = Bottom;
pVertexBuffer[VBufferIndex++] = 1.0f;
pVertexBuffer[VBufferIndex++] = Right;
pVertexBuffer[VBufferIndex++] = Bottom;
pVertexBuffer[VBufferIndex++] = 1.0f;
pVertexBuffer[VBufferIndex++] = Right;
pVertexBuffer[VBufferIndex++] = Top;
pVertexBuffer[VBufferIndex] = 1.0f;
return;
}
void Renderer::Draw(LevelScene * pScene){
const int QuadStride = 12;
const int QuadTexStride = 8;
const int GridWidth = pScene->GetWidth();
const int GridHeight = pScene->GetHeight();
const int Area = GridWidth * GridHeight;
const int nProps = pScene->PropList.size();
//const float DLeft = pScene->CamX - Ratio;
//const int StartX = (DLeft <= 0) ? 0 : (int)((DLeft) / LevelScene::LevelTileOffset);
//const float DRight = CamX + FoofRenderer.ratio; pScene->
//const int EndX = (DRight >= pScene->) ? GridWidth : (int)((DRight) / LevelScene::LevelTileOffset) + 1;
//
//const float DDown = CamY - 1.0f;
//const int StartY = (DDown <= 0) ? 0 : (int)((DDown) / LevelScene::LevelTileOffset);
//const float DUp = CamY + 1.0f;
//const int EndY = (DUp >= LevelGridMeasuredHeight) ? LevelGridHeight : (int)((DUp) / LevelScene::LevelTileOffset) + 1;
glClear(GL_COLOR_BUFFER_BIT);
glLoadIdentity();
glTranslatef(-Globals::CamX , - Globals::CamY, 0.0f);
const int nEnemies = pScene->EnemyList.size();
GLfloat * pVertexBuffer = new GLfloat[(Area + nEnemies) * QuadStride];
float * pTexBuffer = new float[(Area + nEnemies) * QuadTexStride];
int RenderCount = 0;
const int StartX = 0; //pScroller->GetXScrollFraction() * GridWidth;
const int EndX = GridWidth;//StartX + 10;
const int EndY = GridHeight;//(1.0f - pScroller->GetInvScrollYFraction()) * GridHeight + 1;
const int StartY = 0;//EndY - 8;
for(int y = StartY; y < EndY; y++){
const float Top = (y+1) * LevelScene::LevelTileOffset;
const float Bottom = y * LevelScene::LevelTileOffset;
for(int x = StartX; x < EndX; x++){
const int TileValue = pScene->GetGridUnit(x,y);
if(TileValue > -1){
const int SpriteID = Globals::TileSet[TileValue].SpriteID;
// ORDER - TOP LEFT, BOTTOM LEFT, BOTTOM RIGHT, TOP RIGHT
const float Left = x * LevelScene::LevelTileOffset;
const float Right = (x+1) * LevelScene::LevelTileOffset;
PushQuadToVertexBuffer(Left, Right, Top, Bottom, pVertexBuffer, RenderCount);
int TexBufferIndex = RenderCount * QuadTexStride;
if(pTexAtlas){
if(TileValue != 127){
pTexAtlas->PushUVsToBuffer(pTexBuffer, TexBufferIndex, SpriteID);
}else{
const float pUVs[] = {
0.0f, 0.0f,
0.0f, 1.0f,
1.0f, 1.0f,
1.0f, 0.0f,
};
memcpy(pTexBuffer+TexBufferIndex, pUVs, sizeof(float) * 8);
}
}
RenderCount++;
}
}
}
for(std::vector<PropStruct*>::iterator it = pScene->DecoList.begin(); it < pScene->DecoList.end(); it++){
PropStruct * pProp = (*it);
StaticDeco * pDeco = (StaticDeco*)pProp->ExtendedInfo;
const unsigned int PropID = pProp->uType;
const float SpriteWidth = pDeco->fDefaultScale;
const int SpriteID = pDeco->iSpriteID;
const float Left = pProp->x - SpriteWidth;
const float Right = pProp->x + SpriteWidth;
const float Top = pProp->y + SpriteWidth;
const float Bottom = pProp->y - SpriteWidth;
PushQuadToVertexBuffer(Left,Right,Top,Bottom,pVertexBuffer,RenderCount);
pTexAtlas->PushUVsToBuffer(pTexBuffer, RenderCount * QuadTexStride, SpriteID);
RenderCount++;
}
if(nEnemies > 0){
for(std::vector<PropStruct*>::iterator it = pScene->EnemyList.begin(); it < pScene->EnemyList.end(); it++){
PropStruct * pProp = (*it);
const unsigned int PropID = pProp->uType;
ExtendedObject * pDyn = pProp->ExtendedInfo;
if(!(pDyn->SubType == 2 && ((Mover*)pProp)->GetFunctionType() == Mover::Fader && ((Mover*)pProp)->Value < 0)){
float SpriteWidth = pDyn->fDefaultScale;
int SpriteID = pDyn->iSpriteIndex;
if(pDyn->SubType == 9){
SpriteWidth = 0.4f;
SpriteID+= 1;
}
const float Left = pProp->x - SpriteWidth;
const float Right = pProp->x + SpriteWidth;
const float Top = pProp->y + SpriteWidth;
const float Bottom = pProp->y - SpriteWidth;
PushQuadToVertexBuffer(Left,Right,Top,Bottom,pVertexBuffer,RenderCount);
pTexAtlas->PushUVsToBuffer(pTexBuffer, RenderCount * QuadTexStride, SpriteID);
RenderCount++;
}
}
}
for(std::vector<PropStruct*>::iterator it = pScene->HazardList.begin(); it < pScene->HazardList.end(); it++){
PropStruct * pProp = (*it);
HazardousObject * pHaz = (HazardousObject*)pProp->ExtendedInfo;
const unsigned int PropID = pProp->uType;
const float SpriteWidth = pHaz->fDefaultScale;
const int SpriteID = pHaz->SpriteID;
const float Left = pProp->x - SpriteWidth;
const float Right = pProp->x + SpriteWidth;
const float Top = pProp->y + SpriteWidth;
const float Bottom = pProp->y - SpriteWidth;
PushQuadToVertexBuffer(Left,Right,Top,Bottom,pVertexBuffer,RenderCount);
pTexAtlas->PushUVsToBuffer(pTexBuffer, RenderCount * QuadTexStride, SpriteID);
RenderCount++;
}
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, Texture[0]);
glVertexPointer(3, GL_FLOAT, 0, pVertexBuffer);
glTexCoordPointer(2, GL_FLOAT, 0, pTexBuffer);
glDrawArrays(GL_QUADS, 0, RenderCount * 4);
delete[] pVertexBuffer;
delete[] pTexBuffer;
const unsigned long nTotal = nProps + pScene->BunnyList.size() + pScene->TokenList.size();
pVertexBuffer = new GLfloat[(nTotal+2) * QuadStride];
pTexBuffer = new float[(nTotal+2) * QuadTexStride];
GLfloat * pColorBuffer = new GLfloat[(nTotal+2)*16];
RenderCount = 0;
if(nProps > 0){
for(std::vector<PropStruct*>::iterator it = pScene->PropList.begin(); it < pScene->PropList.end(); it++){
PropStruct * pProp = (*it);
const unsigned int PropID = pProp->uType;
float SpriteWidth = 0.0f;
int SpriteIndex = 0;
if(PropID > 0){
if(PropID == 88){
SpriteWidth = 0.20f;
SpriteIndex = Globals::CheckPointIndex;
}else{
SpriteWidth = CollectibleWidths[PropID];
SpriteIndex = Globals::CollectibleID[PropID];
}
}
const float Left = pProp->x - SpriteWidth;
const float Right = pProp->x + SpriteWidth;
const float Top = pProp->y + SpriteWidth;
const float Bottom = pProp->y - SpriteWidth;
PushQuadToVertexBuffer(Left,Right,Top,Bottom,pVertexBuffer,RenderCount);
pGlobalAtlas->PushUVsToBuffer(pTexBuffer, RenderCount * QuadTexStride, SpriteIndex);
PushColor(1.0f, 1.0f, 1.0f, 1.0f, pColorBuffer, RenderCount);
RenderCount++;
}
} // End Props
int Add = 0;
for(std::vector<PropStruct*>::iterator it = pScene->BunnyList.begin(); it < pScene->BunnyList.end(); it++){
PropStruct * pProp = (*it);
const float SpriteWidth = 0.15f;
const float Left = pProp->x - SpriteWidth;
const float Right = pProp->x + SpriteWidth;
const float Top = pProp->y + SpriteWidth;
const float Bottom = pProp->y - SpriteWidth;
PushQuadToVertexBuffer(Left,Right,Top,Bottom,pVertexBuffer,RenderCount);
pGlobalAtlas->PushUVsToBuffer(pTexBuffer, RenderCount * QuadTexStride, Globals::BabyBunnyIndex + Add++);
PushColor(1.0f, 1.0f, 1.0f, 1.0f, pColorBuffer, RenderCount);
RenderCount++;
} //end bunnies
for(std::vector<PropStruct*>::iterator it = pScene->TokenList.begin(); it < pScene->TokenList.end(); it++){
PropStruct * pProp = (*it);
const float SpriteWidth = 0.12f;
const float Left = pProp->x - SpriteWidth;
const float Right = pProp->x + SpriteWidth;
const float Top = pProp->y + SpriteWidth;
const float Bottom = pProp->y - SpriteWidth;
PushQuadToVertexBuffer(Left,Right,Top,Bottom,pVertexBuffer,RenderCount);
pGlobalAtlas->PushUVsToBuffer(pTexBuffer, RenderCount * QuadTexStride, Globals::TokenIndex);
PushColor(1.0f, 1.0f, 1.0f, 1.0f, pColorBuffer, RenderCount);
RenderCount++;
} //end tokens
//Add exit
{
const float ExitScale = 0.3f;
const float PlayerX = pScene->ExitPos_X; //GetPlayerStartX();
const float PlayerY = pScene->ExitPos_Y;
const float Left = PlayerX - ExitScale;
const float Right = PlayerX + ExitScale;
const float Top = PlayerY + ExitScale;
const float Bottom = PlayerY - ExitScale;
PushQuadToVertexBuffer(Left,Right,Top,Bottom,pVertexBuffer,RenderCount);
pGlobalAtlas->PushUVsToBuffer(pTexBuffer, RenderCount * QuadTexStride, Globals::ExitIndex, false);
PushColor(1.0f, 1.0f, 1.0f, 1.0f, pColorBuffer, RenderCount);
RenderCount++;
}
//Add player to top of render queue
{
const float PlayerX = pScene->mPlayer.X; //GetPlayerStartX();
const float PlayerY = pScene->mPlayer.Y;
const float Left = PlayerX - LevelScene::PlayerWidth;
const float Right = PlayerX + LevelScene::PlayerWidth;
const float Top = PlayerY + LevelScene::PlayerWidth;
const float Bottom = PlayerY - LevelScene::PlayerWidth;
PushQuadToVertexBuffer(Left,Right,Top,Bottom,pVertexBuffer,RenderCount);
pGlobalAtlas->PushUVsToBuffer(pTexBuffer, RenderCount * QuadTexStride, pScene->mPlayer.CurrentSprite, pScene->mPlayer.bFlip);
PushColor(1.0f, 1.0f, 1.0f, 1.0f, pColorBuffer, RenderCount);
RenderCount++;
}
glEnable(GL_TEXTURE_2D);
glEnableClientState(GL_COLOR_ARRAY);
glBindTexture(GL_TEXTURE_2D, Texture[1]);
glColorPointer(4, GL_FLOAT, 0, pColorBuffer);
glVertexPointer(3, GL_FLOAT, 0, pVertexBuffer);
glTexCoordPointer(2, GL_FLOAT, 0, pTexBuffer);
glDrawArrays(GL_QUADS, 0, RenderCount * 4);
delete[] pVertexBuffer;
delete[] pTexBuffer;
delete[] pColorBuffer;
//Hover our current prop brush if it exists
if(Globals::pObjectBrush){
pVertexBuffer = new GLfloat[QuadStride];
pTexBuffer = new float[QuadTexStride];
pColorBuffer = new GLfloat[16];
const unsigned int PropID = Globals::pObjectBrush->uType;
if(PropID > 0 && pGlobalAtlas){
float SpriteWidth = 1.0f;
int SpriteID = 0;
TextureAtlasManager * pAtlas = NULL;
if(PropID < 10){
SpriteWidth = CollectibleWidths[PropID];
SpriteID = Globals::CollectibleID[PropID];
pAtlas = pGlobalAtlas;
}else{
const int DynID = 0;
if(Globals::pObjectBrush->ExtendedInfo->Type == 1){
ExtendedObject * pDyn = Globals::pObjectBrush->ExtendedInfo;
SpriteWidth = pDyn->fDefaultScale;
SpriteID = pDyn->iSpriteIndex;
}else if(Globals::pObjectBrush->ExtendedInfo->Type == 2){
HazardousObject * pHaz = (HazardousObject*)Globals::pObjectBrush->ExtendedInfo;
SpriteWidth = pHaz->fDefaultScale;
SpriteID = pHaz->SpriteID;
}else if(Globals::pObjectBrush->ExtendedInfo->Type == 3){
StaticDeco * pDeco = (StaticDeco*)Globals::pObjectBrush->ExtendedInfo;
SpriteWidth = pDeco->fDefaultScale;
SpriteID = pDeco->iSpriteID;
}
glBindTexture(GL_TEXTURE_2D, Texture[0]);
pAtlas = pTexAtlas;
}
const float Left = Globals::pObjectBrush->x - SpriteWidth;
const float Right = Globals::pObjectBrush->x + SpriteWidth;
const float Top = Globals::pObjectBrush->y + SpriteWidth;
const float Bottom = Globals::pObjectBrush->y - SpriteWidth;
PushQuadToVertexBuffer(Left,Right,Top,Bottom,pVertexBuffer,0);
pAtlas->PushUVsToBuffer(pTexBuffer, 0, SpriteID);
PushColor(1.0f, 1.0f, 1.0f, 0.5f, pColorBuffer, 0);
glColorPointer(4, GL_FLOAT, 0, pColorBuffer);
glVertexPointer(3, GL_FLOAT, 0, pVertexBuffer);
glTexCoordPointer(2, GL_FLOAT, 0, pTexBuffer);
glDrawArrays(GL_QUADS, 0, 4);
delete[] pVertexBuffer;
delete[] pTexBuffer;
delete[] pColorBuffer;
}
}
glDisableClientState(GL_COLOR_ARRAY);
//Draw camera icons if they exist
const int nCameras = pScene->CamList.size();
if(nCameras > 0){
glBindTexture(GL_TEXTURE_2D, Texture[2]);
RenderCount = 0;
pVertexBuffer = new GLfloat[nCameras * QuadStride];
pTexBuffer = new float[QuadTexStride * nCameras];
for(std::vector<CamZone*>::iterator it = pScene->CamList.begin(); it < pScene->CamList.end(); it++){
CamZone * pCam = *it;
const float Left = pCam->x - CamZone::Scale;
const float Right = pCam->x + CamZone::Scale;
const float Top = pCam->y + CamZone::Scale;
const float Bottom = pCam->y - CamZone::Scale;
PushQuadToVertexBuffer(Left,Right,Top,Bottom,pVertexBuffer,RenderCount);
memcpy(pTexBuffer + (RenderCount * QuadTexStride), FullTexUV, sizeof(float) * 8);
RenderCount++;
}
glVertexPointer(3, GL_FLOAT, 0, pVertexBuffer);
glTexCoordPointer(2, GL_FLOAT, 0, pTexBuffer);
glDrawArrays(GL_QUADS, 0, RenderCount*4);
delete[] pVertexBuffer;
delete[] pTexBuffer;
}
glDisable(GL_TEXTURE_2D);
//Draw borders around selected objects if they exist
const int nSelectedObjects = Globals::SelectedObjects.size();
if(nSelectedObjects > 0){
RenderCount = 0;
pVertexBuffer = new GLfloat[QuadStride * nSelectedObjects];
for(std::vector<PropStruct*>::iterator it = Globals::SelectedObjects.begin(); it < Globals::SelectedObjects.end(); it++){
const PropStruct * pObject = *it;
const int PropID = pObject->uType;
float SpriteWidth = 0.0f;
if(pObject->uObjectType == PropStruct::Collectible){
SpriteWidth = CollectibleWidths[PropID];
}else if(pObject->uObjectType == PropStruct::CameraZone){
SpriteWidth = CamZone::Scale;
//draw the area
CamZone * pCam = (CamZone*)pObject;
glBegin(GL_QUADS);
glColor4f(0.3f, 1.0f, 0.0f, 0.5f);
glVertex3f(pCam->Left, pCam->Up, 0.0f);
glVertex3f(pCam->Left, pCam->Down, 0.0f);
glVertex3f(pCam->Right, pCam->Down, 0.0f);
glVertex3f(pCam->Right, pCam->Up, 0.0f);
glEnd();
} else if(PropID == PropStruct::Bunny || PropID == PropStruct::Token){
SpriteWidth = 0.10f;
} else{
SpriteWidth = pObject->ExtendedInfo->fDefaultScale;
}
const float Left = pObject->x - SpriteWidth;
const float Right = pObject->x + SpriteWidth;
const float Top = pObject->y + SpriteWidth;
const float Bottom = pObject->y - SpriteWidth;
PushQuadToVertexBuffer(Left,Right,Top,Bottom,pVertexBuffer,RenderCount++);
}
glVertexPointer(3,GL_FLOAT,0,pVertexBuffer);
glColor4f(0.7f, 0.4f, 1.0f, 0.5f);
glDrawArrays(GL_QUADS, 0, RenderCount * 4);
delete[] pVertexBuffer;
}
//Draw Lines
glColor3f(1.0f, 1.0f, 1.0f);
if(Globals::bDrawGrid){
if(pGridLinesVB){
glVertexPointer(3, GL_FLOAT, 0, pGridLinesVB);
glDrawArrays(GL_LINES, 0, GridPoints);
}
if(pMediumSpotGridVB){
glVertexPointer(3, GL_FLOAT, 0, pMediumSpotGridVB);
glDrawArrays(GL_POINTS, 0, MediumPoints);
}
}
SwapBuffers(hDC);
return;
}
void Renderer::ResizeFrame(const GLsizei w, const GLsizei h){
glViewport(0,0, w, h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
Ratio = (float)w/h;
gluOrtho2D(-Ratio, Ratio, -1.0f, 1.0f);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
return;
}
void Renderer::SetTexture(const char * cTexPath){
int Width, Height;
//void * ImageData = GDIImageLoader::LoadImage(L"C:/Users/Malvina/workspace/FoofGame/res/drawable-hdpi/forestlevel.png", &Width, &Height);
void * ImageData = GDIImageLoader::LoadImage(L"C:/Users/Malvina/workspace/FoofGame/res/drawable-hdpi/mechlevel.png", &Width, &Height);
glGenTextures(3, Texture); //Generate room for 1 texture. (We only need one...)
if(ImageData){
glBindTexture(GL_TEXTURE_2D, Texture[0]); //Bind it to the pipeline. Once and for all.
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, 4, Width, Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, ImageData);
delete[] ImageData;
ImageData = NULL;
}
ImageData = GDIImageLoader::LoadImage(L"C:/Users/Malvina/workspace/FoofGame/res/drawable-hdpi/gameglobal.png", &Width, &Height);
if(ImageData){
glBindTexture(GL_TEXTURE_2D, Texture[1]); //Bind it to the pipeline. Once and for all.
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, 4, Width, Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, ImageData);
delete[] ImageData;
}
ImageData = GDIImageLoader::LoadImage(L"./CameraIcon1.png", &Width, &Height);
if(ImageData){
glBindTexture(GL_TEXTURE_2D, Texture[2]);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, 4, Width, Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, ImageData);
delete[] ImageData;
}
return;
}
void Renderer::RebuildGrid(int Width, int Height){
if(pGridLinesVB != NULL){
delete[] pGridLinesVB;
}
GridPoints = (Width * 2 + Height * 2);
pGridLinesVB = new GLfloat[GridPoints * 3];
int Index = 0;
const float MaxY = Height * LevelScene::LevelTileOffset;
const float MaxX = Width * LevelScene::LevelTileOffset;
for(int y = 0; y < Height; y++){
float YCoord = LevelScene::LevelTileOffset * y;
pGridLinesVB[Index++] = 0.0f;
pGridLinesVB[Index++] = YCoord;
pGridLinesVB[Index++] = 0.0f;
pGridLinesVB[Index++] = MaxX;
pGridLinesVB[Index++] = YCoord;
pGridLinesVB[Index++] = 0.0f;
}
for(int x = 0; x < Width; x++){
float XCoord = LevelScene::LevelTileOffset * x;
pGridLinesVB[Index++] = XCoord;
pGridLinesVB[Index++] = 0.0f;
pGridLinesVB[Index++] = 0.0f;
pGridLinesVB[Index++] = XCoord;
pGridLinesVB[Index++] = MaxY;
pGridLinesVB[Index++] = 0.0f;
}
// Make Medium Grid
const float MediumWidth = Width * 2 + 1;
const float MediumHeight = Height * 2 + 1;
MediumPoints = MediumWidth * MediumHeight;
pMediumSpotGridVB = new GLfloat[MediumPoints * 3];
Index = 0;
const float MediumOffset = LevelScene::LevelTileOffset / 2.0f;
for(int x = 0; x < MediumWidth; x++){
const float XCoord = x * MediumOffset;
for(int y = 0; y < MediumHeight; y++){
pMediumSpotGridVB[Index++] = XCoord;
pMediumSpotGridVB[Index++] = y * MediumOffset;
pMediumSpotGridVB[Index++] = 0.0f;
}
}
return;
}
float Renderer::GetRatio(){
return Ratio;
}
void Renderer::AssociateScroller(ScrollingComponent * pNewScroller){
pScroller = pNewScroller;
return;
}
void Renderer::AssociateTextureAtlas(TextureAtlasManager * pNewAtlas){
pTexAtlas = pNewAtlas;
return;
}
void Renderer::AssociateGlobalTextureAtlas(TextureAtlasManager * pNewAtlas){
pGlobalAtlas = pNewAtlas;
return;
}
float Renderer::GetPixelWidth(){
return PixelWidth;
} | [
"jason.ioffe@baruchmail.cuny.edu"
] | jason.ioffe@baruchmail.cuny.edu |
0278d5a84bae678471f1195065c1f5161f3d905c | 4a36849188747a1e3cc4b052eb6bc3a21e3e53bb | /LeetCode/Problems/503. Next Greater Element II/code.cpp | 235d02d1bc7b0bfd658135d7ee1b89196ea4a80a | [] | no_license | koking0/Algorithm | 88f69a26f424d1b60a8440c09dd51c8563a86309 | 2828811ae2f905865b4f391672693375c124c185 | refs/heads/master | 2022-07-06T17:10:07.440930 | 2022-06-24T14:59:40 | 2022-06-24T14:59:40 | 216,952,717 | 35 | 48 | null | 2020-07-21T02:46:26 | 2019-10-23T02:41:09 | Java | UTF-8 | C++ | false | false | 354 | cpp | class Solution {
public:
vector<int> nextGreaterElements(vector<int>& nums) {
stack<int> s;
int n = nums.size();
vector<int> res(n, -1);
for (int i = 0; i < 2 * n; i++) {
while (!s.empty() && nums[s.top()] < nums[i % n]) {
res[s.top()] = nums[i % n];
s.pop();
}
s.push(i % n);
}
return res;
}
};
| [
"alex18812649207@gmail.com"
] | alex18812649207@gmail.com |
5378cf464244a40aab4d13e01b26392bc1afe2c8 | 5a4834083e45a103f155d29dea38afc3cb54a0be | /25mayo/my-tshirt-suitsme.cpp | ee790b3afa4d837ed2b329a9811262d0a0f46626 | [] | no_license | henryzrr/Uva-vjudge-aa | 4fa56e0a7e60198ccfef5cf90acac81f086aa8ec | ae2e6bd1caf4cc095d4b2e9e4b0551034c0bccd6 | refs/heads/master | 2020-04-29T04:16:05.902670 | 2019-06-11T01:40:33 | 2019-06-11T01:40:33 | 175,841,534 | 0 | 0 | null | 2019-06-11T01:40:34 | 2019-03-15T15:03:36 | C++ | UTF-8 | C++ | false | false | 2,421 | cpp | #include<cstdio>
#include<cstring>
#include<unordered_map>
#include<stack>
using namespace std;
int j,cases,personas,poleras,resp,nump,grafo[50][50],i,minim,tam,aux1,aux2,aux,tam1,tam2;
char talla1[5],talla2[5];
unordered_map<string,int>tallas;
unordered_map<int,int> padre;
bool encontrado,camino;
void settallas(){
tallas["XXL"]=2;
tallas["XL"]=3;
tallas["L"]=4;
tallas["M"]=5;
tallas["S"]=6;
tallas["XS"]=7;
}
void iniciargrafo(){
for(i=0;i<50;i++){
for(j=0;j<50;j++){
grafo[i][j]=0;
}
}
aux = 8+personas;
for(i=8;i<aux;i++) grafo[0][i]=1;
for(i=2;i<8;i++) grafo[i][1]=nump;
}
int main(){
scanf("%i",&cases);
settallas();
while(cases--){
scanf("%i %i",&poleras,&personas);
nump = poleras/6;
iniciargrafo();
for(i=0;i<personas;i++){
scanf("%s %s",talla1,talla2);
tam1 = tallas[talla1];
tam2 = tallas[talla2];
grafo[8+i][tam1]=1;
grafo[8+i][tam2]=1;
}
resp=0;
camino=false;
while(!camino){
stack<int>pila;
pila.push(0);
encontrado=false;
minim=50000;
padre.clear();
padre[0]=0;
while(!encontrado && !pila.empty()){
aux1 = pila.top();
pila.pop();
if(aux1!=1){
for(i=0;i<8+personas;i++){
if(grafo[aux1][i]>0 && padre.find(i)==padre.end()){
padre[i]=aux1;
pila.push(i);
minim = minim<grafo[aux1][i]?minim:grafo[aux1][i];
}
}
}else{
encontrado =true;
aux1 = 1;
while(padre[aux1]!=aux1){
aux2 = padre[aux1];
aux = grafo[aux2][aux1]-minim;
grafo[aux2][aux1] = aux;
aux = grafo[aux1][aux2]+minim;
grafo[aux1][aux2] = aux;
aux1 = aux2;
}
resp +=minim;
}
}
if(!encontrado)camino=true;
}
if(resp==personas)puts("YES");
else puts("NO");
}
return 0;
} | [
"henry.zrz@gmail.com"
] | henry.zrz@gmail.com |
43de1ae9b850a405eab6c91a719201ef0bd66200 | 3ccf768d7354a3959c230cf148b82e4ffb3345e5 | /Algorithms/CodeAsylums/Contests/contest-2-Simple Text Editor.cpp | c315af7bfa91fe7957be015c06295f4cdd25b327 | [] | no_license | AdityaRajSingh/CP | f954153d0f212729a12c00c13ac426b6dbf79a65 | 63a45f85a116c1ac6072b2ea82d6c3dc9f2fb910 | refs/heads/master | 2021-06-18T20:37:13.016307 | 2021-04-17T17:30:01 | 2021-04-17T17:30:01 | 204,256,046 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,144 | cpp | #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define endl '\n'
#define rep(i,a,b) for(ll i=a;i<b;i++)
int q,t,k;
string n;
string s="";
string sprev="";
void appen()
{
sprev=s;
s=s+n;
cout<<"after append "<<s.length()<<endl;
}
void del()
{
sprev=s;
s.erase(s.length()-k);
cout<<"after delete "<<s.length()<<endl;
}
void prin()
{
cout<<"print "<<s[k-1]<<endl;
}
void undo()
{
s=sprev;
}
int main()
{
#ifndef ONLINE_JUDGE
freopen("/home/aadi/Documents/input.txt", "r", stdin);
freopen("/home/aadi/Documents/output.txt", "w", stdout);
#endif
fast;
//////////////////////////////////////////////////////////////////////
cin>>q;
while(q--)
{
cin>>t;
if(t==1)
{
cin>>n;
cout<<n<<endl;
appen();
}
if(t==2)
{
cin>>k;
del();
}
if(t==3)
{
cin>>k;
prin();
}
if(t==4)
{
undo();
}
}
//////////////////////////////////////////////////////////////////////
#ifndef ONLINE_JUDGE
cout<<endl<<"Time Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec"<<endl;
#endif
return 0;
} | [
"adi4adityaraj@gmail.com"
] | adi4adityaraj@gmail.com |
05b4665327237053a04d7e2d2ecdb5e6b4f5d0f2 | 40a18005bd3aaa728be29918104b82a2a9761a64 | /src/tokenizer.h | ba4e2a4f971385d7530a4132916f8b0430479d11 | [] | no_license | 8l/consolite-compiler | 164f4bfb256e11725ffa2554a599b5118d2bfc62 | ec33957bbd33b466db7fb739bf4aa86eebec18f7 | refs/heads/master | 2021-01-17T14:03:02.941388 | 2015-10-02T23:21:14 | 2015-10-02T23:21:14 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 790 | h | /**
* Consolite Compiler
* Copyright (c) 2015 Robert Fotino, All Rights Reserved
*/
#ifndef CONSOLITE_COMPILER_TOKENIZER_H
#define CONSOLITE_COMPILER_TOKENIZER_H
#include <string>
#include "syntax.h"
class Tokenizer {
public:
/**
* Opens the given file and mmaps it to an internal pointer for easy
* traversal. Throws an exception on failure.
*/
Tokenizer(char *filename);
~Tokenizer();
/**
* Consumes the next token and returns it.
*/
AtomToken getNext();
/**
* Returns the next token without consuming it. Subsequent calls to
* getNext() or peekNext() will return the same token.
*/
AtomToken peekNext();
private:
int _offset;
int _length;
int _mmapLength;
char *_data;
int _lineNum;
bool _hasNext;
AtomToken _next;
};
#endif
| [
"robert.fotino@gmail.com"
] | robert.fotino@gmail.com |
ab51e051431e163aeabd5b131a2b91df92953071 | 06544873c5823cc8b0efc43b9c617ab5cb951dec | /Prog/Raktarozas/raktarozas.cpp | b57225f8fc4eba89f0bc420efdca86dd222f500f | [] | no_license | adipapp/SZE-Codes | f59dc0f2db4a15c39507bcc7e5d9534dcb439957 | 85ef9c603c16fccad53f8156b57fff328c906654 | refs/heads/master | 2020-04-15T16:32:45.916661 | 2019-12-12T19:18:19 | 2019-12-12T19:18:19 | 164,840,468 | 2 | 2 | null | null | null | null | ISO-8859-2 | C++ | false | false | 2,029 | cpp | #include <iostream>
#include <string>
#include <ctime>
#include <cstdlib>
using namespace std;
struct Termek
{
string nev;
int db;
int ar;
Termek* bal;
Termek* jobb;
};
Termek* binfaKeres(Termek* gyoker, string nev, int db, int& keszletar){
if (gyoker == NULL){
gyoker = new Termek;
gyoker->nev = nev;
gyoker->db = db;
gyoker->ar = 10 + rand() % 99991;
gyoker->bal = gyoker->jobb = NULL;
}
else if (gyoker->nev > nev){
gyoker->bal = binfaKeres(gyoker->bal, nev, db, keszletar);
}
else if (gyoker->nev < nev){
gyoker->jobb = binfaKeres(gyoker->jobb, nev, db, keszletar);
}
else{
gyoker->db += db;
keszletar = gyoker->db*gyoker->ar;
}
return gyoker;
}
void binfaKiir(Termek* gyoker){
if (gyoker != NULL){
binfaKiir(gyoker->bal);
cout << gyoker->nev << '\t' << gyoker->db << '\t' << gyoker->ar << endl;
binfaKiir(gyoker->jobb);
}
}
void binfaKivag(Termek* gyoker){
if (gyoker != NULL){
binfaKivag(gyoker->bal);
binfaKivag(gyoker->jobb);
delete gyoker;
}
}
void main(){
Termek* gyoker = NULL;
string nev;
int db, keszletar = 0;
bool vege = false;
srand(time(NULL));
cout << "Raktarozas nyilvantartas\n--------------------"<<endl;
do
{
cout << "\nAdjon meg egy termeknevet:"<<endl;
getline(cin, nev); // getline tud whitespace-eket is olvasni(és ki is veszi őket a pufferből), de a cin önmagában nem
if (nev != ""){ // ha nem entert(semmit/üres sort) olvasott be a getline
cout << "\nAdja meg a fenti termek darabszamat: "<<endl;
cin >> db; // cin után benntmarad a pufferben a sortörés
cin.ignore(1); // ez kiveszi belőle
gyoker = binfaKeres(gyoker, nev, db, keszletar);
if (keszletar == 0) cout << "A termek nem szerepelt a nyilvantartasban, hozzaadasra kerult." << endl;
else cout << "A termek szerepelt mar a nyilvantartasban, a tarolt keszlet erteke: " << keszletar << " Ft" << endl;
keszletar = 0;
}
else break; //ez tudom hogy csúnya
} while (true); //ez meg még csúnyább :)
binfaKiir(gyoker);
binfaKivag(gyoker);
} | [
"adipapp98@gmail.com"
] | adipapp98@gmail.com |
d3788e161083606a412a5e7a04bfad2c5827577d | 407b47de02072ea986d0812f5190fc7f258c6c1a | /codeforces401Cteam.cpp | 1ff5970bf64046ab8857b3823e5f1f88b1555040 | [] | no_license | sreyansb/Codeforces | c0a472940bafb020c914d45d6b790d5f75513dff | 12baa08a32837dcea0ee8a2bf019f0551e009420 | refs/heads/master | 2023-01-04T11:33:14.749438 | 2020-10-28T08:20:44 | 2020-10-28T08:20:44 | 275,894,673 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 513 | cpp | #include <bits/stdc++.h>
using namespace std;
int main()
{
int z,o;
cin>>z>>o;
if (o<z-1 || o>(2*z+2))
cout<<-1<<"\n";
else
{
if (z-1==o)
{
cout<<0;
for(int i=0;i<o;i++)
cout<<"10";
cout<<"\n";
}
else if (o-1==z)
{
cout<<1;
for(int i=0;i<z;i++)
cout<<"01";
cout<<"\n";
}
else{
while(o>0&&z>0)
{if (o<2*z)
{
cout<<"10";
o--;z--;
}
else
{
cout<<"110";
o-=2;
z--;
}}
for (int i=0;i<o;i++)
cout<<1;
cout<<"\n";
}}
return 0;
}
| [
"sreyansrocks@gmail.com"
] | sreyansrocks@gmail.com |
545e2078ed2c9c74d7353c53f820a41b2e90adc5 | c51d7d38deb97d138781acd345d216d2f6091077 | /LinkedListSort/selectSort.cc | 5a061ee0a3f90709f763d3681de82776c4f9a564 | [] | no_license | lexingsen/Data-Structure | 42e1f68b2aae6de4db0767ccbe5097b9f88739a6 | e850295cb6644e86d9cafd5753ed728350b56b24 | refs/heads/master | 2023-01-09T17:57:30.916528 | 2020-11-12T10:34:36 | 2020-11-12T10:34:36 | 302,799,089 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,023 | cc | /*
* @Description: 单链表选择排序
* @Language: C++
* @Author: lexingsen
* @Date: 2020-10-30 00:51:28
*/
#include <bits/stdc++.h>
using namespace std;
struct ListNode {
int val;
ListNode *next;
};
void selectSort(int *a, int n) {
for (int i=0; i<n; ++i) {
int minIndex=i;
for (int j=i+1; j<n; ++j) {
if (a[j] < a[minIndex]) {
minIndex = j;
}
}
if (i != minIndex) swap(a[i], a[minIndex]);
}
}
class Solution {
public:
ListNode *selectSort(ListNode *head) {
if (!head || !head->next) return head;
ListNode* dummy = new ListNode();
dummy->next = head;
ListNode* p = head;
while (p) {
ListNode* tmp = p;
ListNode* min = p;
while (tmp) {
if (tmp->val < min->val) {
min = tmp;
}
tmp = tmp->next;
}
int t = p->val;
p->val = min->val;
min->val = t;
p = p->next;
}
return dummy->next;
}
};
| [
"1050592374@qq.com"
] | 1050592374@qq.com |
6f78ac50e4751ddfce1972c35f023db4ddb62158 | c7385b3fb56b49e3a67d4df79de198b6f674e905 | /src/Magnum/OpenDdl/Type.h | 1ac374ed3ec0f348bb5ea3d745b341b5ff55de03 | [
"MIT"
] | permissive | Squareys/magnum-plugins | 61bbf2ba01b1d17ce47a4c436b4c0398813eccfc | 2fadb319fc8675347e5f949b24cf39b20ce972f5 | refs/heads/master | 2022-08-20T07:09:52.858498 | 2022-07-20T17:11:02 | 2022-07-20T17:11:02 | 40,075,154 | 1 | 1 | null | 2017-10-31T15:32:08 | 2015-08-02T09:45:26 | C++ | UTF-8 | C++ | false | false | 6,052 | h | #ifndef Magnum_OpenDdl_Type_h
#define Magnum_OpenDdl_Type_h
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019,
2020, 2021, 2022 Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
/** @file
* @brief Enum @ref Magnum::OpenDdl::Type, @ref Magnum::OpenDdl::PropertyType, constant @ref Magnum::OpenDdl::UnknownIdentifier
*/
#include <Magnum/Magnum.h>
#include "Magnum/OpenDdl/visibility.h"
namespace Magnum { namespace OpenDdl {
/**
@brief OpenDDL type
@see @ref Structure::type()
*/
enum class Type: UnsignedInt {
/** Boolean. Stored in @cpp bool @ce type. */
Bool,
/**
* Unsigned byte (8 bit). Stored in @ref Magnum::UnsignedByte "UnsignedByte"
* type.
*/
UnsignedByte,
/** Signed byte (8 bit). Stored in @ref Magnum::Byte "Byte" type. */
Byte,
/**
* Unsigned short (16 bit). Stored in @ref Magnum::UnsignedShort "UnsignedShort"
* type.
*/
UnsignedShort,
/** Signed short (16 bit). Stored in @ref Magnum::Short "Short" type. */
Short,
/**
* Unsigned int (32 bit). Stored in @ref Magnum::UnsignedInt "UnsignedInt"
* type.
*/
UnsignedInt,
/** Signed int (32 bit). Stored in @ref Magnum::Int "Int" type. */
Int,
#ifndef CORRADE_TARGET_EMSCRIPTEN
/**
* Unsigned long (64 bit). Stored in @ref Magnum::UnsignedLong "UnsignedLong"
* type.
* @partialsupport 64-bit integers are not available on
* @ref CORRADE_TARGET_EMSCRIPTEN "Emscripten".
*/
UnsignedLong,
/**
* Long (64 bit). Stored in @ref Magnum::Long "Long" type.
* @partialsupport 64-bit integers are not available on
* @ref CORRADE_TARGET_EMSCRIPTEN "Emscripten".
*/
Long,
#endif
/** @todo Half */
/** Float (32 bit). Stored in @ref Magnum::Float "Float" type. */
Float,
/** Double (64 bit). Stored in @ref Magnum::Double "Double" type. */
Double,
/** UTF-8 string. Stored in @ref std::string type. */
String,
/** ASCII reference string. Stored in @ref std::string type. */
Reference,
/** Type enumeration. Stored in @ref Type type. */
Type,
/** Custom structure type */
Custom
};
/** @debugoperatorenum{Type} */
MAGNUM_OPENDDL_EXPORT Debug& operator<<(Debug& debug, Type value);
/**
@brief Property type
Because of parsing ambiguity, the properties are internally stored only in a
subset of types. The remaining types are just for use in
@ref Property::isTypeCompatibleWith(). See documentation of particular values
for more information.
*/
enum class PropertyType: UnsignedByte {
/** Boolean. Stored in @cpp bool @ce type. */
Bool,
/** Unsigned byte (8 bit). Stored as if it is @ref PropertyType::Int. */
UnsignedByte,
/** Signed byte (8 bit). Stored as if it is @ref PropertyType::Int. */
Byte,
/** Unsigned short (16 bit). Stored as if it is @ref PropertyType::Int. */
UnsignedShort,
/** Signed short (16 bit). Stored as if it is @ref PropertyType::Int. */
Short,
/** Unsigned int (32 bit). Stored as if it is @ref PropertyType::Int. */
UnsignedInt,
/** Signed int (32 bit). Stored in @ref Magnum::Int "Int" type. */
Int,
#ifndef MAGNUM_TARGET_WEBGL
/**
* Unsigned long (64 bit). Stored as if it is @ref PropertyType::Int.
* @requires_gles 64-bit integers are not available in WebGL.
*/
UnsignedLong,
/**
* Long (64 bit). Stored as if it is @ref PropertyType::Int.
* @requires_gles 64-bit integers are not available in WebGL.
*/
Long,
#endif
/** @todo Half */
/** Float (32 bit). Stored in @ref Magnum::Float "Float" type. */
Float,
/** Double (64 bit). Stored as if it is @ref PropertyType::Float. */
Double,
/** UTF-8 string. Stored in @ref std::string type. */
String,
/** ASCII reference string. Stored in @ref std::string type. */
Reference,
/** Type enumeration. Stored in @ref Type type. */
Type
};
/** @debugoperatorenum{PropertyType} */
MAGNUM_OPENDDL_EXPORT Debug& operator<<(Debug& debug, PropertyType value);
enum: Int {
/**
* Identifier which was not in the identifier list passed to
* @ref Document::parse().
* @see @ref Structure::identifier(), @ref Property::identifier()
*/
UnknownIdentifier = INT16_MAX - Int(Type::Custom)
};
namespace Implementation {
enum class InternalPropertyType: UnsignedByte {
Bool = UnsignedByte(PropertyType::Bool),
Integral = UnsignedByte(PropertyType::Int),
Float = UnsignedByte(PropertyType::Float),
String = UnsignedByte(PropertyType::String),
Reference = UnsignedByte(PropertyType::Reference),
Type = UnsignedByte(PropertyType::Type),
Character = 254,
Binary = 255
};
MAGNUM_OPENDDL_EXPORT Debug& operator<<(Debug& debug, InternalPropertyType value);
}
}}
#endif
| [
"mosra@centrum.cz"
] | mosra@centrum.cz |
3f82a852378026514b8adfcc6fe0758ffa012a64 | e68837afb7de1d8e5fbc4411f9e664d671ff29eb | /Source/Prototype1/CannonCrop.cpp | 9af701147c6846cb65cdbf1a0db030e3379f18c2 | [] | no_license | Adrianron/Gruppe1_beelzebubclub | 9bc40b331edfe0b37203943d33a7969beb1cd834 | 1ddfd1a4bc7e5f1211be6325f1bab26a5590e739 | refs/heads/master | 2021-01-21T20:52:51.649270 | 2017-05-24T11:47:05 | 2017-05-24T11:47:05 | 92,285,944 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 686 | cpp | // Fill out your copyright notice in the Description page of Project Settings.
#include "Prototype1.h"
#include "CannonCrop.h"
// Sets default values
ACannonCrop::ACannonCrop()
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
RootBox = CreateDefaultSubobject<UBoxComponent>(TEXT("CannonCrop"));
RootBox->bGenerateOverlapEvents = true;
}
// Called when the game starts or when spawned
void ACannonCrop::BeginPlay()
{
Super::BeginPlay();
}
// Called every frame
void ACannonCrop::Tick( float DeltaTime )
{
Super::Tick( DeltaTime );
}
| [
"noreply@github.com"
] | noreply@github.com |
2321dc98062f10608f165142c75a7b4d659e4c09 | 2a20de46ae2e16e31a5f93b41d97df658343c9ad | /Year-2020/05-May/2020-05-01-21/yuange/yuange21.cpp | fceb782445845559a3fc435263b04f7949838fbf | [
"ICU"
] | permissive | ygtxr1997/CodingEveryday | 9566c79cf110f333973013c1f5f9af94c93d2569 | 34f6641f14c8ab80d17b6cebf27a2769701c7162 | refs/heads/master | 2021-07-09T00:48:25.351284 | 2020-07-31T05:16:18 | 2020-07-31T05:16:18 | 172,870,889 | 13 | 3 | null | null | null | null | UTF-8 | C++ | false | false | 780 | cpp | /**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode(int x) : val(x), next(NULL) {}
* };
*/
class Solution {
public:
ListNode* mergeTwoLists(ListNode* l1, ListNode* l2) {
if (!l1) return l2;
if (!l2) return l1;
ListNode* ret = nullptr, * tail = nullptr;
while (l1 && l2) {
int val;
if (l1->val < l2->val) val = l1->val, l1 = l1->next;
else val = l2->val, l2 = l2->next;
ListNode* cur = new ListNode(val);
if (!ret) ret = cur;
if (!tail) tail = cur;
else tail->next = cur, tail = cur;
}
if (l1) tail->next = l1;
else if (l2) tail->next = l2;
return ret;
}
}; | [
"gavingreenson@icloud.com"
] | gavingreenson@icloud.com |
19a3e60701343b0a1cf443efc6b7ccfe9dca272d | 27c94a0233b271700ccfee628c7f98f7f22982a8 | /圣诞/圣诞/main.cpp | 7101290c7dc0416883969e04120102d7c3c9ead9 | [] | no_license | jacky1193610322/acm-contest-with-my-friends | f487d23987208891354e198a4782c1cbbad23adf | 72d29c0660766d824328c1cde16948fdf3f1a56b | refs/heads/master | 2021-01-19T03:29:26.992233 | 2016-05-27T13:24:25 | 2016-05-27T13:24:25 | 59,833,333 | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 892 | cpp | //这是我送给你们德圣诞节礼物
#include<stdio.h>
#include<Windows.h>
int main()
{
int i, j, x, n = 0;
char a = 32, b = 42, c = 48;
for (x = 0; x<3; x++)
{
for (i = 0; i<x + 3; i++)
{
for (j = 0; j<80; j++)
{
if (j <= 25 + n&&j >= 25 - n)
printf("%c", c);
else if ((j % (n + 6) == n) && (j>25 + n || j<25 - n))
printf("%c", b);
else
printf("%c", a);
}
printf("\n");
n = n + 2;
}
n = n - 2 * (x + 2);
}
for (i = 0; i<5; i++)
{
for (j = 0; j<80; j++)
{
if (j >= 22 && j <= 28)
printf("%c", c);
else if ((j % (n + 6) == n) && (j>25 + n || j<25 - n))
printf("%c", b);
else
printf("%c", a);
}
n = n + 2;
printf("\n");
}
for (i = 0; i<3; i++)
{
for (j = 0; j<80; j++)
{
if (j % 2 == 0)
printf("%c", b);
else
printf("%c", a);
}
printf("\n");
}
system("pause");
return 0;
} | [
"1193610322@qq.com"
] | 1193610322@qq.com |
bd5f9d9267c6429873e6df7c492100fe76fec9b0 | d7b84a31cafb72a3cb71b3a3cc724a68119ba18e | /Kvasir/0.46/uniform/time | 1a889deae4e02bc04a9e1cf52df2bd4e2a0800b8 | [] | no_license | benroque/Ragnorak | 6cc7c68db801f9281a4ac241da754bce88ef6caf | a1bfc2430cccb207192792acebdd1530f1388a4c | refs/heads/master | 2021-01-14T08:13:18.774988 | 2017-02-20T08:32:53 | 2017-02-20T08:32:53 | 82,008,402 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 995 | /*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 4.1 |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "0.46/uniform";
object time;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
value 0.460000000000000353;
name "0.46";
index 230;
deltaT 0.002;
deltaT0 0.002;
// ************************************************************************* //
| [
"benroque94@gmail.com"
] | benroque94@gmail.com | |
30dbaebf96e93a0b2663180b32600db764c6470d | 293a7f11ce665f5e810fd14d775ac1c7d5f33adb | /Source/Samples/07_Billboards/Billboards.cpp | 7c5cec062461e2c03ecf6c60cd6ac96078717c08 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | seanvolt/Urho3D_VR | 56233588d06098837629f59e60f5471cfcb3afce | fda10ce0364c5348a7ee7a4ed20f229235c804c0 | refs/heads/master | 2021-01-20T23:08:46.952421 | 2017-08-30T04:41:57 | 2017-08-30T04:41:57 | 101,838,332 | 4 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 13,455 | cpp | //
// Copyright (c) 2008-2017 the Urho3D project.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
#include <Urho3D/Core/CoreEvents.h>
#include <Urho3D/Engine/Engine.h>
#include <Urho3D/Graphics/BillboardSet.h>
#include <Urho3D/Graphics/Camera.h>
#include <Urho3D/Graphics/DebugRenderer.h>
#include <Urho3D/Graphics/Graphics.h>
#include <Urho3D/Graphics/Light.h>
#include <Urho3D/Graphics/Material.h>
#include <Urho3D/Graphics/Model.h>
#include <Urho3D/Graphics/Octree.h>
#include <Urho3D/Graphics/Renderer.h>
#include <Urho3D/Graphics/StaticModel.h>
#include <Urho3D/Graphics/Zone.h>
#include <Urho3D/Input/Input.h>
#include <Urho3D/Resource/ResourceCache.h>
#include <Urho3D/Scene/Scene.h>
#include <Urho3D/UI/Font.h>
#include <Urho3D/UI/Text.h>
#include <Urho3D/UI/UI.h>
#include "Billboards.h"
#include <Urho3D/DebugNew.h>
URHO3D_DEFINE_APPLICATION_MAIN(Billboards)
Billboards::Billboards(Context* context) :
Sample(context),
drawDebug_(false)
{
}
void Billboards::Start()
{
// Execute base class startup
Sample::Start();
// Create the scene content
CreateScene();
// Create the UI content
CreateInstructions();
// Setup the viewport for displaying the scene
SetupViewport();
// Hook up to the frame update and render post-update events
SubscribeToEvents();
// Set the mouse mode to use in the sample
Sample::InitMouseMode(MM_ABSOLUTE);
}
void Billboards::CreateScene()
{
ResourceCache* cache = GetSubsystem<ResourceCache>();
scene_ = new Scene(context_);
// Create octree, use default volume (-1000, -1000, -1000) to (1000, 1000, 1000)
// Also create a DebugRenderer component so that we can draw debug geometry
scene_->CreateComponent<Octree>();
scene_->CreateComponent<DebugRenderer>();
// Create a Zone component for ambient lighting & fog control
Node* zoneNode = scene_->CreateChild("Zone");
Zone* zone = zoneNode->CreateComponent<Zone>();
zone->SetBoundingBox(BoundingBox(-1000.0f, 1000.0f));
zone->SetAmbientColor(Color(0.1f, 0.1f, 0.1f));
zone->SetFogStart(100.0f);
zone->SetFogEnd(300.0f);
// Create a directional light without shadows
Node* lightNode = scene_->CreateChild("DirectionalLight");
lightNode->SetDirection(Vector3(0.5f, -1.0f, 0.5f));
Light* light = lightNode->CreateComponent<Light>();
light->SetLightType(LIGHT_DIRECTIONAL);
light->SetColor(Color(0.2f, 0.2f, 0.2f));
light->SetSpecularIntensity(1.0f);
// Create a "floor" consisting of several tiles
for (int y = -5; y <= 5; ++y)
{
for (int x = -5; x <= 5; ++x)
{
Node* floorNode = scene_->CreateChild("FloorTile");
floorNode->SetPosition(Vector3(x * 20.5f, -0.5f, y * 20.5f));
floorNode->SetScale(Vector3(20.0f, 1.0f, 20.f));
StaticModel* floorObject = floorNode->CreateComponent<StaticModel>();
floorObject->SetModel(cache->GetResource<Model>("Models/Box.mdl"));
floorObject->SetMaterial(cache->GetResource<Material>("Materials/Stone.xml"));
}
}
// Create groups of mushrooms, which act as shadow casters
const unsigned NUM_MUSHROOMGROUPS = 25;
const unsigned NUM_MUSHROOMS = 25;
for (unsigned i = 0; i < NUM_MUSHROOMGROUPS; ++i)
{
// First create a scene node for the group. The individual mushrooms nodes will be created as children
Node* groupNode = scene_->CreateChild("MushroomGroup");
groupNode->SetPosition(Vector3(Random(190.0f) - 95.0f, 0.0f, Random(190.0f) - 95.0f));
for (unsigned j = 0; j < NUM_MUSHROOMS; ++j)
{
Node* mushroomNode = groupNode->CreateChild("Mushroom");
mushroomNode->SetPosition(Vector3(Random(25.0f) - 12.5f, 0.0f, Random(25.0f) - 12.5f));
mushroomNode->SetRotation(Quaternion(0.0f, Random() * 360.0f, 0.0f));
mushroomNode->SetScale(1.0f + Random() * 4.0f);
StaticModel* mushroomObject = mushroomNode->CreateComponent<StaticModel>();
mushroomObject->SetModel(cache->GetResource<Model>("Models/Mushroom.mdl"));
mushroomObject->SetMaterial(cache->GetResource<Material>("Materials/Mushroom.xml"));
mushroomObject->SetCastShadows(true);
}
}
// Create billboard sets (floating smoke)
const unsigned NUM_BILLBOARDNODES = 25;
const unsigned NUM_BILLBOARDS = 10;
for (unsigned i = 0; i < NUM_BILLBOARDNODES; ++i)
{
Node* smokeNode = scene_->CreateChild("Smoke");
smokeNode->SetPosition(Vector3(Random(200.0f) - 100.0f, Random(20.0f) + 10.0f, Random(200.0f) - 100.0f));
BillboardSet* billboardObject = smokeNode->CreateComponent<BillboardSet>();
billboardObject->SetNumBillboards(NUM_BILLBOARDS);
billboardObject->SetMaterial(cache->GetResource<Material>("Materials/LitSmoke.xml"));
billboardObject->SetSorted(true);
for (unsigned j = 0; j < NUM_BILLBOARDS; ++j)
{
Billboard* bb = billboardObject->GetBillboard(j);
bb->position_ = Vector3(Random(12.0f) - 6.0f, Random(8.0f) - 4.0f, Random(12.0f) - 6.0f);
bb->size_ = Vector2(Random(2.0f) + 3.0f, Random(2.0f) + 3.0f);
bb->rotation_ = Random() * 360.0f;
bb->enabled_ = true;
}
// After modifying the billboards, they need to be "committed" so that the BillboardSet updates its internals
billboardObject->Commit();
}
// Create shadow casting spotlights
const unsigned NUM_LIGHTS = 9;
for (unsigned i = 0; i < NUM_LIGHTS; ++i)
{
Node* lightNode = scene_->CreateChild("SpotLight");
Light* light = lightNode->CreateComponent<Light>();
float angle = 0.0f;
Vector3 position((i % 3) * 60.0f - 60.0f, 45.0f, (i / 3) * 60.0f - 60.0f);
Color color(((i + 1) & 1) * 0.5f + 0.5f, (((i + 1) >> 1) & 1) * 0.5f + 0.5f, (((i + 1) >> 2) & 1) * 0.5f + 0.5f);
lightNode->SetPosition(position);
lightNode->SetDirection(Vector3(Sin(angle), -1.5f, Cos(angle)));
light->SetLightType(LIGHT_SPOT);
light->SetRange(90.0f);
light->SetRampTexture(cache->GetResource<Texture2D>("Textures/RampExtreme.png"));
light->SetFov(45.0f);
light->SetColor(color);
light->SetSpecularIntensity(1.0f);
light->SetCastShadows(true);
light->SetShadowBias(BiasParameters(0.00002f, 0.0f));
// Configure shadow fading for the lights. When they are far away enough, the lights eventually become unshadowed for
// better GPU performance. Note that we could also set the maximum distance for each object to cast shadows
light->SetShadowFadeDistance(100.0f); // Fade start distance
light->SetShadowDistance(125.0f); // Fade end distance, shadows are disabled
// Set half resolution for the shadow maps for increased performance
light->SetShadowResolution(0.5f);
// The spot lights will not have anything near them, so move the near plane of the shadow camera farther
// for better shadow depth resolution
light->SetShadowNearFarRatio(0.01f);
}
// Create the camera. Limit far clip distance to match the fog
cameraNode_ = scene_->CreateChild("Camera");
Camera* camera = cameraNode_->CreateComponent<Camera>();
camera->SetFarClip(300.0f);
// Set an initial position for the camera scene node above the plane
cameraNode_->SetPosition(Vector3(0.0f, 5.0f, 0.0f));
}
void Billboards::CreateInstructions()
{
ResourceCache* cache = GetSubsystem<ResourceCache>();
UI* ui = GetSubsystem<UI>();
// Construct new Text object, set string to display and font to use
Text* instructionText = ui->GetRoot()->CreateChild<Text>();
instructionText->SetText(
"Use WASD keys and mouse/touch to move\n"
"Space to toggle debug geometry"
);
instructionText->SetFont(cache->GetResource<Font>("Fonts/Anonymous Pro.ttf"), 15);
// The text has multiple rows. Center them in relation to each other
instructionText->SetTextAlignment(HA_CENTER);
// Position the text relative to the screen center
instructionText->SetHorizontalAlignment(HA_CENTER);
instructionText->SetVerticalAlignment(VA_CENTER);
instructionText->SetPosition(0, ui->GetRoot()->GetHeight() / 4);
}
void Billboards::SetupViewport()
{
Renderer* renderer = GetSubsystem<Renderer>();
// Set up a viewport to the Renderer subsystem so that the 3D scene can be seen
SharedPtr<Viewport> viewport(new Viewport(context_, scene_, cameraNode_->GetComponent<Camera>()));
renderer->SetViewport(0, viewport);
}
void Billboards::SubscribeToEvents()
{
// Subscribe HandleUpdate() function for processing update events
SubscribeToEvent(E_UPDATE, URHO3D_HANDLER(Billboards, HandleUpdate));
// Subscribe HandlePostRenderUpdate() function for processing the post-render update event, during which we request
// debug geometry
SubscribeToEvent(E_POSTRENDERUPDATE, URHO3D_HANDLER(Billboards, HandlePostRenderUpdate));
}
void Billboards::MoveCamera(float timeStep)
{
// Do not move if the UI has a focused element (the console)
if (GetSubsystem<UI>()->GetFocusElement())
return;
Input* input = GetSubsystem<Input>();
// Movement speed as world units per second
const float MOVE_SPEED = 20.0f;
// Mouse sensitivity as degrees per pixel
const float MOUSE_SENSITIVITY = 0.1f;
// Use this frame's mouse motion to adjust camera node yaw and pitch. Clamp the pitch between -90 and 90 degrees
IntVector2 mouseMove = input->GetMouseMove();
yaw_ += MOUSE_SENSITIVITY * mouseMove.x_;
pitch_ += MOUSE_SENSITIVITY * mouseMove.y_;
pitch_ = Clamp(pitch_, -90.0f, 90.0f);
// Construct new orientation for the camera scene node from yaw and pitch. Roll is fixed to zero
cameraNode_->SetRotation(Quaternion(pitch_, yaw_, 0.0f));
// Read WASD keys and move the camera scene node to the corresponding direction if they are pressed
if (input->GetKeyDown(KEY_W))
cameraNode_->Translate(Vector3::FORWARD * MOVE_SPEED * timeStep);
if (input->GetKeyDown(KEY_S))
cameraNode_->Translate(Vector3::BACK * MOVE_SPEED * timeStep);
if (input->GetKeyDown(KEY_A))
cameraNode_->Translate(Vector3::LEFT * MOVE_SPEED * timeStep);
if (input->GetKeyDown(KEY_D))
cameraNode_->Translate(Vector3::RIGHT * MOVE_SPEED * timeStep);
// Toggle debug geometry with space
if (input->GetKeyPress(KEY_SPACE))
drawDebug_ = !drawDebug_;
}
void Billboards::AnimateScene(float timeStep)
{
// Get the light and billboard scene nodes
PODVector<Node*> lightNodes;
PODVector<Node*> billboardNodes;
scene_->GetChildrenWithComponent<Light>(lightNodes);
scene_->GetChildrenWithComponent<BillboardSet>(billboardNodes);
const float LIGHT_ROTATION_SPEED = 20.0f;
const float BILLBOARD_ROTATION_SPEED = 50.0f;
// Rotate the lights around the world Y-axis
for (unsigned i = 0; i < lightNodes.Size(); ++i)
lightNodes[i]->Rotate(Quaternion(0.0f, LIGHT_ROTATION_SPEED * timeStep, 0.0f), TS_WORLD);
// Rotate the individual billboards within the billboard sets, then recommit to make the changes visible
for (unsigned i = 0; i < billboardNodes.Size(); ++i)
{
BillboardSet* billboardObject = billboardNodes[i]->GetComponent<BillboardSet>();
for (unsigned j = 0; j < billboardObject->GetNumBillboards(); ++j)
{
Billboard* bb = billboardObject->GetBillboard(j);
bb->rotation_ += BILLBOARD_ROTATION_SPEED * timeStep;
}
billboardObject->Commit();
}
}
void Billboards::HandleUpdate(StringHash eventType, VariantMap& eventData)
{
using namespace Update;
// Take the frame time step, which is stored as a float
float timeStep = eventData[P_TIMESTEP].GetFloat();
// Move the camera and animate the scene, scale movement with time step
MoveCamera(timeStep);
AnimateScene(timeStep);
}
void Billboards::HandlePostRenderUpdate(StringHash eventType, VariantMap& eventData)
{
// If draw debug mode is enabled, draw viewport debug geometry. This time use depth test, as otherwise the result becomes
// hard to interpret due to large object count
if (drawDebug_)
GetSubsystem<Renderer>()->DrawDebugGeometry(true);
}
| [
"seanvolt@gmail.com"
] | seanvolt@gmail.com |
ed84554bfa92629d178a973e87a4adc0e77e9729 | 82df251100d1e15d0793e2aa7a73ba6220c5f391 | /collision/circle.cpp | 1cb5a40088d91ba31a115e0c05175defc8604913 | [] | no_license | limepixl/collision | 5e04c597df6e932e87e67bb28840da3d2bb84af5 | 14d06a4a11e68a74898f9cfb446fb00972689a59 | refs/heads/master | 2020-08-01T23:44:24.581292 | 2019-09-29T18:45:01 | 2019-09-29T18:45:01 | 211,162,981 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 563 | cpp | #include "circle.hpp"
#include "utils.hpp"
Circle::Circle(float r, const sf::Vector2f& c, const sf::Vector2f& v) : radius(r), mass(r), center(c), velocity(v)
{
color = sf::Vector3i(rand() % 200 + 56, rand() % 200 + 56, rand() % 200 + 56);
}
bool Circle::IsMoving()
{
return velocity != sf::Vector2f(0.0f, 0.0f);
}
bool CheckOverlap(Circle& first, Circle& second)
{
if(first.IsMoving() || second.IsMoving())
return false;
float dist = Length(first.center - second.center);
if(dist < first.radius + second.radius - 1.0f)
return true;
return false;
}
| [
"stefs.ivanovski@gmail.com"
] | stefs.ivanovski@gmail.com |
62008d1b0873ec0559e5afaa1c54eb2f9661a5eb | c3463be89e53d6bd7ed5c1fddcdad549091c9632 | /Applied/CCore/test/test3005.LogMem.cpp | 4e301c1f6c62e883b4c9e9a4222c24b172661786 | [
"BSL-1.0",
"FTL"
] | permissive | SergeyStrukov/CCore-4-xx | c6f8eb37bbda33fbc8ab4a15b72c88b35aac291b | c15aeee098cc2f62914e45741af95b1a90e3ed10 | refs/heads/master | 2023-02-18T09:22:43.796949 | 2023-02-08T06:30:43 | 2023-02-08T06:30:43 | 262,752,021 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,143 | cpp | /* test3005.LogMem.cpp */
//----------------------------------------------------------------------------------------
//
// Project: CCore 4.01
//
// Tag: Applied
//
// License: Boost Software License - Version 1.0 - August 17th, 2003
//
// see http://www.boost.org/LICENSE_1_0.txt or the local copy
//
// Copyright (c) 2020 Sergey Strukov. All rights reserved.
//
//----------------------------------------------------------------------------------------
#include <CCore/test/test.h>
#include <CCore/inc/Log.h>
#include <CCore/inc/Random.h>
#include <CCore/inc/OwnPtr.h>
#include <CCore/inc/Counters.h>
namespace App {
namespace Private_3005 {
/* enum Event */
enum Event
{
EventNoMem,
EventAlloc,
EventFree,
EventDel,
EventClear,
EventLim
};
const char * GetTextDesc(Event ev)
{
static const char *const Table[]=
{
"NoMem",
"Alloc",
"Free",
"Del",
"Clear"
};
return Table[ev];
}
/* class Engine */
class Engine : NoCopy
{
LogMem logmem;
Random random;
Counters<Event,EventLim> stat;
struct Head
{
SLink<Head> link;
ulen len;
byte fill;
byte * mem() { return PlaceAt(this)+sizeof (Head); }
PtrLen<byte> range() { return Range(mem(),len); }
void init(ulen len_,byte fill_)
{
len=len_;
fill=fill_;
fill_ext();
}
void fill_ext()
{
range().set(fill);
}
void check_ext()
{
for(byte b : range() ) if( b!=fill ) Printf(Exception,"fail");
}
};
SLink<Head>::LinearAlgo<&Head::link>::FirstLast list;
private:
void alloc()
{
ulen len=random.select(0,1_KByte);
void *mem=logmem.alloc(len+sizeof (Head));
if( !mem )
{
stat.count(EventNoMem);
return;
}
if( random.select(10) )
{
Head *head=new(PlaceAt(mem)) Head;
head->init(len,random.next_uint<byte>());
list.ins_last(head);
stat.count(EventAlloc);
}
else
{
logmem.free(mem);
stat.count(EventFree);
}
}
void del()
{
if( Head *head=list.del_first() )
{
head->check_ext();
if( +list )
{
logmem.del(list.first);
stat.count(EventDel);
}
else
{
logmem.clear();
stat.count(EventClear);
}
}
}
public:
Engine()
: logmem(10_KByte)
{
}
void run(ulen count)
{
for(; count ;count--)
{
switch( random.select(2) )
{
case 0 :
{
alloc();
}
break;
case 1 :
{
del();
}
break;
}
}
Printf(Con,"#10l;\n",stat);
}
};
} // namespace Private_3005
using namespace Private_3005;
/* Testit<3005> */
template<>
const char *const Testit<3005>::Name="Test3005 LogMem";
template<>
bool Testit<3005>::Main()
{
OwnPtr<Engine> engine(new Engine);
engine->run(10'000'000);
return true;
}
} // namespace App
| [
"sshimnick@hotmail.com"
] | sshimnick@hotmail.com |
c760f867e0d2ad14c43ee10040b905ff2cc6bd71 | a07ce5699582b2c3068198a3c89afb430ed34c62 | /webcgi-fpm/WebCGIDefault.cpp | 1f0c0ab34a8e1e58e943f0d593a41fc9640121b4 | [
"BSD-2-Clause"
] | permissive | jackbrains/webcgi | b16df4fe7bc05d22d91eab4e4572a25c1f237372 | fb9b9fc73bb3f12107409a8c985861a70da9a9ed | refs/heads/master | 2021-04-12T09:06:28.583827 | 2017-06-16T16:54:07 | 2017-06-16T16:54:07 | 94,521,553 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 117 | cpp | #include "WebCGIDefault.h"
webcgi::WebCGIDefault::WebCGIDefault()
{
}
webcgi::WebCGIDefault::~WebCGIDefault()
{
}
| [
"sourcecode@skyosx"
] | sourcecode@skyosx |
e758699080ceac48dd16ecafa8cd9714a84b8f36 | 5fb7d0b239e4f79a27ebd1ba01aca628b2261d22 | /arduino/ultra.ino | f6249cf4faf42334c65833522aa44db645af6761 | [
"MIT"
] | permissive | Nesdood007/mart380_musigen | d89422cca111c0251788b43519c174bd32e0b9c8 | fc791b57ef12e685f17382801340d10d45f5c5ba | refs/heads/master | 2020-05-18T02:57:35.122026 | 2019-05-09T04:02:07 | 2019-05-09T04:02:07 | 184,132,963 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,068 | ino | /* Arduino Ultrasonic Music Sensor. Sends Serial Commands back to a computer of the notes to turn on.
*
*
*/
const int TRIG = 2;
const int ECHO = 3;
const long MIN_VAL = 2; //Measured in Inches
const long MAX_VAL = 22; //inches
long duration, inches;
int val = 0; //Byte to send
void setup() {
Serial.begin(9600);
pinMode(TRIG, OUTPUT);
pinMode(ECHO, INPUT);
pinMode(LED_BUILTIN, OUTPUT);
}
void loop() {
digitalWrite(LED_BUILTIN, LOW);
digitalWrite(TRIG, LOW);
delayMicroseconds(2);
digitalWrite(TRIG, HIGH);
delayMicroseconds(2);
digitalWrite(TRIG, LOW);
duration = pulseIn(ECHO, HIGH);
inches = microsecondsToInches(duration);
if (inches < MIN_VAL) val = 0;
else if (inches > MAX_VAL) val = 127;
else {
val = (int)(((float)(inches - MIN_VAL) / (MAX_VAL - MIN_VAL)) * 127);
digitalWrite(LED_BUILTIN, HIGH);
}
Serial.write(val);
delay(25);
}
long microsecondsToInches(long microseconds) {
return microseconds/74/2;
}
long microsecondsToCentimeters(long microseconds) {
return microseconds/29/2;
}
| [
"thebradyoleary@gmail.com"
] | thebradyoleary@gmail.com |
b9ecff83cdeef1a3ef50cb9261a70f7eeda0e55e | f271c46bb77d70c81354f550b3004976541ba12b | /src/SystemInfo.cpp | 28238a3c4c149121bbecbc1346f166a8452380be | [] | no_license | yearling/YYUI | 4baa2b2f5a7cb0a61120a0404e9ed3afe7c4e73f | 3984776c5878f48851c4e7814789d403a15b1114 | refs/heads/master | 2021-01-10T01:06:10.881411 | 2015-06-10T12:40:34 | 2015-06-10T12:40:34 | 36,545,444 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 490 | cpp | #include "YUI.h"
#include "SystemInfo.h"
namespace YUI
{
SystemInfo::SystemInfo(void)
{
}
SystemInfo::~SystemInfo(void)
{
}
SystemInfo* SystemInfo::GetInstance()
{
return &m_Instant;
}
HINSTANCE SystemInfo::GetProcessInstance() const
{
return m_hIns;
}
void SystemInfo::SetProcessInstance(HINSTANCE hIns)
{
m_hIns =hIns;
}
YUI::SystemInfo SystemInfo::m_Instant;
} | [
"yearlingwes@gmail.com"
] | yearlingwes@gmail.com |
f517dd6de3ce1e161756f66b4a5d8b6dbc87f629 | f209c033c4d92363ec44dca0cf84f2b305a5047d | /emtg/src/Mission/Journey/Phase/BoundaryEvents/Departure/EphemerisPeggedDeparture/EphemerisPeggedSpiralDeparture.h | d0d091ec3bab47080eecc8bf43faf4b7f87ba032 | [] | no_license | Yuricst/EMTG | 97650f57c7ca9f535376114a6fb9639b50e27d62 | 5a0b4d140e6550b0d8478ee39fe91bc747d5ac16 | refs/heads/master | 2023-01-30T22:47:00.250863 | 2020-12-13T17:49:36 | 2020-12-13T17:49:36 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,150 | h | // EMTG: Evolutionary Mission Trajectory Generator
// An open-source global optimization tool for preliminary mission design
// Provided by NASA Goddard Space Flight Center
//
// Copyright (c) 2013 - 2020 United States Government as represented by the
// Administrator of the National Aeronautics and Space Administration.
// All Other Rights Reserved.
// Licensed under the NASA Open Source License (the "License");
// You may not use this file except in compliance with the License.
// You may obtain a copy of the License at:
// https://opensource.org/licenses/NASA-1.3
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
// express or implied. See the License for the specific language
// governing permissions and limitations under the License.
//EphemerisPeggedSpiralDeparture
//Jacob Englander 10-24-2017
#include "EdelbaumSpiral.h"
#include "EphemerisPeggedDeparture.h"
namespace EMTG
{
namespace BoundaryEvents
{
class EphemerisPeggedSpiralDeparture : virtual public EphemerisPeggedDeparture
{
public:
EphemerisPeggedSpiralDeparture(const std::string& name,
const size_t& journeyIndex,
const size_t& phaseIndex,
size_t& stageIndex,
Astrodynamics::universe* Universe,
HardwareModels::Spacecraft* mySpacecraft,
missionoptions* myOptions,
ArrivalEvent* PreviousPhaseArrivalEvent);
~EphemerisPeggedSpiralDeparture();
//we have to override setup-calcbounds so that we can set up the owned EdelbaumSpiral class and its owned classes
void setup_calcbounds(
std::vector<double>* Xupperbounds,
std::vector<double>* Xlowerbounds,
std::vector<double>* X_scale_factors,
std::vector<double>* Fupperbounds,
std::vector<double>* Flowerbounds,
std::vector<double>* F_scale_factors,
std::vector<std::string>* Xdescriptions,
std::vector<std::string>* Fdescriptions,
std::vector<size_t>* iGfun,
std::vector<size_t>* jGvar,
std::vector<std::string>* Gdescriptions,
std::vector<size_t>* iAfun,
std::vector<size_t>* jAvar,
std::vector<std::string>* Adescriptions,
std::vector<double>* A);
void calcbounds();
void process_event(const std::vector<doubleType>& X,
size_t& Xindex,
std::vector<doubleType>& F,
size_t& Findex,
std::vector<double>& G,
const bool& needG);
void output(std::ofstream& outputfile,
const double& launchdate,
size_t& eventcount);
math::Matrix<doubleType> get_periapse_state();
protected:
void calcbounds_event_main();
void calcbounds_event_right_side();
void calcbounds_virtual_propellant_constraints() {}; //stub, propellant constraints live in the owned spiral segment objects
void process_event_main(const std::vector<doubleType>& X,
size_t& Xindex,
std::vector<doubleType>& F,
size_t& Findex,
std::vector<double>& G,
const bool& needG);
void process_event_right_side(const std::vector<doubleType>& X,
size_t& Xindex,
std::vector<doubleType>& F,
size_t& Findex,
std::vector<double>& G,
const bool& needG);
void process_virtual_propellant_constraints(const std::vector<doubleType>& X,
size_t& Xindex,
std::vector<doubleType>& F,
size_t& Findex,
std::vector<double>& G,
const bool& needG) {}; //stub, propellant constraints live in the owned spiral segment objects
//fields
EdelbaumSpiral* mySpiral;
math::Matrix<doubleType> StateAfterSpiral;
//derivative indices
size_t Xindex_SpiralFlightTime;
size_t Gindex_dSpiralFlightTimeConstraint_dSpiralFlightTime;
std::vector<size_t> Gindex_dSpiralFlightTimeConstraint_dPreviousTimeVariable; //first entry is launch epoch
size_t Gindex_dSpiralFlightTimeConstraint_dMassAtBeginningOfSpiral;
size_t dIndex_EpochAfterSpiral_wrt_SpiralFlightTime;
std::vector<size_t> dIndex_MassAfterSprial_wrt_PreviousTimeVariables;
std::vector<size_t> dIndex_6state_wrt_SpiralFlightTime;
std::vector<size_t> Gindex_VirtualElectricPropellantConstraint_wrt_PreviousTimeVariables;
size_t Gindex_VirtualElectricPropellantConstraint_wrt_MassBeforeSpiral;
};//end class EdelbaumSpiralDeparture
}//close namespace BoundaryEvents
}//close namespace EMTG | [
"jacob.a.englander@nasa.gov"
] | jacob.a.englander@nasa.gov |
b9644ee2fe260651a50fc56d80a39fc3e579054b | 88ddf9f262a914a470075852819fb462f392ee5a | /Amazon Mockup/product.cpp | 2606855462250b4ab088320f68f355558a422b5c | [] | no_license | julianzhang98/Amazon-Mockup | 0a7d13acb0eba916ae5784edafa1c684b7d9dfab | 3db1a4a1f21463687149dd98985f13cdfc7f4dd9 | refs/heads/master | 2021-05-15T23:23:39.410343 | 2017-10-13T11:52:32 | 2017-10-13T11:52:32 | 106,810,688 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 997 | cpp | #include <sstream>
#include <iomanip>
#include "product.h"
using namespace std;
Product::Product(const std::string category, const std::string name, double price, int qty) :
name_(name),
price_(price),
qty_(qty),
category_(category),
rating_(0)
{
}
Product::~Product()
{
}
double Product::getPrice() const
{
return price_;
}
std::string Product::getName() const
{
return name_;
}
void Product::subtractQty(int num)
{
qty_ -= num;
}
int Product::getQty() const
{
return qty_;
}
double Product::getRating() const
{
return rating_;
}
void Product::setRating(double rating)
{
rating_ = rating;
}
/**
* default implementation...can be overriden in a future
* assignment
*/
bool Product::isMatch(/*std::vector<std::string>& searchTerms*/) const
{
return false;
}
void Product::dump(std::ostream& os) const
{
os << category_ << "\n" << name_ << "\n" << price_ << "\n" << qty_ << endl;
}
string Product::getCategory() {
return category_;
}
| [
"julianzhang98@gmail.com"
] | julianzhang98@gmail.com |
f9ea598003d2434a1fc6c168e6529d8be3dd0e64 | 43963deaade533bc28ed8ca3a00e99bec171046e | /src/kernel/RtlFillMemory.cpp | 3d73afcd8f3798ba8baec4242d7536c5540e35b3 | [] | no_license | mborgerson/OpenXBOX | 3bc8dac3b719859b1284b2426b195945bb878b98 | 126fbd13a51dd09ae3f7cac747dffe1ce1a0e912 | refs/heads/master | 2023-02-25T16:11:31.497371 | 2017-12-27T21:08:57 | 2017-12-27T21:08:57 | 113,101,895 | 18 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 425 | cpp | #include "common.h"
/*
* RtlFillMemory
*
* Import Number: 284
* Calling Convention: stdcall
* Parameter 0: PVOID Destination
* Parameter 1: ULONG Length
* Parameter 2: UCHAR Fill
* Return Type: VOID
*/
int Xbox::RtlFillMemory()
{
K_ENTER_STDCALL();
K_INIT_ARG(PVOID, Destination);
K_INIT_ARG(ULONG, Length);
K_INIT_ARG(UCHAR, Fill);
K_EXIT();
return ERROR_NOT_IMPLEMENTED;
}
| [
"contact@mborgerson.com"
] | contact@mborgerson.com |
299f03bf6e3495f53e9cc14ea51dbe80f9a6cb50 | e1e2b98b507baefee43bc9f09e4fc5e43828abc6 | /level_zero/tools/source/sysman/temperature/windows/os_temperature_imp.cpp | 535619afdf23f082f775002ebb2c69c491eda2d2 | [
"MIT"
] | permissive | Anxs-04/compute-runtime | 9286128bb747a02593cfde45d5a95dca02a1a66b | df75856f17ccce2d356917fbcd6ea478c8ba4a38 | refs/heads/master | 2023-03-05T01:27:23.257072 | 2020-06-19T09:20:27 | 2020-06-21T20:15:35 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 878 | cpp | /*
* Copyright (C) 2020 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "sysman/temperature/os_temperature.h"
namespace L0 {
class WddmTemperatureImp : public OsTemperature {
public:
ze_result_t getSensorTemperature(double *pTemperature) override;
bool isTempModuleSupported() override;
void setSensorType(zet_temp_sensors_t sensorType) override;
};
ze_result_t WddmTemperatureImp::getSensorTemperature(double *pTemperature) {
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
}
bool WddmTemperatureImp::isTempModuleSupported() {
return false;
}
void WddmTemperatureImp::setSensorType(zet_temp_sensors_t sensorType) {}
OsTemperature *OsTemperature::create(OsSysman *pOsSysman) {
WddmTemperatureImp *pWddmTemperatureImp = new WddmTemperatureImp();
return static_cast<OsTemperature *>(pWddmTemperatureImp);
}
} // namespace L0 | [
"ocldev@intel.com"
] | ocldev@intel.com |
ca8a48308d3fc3ad4ffa438575c7004a28d1fec6 | cd84fc75487a5d5ea4b7ea4af10a10de789a85ab | /project_code/com/drollic/graphics/painting/nativeprocessing/wmvFile.h | 808f2d5bfe4c7c24e4d412b141c4add9246ad86d | [
"LicenseRef-scancode-warranty-disclaimer",
"Apache-2.0"
] | permissive | drollicdotcom/devart-template | be11d8992bb3f726bc775ee17548ec12b09d2861 | 4e59a8b4f7e0e94cccc33911a2c58dd981dfbee5 | refs/heads/master | 2020-05-20T18:17:59.649841 | 2014-03-27T02:53:05 | 2014-03-27T02:53:05 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,544 | h | #pragma once
#include <wmsdk.h>
#include <wmsysprf.h>
#ifndef WMFORMAT_SDK_VERSION
#define WMFORMAT_SDK_VERSION WMT_VER_9_0
#endif
#define WINVER 0x0601
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
// Windows Header Files:
#include <windows.h>
#include <stdlib.h>
#include <malloc.h>
#include <memory.h>
#include <tchar.h>
#include <string.h>
#include <stdio.h>
namespace com
{
namespace drollic
{
namespace graphics
{
namespace painting
{
namespace native
{
namespace processing
{
class CwmvFile
{
bool readyToGenerate;
IWMProfile *m_pWMProfile;
IWMWriter *m_pWMWriter;
IWMInputMediaProps *m_pVideoProps;
IWMProfileManager *m_pWMProfileManager;
HDC m_hwmvDC;
TCHAR m_szErrMsg[MAX_PATH];
DWORD m_dwVideoInput;
DWORD m_dwCurrentVideoSample;
QWORD m_msVideoTime;
DWORD m_dwFrameRate; // Frames Per Second Rate (FPS)
int m_nAppendFuncSelector; //0=Dummy 1=FirstTime 2=Usual
int totalFramesWritten;
int keyFrameEveryNFrames;
HRESULT AppendFrameFirstTime(HBITMAP );
HRESULT AppendFrameUsual(HBITMAP);
HRESULT AppendDummy(HBITMAP);
HRESULT (CwmvFile::*pAppendFrame[3])(HBITMAP hBitmap);
HRESULT AppendFrameFirstTime(int, int, LPVOID,int );
HRESULT AppendFrameUsual(int, int, LPVOID,int );
HRESULT AppendDummy(int, int, LPVOID,int );
HRESULT (CwmvFile::*pAppendFrameBits[3])(int, int, LPVOID,int );
/// Takes care of creating the memory, streams, compression options etc. required for the movie
HRESULT InitMovieCreation(int nFrameWidth, int nFrameHeight, int nBitsPerPixel);
/// Takes care of releasing the memory and movie related handles
void ReleaseMemory();
/// Sets the Error Message
void SetErrorMessage(LPCTSTR lpszErrMsg);
public:
/// <Summary>
/// Constructor accepts the filename, ProfileGUID and frame rate settings
/// as parameters.
/// lpszFileName: Name of the output movie file to create
/// guidProfileID: GIUD of the Video Profile to be used for compression and other Settings
/// dwFrameRate: The Frames Per Second (FPS) setting to be used for the movie
/// </Summary>
CwmvFile(void);
void PrepareToGenerate(
const GUID& guidProfileID /* = WMProfile_V80_384Video */,
DWORD dwFrameRate /* = 1 */,
char *movieFilename);
/// <Summary>
/// Destructor closes the movie file and flushes all the frames
/// </Summary>
~CwmvFile(void);
/// </Summary>
/// Inserts the given HBitmap into the movie as a new Frame at the end.
/// </Summary>
HRESULT AppendNewFrame(HBITMAP hBitmap);
/// </Summary>
/// Inserts the given bitmap bits into the movie as a new Frame at the end.
/// The width, height and nBitsPerPixel are the width, height and bits per pixel
/// of the bitmap pointed to by the input pBits.
/// </Summary>
HRESULT AppendNewFrame(int nWidth, int nHeight, LPVOID pBits,int nBitsPerPixel=32);
/// <Summary>
/// Returns the last error message, if any.
/// </Summary>
LPCTSTR GetLastErrorMessage() const { return m_szErrMsg; }
};
}
}
}
}
}
} | [
"raysblog@gmail.com"
] | raysblog@gmail.com |
c209d85b14e49003737cf75abe3b302789caed1e | 305ca5426ec02527addfaa21fe4f11bd4662a96a | /Library/source/Engine/Temporary.cpp | 38264d493e880074523284ee529e093a1eaf3402 | [] | no_license | Booljayj/AndoEngine | b7139b0d074ee2a864872d6249a769469ed6d8b3 | e8962d0ef7ebc30736cf22f26400d5f2e0d89c35 | refs/heads/master | 2023-06-22T11:41:43.472192 | 2023-06-17T08:10:31 | 2023-06-17T08:10:31 | 101,098,490 | 3 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,078 | cpp | #include "Engine/Temporary.h"
#include "Engine/Logging.h"
thread_local ThreadBuffer* ThreadBuffer::current = nullptr;
ThreadBuffer::ThreadBuffer(size_t capacity) : HeapBuffer(capacity) {
assert(!current);
current = this;
}
ThreadBuffer::~ThreadBuffer() {
current = nullptr;
}
void ThreadBuffer::LogDebugStats() {
LOGF(Temp, Info, "Thread Buffer:{ Capacity: %i, Current: %i, Peak: %i }", current->GetCapacity(), current->GetUsed(), current->GetPeakUsage());
}
ScopedThreadBufferMark::ScopedThreadBufferMark() : HeapBuffer::ScopedMark(ThreadBuffer::Get()) {}
std::string_view t_printf(char const* format, ...) {
std::va_list args;
va_start(args, format);
Buffer& buffer = ThreadBuffer::Get();
size_t const available = buffer.GetAvailable();
char* const begin = buffer.GetCursor();
size_t const size = vsnprintf(begin, available, format, args);
//Set the cursor to the byte after the null terminator so subsequent prints don't interfere with the results of this one.
buffer.SetCursor(begin + size + 1);
va_end(args);
return std::string_view{ begin, size };
}
| [
"booljayj@gmail.com"
] | booljayj@gmail.com |
84a29cbcd6d763f693ea478f727ddcc5cf09a1e8 | b18330180bc2dddf483e2eb81160934dcd818ef8 | /api/impl/halSequence.cpp | e5e1778819dcebc4d2d377f43ab166779aea22d8 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | ComparativeGenomicsToolkit/hal | 3e5cc48c09bd0083d8d2eb849401ac5ed0bf8b06 | e9e70b6c4a46a82aacf36632e1761804595d7f66 | refs/heads/master | 2023-08-31T06:32:09.551768 | 2023-06-22T23:55:36 | 2023-06-22T23:55:36 | 3,778,244 | 110 | 42 | NOASSERTION | 2023-08-31T15:13:38 | 2012-03-20T17:58:31 | C++ | UTF-8 | C++ | false | false | 563 | cpp | /*
* Copyright (C) 2012 by Glenn Hickey (hickey@soe.ucsc.edu)
* Copyright (C) 2012-2019 by UCSC Computational Genomics Lab
*
* Released under the MIT license, see LICENSE.txt
*/
#include "halDefs.h"
#include "halSequence.h"
#include "halGenome.h"
/* thrown when sequence not found in genome */
hal::SequenceNotFoundException::SequenceNotFoundException(const Genome* genome,
const std::string &name):
hal_exception("Sequence '" + name + "' not found in genome '" + genome->getName() + "'") {
}
| [
"markd@ucsc.edu"
] | markd@ucsc.edu |
3764df48ee283cf4e7b0b452b2a74ac61e38f3cf | 448ac177eacdee48e716e717ad93c536dd4fc27a | /c++/LOc/main.cpp | 70d17cb7b5cc4cae8ffc3c6983bbffd2e59fb725 | [] | no_license | lapalb/Random_Code | 56952d4d0c57e508b52eb503ef0b882c15d6630e | b545fbebe470d73ed01398f141ab7a06ff13665a | refs/heads/master | 2020-03-22T21:37:47.049770 | 2018-07-12T11:09:45 | 2018-07-12T11:09:45 | 140,701,932 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,079 | cpp | #include<bits/stdc++.h>
using namespace std;
#define eps 1e-12
#define pi 3.14159265358979323846
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define bgn begin
#define ll long long
#define ld long double
#define ull unsigned long long
#define ii pair<ll,ll>
struct gcdExtnd
{
ll x,y,g;
ll gcd(ll a,ll b)
{
if(b==0)
{
x=1;
y=0;
return a;
}
g=gcd(b,a%b);
ll t=y;
y=x-(a/b)*y;
x=t;
return g;
}
};
ll invrsMod(ll a, ll m)
{
gcdExtnd o;
ll g=o.gcd(a,m);
ll x=(o.x)%m;
if(x<0)x+=m;
return x;
}
const int N=1000,M=1e9+7;
ll q,n,t,res,fct[N+10];
void solve()
{
fct[0]=1;
for(int i=1;i<=N;i++)
{
fct[i]=(fct[i-1]*i)%M;
}
cin>>q;
while(q--)
{
cin>>n>>t;
res=invrsMod(t+1,M);
for(ll i=1,j=n+t+1,k;i<=t+1;i++,j--)
{
res=(res*(j%M))%M;
}
res=(res-fct[t]+M)%M;
cout<<res<<"\n";
}
}
int main()
{
std::ios::sync_with_stdio(0);
cin.tie(0);
#ifdef localProject
freopen("in.txt","r",stdin);
#endif
solve();
return 0;
}
| [
"noreply@github.com"
] | noreply@github.com |
d199cac761e036f80448fe2b0b052964cea4d832 | 4678e9d4ae05495649f690dfd5870bf4a172192e | /hw3/q1_ben/code/fastMarching/fmm.cpp | 5f58cc8904c32d68a9bf196c7bca18b49b4ae477 | [] | no_license | dekel2003/Geometric-Computer-Vision | 75f2bc9a4c02a1b72c37945971249ad101e2f238 | 52748e28c5320ccfd7758e419320f1a7c19e6e08 | refs/heads/master | 2021-01-22T23:58:26.624984 | 2017-03-31T19:59:43 | 2017-03-31T19:59:43 | 85,684,485 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,491 | cpp | #include "fmm.h"
#include "fheap/fib.h"
#include "fheap/fibpriv.h"
// variables
int num_rows; //F rows
int num_cols; //F cols
double* F = NULL; //Weights of all matrix cells
double* T = NULL; //distances
mxArray* T_iter = NULL; // distances for each iteration
Color* S = NULL;
double* src = NULL; // input sources points (x,y)
int num_src_points = 0; // #sources
double* t0 = NULL; //src points initial values.
int max_iterations = 20000000; //limit the number of iterations
fibheap_el** fb_heap = NULL; // use the included library for creating fibonacci heap.
int display_mode = 0; // 0 - silent and 1 - iter
#define GET_ELEMENT(a,i,j) a[(i)+num_rows*(j)] //i=column j=row column wise matlab.
#define src_points_(i,k) src[(i)+2*(k)]
#define F_(i,j) GET_ELEMENT(F,i,j)
#define T_(i,j) GET_ELEMENT(T,i,j)
#define fb_heap_(i,j) GET_ELEMENT(fb_heap,i,j)
#define S_(i,j) GET_ELEMENT(S,i,j)
#define T_iter_(i,j) GET_ELEMENT(mxGetPr(T_iter),i,j)
using namespace std;
struct Vertex_2D
{
int i, j;
Vertex_2D(int _i, int _j){
i = _i;
j = _j;
}
};
typedef vector<Vertex_2D*> vertices;
inline
int compare_points(void *x, void *y)
{
Vertex_2D& p1 = *((Vertex_2D*)x);
Vertex_2D& p2 = *((Vertex_2D*)y);
return cmp(T_(p1.i, p1.j), T_(p2.i, p2.j));
}
void iter_mode(int i,int j,Color state)
{
switch (state) {
case Black:
mexPrintf("\n(%d,%d) is Black\n", i, j);
break;
case Red:
mexPrintf("\n(%d,%d) is Red\n", i, j);
break;
case Green:
mexPrintf("\n(%d,%d) is Green\n", i, j);
break;
}
mexPutVariable("caller", "TT",T_iter );
mexEvalString("imshow(colorDistanceMap(TT),'InitialMagnification','fit'); drawnow;");
}
void fmm()
{
struct fibheap* fibonacciHeap = fh_makeheap();
fh_setcmp(fibonacciHeap, compare_points);
T_iter = mxCreateDoubleMatrix(num_rows, num_cols, mxREAL);
double h = 1.0 / num_rows;
for (int i = 0; i < num_rows; ++i)
for (int j = 0; j < num_cols; ++j)
{
T_(i, j) = INF;
T_iter_(i, j) = INF;
S_(i, j) = Green;
}
fb_heap = new fibheap_el*[num_rows*num_cols];
memset(fb_heap, NULL, num_rows*num_cols*sizeof(fibheap_el*));
vertices checked_vertices;
for (int k = 0; k < num_src_points; ++k)
{
int i = (int)src_points_(0, k);
int j = (int)src_points_(1, k);
Vertex_2D* v = new Vertex_2D(i, j);
checked_vertices.push_back(v);
fb_heap_(i, j) = fh_insert(fibonacciHeap, v);
T_(i, j) = t0[k];
T_iter_(i, j) = t0[k];
S_(i, j) = Red;
if (display_mode==1)
iter_mode(i, j, Red);
}
int iter_number = 0;
while (!fh_isempty(fibonacciHeap) && iter_number < max_iterations)
{
iter_number++;
Vertex_2D& cur_point = *((Vertex_2D*)fh_extractmin(fibonacciHeap));
int i = cur_point.i;
int j = cur_point.j;
fb_heap_(i, j) = NULL;
S_(i, j) = Black;
if (display_mode==1)
iter_mode(i, j, Black);
int neighbor_i[4] = { i + 1, i, i - 1, i };
int neighbor_j[4] = { j, j + 1, j, j - 1 };
for (int k = 0; k < 4; ++k)
{
int ii = neighbor_i[k];
int jj = neighbor_j[k];
if (ii < 0 || jj < 0 || ii >= num_rows || jj >= num_cols)
continue;
double FH = h / F_(ii, jj);
double t1 = INF;
if (ii<num_rows - 1)
{
t1 = T_(ii + 1, jj);
}
if (ii>0)
{
t1 = MIN(t1, T_(ii - 1, jj));
}
double t2 = INF;
if (jj<num_cols - 1)
{
t2 = T_(ii, jj + 1);
}
if (jj>0)
{
t2 = MIN(t2, T_(ii, jj - 1));
}
double T3 = 0;
if (FH*FH > (t2 - t1)*(t2 - t1))
{
double s = 2 * FH*FH - (t2 - t1)*(t2 - t1);
T3 = (t1 + t2 + sqrt(s)) / 2.0;
}
else
T3 = MIN(t1, t2) + FH;
if (((int)S_(ii, jj)) == Black)
{
if (T3 < T_(ii, jj))
{
T_(ii, jj) = T3;
T_iter_(ii, jj) = T3;
}
}
else if (((int)S_(ii, jj)) == Red)
{
if (T3 < T_(ii, jj))
{
T_(ii, jj) = T3;
T_iter_(ii, jj) = T3;
fibheap_el* cur_el = fb_heap_(ii, jj);
if (cur_el != NULL)
fh_replacedata(fibonacciHeap, cur_el, cur_el->fhe_data);
}
}
else if (((int)S_(ii, jj)) == Green)
{
S_(ii, jj) = Red;
if (display_mode==1)
iter_mode(ii, jj, Red);
T_(ii, jj) = T3;
T_iter_(ii, jj) = T3;
Vertex_2D* pt = new Vertex_2D(ii, jj);
checked_vertices.push_back(pt);
fb_heap_(ii, jj) = fh_insert(fibonacciHeap, pt);
}
}
}
fh_deleteheap(fibonacciHeap);
for (vertices::iterator it = checked_vertices.begin(); it != checked_vertices.end(); ++it)
DELETE_POINTER(*it);
DELETE_ARRAY(fb_heap);
} | [
"dekel2003@gmail.com"
] | dekel2003@gmail.com |
04cf1b25b1c3688b1201b431d14655d491e99e4d | efb43442be45b60eca4f8c2d09bca74fdc152caf | /src/EDGIf.hh | 5c2338ec3a940183350ecf5842d6cfad9283b797 | [] | no_license | stuartw/gross | 105fa4468b215467de5812217a03512f3f4975e7 | dfdf3790a3814654b155cf9ee1fef3b9ddf1c595 | refs/heads/master | 2020-06-01T18:25:11.963820 | 2012-03-18T19:01:10 | 2012-03-18T19:01:10 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 512 | hh | #ifndef EDGIF_H
#define EDGIF_H
#include "Log.hh"
/*! \brief EDG Interface class
Implemented as a class for future scalability. Not strictly necessary at the moment.
*/
class EDGIf {
public:
EDGIf() {};
//string getOutput(const string edgJobId, string oDir="./") const;
string getOutput(const int bossJobId, string oDir="./") const;
string untarLocalOutput(const int bossId,const string oDir) const;
private:
//No implementation
EDGIf(const EDGIf&);
EDGIf operator=(const EDGIf&);
};
#endif
| [
"stuart.wakefield@gmail.com"
] | stuart.wakefield@gmail.com |
b8f6d053516ba8b897c0555abc3e29b039eac9e1 | 7088ab78d1b06b60b540d84892a1cca4157297ac | /GSP420OpenGLEngine/Sprite.h | f9cd42bbc667e610d07cc61e81946a4c9de55347 | [] | no_license | blakdragan7/GSP420OpenGLEngine | 096e917701bf0c28702eefb94266953b690b219c | e99eac13a41a8ba205969155115121d5186df132 | refs/heads/master | 2021-01-10T14:13:58.896463 | 2015-12-13T20:50:08 | 2015-12-13T20:50:08 | 45,306,919 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 886 | h | #pragma once
#include "drawableobject.h"
class GLTexture;
class GLShaderProgram;
class Sprite :
public DrawableObject
{
protected:
GLTexture* texture; // texture shown by this sprite
GLShaderProgram* program; // The Shader Program Used By This Sprite.
bool shouldRenderTexture; // if true then will bind and render texture
bool shouldUseProgram; // if true then will use a shader program
bool hasAlpha; //If set to true will enable alhp blending for drawing
bool needsDelete; // Set To True if this Instance Spawned The Textures and not a manager
public:
Sprite();
Sprite(GLTexture* tex,GLShaderProgram* program=0);
Sprite(const char* file,GLShaderProgram* program=0);
~Sprite(void);
virtual void draw() override; // draw call
virtual void update(float dt) override; // update call
void setAlpha(bool alpha=true);
};
| [
"jcopela4@gmail.com"
] | jcopela4@gmail.com |
fee0957fb66fb663a1b903a88cc7b9aa64626bd1 | a06515f4697a3dbcbae4e3c05de2f8632f8d5f46 | /corpus/taken_from_cppcheck_tests/stolen_13180.cpp | 13aa1c70bcc2a4df0b4967d64a4b017004e7c0ee | [] | no_license | pauldreik/fuzzcppcheck | 12d9c11bcc182cc1f1bb4893e0925dc05fcaf711 | 794ba352af45971ff1f76d665b52adeb42dcab5f | refs/heads/master | 2020-05-01T01:55:04.280076 | 2019-03-22T21:05:28 | 2019-03-22T21:05:28 | 177,206,313 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 125 | cpp | struct Container {
Container();
int* mElements;
};
Container::Container() : mElements(nullptr) {}
Container intContainer; | [
"github@pauldreik.se"
] | github@pauldreik.se |
796e0b9a31a15692a3ee6eff282f5becd3a052ee | 056fcc67222afe34d96fd9cadb35469f6d305907 | /driveronly_mp_rom/frameworks/av/include/media/AudioParameter.h | cf885505434f34effe19aec48b5d7806cde70e06 | [
"LicenseRef-scancode-unicode",
"Apache-2.0"
] | permissive | datagutt/12055 | a9e98f2972a76d92b7d07eee690cd1300b780efe | 593741d834fff91ad3587c762caea5f00b69ba69 | refs/heads/master | 2020-07-21T13:04:55.731555 | 2013-10-10T06:12:43 | 2013-10-10T06:12:43 | 14,116,459 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 2,970 | h | /*
* Copyright (C) 2008-2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ANDROID_AUDIOPARAMETER_H_
#define ANDROID_AUDIOPARAMETER_H_
#include <utils/Errors.h>
#include <utils/KeyedVector.h>
#include <utils/String8.h>
namespace android {
class AudioParameter {
public:
AudioParameter() {}
AudioParameter(const String8& keyValuePairs);
virtual ~AudioParameter();
// reserved parameter keys for changing standard parameters with setParameters() function.
// Using these keys is mandatory for AudioFlinger to properly monitor audio output/input
// configuration changes and act accordingly.
// keyRouting: to change audio routing, value is an int in audio_devices_t
// keySamplingRate: to change sampling rate routing, value is an int
// keyFormat: to change audio format, value is an int in audio_format_t
// keyChannels: to change audio channel configuration, value is an int in audio_channels_t
// keyFrameCount: to change audio output frame count, value is an int
// keyInputSource: to change audio input source, value is an int in audio_source_t
// (defined in media/mediarecorder.h)
// keyScreenState: either "on" or "off"
static const char * const keyRouting;
static const char * const keySamplingRate;
static const char * const keyFormat;
static const char * const keyChannels;
static const char * const keyFrameCount;
static const char * const keyInputSource;
static const char * const keyScreenState;
#ifdef VENDOR_EDIT
//Jirui.kang@BasicDrv.Audio, 2013/02/17, Add for extern codec
#ifdef EXTERNAL_CODEC_SUPPORT
static const char * const keySetStreamType;
#endif //EXTERNAL_CODEC13009_SUPPORT
#endif /* VENDOR_EDIT */
String8 toString();
status_t add(const String8& key, const String8& value);
status_t addInt(const String8& key, const int value);
status_t addFloat(const String8& key, const float value);
status_t remove(const String8& key);
status_t get(const String8& key, String8& value);
status_t getInt(const String8& key, int& value);
status_t getFloat(const String8& key, float& value);
status_t getAt(size_t index, String8& key, String8& value);
size_t size() { return mParameters.size(); }
private:
String8 mKeyValuePairs;
KeyedVector <String8, String8> mParameters;
};
}; // namespace android
#endif /*ANDROID_AUDIOPARAMETER_H_*/
| [
"zhangws@gmail.com"
] | zhangws@gmail.com |
35715b4a1e20f710f3f6ec34e1caa0f402e276d6 | f079374b6b70952b7ec09fec44c6a3e7a7f4d18e | /Baekjoon/05_DFS/2583.cpp | bc158916c9d9b4c0a2da6c321291889bd47939fd | [] | no_license | minsung1129/algorithm | 26a5b365174f52820721a7e56225a6a928b90a92 | 744d29134d02bafd8ec29ce09dcc4fc21f548730 | refs/heads/master | 2023-02-18T15:37:42.509375 | 2021-01-09T14:38:25 | 2021-01-09T14:38:25 | 321,866,815 | 2 | 0 | null | 2021-01-09T14:38:26 | 2020-12-16T04:23:03 | C++ | UTF-8 | C++ | false | false | 1,438 | cpp | #include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int nx[] = {-1, 0, 0, 1};
int ny[] = {0, -1, 1, 0};
int n, m, k;
int cnt, val;
bool visit[102][102];
pair<int, int> rect[102][2]; // 왼아 x, y | 오위 x, y
vector<int> v;
void dfs(int x, int y, int cnt) {
if (visit[x][y]) return;
val++;
visit[x][y] = true;
for (int i = 0; i < 4; i++) {
int dx = x + nx[i];
int dy = y + ny[i];
if (dx >= 0 && dx < m && dy >= 0 && dy < n) {
dfs(dx, dy, cnt);
}
}
}
int main() {
cin >> n >> m >> k;
for (int i = 0; i < k; i++) {
cin >> rect[i][0].first >> rect[i][0].second >> rect[i][1].first >> rect[i][1].second;
}
for (int i = 0; i < m; i++) {
for (int j = 0; j < n; j++) {
if (visit[i][j]) continue;
for (int a = 0; a < k; a++) {
if (i >= rect[a][0].first && i < rect[a][1].first && j >= rect[a][0].second && j < rect[a][1].second) {
visit[i][j] = true;
}
}
}
}
for (int i = 0; i < m; i++) {
for (int j = 0; j < n; j++) {
if (visit[i][j]) continue;
val = 0;
dfs(i, j, cnt++);
v.push_back(val);
}
}
cout << cnt << endl;
sort(v.begin(), v.end());
for (int i = 0; i < v.size(); i++) {
cout << v[i] << " ";
}
return 0;
} | [
"minsungkim@Minsungui-MacBookPro.local"
] | minsungkim@Minsungui-MacBookPro.local |
77cb353112ba7d29adca6ed17bcba29b20110b3d | 966c4b7c229568145b337d277b719cd48b227f70 | /src/demo.cpp | 0ba00f0709794325d4baafd6721d05d770e24784 | [] | no_license | ShawInnes/learn-cpp-unittesting | 9188bc0dce8f94e8966cf069342f283546683f91 | d1b5c70f4ecb2504366306583faa5f08d4c4993a | refs/heads/master | 2021-06-30T04:45:57.874592 | 2017-06-28T11:23:45 | 2017-06-28T11:23:45 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 883 | cpp | #include "demo.h"
// Returns n! (the factorial of n). For negative n, n! is defined to be 1.
int Factorial(int n) {
int result = 1;
for (int i = 1; i <= n; i++) {
result *= i;
}
return result;
}
// Returns n * 2
int Double(int n) {
return n * 2;
}
// Returns true iff n is a prime number.
bool IsPrime(int n) {
// Trivial case 1: small numbers
if (n <= 1) return false;
// Trivial case 2: even numbers
if (n % 2 == 0) return n == 2;
// Now, we have that n is odd and n >= 3.
// Try to divide n by every odd number i, starting from 3
for (int i = 3; ; i += 2) {
// We only have to try i up to the squre root of n
if (i > n/i) break;
// Now, we have i <= n/i < n.
// If n is divisible by i, n is not prime.
if (n % i == 0) return false;
}
// n has no integer factor in the range (1, n), and thus is prime.
return true;
}
| [
"shaw.innes@tattsgroup.com"
] | shaw.innes@tattsgroup.com |
fdeec0c255a82ac251439804ac62587a6aef2e26 | 9fc13dafd7c201773bf60c4e94ef0d116b7e9638 | /Task5.cpp | 67fe29e04dc9cb4a3d4a8adbcc5f00ff7f04d0a0 | [] | no_license | plamenag/HW1 | 92b5b0141b37d53295726d762f8001c521d1995f | 9c9961c5c1b3d021fddfe53c50ba8d389d9f7e2e | refs/heads/master | 2020-04-05T18:53:12.398665 | 2018-11-11T20:54:37 | 2018-11-11T20:54:37 | 157,116,290 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 526 | cpp | #include <iostream>
#include <cmath>
using namespace std;
int main()
{
int n, m;
int counter = 0;
cout << "n = ";
cin >> n;
cout << "m = ";
cin >> m;
for (int i = n; i <= m; i++)
{
int sum = 0;
for (int j = 1; j < i; j++)
{
if (i % j == 0)
sum += j;
}
bool flag = true;
int j = 1;
for (int p = 2; p <= sqrt(sum); p++)
{
if (sum % p == 0)
j++;
}
if (j != 1)
flag = false;
if (flag)
counter++;
}
cout << counter << endl;
return 0;
}
| [
"noreply@github.com"
] | noreply@github.com |
6e6d2f5a201ef18f49d7ef22c66c106888aa6abd | 7fd5e6156d6a42b305809f474659f641450cea81 | /boost/thread/detail/invoker.hpp | 9dfd22cab8e12bc15a1cae30b68ed1dd26896c4d | [] | no_license | imos/icfpc2015 | 5509b6cfc060108c9e5df8093c5bc5421c8480ea | e998055c0456c258aa86e8379180fad153878769 | refs/heads/master | 2020-04-11T04:30:08.777739 | 2015-08-10T11:53:12 | 2015-08-10T11:53:12 | 40,011,767 | 8 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 23,559 | hpp | // Copyright (C) 2012 Vicente J. Botet Escriba
//
// 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)
// 2013/04 Vicente J. Botet Escriba
// Provide implementation up to 9 parameters when BOOST_NO_CXX11_VARIADIC_TEMPLATES is defined.
// Make use of Boost.Move
// Make use of Boost.Tuple (movable)
// 2012/11 Vicente J. Botet Escriba
// Adapt to boost libc++ implementation
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
// The invoker code is based on the one from libcxx.
//===----------------------------------------------------------------------===//
#ifndef BOOST_THREAD_DETAIL_INVOKER_HPP
#define BOOST_THREAD_DETAIL_INVOKER_HPP
#include "boost/config.hpp"
#include "boost/utility/result_of.hpp"
#include "boost/thread/detail/move.hpp"
#include "boost/thread/detail/invoke.hpp"
#include "boost/thread/detail/make_tuple_indices.hpp"
#include "boost/thread/csbl/tuple.hpp"
#include "boost/tuple/tuple.hpp"
#include "boost/thread/detail/variadic_header.hpp"
namespace boost
{
namespace detail
{
#if defined(BOOST_THREAD_PROVIDES_INVOKE) && ! defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && ! defined(BOOST_NO_CXX11_HDR_TUPLE)
template <class Fp, class ... Args>
class invoker
{
//typedef typename decay<Fp>::type Fpd;
//typedef tuple<typename decay<Args>::type...> Argsd;
//csbl::tuple<Fpd, Argsd...> f_;
csbl::tuple<Fp, Args...> f_;
public:
BOOST_THREAD_COPYABLE_AND_MOVABLE( invoker)
//typedef typename invoke_of<_Fp, _Args...>::type Rp;
typedef typename result_of<Fp(Args...)>::type result_type;
template <class F, class ... As>
BOOST_SYMBOL_VISIBLE
explicit invoker(BOOST_THREAD_FWD_REF(F) f, BOOST_THREAD_FWD_REF(As)... args)
: f_(boost::forward<F>(f), boost::forward<As>(args)...)
{}
BOOST_SYMBOL_VISIBLE
invoker(BOOST_THREAD_RV_REF(invoker) f) : f_(boost::move(BOOST_THREAD_RV(f).f_))
{}
BOOST_SYMBOL_VISIBLE
invoker( const invoker& f) : f_(f.f_)
{}
BOOST_SYMBOL_VISIBLE
invoker& operator=(BOOST_THREAD_RV_REF(invoker) f)
{
f_ = boost::move(BOOST_THREAD_RV(f).f_);
}
BOOST_SYMBOL_VISIBLE
invoker& operator=( BOOST_THREAD_COPY_ASSIGN_REF(invoker) f)
{
f_ = f.f_;
}
result_type operator()()
{
typedef typename make_tuple_indices<1+sizeof...(Args), 1>::type Index;
return execute(Index());
}
private:
template <size_t ...Indices>
result_type
execute(tuple_indices<Indices...>)
{
return invoke(boost::move(csbl::get<0>(f_)), boost::move(csbl::get<Indices>(f_))...);
}
};
template <class R, class Fp, class ... Args>
class invoker_ret
{
//typedef typename decay<Fp>::type Fpd;
//typedef tuple<typename decay<Args>::type...> Argsd;
//csbl::tuple<Fpd, Argsd...> f_;
csbl::tuple<Fp, Args...> f_;
public:
BOOST_THREAD_COPYABLE_AND_MOVABLE( invoker_ret)
typedef R result_type;
template <class F, class ... As>
BOOST_SYMBOL_VISIBLE
explicit invoker_ret(BOOST_THREAD_FWD_REF(F) f, BOOST_THREAD_FWD_REF(As)... args)
: f_(boost::forward<F>(f), boost::forward<As>(args)...)
{}
BOOST_SYMBOL_VISIBLE
invoker_ret(BOOST_THREAD_RV_REF(invoker_ret) f) : f_(boost::move(BOOST_THREAD_RV(f).f_))
{}
result_type operator()()
{
typedef typename make_tuple_indices<1+sizeof...(Args), 1>::type Index;
return execute(Index());
}
private:
template <size_t ...Indices>
result_type
execute(tuple_indices<Indices...>)
{
return invoke<R>(boost::move(csbl::get<0>(f_)), boost::move(csbl::get<Indices>(f_))...);
}
};
//BOOST_THREAD_DCL_MOVABLE_BEG(X) invoker<Fp> BOOST_THREAD_DCL_MOVABLE_END
#else
#if ! defined BOOST_MSVC
#define BOOST_THREAD_RV_REF_ARG_T(z, n, unused) BOOST_PP_COMMA_IF(n) BOOST_THREAD_RV_REF(Arg##n)
#define BOOST_THREAD_RV_REF_A_T(z, n, unused) BOOST_PP_COMMA_IF(n) BOOST_THREAD_RV_REF(A##n)
#define BOOST_THREAD_RV_REF_ARG(z, n, unused) , BOOST_THREAD_RV_REF(Arg##n) arg##n
#define BOOST_THREAD_FWD_REF_A(z, n, unused) , BOOST_THREAD_FWD_REF(A##n) arg##n
#define BOOST_THREAD_FWD_REF_ARG(z, n, unused) , BOOST_THREAD_FWD_REF(Arg##n) arg##n
#define BOOST_THREAD_FWD_PARAM(z, n, unused) , boost::forward<Arg##n>(arg##n)
#define BOOST_THREAD_FWD_PARAM_A(z, n, unused) , boost::forward<A##n>(arg##n)
#define BOOST_THREAD_DCL(z, n, unused) Arg##n v##n;
#define BOOST_THREAD_MOVE_PARAM(z, n, unused) , v##n(boost::move(arg##n))
#define BOOST_THREAD_FORWARD_PARAM_A(z, n, unused) , v##n(boost::forward<A##n>(arg##n))
#define BOOST_THREAD_MOVE_RHS_PARAM(z, n, unused) , v##n(boost::move(x.v##n))
#define BOOST_THREAD_MOVE_DCL(z, n, unused) , boost::move(v##n)
#define BOOST_THREAD_MOVE_DCL_T(z, n, unused) BOOST_PP_COMMA_IF(n) boost::move(v##n)
#define BOOST_THREAD_ARG_DEF(z, n, unused) , class Arg##n = tuples::null_type
template <class Fp, class Arg = tuples::null_type
BOOST_PP_REPEAT(BOOST_THREAD_MAX_ARGS, BOOST_THREAD_ARG_DEF, ~)
>
class invoker;
#define BOOST_THREAD_ASYNC_FUNCT(z, n, unused) \
template <class Fp BOOST_PP_COMMA_IF(n) BOOST_PP_ENUM_PARAMS(n, class Arg) > \
class invoker<Fp BOOST_PP_COMMA_IF(n) BOOST_PP_ENUM_PARAMS(n, Arg)> \
{ \
Fp fp_; \
BOOST_PP_REPEAT(n, BOOST_THREAD_DCL, ~) \
public: \
BOOST_THREAD_COPYABLE_AND_MOVABLE(invoker) \
typedef typename result_of<Fp(BOOST_PP_ENUM_PARAMS(n, Arg))>::type result_type; \
\
template <class F BOOST_PP_COMMA_IF(n) BOOST_PP_ENUM_PARAMS(n, class A) > \
BOOST_SYMBOL_VISIBLE \
explicit invoker(BOOST_THREAD_FWD_REF(F) f \
BOOST_PP_REPEAT(n, BOOST_THREAD_FWD_REF_A, ~) \
) \
: fp_(boost::forward<F>(f)) \
BOOST_PP_REPEAT(n, BOOST_THREAD_FORWARD_PARAM_A, ~) \
{} \
\
BOOST_SYMBOL_VISIBLE \
invoker(BOOST_THREAD_RV_REF(invoker) x) \
: fp_(boost::move(x.fp_)) \
BOOST_PP_REPEAT(n, BOOST_THREAD_MOVE_RHS_PARAM, ~) \
{} \
\
result_type operator()() { \
return invoke(boost::move(fp_) \
BOOST_PP_REPEAT(n, BOOST_THREAD_MOVE_DCL, ~) \
); \
} \
}; \
\
template <class R BOOST_PP_COMMA_IF(n) BOOST_PP_ENUM_PARAMS(n, class Arg) > \
class invoker<R(*)(BOOST_PP_REPEAT(n, BOOST_THREAD_RV_REF_ARG_T, ~)) BOOST_PP_COMMA_IF(n) BOOST_PP_ENUM_PARAMS(n, Arg)> \
{ \
typedef R(*Fp)(BOOST_PP_REPEAT(n, BOOST_THREAD_RV_REF_ARG_T, ~)); \
Fp fp_; \
BOOST_PP_REPEAT(n, BOOST_THREAD_DCL, ~) \
public: \
BOOST_THREAD_COPYABLE_AND_MOVABLE(invoker) \
typedef typename result_of<Fp(BOOST_PP_ENUM_PARAMS(n, Arg))>::type result_type; \
\
template <class R2 BOOST_PP_COMMA_IF(n) BOOST_PP_ENUM_PARAMS(n, class A) > \
BOOST_SYMBOL_VISIBLE \
explicit invoker(R2(*f)(BOOST_PP_REPEAT(n, BOOST_THREAD_RV_REF_A_T, ~)) \
BOOST_PP_REPEAT(n, BOOST_THREAD_FWD_REF_A, ~) \
) \
: fp_(f) \
BOOST_PP_REPEAT(n, BOOST_THREAD_FORWARD_PARAM_A, ~) \
{} \
\
BOOST_SYMBOL_VISIBLE \
invoker(BOOST_THREAD_RV_REF(invoker) x) \
: fp_(x.fp_) \
BOOST_PP_REPEAT(n, BOOST_THREAD_MOVE_RHS_PARAM, ~) \
{} \
\
result_type operator()() { \
return fp_( \
BOOST_PP_REPEAT(n, BOOST_THREAD_MOVE_DCL_T, ~) \
); \
} \
};
BOOST_PP_REPEAT(BOOST_THREAD_MAX_ARGS, BOOST_THREAD_ASYNC_FUNCT, ~)
#undef BOOST_THREAD_RV_REF_ARG_T
#undef BOOST_THREAD_RV_REF_ARG
#undef BOOST_THREAD_FWD_REF_ARG
#undef BOOST_THREAD_FWD_REF_A
#undef BOOST_THREAD_FWD_PARAM
#undef BOOST_THREAD_FWD_PARAM_A
#undef BOOST_THREAD_DCL
#undef BOOST_THREAD_MOVE_PARAM
#undef BOOST_THREAD_MOVE_RHS_PARAM
#undef BOOST_THREAD_MOVE_DCL
#undef BOOST_THREAD_ARG_DEF
#undef BOOST_THREAD_ASYNC_FUNCT
#else
template <class Fp,
class T0 = tuples::null_type, class T1 = tuples::null_type, class T2 = tuples::null_type,
class T3 = tuples::null_type, class T4 = tuples::null_type, class T5 = tuples::null_type,
class T6 = tuples::null_type, class T7 = tuples::null_type, class T8 = tuples::null_type
, class T9 = tuples::null_type
>
class invoker;
template <class Fp,
class T0 , class T1 , class T2 ,
class T3 , class T4 , class T5 ,
class T6 , class T7 , class T8 >
class invoker<Fp, T0, T1, T2, T3, T4, T5, T6, T7, T8>
{
Fp fp_;
T0 v0_;
T1 v1_;
T2 v2_;
T3 v3_;
T4 v4_;
T5 v5_;
T6 v6_;
T7 v7_;
T8 v8_;
//::boost::tuple<Fp, T0, T1, T2, T3, T4, T5, T6, T7, T8> f_;
public:
BOOST_THREAD_COPYABLE_AND_MOVABLE(invoker)
typedef typename result_of<Fp(T0, T1, T2, T3, T4, T5, T6, T7, T8)>::type result_type;
BOOST_SYMBOL_VISIBLE
explicit invoker(BOOST_THREAD_FWD_REF(Fp) f
, BOOST_THREAD_RV_REF(T0) a0
, BOOST_THREAD_RV_REF(T1) a1
, BOOST_THREAD_RV_REF(T2) a2
, BOOST_THREAD_RV_REF(T3) a3
, BOOST_THREAD_RV_REF(T4) a4
, BOOST_THREAD_RV_REF(T5) a5
, BOOST_THREAD_RV_REF(T6) a6
, BOOST_THREAD_RV_REF(T7) a7
, BOOST_THREAD_RV_REF(T8) a8
)
: fp_(boost::move(f))
, v0_(boost::move(a0))
, v1_(boost::move(a1))
, v2_(boost::move(a2))
, v3_(boost::move(a3))
, v4_(boost::move(a4))
, v5_(boost::move(a5))
, v6_(boost::move(a6))
, v7_(boost::move(a7))
, v8_(boost::move(a8))
{}
BOOST_SYMBOL_VISIBLE
invoker(BOOST_THREAD_RV_REF(invoker) f)
: fp_(boost::move(BOOST_THREAD_RV(f).fp))
, v0_(boost::move(BOOST_THREAD_RV(f).v0_))
, v1_(boost::move(BOOST_THREAD_RV(f).v1_))
, v2_(boost::move(BOOST_THREAD_RV(f).v2_))
, v3_(boost::move(BOOST_THREAD_RV(f).v3_))
, v4_(boost::move(BOOST_THREAD_RV(f).v4_))
, v5_(boost::move(BOOST_THREAD_RV(f).v5_))
, v6_(boost::move(BOOST_THREAD_RV(f).v6_))
, v7_(boost::move(BOOST_THREAD_RV(f).v7_))
, v8_(boost::move(BOOST_THREAD_RV(f).v8_))
{}
result_type operator()()
{
return invoke(boost::move(fp_)
, boost::move(v0_)
, boost::move(v1_)
, boost::move(v2_)
, boost::move(v3_)
, boost::move(v4_)
, boost::move(v5_)
, boost::move(v6_)
, boost::move(v7_)
, boost::move(v8_)
);
}
};
template <class Fp, class T0, class T1, class T2, class T3, class T4, class T5, class T6, class T7 >
class invoker<Fp, T0, T1, T2, T3, T4, T5, T6, T7>
{
Fp fp_;
T0 v0_;
T1 v1_;
T2 v2_;
T3 v3_;
T4 v4_;
T5 v5_;
T6 v6_;
T7 v7_;
public:
BOOST_THREAD_COPYABLE_AND_MOVABLE(invoker)
typedef typename result_of<Fp(T0, T1, T2, T3, T4, T5, T6, T7)>::type result_type;
BOOST_SYMBOL_VISIBLE
explicit invoker(BOOST_THREAD_FWD_REF(Fp) f
, BOOST_THREAD_RV_REF(T0) a0
, BOOST_THREAD_RV_REF(T1) a1
, BOOST_THREAD_RV_REF(T2) a2
, BOOST_THREAD_RV_REF(T3) a3
, BOOST_THREAD_RV_REF(T4) a4
, BOOST_THREAD_RV_REF(T5) a5
, BOOST_THREAD_RV_REF(T6) a6
, BOOST_THREAD_RV_REF(T7) a7
)
: fp_(boost::move(f))
, v0_(boost::move(a0))
, v1_(boost::move(a1))
, v2_(boost::move(a2))
, v3_(boost::move(a3))
, v4_(boost::move(a4))
, v5_(boost::move(a5))
, v6_(boost::move(a6))
, v7_(boost::move(a7))
{}
BOOST_SYMBOL_VISIBLE
invoker(BOOST_THREAD_RV_REF(invoker) f)
: fp_(boost::move(BOOST_THREAD_RV(f).fp))
, v0_(boost::move(BOOST_THREAD_RV(f).v0_))
, v1_(boost::move(BOOST_THREAD_RV(f).v1_))
, v2_(boost::move(BOOST_THREAD_RV(f).v2_))
, v3_(boost::move(BOOST_THREAD_RV(f).v3_))
, v4_(boost::move(BOOST_THREAD_RV(f).v4_))
, v5_(boost::move(BOOST_THREAD_RV(f).v5_))
, v6_(boost::move(BOOST_THREAD_RV(f).v6_))
, v7_(boost::move(BOOST_THREAD_RV(f).v7_))
{}
result_type operator()()
{
return invoke(boost::move(fp_)
, boost::move(v0_)
, boost::move(v1_)
, boost::move(v2_)
, boost::move(v3_)
, boost::move(v4_)
, boost::move(v5_)
, boost::move(v6_)
, boost::move(v7_)
);
}
};
template <class Fp, class T0, class T1, class T2, class T3, class T4, class T5, class T6>
class invoker<Fp, T0, T1, T2, T3, T4, T5, T6>
{
Fp fp_;
T0 v0_;
T1 v1_;
T2 v2_;
T3 v3_;
T4 v4_;
T5 v5_;
T6 v6_;
public:
BOOST_THREAD_COPYABLE_AND_MOVABLE(invoker)
typedef typename result_of<Fp(T0, T1, T2, T3, T4, T5, T6)>::type result_type;
BOOST_SYMBOL_VISIBLE
explicit invoker(BOOST_THREAD_FWD_REF(Fp) f
, BOOST_THREAD_RV_REF(T0) a0
, BOOST_THREAD_RV_REF(T1) a1
, BOOST_THREAD_RV_REF(T2) a2
, BOOST_THREAD_RV_REF(T3) a3
, BOOST_THREAD_RV_REF(T4) a4
, BOOST_THREAD_RV_REF(T5) a5
, BOOST_THREAD_RV_REF(T6) a6
)
: fp_(boost::move(f))
, v0_(boost::move(a0))
, v1_(boost::move(a1))
, v2_(boost::move(a2))
, v3_(boost::move(a3))
, v4_(boost::move(a4))
, v5_(boost::move(a5))
, v6_(boost::move(a6))
{}
BOOST_SYMBOL_VISIBLE
invoker(BOOST_THREAD_RV_REF(invoker) f)
: fp_(boost::move(BOOST_THREAD_RV(f).fp))
, v0_(boost::move(BOOST_THREAD_RV(f).v0_))
, v1_(boost::move(BOOST_THREAD_RV(f).v1_))
, v2_(boost::move(BOOST_THREAD_RV(f).v2_))
, v3_(boost::move(BOOST_THREAD_RV(f).v3_))
, v4_(boost::move(BOOST_THREAD_RV(f).v4_))
, v5_(boost::move(BOOST_THREAD_RV(f).v5_))
, v6_(boost::move(BOOST_THREAD_RV(f).v6_))
{}
result_type operator()()
{
return invoke(boost::move(fp_)
, boost::move(v0_)
, boost::move(v1_)
, boost::move(v2_)
, boost::move(v3_)
, boost::move(v4_)
, boost::move(v5_)
, boost::move(v6_)
);
}
};
template <class Fp, class T0, class T1, class T2, class T3, class T4, class T5>
class invoker<Fp, T0, T1, T2, T3, T4, T5>
{
Fp fp_;
T0 v0_;
T1 v1_;
T2 v2_;
T3 v3_;
T4 v4_;
T5 v5_;
public:
BOOST_THREAD_COPYABLE_AND_MOVABLE(invoker)
typedef typename result_of<Fp(T0, T1, T2, T3, T4, T5)>::type result_type;
BOOST_SYMBOL_VISIBLE
explicit invoker(BOOST_THREAD_FWD_REF(Fp) f
, BOOST_THREAD_RV_REF(T0) a0
, BOOST_THREAD_RV_REF(T1) a1
, BOOST_THREAD_RV_REF(T2) a2
, BOOST_THREAD_RV_REF(T3) a3
, BOOST_THREAD_RV_REF(T4) a4
, BOOST_THREAD_RV_REF(T5) a5
)
: fp_(boost::move(f))
, v0_(boost::move(a0))
, v1_(boost::move(a1))
, v2_(boost::move(a2))
, v3_(boost::move(a3))
, v4_(boost::move(a4))
, v5_(boost::move(a5))
{}
BOOST_SYMBOL_VISIBLE
invoker(BOOST_THREAD_RV_REF(invoker) f)
: fp_(boost::move(BOOST_THREAD_RV(f).fp))
, v0_(boost::move(BOOST_THREAD_RV(f).v0_))
, v1_(boost::move(BOOST_THREAD_RV(f).v1_))
, v2_(boost::move(BOOST_THREAD_RV(f).v2_))
, v3_(boost::move(BOOST_THREAD_RV(f).v3_))
, v4_(boost::move(BOOST_THREAD_RV(f).v4_))
, v5_(boost::move(BOOST_THREAD_RV(f).v5_))
{}
result_type operator()()
{
return invoke(boost::move(fp_)
, boost::move(v0_)
, boost::move(v1_)
, boost::move(v2_)
, boost::move(v3_)
, boost::move(v4_)
, boost::move(v5_)
);
}
};
template <class Fp, class T0, class T1, class T2, class T3, class T4>
class invoker<Fp, T0, T1, T2, T3, T4>
{
Fp fp_;
T0 v0_;
T1 v1_;
T2 v2_;
T3 v3_;
T4 v4_;
public:
BOOST_THREAD_COPYABLE_AND_MOVABLE(invoker)
typedef typename result_of<Fp(T0, T1, T2, T3, T4)>::type result_type;
BOOST_SYMBOL_VISIBLE
explicit invoker(BOOST_THREAD_FWD_REF(Fp) f
, BOOST_THREAD_RV_REF(T0) a0
, BOOST_THREAD_RV_REF(T1) a1
, BOOST_THREAD_RV_REF(T2) a2
, BOOST_THREAD_RV_REF(T3) a3
, BOOST_THREAD_RV_REF(T4) a4
)
: fp_(boost::move(f))
, v0_(boost::move(a0))
, v1_(boost::move(a1))
, v2_(boost::move(a2))
, v3_(boost::move(a3))
, v4_(boost::move(a4))
{}
BOOST_SYMBOL_VISIBLE
invoker(BOOST_THREAD_RV_REF(invoker) f)
: fp_(boost::move(BOOST_THREAD_RV(f).fp))
, v0_(boost::move(BOOST_THREAD_RV(f).v0_))
, v1_(boost::move(BOOST_THREAD_RV(f).v1_))
, v2_(boost::move(BOOST_THREAD_RV(f).v2_))
, v3_(boost::move(BOOST_THREAD_RV(f).v3_))
, v4_(boost::move(BOOST_THREAD_RV(f).v4_))
{}
result_type operator()()
{
return invoke(boost::move(fp_)
, boost::move(v0_)
, boost::move(v1_)
, boost::move(v2_)
, boost::move(v3_)
, boost::move(v4_)
);
}
};
template <class Fp, class T0, class T1, class T2, class T3>
class invoker<Fp, T0, T1, T2, T3>
{
Fp fp_;
T0 v0_;
T1 v1_;
T2 v2_;
T3 v3_;
public:
BOOST_THREAD_COPYABLE_AND_MOVABLE(invoker)
typedef typename result_of<Fp(T0, T1, T2, T3)>::type result_type;
BOOST_SYMBOL_VISIBLE
explicit invoker(BOOST_THREAD_FWD_REF(Fp) f
, BOOST_THREAD_RV_REF(T0) a0
, BOOST_THREAD_RV_REF(T1) a1
, BOOST_THREAD_RV_REF(T2) a2
, BOOST_THREAD_RV_REF(T3) a3
)
: fp_(boost::move(f))
, v0_(boost::move(a0))
, v1_(boost::move(a1))
, v2_(boost::move(a2))
, v3_(boost::move(a3))
{}
BOOST_SYMBOL_VISIBLE
invoker(BOOST_THREAD_RV_REF(invoker) f)
: fp_(boost::move(BOOST_THREAD_RV(f).fp))
, v0_(boost::move(BOOST_THREAD_RV(f).v0_))
, v1_(boost::move(BOOST_THREAD_RV(f).v1_))
, v2_(boost::move(BOOST_THREAD_RV(f).v2_))
, v3_(boost::move(BOOST_THREAD_RV(f).v3_))
{}
result_type operator()()
{
return invoke(boost::move(fp_)
, boost::move(v0_)
, boost::move(v1_)
, boost::move(v2_)
, boost::move(v3_)
);
}
};
template <class Fp, class T0, class T1, class T2>
class invoker<Fp, T0, T1, T2>
{
Fp fp_;
T0 v0_;
T1 v1_;
T2 v2_;
public:
BOOST_THREAD_COPYABLE_AND_MOVABLE(invoker)
typedef typename result_of<Fp(T0, T1, T2)>::type result_type;
BOOST_SYMBOL_VISIBLE
explicit invoker(BOOST_THREAD_FWD_REF(Fp) f
, BOOST_THREAD_RV_REF(T0) a0
, BOOST_THREAD_RV_REF(T1) a1
, BOOST_THREAD_RV_REF(T2) a2
)
: fp_(boost::move(f))
, v0_(boost::move(a0))
, v1_(boost::move(a1))
, v2_(boost::move(a2))
{}
BOOST_SYMBOL_VISIBLE
invoker(BOOST_THREAD_RV_REF(invoker) f)
: fp_(boost::move(BOOST_THREAD_RV(f).fp))
, v0_(boost::move(BOOST_THREAD_RV(f).v0_))
, v1_(boost::move(BOOST_THREAD_RV(f).v1_))
, v2_(boost::move(BOOST_THREAD_RV(f).v2_))
{}
result_type operator()()
{
return invoke(boost::move(fp_)
, boost::move(v0_)
, boost::move(v1_)
, boost::move(v2_)
);
}
};
template <class Fp, class T0, class T1>
class invoker<Fp, T0, T1>
{
Fp fp_;
T0 v0_;
T1 v1_;
public:
BOOST_THREAD_COPYABLE_AND_MOVABLE(invoker)
typedef typename result_of<Fp(T0, T1)>::type result_type;
BOOST_SYMBOL_VISIBLE
explicit invoker(BOOST_THREAD_FWD_REF(Fp) f
, BOOST_THREAD_RV_REF(T0) a0
, BOOST_THREAD_RV_REF(T1) a1
)
: fp_(boost::move(f))
, v0_(boost::move(a0))
, v1_(boost::move(a1))
{}
BOOST_SYMBOL_VISIBLE
invoker(BOOST_THREAD_RV_REF(invoker) f)
: fp_(boost::move(BOOST_THREAD_RV(f).fp))
, v0_(boost::move(BOOST_THREAD_RV(f).v0_))
, v1_(boost::move(BOOST_THREAD_RV(f).v1_))
{}
result_type operator()()
{
return invoke(boost::move(fp_)
, boost::move(v0_)
, boost::move(v1_)
);
}
};
template <class Fp, class T0>
class invoker<Fp, T0>
{
Fp fp_;
T0 v0_;
public:
BOOST_THREAD_COPYABLE_AND_MOVABLE(invoker)
typedef typename result_of<Fp(T0)>::type result_type;
BOOST_SYMBOL_VISIBLE
explicit invoker(BOOST_THREAD_FWD_REF(Fp) f
, BOOST_THREAD_RV_REF(T0) a0
)
: fp_(boost::move(f))
, v0_(boost::move(a0))
{}
BOOST_SYMBOL_VISIBLE
invoker(BOOST_THREAD_RV_REF(invoker) f)
: fp_(boost::move(BOOST_THREAD_RV(f).fp))
, v0_(boost::move(BOOST_THREAD_RV(f).v0_))
{}
result_type operator()()
{
return invoke(boost::move(fp_)
, boost::move(v0_)
);
}
};
template <class Fp>
class invoker<Fp>
{
Fp fp_;
public:
BOOST_THREAD_COPYABLE_AND_MOVABLE(invoker)
typedef typename result_of<Fp()>::type result_type;
BOOST_SYMBOL_VISIBLE
explicit invoker(BOOST_THREAD_FWD_REF(Fp) f)
: fp_(boost::move(f))
{}
BOOST_SYMBOL_VISIBLE
invoker(BOOST_THREAD_RV_REF(invoker) f)
: fp_(boost::move(f.fp_))
{}
result_type operator()()
{
return fp_();
}
};
template <class R>
class invoker<R(*)()>
{
typedef R(*Fp)();
Fp fp_;
public:
BOOST_THREAD_COPYABLE_AND_MOVABLE(invoker)
typedef typename result_of<Fp()>::type result_type;
BOOST_SYMBOL_VISIBLE
explicit invoker(Fp f)
: fp_(f)
{}
BOOST_SYMBOL_VISIBLE
invoker(BOOST_THREAD_RV_REF(invoker) f)
: fp_(f.fp_)
{}
result_type operator()()
{
return fp_();
}
};
#endif
#endif
}
}
#include "boost/thread/detail/variadic_footer.hpp"
#endif // header
| [
"git@imoz.jp"
] | git@imoz.jp |
0345fd123e48c903b3108031ae56664aacbf01b6 | c1eee06a18009641bedede321ab63d114d02b463 | /app/src/main/cpp/2d/CCTextFieldTTF.cpp | 06e920208922c657bb21ccffdec10e23f115ac3f | [] | no_license | playbar/glespainting | e1280e277f2a6c4a295d30352478e0e010e3d3d9 | 2cc49965597c089e597350c1673659000ce94e52 | refs/heads/master | 2021-04-06T06:23:10.759182 | 2018-03-19T10:29:18 | 2018-03-19T10:29:18 | 124,718,906 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 19,684 | cpp | /****************************************************************************
Copyright (c) 2010-2012 cocos2d-x.org
Copyright (c) 2013-2016 Chukong Technologies Inc.
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#include "2d/CCTextFieldTTF.h"
#include "base/CCDirector.h"
#include "platform/CCFileUtils.h"
#include "base/ccUTF8.h"
#include "2d/CCSprite.h"
NS_CC_BEGIN
#define CURSOR_TIME_SHOW_HIDE 0.5f
#define CURSOR_DEFAULT_CHAR '|'
#define PASSWORD_STYLE_TEXT_DEFAULT "\xe2\x80\xa2"
static std::size_t _calcCharCount(const char * text)
{
int n = 0;
char ch = 0;
while ((ch = *text))
{
CC_BREAK_IF(! ch);
if (0x80 != (0xC0 & ch))
{
++n;
}
++text;
}
return n;
}
bool TextFieldDelegate::onTextFieldAttachWithIME(TextFieldTTF* /*sender*/)
{
return false;
}
bool TextFieldDelegate::onTextFieldDetachWithIME(TextFieldTTF* /*sender*/)
{
return false;
}
bool TextFieldDelegate::onTextFieldInsertText(TextFieldTTF* /*sender*/, const char* /*text*/, size_t /*nLen*/)
{
return false;
}
bool TextFieldDelegate::onTextFieldDeleteBackward(TextFieldTTF* /*sender*/, const char* /*delText*/, size_t /*nLen*/)
{
return false;
}
bool TextFieldDelegate::onVisit(TextFieldTTF* /*sender*/, CocRenderer* /*renderer*/, const CocMat4& /*transform*/, uint32_t /*flags*/)
{
return false;
}
//////////////////////////////////////////////////////////////////////////
// constructor and destructor
//////////////////////////////////////////////////////////////////////////
TextFieldTTF::TextFieldTTF()
: _delegate(0)
, _charCount(0)
, _inputText("")
, _placeHolder("") // prevent Label initWithString assertion
, _colorText(Color4B::WHITE)
, _secureTextEntry(false)
, _passwordStyleText(PASSWORD_STYLE_TEXT_DEFAULT)
, _cursorEnabled(false)
, _cursorPosition(0)
, _cursorChar(CURSOR_DEFAULT_CHAR)
, _cursorShowingTime(0.0f)
, _isAttachWithIME(false)
{
_colorSpaceHolder.r = _colorSpaceHolder.g = _colorSpaceHolder.b = 127;
_colorSpaceHolder.a = 255;
}
TextFieldTTF::~TextFieldTTF()
{
}
//////////////////////////////////////////////////////////////////////////
// static constructor
//////////////////////////////////////////////////////////////////////////
TextFieldTTF * TextFieldTTF::textFieldWithPlaceHolder(const std::string& placeholder, const Size& dimensions, TextHAlignment alignment, const std::string& fontName, float fontSize)
{
TextFieldTTF *ret = new (std::nothrow) TextFieldTTF();
if(ret && ret->initWithPlaceHolder("", dimensions, alignment, fontName, fontSize))
{
ret->autorelease();
if (placeholder.size()>0)
{
ret->setPlaceHolder(placeholder);
}
return ret;
}
CC_SAFE_DELETE(ret);
return nullptr;
}
TextFieldTTF * TextFieldTTF::textFieldWithPlaceHolder(const std::string& placeholder, const std::string& fontName, float fontSize)
{
TextFieldTTF *ret = new (std::nothrow) TextFieldTTF();
if(ret && ret->initWithPlaceHolder("", fontName, fontSize))
{
ret->autorelease();
if (placeholder.size()>0)
{
ret->setPlaceHolder(placeholder);
}
return ret;
}
CC_SAFE_DELETE(ret);
return nullptr;
}
//////////////////////////////////////////////////////////////////////////
// initialize
//////////////////////////////////////////////////////////////////////////
bool TextFieldTTF::initWithPlaceHolder(const std::string& placeholder, const Size& dimensions, TextHAlignment alignment, const std::string& fontName, float fontSize)
{
setDimensions(dimensions.width, dimensions.height);
setAlignment(alignment, TextVAlignment::CENTER);
return initWithPlaceHolder(placeholder, fontName, fontSize);
}
bool TextFieldTTF::initWithPlaceHolder(const std::string& placeholder, const std::string& fontName, float fontSize)
{
_placeHolder = placeholder;
do
{
// If fontName is ttf file and it corrected, use TTFConfig
if (FileUtils::getInstance()->isFileExist(fontName))
{
TTFConfig ttfConfig(fontName, fontSize, GlyphCollection::DYNAMIC);
if (setTTFConfig(ttfConfig))
{
break;
}
}
setSystemFontName(fontName);
setSystemFontSize(fontSize);
} while (false);
setTextColorInternally(_colorSpaceHolder);
Label::setString(_placeHolder);
#if (CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 || CC_TARGET_PLATFORM == CC_PLATFORM_LINUX)
// On desktop default enable cursor
if (_currentLabelType == LabelType::TTF)
{
setCursorEnabled(true);
}
#endif
return true;
}
//////////////////////////////////////////////////////////////////////////
// IMEDelegate
//////////////////////////////////////////////////////////////////////////
bool TextFieldTTF::attachWithIME()
{
bool ret = IMEDelegate::attachWithIME();
if (ret)
{
// open keyboard
auto pGlView = Director::getInstance()->getOpenGLView();
if (pGlView)
{
pGlView->setIMEKeyboardState(true);
}
}
return ret;
}
bool TextFieldTTF::detachWithIME()
{
bool ret = IMEDelegate::detachWithIME();
if (ret)
{
// close keyboard
auto glView = Director::getInstance()->getOpenGLView();
if (glView)
{
glView->setIMEKeyboardState(false);
}
}
return ret;
}
void TextFieldTTF::didAttachWithIME()
{
setAttachWithIME(true);
}
void TextFieldTTF::didDetachWithIME()
{
setAttachWithIME(false);
}
bool TextFieldTTF::canAttachWithIME()
{
return (_delegate) ? (! _delegate->onTextFieldAttachWithIME(this)) : true;
}
bool TextFieldTTF::canDetachWithIME()
{
return (_delegate) ? (! _delegate->onTextFieldDetachWithIME(this)) : true;
}
void TextFieldTTF::insertText(const char * text, size_t len)
{
std::string insert(text, len);
// insert \n means input end
int pos = static_cast<int>(insert.find((char)TextFormatter::NewLine));
if ((int)insert.npos != pos)
{
len = pos;
insert.erase(pos);
}
if (len > 0)
{
if (_delegate && _delegate->onTextFieldInsertText(this, insert.c_str(), len))
{
// delegate doesn't want to insert text
return;
}
std::size_t countInsertChar = _calcCharCount(insert.c_str());
_charCount += countInsertChar;
if (_cursorEnabled)
{
StringUtils::StringUTF8 stringUTF8;
stringUTF8.replace(_inputText);
stringUTF8.insert(_cursorPosition, insert);
setCursorPosition(_cursorPosition + countInsertChar);
setString(stringUTF8.getAsCharSequence());
}
else
{
std::string sText(_inputText);
sText.append(insert);
setString(sText);
}
}
if ((int)insert.npos == pos) {
return;
}
// '\n' inserted, let delegate process first
if (_delegate && _delegate->onTextFieldInsertText(this, "\n", 1))
{
return;
}
// if delegate hasn't processed, detach from IME by default
detachWithIME();
}
void TextFieldTTF::deleteBackward()
{
size_t len = _inputText.length();
if (! len)
{
// there is no string
return;
}
// get the delete byte number
size_t deleteLen = 1; // default, erase 1 byte
while(0x80 == (0xC0 & _inputText.at(len - deleteLen)))
{
++deleteLen;
}
if (_delegate && _delegate->onTextFieldDeleteBackward(this, _inputText.c_str() + len - deleteLen, static_cast<int>(deleteLen)))
{
// delegate doesn't want to delete backwards
return;
}
// if all text deleted, show placeholder string
if (len <= deleteLen)
{
_inputText = "";
_charCount = 0;
setCursorPosition(0);
setString(_inputText);
return;
}
// set new input text
if (_cursorEnabled)
{
if (_cursorPosition)
{
setCursorPosition(_cursorPosition - 1);
StringUtils::StringUTF8 stringUTF8;
stringUTF8.replace(_inputText);
stringUTF8.deleteChar(_cursorPosition);
_charCount = stringUTF8.length();
setString(stringUTF8.getAsCharSequence());
}
}
else
{
std::string text(_inputText.c_str(), len - deleteLen);
setString(text);
}
}
const std::string& TextFieldTTF::getContentText()
{
return _inputText;
}
void TextFieldTTF::setCursorPosition(std::size_t cursorPosition)
{
if (_cursorEnabled && cursorPosition <= (std::size_t)_charCount)
{
_cursorPosition = cursorPosition;
_cursorShowingTime = CURSOR_TIME_SHOW_HIDE * 2.0f;
}
}
void TextFieldTTF::setCursorFromPoint(const CocVec2 &point, const Camera* camera)
{
if (_cursorEnabled)
{
// Reset Label, no cursor
bool oldIsAttachWithIME = _isAttachWithIME;
_isAttachWithIME = false;
updateCursorDisplayText();
Rect rect;
rect.size = getContentSize();
if (isScreenPointInRect(point, camera, getWorldToNodeTransform(), rect, nullptr))
{
int latterPosition = 0;
for (; latterPosition < _lengthOfString; ++latterPosition)
{
if (_lettersInfo[latterPosition].valid && _lettersInfo[latterPosition].atlasIndex >= 0)
{
auto sprite = getLetter(latterPosition);
if (sprite)
{
rect.size = sprite->getContentSize();
if (isScreenPointInRect(point, camera, sprite->getWorldToNodeTransform(), rect, nullptr))
{
setCursorPosition(latterPosition);
break;
}
}
}
}
if (latterPosition == _lengthOfString)
{
setCursorPosition(latterPosition);
}
}
// Set cursor
_isAttachWithIME = oldIsAttachWithIME;
updateCursorDisplayText();
}
}
void TextFieldTTF::setAttachWithIME(bool isAttachWithIME)
{
if (isAttachWithIME != _isAttachWithIME)
{
_isAttachWithIME = isAttachWithIME;
if (_isAttachWithIME)
{
setCursorPosition(_charCount);
}
updateCursorDisplayText();
}
}
void TextFieldTTF::setTextColorInternally(const Color4B& color)
{
if (_currentLabelType == LabelType::BMFONT) {
Label::setColor(Color3B(color));
return;
}
Label::setTextColor(color);
}
void TextFieldTTF::setTextColor(const Color4B &color)
{
_colorText = color;
if (!_inputText.empty())
{
setTextColorInternally(color);
}
}
void TextFieldTTF::visit(CocRenderer *renderer, const CocMat4 &parentTransform, uint32_t parentFlags)
{
if (_delegate && _delegate->onVisit(this,renderer,parentTransform,parentFlags))
{
return;
}
Label::visit(renderer,parentTransform,parentFlags);
}
void TextFieldTTF::update(float delta)
{
if (_cursorEnabled && _isAttachWithIME)
{
_cursorShowingTime -= delta;
if (_cursorShowingTime < -CURSOR_TIME_SHOW_HIDE)
{
_cursorShowingTime = CURSOR_TIME_SHOW_HIDE;
}
// before cursor inserted '\b', need next letter
auto sprite = getLetter((int)_cursorPosition + 1);
if (sprite)
{
if (_currentLabelType == LabelType::BMFONT) {
sprite->setColor(getColor());
}
if (_cursorShowingTime >= 0.0f)
{
sprite->setOpacity(255);
}
else
{
sprite->setOpacity(0);
}
sprite->setDirty(true);
}
}
}
const Color4B& TextFieldTTF::getColorSpaceHolder()
{
return _colorSpaceHolder;
}
void TextFieldTTF::setColorSpaceHolder(const Color3B& color)
{
setColorSpaceHolder(Color4B(color));
}
void TextFieldTTF::setColorSpaceHolder(const Color4B& color)
{
_colorSpaceHolder = color;
if (_inputText.empty())
{
setTextColorInternally(_colorSpaceHolder);
}
}
//////////////////////////////////////////////////////////////////////////
// properties
//////////////////////////////////////////////////////////////////////////
// input text property
void TextFieldTTF::setString(const std::string &text)
{
std::string displayText;
std::size_t charCount = 0;
if (!text.empty())
{
_inputText = text;
displayText = _inputText;
charCount = _calcCharCount(_inputText.c_str());
if (_secureTextEntry)
{
displayText = "";
size_t length = charCount;
while (length)
{
displayText.append(_passwordStyleText);
--length;
}
}
}
else
{
_inputText = "";
}
if (_cursorEnabled && charCount != _charCount)
{
_cursorPosition = charCount;
}
if (_cursorEnabled)
{
// Need for recreate all letters in Label
Label::removeAllChildrenWithCleanup(false);
}
// if there is no input text, display placeholder instead
if (_inputText.empty() && (!_cursorEnabled || !_isAttachWithIME))
{
setTextColorInternally(_colorSpaceHolder);
Label::setString(_placeHolder);
}
else
{
makeStringSupportCursor(displayText);
setTextColorInternally(_colorText);
Label::setString(displayText);
}
_charCount = charCount;
}
void TextFieldTTF::appendString(const std::string& text)
{
insertText(text.c_str(), text.length());
}
void TextFieldTTF::makeStringSupportCursor(std::string& displayText)
{
if (_cursorEnabled && _isAttachWithIME)
{
if (displayText.empty())
{
// \b - Next char not change x position
if (_currentLabelType == LabelType::TTF || _currentLabelType == LabelType::BMFONT)
displayText.push_back((char) TextFormatter::NextCharNoChangeX);
displayText.push_back(_cursorChar);
}
else
{
StringUtils::StringUTF8 stringUTF8;
stringUTF8.replace(displayText);
if (_cursorPosition > stringUTF8.length())
{
_cursorPosition = stringUTF8.length();
}
std::string cursorChar;
// \b - Next char not change x position
if (_currentLabelType == LabelType::TTF || _currentLabelType == LabelType::BMFONT)
cursorChar.push_back((char)TextFormatter::NextCharNoChangeX);
cursorChar.push_back(_cursorChar);
stringUTF8.insert(_cursorPosition, cursorChar);
displayText = stringUTF8.getAsCharSequence();
}
}
}
void TextFieldTTF::updateCursorDisplayText()
{
// Update Label content
setString(_inputText);
}
void TextFieldTTF::setCursorChar(char cursor)
{
if (_cursorChar != cursor)
{
_cursorChar = cursor;
updateCursorDisplayText();
}
}
void TextFieldTTF::controlKey(EventKeyboard::KeyCode keyCode)
{
if (_cursorEnabled)
{
switch (keyCode)
{
case EventKeyboard::KeyCode::KEY_HOME:
case EventKeyboard::KeyCode::KEY_KP_HOME:
setCursorPosition(0);
updateCursorDisplayText();
break;
case EventKeyboard::KeyCode::KEY_END:
setCursorPosition(_charCount);
updateCursorDisplayText();
break;
case EventKeyboard::KeyCode::KEY_DELETE:
case EventKeyboard::KeyCode::KEY_KP_DELETE:
if (_cursorPosition < (std::size_t)_charCount)
{
StringUtils::StringUTF8 stringUTF8;
stringUTF8.replace(_inputText);
stringUTF8.deleteChar(_cursorPosition);
setCursorPosition(_cursorPosition);
_charCount = stringUTF8.length();
setString(stringUTF8.getAsCharSequence());
}
break;
case EventKeyboard::KeyCode::KEY_LEFT_ARROW:
if (_cursorPosition)
{
setCursorPosition(_cursorPosition - 1);
updateCursorDisplayText();
}
break;
case EventKeyboard::KeyCode::KEY_RIGHT_ARROW:
if (_cursorPosition < (std::size_t)_charCount)
{
setCursorPosition(_cursorPosition + 1);
updateCursorDisplayText();
}
break;
case EventKeyboard::KeyCode::KEY_ESCAPE:
detachWithIME();
break;
default:
break;
}
}
}
const std::string& TextFieldTTF::getString() const
{
return _inputText;
}
// place holder text property
void TextFieldTTF::setPlaceHolder(const std::string& text)
{
_placeHolder = text;
if (_inputText.empty() && !_isAttachWithIME)
{
setTextColorInternally(_colorSpaceHolder);
Label::setString(_placeHolder);
}
}
const std::string& TextFieldTTF::getPlaceHolder() const
{
return _placeHolder;
}
void TextFieldTTF::setCursorEnabled(bool enabled)
{
if (_cursorEnabled == enabled)
{
return;
}
_cursorEnabled = enabled;
if (_cursorEnabled)
{
_cursorPosition = _charCount;
if (_currentLabelType == LabelType::TTF || _currentLabelType == LabelType::BMFONT) {
scheduleUpdate();
}
return;
}
_cursorPosition = 0;
if (_currentLabelType == LabelType::TTF || _currentLabelType == LabelType::BMFONT) {
unscheduleUpdate();
}
}
// secureTextEntry
void TextFieldTTF::setSecureTextEntry(bool value)
{
if (_secureTextEntry != value)
{
_secureTextEntry = value;
setString(_inputText);
}
}
void TextFieldTTF::setPasswordTextStyle(const std::string &text)
{
if (text.length() < 1)
{
return;
}
if (text != _passwordStyleText) {
_passwordStyleText = text;
setString(_inputText);
}
}
const std::string& TextFieldTTF::getPasswordTextStyle() const
{
return _passwordStyleText;
}
bool TextFieldTTF::isSecureTextEntry() const
{
return _secureTextEntry;
}
NS_CC_END
| [
"hgl868@126.com"
] | hgl868@126.com |
5e44bf8715c8074aa7e9da5fc691dad19458f8ca | d428a0c7f06dfcd249bcabb29e570df22d83f944 | /LoRa-Project-Code/Bi-Directional_LED_Toggle/Project_2_One_Master_Multiple_Slave/Slave_1_v0.6_RTX/Slave_1_v0.6_RTX.ino | 3c0d6543327cf2197e4086a12acf86190df92426 | [] | no_license | aidenbarrett/LoRa-Network-Project | 95bd7b0bdaa1212c9ea28d9e89c8d7b6877d0f39 | 50dc4d79375aac9632527c6c4edf074b4323a7c7 | refs/heads/master | 2021-08-17T08:19:17.480891 | 2017-11-21T00:19:13 | 2017-11-21T00:19:13 | 111,477,381 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,538 | ino | #include <OneWire.h>
/* This is Slave One
*/
//Header files
#include <SoftwareSerial.h>
#include "LoraFunctions.h"
#include "SensorFunctions.h"
//<DS18B20>
#include <DallasTemperature.h>
//</DS18B20>
//<DS1620>
#include "ds1620.h"
//</DS1620>
//Main pin definitions
#define LED_PIN 19
#define LED_RTX 12
#define RESET_PIN 14
//<DS18B20>
// Data wire is plugged into pin 0 on the Arduino
#define ONE_WIRE_BUS 2
//</DS18B20>
//Set-up SS with RN2483
SoftwareSerial loraSerial(9, 10); //Rx,Tx
// Setup a oneWire instance to communicate with any OneWire devices
// (not just Maxim/Dallas temperature ICs)
//<DS18B20>
OneWire oneWire(ONE_WIRE_BUS);
// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);
//</DS18B20>
//<DS1620>
Ds1620 ds1620 = Ds1620(5/*rst*/,6/*clk*/,7/*dq*/);
//</DS1620>
//Global variable definitions
String str, res, toRasPi, sampleStr="4d304d304d304d304d304d30", onOffCommand="";
int resInt, theTime, s0Val=0, s1Val=0, s2Val=5;
char onOffCommandChar=' ';
void setup() {
pinMode(LED_PIN, OUTPUT);
pinMode(LED_RTX, OUTPUT);
led_off_rtx();
//Setting RESET PIN of SLAVE RN2483
pinMode(RESET_PIN, INPUT);//Pin 14 is the A0 pin used to reset RN2483
// Open serial communications and wait for PC port to open:
Serial.begin(57600);
while (!Serial) {;}
Serial.println("Initiating SLAVE Lora");
//Initiating SS with SLAVE RN2483 at 57600 bauds
Serial.println("Initiating SLAVE Lora Software Serial");
Serial.println("Wait ...");
loraSerial.begin(57600);
delay(1000);
//Initiating SLAVE RN2483
pinMode(RESET_PIN, OUTPUT);
digitalWrite(RESET_PIN, LOW);
delay(500);
digitalWrite(RESET_PIN, HIGH);
pinMode(RESET_PIN, INPUT);
delay(1000);
Serial.println("Lora initiated...");
Serial.println("");
//Configuring SLAVE RN2483 - pausing mac
loraSerial.println("mac pause");
str = loraSerial.readStringUntil('\n');
Serial.println(str);
//Configuring SLAVE RN2483 - setting frequency
loraSerial.println("radio set freq 866700000");
str = loraSerial.readStringUntil('\n');
Serial.println(str);
//Configuring SLAVE RN2483 - set watchdog timer 0 - endless loop
loraSerial.println("radio set wdt 0");
str = loraSerial.readStringUntil('\n');
Serial.println(str);
Serial.println("starting loop");
//<DS18B20>
// Start up the library
Serial.println("Dallas Temperature IC Control Library Demo");
sensors.begin();
//<DS18B20>
//<DS1620>
// Sets cpu mode as 1 shot
ds1620.config();
//</DS1620>
}
void loop() {
//Variable initialization
res="";
str="";
//Beginning to wait for Master No. + Node No. from MASTER eg. HEX version of M001:1
loraSerial.println("radio rx 0");
led_off_rtx();
str = loraSerial.readStringUntil('\n');
//On successful setting of receiving mode then ...
if (str.indexOf("ok") == 0){
str = String("");
while(str==""){
str = loraSerial.readStringUntil('\n');
}
//On successful receipt of message from MASTER then ...
if ( str.indexOf("radio_rx") == 0 ){
toggle_led();
Serial.print("\n\nSLAVE :\n---> ");
res = str.substring(10); //Extracting received HEX message
Serial.println(res);
onOffCommand = hexStringToString(res);
Serial.println("Received from MASTER "+onOffCommand);
}
else{
Serial.println("Received nothing");
}
}
else{
Serial.println("radio not going into receive mode");
delay(1000);
}
if(onOffCommand.charAt(5)=='1'){ //'1' is the NodeNumber for Slave 1
onOffCommandChar = onOffCommand.charAt(0);
if(onOffCommandChar == 'A') led_on();
if(onOffCommandChar == 'Z') led_off();
//Reading sensor values
led_on_rtx();
//<DS18B20>
sensors.requestTemperatures(); // Send the command to get temperatures
s0Val=(int)sensors.getTempCByIndex(0); // Why "byIndex"?
// You can have more than one IC on the same bus.
// 0 refers to the first IC on the wire
delay(1000);
//s0Val=readSensor0();
//</DS18B20>
//<DS1620>
// Start temperature converion in 1 shot mode
ds1620.start_conv();
// Read the last temperature converson
int raw_data = ds1620.read_data();
// Stop conversion, not really needed since we are in 1 shot mode
ds1620.stop_conv();
s1Val = (int)(raw_data / 2.0);
//s1Val=readSensor1();
//<DS1620>
s2Val=readSensor2();
sampleStr="";
Serial.println("Sending to MASTER "+String(s0Val)+":"+String(s1Val)+":"+String(s2Val)+":");
//Preparing the Data String as 'value1:value2:value3:'
//Then converting it to HEX also to get the HEX Data String which will be transmitted eg. 43:22:56:
//Note the de-limiter is ':' which is "3A" in HEX
sampleStr = intToHexString(s0Val)+stringToHexString(":")+intToHexString(s1Val)+stringToHexString(":")+intToHexString(s2Val)+stringToHexString(":");
loraSerial.print("radio tx "); //Transmitting the HEX Data String eg. HEX version of 43:22:56:
loraSerial.println(sampleStr);
delay(200);
str = loraSerial.readStringUntil('\n');
Serial.println(sampleStr+" --->");
//Serial.println("Tx 1>"+str+':'+sampleStr);
str = loraSerial.readStringUntil('\n');
//Serial.println("Tx 2>"+str);
}
}
void toggle_led(){
digitalWrite(12, !digitalRead(12));
}
void led_on(){
digitalWrite(LED_PIN, 1);
}
void led_off(){
digitalWrite(LED_PIN, 0);
}
void led_on_rtx(){
digitalWrite(LED_RTX, 1);
}
void led_off_rtx(){
digitalWrite(LED_RTX, 0);
}
| [
"Aidenbarrett101@gmail.com"
] | Aidenbarrett101@gmail.com |
9841d9061b0d0cdc357430b221352f30ad9fe1e0 | 7a498696d7ee2e773684eeeb97a9e4badfdf35c8 | /src/perception/sensors/oakd/depthai/depthai-api/shared/3rdparty/dldt/ngraph/src/tools/nbench/nbench.cpp | da34eddf341e77bcdf579ea3a4bf69d18e91ffa3 | [
"Apache-2.0",
"MIT"
] | permissive | jaggiK/cv_visual_assistance | 615df2f8183ab2305b467c7a914a22c0fe8b9421 | a199be9477063ac27c9247afd6521ee5bbbcd53f | refs/heads/master | 2023-05-30T16:20:41.686632 | 2021-06-10T14:48:44 | 2021-06-10T14:48:44 | 357,269,753 | 4 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 16,180 | cpp | //*****************************************************************************
// Copyright 2017-2019 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//*****************************************************************************
// tool to benchmark any ngraph json model with given backend.
// compile and run with:
// $ g++ ./nbench.cpp
// -std=c++11
// -I$HOME/ngraph_dist/include
// -L$HOME/ngraph_dist/lib
// -lngraph
// -o nbench
// $ env LD_LIBRARY_PATH=$HOME/ngraph_dist/lib env NGRAPH_INTERPRETER_EMIT_TIMING=1 ./nbench
// sample models are under ../../test/models
#include <fstream>
#include <iomanip>
#include "benchmark.hpp"
#include "benchmark_pipelined.hpp"
#include "ngraph/distributed.hpp"
#include "ngraph/except.hpp"
#include "ngraph/file_util.hpp"
#include "ngraph/graph_util.hpp"
#include "ngraph/ops.hpp"
#include "ngraph/pass/liveness.hpp"
#include "ngraph/pass/manager.hpp"
#include "ngraph/pass/memory_layout.hpp"
#include "ngraph/pass/visualize_tree.hpp"
#include "ngraph/runtime/backend.hpp"
#include "ngraph/runtime/backend_manager.hpp"
#include "ngraph/runtime/interpreter/int_backend.hpp"
#include "ngraph/serializer.hpp"
#include "ngraph/util.hpp"
using namespace std;
using namespace ngraph;
static void configure_static_backends()
{
#ifdef NGRAPH_INTERPRETER_STATIC_LIB_ENABLE
ngraph::runtime::BackendManager::register_backend(
"INTERPRETER", ngraph::runtime::interpreter::get_backend_constructor_pointer());
#endif
}
class PerfShape : public ngraph::runtime::PerformanceCounter
{
public:
PerfShape(const runtime::PerformanceCounter& p, Shape s)
: PerformanceCounter(p)
, shape(s)
{
}
Shape shape;
};
vector<PerfShape> to_perf_shape(shared_ptr<Function> f,
const vector<runtime::PerformanceCounter>& perf_data)
{
vector<PerfShape> result;
for (const runtime::PerformanceCounter& p : perf_data)
{
auto node = p.get_node();
if (node == nullptr)
{
ostringstream os;
os << "Can't find \"" << node->get_name() << "\" in Function \"" << f->get_name()
<< "\".";
throw runtime_error(os.str());
}
Shape shape = node->output(0).get_shape();
result.push_back(PerfShape(p, shape));
}
return result;
}
multimap<size_t, string> aggregate_timing_details(const vector<PerfShape>& perf_data)
{
unordered_map<string, size_t> timing;
unordered_map<string, size_t> count;
for (const PerfShape& p : perf_data)
{
auto node = p.get_node();
string op = node->description();
string shape_name = " {" + join(p.shape) + "} ";
timing[op + shape_name] += p.microseconds();
count[op + shape_name] += 1;
}
multimap<size_t, string> rc;
for (auto& t : timing)
{
rc.insert({t.second, t.first + to_string(count[t.first])});
}
return rc;
}
multimap<size_t, string> aggregate_timing(const vector<PerfShape>& perf_data)
{
unordered_map<string, size_t> timing;
for (const PerfShape& p : perf_data)
{
auto node = p.get_node();
string op = node->description();
timing[op] += p.microseconds();
}
multimap<size_t, string> rc;
for (auto& t : timing)
{
rc.insert({t.second, t.first});
}
return rc;
}
void print_times(const multimap<size_t, string>& timing)
{
// set the column widths
int name_width = 0;
int time_width = 0;
for (auto& p : timing)
{
name_width = max(name_width, static_cast<int>(p.second.size()));
time_width = max(time_width, static_cast<int>(locale_string(p.first).size()));
}
for (auto it = timing.rbegin(); it != timing.rend(); it++)
{
cout << setw(name_width + 2) << left << it->second << " " << setw(time_width + 2) << right
<< it->first << "us\n";
}
}
void print_results(vector<PerfShape> perf_data, bool timing_detail)
{
sort(perf_data.begin(), perf_data.end(), [](const PerfShape& p1, const PerfShape& p2) {
return p1.total_microseconds() > p2.total_microseconds();
});
multimap<size_t, string> timing = aggregate_timing(perf_data);
multimap<size_t, string> timing_details = aggregate_timing_details(perf_data);
if (timing_detail)
{
cout << "\n---- Aggregate times per op type ----\n";
print_times(timing);
cout << "\n---- Aggregate times per op type/shape/count ----\n";
print_times(timing_details);
}
}
int main(int argc, char** argv)
{
string model_arg;
string backend;
string directory;
int iterations = 10;
bool failed = false;
bool statistics = false;
bool timing_detail = false;
bool visualize = false;
int warmup_iterations = 1;
bool copy_data = true;
bool dot_file = false;
bool double_buffer = false;
configure_static_backends();
for (int i = 1; i < argc; i++)
{
string arg = argv[i];
if (arg == "-f" || arg == "--file")
{
model_arg = argv[++i];
}
else if (arg == "-b" || arg == "--backend")
{
backend = argv[++i];
}
else if (arg == "-i" || arg == "--iterations")
{
try
{
iterations = stoi(argv[++i]);
}
catch (...)
{
cout << "Invalid Argument\n";
failed = true;
}
}
else if (arg == "-s" || arg == "--statistics")
{
statistics = true;
}
else if (arg == "--timing_detail" || arg == "--timing-detail")
{
timing_detail = true;
}
else if (arg == "--no_copy_data")
{
copy_data = false;
}
else if (arg == "-v" || arg == "--visualize")
{
visualize = true;
}
else if (arg == "--dot")
{
dot_file = true;
}
else if (arg == "-d" || arg == "--directory")
{
directory = argv[++i];
}
else if (arg == "--double_buffer")
{
double_buffer = true;
}
else if (arg == "-w" || arg == "--warmup_iterations")
{
try
{
warmup_iterations = stoi(argv[++i]);
}
catch (...)
{
cout << "Invalid Argument\n";
failed = true;
}
}
else
{
cout << "Unknown option: " << arg << endl;
failed = true;
}
}
if (!model_arg.empty() && !file_util::exists(model_arg))
{
cout << "File " << model_arg << " not found\n";
failed = true;
}
else if (!directory.empty() && !file_util::exists(directory))
{
cout << "Directory " << directory << " not found\n";
failed = true;
}
else if (directory.empty() && model_arg.empty())
{
cout << "Either file or directory must be specified\n";
failed = true;
}
if (failed)
{
cout << R"###(
DESCRIPTION
Benchmark nGraph JSON model with given backend.
SYNOPSIS
nbench [-f <filename>] [-b <backend>] [-i <iterations>]
OPTIONS
-f|--file Serialized model file
-b|--backend Backend to use (default: CPU)
-d|--directory Directory to scan for models. All models are benchmarked.
-i|--iterations Iterations (default: 10)
-s|--statistics Display op statistics
-v|--visualize Visualize a model (WARNING: requires Graphviz installed)
--timing_detail Gather detailed timing
-w|--warmup_iterations Number of warm-up iterations
--no_copy_data Disable copy of input/result data every iteration
--dot Generate Graphviz dot file
--double_buffer Double buffer inputs and outputs
)###";
return 1;
}
vector<string> models;
if (!directory.empty())
{
vector<PerfShape> aggregate_perf_data;
file_util::iterate_files(directory,
[&](const string& file, bool is_dir) {
if (!is_dir)
{
models.push_back(file);
}
},
true);
}
else
{
// Error case where model is missing already checked above
models.push_back(model_arg);
}
vector<PerfShape> aggregate_perf_data;
int rc = 0;
for (const string& model : models)
{
cout << "\n";
cout << "============================================================================\n";
cout << "---- Processing '" << model << "'\n";
cout << "============================================================================\n";
try
{
if (visualize)
{
shared_ptr<Function> f = deserialize(model);
auto model_file_name = ngraph::file_util::get_file_name(model) +
(dot_file ? ".dot" : ngraph::file_util::get_file_ext(model));
pass::Manager pass_manager;
pass_manager.register_pass<pass::VisualizeTree>(model_file_name, nullptr, true);
pass_manager.run_passes(f);
}
if (statistics)
{
shared_ptr<Function> f = deserialize(model);
pass::Manager pass_manager;
pass_manager.register_pass<pass::Liveness>();
pass_manager.register_pass<pass::MemoryLayout>();
pass_manager.run_passes(f);
cout << "\n---- Source Graph Statistics ----\n";
cout << "Total nodes: " << locale_string(f->get_ops().size()) << endl;
size_t total_constant_bytes = 0;
size_t total_parameter_bytes = 0;
size_t total_result_bytes = 0;
size_t total_temporary_bytes = 0;
size_t total_constant_count = 0;
size_t total_parameter_count = 0;
size_t total_result_count = 0;
size_t total_temporary_count = 0;
unordered_map<string, size_t> op_list;
set<string> type_list;
for (shared_ptr<Node> node : f->get_ordered_ops())
{
for (auto value : node->outputs())
{
type_list.insert(value.get_element_type().c_type_string());
}
for (descriptor::Tensor* tensor : node->liveness_new_list)
{
total_temporary_bytes += tensor->size();
total_temporary_count++;
}
string op_name = node->description();
string shape_name = "{" + join(node->output(0).get_shape()) + "}";
op_list[op_name + shape_name]++;
if (node->is_constant())
{
total_constant_count++;
const Shape& shape = node->output(0).get_shape();
size_t const_size = node->output(0).get_element_type().size();
if (shape.size() == 0)
{
total_constant_bytes += const_size;
}
else
{
total_constant_bytes +=
(const_size * shape_size(node->output(0).get_shape()));
}
}
else if (node->is_parameter())
{
total_parameter_count++;
const Shape& shape = node->output(0).get_shape();
size_t size = node->output(0).get_element_type().size() * shape_size(shape);
total_parameter_bytes += size;
}
else if (is_type<op::Result>(node))
{
total_result_count++;
const Shape& shape = node->input(0).get_shape();
size_t size = node->input(0).get_element_type().size() * shape_size(shape);
total_result_bytes += size;
}
}
cout << "--\n";
cout << "Total Constant size: " << locale_string(total_constant_bytes)
<< " bytes in " << total_constant_count << " constants\n";
cout << "Total Parameter size: " << locale_string(total_parameter_bytes)
<< " bytes in " << total_parameter_count << " parameters\n";
cout << "Total Result size: " << locale_string(total_result_bytes) << " bytes in "
<< total_result_count << " results\n";
cout << "Total Temporary size: " << locale_string(total_temporary_bytes)
<< " bytes in " << total_temporary_count << " temporaries\n";
cout << "Temporary size with reuse : "
<< locale_string(f->get_temporary_pool_size()) << " bytes\n";
cout << "--\n";
cout << "Types used:\n";
for (const string& type : type_list)
{
cout << " " << type << "\n";
}
cout << "--\n";
for (auto& op_info : op_list)
{
cout << op_info.first << ": " << op_info.second << " ops" << endl;
}
}
if (!backend.empty())
{
cout << "\n---- Benchmark ----\n";
shared_ptr<Function> f = deserialize(model);
vector<runtime::PerformanceCounter> perf_data;
if (double_buffer)
{
perf_data = run_benchmark_pipelined(
f, backend, iterations, timing_detail, warmup_iterations, copy_data);
}
else
{
perf_data = run_benchmark(
f, backend, iterations, timing_detail, warmup_iterations, copy_data);
}
auto perf_shape = to_perf_shape(f, perf_data);
aggregate_perf_data.insert(
aggregate_perf_data.end(), perf_shape.begin(), perf_shape.end());
print_results(perf_shape, timing_detail);
}
}
catch (ngraph::unsupported_op& ue)
{
cout << "Unsupported op '" << ue.what() << "' in model " << model << endl;
rc += 1;
}
catch (exception& e)
{
cout << "Exception caught on '" << model << "'\n" << e.what() << endl;
rc += 1;
}
}
if (models.size() > 1)
{
cout << "\n";
cout << "============================================================================\n";
cout << "---- Aggregate over all models\n";
cout << "============================================================================\n";
print_results(aggregate_perf_data, timing_detail);
}
return rc;
}
| [
"jagadishkmahendran@gmail.com"
] | jagadishkmahendran@gmail.com |
be7acd071ec6a5c7f7568dae938e866494f3376e | 0379dd91363f38d8637ff242c1ce5d3595c9b549 | /windows_10_shared_source_kit/windows_10_shared_source_kit/unknown_version_2/Source/Tests/Graphics/Graphics/DirectX/Common/WGFTestFramework/AddOns/CustomTestApp/CustomTestApp.inl | 7e9e2cda216adcfbd9ed4c9b87b53c6e1d4ebce6 | [] | no_license | zhanglGitHub/windows_10_shared_source_kit | 14f25e6fff898733892d0b5cc23b2b88b04458d9 | 6784379b0023185027894efe6b97afee24ca77e0 | refs/heads/master | 2023-03-21T05:04:08.653859 | 2020-09-28T16:44:54 | 2020-09-28T16:44:54 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 11,461 | inl | //////////////////////////////////////////////////////////////////////
// File: CustomTestApp.inl
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// Purpose:
// Implementation of custom test app object.
//
// History:
// 10 Mar 2006 SEdmison Factored from other tests into a shared lib.
//////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
//
// Constants
//
/////////////////////////////////////////////////////////////////
EXTERN_C const GUID FAR GUID_VIDEO_SUBGROUP;
EXTERN_C const GUID FAR GUID_VIDEO_POWERDOWN_TIMEOUT;
/////////////////////////////////////////////////////////////////
//
// Implementation
//
/////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////
// Function: CMyTestApp
//
// Purpose:
// Constructor.
///////////////////////////////////////////////////////
template < typename ParentClass >
CCustomTestApp< ParentClass >::CCustomTestApp< ParentClass >()
:
m_OriginalForegroundWindowLockTimeout( 0 ),
m_bCompositionUIValueFound( FALSE ),
m_CompositionUIValue( 0 )
{
};
///////////////////////////////////////////////////////
// Function: Setup
//
// Purpose:
// Performs app-wide initialization.
///////////////////////////////////////////////////////
template < typename ParentClass >
bool CCustomTestApp< ParentClass >::Setup()
{
//
// Initialize locals.
//
bool bOverallResult = false;
//
// Turn off DWM composition UI, which otherwise would jump up
// at inopportune times, thus stealing the foreground from the
// windows created by our tests.
//
// warning 28931: Unused assignment of variable hToggleCompositionUIResult
HRESULT hToggleCompositionUIResult = ToggleDWMCompositionUI( FALSE );
if (FAILED(hToggleCompositionUIResult))
{
WriteToLog
(
_T( "Setup: ToggleDWMCompositionUI( FALSE ) failed." )
);
goto Cleanup;
}
//
// Enable the system shutdown privilege.
//
HRESULT hEnableShutdownResult = EnablePrivilege( SE_SHUTDOWN_NAME );
if ( FAILED( hEnableShutdownResult ) )
{
WriteToLog
(
_T( "Setup: EnablePrivilege( SE_SHUTDOWN_NAME ) failed." )
);
goto Cleanup;
};
//
// Retrieve the original foreground lock timeout.
//
SystemParametersInfo
(
SPI_GETFOREGROUNDLOCKTIMEOUT,
0,
&m_OriginalForegroundWindowLockTimeout,
0
);
//
// Override that timeout with zero to unlock the foreground
// window (meaning that we can freely SetForegroundWindow).
//
BOOL bOverrideForegroundTimeoutResult = SystemParametersInfo
(
SPI_SETFOREGROUNDLOCKTIMEOUT,
0,
NULL,
SPIF_SENDWININICHANGE | SPIF_UPDATEINIFILE
);
if ( bOverrideForegroundTimeoutResult != TRUE )
{
DWORD OverrideForegroundTimeoutResult = GetLastError();
WriteToLogF
(
_T( "Setup: SystemParametersInfo( SPI_SETFOREGROUNDLOCKTIMEOUT ) ")
_T( "failed with error %u. This may mean that the test is" )
_T( "occluded by another window, and may cause failures." ),
OverrideForegroundTimeoutResult
);
//goto Cleanup;
};
bOverallResult = true;
Cleanup:
return bOverallResult;
};
///////////////////////////////////////////////////////
// Function: Cleanup
//
// Purpose:
// Application-wide cleanup.
///////////////////////////////////////////////////////
template < typename ParentClass >
void CCustomTestApp< ParentClass >::Cleanup()
{
//
// Restore the original foreground window lock timeout.
//
SystemParametersInfo
(
SPI_SETFOREGROUNDLOCKTIMEOUT,
0,
(PVOID) (DWORD_PTR) m_OriginalForegroundWindowLockTimeout,
SPIF_SENDWININICHANGE | SPIF_UPDATEINIFILE
);
//
// Restore prior DWM composition UI setting.
//
/* HRESULT hToggleCompositionUIResult = */ ToggleDWMCompositionUI( TRUE );
};
///////////////////////////////////////////////////////
// Function: EnablePrivilege
//
// Purpose:
// Asserts the specified security privilege for the
// process.
///////////////////////////////////////////////////////
template < typename ParentClass >
HRESULT CCustomTestApp< ParentClass >::EnablePrivilege
(
IN LPCTSTR PrivilegeName
)
{
//
// Validate parameters.
//
if ( PrivilegeName == NULL )
{
return E_INVALIDARG;
};
//
// Open the process token.
//
HANDLE hToken = NULL;
BOOL bOpenTokenResult = OpenProcessToken
(
GetCurrentProcess(),
TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY,
&hToken
);
if
(
bOpenTokenResult != TRUE ||
hToken == NULL ||
hToken == INVALID_HANDLE_VALUE
)
{
return HRESULT_FROM_WIN32( GetLastError() );
};
TOKEN_PRIVILEGES tkp; // pointer to token structure
ZeroMemory( &tkp, sizeof( tkp ) );
//
// Lookup the shutdown privilege.
//
LookupPrivilegeValue
(
NULL,
PrivilegeName,
&tkp.Privileges[0].Luid
);
tkp.PrivilegeCount = 1;
tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
//
// Enable the privilege for the process.
//
BOOL bAdjustPrivilegesResult = AdjustTokenPrivileges
(
hToken,
FALSE,
&tkp,
sizeof( tkp ),
(PTOKEN_PRIVILEGES) NULL,
0
);
if ( bAdjustPrivilegesResult != TRUE )
{
DWORD AdjustPrivilegesError = GetLastError();
if ( AdjustPrivilegesError != ERROR_SUCCESS )
{
return HRESULT_FROM_WIN32( AdjustPrivilegesError );
};
};
return S_OK;
};
///////////////////////////////////////////////////////
// Function: ToggleDWMCompositionUI
//
// Purpose:
// Disables or restores DWM composition UI via a
// registry hack.
///////////////////////////////////////////////////////
template < typename ParentClass >
HRESULT CCustomTestApp< ParentClass >::ToggleDWMCompositionUI
(
IN BOOL bRestore
)
{
HRESULT hOverallResult = E_FAIL;
//
// Open or create the parent registry key.
//
HKEY hParentKey = NULL;
LONG CreateParentKeyResult = RegCreateKeyEx
(
HKEY_CURRENT_USER,
_T( "Software\\Microsoft\\Windows\\DWM" ),
0,
NULL,
0,
KEY_READ | KEY_WRITE,
NULL,
&hParentKey,
NULL
);
if ( CreateParentKeyResult != ERROR_SUCCESS )
{
hOverallResult = HRESULT_FROM_WIN32( CreateParentKeyResult );
goto Cleanup;
};
//
// Set the value thus suppressing the behavior, or restore
// the system to its prior state.
//
// If we're restoring the state of the system...
if ( bRestore == TRUE )
{
// ...and the value wasn't set originally...
if ( m_bCompositionUIValueFound == FALSE )
{
// ...then delete it...
/*
WriteToLog
(
_T( "ToggleDWMCompositionUI: Removing SuppressDisableCompositionUI value from the registry." )
);
*/
LONG DeleteValueResult = RegDeleteValue
(
hParentKey,
_T( "SuppressDisableCompositionUI" )
);
if ( DeleteValueResult != ERROR_SUCCESS )
{
hOverallResult = HRESULT_FROM_WIN32( DeleteValueResult );
goto Cleanup;
};
}
// ...otherwise, it was set, ...
else
{
// ...so restore it to its original value...
/*
WriteToLogF
(
_T( "ToggleDWMCompositionUI: Restoring SuppressDisableCompositionUI value to %u in the registry." ),
m_CompositionUIValue
);
*/
LONG SetValueResult = RegSetValueEx
(
hParentKey,
_T( "SuppressDisableCompositionUI" ),
0,
REG_DWORD,
(LPBYTE) &m_CompositionUIValue,
sizeof( m_CompositionUIValue )
);
if ( SetValueResult != ERROR_SUCCESS )
{
hOverallResult = HRESULT_FROM_WIN32( SetValueResult );
goto Cleanup;
};
};
}
// ...otherwise, if we're overriding the state of the system...
else
{
// ...then query the value...
DWORD ValueType = REG_DWORD;
DWORD ValueSize = sizeof( DWORD );
LONG QueryValueResult = RegQueryValueEx
(
hParentKey,
_T( "SuppressDisableCompositionUI" ),
NULL,
&ValueType,
(LPBYTE) &m_CompositionUIValue,
&ValueSize
);
// ...and if we found it...
if ( QueryValueResult == ERROR_SUCCESS )
{
// ...then sanity-check it...
assert( ValueType == REG_DWORD );
assert( ValueSize == sizeof( DWORD ) );
// ...and stash it for restoration at cleanup time...
m_bCompositionUIValueFound = TRUE;
}
else
{
// ...otherwise, make a note that we didn't find it.
m_bCompositionUIValueFound = FALSE;
};
//
// Override the value.
//
/*
WriteToLog
(
_T( "ToggleDWMCompositionUI: Overriding SuppressDisableCompositionUI value in the registry." )
);
*/
DWORD OverrideData = 1;
LONG SetValueResult = RegSetValueEx
(
hParentKey,
_T( "SuppressDisableCompositionUI" ),
0,
REG_DWORD,
(LPBYTE) &OverrideData,
sizeof( OverrideData )
);
if ( SetValueResult != ERROR_SUCCESS )
{
hOverallResult = HRESULT_FROM_WIN32( SetValueResult );
goto Cleanup;
};
};
//
// If we made it this far, then we're good to go.
//
hOverallResult = S_OK;
Cleanup:
//
// Close the parent key.
//
if ( hParentKey != NULL )
{
RegCloseKey( hParentKey );
hParentKey = NULL;
};
return hOverallResult;
};
///////////////////////////////////////////////////////
// Function: DetectDriverModelForDevice
//
// Purpose:
// Determines whether the specified device supports the
// Longhorn device driver model (LDDM).
//
// Returns:
// DRIVERMODEL_XPDM for Windows XP devices
// DRIVERMODEL_LDDM for Longhorn (LDDM) devices
///////////////////////////////////////////////////////
template < typename ParentClass >
DRIVERMODEL CCustomTestApp< ParentClass >::DetectDriverModelForDevice
(
IN LPCWSTR pDeviceName
)
{
DRIVERMODEL DriverModel = DRIVERMODEL_XPDM;
HMODULE hGDI = NULL;
HDC hDC = NULL;
if ( pDeviceName != NULL )
{
hDC = CreateDCW
(
pDeviceName,
NULL,
NULL,
NULL
);
}
else
{
hDC = CreateDCW
(
L"DISPLAY",
NULL,
NULL,
NULL
);
};
if ( hDC == NULL )
{
goto Cleanup;
};
//
// Load GDI.
//
hGDI = LoadLibrary(_T("gdi32.dll"));
if ( hGDI == NULL )
{
goto Cleanup;
};
//
// Get pointers to our GDI kernel-mode thunks.
//
PFND3DKMT_OPENADAPTERFROMHDC pfnOsThunkDDIOpenAdapterFromHdc = (PFND3DKMT_OPENADAPTERFROMHDC)GetProcAddress
(
hGDI,
"D3DKMTOpenAdapterFromHdc"
);
if (pfnOsThunkDDIOpenAdapterFromHdc == NULL)
{
goto Cleanup;
};
PFND3DKMT_CLOSEADAPTER pfnOsThunkDDICloseAdapter = (PFND3DKMT_CLOSEADAPTER)GetProcAddress
(
hGDI,
"D3DKMTCloseAdapter"
);
if (pfnOsThunkDDICloseAdapter == NULL)
{
goto Cleanup;
};
//
// Open the adapter.
//
D3DKMT_OPENADAPTERFROMHDC OpenAdapterFromHdc;
OpenAdapterFromHdc.hDc = hDC;
if
(
(*pfnOsThunkDDIOpenAdapterFromHdc)(&OpenAdapterFromHdc) != STATUS_SUCCESS
)
{
goto Cleanup;
};
//
// Close the adapter.
//
D3DKMT_CLOSEADAPTER CloseAdapter;
CloseAdapter.hAdapter = OpenAdapterFromHdc.hAdapter;
(*pfnOsThunkDDICloseAdapter)(&CloseAdapter);
DriverModel = DRIVERMODEL_LDDM;
Cleanup:
if ( hDC != NULL )
{
DeleteDC( hDC );
hDC = NULL;
};
if ( hGDI != NULL )
{
FreeLibrary( hGDI );
hGDI = NULL;
};
return DriverModel;
};
| [
"benjamin.barratt@icloud.com"
] | benjamin.barratt@icloud.com |
a183e988c888b78d44ab98fe210e8c9ca7a2317c | f2574b2f053b6faa4b6d4fc75bef389e83132c33 | /ntl/stlx/ext/pp/macro_repeat.hxx | efb74ead94b8f6967b6aecbe0175647c630cdc5e | [
"Zlib",
"LicenseRef-scancode-stlport-4.5"
] | permissive | icestudent/ontl | a0a391b06b55ef45f496021614cf0b9df318e7a6 | 6ed48916bbc8323776c710f393c853ee94cb97de | refs/heads/master | 2022-05-15T21:45:29.063446 | 2022-05-04T03:51:02 | 2022-05-04T11:18:20 | 15,104,848 | 46 | 13 | null | 2022-05-04T11:18:20 | 2013-12-11T10:45:04 | C++ | UTF-8 | C++ | false | false | 54,789 | hxx | // macro_repeat.hpp
//
// Copyright (c) 2003 Eugene Gladyshev
//
// Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all copies.
// This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose.
//
#ifndef __ttl_macro_repeat__hpp
#define __ttl_macro_repeat__hpp
#pragma once
#include "macro_counter.hxx"
#define TTL_REPEAT_0(m,l,p)
#define TTL_REPEAT_1(m,l,p) TTL_REPEAT_0(m,l,p) m(1,p)
#define TTL_REPEAT_2(m,l,p) TTL_REPEAT_1(m,l,p) m(2,p)
#define TTL_REPEAT_3(m,l,p) TTL_REPEAT_2(m,l,p) m(3,p)
#define TTL_REPEAT_4(m,l,p) TTL_REPEAT_3(m,l,p) m(4,p)
#define TTL_REPEAT_5(m,l,p) TTL_REPEAT_4(m,l,p) m(5,p)
#define TTL_REPEAT_6(m,l,p) TTL_REPEAT_5(m,l,p) m(6,p)
#define TTL_REPEAT_7(m,l,p) TTL_REPEAT_6(m,l,p) m(7,p)
#define TTL_REPEAT_8(m,l,p) TTL_REPEAT_7(m,l,p) m(8,p)
#define TTL_REPEAT_9(m,l,p) TTL_REPEAT_8(m,l,p) m(9,p)
#define TTL_REPEAT_10(m,l,p) TTL_REPEAT_9(m,l,p) m(10,p)
#define TTL_REPEAT_11(m,l,p) TTL_REPEAT_10(m,l,p) m(11,p)
#define TTL_REPEAT_12(m,l,p) TTL_REPEAT_11(m,l,p) m(12,p)
#define TTL_REPEAT_13(m,l,p) TTL_REPEAT_12(m,l,p) m(13,p)
#define TTL_REPEAT_14(m,l,p) TTL_REPEAT_13(m,l,p) m(14,p)
#define TTL_REPEAT_15(m,l,p) TTL_REPEAT_14(m,l,p) m(15,p)
#define TTL_REPEAT_16(m,l,p) TTL_REPEAT_15(m,l,p) m(16,p)
#define TTL_REPEAT_17(m,l,p) TTL_REPEAT_16(m,l,p) m(17,p)
#define TTL_REPEAT_18(m,l,p) TTL_REPEAT_17(m,l,p) m(18,p)
#define TTL_REPEAT_19(m,l,p) TTL_REPEAT_18(m,l,p) m(19,p)
#define TTL_REPEAT_20(m,l,p) TTL_REPEAT_19(m,l,p) m(20,p)
#define TTL_REPEAT_21(m,l,p) TTL_REPEAT_20(m,l,p) m(21,p)
#define TTL_REPEAT_22(m,l,p) TTL_REPEAT_21(m,l,p) m(22,p)
#define TTL_REPEAT_23(m,l,p) TTL_REPEAT_22(m,l,p) m(23,p)
#define TTL_REPEAT_24(m,l,p) TTL_REPEAT_23(m,l,p) m(24,p)
#define TTL_REPEAT_25(m,l,p) TTL_REPEAT_24(m,l,p) m(25,p)
#define TTL_REPEAT_26(m,l,p) TTL_REPEAT_25(m,l,p) m(26,p)
#define TTL_REPEAT_27(m,l,p) TTL_REPEAT_26(m,l,p) m(27,p)
#define TTL_REPEAT_28(m,l,p) TTL_REPEAT_27(m,l,p) m(28,p)
#define TTL_REPEAT_29(m,l,p) TTL_REPEAT_28(m,l,p) m(29,p)
#define TTL_REPEAT_30(m,l,p) TTL_REPEAT_29(m,l,p) m(30,p)
#define TTL_REPEAT_31(m,l,p) TTL_REPEAT_30(m,l,p) m(31,p)
#define TTL_REPEAT_32(m,l,p) TTL_REPEAT_31(m,l,p) m(32,p)
#define TTL_REPEAT_33(m,l,p) TTL_REPEAT_32(m,l,p) m(33,p)
#define TTL_REPEAT_34(m,l,p) TTL_REPEAT_33(m,l,p) m(34,p)
#define TTL_REPEAT_35(m,l,p) TTL_REPEAT_34(m,l,p) m(35,p)
#define TTL_REPEAT_36(m,l,p) TTL_REPEAT_35(m,l,p) m(36,p)
#define TTL_REPEAT_37(m,l,p) TTL_REPEAT_36(m,l,p) m(37,p)
#define TTL_REPEAT_38(m,l,p) TTL_REPEAT_37(m,l,p) m(38,p)
#define TTL_REPEAT_39(m,l,p) TTL_REPEAT_38(m,l,p) m(39,p)
#define TTL_REPEAT_40(m,l,p) TTL_REPEAT_39(m,l,p) m(40,p)
#define TTL_REPEAT_41(m,l,p) TTL_REPEAT_40(m,l,p) m(41,p)
#define TTL_REPEAT_42(m,l,p) TTL_REPEAT_41(m,l,p) m(42,p)
#define TTL_REPEAT_43(m,l,p) TTL_REPEAT_42(m,l,p) m(43,p)
#define TTL_REPEAT_44(m,l,p) TTL_REPEAT_43(m,l,p) m(44,p)
#define TTL_REPEAT_45(m,l,p) TTL_REPEAT_44(m,l,p) m(45,p)
#define TTL_REPEAT_46(m,l,p) TTL_REPEAT_45(m,l,p) m(46,p)
#define TTL_REPEAT_47(m,l,p) TTL_REPEAT_46(m,l,p) m(47,p)
#define TTL_REPEAT_48(m,l,p) TTL_REPEAT_47(m,l,p) m(48,p)
#define TTL_REPEAT_49(m,l,p) TTL_REPEAT_48(m,l,p) m(49,p)
#define TTL_REPEAT_50(m,l,p) TTL_REPEAT_49(m,l,p) m(50,p)
#define TTL_REPEAT_51(m,l,p) TTL_REPEAT_50(m,l,p) m(51,p)
#define TTL_REPEAT_52(m,l,p) TTL_REPEAT_51(m,l,p) m(52,p)
#define TTL_REPEAT_53(m,l,p) TTL_REPEAT_52(m,l,p) m(53,p)
#define TTL_REPEAT_54(m,l,p) TTL_REPEAT_53(m,l,p) m(54,p)
#define TTL_REPEAT_55(m,l,p) TTL_REPEAT_54(m,l,p) m(55,p)
#define TTL_REPEAT_56(m,l,p) TTL_REPEAT_55(m,l,p) m(56,p)
#define TTL_REPEAT_57(m,l,p) TTL_REPEAT_56(m,l,p) m(57,p)
#define TTL_REPEAT_58(m,l,p) TTL_REPEAT_57(m,l,p) m(58,p)
#define TTL_REPEAT_59(m,l,p) TTL_REPEAT_58(m,l,p) m(59,p)
#define TTL_REPEAT_60(m,l,p) TTL_REPEAT_59(m,l,p) m(60,p)
#define TTL_REPEAT_61(m,l,p) TTL_REPEAT_60(m,l,p) m(61,p)
#define TTL_REPEAT_62(m,l,p) TTL_REPEAT_61(m,l,p) m(62,p)
#define TTL_REPEAT_63(m,l,p) TTL_REPEAT_62(m,l,p) m(63,p)
#define TTL_REPEAT_64(m,l,p) TTL_REPEAT_63(m,l,p) m(64,p)
#define TTL_REPEAT_65(m,l,p) TTL_REPEAT_64(m,l,p) m(65,p)
#define TTL_REPEAT_66(m,l,p) TTL_REPEAT_65(m,l,p) m(66,p)
#define TTL_REPEAT_67(m,l,p) TTL_REPEAT_66(m,l,p) m(67,p)
#define TTL_REPEAT_68(m,l,p) TTL_REPEAT_67(m,l,p) m(68,p)
#define TTL_REPEAT_69(m,l,p) TTL_REPEAT_68(m,l,p) m(69,p)
#define TTL_REPEAT_70(m,l,p) TTL_REPEAT_69(m,l,p) m(70,p)
#define TTL_REPEAT_71(m,l,p) TTL_REPEAT_70(m,l,p) m(71,p)
#define TTL_REPEAT_72(m,l,p) TTL_REPEAT_71(m,l,p) m(72,p)
#define TTL_REPEAT_73(m,l,p) TTL_REPEAT_72(m,l,p) m(73,p)
#define TTL_REPEAT_74(m,l,p) TTL_REPEAT_73(m,l,p) m(74,p)
#define TTL_REPEAT_75(m,l,p) TTL_REPEAT_74(m,l,p) m(75,p)
#define TTL_REPEAT_76(m,l,p) TTL_REPEAT_75(m,l,p) m(76,p)
#define TTL_REPEAT_77(m,l,p) TTL_REPEAT_76(m,l,p) m(77,p)
#define TTL_REPEAT_78(m,l,p) TTL_REPEAT_77(m,l,p) m(78,p)
#define TTL_REPEAT_79(m,l,p) TTL_REPEAT_78(m,l,p) m(79,p)
#define TTL_REPEAT_80(m,l,p) TTL_REPEAT_79(m,l,p) m(80,p)
#define TTL_REPEAT_81(m,l,p) TTL_REPEAT_80(m,l,p) m(81,p)
#define TTL_REPEAT_82(m,l,p) TTL_REPEAT_81(m,l,p) m(82,p)
#define TTL_REPEAT_83(m,l,p) TTL_REPEAT_82(m,l,p) m(83,p)
#define TTL_REPEAT_84(m,l,p) TTL_REPEAT_83(m,l,p) m(84,p)
#define TTL_REPEAT_85(m,l,p) TTL_REPEAT_84(m,l,p) m(85,p)
#define TTL_REPEAT_86(m,l,p) TTL_REPEAT_85(m,l,p) m(86,p)
#define TTL_REPEAT_87(m,l,p) TTL_REPEAT_86(m,l,p) m(87,p)
#define TTL_REPEAT_88(m,l,p) TTL_REPEAT_87(m,l,p) m(88,p)
#define TTL_REPEAT_89(m,l,p) TTL_REPEAT_88(m,l,p) m(89,p)
#define TTL_REPEAT_90(m,l,p) TTL_REPEAT_89(m,l,p) m(90,p)
#define TTL_REPEAT_91(m,l,p) TTL_REPEAT_90(m,l,p) m(91,p)
#define TTL_REPEAT_92(m,l,p) TTL_REPEAT_91(m,l,p) m(92,p)
#define TTL_REPEAT_93(m,l,p) TTL_REPEAT_92(m,l,p) m(93,p)
#define TTL_REPEAT_94(m,l,p) TTL_REPEAT_93(m,l,p) m(94,p)
#define TTL_REPEAT_95(m,l,p) TTL_REPEAT_94(m,l,p) m(95,p)
#define TTL_REPEAT_96(m,l,p) TTL_REPEAT_95(m,l,p) m(96,p)
#define TTL_REPEAT_97(m,l,p) TTL_REPEAT_96(m,l,p) m(97,p)
#define TTL_REPEAT_98(m,l,p) TTL_REPEAT_97(m,l,p) m(98,p)
#define TTL_REPEAT_99(m,l,p) TTL_REPEAT_98(m,l,p) m(99,p)
#define TTL_REPEAT_100(m,l,p) TTL_REPEAT_99(m,l,p) m(100,p)
#define TTL_REPEAT_101(m,l,p) TTL_REPEAT_100(m,l,p) m(101,p)
#define TTL_REPEAT_102(m,l,p) TTL_REPEAT_101(m,l,p) m(102,p)
#define TTL_REPEAT_103(m,l,p) TTL_REPEAT_102(m,l,p) m(103,p)
#define TTL_REPEAT_104(m,l,p) TTL_REPEAT_103(m,l,p) m(104,p)
#define TTL_REPEAT_105(m,l,p) TTL_REPEAT_104(m,l,p) m(105,p)
#define TTL_REPEAT_106(m,l,p) TTL_REPEAT_105(m,l,p) m(106,p)
#define TTL_REPEAT_107(m,l,p) TTL_REPEAT_106(m,l,p) m(107,p)
#define TTL_REPEAT_108(m,l,p) TTL_REPEAT_107(m,l,p) m(108,p)
#define TTL_REPEAT_109(m,l,p) TTL_REPEAT_108(m,l,p) m(109,p)
#define TTL_REPEAT_110(m,l,p) TTL_REPEAT_109(m,l,p) m(110,p)
#define TTL_REPEAT_111(m,l,p) TTL_REPEAT_110(m,l,p) m(111,p)
#define TTL_REPEAT_112(m,l,p) TTL_REPEAT_111(m,l,p) m(112,p)
#define TTL_REPEAT_113(m,l,p) TTL_REPEAT_112(m,l,p) m(113,p)
#define TTL_REPEAT_114(m,l,p) TTL_REPEAT_113(m,l,p) m(114,p)
#define TTL_REPEAT_115(m,l,p) TTL_REPEAT_114(m,l,p) m(115,p)
#define TTL_REPEAT_116(m,l,p) TTL_REPEAT_115(m,l,p) m(116,p)
#define TTL_REPEAT_117(m,l,p) TTL_REPEAT_116(m,l,p) m(117,p)
#define TTL_REPEAT_118(m,l,p) TTL_REPEAT_117(m,l,p) m(118,p)
#define TTL_REPEAT_119(m,l,p) TTL_REPEAT_118(m,l,p) m(119,p)
#define TTL_REPEAT_120(m,l,p) TTL_REPEAT_119(m,l,p) m(120,p)
#define TTL_REPEAT_121(m,l,p) TTL_REPEAT_120(m,l,p) m(121,p)
#define TTL_REPEAT_122(m,l,p) TTL_REPEAT_121(m,l,p) m(122,p)
#define TTL_REPEAT_123(m,l,p) TTL_REPEAT_122(m,l,p) m(123,p)
#define TTL_REPEAT_124(m,l,p) TTL_REPEAT_123(m,l,p) m(124,p)
#define TTL_REPEAT_125(m,l,p) TTL_REPEAT_124(m,l,p) m(125,p)
#define TTL_REPEAT_126(m,l,p) TTL_REPEAT_125(m,l,p) m(126,p)
#define TTL_REPEAT_127(m,l,p) TTL_REPEAT_126(m,l,p) m(127,p)
#define TTL_REPEAT_128(m,l,p) TTL_REPEAT_127(m,l,p) m(128,p)
#define TTL_REPEAT_129(m,l,p) TTL_REPEAT_128(m,l,p) m(129,p)
#define TTL_REPEAT_130(m,l,p) TTL_REPEAT_129(m,l,p) m(130,p)
#define TTL_REPEAT_131(m,l,p) TTL_REPEAT_130(m,l,p) m(131,p)
#define TTL_REPEAT_132(m,l,p) TTL_REPEAT_131(m,l,p) m(132,p)
#define TTL_REPEAT_133(m,l,p) TTL_REPEAT_132(m,l,p) m(133,p)
#define TTL_REPEAT_134(m,l,p) TTL_REPEAT_133(m,l,p) m(134,p)
#define TTL_REPEAT_135(m,l,p) TTL_REPEAT_134(m,l,p) m(135,p)
#define TTL_REPEAT_136(m,l,p) TTL_REPEAT_135(m,l,p) m(136,p)
#define TTL_REPEAT_137(m,l,p) TTL_REPEAT_136(m,l,p) m(137,p)
#define TTL_REPEAT_138(m,l,p) TTL_REPEAT_137(m,l,p) m(138,p)
#define TTL_REPEAT_139(m,l,p) TTL_REPEAT_138(m,l,p) m(139,p)
#define TTL_REPEAT_140(m,l,p) TTL_REPEAT_139(m,l,p) m(140,p)
#define TTL_REPEAT_141(m,l,p) TTL_REPEAT_140(m,l,p) m(141,p)
#define TTL_REPEAT_142(m,l,p) TTL_REPEAT_141(m,l,p) m(142,p)
#define TTL_REPEAT_143(m,l,p) TTL_REPEAT_142(m,l,p) m(143,p)
#define TTL_REPEAT_144(m,l,p) TTL_REPEAT_143(m,l,p) m(144,p)
#define TTL_REPEAT_145(m,l,p) TTL_REPEAT_144(m,l,p) m(145,p)
#define TTL_REPEAT_146(m,l,p) TTL_REPEAT_145(m,l,p) m(146,p)
#define TTL_REPEAT_147(m,l,p) TTL_REPEAT_146(m,l,p) m(147,p)
#define TTL_REPEAT_148(m,l,p) TTL_REPEAT_147(m,l,p) m(148,p)
#define TTL_REPEAT_149(m,l,p) TTL_REPEAT_148(m,l,p) m(149,p)
#define TTL_REPEAT_150(m,l,p) TTL_REPEAT_149(m,l,p) m(150,p)
#define TTL_REPEAT_151(m,l,p) TTL_REPEAT_150(m,l,p) m(151,p)
#define TTL_REPEAT_152(m,l,p) TTL_REPEAT_151(m,l,p) m(152,p)
#define TTL_REPEAT_153(m,l,p) TTL_REPEAT_152(m,l,p) m(153,p)
#define TTL_REPEAT_154(m,l,p) TTL_REPEAT_153(m,l,p) m(154,p)
#define TTL_REPEAT_155(m,l,p) TTL_REPEAT_154(m,l,p) m(155,p)
#define TTL_REPEAT_156(m,l,p) TTL_REPEAT_155(m,l,p) m(156,p)
#define TTL_REPEAT_157(m,l,p) TTL_REPEAT_156(m,l,p) m(157,p)
#define TTL_REPEAT_158(m,l,p) TTL_REPEAT_157(m,l,p) m(158,p)
#define TTL_REPEAT_159(m,l,p) TTL_REPEAT_158(m,l,p) m(159,p)
#define TTL_REPEAT_160(m,l,p) TTL_REPEAT_159(m,l,p) m(160,p)
#define TTL_REPEAT_161(m,l,p) TTL_REPEAT_160(m,l,p) m(161,p)
#define TTL_REPEAT_162(m,l,p) TTL_REPEAT_161(m,l,p) m(162,p)
#define TTL_REPEAT_163(m,l,p) TTL_REPEAT_162(m,l,p) m(163,p)
#define TTL_REPEAT_164(m,l,p) TTL_REPEAT_163(m,l,p) m(164,p)
#define TTL_REPEAT_165(m,l,p) TTL_REPEAT_164(m,l,p) m(165,p)
#define TTL_REPEAT_166(m,l,p) TTL_REPEAT_165(m,l,p) m(166,p)
#define TTL_REPEAT_167(m,l,p) TTL_REPEAT_166(m,l,p) m(167,p)
#define TTL_REPEAT_168(m,l,p) TTL_REPEAT_167(m,l,p) m(168,p)
#define TTL_REPEAT_169(m,l,p) TTL_REPEAT_168(m,l,p) m(169,p)
#define TTL_REPEAT_170(m,l,p) TTL_REPEAT_169(m,l,p) m(170,p)
#define TTL_REPEAT_171(m,l,p) TTL_REPEAT_170(m,l,p) m(171,p)
#define TTL_REPEAT_172(m,l,p) TTL_REPEAT_171(m,l,p) m(172,p)
#define TTL_REPEAT_173(m,l,p) TTL_REPEAT_172(m,l,p) m(173,p)
#define TTL_REPEAT_174(m,l,p) TTL_REPEAT_173(m,l,p) m(174,p)
#define TTL_REPEAT_175(m,l,p) TTL_REPEAT_174(m,l,p) m(175,p)
#define TTL_REPEAT_176(m,l,p) TTL_REPEAT_175(m,l,p) m(176,p)
#define TTL_REPEAT_177(m,l,p) TTL_REPEAT_176(m,l,p) m(177,p)
#define TTL_REPEAT_178(m,l,p) TTL_REPEAT_177(m,l,p) m(178,p)
#define TTL_REPEAT_179(m,l,p) TTL_REPEAT_178(m,l,p) m(179,p)
#define TTL_REPEAT_180(m,l,p) TTL_REPEAT_179(m,l,p) m(180,p)
#define TTL_REPEAT_181(m,l,p) TTL_REPEAT_180(m,l,p) m(181,p)
#define TTL_REPEAT_182(m,l,p) TTL_REPEAT_181(m,l,p) m(182,p)
#define TTL_REPEAT_183(m,l,p) TTL_REPEAT_182(m,l,p) m(183,p)
#define TTL_REPEAT_184(m,l,p) TTL_REPEAT_183(m,l,p) m(184,p)
#define TTL_REPEAT_185(m,l,p) TTL_REPEAT_184(m,l,p) m(185,p)
#define TTL_REPEAT_186(m,l,p) TTL_REPEAT_185(m,l,p) m(186,p)
#define TTL_REPEAT_187(m,l,p) TTL_REPEAT_186(m,l,p) m(187,p)
#define TTL_REPEAT_188(m,l,p) TTL_REPEAT_187(m,l,p) m(188,p)
#define TTL_REPEAT_189(m,l,p) TTL_REPEAT_188(m,l,p) m(189,p)
#define TTL_REPEAT_190(m,l,p) TTL_REPEAT_189(m,l,p) m(190,p)
#define TTL_REPEAT_191(m,l,p) TTL_REPEAT_190(m,l,p) m(191,p)
#define TTL_REPEAT_192(m,l,p) TTL_REPEAT_191(m,l,p) m(192,p)
#define TTL_REPEAT_193(m,l,p) TTL_REPEAT_192(m,l,p) m(193,p)
#define TTL_REPEAT_194(m,l,p) TTL_REPEAT_193(m,l,p) m(194,p)
#define TTL_REPEAT_195(m,l,p) TTL_REPEAT_194(m,l,p) m(195,p)
#define TTL_REPEAT_196(m,l,p) TTL_REPEAT_195(m,l,p) m(196,p)
#define TTL_REPEAT_197(m,l,p) TTL_REPEAT_196(m,l,p) m(197,p)
#define TTL_REPEAT_198(m,l,p) TTL_REPEAT_197(m,l,p) m(198,p)
#define TTL_REPEAT_199(m,l,p) TTL_REPEAT_198(m,l,p) m(199,p)
#define TTL_REPEAT_200(m,l,p) TTL_REPEAT_199(m,l,p) m(200,p)
#define TTL_REPEAT_201(m,l,p) TTL_REPEAT_200(m,l,p) m(201,p)
#define TTL_REPEAT_202(m,l,p) TTL_REPEAT_201(m,l,p) m(202,p)
#define TTL_REPEAT_203(m,l,p) TTL_REPEAT_202(m,l,p) m(203,p)
#define TTL_REPEAT_204(m,l,p) TTL_REPEAT_203(m,l,p) m(204,p)
#define TTL_REPEAT_205(m,l,p) TTL_REPEAT_204(m,l,p) m(205,p)
#define TTL_REPEAT_206(m,l,p) TTL_REPEAT_205(m,l,p) m(206,p)
#define TTL_REPEAT_207(m,l,p) TTL_REPEAT_206(m,l,p) m(207,p)
#define TTL_REPEAT_208(m,l,p) TTL_REPEAT_207(m,l,p) m(208,p)
#define TTL_REPEAT_209(m,l,p) TTL_REPEAT_208(m,l,p) m(209,p)
#define TTL_REPEAT_210(m,l,p) TTL_REPEAT_209(m,l,p) m(210,p)
#define TTL_REPEAT_211(m,l,p) TTL_REPEAT_210(m,l,p) m(211,p)
#define TTL_REPEAT_212(m,l,p) TTL_REPEAT_211(m,l,p) m(212,p)
#define TTL_REPEAT_213(m,l,p) TTL_REPEAT_212(m,l,p) m(213,p)
#define TTL_REPEAT_214(m,l,p) TTL_REPEAT_213(m,l,p) m(214,p)
#define TTL_REPEAT_215(m,l,p) TTL_REPEAT_214(m,l,p) m(215,p)
#define TTL_REPEAT_216(m,l,p) TTL_REPEAT_215(m,l,p) m(216,p)
#define TTL_REPEAT_217(m,l,p) TTL_REPEAT_216(m,l,p) m(217,p)
#define TTL_REPEAT_218(m,l,p) TTL_REPEAT_217(m,l,p) m(218,p)
#define TTL_REPEAT_219(m,l,p) TTL_REPEAT_218(m,l,p) m(219,p)
#define TTL_REPEAT_220(m,l,p) TTL_REPEAT_219(m,l,p) m(220,p)
#define TTL_REPEAT_221(m,l,p) TTL_REPEAT_220(m,l,p) m(221,p)
#define TTL_REPEAT_222(m,l,p) TTL_REPEAT_221(m,l,p) m(222,p)
#define TTL_REPEAT_223(m,l,p) TTL_REPEAT_222(m,l,p) m(223,p)
#define TTL_REPEAT_224(m,l,p) TTL_REPEAT_223(m,l,p) m(224,p)
#define TTL_REPEAT_225(m,l,p) TTL_REPEAT_224(m,l,p) m(225,p)
#define TTL_REPEAT_226(m,l,p) TTL_REPEAT_225(m,l,p) m(226,p)
#define TTL_REPEAT_227(m,l,p) TTL_REPEAT_226(m,l,p) m(227,p)
#define TTL_REPEAT_228(m,l,p) TTL_REPEAT_227(m,l,p) m(228,p)
#define TTL_REPEAT_229(m,l,p) TTL_REPEAT_228(m,l,p) m(229,p)
#define TTL_REPEAT_230(m,l,p) TTL_REPEAT_229(m,l,p) m(230,p)
#define TTL_REPEAT_231(m,l,p) TTL_REPEAT_230(m,l,p) m(231,p)
#define TTL_REPEAT_232(m,l,p) TTL_REPEAT_231(m,l,p) m(232,p)
#define TTL_REPEAT_233(m,l,p) TTL_REPEAT_232(m,l,p) m(233,p)
#define TTL_REPEAT_234(m,l,p) TTL_REPEAT_233(m,l,p) m(234,p)
#define TTL_REPEAT_235(m,l,p) TTL_REPEAT_234(m,l,p) m(235,p)
#define TTL_REPEAT_236(m,l,p) TTL_REPEAT_235(m,l,p) m(236,p)
#define TTL_REPEAT_237(m,l,p) TTL_REPEAT_236(m,l,p) m(237,p)
#define TTL_REPEAT_238(m,l,p) TTL_REPEAT_237(m,l,p) m(238,p)
#define TTL_REPEAT_239(m,l,p) TTL_REPEAT_238(m,l,p) m(239,p)
#define TTL_REPEAT_240(m,l,p) TTL_REPEAT_239(m,l,p) m(240,p)
#define TTL_REPEAT_241(m,l,p) TTL_REPEAT_240(m,l,p) m(241,p)
#define TTL_REPEAT_242(m,l,p) TTL_REPEAT_241(m,l,p) m(242,p)
#define TTL_REPEAT_243(m,l,p) TTL_REPEAT_242(m,l,p) m(243,p)
#define TTL_REPEAT_244(m,l,p) TTL_REPEAT_243(m,l,p) m(244,p)
#define TTL_REPEAT_245(m,l,p) TTL_REPEAT_244(m,l,p) m(245,p)
#define TTL_REPEAT_246(m,l,p) TTL_REPEAT_245(m,l,p) m(246,p)
#define TTL_REPEAT_247(m,l,p) TTL_REPEAT_246(m,l,p) m(247,p)
#define TTL_REPEAT_248(m,l,p) TTL_REPEAT_247(m,l,p) m(248,p)
#define TTL_REPEAT_249(m,l,p) TTL_REPEAT_248(m,l,p) m(249,p)
#define TTL_REPEAT_250(m,l,p) TTL_REPEAT_249(m,l,p) m(250,p)
#define TTL_REPEAT_251(m,l,p) TTL_REPEAT_250(m,l,p) m(251,p)
#define TTL_REPEAT_252(m,l,p) TTL_REPEAT_251(m,l,p) m(252,p)
#define TTL_REPEAT_253(m,l,p) TTL_REPEAT_252(m,l,p) m(253,p)
#define TTL_REPEAT_254(m,l,p) TTL_REPEAT_253(m,l,p) m(254,p)
#define TTL_REPEAT_255(m,l,p) TTL_REPEAT_254(m,l,p) m(255,p)
#define TTL_REPEAT_256(m,l,p) TTL_REPEAT_255(m,l,p) m(256,p)
#define TTL_REPEAT_257(m,l,p) TTL_REPEAT_256(m,l,p) m(257,p)
#define TTL_REPEAT_258(m,l,p) TTL_REPEAT_257(m,l,p) m(258,p)
#define TTL_REPEAT_259(m,l,p) TTL_REPEAT_258(m,l,p) m(259,p)
#define TTL_REPEAT_260(m,l,p) TTL_REPEAT_259(m,l,p) m(260,p)
#define TTL_REPEAT_261(m,l,p) TTL_REPEAT_260(m,l,p) m(261,p)
#define TTL_REPEAT_262(m,l,p) TTL_REPEAT_261(m,l,p) m(262,p)
#define TTL_REPEAT_263(m,l,p) TTL_REPEAT_262(m,l,p) m(263,p)
#define TTL_REPEAT_264(m,l,p) TTL_REPEAT_263(m,l,p) m(264,p)
#define TTL_REPEAT_265(m,l,p) TTL_REPEAT_264(m,l,p) m(265,p)
#define TTL_REPEAT_266(m,l,p) TTL_REPEAT_265(m,l,p) m(266,p)
#define TTL_REPEAT_267(m,l,p) TTL_REPEAT_266(m,l,p) m(267,p)
#define TTL_REPEAT_268(m,l,p) TTL_REPEAT_267(m,l,p) m(268,p)
#define TTL_REPEAT_269(m,l,p) TTL_REPEAT_268(m,l,p) m(269,p)
#define TTL_REPEAT_270(m,l,p) TTL_REPEAT_269(m,l,p) m(270,p)
#define TTL_REPEAT_271(m,l,p) TTL_REPEAT_270(m,l,p) m(271,p)
#define TTL_REPEAT_272(m,l,p) TTL_REPEAT_271(m,l,p) m(272,p)
#define TTL_REPEAT_273(m,l,p) TTL_REPEAT_272(m,l,p) m(273,p)
#define TTL_REPEAT_274(m,l,p) TTL_REPEAT_273(m,l,p) m(274,p)
#define TTL_REPEAT_275(m,l,p) TTL_REPEAT_274(m,l,p) m(275,p)
#define TTL_REPEAT_276(m,l,p) TTL_REPEAT_275(m,l,p) m(276,p)
#define TTL_REPEAT_277(m,l,p) TTL_REPEAT_276(m,l,p) m(277,p)
#define TTL_REPEAT_278(m,l,p) TTL_REPEAT_277(m,l,p) m(278,p)
#define TTL_REPEAT_279(m,l,p) TTL_REPEAT_278(m,l,p) m(279,p)
#define TTL_REPEAT_280(m,l,p) TTL_REPEAT_279(m,l,p) m(280,p)
#define TTL_REPEAT_281(m,l,p) TTL_REPEAT_280(m,l,p) m(281,p)
#define TTL_REPEAT_282(m,l,p) TTL_REPEAT_281(m,l,p) m(282,p)
#define TTL_REPEAT_283(m,l,p) TTL_REPEAT_282(m,l,p) m(283,p)
#define TTL_REPEAT_284(m,l,p) TTL_REPEAT_283(m,l,p) m(284,p)
#define TTL_REPEAT_285(m,l,p) TTL_REPEAT_284(m,l,p) m(285,p)
#define TTL_REPEAT_286(m,l,p) TTL_REPEAT_285(m,l,p) m(286,p)
#define TTL_REPEAT_287(m,l,p) TTL_REPEAT_286(m,l,p) m(287,p)
#define TTL_REPEAT_288(m,l,p) TTL_REPEAT_287(m,l,p) m(288,p)
#define TTL_REPEAT_289(m,l,p) TTL_REPEAT_288(m,l,p) m(289,p)
#define TTL_REPEAT_290(m,l,p) TTL_REPEAT_289(m,l,p) m(290,p)
#define TTL_REPEAT_291(m,l,p) TTL_REPEAT_290(m,l,p) m(291,p)
#define TTL_REPEAT_292(m,l,p) TTL_REPEAT_291(m,l,p) m(292,p)
#define TTL_REPEAT_293(m,l,p) TTL_REPEAT_292(m,l,p) m(293,p)
#define TTL_REPEAT_294(m,l,p) TTL_REPEAT_293(m,l,p) m(294,p)
#define TTL_REPEAT_295(m,l,p) TTL_REPEAT_294(m,l,p) m(295,p)
#define TTL_REPEAT_296(m,l,p) TTL_REPEAT_295(m,l,p) m(296,p)
#define TTL_REPEAT_297(m,l,p) TTL_REPEAT_296(m,l,p) m(297,p)
#define TTL_REPEAT_298(m,l,p) TTL_REPEAT_297(m,l,p) m(298,p)
#define TTL_REPEAT_299(m,l,p) TTL_REPEAT_298(m,l,p) m(299,p)
#define TTL_REPEAT_300(m,l,p) TTL_REPEAT_299(m,l,p) m(300,p)
#define TTL_REPEAT_301(m,l,p) TTL_REPEAT_300(m,l,p) m(301,p)
#define TTL_REPEAT_302(m,l,p) TTL_REPEAT_301(m,l,p) m(302,p)
#define TTL_REPEAT_303(m,l,p) TTL_REPEAT_302(m,l,p) m(303,p)
#define TTL_REPEAT_304(m,l,p) TTL_REPEAT_303(m,l,p) m(304,p)
#define TTL_REPEAT_305(m,l,p) TTL_REPEAT_304(m,l,p) m(305,p)
#define TTL_REPEAT_306(m,l,p) TTL_REPEAT_305(m,l,p) m(306,p)
#define TTL_REPEAT_307(m,l,p) TTL_REPEAT_306(m,l,p) m(307,p)
#define TTL_REPEAT_308(m,l,p) TTL_REPEAT_307(m,l,p) m(308,p)
#define TTL_REPEAT_309(m,l,p) TTL_REPEAT_308(m,l,p) m(309,p)
#define TTL_REPEAT_310(m,l,p) TTL_REPEAT_309(m,l,p) m(310,p)
#define TTL_REPEAT_311(m,l,p) TTL_REPEAT_310(m,l,p) m(311,p)
#define TTL_REPEAT_312(m,l,p) TTL_REPEAT_311(m,l,p) m(312,p)
#define TTL_REPEAT_313(m,l,p) TTL_REPEAT_312(m,l,p) m(313,p)
#define TTL_REPEAT_314(m,l,p) TTL_REPEAT_313(m,l,p) m(314,p)
#define TTL_REPEAT_315(m,l,p) TTL_REPEAT_314(m,l,p) m(315,p)
#define TTL_REPEAT_316(m,l,p) TTL_REPEAT_315(m,l,p) m(316,p)
#define TTL_REPEAT_317(m,l,p) TTL_REPEAT_316(m,l,p) m(317,p)
#define TTL_REPEAT_318(m,l,p) TTL_REPEAT_317(m,l,p) m(318,p)
#define TTL_REPEAT_319(m,l,p) TTL_REPEAT_318(m,l,p) m(319,p)
#define TTL_REPEAT_320(m,l,p) TTL_REPEAT_319(m,l,p) m(320,p)
#define TTL_REPEAT_321(m,l,p) TTL_REPEAT_320(m,l,p) m(321,p)
#define TTL_REPEAT_322(m,l,p) TTL_REPEAT_321(m,l,p) m(322,p)
#define TTL_REPEAT_323(m,l,p) TTL_REPEAT_322(m,l,p) m(323,p)
#define TTL_REPEAT_324(m,l,p) TTL_REPEAT_323(m,l,p) m(324,p)
#define TTL_REPEAT_325(m,l,p) TTL_REPEAT_324(m,l,p) m(325,p)
#define TTL_REPEAT_326(m,l,p) TTL_REPEAT_325(m,l,p) m(326,p)
#define TTL_REPEAT_327(m,l,p) TTL_REPEAT_326(m,l,p) m(327,p)
#define TTL_REPEAT_328(m,l,p) TTL_REPEAT_327(m,l,p) m(328,p)
#define TTL_REPEAT_329(m,l,p) TTL_REPEAT_328(m,l,p) m(329,p)
#define TTL_REPEAT_330(m,l,p) TTL_REPEAT_329(m,l,p) m(330,p)
#define TTL_REPEAT_331(m,l,p) TTL_REPEAT_330(m,l,p) m(331,p)
#define TTL_REPEAT_332(m,l,p) TTL_REPEAT_331(m,l,p) m(332,p)
#define TTL_REPEAT_333(m,l,p) TTL_REPEAT_332(m,l,p) m(333,p)
#define TTL_REPEAT_334(m,l,p) TTL_REPEAT_333(m,l,p) m(334,p)
#define TTL_REPEAT_335(m,l,p) TTL_REPEAT_334(m,l,p) m(335,p)
#define TTL_REPEAT_336(m,l,p) TTL_REPEAT_335(m,l,p) m(336,p)
#define TTL_REPEAT_337(m,l,p) TTL_REPEAT_336(m,l,p) m(337,p)
#define TTL_REPEAT_338(m,l,p) TTL_REPEAT_337(m,l,p) m(338,p)
#define TTL_REPEAT_339(m,l,p) TTL_REPEAT_338(m,l,p) m(339,p)
#define TTL_REPEAT_340(m,l,p) TTL_REPEAT_339(m,l,p) m(340,p)
#define TTL_REPEAT_341(m,l,p) TTL_REPEAT_340(m,l,p) m(341,p)
#define TTL_REPEAT_342(m,l,p) TTL_REPEAT_341(m,l,p) m(342,p)
#define TTL_REPEAT_343(m,l,p) TTL_REPEAT_342(m,l,p) m(343,p)
#define TTL_REPEAT_344(m,l,p) TTL_REPEAT_343(m,l,p) m(344,p)
#define TTL_REPEAT_345(m,l,p) TTL_REPEAT_344(m,l,p) m(345,p)
#define TTL_REPEAT_346(m,l,p) TTL_REPEAT_345(m,l,p) m(346,p)
#define TTL_REPEAT_347(m,l,p) TTL_REPEAT_346(m,l,p) m(347,p)
#define TTL_REPEAT_348(m,l,p) TTL_REPEAT_347(m,l,p) m(348,p)
#define TTL_REPEAT_349(m,l,p) TTL_REPEAT_348(m,l,p) m(349,p)
#define TTL_REPEAT_350(m,l,p) TTL_REPEAT_349(m,l,p) m(350,p)
#define TTL_REPEAT_351(m,l,p) TTL_REPEAT_350(m,l,p) m(351,p)
#define TTL_REPEAT_352(m,l,p) TTL_REPEAT_351(m,l,p) m(352,p)
#define TTL_REPEAT_353(m,l,p) TTL_REPEAT_352(m,l,p) m(353,p)
#define TTL_REPEAT_354(m,l,p) TTL_REPEAT_353(m,l,p) m(354,p)
#define TTL_REPEAT_355(m,l,p) TTL_REPEAT_354(m,l,p) m(355,p)
#define TTL_REPEAT_356(m,l,p) TTL_REPEAT_355(m,l,p) m(356,p)
#define TTL_REPEAT_357(m,l,p) TTL_REPEAT_356(m,l,p) m(357,p)
#define TTL_REPEAT_358(m,l,p) TTL_REPEAT_357(m,l,p) m(358,p)
#define TTL_REPEAT_359(m,l,p) TTL_REPEAT_358(m,l,p) m(359,p)
#define TTL_REPEAT_360(m,l,p) TTL_REPEAT_359(m,l,p) m(360,p)
#define TTL_REPEAT_361(m,l,p) TTL_REPEAT_360(m,l,p) m(361,p)
#define TTL_REPEAT_362(m,l,p) TTL_REPEAT_361(m,l,p) m(362,p)
#define TTL_REPEAT_363(m,l,p) TTL_REPEAT_362(m,l,p) m(363,p)
#define TTL_REPEAT_364(m,l,p) TTL_REPEAT_363(m,l,p) m(364,p)
#define TTL_REPEAT_365(m,l,p) TTL_REPEAT_364(m,l,p) m(365,p)
#define TTL_REPEAT_366(m,l,p) TTL_REPEAT_365(m,l,p) m(366,p)
#define TTL_REPEAT_367(m,l,p) TTL_REPEAT_366(m,l,p) m(367,p)
#define TTL_REPEAT_368(m,l,p) TTL_REPEAT_367(m,l,p) m(368,p)
#define TTL_REPEAT_369(m,l,p) TTL_REPEAT_368(m,l,p) m(369,p)
#define TTL_REPEAT_370(m,l,p) TTL_REPEAT_369(m,l,p) m(370,p)
#define TTL_REPEAT_371(m,l,p) TTL_REPEAT_370(m,l,p) m(371,p)
#define TTL_REPEAT_372(m,l,p) TTL_REPEAT_371(m,l,p) m(372,p)
#define TTL_REPEAT_373(m,l,p) TTL_REPEAT_372(m,l,p) m(373,p)
#define TTL_REPEAT_374(m,l,p) TTL_REPEAT_373(m,l,p) m(374,p)
#define TTL_REPEAT_375(m,l,p) TTL_REPEAT_374(m,l,p) m(375,p)
#define TTL_REPEAT_376(m,l,p) TTL_REPEAT_375(m,l,p) m(376,p)
#define TTL_REPEAT_377(m,l,p) TTL_REPEAT_376(m,l,p) m(377,p)
#define TTL_REPEAT_378(m,l,p) TTL_REPEAT_377(m,l,p) m(378,p)
#define TTL_REPEAT_379(m,l,p) TTL_REPEAT_378(m,l,p) m(379,p)
#define TTL_REPEAT_380(m,l,p) TTL_REPEAT_379(m,l,p) m(380,p)
#define TTL_REPEAT_381(m,l,p) TTL_REPEAT_380(m,l,p) m(381,p)
#define TTL_REPEAT_382(m,l,p) TTL_REPEAT_381(m,l,p) m(382,p)
#define TTL_REPEAT_383(m,l,p) TTL_REPEAT_382(m,l,p) m(383,p)
#define TTL_REPEAT_384(m,l,p) TTL_REPEAT_383(m,l,p) m(384,p)
#define TTL_REPEAT_385(m,l,p) TTL_REPEAT_384(m,l,p) m(385,p)
#define TTL_REPEAT_386(m,l,p) TTL_REPEAT_385(m,l,p) m(386,p)
#define TTL_REPEAT_387(m,l,p) TTL_REPEAT_386(m,l,p) m(387,p)
#define TTL_REPEAT_388(m,l,p) TTL_REPEAT_387(m,l,p) m(388,p)
#define TTL_REPEAT_389(m,l,p) TTL_REPEAT_388(m,l,p) m(389,p)
#define TTL_REPEAT_390(m,l,p) TTL_REPEAT_389(m,l,p) m(390,p)
#define TTL_REPEAT_391(m,l,p) TTL_REPEAT_390(m,l,p) m(391,p)
#define TTL_REPEAT_392(m,l,p) TTL_REPEAT_391(m,l,p) m(392,p)
#define TTL_REPEAT_393(m,l,p) TTL_REPEAT_392(m,l,p) m(393,p)
#define TTL_REPEAT_394(m,l,p) TTL_REPEAT_393(m,l,p) m(394,p)
#define TTL_REPEAT_395(m,l,p) TTL_REPEAT_394(m,l,p) m(395,p)
#define TTL_REPEAT_396(m,l,p) TTL_REPEAT_395(m,l,p) m(396,p)
#define TTL_REPEAT_397(m,l,p) TTL_REPEAT_396(m,l,p) m(397,p)
#define TTL_REPEAT_398(m,l,p) TTL_REPEAT_397(m,l,p) m(398,p)
#define TTL_REPEAT_399(m,l,p) TTL_REPEAT_398(m,l,p) m(399,p)
#define TTL_REPEAT_400(m,l,p) TTL_REPEAT_399(m,l,p) m(400,p)
#define TTL_REPEAT_401(m,l,p) TTL_REPEAT_400(m,l,p) m(401,p)
#define TTL_REPEAT_402(m,l,p) TTL_REPEAT_401(m,l,p) m(402,p)
#define TTL_REPEAT_403(m,l,p) TTL_REPEAT_402(m,l,p) m(403,p)
#define TTL_REPEAT_404(m,l,p) TTL_REPEAT_403(m,l,p) m(404,p)
#define TTL_REPEAT_405(m,l,p) TTL_REPEAT_404(m,l,p) m(405,p)
#define TTL_REPEAT_406(m,l,p) TTL_REPEAT_405(m,l,p) m(406,p)
#define TTL_REPEAT_407(m,l,p) TTL_REPEAT_406(m,l,p) m(407,p)
#define TTL_REPEAT_408(m,l,p) TTL_REPEAT_407(m,l,p) m(408,p)
#define TTL_REPEAT_409(m,l,p) TTL_REPEAT_408(m,l,p) m(409,p)
#define TTL_REPEAT_410(m,l,p) TTL_REPEAT_409(m,l,p) m(410,p)
#define TTL_REPEAT_411(m,l,p) TTL_REPEAT_410(m,l,p) m(411,p)
#define TTL_REPEAT_412(m,l,p) TTL_REPEAT_411(m,l,p) m(412,p)
#define TTL_REPEAT_413(m,l,p) TTL_REPEAT_412(m,l,p) m(413,p)
#define TTL_REPEAT_414(m,l,p) TTL_REPEAT_413(m,l,p) m(414,p)
#define TTL_REPEAT_415(m,l,p) TTL_REPEAT_414(m,l,p) m(415,p)
#define TTL_REPEAT_416(m,l,p) TTL_REPEAT_415(m,l,p) m(416,p)
#define TTL_REPEAT_417(m,l,p) TTL_REPEAT_416(m,l,p) m(417,p)
#define TTL_REPEAT_418(m,l,p) TTL_REPEAT_417(m,l,p) m(418,p)
#define TTL_REPEAT_419(m,l,p) TTL_REPEAT_418(m,l,p) m(419,p)
#define TTL_REPEAT_420(m,l,p) TTL_REPEAT_419(m,l,p) m(420,p)
#define TTL_REPEAT_421(m,l,p) TTL_REPEAT_420(m,l,p) m(421,p)
#define TTL_REPEAT_422(m,l,p) TTL_REPEAT_421(m,l,p) m(422,p)
#define TTL_REPEAT_423(m,l,p) TTL_REPEAT_422(m,l,p) m(423,p)
#define TTL_REPEAT_424(m,l,p) TTL_REPEAT_423(m,l,p) m(424,p)
#define TTL_REPEAT_425(m,l,p) TTL_REPEAT_424(m,l,p) m(425,p)
#define TTL_REPEAT_426(m,l,p) TTL_REPEAT_425(m,l,p) m(426,p)
#define TTL_REPEAT_427(m,l,p) TTL_REPEAT_426(m,l,p) m(427,p)
#define TTL_REPEAT_428(m,l,p) TTL_REPEAT_427(m,l,p) m(428,p)
#define TTL_REPEAT_429(m,l,p) TTL_REPEAT_428(m,l,p) m(429,p)
#define TTL_REPEAT_430(m,l,p) TTL_REPEAT_429(m,l,p) m(430,p)
#define TTL_REPEAT_431(m,l,p) TTL_REPEAT_430(m,l,p) m(431,p)
#define TTL_REPEAT_432(m,l,p) TTL_REPEAT_431(m,l,p) m(432,p)
#define TTL_REPEAT_433(m,l,p) TTL_REPEAT_432(m,l,p) m(433,p)
#define TTL_REPEAT_434(m,l,p) TTL_REPEAT_433(m,l,p) m(434,p)
#define TTL_REPEAT_435(m,l,p) TTL_REPEAT_434(m,l,p) m(435,p)
#define TTL_REPEAT_436(m,l,p) TTL_REPEAT_435(m,l,p) m(436,p)
#define TTL_REPEAT_437(m,l,p) TTL_REPEAT_436(m,l,p) m(437,p)
#define TTL_REPEAT_438(m,l,p) TTL_REPEAT_437(m,l,p) m(438,p)
#define TTL_REPEAT_439(m,l,p) TTL_REPEAT_438(m,l,p) m(439,p)
#define TTL_REPEAT_440(m,l,p) TTL_REPEAT_439(m,l,p) m(440,p)
#define TTL_REPEAT_441(m,l,p) TTL_REPEAT_440(m,l,p) m(441,p)
#define TTL_REPEAT_442(m,l,p) TTL_REPEAT_441(m,l,p) m(442,p)
#define TTL_REPEAT_443(m,l,p) TTL_REPEAT_442(m,l,p) m(443,p)
#define TTL_REPEAT_444(m,l,p) TTL_REPEAT_443(m,l,p) m(444,p)
#define TTL_REPEAT_445(m,l,p) TTL_REPEAT_444(m,l,p) m(445,p)
#define TTL_REPEAT_446(m,l,p) TTL_REPEAT_445(m,l,p) m(446,p)
#define TTL_REPEAT_447(m,l,p) TTL_REPEAT_446(m,l,p) m(447,p)
#define TTL_REPEAT_448(m,l,p) TTL_REPEAT_447(m,l,p) m(448,p)
#define TTL_REPEAT_449(m,l,p) TTL_REPEAT_448(m,l,p) m(449,p)
#define TTL_REPEAT_450(m,l,p) TTL_REPEAT_449(m,l,p) m(450,p)
#define TTL_REPEAT_451(m,l,p) TTL_REPEAT_450(m,l,p) m(451,p)
#define TTL_REPEAT_452(m,l,p) TTL_REPEAT_451(m,l,p) m(452,p)
#define TTL_REPEAT_453(m,l,p) TTL_REPEAT_452(m,l,p) m(453,p)
#define TTL_REPEAT_454(m,l,p) TTL_REPEAT_453(m,l,p) m(454,p)
#define TTL_REPEAT_455(m,l,p) TTL_REPEAT_454(m,l,p) m(455,p)
#define TTL_REPEAT_456(m,l,p) TTL_REPEAT_455(m,l,p) m(456,p)
#define TTL_REPEAT_457(m,l,p) TTL_REPEAT_456(m,l,p) m(457,p)
#define TTL_REPEAT_458(m,l,p) TTL_REPEAT_457(m,l,p) m(458,p)
#define TTL_REPEAT_459(m,l,p) TTL_REPEAT_458(m,l,p) m(459,p)
#define TTL_REPEAT_460(m,l,p) TTL_REPEAT_459(m,l,p) m(460,p)
#define TTL_REPEAT_461(m,l,p) TTL_REPEAT_460(m,l,p) m(461,p)
#define TTL_REPEAT_462(m,l,p) TTL_REPEAT_461(m,l,p) m(462,p)
#define TTL_REPEAT_463(m,l,p) TTL_REPEAT_462(m,l,p) m(463,p)
#define TTL_REPEAT_464(m,l,p) TTL_REPEAT_463(m,l,p) m(464,p)
#define TTL_REPEAT_465(m,l,p) TTL_REPEAT_464(m,l,p) m(465,p)
#define TTL_REPEAT_466(m,l,p) TTL_REPEAT_465(m,l,p) m(466,p)
#define TTL_REPEAT_467(m,l,p) TTL_REPEAT_466(m,l,p) m(467,p)
#define TTL_REPEAT_468(m,l,p) TTL_REPEAT_467(m,l,p) m(468,p)
#define TTL_REPEAT_469(m,l,p) TTL_REPEAT_468(m,l,p) m(469,p)
#define TTL_REPEAT_470(m,l,p) TTL_REPEAT_469(m,l,p) m(470,p)
#define TTL_REPEAT_471(m,l,p) TTL_REPEAT_470(m,l,p) m(471,p)
#define TTL_REPEAT_472(m,l,p) TTL_REPEAT_471(m,l,p) m(472,p)
#define TTL_REPEAT_473(m,l,p) TTL_REPEAT_472(m,l,p) m(473,p)
#define TTL_REPEAT_474(m,l,p) TTL_REPEAT_473(m,l,p) m(474,p)
#define TTL_REPEAT_475(m,l,p) TTL_REPEAT_474(m,l,p) m(475,p)
#define TTL_REPEAT_476(m,l,p) TTL_REPEAT_475(m,l,p) m(476,p)
#define TTL_REPEAT_477(m,l,p) TTL_REPEAT_476(m,l,p) m(477,p)
#define TTL_REPEAT_478(m,l,p) TTL_REPEAT_477(m,l,p) m(478,p)
#define TTL_REPEAT_479(m,l,p) TTL_REPEAT_478(m,l,p) m(479,p)
#define TTL_REPEAT_480(m,l,p) TTL_REPEAT_479(m,l,p) m(480,p)
#define TTL_REPEAT_481(m,l,p) TTL_REPEAT_480(m,l,p) m(481,p)
#define TTL_REPEAT_482(m,l,p) TTL_REPEAT_481(m,l,p) m(482,p)
#define TTL_REPEAT_483(m,l,p) TTL_REPEAT_482(m,l,p) m(483,p)
#define TTL_REPEAT_484(m,l,p) TTL_REPEAT_483(m,l,p) m(484,p)
#define TTL_REPEAT_485(m,l,p) TTL_REPEAT_484(m,l,p) m(485,p)
#define TTL_REPEAT_486(m,l,p) TTL_REPEAT_485(m,l,p) m(486,p)
#define TTL_REPEAT_487(m,l,p) TTL_REPEAT_486(m,l,p) m(487,p)
#define TTL_REPEAT_488(m,l,p) TTL_REPEAT_487(m,l,p) m(488,p)
#define TTL_REPEAT_489(m,l,p) TTL_REPEAT_488(m,l,p) m(489,p)
#define TTL_REPEAT_490(m,l,p) TTL_REPEAT_489(m,l,p) m(490,p)
#define TTL_REPEAT_491(m,l,p) TTL_REPEAT_490(m,l,p) m(491,p)
#define TTL_REPEAT_492(m,l,p) TTL_REPEAT_491(m,l,p) m(492,p)
#define TTL_REPEAT_493(m,l,p) TTL_REPEAT_492(m,l,p) m(493,p)
#define TTL_REPEAT_494(m,l,p) TTL_REPEAT_493(m,l,p) m(494,p)
#define TTL_REPEAT_495(m,l,p) TTL_REPEAT_494(m,l,p) m(495,p)
#define TTL_REPEAT_496(m,l,p) TTL_REPEAT_495(m,l,p) m(496,p)
#define TTL_REPEAT_497(m,l,p) TTL_REPEAT_496(m,l,p) m(497,p)
#define TTL_REPEAT_498(m,l,p) TTL_REPEAT_497(m,l,p) m(498,p)
#define TTL_REPEAT_499(m,l,p) TTL_REPEAT_498(m,l,p) m(499,p)
#define TTL_REPEAT_500(m,l,p) TTL_REPEAT_499(m,l,p) m(500,p)
#define TTL_REPEAT_501(m,l,p) TTL_REPEAT_500(m,l,p) m(501,p)
#define TTL_REPEAT_502(m,l,p) TTL_REPEAT_501(m,l,p) m(502,p)
#define TTL_REPEAT_503(m,l,p) TTL_REPEAT_502(m,l,p) m(503,p)
#define TTL_REPEAT_504(m,l,p) TTL_REPEAT_503(m,l,p) m(504,p)
#define TTL_REPEAT_505(m,l,p) TTL_REPEAT_504(m,l,p) m(505,p)
#define TTL_REPEAT_506(m,l,p) TTL_REPEAT_505(m,l,p) m(506,p)
#define TTL_REPEAT_507(m,l,p) TTL_REPEAT_506(m,l,p) m(507,p)
#define TTL_REPEAT_508(m,l,p) TTL_REPEAT_507(m,l,p) m(508,p)
#define TTL_REPEAT_509(m,l,p) TTL_REPEAT_508(m,l,p) m(509,p)
#define TTL_REPEAT_510(m,l,p) TTL_REPEAT_509(m,l,p) m(510,p)
#define TTL_REPEAT_511(m,l,p) TTL_REPEAT_510(m,l,p) m(511,p)
#define TTL_REPEAT_512(m,l,p) TTL_REPEAT_511(m,l,p) m(512,p)
//************************
#define TTL_LAST_REPEAT_0(m,p)
#define TTL_LAST_REPEAT_1(m,p) m(1,p)
#define TTL_LAST_REPEAT_2(m,p) m(2,p)
#define TTL_LAST_REPEAT_3(m,p) m(3,p)
#define TTL_LAST_REPEAT_4(m,p) m(4,p)
#define TTL_LAST_REPEAT_5(m,p) m(5,p)
#define TTL_LAST_REPEAT_6(m,p) m(6,p)
#define TTL_LAST_REPEAT_7(m,p) m(7,p)
#define TTL_LAST_REPEAT_8(m,p) m(8,p)
#define TTL_LAST_REPEAT_9(m,p) m(9,p)
#define TTL_LAST_REPEAT_10(m,p) m(10,p)
#define TTL_LAST_REPEAT_11(m,p) m(11,p)
#define TTL_LAST_REPEAT_12(m,p) m(12,p)
#define TTL_LAST_REPEAT_13(m,p) m(13,p)
#define TTL_LAST_REPEAT_14(m,p) m(14,p)
#define TTL_LAST_REPEAT_15(m,p) m(15,p)
#define TTL_LAST_REPEAT_16(m,p) m(16,p)
#define TTL_LAST_REPEAT_17(m,p) m(17,p)
#define TTL_LAST_REPEAT_18(m,p) m(18,p)
#define TTL_LAST_REPEAT_19(m,p) m(19,p)
#define TTL_LAST_REPEAT_20(m,p) m(20,p)
#define TTL_LAST_REPEAT_21(m,p) m(21,p)
#define TTL_LAST_REPEAT_22(m,p) m(22,p)
#define TTL_LAST_REPEAT_23(m,p) m(23,p)
#define TTL_LAST_REPEAT_24(m,p) m(24,p)
#define TTL_LAST_REPEAT_25(m,p) m(25,p)
#define TTL_LAST_REPEAT_26(m,p) m(26,p)
#define TTL_LAST_REPEAT_27(m,p) m(27,p)
#define TTL_LAST_REPEAT_28(m,p) m(28,p)
#define TTL_LAST_REPEAT_29(m,p) m(29,p)
#define TTL_LAST_REPEAT_30(m,p) m(30,p)
#define TTL_LAST_REPEAT_31(m,p) m(31,p)
#define TTL_LAST_REPEAT_32(m,p) m(32,p)
#define TTL_LAST_REPEAT_33(m,p) m(33,p)
#define TTL_LAST_REPEAT_34(m,p) m(34,p)
#define TTL_LAST_REPEAT_35(m,p) m(35,p)
#define TTL_LAST_REPEAT_36(m,p) m(36,p)
#define TTL_LAST_REPEAT_37(m,p) m(37,p)
#define TTL_LAST_REPEAT_38(m,p) m(38,p)
#define TTL_LAST_REPEAT_39(m,p) m(39,p)
#define TTL_LAST_REPEAT_40(m,p) m(40,p)
#define TTL_LAST_REPEAT_41(m,p) m(41,p)
#define TTL_LAST_REPEAT_42(m,p) m(42,p)
#define TTL_LAST_REPEAT_43(m,p) m(43,p)
#define TTL_LAST_REPEAT_44(m,p) m(44,p)
#define TTL_LAST_REPEAT_45(m,p) m(45,p)
#define TTL_LAST_REPEAT_46(m,p) m(46,p)
#define TTL_LAST_REPEAT_47(m,p) m(47,p)
#define TTL_LAST_REPEAT_48(m,p) m(48,p)
#define TTL_LAST_REPEAT_49(m,p) m(49,p)
#define TTL_LAST_REPEAT_50(m,p) m(50,p)
#define TTL_LAST_REPEAT_51(m,p) m(51,p)
#define TTL_LAST_REPEAT_52(m,p) m(52,p)
#define TTL_LAST_REPEAT_53(m,p) m(53,p)
#define TTL_LAST_REPEAT_54(m,p) m(54,p)
#define TTL_LAST_REPEAT_55(m,p) m(55,p)
#define TTL_LAST_REPEAT_56(m,p) m(56,p)
#define TTL_LAST_REPEAT_57(m,p) m(57,p)
#define TTL_LAST_REPEAT_58(m,p) m(58,p)
#define TTL_LAST_REPEAT_59(m,p) m(59,p)
#define TTL_LAST_REPEAT_60(m,p) m(60,p)
#define TTL_LAST_REPEAT_61(m,p) m(61,p)
#define TTL_LAST_REPEAT_62(m,p) m(62,p)
#define TTL_LAST_REPEAT_63(m,p) m(63,p)
#define TTL_LAST_REPEAT_64(m,p) m(64,p)
#define TTL_LAST_REPEAT_65(m,p) m(65,p)
#define TTL_LAST_REPEAT_66(m,p) m(66,p)
#define TTL_LAST_REPEAT_67(m,p) m(67,p)
#define TTL_LAST_REPEAT_68(m,p) m(68,p)
#define TTL_LAST_REPEAT_69(m,p) m(69,p)
#define TTL_LAST_REPEAT_70(m,p) m(70,p)
#define TTL_LAST_REPEAT_71(m,p) m(71,p)
#define TTL_LAST_REPEAT_72(m,p) m(72,p)
#define TTL_LAST_REPEAT_73(m,p) m(73,p)
#define TTL_LAST_REPEAT_74(m,p) m(74,p)
#define TTL_LAST_REPEAT_75(m,p) m(75,p)
#define TTL_LAST_REPEAT_76(m,p) m(76,p)
#define TTL_LAST_REPEAT_77(m,p) m(77,p)
#define TTL_LAST_REPEAT_78(m,p) m(78,p)
#define TTL_LAST_REPEAT_79(m,p) m(79,p)
#define TTL_LAST_REPEAT_80(m,p) m(80,p)
#define TTL_LAST_REPEAT_81(m,p) m(81,p)
#define TTL_LAST_REPEAT_82(m,p) m(82,p)
#define TTL_LAST_REPEAT_83(m,p) m(83,p)
#define TTL_LAST_REPEAT_84(m,p) m(84,p)
#define TTL_LAST_REPEAT_85(m,p) m(85,p)
#define TTL_LAST_REPEAT_86(m,p) m(86,p)
#define TTL_LAST_REPEAT_87(m,p) m(87,p)
#define TTL_LAST_REPEAT_88(m,p) m(88,p)
#define TTL_LAST_REPEAT_89(m,p) m(89,p)
#define TTL_LAST_REPEAT_90(m,p) m(90,p)
#define TTL_LAST_REPEAT_91(m,p) m(91,p)
#define TTL_LAST_REPEAT_92(m,p) m(92,p)
#define TTL_LAST_REPEAT_93(m,p) m(93,p)
#define TTL_LAST_REPEAT_94(m,p) m(94,p)
#define TTL_LAST_REPEAT_95(m,p) m(95,p)
#define TTL_LAST_REPEAT_96(m,p) m(96,p)
#define TTL_LAST_REPEAT_97(m,p) m(97,p)
#define TTL_LAST_REPEAT_98(m,p) m(98,p)
#define TTL_LAST_REPEAT_99(m,p) m(99,p)
#define TTL_LAST_REPEAT_100(m,p) m(100,p)
#define TTL_LAST_REPEAT_101(m,p) m(101,p)
#define TTL_LAST_REPEAT_102(m,p) m(102,p)
#define TTL_LAST_REPEAT_103(m,p) m(103,p)
#define TTL_LAST_REPEAT_104(m,p) m(104,p)
#define TTL_LAST_REPEAT_105(m,p) m(105,p)
#define TTL_LAST_REPEAT_106(m,p) m(106,p)
#define TTL_LAST_REPEAT_107(m,p) m(107,p)
#define TTL_LAST_REPEAT_108(m,p) m(108,p)
#define TTL_LAST_REPEAT_109(m,p) m(109,p)
#define TTL_LAST_REPEAT_110(m,p) m(110,p)
#define TTL_LAST_REPEAT_111(m,p) m(111,p)
#define TTL_LAST_REPEAT_112(m,p) m(112,p)
#define TTL_LAST_REPEAT_113(m,p) m(113,p)
#define TTL_LAST_REPEAT_114(m,p) m(114,p)
#define TTL_LAST_REPEAT_115(m,p) m(115,p)
#define TTL_LAST_REPEAT_116(m,p) m(116,p)
#define TTL_LAST_REPEAT_117(m,p) m(117,p)
#define TTL_LAST_REPEAT_118(m,p) m(118,p)
#define TTL_LAST_REPEAT_119(m,p) m(119,p)
#define TTL_LAST_REPEAT_120(m,p) m(120,p)
#define TTL_LAST_REPEAT_121(m,p) m(121,p)
#define TTL_LAST_REPEAT_122(m,p) m(122,p)
#define TTL_LAST_REPEAT_123(m,p) m(123,p)
#define TTL_LAST_REPEAT_124(m,p) m(124,p)
#define TTL_LAST_REPEAT_125(m,p) m(125,p)
#define TTL_LAST_REPEAT_126(m,p) m(126,p)
#define TTL_LAST_REPEAT_127(m,p) m(127,p)
#define TTL_LAST_REPEAT_128(m,p) m(128,p)
#define TTL_LAST_REPEAT_129(m,p) m(129,p)
#define TTL_LAST_REPEAT_130(m,p) m(130,p)
#define TTL_LAST_REPEAT_131(m,p) m(131,p)
#define TTL_LAST_REPEAT_132(m,p) m(132,p)
#define TTL_LAST_REPEAT_133(m,p) m(133,p)
#define TTL_LAST_REPEAT_134(m,p) m(134,p)
#define TTL_LAST_REPEAT_135(m,p) m(135,p)
#define TTL_LAST_REPEAT_136(m,p) m(136,p)
#define TTL_LAST_REPEAT_137(m,p) m(137,p)
#define TTL_LAST_REPEAT_138(m,p) m(138,p)
#define TTL_LAST_REPEAT_139(m,p) m(139,p)
#define TTL_LAST_REPEAT_140(m,p) m(140,p)
#define TTL_LAST_REPEAT_141(m,p) m(141,p)
#define TTL_LAST_REPEAT_142(m,p) m(142,p)
#define TTL_LAST_REPEAT_143(m,p) m(143,p)
#define TTL_LAST_REPEAT_144(m,p) m(144,p)
#define TTL_LAST_REPEAT_145(m,p) m(145,p)
#define TTL_LAST_REPEAT_146(m,p) m(146,p)
#define TTL_LAST_REPEAT_147(m,p) m(147,p)
#define TTL_LAST_REPEAT_148(m,p) m(148,p)
#define TTL_LAST_REPEAT_149(m,p) m(149,p)
#define TTL_LAST_REPEAT_150(m,p) m(150,p)
#define TTL_LAST_REPEAT_151(m,p) m(151,p)
#define TTL_LAST_REPEAT_152(m,p) m(152,p)
#define TTL_LAST_REPEAT_153(m,p) m(153,p)
#define TTL_LAST_REPEAT_154(m,p) m(154,p)
#define TTL_LAST_REPEAT_155(m,p) m(155,p)
#define TTL_LAST_REPEAT_156(m,p) m(156,p)
#define TTL_LAST_REPEAT_157(m,p) m(157,p)
#define TTL_LAST_REPEAT_158(m,p) m(158,p)
#define TTL_LAST_REPEAT_159(m,p) m(159,p)
#define TTL_LAST_REPEAT_160(m,p) m(160,p)
#define TTL_LAST_REPEAT_161(m,p) m(161,p)
#define TTL_LAST_REPEAT_162(m,p) m(162,p)
#define TTL_LAST_REPEAT_163(m,p) m(163,p)
#define TTL_LAST_REPEAT_164(m,p) m(164,p)
#define TTL_LAST_REPEAT_165(m,p) m(165,p)
#define TTL_LAST_REPEAT_166(m,p) m(166,p)
#define TTL_LAST_REPEAT_167(m,p) m(167,p)
#define TTL_LAST_REPEAT_168(m,p) m(168,p)
#define TTL_LAST_REPEAT_169(m,p) m(169,p)
#define TTL_LAST_REPEAT_170(m,p) m(170,p)
#define TTL_LAST_REPEAT_171(m,p) m(171,p)
#define TTL_LAST_REPEAT_172(m,p) m(172,p)
#define TTL_LAST_REPEAT_173(m,p) m(173,p)
#define TTL_LAST_REPEAT_174(m,p) m(174,p)
#define TTL_LAST_REPEAT_175(m,p) m(175,p)
#define TTL_LAST_REPEAT_176(m,p) m(176,p)
#define TTL_LAST_REPEAT_177(m,p) m(177,p)
#define TTL_LAST_REPEAT_178(m,p) m(178,p)
#define TTL_LAST_REPEAT_179(m,p) m(179,p)
#define TTL_LAST_REPEAT_180(m,p) m(180,p)
#define TTL_LAST_REPEAT_181(m,p) m(181,p)
#define TTL_LAST_REPEAT_182(m,p) m(182,p)
#define TTL_LAST_REPEAT_183(m,p) m(183,p)
#define TTL_LAST_REPEAT_184(m,p) m(184,p)
#define TTL_LAST_REPEAT_185(m,p) m(185,p)
#define TTL_LAST_REPEAT_186(m,p) m(186,p)
#define TTL_LAST_REPEAT_187(m,p) m(187,p)
#define TTL_LAST_REPEAT_188(m,p) m(188,p)
#define TTL_LAST_REPEAT_189(m,p) m(189,p)
#define TTL_LAST_REPEAT_190(m,p) m(190,p)
#define TTL_LAST_REPEAT_191(m,p) m(191,p)
#define TTL_LAST_REPEAT_192(m,p) m(192,p)
#define TTL_LAST_REPEAT_193(m,p) m(193,p)
#define TTL_LAST_REPEAT_194(m,p) m(194,p)
#define TTL_LAST_REPEAT_195(m,p) m(195,p)
#define TTL_LAST_REPEAT_196(m,p) m(196,p)
#define TTL_LAST_REPEAT_197(m,p) m(197,p)
#define TTL_LAST_REPEAT_198(m,p) m(198,p)
#define TTL_LAST_REPEAT_199(m,p) m(199,p)
#define TTL_LAST_REPEAT_200(m,p) m(200,p)
#define TTL_LAST_REPEAT_201(m,p) m(201,p)
#define TTL_LAST_REPEAT_202(m,p) m(202,p)
#define TTL_LAST_REPEAT_203(m,p) m(203,p)
#define TTL_LAST_REPEAT_204(m,p) m(204,p)
#define TTL_LAST_REPEAT_205(m,p) m(205,p)
#define TTL_LAST_REPEAT_206(m,p) m(206,p)
#define TTL_LAST_REPEAT_207(m,p) m(207,p)
#define TTL_LAST_REPEAT_208(m,p) m(208,p)
#define TTL_LAST_REPEAT_209(m,p) m(209,p)
#define TTL_LAST_REPEAT_210(m,p) m(210,p)
#define TTL_LAST_REPEAT_211(m,p) m(211,p)
#define TTL_LAST_REPEAT_212(m,p) m(212,p)
#define TTL_LAST_REPEAT_213(m,p) m(213,p)
#define TTL_LAST_REPEAT_214(m,p) m(214,p)
#define TTL_LAST_REPEAT_215(m,p) m(215,p)
#define TTL_LAST_REPEAT_216(m,p) m(216,p)
#define TTL_LAST_REPEAT_217(m,p) m(217,p)
#define TTL_LAST_REPEAT_218(m,p) m(218,p)
#define TTL_LAST_REPEAT_219(m,p) m(219,p)
#define TTL_LAST_REPEAT_220(m,p) m(220,p)
#define TTL_LAST_REPEAT_221(m,p) m(221,p)
#define TTL_LAST_REPEAT_222(m,p) m(222,p)
#define TTL_LAST_REPEAT_223(m,p) m(223,p)
#define TTL_LAST_REPEAT_224(m,p) m(224,p)
#define TTL_LAST_REPEAT_225(m,p) m(225,p)
#define TTL_LAST_REPEAT_226(m,p) m(226,p)
#define TTL_LAST_REPEAT_227(m,p) m(227,p)
#define TTL_LAST_REPEAT_228(m,p) m(228,p)
#define TTL_LAST_REPEAT_229(m,p) m(229,p)
#define TTL_LAST_REPEAT_230(m,p) m(230,p)
#define TTL_LAST_REPEAT_231(m,p) m(231,p)
#define TTL_LAST_REPEAT_232(m,p) m(232,p)
#define TTL_LAST_REPEAT_233(m,p) m(233,p)
#define TTL_LAST_REPEAT_234(m,p) m(234,p)
#define TTL_LAST_REPEAT_235(m,p) m(235,p)
#define TTL_LAST_REPEAT_236(m,p) m(236,p)
#define TTL_LAST_REPEAT_237(m,p) m(237,p)
#define TTL_LAST_REPEAT_238(m,p) m(238,p)
#define TTL_LAST_REPEAT_239(m,p) m(239,p)
#define TTL_LAST_REPEAT_240(m,p) m(240,p)
#define TTL_LAST_REPEAT_241(m,p) m(241,p)
#define TTL_LAST_REPEAT_242(m,p) m(242,p)
#define TTL_LAST_REPEAT_243(m,p) m(243,p)
#define TTL_LAST_REPEAT_244(m,p) m(244,p)
#define TTL_LAST_REPEAT_245(m,p) m(245,p)
#define TTL_LAST_REPEAT_246(m,p) m(246,p)
#define TTL_LAST_REPEAT_247(m,p) m(247,p)
#define TTL_LAST_REPEAT_248(m,p) m(248,p)
#define TTL_LAST_REPEAT_249(m,p) m(249,p)
#define TTL_LAST_REPEAT_250(m,p) m(250,p)
#define TTL_LAST_REPEAT_251(m,p) m(251,p)
#define TTL_LAST_REPEAT_252(m,p) m(252,p)
#define TTL_LAST_REPEAT_253(m,p) m(253,p)
#define TTL_LAST_REPEAT_254(m,p) m(254,p)
#define TTL_LAST_REPEAT_255(m,p) m(255,p)
#define TTL_LAST_REPEAT_256(m,p) m(256,p)
#define TTL_LAST_REPEAT_257(m,p) m(257,p)
#define TTL_LAST_REPEAT_258(m,p) m(258,p)
#define TTL_LAST_REPEAT_259(m,p) m(259,p)
#define TTL_LAST_REPEAT_260(m,p) m(260,p)
#define TTL_LAST_REPEAT_261(m,p) m(261,p)
#define TTL_LAST_REPEAT_262(m,p) m(262,p)
#define TTL_LAST_REPEAT_263(m,p) m(263,p)
#define TTL_LAST_REPEAT_264(m,p) m(264,p)
#define TTL_LAST_REPEAT_265(m,p) m(265,p)
#define TTL_LAST_REPEAT_266(m,p) m(266,p)
#define TTL_LAST_REPEAT_267(m,p) m(267,p)
#define TTL_LAST_REPEAT_268(m,p) m(268,p)
#define TTL_LAST_REPEAT_269(m,p) m(269,p)
#define TTL_LAST_REPEAT_270(m,p) m(270,p)
#define TTL_LAST_REPEAT_271(m,p) m(271,p)
#define TTL_LAST_REPEAT_272(m,p) m(272,p)
#define TTL_LAST_REPEAT_273(m,p) m(273,p)
#define TTL_LAST_REPEAT_274(m,p) m(274,p)
#define TTL_LAST_REPEAT_275(m,p) m(275,p)
#define TTL_LAST_REPEAT_276(m,p) m(276,p)
#define TTL_LAST_REPEAT_277(m,p) m(277,p)
#define TTL_LAST_REPEAT_278(m,p) m(278,p)
#define TTL_LAST_REPEAT_279(m,p) m(279,p)
#define TTL_LAST_REPEAT_280(m,p) m(280,p)
#define TTL_LAST_REPEAT_281(m,p) m(281,p)
#define TTL_LAST_REPEAT_282(m,p) m(282,p)
#define TTL_LAST_REPEAT_283(m,p) m(283,p)
#define TTL_LAST_REPEAT_284(m,p) m(284,p)
#define TTL_LAST_REPEAT_285(m,p) m(285,p)
#define TTL_LAST_REPEAT_286(m,p) m(286,p)
#define TTL_LAST_REPEAT_287(m,p) m(287,p)
#define TTL_LAST_REPEAT_288(m,p) m(288,p)
#define TTL_LAST_REPEAT_289(m,p) m(289,p)
#define TTL_LAST_REPEAT_290(m,p) m(290,p)
#define TTL_LAST_REPEAT_291(m,p) m(291,p)
#define TTL_LAST_REPEAT_292(m,p) m(292,p)
#define TTL_LAST_REPEAT_293(m,p) m(293,p)
#define TTL_LAST_REPEAT_294(m,p) m(294,p)
#define TTL_LAST_REPEAT_295(m,p) m(295,p)
#define TTL_LAST_REPEAT_296(m,p) m(296,p)
#define TTL_LAST_REPEAT_297(m,p) m(297,p)
#define TTL_LAST_REPEAT_298(m,p) m(298,p)
#define TTL_LAST_REPEAT_299(m,p) m(299,p)
#define TTL_LAST_REPEAT_300(m,p) m(300,p)
#define TTL_LAST_REPEAT_301(m,p) m(301,p)
#define TTL_LAST_REPEAT_302(m,p) m(302,p)
#define TTL_LAST_REPEAT_303(m,p) m(303,p)
#define TTL_LAST_REPEAT_304(m,p) m(304,p)
#define TTL_LAST_REPEAT_305(m,p) m(305,p)
#define TTL_LAST_REPEAT_306(m,p) m(306,p)
#define TTL_LAST_REPEAT_307(m,p) m(307,p)
#define TTL_LAST_REPEAT_308(m,p) m(308,p)
#define TTL_LAST_REPEAT_309(m,p) m(309,p)
#define TTL_LAST_REPEAT_310(m,p) m(310,p)
#define TTL_LAST_REPEAT_311(m,p) m(311,p)
#define TTL_LAST_REPEAT_312(m,p) m(312,p)
#define TTL_LAST_REPEAT_313(m,p) m(313,p)
#define TTL_LAST_REPEAT_314(m,p) m(314,p)
#define TTL_LAST_REPEAT_315(m,p) m(315,p)
#define TTL_LAST_REPEAT_316(m,p) m(316,p)
#define TTL_LAST_REPEAT_317(m,p) m(317,p)
#define TTL_LAST_REPEAT_318(m,p) m(318,p)
#define TTL_LAST_REPEAT_319(m,p) m(319,p)
#define TTL_LAST_REPEAT_320(m,p) m(320,p)
#define TTL_LAST_REPEAT_321(m,p) m(321,p)
#define TTL_LAST_REPEAT_322(m,p) m(322,p)
#define TTL_LAST_REPEAT_323(m,p) m(323,p)
#define TTL_LAST_REPEAT_324(m,p) m(324,p)
#define TTL_LAST_REPEAT_325(m,p) m(325,p)
#define TTL_LAST_REPEAT_326(m,p) m(326,p)
#define TTL_LAST_REPEAT_327(m,p) m(327,p)
#define TTL_LAST_REPEAT_328(m,p) m(328,p)
#define TTL_LAST_REPEAT_329(m,p) m(329,p)
#define TTL_LAST_REPEAT_330(m,p) m(330,p)
#define TTL_LAST_REPEAT_331(m,p) m(331,p)
#define TTL_LAST_REPEAT_332(m,p) m(332,p)
#define TTL_LAST_REPEAT_333(m,p) m(333,p)
#define TTL_LAST_REPEAT_334(m,p) m(334,p)
#define TTL_LAST_REPEAT_335(m,p) m(335,p)
#define TTL_LAST_REPEAT_336(m,p) m(336,p)
#define TTL_LAST_REPEAT_337(m,p) m(337,p)
#define TTL_LAST_REPEAT_338(m,p) m(338,p)
#define TTL_LAST_REPEAT_339(m,p) m(339,p)
#define TTL_LAST_REPEAT_340(m,p) m(340,p)
#define TTL_LAST_REPEAT_341(m,p) m(341,p)
#define TTL_LAST_REPEAT_342(m,p) m(342,p)
#define TTL_LAST_REPEAT_343(m,p) m(343,p)
#define TTL_LAST_REPEAT_344(m,p) m(344,p)
#define TTL_LAST_REPEAT_345(m,p) m(345,p)
#define TTL_LAST_REPEAT_346(m,p) m(346,p)
#define TTL_LAST_REPEAT_347(m,p) m(347,p)
#define TTL_LAST_REPEAT_348(m,p) m(348,p)
#define TTL_LAST_REPEAT_349(m,p) m(349,p)
#define TTL_LAST_REPEAT_350(m,p) m(350,p)
#define TTL_LAST_REPEAT_351(m,p) m(351,p)
#define TTL_LAST_REPEAT_352(m,p) m(352,p)
#define TTL_LAST_REPEAT_353(m,p) m(353,p)
#define TTL_LAST_REPEAT_354(m,p) m(354,p)
#define TTL_LAST_REPEAT_355(m,p) m(355,p)
#define TTL_LAST_REPEAT_356(m,p) m(356,p)
#define TTL_LAST_REPEAT_357(m,p) m(357,p)
#define TTL_LAST_REPEAT_358(m,p) m(358,p)
#define TTL_LAST_REPEAT_359(m,p) m(359,p)
#define TTL_LAST_REPEAT_360(m,p) m(360,p)
#define TTL_LAST_REPEAT_361(m,p) m(361,p)
#define TTL_LAST_REPEAT_362(m,p) m(362,p)
#define TTL_LAST_REPEAT_363(m,p) m(363,p)
#define TTL_LAST_REPEAT_364(m,p) m(364,p)
#define TTL_LAST_REPEAT_365(m,p) m(365,p)
#define TTL_LAST_REPEAT_366(m,p) m(366,p)
#define TTL_LAST_REPEAT_367(m,p) m(367,p)
#define TTL_LAST_REPEAT_368(m,p) m(368,p)
#define TTL_LAST_REPEAT_369(m,p) m(369,p)
#define TTL_LAST_REPEAT_370(m,p) m(370,p)
#define TTL_LAST_REPEAT_371(m,p) m(371,p)
#define TTL_LAST_REPEAT_372(m,p) m(372,p)
#define TTL_LAST_REPEAT_373(m,p) m(373,p)
#define TTL_LAST_REPEAT_374(m,p) m(374,p)
#define TTL_LAST_REPEAT_375(m,p) m(375,p)
#define TTL_LAST_REPEAT_376(m,p) m(376,p)
#define TTL_LAST_REPEAT_377(m,p) m(377,p)
#define TTL_LAST_REPEAT_378(m,p) m(378,p)
#define TTL_LAST_REPEAT_379(m,p) m(379,p)
#define TTL_LAST_REPEAT_380(m,p) m(380,p)
#define TTL_LAST_REPEAT_381(m,p) m(381,p)
#define TTL_LAST_REPEAT_382(m,p) m(382,p)
#define TTL_LAST_REPEAT_383(m,p) m(383,p)
#define TTL_LAST_REPEAT_384(m,p) m(384,p)
#define TTL_LAST_REPEAT_385(m,p) m(385,p)
#define TTL_LAST_REPEAT_386(m,p) m(386,p)
#define TTL_LAST_REPEAT_387(m,p) m(387,p)
#define TTL_LAST_REPEAT_388(m,p) m(388,p)
#define TTL_LAST_REPEAT_389(m,p) m(389,p)
#define TTL_LAST_REPEAT_390(m,p) m(390,p)
#define TTL_LAST_REPEAT_391(m,p) m(391,p)
#define TTL_LAST_REPEAT_392(m,p) m(392,p)
#define TTL_LAST_REPEAT_393(m,p) m(393,p)
#define TTL_LAST_REPEAT_394(m,p) m(394,p)
#define TTL_LAST_REPEAT_395(m,p) m(395,p)
#define TTL_LAST_REPEAT_396(m,p) m(396,p)
#define TTL_LAST_REPEAT_397(m,p) m(397,p)
#define TTL_LAST_REPEAT_398(m,p) m(398,p)
#define TTL_LAST_REPEAT_399(m,p) m(399,p)
#define TTL_LAST_REPEAT_400(m,p) m(400,p)
#define TTL_LAST_REPEAT_401(m,p) m(401,p)
#define TTL_LAST_REPEAT_402(m,p) m(402,p)
#define TTL_LAST_REPEAT_403(m,p) m(403,p)
#define TTL_LAST_REPEAT_404(m,p) m(404,p)
#define TTL_LAST_REPEAT_405(m,p) m(405,p)
#define TTL_LAST_REPEAT_406(m,p) m(406,p)
#define TTL_LAST_REPEAT_407(m,p) m(407,p)
#define TTL_LAST_REPEAT_408(m,p) m(408,p)
#define TTL_LAST_REPEAT_409(m,p) m(409,p)
#define TTL_LAST_REPEAT_410(m,p) m(410,p)
#define TTL_LAST_REPEAT_411(m,p) m(411,p)
#define TTL_LAST_REPEAT_412(m,p) m(412,p)
#define TTL_LAST_REPEAT_413(m,p) m(413,p)
#define TTL_LAST_REPEAT_414(m,p) m(414,p)
#define TTL_LAST_REPEAT_415(m,p) m(415,p)
#define TTL_LAST_REPEAT_416(m,p) m(416,p)
#define TTL_LAST_REPEAT_417(m,p) m(417,p)
#define TTL_LAST_REPEAT_418(m,p) m(418,p)
#define TTL_LAST_REPEAT_419(m,p) m(419,p)
#define TTL_LAST_REPEAT_420(m,p) m(420,p)
#define TTL_LAST_REPEAT_421(m,p) m(421,p)
#define TTL_LAST_REPEAT_422(m,p) m(422,p)
#define TTL_LAST_REPEAT_423(m,p) m(423,p)
#define TTL_LAST_REPEAT_424(m,p) m(424,p)
#define TTL_LAST_REPEAT_425(m,p) m(425,p)
#define TTL_LAST_REPEAT_426(m,p) m(426,p)
#define TTL_LAST_REPEAT_427(m,p) m(427,p)
#define TTL_LAST_REPEAT_428(m,p) m(428,p)
#define TTL_LAST_REPEAT_429(m,p) m(429,p)
#define TTL_LAST_REPEAT_430(m,p) m(430,p)
#define TTL_LAST_REPEAT_431(m,p) m(431,p)
#define TTL_LAST_REPEAT_432(m,p) m(432,p)
#define TTL_LAST_REPEAT_433(m,p) m(433,p)
#define TTL_LAST_REPEAT_434(m,p) m(434,p)
#define TTL_LAST_REPEAT_435(m,p) m(435,p)
#define TTL_LAST_REPEAT_436(m,p) m(436,p)
#define TTL_LAST_REPEAT_437(m,p) m(437,p)
#define TTL_LAST_REPEAT_438(m,p) m(438,p)
#define TTL_LAST_REPEAT_439(m,p) m(439,p)
#define TTL_LAST_REPEAT_440(m,p) m(440,p)
#define TTL_LAST_REPEAT_441(m,p) m(441,p)
#define TTL_LAST_REPEAT_442(m,p) m(442,p)
#define TTL_LAST_REPEAT_443(m,p) m(443,p)
#define TTL_LAST_REPEAT_444(m,p) m(444,p)
#define TTL_LAST_REPEAT_445(m,p) m(445,p)
#define TTL_LAST_REPEAT_446(m,p) m(446,p)
#define TTL_LAST_REPEAT_447(m,p) m(447,p)
#define TTL_LAST_REPEAT_448(m,p) m(448,p)
#define TTL_LAST_REPEAT_449(m,p) m(449,p)
#define TTL_LAST_REPEAT_450(m,p) m(450,p)
#define TTL_LAST_REPEAT_451(m,p) m(451,p)
#define TTL_LAST_REPEAT_452(m,p) m(452,p)
#define TTL_LAST_REPEAT_453(m,p) m(453,p)
#define TTL_LAST_REPEAT_454(m,p) m(454,p)
#define TTL_LAST_REPEAT_455(m,p) m(455,p)
#define TTL_LAST_REPEAT_456(m,p) m(456,p)
#define TTL_LAST_REPEAT_457(m,p) m(457,p)
#define TTL_LAST_REPEAT_458(m,p) m(458,p)
#define TTL_LAST_REPEAT_459(m,p) m(459,p)
#define TTL_LAST_REPEAT_460(m,p) m(460,p)
#define TTL_LAST_REPEAT_461(m,p) m(461,p)
#define TTL_LAST_REPEAT_462(m,p) m(462,p)
#define TTL_LAST_REPEAT_463(m,p) m(463,p)
#define TTL_LAST_REPEAT_464(m,p) m(464,p)
#define TTL_LAST_REPEAT_465(m,p) m(465,p)
#define TTL_LAST_REPEAT_466(m,p) m(466,p)
#define TTL_LAST_REPEAT_467(m,p) m(467,p)
#define TTL_LAST_REPEAT_468(m,p) m(468,p)
#define TTL_LAST_REPEAT_469(m,p) m(469,p)
#define TTL_LAST_REPEAT_470(m,p) m(470,p)
#define TTL_LAST_REPEAT_471(m,p) m(471,p)
#define TTL_LAST_REPEAT_472(m,p) m(472,p)
#define TTL_LAST_REPEAT_473(m,p) m(473,p)
#define TTL_LAST_REPEAT_474(m,p) m(474,p)
#define TTL_LAST_REPEAT_475(m,p) m(475,p)
#define TTL_LAST_REPEAT_476(m,p) m(476,p)
#define TTL_LAST_REPEAT_477(m,p) m(477,p)
#define TTL_LAST_REPEAT_478(m,p) m(478,p)
#define TTL_LAST_REPEAT_479(m,p) m(479,p)
#define TTL_LAST_REPEAT_480(m,p) m(480,p)
#define TTL_LAST_REPEAT_481(m,p) m(481,p)
#define TTL_LAST_REPEAT_482(m,p) m(482,p)
#define TTL_LAST_REPEAT_483(m,p) m(483,p)
#define TTL_LAST_REPEAT_484(m,p) m(484,p)
#define TTL_LAST_REPEAT_485(m,p) m(485,p)
#define TTL_LAST_REPEAT_486(m,p) m(486,p)
#define TTL_LAST_REPEAT_487(m,p) m(487,p)
#define TTL_LAST_REPEAT_488(m,p) m(488,p)
#define TTL_LAST_REPEAT_489(m,p) m(489,p)
#define TTL_LAST_REPEAT_490(m,p) m(490,p)
#define TTL_LAST_REPEAT_491(m,p) m(491,p)
#define TTL_LAST_REPEAT_492(m,p) m(492,p)
#define TTL_LAST_REPEAT_493(m,p) m(493,p)
#define TTL_LAST_REPEAT_494(m,p) m(494,p)
#define TTL_LAST_REPEAT_495(m,p) m(495,p)
#define TTL_LAST_REPEAT_496(m,p) m(496,p)
#define TTL_LAST_REPEAT_497(m,p) m(497,p)
#define TTL_LAST_REPEAT_498(m,p) m(498,p)
#define TTL_LAST_REPEAT_499(m,p) m(499,p)
#define TTL_LAST_REPEAT_500(m,p) m(500,p)
#define TTL_LAST_REPEAT_501(m,p) m(501,p)
#define TTL_LAST_REPEAT_502(m,p) m(502,p)
#define TTL_LAST_REPEAT_503(m,p) m(503,p)
#define TTL_LAST_REPEAT_504(m,p) m(504,p)
#define TTL_LAST_REPEAT_505(m,p) m(505,p)
#define TTL_LAST_REPEAT_506(m,p) m(506,p)
#define TTL_LAST_REPEAT_507(m,p) m(507,p)
#define TTL_LAST_REPEAT_508(m,p) m(508,p)
#define TTL_LAST_REPEAT_509(m,p) m(509,p)
#define TTL_LAST_REPEAT_510(m,p) m(510,p)
#define TTL_LAST_REPEAT_511(m,p) m(511,p)
#define TTL_LAST_REPEAT_512(m,p) m(512,p)
/**
* n - repeat count
* m - `middle` macro
* l - `last` macro
* p - parameter name
*
* where \i macro is: <tt> MACRO(n, p) </tt>, where
* \c n is current counter value and
* \c p is param name provided at TTL_REPEAT
*
**/
#define TTL_REPEAT(n, m, l, p) TTL_APPEND(TTL_REPEAT_, TTL_DEC(n))(m,l,p) TTL_APPEND(TTL_LAST_REPEAT_,n)(l,p)
#define TTL_REPEAT_BIDIR(n, m, l, p) TTL_APPEND(TTL_REPEAT_, TTL_DEC(n))(m,l,TTL_INC(p)) l(n,p)
#define TTL_REPEAT_NEST(n, m, l, p) TTL_APPEND(TTL_REPEAT_, TTL_DEC(n))(m,l,p) l(n,p)
#endif //__macro_repeat__hpp
| [
"icestudent@gmail.com"
] | icestudent@gmail.com |
7ddf6a300691fe3aa767faea9575ee943504300a | 436db832ef9a8799216248aef43ad5644789624c | /src/containbox.cpp | 730012a3c4923b202dc2d09c5f90390a4ddc9dc9 | [] | no_license | bywbilly/naive-ray-tracing | c90445449c975e5e22449579ab6e0d59b63d022a | 3056aa6dea89754a6ac2561dcd6c540b1322eabd | refs/heads/master | 2021-01-23T02:35:29.393770 | 2017-04-06T04:59:27 | 2017-04-06T04:59:27 | 87,369,446 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,510 | cpp | #include <vector>
#include <iostream>
#include <cstring>
#include <algorithm>
#include "triangle.hpp"
#include "ray.hpp"
#include "containbox.hpp"
using std::cerr;
using std::endl;
using std::vector;
using std::min_element;
using std::max_element;
const int ContainBox::max_objects = 5;
static bool compare_x(Triangle *a, Triangle *b){
double aa[] = {a->a.x, a->b.x, a->c.x};
double bb[] = {b->a.x, b->b.x, b->c.x};
return *min_element(aa, aa + 3) < *min_element(bb, bb + 3);
}
static bool compare_y(Triangle *a, Triangle *b){
double aa[] = {a->a.y, a->b.y, a->c.y};
double bb[] = {b->a.y, b->b.y, b->c.y};
return *min_element(aa, aa + 3) < *min_element(bb, bb + 3);
}
void ContainBox::split(){
vector<Triangle *> x_dir[2];
std::sort(triangles.begin(), triangles.end(), compare_x);
int size = triangles.size();
x_dir[0] = vector<Triangle*>(triangles.begin(), triangles.begin() + (size >> 1));
x_dir[1] = vector<Triangle*>(triangles.begin() + (size >> 1), triangles.end());
for(int x = 0 ; x < 2 ; ++x){
vector<Triangle *> y_dir[2];
sort(x_dir[x].begin(), x_dir[x].end(), compare_y);
int size = x_dir[x].size();
y_dir[0] = vector<Triangle*>(x_dir[x].begin(), x_dir[x].begin() + (size >> 1));
y_dir[1] = vector<Triangle*>(x_dir[x].begin() + (size >> 1), x_dir[x].end());
for(int y = 0 ; y < 2 ; ++y){
vector<Triangle *> z_dir[2];
sort(y_dir[y].begin(), y_dir[y].end(), compare_y);
int size = y_dir[y].size();
z_dir[0] = vector<Triangle*>(y_dir[y].begin(), y_dir[y].begin() + (size >> 1));
z_dir[1] = vector<Triangle*>(y_dir[y].begin() + (size >> 1), y_dir[y].end());
for(int z = 0; z < 2; ++z) {
children[x * 4 + y * 2 + z] = new ContainBox(z_dir[z]);
}
}
}
triangles.clear();
}
void ContainBox::fitSize(){
if(triangles.empty()) {
return;
}
vector<double> nums;
for(int i = 0; i < triangles.size(); ++i)
for(int j = 0; j < 3; ++j) {
nums.push_back((*triangles[i])[j].x);
}
st.x = *min_element(nums.begin(), nums.end()) - EPSILON;
size.x = *max_element(nums.begin(), nums.end()) - st.x + EPSILON;
nums.clear();
for(int i = 0; i < triangles.size(); ++i)
for(int j = 0 ; j < 3 ; ++j) {
nums.push_back((*triangles[i])[j].y);
}
st.y = *min_element(nums.begin(), nums.end()) - EPSILON;
size.y = (*max_element(nums.begin(), nums.end())) - st.y + EPSILON;
nums.clear();
for(int i = 0; i < triangles.size(); ++i)
for(int j = 0; j < 3; ++j) {
nums.push_back((*triangles[i])[j].z);
}
st.z = *min_element(nums.begin(), nums.end()) - EPSILON;
size.z = *max_element(nums.begin(), nums.end()) - st.z + EPSILON;
nums.clear();
}
ContainBox::ContainBox(const vector<Triangle*> _t){
triangles = _t;
fitSize();
if(triangles.size() > max_objects) {
split();
}else{
memset(children, 0, 8 * sizeof(ContainBox *));
}
}
double ContainBox::_intersect(double p0, double p, double s){
if (p == 0) {
return NOT_INTERSECT;
}
return (s - p0) / p;
}
bool ContainBox::isPassing(const Ray & ray){
if(children[0] == NULL && triangles.empty()) return false;
if(ray.st.x - st.x > -EPSILON &&
ray.st.y - st.y > -EPSILON &&
ray.st.z - st.z > -EPSILON &&
ray.st.x - (st.x + size.x) < EPSILON &&
ray.st.y - (st.y + size.y) < EPSILON &&
ray.st.z - (st.z + size.z) < EPSILON) {
return true;
}
double mins[3];
double maxs[3];
mins[0] = _intersect(ray.st.x, ray.dir.x, st.x);
maxs[0] = _intersect(ray.st.x, ray.dir.x, st.x+size.x);
if(mins[0] > maxs[0]) {
_swap(mins[0], maxs[0]);
}
mins[1] = _intersect(ray.st.y, ray.dir.y, st.y);
maxs[1] = _intersect(ray.st.y, ray.dir.y, st.y+size.y);
if(mins[1] > maxs[1]) {
_swap(mins[1], maxs[1]);
}
mins[2] = _intersect(ray.st.z, ray.dir.z, st.z);
maxs[2] = _intersect(ray.st.z, ray.dir.z, st.z+size.z);
if(mins[2] > maxs[2]) {
_swap(mins[2], maxs[2]);
}
double max_of_mins = * max_element(mins, mins+3);
double min_of_maxs = maxs[0];
if(min_of_maxs == NOT_INTERSECT || (maxs[1] != NOT_INTERSECT && maxs[1] < min_of_maxs)) {
min_of_maxs = maxs[1];
}
if(min_of_maxs == NOT_INTERSECT || (maxs[2] != NOT_INTERSECT && maxs[2] < min_of_maxs)) {
min_of_maxs = maxs[2];
}
return max_of_mins <= min_of_maxs;
}
| [
"bywbilly@gmail.com"
] | bywbilly@gmail.com |
47f96bbdacaf2a8b68b5f7a9f082a0442866f19c | a4e7cbae8bc42865304ca4af95fae1311e8d478d | /Lab 3/Queue.h | c75c0a317153f0e43c23064887521cc60f6fb2e6 | [] | no_license | codehunter2000/CS311 | 939b463bf9aa2b4f4a350d67b6578bb8ee0193fd | 74e0f0fa39539b71420a36276c9b1127062d5953 | refs/heads/master | 2021-08-30T12:54:14.138888 | 2017-12-18T02:31:13 | 2017-12-18T02:31:13 | 105,468,218 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,249 | h | /*
Files: Queue.h, Queue.cpp
Author: Gabriel Hunt
Date Last Modified: 9/25/2017
*/
#include<string>
#include<vector>
#include<iostream>
using namespace std;
class Employee
{
protected:
long empId;
string empName;
string email;
public:
Employee() {}
Employee(long i, string n) { empName = n, empId = i; email = "Unknow"; }
friend ostream & operator<<(ostream & output, const Employee & em)
{
output << "ID: " << em.empId << "\t" << "Name: " << em.empName << "\t" << "Email: " << em.email << "\n";
return output;
}
};
class Student
{
private:
long stId;
int year;
string email;
string schoolName;
public:
Student() {}
Student(long i, int y, string sn) { stId = i; year = y; email = "Unknown"; schoolName = sn; }
friend ostream & operator<<(ostream & output, const Student & st)
{
output << "ID: " << st.stId << "\t" << "Year: " << st.year << "\n" << "Email: " << st.email
<< "\t" << "School: " << st.schoolName << "\n";
return output;
}
};
template<class T>
class Queue
{
private:
vector<T> theQ;
public:
Queue();
void Push(T item);
T Pop();
void ReadAnItem();
void PrintQ();
friend ostream& operator<<(ostream& os, const Student& st);
friend ostream& operator<<(ostream& os, const Employee& em);
}; | [
"gabrielrhunt@gmail.com"
] | gabrielrhunt@gmail.com |
2cc6b40bfbc59d6857be603a1da2907658ab5040 | 2d70c142616ade3db2996e7d794694c7acbf2f92 | /QtFileTransferClient/mainwindow.cpp | 34937fb04fb1bdaf89e1b14feefd2127e23cbaa4 | [] | no_license | lastagile/QtFileTransfer | 6f5d0ef8b2bc93e76bdfd66d7c1bc074d821ed86 | 57c77e7699142ba4a5316e428dce503f441a8db0 | refs/heads/master | 2021-01-15T09:08:55.064147 | 2012-03-08T02:51:53 | 2012-03-08T02:51:53 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 9,366 | cpp | #include "mainwindow.h"
#include "ui_mainwindow.h"
#include "../sharedstructures.h"
#include "../fileinfo.h"
#include <QDebug>
#include <QHostAddress>
#include <QProgressBar>
#include <QLabel>
#include <QVBoxLayout>
#include <QMessageBox>
#include <QSettings>
#include <QThread>
#include <QFileDialog>
#include <QTimer>
#include <QToolButton>
#include <QHBoxLayout>
#include <QCloseEvent>
#include <QGridLayout>
ClientUIBundle::ClientUIBundle() : UIBundle()
{
}
ClientUIBundle::ClientUIBundle(FileInfo* file, DownloadClient *clientObj,
QWidget *parent) :
UIBundle(parent)
{
this->file = file;
client = clientObj;
lblFilName->setText(file->getName());
pbProgress->setMaximum(file->getSize());
pbAction->connect(pbAction, SIGNAL(clicked()), clientObj, SLOT(abortFileTransfer()));
}
ClientUIBundle::~ClientUIBundle()
{
}
void ClientUIBundle::update(qint64 value, double speed)
{
UIBundle::update(value, speed, client->getTimeDownloading(), client->getTimeRemaining());
}
void ClientUIBundle::setAborted()
{
UIBundle::setAborted();
pbAction->connect(pbAction, SIGNAL(clicked()), client, SLOT(resumeFileTransfer()));
}
void ClientUIBundle::setResumed()
{
UIBundle::setResumed();
pbAction->connect(pbAction, SIGNAL(clicked()), client, SLOT(abortFileTransfer()));
}
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
connect(ui->pbGetFiles, SIGNAL(clicked()), this, SLOT(downloadFileList()));
connect(ui->pbDownloadSelected, SIGNAL(clicked()), this, SLOT(requestFileDownload()));
connect(ui->pbSelectDownloadDir, SIGNAL(clicked()), this, SLOT(selectNewSaveDirectory()));
QString Octet = "(?:[0-1]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])";
ui->leServerIP->setValidator(new QRegExpValidator(QRegExp("^" + Octet
+ "\\." + Octet
+ "\\." + Octet
+ "\\." + Octet + "$"), this));
settings = new QSettings(tr("Martin Bakiev"), tr("QtFileTransfer"), this);
if(settings->contains("client/ip"))
ui->leServerIP->setText(settings->value("client/ip").toString());
if(settings->contains("client/save_directory"))
ui->leDownloadDir->setText(settings->value("client/save_directory").toString());
tableModel = new FileListItemModel(this);
ui->tvFileList->setModel(tableModel);
ui->tvFileList->header()->setResizeMode(QHeaderView::ResizeToContents);
}
MainWindow::~MainWindow()
{
delete settings;
delete ui;
}
void MainWindow::closeEvent(QCloseEvent *event)
{
emit cleanUpThreads();
QHashIterator<DownloadClient*,DownloadWorkerBundle*> iter(workerHash);
while(iter.hasNext())
{
iter.next();
//This should wait for thread to quit properly
delete iter.value();
}
event->setAccepted(true);
}
void MainWindow::downloadFileList()
{
QHostAddress serverAddress;
if(!getServerAddress(&serverAddress))
return;
settings->setValue("client/ip", ui->leServerIP->text());
m_socket = new QTcpSocket(this);
connect(m_socket, SIGNAL(connected()), this, SLOT(sock_connected()));
connect(m_socket, SIGNAL(error(QAbstractSocket::SocketError)),
this, SLOT(sock_error(QAbstractSocket::SocketError)));
m_socket->connectToHost(serverAddress, DEFAULT_SERVER_LISTEN_PORT);
}
void MainWindow::requestFileDownload()
{
QHostAddress serverAddress;
QString downloadDir = ui->leDownloadDir->text();
if(!getServerAddress(&serverAddress))
return;
if(downloadDir.isEmpty())
{
QMessageBox::warning(this, tr("Please Select Download Location"), tr("Please select a directory to download the files to."), QMessageBox::Ok, QMessageBox::Ok);
return;
}
QModelIndex modelIndex = ui->tvFileList->currentIndex();
if(!modelIndex.isValid())
return;
FileInfo *file = static_cast<FileInfo*>(modelIndex.internalPointer());
if(!file || file->isDir())
return;
DownloadWorkerBundle *worker = new DownloadWorkerBundle();
worker->client = new DownloadClient(file);
worker->client->setServerAddress(serverAddress, DEFAULT_SERVER_LISTEN_PORT);
worker->client->setSaveDirectory(downloadDir);
worker->client->setUpdateInterval(300);
worker->thread = new QThread(this);
worker->client->moveToThread(worker->thread);
connect(worker->client, SIGNAL(fileTransferBeginning(FileInfo*,DownloadClient*)),
this, SLOT(fileTransferStarted(FileInfo*,DownloadClient*)));
connect(worker->client, SIGNAL(fileTransferUpdate(qint64,double,DownloadClient*)),
this, SLOT(fileTransferUpdated(qint64,double,DownloadClient*)));
connect(worker->client, SIGNAL(fileTransferComplete(DownloadClient*)),
this, SLOT(fileTransferCompleted(DownloadClient*)));
connect(worker->client, SIGNAL(fileTransferAborted(qint64,DownloadClient*)),
this, SLOT(fileTransferAborted(qint64,DownloadClient*)));
connect(worker->client, SIGNAL(fileTransferResumed(DownloadClient*)),
this, SLOT(fileTransferResumed(DownloadClient*)));
connect(worker->thread, SIGNAL(started()), worker->client, SLOT(beginDownload()));
connect(worker->client, SIGNAL(finished()), worker->thread, SLOT(quit()));
worker->thread->start();
workerHash.insert(worker->client, worker);
}
void MainWindow::selectNewSaveDirectory()
{
QFileDialog dialog(this);
dialog.setFileMode(QFileDialog::Directory);
dialog.setOption(QFileDialog::ShowDirsOnly, false);
if(settings->contains("client/save_directory"))
dialog.setDirectory(settings->value("client/save_directory").toString());
QStringList selectedDir;
if(dialog.exec())
selectedDir = dialog.selectedFiles();
if(selectedDir.count() > 0)
{
ui->leDownloadDir->setText(selectedDir.at(0));
settings->setValue("client/save_directory", selectedDir.at(0));
}
}
void MainWindow::sock_connected()
{
if(!m_socket->isValid())
{
return;
}
list_ack_receieved = false;
connControlMsg msg;
msg.message = REQUEST_FILE_LIST;
m_socket->write((char*)&msg, sizeof(msg));
connect(m_socket, SIGNAL(readyRead()), this, SLOT(onListReceiveData()));
connect(m_socket, SIGNAL(disconnected()), this, SLOT(sock_disconn()));
}
void MainWindow::sock_error(QAbstractSocket::SocketError err)
{
qDebug() << "SOCKET ERROR: " << err;
if(err == QAbstractSocket::ConnectionRefusedError)
{
QMessageBox::warning(this, tr("Connection Failed"),
tr("Could not connect to server. Please ensure the IP address is correct."),
QMessageBox::Ok, QMessageBox::Ok);
m_socket->deleteLater();
}
else if(err != QAbstractSocket::RemoteHostClosedError)
{
QMessageBox::warning(this, tr("Network Error"),
tr("There was a network error, please try again later."),
QMessageBox::Ok, QMessageBox::Ok);
m_socket->close();
}
}
void MainWindow::sock_disconn()
{
disconnect(m_socket, 0,0,0);
m_socket->deleteLater();
}
void MainWindow::onListReceiveData()
{
if(!list_ack_receieved)
{
connControlMsg msg;
m_socket->read((char*)&msg, sizeof(msg));
if(msg.message == LIST_REQUEST_REJECTED)
{
m_socket->close();
return;
}
//qDebug() << "Received ACK";
list_ack_receieved = true;
m_items_received = 0;
m_items_total = msg.list_size;
}
unsigned int size;
while(m_socket->bytesAvailable() > 0)
{
//Make sure we have enough data available to
//read the entire message
m_socket->peek((char*)&size, sizeof(size));
if(m_socket->bytesAvailable() < size)
return;
m_socket->read((char*)&size, sizeof(size));
char *buff = new char[size];
m_socket->read(buff, size);
FileInfo *fi = new FileInfo();
fi->setFromByteArray(buff);
this->tableModel->insertRowWithData(fi);
m_items_received++;
delete [] buff;
}
if(m_items_received == m_items_total)
{
qDebug() << "Closing...";
m_socket->close();
}
}
void MainWindow::fileTransferStarted(FileInfo* file, DownloadClient* dc)
{
if(!workerHash.contains(dc))
return;
DownloadWorkerBundle *worker = workerHash.value(dc);
worker->ui = new ClientUIBundle(file, dc, this);
worker->ui->insertIntoLayout(1, ui->vlProgressBars);
}
void MainWindow::fileTransferUpdated(qint64 bytes, double speed, DownloadClient *dc)
{
if(!workerHash.contains(dc))
return;
workerHash.value(dc)->ui->update(bytes, speed);
}
void MainWindow::fileTransferCompleted(DownloadClient *dc)
{
if(!workerHash.contains(dc))
return;
workerHash.value(dc)->ui->setFinished();
toRemove.enqueue(workerHash.value(dc));
QTimer::singleShot(10000, this, SLOT(removeDownloadUI()));
}
void MainWindow::fileTransferAborted(qint64 bytes_recieved, DownloadClient *dc)
{
if(!workerHash.contains(dc))
return;
workerHash.value(dc)->ui->update(bytes_recieved, 0.0);
workerHash.value(dc)->ui->setAborted();
//What to do now?
// probably connect restart button to client slot that restarts the download where it left
// off
}
void MainWindow::fileTransferResumed(DownloadClient *dc)
{
//qDebug() << "Setting UI Resumed";
if(!workerHash.contains(dc))
return;
workerHash.value(dc)->ui->setResumed();
}
void MainWindow::removeDownloadUI()
{
DownloadWorkerBundle *worker = toRemove.dequeue();
workerHash.remove(worker->client);
worker->ui->removeFromLayout(ui->vlProgressBars);
delete worker;
}
bool MainWindow::getServerAddress(QHostAddress *addr)
{
if(!addr->setAddress(ui->leServerIP->text()))
{
QMessageBox::warning(this, tr("Invalid Server Address"), tr("The entered server IP address is invalid, please correct it."), QMessageBox::Ok, QMessageBox::Ok);
return false;
}
return true;
}
| [
"mbakiev@gmail.com"
] | mbakiev@gmail.com |
6cd64b115b1d885a38b16f7d73c327ccb79485bb | 613ea8f52d144343895654cf81090f6afd730f9a | /Level-1/Recursion-1b/PairStar.cpp | fb4fc45f167c7c2f6935b2f8584d44fab8c2c4a8 | [] | no_license | 2505shivang/CodingNinjaDS-AlgoSolutions | e74509f302f5328649ce66264975f4616c819db7 | 48522e2c9ba820663d88d45fafc77419fc546222 | refs/heads/main | 2023-06-14T21:11:28.282346 | 2021-07-03T17:47:16 | 2021-07-03T17:47:16 | 382,556,549 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 406 | cpp | int length(char input[]){
int len = 0;
while(input[len]!='\0')len++;
return len;
}
void pairStar(char input[]) {
if(input[0]=='\0' || input[1]=='\0'){
return;
}
pairStar(input+1);
if(input[0]==input[1]){
int len = length(input);
for(int i=len;i>=1;--i){
input[i+1] = input[i];
}
input[1] = '*';
}
return;
} | [
"2505shivang@gmail.com"
] | 2505shivang@gmail.com |
ac9220c82bf9b52be05be5b1664a51c5da707a69 | 87c9d7a770db8202159cd53830bae97d32cf79d1 | /third_party/adhd/cras/src/tests/a2dp_iodev_unittest.cc | c85b9d6749f96aeb7b893b3c4176aaa075b57453 | [
"LicenseRef-scancode-bsd-x11",
"LicenseRef-scancode-other-permissive",
"BSD-1-Clause",
"BSD-3-Clause"
] | permissive | saiprakash-ranjan/crosvm | e66b22c5e511ea7d7752460da3160bc6d8f6ea88 | ed8bf02422c91ba93b33342bb1ebc32dad9c480a | refs/heads/master | 2022-03-28T06:09:27.384398 | 2019-12-29T13:23:45 | 2019-12-29T13:23:45 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 17,426 | cc | // Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <gtest/gtest.h>
#include <stdint.h>
#include <stdio.h>
extern "C" {
#include "a2dp-codecs.h"
#include "audio_thread.h"
#include "audio_thread_log.h"
#include "cras_a2dp_iodev.h"
#include "cras_audio_area.h"
#include "cras_bt_transport.h"
#include "cras_iodev.h"
}
#define FAKE_OBJECT_PATH "/fake/obj/path"
#define MAX_A2DP_ENCODE_CALLS 8
#define MAX_A2DP_WRITE_CALLS 4
static struct cras_bt_transport* fake_transport;
static cras_audio_format format;
static size_t cras_bt_device_append_iodev_called;
static size_t cras_bt_device_rm_iodev_called;
static size_t cras_iodev_add_node_called;
static int cras_iodev_frames_queued_called;
static size_t cras_iodev_rm_node_called;
static size_t cras_iodev_set_active_node_called;
static size_t cras_bt_transport_acquire_called;
static size_t cras_bt_transport_configuration_called;
static size_t cras_bt_transport_release_called;
static size_t init_a2dp_called;
static int init_a2dp_return_val;
static size_t destroy_a2dp_called;
static size_t drain_a2dp_called;
static size_t a2dp_block_size_called;
static size_t a2dp_queued_frames_val;
static size_t cras_iodev_free_format_called;
static size_t cras_iodev_free_resources_called;
static int pcm_buf_size_val[MAX_A2DP_ENCODE_CALLS];
static unsigned int a2dp_encode_processed_bytes_val[MAX_A2DP_ENCODE_CALLS];
static unsigned int a2dp_encode_index;
static int a2dp_write_return_val[MAX_A2DP_WRITE_CALLS];
static unsigned int a2dp_write_index;
static cras_audio_area* dummy_audio_area;
static thread_callback write_callback;
static void* write_callback_data;
static const char* fake_device_name = "fake device name";
static const char* cras_bt_device_name_ret;
static unsigned int cras_bt_transport_write_mtu_ret;
void ResetStubData() {
cras_bt_device_append_iodev_called = 0;
cras_bt_device_rm_iodev_called = 0;
cras_iodev_add_node_called = 0;
cras_iodev_frames_queued_called = 0;
cras_iodev_rm_node_called = 0;
cras_iodev_set_active_node_called = 0;
cras_bt_transport_acquire_called = 0;
cras_bt_transport_configuration_called = 0;
cras_bt_transport_release_called = 0;
init_a2dp_called = 0;
init_a2dp_return_val = 0;
destroy_a2dp_called = 0;
drain_a2dp_called = 0;
a2dp_block_size_called = 0;
a2dp_queued_frames_val = 0;
cras_iodev_free_format_called = 0;
cras_iodev_free_resources_called = 0;
memset(a2dp_encode_processed_bytes_val, 0,
sizeof(a2dp_encode_processed_bytes_val));
a2dp_encode_index = 0;
a2dp_write_index = 0;
cras_bt_transport_write_mtu_ret = 800;
fake_transport = reinterpret_cast<struct cras_bt_transport*>(0x123);
if (!dummy_audio_area) {
dummy_audio_area = (cras_audio_area*)calloc(
1, sizeof(*dummy_audio_area) + sizeof(cras_channel_area) * 2);
}
write_callback = NULL;
}
int iodev_set_format(struct cras_iodev* iodev, struct cras_audio_format* fmt) {
fmt->format = SND_PCM_FORMAT_S16_LE;
fmt->num_channels = 2;
fmt->frame_rate = 44100;
iodev->format = fmt;
return 0;
}
namespace {
static struct timespec time_now;
class A2dpIodev : public testing::Test {
protected:
virtual void SetUp() {
ResetStubData();
atlog = (audio_thread_event_log*)calloc(1, sizeof(audio_thread_event_log));
}
virtual void TearDown() {
free(dummy_audio_area);
dummy_audio_area = NULL;
free(atlog);
}
};
TEST_F(A2dpIodev, InitializeA2dpIodev) {
struct cras_iodev* iodev;
cras_bt_device_name_ret = NULL;
iodev = a2dp_iodev_create(fake_transport);
ASSERT_NE(iodev, (void*)NULL);
ASSERT_EQ(iodev->direction, CRAS_STREAM_OUTPUT);
ASSERT_EQ(1, cras_bt_transport_configuration_called);
ASSERT_EQ(1, init_a2dp_called);
ASSERT_EQ(1, cras_bt_device_append_iodev_called);
ASSERT_EQ(1, cras_iodev_add_node_called);
ASSERT_EQ(1, cras_iodev_set_active_node_called);
/* Assert iodev name matches the object path when bt device doesn't
* have its readable name populated. */
ASSERT_STREQ(FAKE_OBJECT_PATH, iodev->info.name);
a2dp_iodev_destroy(iodev);
ASSERT_EQ(1, cras_bt_device_rm_iodev_called);
ASSERT_EQ(1, cras_iodev_rm_node_called);
ASSERT_EQ(1, destroy_a2dp_called);
ASSERT_EQ(1, cras_iodev_free_resources_called);
cras_bt_device_name_ret = fake_device_name;
/* Assert iodev name matches the bt device's name */
iodev = a2dp_iodev_create(fake_transport);
ASSERT_STREQ(fake_device_name, iodev->info.name);
a2dp_iodev_destroy(iodev);
}
TEST_F(A2dpIodev, InitializeFail) {
struct cras_iodev* iodev;
init_a2dp_return_val = -1;
iodev = a2dp_iodev_create(fake_transport);
ASSERT_EQ(iodev, (void*)NULL);
ASSERT_EQ(1, cras_bt_transport_configuration_called);
ASSERT_EQ(1, init_a2dp_called);
ASSERT_EQ(0, cras_bt_device_append_iodev_called);
ASSERT_EQ(0, cras_iodev_add_node_called);
ASSERT_EQ(0, cras_iodev_set_active_node_called);
ASSERT_EQ(0, cras_iodev_rm_node_called);
}
TEST_F(A2dpIodev, OpenIodev) {
struct cras_iodev* iodev;
iodev = a2dp_iodev_create(fake_transport);
iodev_set_format(iodev, &format);
iodev->configure_dev(iodev);
ASSERT_EQ(1, cras_bt_transport_acquire_called);
iodev->close_dev(iodev);
ASSERT_EQ(1, cras_bt_transport_release_called);
ASSERT_EQ(1, drain_a2dp_called);
ASSERT_EQ(1, cras_iodev_free_format_called);
a2dp_iodev_destroy(iodev);
}
TEST_F(A2dpIodev, GetPutBuffer) {
struct cras_iodev* iodev;
struct cras_audio_area *area1, *area2, *area3;
uint8_t* area1_buf;
unsigned frames;
iodev = a2dp_iodev_create(fake_transport);
iodev_set_format(iodev, &format);
iodev->configure_dev(iodev);
ASSERT_NE(write_callback, (void*)NULL);
frames = 256;
iodev->get_buffer(iodev, &area1, &frames);
ASSERT_EQ(256, frames);
ASSERT_EQ(256, area1->frames);
area1_buf = area1->channels[0].buf;
/* Test 100 frames(400 bytes) put and all processed. */
a2dp_encode_processed_bytes_val[0] = 400;
a2dp_write_index = 0;
a2dp_write_return_val[0] = 400;
iodev->put_buffer(iodev, 100);
write_callback(write_callback_data);
// Start with 4k frames.
EXPECT_EQ(400, pcm_buf_size_val[0]);
iodev->get_buffer(iodev, &area2, &frames);
ASSERT_EQ(256, frames);
ASSERT_EQ(256, area2->frames);
/* Assert buf2 points to the same position as buf1 */
ASSERT_EQ(400, area2->channels[0].buf - area1_buf);
/* Test 100 frames(400 bytes) put, only 360 bytes processed,
* 40 bytes left in pcm buffer.
*/
a2dp_encode_index = 0;
a2dp_encode_processed_bytes_val[0] = 360;
a2dp_encode_processed_bytes_val[1] = 0;
a2dp_write_index = 0;
a2dp_write_return_val[0] = 360;
a2dp_write_return_val[1] = 0;
iodev->put_buffer(iodev, 100);
write_callback(write_callback_data);
EXPECT_EQ(400, pcm_buf_size_val[0]);
ASSERT_EQ(40, pcm_buf_size_val[1]);
iodev->get_buffer(iodev, &area3, &frames);
/* Existing buffer not completed processed, assert new buffer starts from
* current write pointer.
*/
ASSERT_EQ(256, frames);
EXPECT_EQ(800, area3->channels[0].buf - area1_buf);
iodev->close_dev(iodev);
a2dp_iodev_destroy(iodev);
}
TEST_F(A2dpIodev, FramesQueued) {
struct cras_iodev* iodev;
struct cras_audio_area* area;
struct timespec tstamp;
unsigned frames;
iodev = a2dp_iodev_create(fake_transport);
iodev_set_format(iodev, &format);
time_now.tv_sec = 0;
time_now.tv_nsec = 0;
iodev->configure_dev(iodev);
ASSERT_NE(write_callback, (void*)NULL);
frames = 256;
iodev->get_buffer(iodev, &area, &frames);
ASSERT_EQ(256, frames);
ASSERT_EQ(256, area->frames);
/* Put 100 frames, proccessed 400 bytes to a2dp buffer.
* Assume 200 bytes written out, queued 50 frames in a2dp buffer.
*/
a2dp_encode_processed_bytes_val[0] = 400;
a2dp_write_return_val[0] = 50;
a2dp_queued_frames_val = 50;
time_now.tv_sec = 0;
time_now.tv_nsec = 1000000;
iodev->put_buffer(iodev, 200);
write_callback(write_callback_data);
EXPECT_EQ(200, iodev->frames_queued(iodev, &tstamp));
EXPECT_EQ(tstamp.tv_sec, time_now.tv_sec);
EXPECT_EQ(tstamp.tv_nsec, time_now.tv_nsec);
/* After writing another 200 frames, check for correct buffer level. */
time_now.tv_sec = 0;
time_now.tv_nsec = 2000000;
a2dp_encode_index = 0;
a2dp_write_index = 0;
a2dp_encode_processed_bytes_val[0] = 400;
write_callback(write_callback_data);
/* 1000000 nsec has passed, estimated queued frames adjusted by 44 */
EXPECT_EQ(156, iodev->frames_queued(iodev, &tstamp));
EXPECT_EQ(400, pcm_buf_size_val[0]);
EXPECT_EQ(tstamp.tv_sec, time_now.tv_sec);
EXPECT_EQ(tstamp.tv_nsec, time_now.tv_nsec);
/* Queued frames and new put buffer are all written */
a2dp_encode_processed_bytes_val[0] = 400;
a2dp_encode_processed_bytes_val[1] = 0;
a2dp_encode_index = 0;
a2dp_write_return_val[0] = 400;
a2dp_write_return_val[1] = -EAGAIN;
a2dp_write_index = 0;
/* Add wnother 200 samples, get back to the original level. */
time_now.tv_sec = 0;
time_now.tv_nsec = 50000000;
a2dp_encode_processed_bytes_val[0] = 600;
a2dp_queued_frames_val = 50;
iodev->put_buffer(iodev, 200);
EXPECT_EQ(800, pcm_buf_size_val[0]);
EXPECT_EQ(100, iodev->frames_queued(iodev, &tstamp));
EXPECT_EQ(tstamp.tv_sec, time_now.tv_sec);
EXPECT_EQ(tstamp.tv_nsec, time_now.tv_nsec);
iodev->close_dev(iodev);
a2dp_iodev_destroy(iodev);
}
TEST_F(A2dpIodev, FlushAtLowBufferLevel) {
struct cras_iodev* iodev;
struct cras_audio_area* area;
struct timespec tstamp;
unsigned frames;
iodev = a2dp_iodev_create(fake_transport);
iodev_set_format(iodev, &format);
time_now.tv_sec = 0;
time_now.tv_nsec = 0;
iodev->configure_dev(iodev);
ASSERT_NE(write_callback, (void*)NULL);
ASSERT_EQ(iodev->min_buffer_level, 400);
frames = 700;
iodev->get_buffer(iodev, &area, &frames);
ASSERT_EQ(700, frames);
ASSERT_EQ(700, area->frames);
/* First call to a2dp_encode() processed 800 bytes. */
a2dp_encode_processed_bytes_val[0] = 800;
a2dp_encode_processed_bytes_val[1] = 0;
a2dp_write_return_val[0] = 200;
/* put_buffer shouldn't trigger the 2nd call to a2dp_encode() because
* buffer is low. Fake some data to make sure this test case will fail
* when a2dp_encode() called twice.
*/
a2dp_encode_processed_bytes_val[2] = 800;
a2dp_encode_processed_bytes_val[3] = 0;
a2dp_write_return_val[1] = -EAGAIN;
time_now.tv_nsec = 10000000;
iodev->put_buffer(iodev, 700);
time_now.tv_nsec = 20000000;
EXPECT_EQ(500, iodev->frames_queued(iodev, &tstamp));
EXPECT_EQ(tstamp.tv_sec, time_now.tv_sec);
EXPECT_EQ(tstamp.tv_nsec, time_now.tv_nsec);
iodev->close_dev(iodev);
a2dp_iodev_destroy(iodev);
}
TEST_F(A2dpIodev, NoStreamState) {
struct cras_iodev* iodev;
struct cras_audio_area* area;
struct timespec tstamp;
unsigned frames;
iodev = a2dp_iodev_create(fake_transport);
iodev_set_format(iodev, &format);
time_now.tv_sec = 0;
time_now.tv_nsec = 0;
iodev->configure_dev(iodev);
ASSERT_NE(write_callback, (void*)NULL);
ASSERT_EQ(400, iodev->min_buffer_level);
iodev->min_cb_level = 480;
frames = 200;
iodev->get_buffer(iodev, &area, &frames);
iodev->put_buffer(iodev, 200);
iodev->no_stream(iodev, 1);
EXPECT_EQ(1, cras_iodev_frames_queued_called);
/* no_stream will fill the buffer to hw_level = (441 (44100 * 0.01)) * 2
* frames, but 200 < min_buffer_level so cras_iodev_frames_queued will return
* 0 in no_stream and no_stream will fill 882 frames to device buffer.
*/
frames = iodev->frames_queued(iodev, &tstamp);
ASSERT_EQ(1082, frames);
/* After leaving no stream state, output buffer won't be adjusted */
iodev->no_stream(iodev, 0);
frames = iodev->frames_queued(iodev, &tstamp);
ASSERT_EQ(1082, frames);
}
} // namespace
int main(int argc, char** argv) {
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
extern "C" {
int cras_bt_transport_configuration(const struct cras_bt_transport* transport,
void* configuration,
int len) {
cras_bt_transport_configuration_called++;
return 0;
}
int cras_bt_transport_acquire(struct cras_bt_transport* transport) {
cras_bt_transport_acquire_called++;
return 0;
}
int cras_bt_transport_release(struct cras_bt_transport* transport,
unsigned int blocking) {
cras_bt_transport_release_called++;
return 0;
}
int cras_bt_transport_fd(const struct cras_bt_transport* transport) {
return 0;
}
const char* cras_bt_transport_object_path(
const struct cras_bt_transport* transport) {
return FAKE_OBJECT_PATH;
}
uint16_t cras_bt_transport_write_mtu(
const struct cras_bt_transport* transport) {
return cras_bt_transport_write_mtu_ret;
}
int cras_bt_transport_set_volume(struct cras_bt_transport* transport,
uint16_t volume) {
return 0;
}
void cras_iodev_free_format(struct cras_iodev* iodev) {
cras_iodev_free_format_called++;
}
void cras_iodev_free_resources(struct cras_iodev* iodev) {
cras_iodev_free_resources_called++;
}
// Cras iodev
void cras_iodev_add_node(struct cras_iodev* iodev, struct cras_ionode* node) {
cras_iodev_add_node_called++;
iodev->nodes = node;
}
void cras_iodev_rm_node(struct cras_iodev* iodev, struct cras_ionode* node) {
cras_iodev_rm_node_called++;
iodev->nodes = NULL;
}
void cras_iodev_set_active_node(struct cras_iodev* iodev,
struct cras_ionode* node) {
cras_iodev_set_active_node_called++;
iodev->active_node = node;
}
// From cras_bt_transport
struct cras_bt_device* cras_bt_transport_device(
const struct cras_bt_transport* transport) {
return reinterpret_cast<struct cras_bt_device*>(0x456);
;
}
enum cras_bt_device_profile cras_bt_transport_profile(
const struct cras_bt_transport* transport) {
return CRAS_BT_DEVICE_PROFILE_A2DP_SOURCE;
}
// From cras_bt_device
const char* cras_bt_device_name(const struct cras_bt_device* device) {
return cras_bt_device_name_ret;
}
const char* cras_bt_device_object_path(const struct cras_bt_device* device) {
return "/org/bluez/hci0/dev_1A_2B_3C_4D_5E_6F";
}
void cras_bt_device_append_iodev(struct cras_bt_device* device,
struct cras_iodev* iodev,
enum cras_bt_device_profile profile) {
cras_bt_device_append_iodev_called++;
}
void cras_bt_device_rm_iodev(struct cras_bt_device* device,
struct cras_iodev* iodev) {
cras_bt_device_rm_iodev_called++;
}
int cras_bt_device_get_use_hardware_volume(struct cras_bt_device* device) {
return 0;
}
int cras_bt_device_cancel_suspend(struct cras_bt_device* device) {
return 0;
}
int cras_bt_device_schedule_suspend(struct cras_bt_device* device,
unsigned int msec) {
return 0;
}
int init_a2dp(struct a2dp_info* a2dp, a2dp_sbc_t* sbc) {
init_a2dp_called++;
return init_a2dp_return_val;
}
void destroy_a2dp(struct a2dp_info* a2dp) {
destroy_a2dp_called++;
}
int a2dp_codesize(struct a2dp_info* a2dp) {
return 512;
}
int a2dp_block_size(struct a2dp_info* a2dp, int encoded_bytes) {
a2dp_block_size_called++;
// Assumes a2dp block size is 1:1 before/after encode.
return encoded_bytes;
}
int a2dp_queued_frames(struct a2dp_info* a2dp) {
return a2dp_queued_frames_val;
}
void a2dp_drain(struct a2dp_info* a2dp) {
drain_a2dp_called++;
}
int a2dp_encode(struct a2dp_info* a2dp,
const void* pcm_buf,
int pcm_buf_size,
int format_bytes,
size_t link_mtu) {
unsigned int processed;
if (a2dp_encode_index == MAX_A2DP_ENCODE_CALLS)
return 0;
processed = a2dp_encode_processed_bytes_val[a2dp_encode_index];
pcm_buf_size_val[a2dp_encode_index] = pcm_buf_size;
a2dp_encode_index++;
return processed;
}
int a2dp_write(struct a2dp_info* a2dp, int stream_fd, size_t link_mtu) {
return a2dp_write_return_val[a2dp_write_index++];
;
}
int clock_gettime(clockid_t clk_id, struct timespec* tp) {
*tp = time_now;
return 0;
}
void cras_iodev_init_audio_area(struct cras_iodev* iodev, int num_channels) {
iodev->area = dummy_audio_area;
}
void cras_iodev_free_audio_area(struct cras_iodev* iodev) {}
int cras_iodev_frames_queued(struct cras_iodev* iodev,
struct timespec* hw_tstamp) {
int rc;
cras_iodev_frames_queued_called++;
rc = iodev->frames_queued(iodev, hw_tstamp);
if (rc < 0)
return 0;
unsigned int num_queued = (unsigned int)rc;
if (num_queued < iodev->min_buffer_level)
return 0;
return num_queued - iodev->min_buffer_level;
}
void cras_audio_area_config_buf_pointers(struct cras_audio_area* area,
const struct cras_audio_format* fmt,
uint8_t* base_buffer) {
dummy_audio_area->channels[0].buf = base_buffer;
}
struct audio_thread* cras_iodev_list_get_audio_thread() {
return NULL;
}
// From audio_thread
struct audio_thread_event_log* atlog;
void audio_thread_add_write_callback(int fd, thread_callback cb, void* data) {
write_callback = cb;
write_callback_data = data;
}
int audio_thread_rm_callback_sync(struct audio_thread* thread, int fd) {
return 0;
}
void audio_thread_enable_callback(int fd, int enabled) {}
}
| [
"jie.deng@intel.com"
] | jie.deng@intel.com |
ee440efdffe9e4738c2355011a47b228404897af | 43a525edb1d27419c104638b98c91eb5cc381971 | /libs/src/vtlib/vtosg/Material.cpp | 674c3e72d8091338459418b1909b9b81e375f2b8 | [] | no_license | prash471/ofxVTerrain | ac1ca0bff99cf504a0f7e757bdc12d1cf16ae0a8 | c10ae051579bdb6693c5cdbb0b6247d3d0e1aa25 | refs/heads/master | 2021-01-16T21:14:33.585563 | 2013-04-17T19:06:45 | 2013-04-17T19:06:45 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 18,693 | cpp | //
// Material.cpp - Materials for vtlib-OSG
//
// Copyright (c) 2001-2011 Virtual Terrain Project
// Free for all uses, see license.txt for details.
//
#include "vtlib/vtlib.h"
#include <osg/PolygonMode>
///////////////////////////////////
bool vtMaterial::s_bTextureCompression = false;
#define SA_ON osg::StateAttribute::ON
#define SA_OFF osg::StateAttribute::OFF
vtMaterial::vtMaterial() : osg::StateSet()
{
m_pMaterial = new osg::Material;
setAttributeAndModes(m_pMaterial.get());
// Not sure why this is required (should be the default!)
setMode(GL_DEPTH_TEST, SA_ON);
}
/**
* Copy this material from another.
*/
void vtMaterial::CopyFrom(vtMaterial *pFrom)
{
SetDiffuse1(pFrom->GetDiffuse());
SetSpecular1(pFrom->GetSpecular());
SetAmbient1(pFrom->GetAmbient());
SetEmission1(pFrom->GetEmission());
SetCulling(pFrom->GetCulling());
SetLighting(pFrom->GetLighting());
// SetTexture(pFrom->GetTexture());
SetTransparent(pFrom->GetTransparent());
}
/**
* Set the diffuse color of this material.
*
* \param r,g,b The rgb value (0.0 to 1.0) of this material
* \param a For a material with transparency enabled, the alpha component
* of the diffuse color determines the overall transparency of the material.
* This value ranges from 0 (totally transparent) to 1 (totally opaque.)
*
*/
void vtMaterial::SetDiffuse(float r, float g, float b, float a)
{
m_pMaterial->setDiffuse(FAB, osg::Vec4(r, g, b, a));
if (a < 1.0f)
SetTransparent(true);
}
/**
* Get the diffuse color of this material.
*/
RGBAf vtMaterial::GetDiffuse() const
{
osg::Vec4 col = m_pMaterial->getDiffuse(FAB);
return RGBAf(col[0], col[1], col[2], col[3]);
}
/**
* Set the specular color of this material.
*/
void vtMaterial::SetSpecular(float r, float g, float b)
{
m_pMaterial->setSpecular(FAB, osg::Vec4(r, g, b, 1.0f));
}
/**
* Get the specular color of this material.
*/
RGBf vtMaterial::GetSpecular() const
{
osg::Vec4 col = m_pMaterial->getSpecular(FAB);
return RGBf(col[0], col[1], col[2]);
}
/**
* Set the ambient color of this material.
*/
void vtMaterial::SetAmbient(float r, float g, float b)
{
m_pMaterial->setAmbient(FAB, osg::Vec4(r, g, b, 1.0f));
}
/**
* Get the ambient color of this material.
*/
RGBf vtMaterial::GetAmbient() const
{
osg::Vec4 col = m_pMaterial->getAmbient(FAB);
return RGBf(col[0], col[1], col[2]);
}
/**
* Set the emissive color of this material.
*/
void vtMaterial::SetEmission(float r, float g, float b)
{
m_pMaterial->setEmission(FAB, osg::Vec4(r, g, b, 1.0f));
}
/**
* Get the emissive color of this material.
*/
RGBf vtMaterial::GetEmission() const
{
osg::Vec4 col = m_pMaterial->getEmission(FAB);
return RGBf(col[0], col[1], col[2]);
}
/**
* Set the backface culling property of this material.
*/
void vtMaterial::SetCulling(bool bCulling)
{
setMode(GL_CULL_FACE, bCulling ? SA_ON : SA_OFF);
}
/**
* Get the backface culling property of this material.
*/
bool vtMaterial::GetCulling() const
{
osg::StateAttribute::GLModeValue m;
m = getMode(GL_CULL_FACE);
return (m == SA_ON);
}
/**
* Set the lighting property of this material.
*/
void vtMaterial::SetLighting(bool bLighting)
{
setMode(GL_LIGHTING, bLighting ? SA_ON : SA_OFF);
}
/**
* Get the lighting property of this material.
*/
bool vtMaterial::GetLighting() const
{
osg::StateAttribute::GLModeValue m;
m = getMode(GL_LIGHTING);
return (m == SA_ON);
}
/**
* Set the transparent property of this material.
*
* \param bOn True to turn on transparency (blending).
* \param bAdd True for additive blending.
*/
void vtMaterial::SetTransparent(bool bOn, bool bAdd)
{
// setMode(GL_BLEND, bOn ? SA_ON : SA_OFF);
if (bOn)
{
if (!m_pBlendFunc.valid())
m_pBlendFunc = new osg::BlendFunc;
setAttributeAndModes(m_pBlendFunc.get(), SA_ON);
if (!m_pAlphaFunc.valid())
m_pAlphaFunc = new osg::AlphaFunc;
m_pAlphaFunc->setFunction(osg::AlphaFunc::GEQUAL,0.05f);
setAttributeAndModes(m_pAlphaFunc.get(), SA_ON );
setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
#if MAYBE_SOMEDAY
// RJ says he needed this to make multiple transparent surfaces work
// properly. In general, the transparent bin takes care of that,
// but there are cases where polygons (sorted by center) can end up
// in the wrong order.
ref_ptr<Depth> pDepth = new osg::Depth;
pDepth->setWriteMask(false);
setAttribute(pDepth.get());
#endif
}
else
{
setMode(GL_BLEND, SA_OFF);
setRenderingHint( StateSet::OPAQUE_BIN );
}
if (bAdd)
{
if (!m_pBlendFunc.valid())
m_pBlendFunc = new osg::BlendFunc;
// m_pBlendFunc->setFunction(GL_ONE, GL_ONE);
// m_pBlendFunc->setFunction(GL_SRC_COLOR, GL_DST_COLOR);
m_pBlendFunc->setFunction(GL_ONE, GL_ONE_MINUS_SRC_COLOR);
setAttribute(m_pBlendFunc.get());
}
}
/**
* Get the transparent property of this material.
*/
bool vtMaterial::GetTransparent() const
{
// OSG 0.8.45 and before
// osg::StateAttribute::GLModeValue m = getMode(osg::StateAttribute::TRANSPARENCY);
// OSG 0.9.0 onwards
osg::StateAttribute::GLModeValue m;
m = getMode(GL_BLEND);
return (m == SA_ON);
}
/**
* Set the wireframe property of this material.
*
* \param bOn True to turn on wireframe.
*/
void vtMaterial::SetWireframe(bool bOn)
{
if (bOn)
{
osg::PolygonMode *pm = new osg::PolygonMode;
pm->setMode(osg::PolygonMode::FRONT_AND_BACK, osg::PolygonMode::LINE);
setAttributeAndModes(pm, osg::StateAttribute::OVERRIDE | SA_ON);
}
else
{
// turn wireframe off
setMode(GL_POLYGON_MODE, osg::StateAttribute::OFF);
}
}
/**
* Get the wireframe property of this material.
*/
bool vtMaterial::GetWireframe() const
{
// OSG 0.9.0
osg::StateAttribute::GLModeValue m;
m = getMode(osg::StateAttribute::POLYGONMODE);
return (m == SA_ON);
}
/**
* Set the texture for this material.
*/
void vtMaterial::SetTexture(osg::Image *pImage)
{
if (!m_pTexture)
m_pTexture = new osg::Texture2D;
// this stores a reference so that it won't get deleted without this material's permission
m_pTexture->setImage(pImage);
// also store a reference pointer
m_Image = pImage;
/** "Note, If the mode is set USE_IMAGE_DATA_FORMAT, USE_ARB_COMPRESSION,
* USE_S3TC_COMPRESSION the internalFormat is automatically selected, and
* will overwrite the previous _internalFormat. */
// m_pTexture->setInternalFormatMode(osg::Texture::USE_S3TC_DXT1_COMPRESSION);
if (s_bTextureCompression)
//m_pTexture->setInternalFormatMode(osg::Texture::USE_ARB_COMPRESSION);
m_pTexture->setInternalFormatMode(osg::Texture::USE_S3TC_DXT3_COMPRESSION);
// From the OSG list: "Why doesn't the OSG deallocate image buffer right
// *after* a glTextImage2D?
// By default the OSG doesn't do it bacause the user may actually want to
// do things with the image after its been bound. You can make the
// osg::Texture classes unref their images automatically by doing:
// texture->setUnRefImageDataAfterApply(true);
// So i tried this, but it doesn't seem to have any affect on runtime memory
// footprint:
// m_pTexture->setUnRefImageDataAfterApply(true);
setTextureAttributeAndModes(0, m_pTexture.get(), SA_ON);
}
/**
* Returns the texture (image) associated with a material.
*/
osg::Image *vtMaterial::GetTexture() const
{
// It is valid to return a non-const pointer to the image, since the image
// can be modified entirely independently of the material.
return m_Image.get();
}
/**
* Call this method to tell vtlib that you have modified the contents of a
* texture so it needs to be sent again to the graphics card.
*/
void vtMaterial::ModifiedTexture()
{
if (!m_pTexture)
return;
// Two steps: first we tell the Texture it's changed, then we tell the
// Image it's changed.
m_pTexture->dirtyTextureObject();
// OSG calls a modified image 'dirty'
m_pTexture->getImage()->dirty();
}
/**
* Set the texture clamping property for this material.
*/
void vtMaterial::SetClamp(bool bClamp)
{
if (!m_pTexture)
return;
if (bClamp)
{
// TODO: try texture->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_EDGE);
m_pTexture->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP);
m_pTexture->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP);
}
else
{
m_pTexture->setWrap(osg::Texture::WRAP_S, osg::Texture::REPEAT);
m_pTexture->setWrap(osg::Texture::WRAP_T, osg::Texture::REPEAT);
}
}
/**
* Get the texture clamping property of this material.
*/
bool vtMaterial::GetClamp() const
{
if (!m_pTexture)
return false;
osg::Texture::WrapMode w = m_pTexture->getWrap(osg::Texture::WRAP_S);
return (w == osg::Texture::CLAMP);
}
/**
* Set the texture mipmapping property for this material.
*/
void vtMaterial::SetMipMap(bool bMipMap)
{
if (!m_pTexture)
return;
if (bMipMap)
m_pTexture->setFilter(osg::Texture::MIN_FILTER, osg::Texture::LINEAR_MIPMAP_LINEAR);
else
m_pTexture->setFilter(osg::Texture::MIN_FILTER, osg::Texture::LINEAR);
}
/**
* Get the texture mipmapping property of this material.
*/
bool vtMaterial::GetMipMap() const
{
if (!m_pTexture)
return false;
osg::Texture::FilterMode m = m_pTexture->getFilter(osg::Texture::MIN_FILTER);
return (m == osg::Texture::LINEAR_MIPMAP_LINEAR);
}
/////////////////////////////////////////////////////////////////////////////
// vtMaterialArray
//
/** Find a material in this array, by pointer */
int vtMaterialArray::Find(vtMaterial *mat)
{
for (size_t i = 0; i < size(); i++)
if (at(i).get() == mat)
return i;
return -1;
}
/**
* Create and add a simple textured material. This method takes a osg::Image
* and let you control many other aspects of the material. Only the first
* three parameters are required, the rest will be assumed with default
* values if desired.
*
* \param pImage A valid image (bitmap) which you have created.
*
* \param bCulling true to cull backfaces (only the front side
* of each polygon is rendered.)
*
* \param bLighting true to "light" the material. This means it will
* use the material's color values, and any active lights to
* determine the color of the drawn geometry. If false, then
* only the material's diffuse color is used, and it is not affected
* by any lights.
*
* \param bTransp true for a material with some transparency (default
* is false).
*
* \param bAdditive true for an additive material (default is false).
* This means that the rendered color will be added to, rather than
* replace, the rendering surface. This is useful for some effects
* such as drawing stars against a twilight sky, in which the light
* of a dim star should be added to the background sky.
*
* \param fAmbient Ambient material value, ranges from 0 to 1 (default 0).
* If lighting is enabled, this determines how this material is affected
* by the Ambient component of each existing light.
*
* \param fDiffuse Diffuse material value, ranges from 0 to 1 (default 1).
* If lighting is enabled, this determines how this material is affected
* by the Diffuse component of each existing light. If lighting is
* not enabled, this indicates the exact lighting value to use for the
* material.
*
* \param fAlpha Alpha value (opacity), ranges from 0 (completely
* transparent) to 1 (opaque). Default is 1. If transparency is
* not enabled, this value is ignored.
*
* \param fEmissive Emmisive material value, ranges from 0 to 1 (default 0).
* If lighting is enabled, this value is added to the combined
* effect of each existing light. This is useful for geometry which
* is brighter than the existing light level, such as illuminated
* objects at night.
*
* \param bTexGen true for materials whose texture mapping will be generated
* automatically. false if you will provide explicit UV values to
* drape your texture. Default is false.
*
* \param bClamp true for Texture Clamping, which prevents sub-texel
* interpolation at the edge of the texture. Default is false.
*
* \param bMipMap true for Mip-mapping, which provided smoother interpolation
* of the textured geometry when it is under-sampled (generally when it
* is in the distance.) Useful for avoiding unpleasant aliasing artifacts,
* but costs 1/3 more texture memory.
*
* \return The index of the added material.
*/
int vtMaterialArray::AddTextureMaterial(osg::Image *pImage,
bool bCulling, bool bLighting,
bool bTransp, bool bAdditive,
float fAmbient, float fDiffuse,
float fAlpha, float fEmissive,
bool bTexGen, bool bClamp,
bool bMipMap)
{
vtMaterial *pMat = new vtMaterial;
pMat->SetTexture(pImage);
pMat->SetCulling(bCulling);
pMat->SetLighting(bLighting);
pMat->SetTransparent(bTransp, bAdditive);
pMat->SetAmbient(fAmbient, fAmbient, fAmbient);
pMat->SetDiffuse(fDiffuse, fDiffuse, fDiffuse, fAlpha);
pMat->SetEmission(fEmissive, fEmissive, fEmissive);
pMat->SetClamp(bClamp);
pMat->SetMipMap(bMipMap);
return AppendMaterial(pMat);
}
/**
* Create and add a simple textured material. This method takes a a filename
* of the texture image to use.
*
* See AddTextureMaterial() for a description of the parameters, which
* lets you control many other aspects of the material.
*
* \return The index of the added material if successful, or -1 on failure.
*/
int vtMaterialArray::AddTextureMaterial2(const char *fname,
bool bCulling, bool bLighting,
bool bTransp, bool bAdditive,
float fAmbient, float fDiffuse,
float fAlpha, float fEmissive,
bool bTexGen, bool bClamp,
bool bMipMap)
{
// check for common mistake
if (*fname == 0)
return -1;
ImagePtr image = osgDB::readImageFile(fname);
if (!image.valid())
return -1;
int index = AddTextureMaterial(image, bCulling, bLighting,
bTransp, bAdditive, fAmbient, fDiffuse, fAlpha, fEmissive, bTexGen,
bClamp, bMipMap);
return index;
}
/**
* Create and add a simple colored material. This method takes diffuse
* and ambient color and let you control several other aspects of the material.
*
* \param diffuse The Diffuse color component of the material.
*
* \param ambient The Ambient color component of the material.
*
* \param bCulling true to cull backfaces (only the front side
* of each polygon is rendered.)
*
* \param bLighting true to "light" the material. This means it will
* use the material's color values, and any active lights to
* determine the color of the drawn geometry. If false, then
* only the material's diffuse color is used, and it is not affected
* by any lights.
*
* \param bWireframe True for a material which will render only the edges
* of polygons.
*
* \param fAlpha Alpha value (opacity), ranges from 0 (completely
* transparent) to 1 (opaque). Default is 1. If transparency is
* not enabled, this value is ignored.
*
* \param fEmissive Emmisive material value, ranges from 0 to 1 (default 0).
* If lighting is enabled, this value is added to the combined
* effect of each existing light. This is useful for geometry which
* is brighter than the existing light level, such as illuminated
* objects at night.
*
* \return The index of the added material.
*/
int vtMaterialArray::AddRGBMaterial(const RGBf &diffuse, const RGBf &ambient,
bool bCulling, bool bLighting, bool bWireframe,
float fAlpha, float fEmissive)
{
vtMaterial *pMat = new vtMaterial;
pMat->SetCulling(bCulling);
pMat->SetLighting(bLighting);
pMat->SetWireframe(bWireframe);
pMat->SetDiffuse(diffuse.r, diffuse.g, diffuse.b, fAlpha);
pMat->SetSpecular(0.0f, 0.0f, 0.0f);
pMat->SetAmbient(ambient.r, ambient.g, ambient.b);
pMat->SetEmission(fEmissive, fEmissive, fEmissive);
return AppendMaterial(pMat);
}
/**
* Create and add a simple colored material. This method takes diffuse
* color and let you control several other aspects of the material.
* Ambient color will be assumed to a be a dimmer shade of the supplied
* diffuse color (diffuse / 4).
*
* \param diffuse The Diffuse color component of the material.
*
* \param bCulling true to cull backfaces (only the front side
* of each polygon is rendered.)
*
* \param bLighting true to "light" the material. This means it will
* use the material's color values, and any active lights to
* determine the color of the drawn geometry. If false, then
* only the material's diffuse color is used, and it is not affected
* by any lights.
*
* \param bWireframe True for a material which will render only the edges
* of polygons.
*
* \param fAlpha Alpha value (opacity), ranges from 0 (completely
* transparent) to 1 (opaque). Default is 1. If transparency is
* not enabled, this value is ignored.
*
* \param fEmissive Emmisive material value, ranges from 0 to 1 (default 0).
* If lighting is enabled, this value is added to the combined
* effect of each existing light. This is useful for geometry which
* is brighter than the existing light level, such as illuminated
* objects at night.
*
* \return The index of the added material.
*/
int vtMaterialArray::AddRGBMaterial1(const RGBf &diffuse,
bool bCulling, bool bLighting, bool bWireframe,
float fAlpha, float fEmissive)
{
return AddRGBMaterial(diffuse, diffuse/4, bCulling, bLighting, bWireframe,
fAlpha, fEmissive);
}
/**
* Copies all the materials from one vtMaterialArray to another.
*
* The materials copied from the source are simply appending to this
* array.
*/
void vtMaterialArray::CopyFrom(vtMaterialArray *pFrom)
{
int num = pFrom->size();
for (int i = 0; i < num; i++)
{
vtMaterial *pMat1 = pFrom->at(i).get();
vtMaterial *pMat2 = new vtMaterial;
pMat2->CopyFrom(pMat1);
AppendMaterial(pMat2);
}
}
void vtMaterialArray::RemoveMaterial(vtMaterial *pMat)
{
for (size_t i = 0; i < size(); i++)
{
if (at(i).get() == pMat)
{
erase(begin() + i);
return;
}
}
}
/**
* Find a material in an array by looking for a specific diffuse color.
*
* \return The index of the material if found, otherwise -1.
*/
int vtMaterialArray::FindByDiffuse(const RGBAf &rgba) const
{
for (uint i = 0; i < size(); i++)
{
if (rgba == at(i)->GetDiffuse())
return i;
}
return -1;
}
/**
* Find a material in an array by looking for a specific texture image.
*
* \return The index of the material if found, otherwise -1.
*/
int vtMaterialArray::FindByImage(const osg::Image *image) const
{
for (uint i = 0; i < size(); i++)
{
const osg::Image *tex = at(i)->GetTexture();
if (tex == image)
return i;
}
return -1;
}
/**
* Adds a material to this material array.
*
* \return The index of the material that was added.
*/
int vtMaterialArray::AppendMaterial(vtMaterial *pMat)
{
// nothing special to do
push_back(pMat);
return (int) size() - 1;
}
| [
"info@kalwaltart.it"
] | info@kalwaltart.it |
3c2d2d13f501c101993993501d73ce26476d50f7 | aaaaf48e8849025f68a3749d316e70d2de729857 | /Sierp-I-Mlot/Menu.cpp | fb054126fd124f5a784e47d3def71459020bab0b | [] | no_license | Niekarp/Sierp-I-Mlot | 1c6ea72fc80a33f9a1b7716d12a2afcdd8070793 | eca409bb3292b306533efa03639bfc275d222eeb | refs/heads/master | 2020-04-02T22:57:03.943859 | 2018-12-17T23:02:55 | 2018-12-17T23:02:55 | 154,729,126 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,014 | cpp | #include "pch.h"
#include "Menu.h"
#include "CenteredFramedPlane.h"
#include "FileImagePlane.h"
#include "ButtonPlane.h"
#include "FramePlaneFrameCreator.h"
Menu::Menu()
{
}
void Menu::add_option(const Option& option)
{
_options.push_back(option);
}
void Menu::draw_on(const std::shared_ptr<Console>& output)
{
auto menu_plane = std::make_shared<CenteredFramedPlane>();
menu_plane->size({ 60, 40 });
menu_plane->frame_color(FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE | BACKGROUND_BLUE | BACKGROUND_INTENSITY);
menu_plane->fill_color(BACKGROUND_BLUE | BACKGROUND_INTENSITY);
output->add_plane(menu_plane);
auto logo_plane = std::make_shared<FileImagePlane>("resources/logo_pattern.txt");
logo_plane->color(FOREGROUND_RED | FOREGROUND_INTENSITY | BACKGROUND_BLUE | BACKGROUND_INTENSITY);
output->add_plane(logo_plane);
int i = 0;
for (auto &option : _options)
{
auto button_plane = std::make_shared<ButtonPlane>(i++);
FramePlaneFrameCreator(button_plane).make_double_line_frame();
button_plane->size({ 50, 6 });
button_plane->frame_color(FOREGROUND_GREEN | FOREGROUND_RED | BACKGROUND_BLUE | BACKGROUND_INTENSITY);
button_plane->fill_color(BACKGROUND_BLUE | BACKGROUND_INTENSITY);
button_plane->on_click(option.callback);
output->add_clickable_plane(button_plane);
auto text = std::make_shared<TextConsolePlane>();
text->font_size({ xo::conf::FONT_SMALL_SIZE_X, xo::conf::FONT_SMALL_SIZE_Y });
text->text(option.name);
text->load_font(xo::conf::FONT_SMALL_DIRECTORY);
text->foreground(' ', BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_INTENSITY);
text->background(' ', BACKGROUND_BLUE | BACKGROUND_INTENSITY);
text->position({ 0, 0 });
button_plane->text(text);
}
auto wnd_resize_callback = [logo_plane](auto new_width, auto new_height)
{
logo_plane->position({
new_width / 2 - logo_plane->size().x / 2,
new_height / 2 - 14 });
};
wnd_resize_callback(output->width(), output->height());
output->window_resize_event(wnd_resize_callback);
}
| [
"pawel@antoniuk.pl"
] | pawel@antoniuk.pl |
cfffc74a26cfc1046ec8d430092a33744622550f | c0c1c293aae7b22bb26f8e0cf5c8f01be006862d | /trees/todll.cpp | fdf9679317f487f5655147f3fd651af206bc45da | [] | no_license | rajeevt09/AlgorithmsCode | a3412b8be25ca87b7d78f721c4c62e815f0d671b | 1ccc1f06d455b330dd43b4219697f43aa63962aa | refs/heads/master | 2020-06-19T21:33:35.602938 | 2019-07-14T21:34:24 | 2019-07-14T21:34:24 | 196,882,489 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,755 | cpp | #include <iostream>
using namespace std;
struct Node
{
Node *left;
Node *right;
int val;
Node(int v):val(v),left(nullptr),right(nullptr){}
};
/*
* Complete the function below.
*/
void todll(Node *p,Node **head,Node **tail);
void printdll(Node *head)
{
Node *p = head;
do
{
cout << p->val;
p = p->right;
}while(p);
}
void BSTtoLL(Node* root) {
Node *head;
Node *tail;
todll(root,&head,&tail);
// cout << "Head/Tails : " << head << "/" << tail << endl;
if(head&&tail)
{
tail->right = head;
head->left = tail;
printdll(head);
}
}
void pushtodll(Node *h,Node *p)
{
if(h&&p)
{
h->right = p;
p->left = h;
}
}
void todll(Node *p,Node **head,Node **tail)
{
Node *left_head;
Node *left_tail;
Node *right_head;
Node *right_tail;
*head = *tail = nullptr;
if(p==nullptr) return;
todll(p->left,&left_head,&left_tail);
todll(p->right,&right_head,&right_tail);
//Link Self to Left and Right DLL's
pushtodll(left_tail,p);
pushtodll(p,right_head);
if(left_head == nullptr)
{
left_head = p;
}
if(right_tail == nullptr)
{
right_tail = p;
}
//return new DLL's head and Tail
*head = left_head;
*tail = right_tail;
cout << "p Head/Tails : " << p->val << " " << (*head)->val << " " << (*tail)->val << ";" << endl;
return;
}
int main()
{
cout << "Tree To DLL" << endl;
Node* root = new Node(1);
root->left = new Node(2);
root->right = new Node(3);
Node *tl = root->left;
tl->left = new Node(4);
tl->right = new Node(5);
tl = root->right;
tl->left = new Node(6);
tl->right = new Node(7);
BSTtoLL(root);
}
| [
"rajeevt09@gmail.com"
] | rajeevt09@gmail.com |
5cd2aff9b2e61c4a559c99d5c5e875adf3bde586 | eea3110ec52ca7842de9787a3e615dc537d5996d | /25_pages_latex/edit/editDistance.cpp | bd66b9288afd5b8b678767402a5e6139e5afd865 | [] | no_license | matthewschallenkamp/Red-Team-Code | 7402a7d90ffed99e9ae69f370d1cbc0a5c298c09 | 21dd37cb6b8897246be09f816788954718162469 | refs/heads/master | 2020-03-27T20:18:40.417765 | 2018-09-26T15:25:48 | 2018-09-26T15:25:48 | 147,057,828 | 5 | 3 | null | 2018-09-02T05:40:29 | 2018-09-02T05:40:29 | null | UTF-8 | C++ | false | false | 971 | cpp | const int MAX_LEN = 5000; //max length of input strings
int d[MAX_LEN][MAX_LEN]; //dynamic programming table
void init_table(int len1, int len2) { //initializes array, call before edit_dist
for (int i = 0; i <= len1; i++)
for (int j = 0; j <= len2; j++)
d[i][j] = 1;
for (int i = 0; i <= len1; i++)
d[i][0] = i;
for (int j = 0; j <= len2; j++)
d[0][j] = j;
}
//finds edit dist of s1 and s2; first call: end_s1=s1.length(),end_s2=s2.length()
int editdist(string s1, string s2, int end_s1, int end_s2) {
int try_delete, try_insert, try_match;
if (d[end_s1][end_s2] >= 0)
return d[end_s1][end_s2];
try_match = editdist(s1, s2, end_s1 - 1, end_s2 - 1);
if (s1[end_s1 - 1] != s2[end_s2 - 1])
try_match++;
try_delete = editdist(s1, s2, end_s1 - 1, end_s2) + 1;
try_insert = editdist(s1, s2, end_s1, end_s2 - 1) + 1;
d[end_s1][end_s2] = min(try_insert, min(try_delete, try_match));
return d[end_s1][end_s2];
} //testcase:kitten,sitting=>3
| [
"matthew.schallenkamp@gmail.com"
] | matthew.schallenkamp@gmail.com |
c8c5efa99ed8f289dbc1162ffb8a352d54bbb4a8 | 6a257702669720db3421e4f599b07d391e69b28d | /cBird.h | a83519b66a6b7e448eac50f93a4f720108a4a66d | [] | no_license | CuzzImBatman/CS202-Crossing_Road | abb8b088805249252ff9d60aa47c9d4d5d0f19d5 | 8ad4c18c48da6857221598e259bc4a28e8ca6c6a | refs/heads/main | 2023-02-10T20:25:54.626564 | 2021-01-08T17:29:59 | 2021-01-08T17:29:59 | 325,157,897 | 0 | 0 | null | 2021-01-06T05:37:57 | 2020-12-29T01:40:17 | C++ | UTF-8 | C++ | false | false | 500 | h | #pragma once
#include "cAnimal.h"
class cBird : public cAnimal
{
public:
cBird() : cAnimal()
{
}
cBird(int x, int y) :cAnimal(x, y)
{
}
void draw()
{
TextColor(ColorCode_DarkRed);
gotoXY(m_x, m_y);
printf("%c", 219);
gotoXY(m_x - 1, m_y - 1);
printf("%c", 219);
gotoXY(m_x + 1, m_y - 1);
printf("%c", 219);
TextColor(7);
}
void deleteChar()
{
gotoXY(m_x, m_y);
cout << ' ';
gotoXY(m_x - 1, m_y - 1);
cout << ' ';
gotoXY(m_x + 1, m_y - 1);
cout << ' ';
}
};
| [
"lgbao19@apcs.vn"
] | lgbao19@apcs.vn |
39a19460085a6766d9814c43ab4c8fba128d9ea7 | 0ecf2d067e8fe6cdec12b79bfd68fe79ec222ffd | /chrome/browser/chromeos/file_manager/file_tasks.h | eb18ed89def2ce8b274ecbd6a411bc25e5be88a8 | [
"BSD-3-Clause"
] | permissive | yachtcaptain23/browser-android-tabs | e5144cee9141890590d6d6faeb1bdc5d58a6cbf1 | a016aade8f8333c822d00d62738a922671a52b85 | refs/heads/master | 2021-04-28T17:07:06.955483 | 2018-09-26T06:22:11 | 2018-09-26T06:22:11 | 122,005,560 | 0 | 0 | NOASSERTION | 2019-05-17T19:37:59 | 2018-02-19T01:00:10 | null | UTF-8 | C++ | false | false | 13,498 | h | // Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// This file provides utility functions for "file tasks".
//
// WHAT ARE FILE TASKS?
//
// File tasks are representation of actions that can be performed over the
// currently selected files from the Files app. A task can be either of:
//
// 1) Chrome extension or app, registered via "file_handlers" or
// "file_browser_handlers" in manifest.json (ex. Text.app). This information
// comes from FileBrowserHandler::GetHandlers()
//
// See also:
// https://developer.chrome.com/extensions/manifest.html#file_handlers
// https://developer.chrome.com/extensions/fileBrowserHandler.html
//
// 2) Built-in handlers provided from the Files app. The Files app provides
// lots of file_browser_handlers, such as "play", "mount-archive". These
// built-in handlers are often handled in special manners inside the Files
// app. This information also comes from FileBrowserHandler::GetHandlers().
//
// See also:
// ui/file_manager/file_manager/manifest.json
//
// 3) Drive app, which is a hosted app (i.e. just web site), that can work
// with Drive (ex. Pixlr Editor). This information comes from
// drive::DriveAppRegistry.
//
// See also:
// https://chrome.google.com/webstore/category/collection/drive_apps
//
// For example, if the user is now selecting a JPEG file, the Files app will
// receive file tasks represented as a JSON object via
// chrome.fileManagerPrivate.getFileTasks() API, which look like:
//
// [
// {
// "driveApp": true,
// "iconUrl": "<app_icon_url>",
// "isDefault": false,
// "taskId": "<drive_app_id>|drive|open-with",
// "title": "Drive App Name (ex. Pixlr Editor)"
// },
// {
// "driveApp": false,
// "iconUrl":
// "chrome://extension-icon/hhaomjibdihmijegdhdafkllkbggdgoj/16/1",
// "isDefault": true,
// "taskId": "hhaomjibdihmijegdhdafkllkbggdgoj|file|gallery",
// "title": "__MSG_OPEN_ACTION__"
// }
// ]
//
// The first file task is a Drive app. The second file task is a built-in
// handler from the Files app.
//
// WHAT ARE TASK IDS?
//
// You may have noticed that "taskId" fields in the above example look
// awkward. Apparently "taskId" encodes three types of information delimited
// by "|". This is a weird format for something called as an ID.
//
// 1) Why are the three types information encoded in this way?
//
// It's just a historical reason. The reason is that a simple string can be
// easily stored in user's preferences. We should stop doing this, by storing
// this information in chrome.storage instead. crbug.com/267359.
//
// 2) OK, then what are the three types of information encoded here?
//
// The task ID encodes the following structure:
//
// <app-id>|<task-type>|<task-action-id>
//
// <app-id> is either of Chrome Extension/App ID or Drive App ID. For some
// reason, Chrome Extension/App IDs and Drive App IDs look differently. As of
// writing, the former looks like "hhaomjibdihmijegdhdafkllkbggdgoj"
// (the Files app) and the latter looks like "419782477519" (Pixlr Editor).
//
// <task-type> is either of
// - "file" - File browser handler - app/extension declaring
// "file_browser_handlers" in manifest.
// - "app" - File handler - app declaring "file_handlers" in manifest.json.
// - "drive" - Drive App
// - "arc" - ARC App
// - "crostini" - Crostini App
//
// <task-action-id> is an ID string used for identifying actions provided
// from a single Chrome Extension/App. In other words, a single
// Chrome/Extension can provide multiple file handlers hence each of them
// needs to have a unique action ID. For Drive and Crostini apps,
// <task-action-id> is always "open-with".
//
// HOW TASKS ARE EXECUTED?
//
// chrome.fileManagerPrivate.viewFiles() is used to open a file in a browser,
// without any handler. Browser will take care of handling the file (ex. PDF).
//
// chrome.fileManagerPrivate.executeTasks() is used to open a file with a
// handler (Chrome Extension/App or Drive App).
//
// Some built-in handlers such as "play" are handled internally in the Files
// app. "mount-archive" is handled very differently. The task execution
// business should be simplified: crbug.com/267313
//
// See also:
// ui/file_manager/file_manager/foreground/js/file_tasks.js
//
#ifndef CHROME_BROWSER_CHROMEOS_FILE_MANAGER_FILE_TASKS_H_
#define CHROME_BROWSER_CHROMEOS_FILE_MANAGER_FILE_TASKS_H_
#include <memory>
#include <set>
#include <string>
#include <vector>
#include "base/callback_forward.h"
#include "chrome/common/extensions/api/file_manager_private.h"
#include "extensions/browser/api/file_handlers/app_file_handler_util.h"
#include "url/gurl.h"
class PrefService;
class Profile;
namespace drive {
class DriveAppRegistry;
}
namespace extensions {
struct EntryInfo;
}
namespace storage {
class FileSystemURL;
}
namespace file_manager {
namespace file_tasks {
// Task types as explained in the comment above. Search for <task-type>.
enum TaskType {
TASK_TYPE_UNKNOWN = 0, // Used only for handling errors.
TASK_TYPE_FILE_BROWSER_HANDLER,
TASK_TYPE_FILE_HANDLER,
TASK_TYPE_DRIVE_APP,
TASK_TYPE_ARC_APP,
TASK_TYPE_CROSTINI_APP,
// The enum values must be kept in sync with FileManagerTaskType in
// tools/metrics/histograms/enums.xml. Since enums for histograms are
// append-only (for keeping the number consistent across versions), new values
// for this enum also has to be always appended at the end (i.e., here).
NUM_TASK_TYPE,
};
// Describes a task.
// See the comment above for <app-id>, <task-type>, and <action-id>.
struct TaskDescriptor {
TaskDescriptor(const std::string& in_app_id,
TaskType in_task_type,
const std::string& in_action_id)
: app_id(in_app_id),
task_type(in_task_type),
action_id(in_action_id) {
}
TaskDescriptor() = default;
std::string app_id;
TaskType task_type;
std::string action_id;
};
// Describes a task with extra information such as icon URL.
class FullTaskDescriptor {
public:
FullTaskDescriptor(
const TaskDescriptor& task_descriptor,
const std::string& task_title,
const extensions::api::file_manager_private::Verb task_verb,
const GURL& icon_url,
bool is_default,
bool is_generic_file_handler);
~FullTaskDescriptor();
FullTaskDescriptor(const FullTaskDescriptor& other);
const TaskDescriptor& task_descriptor() const { return task_descriptor_; }
// The title of the task.
const std::string& task_title() const { return task_title_; }
// The verb of the task.
extensions::api::file_manager_private::Verb task_verb() const {
return task_verb_;
}
// The icon URL for the task (ex. app icon)
const GURL& icon_url() const { return icon_url_; }
// True if this task is set as default.
bool is_default() const { return is_default_; }
void set_is_default(bool is_default) { is_default_ = is_default; }
// True if this task is from generic file handler. Generic file handler is a
// file handler which handles any type of files (e.g. extensions: ["*"],
// types: ["*/*"]). Partial wild card (e.g. types: ["image/*"]) is not
// generic file handler.
bool is_generic_file_handler() const { return is_generic_file_handler_; }
void set_is_generic_file_handler(bool is_generic_file_handler) {
is_generic_file_handler_ = is_generic_file_handler;
}
private:
TaskDescriptor task_descriptor_;
std::string task_title_;
extensions::api::file_manager_private::Verb task_verb_;
GURL icon_url_;
bool is_default_;
bool is_generic_file_handler_;
};
// Update the default file handler for the given sets of suffixes and MIME
// types.
void UpdateDefaultTask(PrefService* pref_service,
const std::string& task_id,
const std::set<std::string>& suffixes,
const std::set<std::string>& mime_types);
// Returns the task ID of the default task for the given |mime_type|/|suffix|
// combination. If it finds a MIME type match, then it prefers that over a
// suffix match. If it a default can't be found, then it returns the empty
// string.
std::string GetDefaultTaskIdFromPrefs(const PrefService& pref_service,
const std::string& mime_type,
const std::string& suffix);
// Generates task id for the task specified by |app_id|, |task_type| and
// |action_id|.
//
// |app_id| is either of Chrome Extension/App ID or Drive App ID.
// |action_id| is a free-form string ID for the action.
std::string MakeTaskID(const std::string& app_id,
TaskType task_type,
const std::string& action_id);
// Converts |task_descriptor| to a task ID.
std::string TaskDescriptorToId(const TaskDescriptor& task_descriptor);
// Parses the task ID and extracts app ID, task type, and action ID into
// |task|. On failure, returns false, and the contents of |task| are
// undefined.
//
// See also the comment at the beginning of the file for details for how
// "task_id" looks like.
bool ParseTaskID(const std::string& task_id, TaskDescriptor* task);
// The callback is used for ExecuteFileTask(). Will be called with true if
// the file task execution is successful, or false if unsuccessful.
typedef base::Callback<void(extensions::api::file_manager_private::TaskResult
result)> FileTaskFinishedCallback;
// Executes file handler task for each element of |file_urls|.
// Returns |false| if the execution cannot be initiated. Otherwise returns
// |true| and then eventually calls |done| when all the files have been handled.
// |done| can be a null callback.
//
// Parameters:
// profile - The profile used for making this function call.
// source_url - The source URL which originates this function call.
// task - See the comment at TaskDescriptor struct.
// file_urls - URLs of the target files.
// done - The callback which will be called on completion.
// The callback won't be called if the function returns
// false.
bool ExecuteFileTask(Profile* profile,
const GURL& source_url,
const TaskDescriptor& task,
const std::vector<storage::FileSystemURL>& file_urls,
const FileTaskFinishedCallback& done);
// Finds the Drive app tasks that can be used with the given |entries|
// from |drive_app_registry|, and append them to the |result_list|.
// Drive app tasks will be found only if all of the files are on Drive.
void FindDriveAppTasks(const drive::DriveAppRegistry& drive_app_registry,
const std::vector<extensions::EntryInfo>& entries,
std::vector<FullTaskDescriptor>* result_list);
// Returns true if a file handler matches with entries as good match.
bool IsGoodMatchFileHandler(
const extensions::FileHandlerInfo& file_handler_info,
const std::vector<extensions::EntryInfo>& entries);
// Finds the file handler tasks (apps declaring "file_handlers" in
// manifest.json) that can be used with the given entries, appending them to
// the |result_list|.
void FindFileHandlerTasks(Profile* profile,
const std::vector<extensions::EntryInfo>& entries,
std::vector<FullTaskDescriptor>* result_list);
// Finds the file browser handler tasks (app/extensions declaring
// "file_browser_handlers" in manifest.json) that can be used with the
// given files, appending them to the |result_list|.
void FindFileBrowserHandlerTasks(
Profile* profile,
const std::vector<GURL>& file_urls,
std::vector<FullTaskDescriptor>* result_list);
// Callback function type for FindAllTypesOfTasks.
typedef base::Callback<void(
std::unique_ptr<std::vector<FullTaskDescriptor>> result)>
FindTasksCallback;
// Finds all types (drive, file handlers, file browser handlers) of
// tasks. See the comment at FindDriveAppTasks() about |result_list|.
// Drive app tasks will be found only if all of the files are on Drive.
// |drive_app_registry| can be NULL if the drive app registry is not
// present.
//
// If |entries| contains a Google document, only the internal tasks of the
// Files app (i.e., tasks having the app ID of the Files app) are listed.
// This is to avoid dups between Drive app tasks and an internal handler that
// the Files app provides, and to avoid listing normal file handler and file
// browser handler tasks, which can handle only normal files.
void FindAllTypesOfTasks(Profile* profile,
const drive::DriveAppRegistry* drive_app_registry,
const std::vector<extensions::EntryInfo>& entries,
const std::vector<GURL>& file_urls,
const FindTasksCallback& callback);
// Chooses the default task in |tasks| and sets it as default, if the default
// task is found (i.e. the default task may not exist in |tasks|). No tasks
// should be set as default before calling this function.
void ChooseAndSetDefaultTask(const PrefService& pref_service,
const std::vector<extensions::EntryInfo>& entries,
std::vector<FullTaskDescriptor>* tasks);
} // namespace file_tasks
} // namespace file_manager
#endif // CHROME_BROWSER_CHROMEOS_FILE_MANAGER_FILE_TASKS_H_
| [
"artem@brave.com"
] | artem@brave.com |
5f86182a21319c8f3c76cf8b14bcadc4412c09ae | 5e9fb30ecf46b2e502e99785426a56b660ed591b | /P68087_en.cpp | cd9ff92693b38ce7a0def83b7bc898161bd9d694 | [] | no_license | srgrr/JutgeContests | fc8b7373255844f0eee904fe06efb552316bb40b | 63926407b792b8ea0071a2a3df22512ed961803f | refs/heads/master | 2021-01-16T23:14:38.609141 | 2018-06-21T09:12:46 | 2018-06-21T09:12:46 | 59,954,245 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,622 | cpp | /*
Author: sergiorg
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
/*
Programacio dinamica amb mascara de bits optimitzada
fins vomitar, poc a dir. El paper que fa es evitar comptar
un subconjunt maximal mes dun cop:
000 -> 001 -> 011
000 -> 010 -> 011
Aixo faria que comptessim el subset 011 dos cops.
Gracies a aquest problema he descobert que amb grafs petits pots
representar les adjacencies com una mascara de bits, i comprovar
si dos vertexs tenen en comu algun vei en O(1) fent un AND.
La solucio esperada se suposa que es un backtracking no massa original
ni massa orientat a rascar temps segons l'organitzador del concurs.
*/
int n, ans = 0, g[21], dp[1 << 21];
inline void calc(int mask) {
if(dp[mask]) return;
dp[mask] = 1;
bool maximal = true;
for(int toadd = 0; toadd < n; ++toadd) {
if(!(mask & (1<<toadd))) {
bool valid = true;
if(g[toadd] & mask) valid = false;
if(valid) maximal = false, calc(mask | (1<<toadd));
}
}
if(maximal) {
//cout << mask << endl;
++ans;
}
}
int main() {
ios_base::sync_with_stdio(0); cin.tie(0);
while(scanf("%d", &n) == 1) {
memset(dp, 0x00, sizeof(int) * (1 << n));
memset(g, 0x00, sizeof(g));
char s[1231];
for(int i = 0; i < n; ++i) {
scanf("%s", s);
for(int j = 0; j < n; ++j) {
g[i] |= (s[j] == 'D') * (1 << j);
g[j] |= (s[j] == 'D') * (1 << i);
}
}
ans = 0;
calc(0);
printf("%d\n", ans);
}
}
| [
"sergi9rr9r@gmail.com"
] | sergi9rr9r@gmail.com |
6fa77c499f9a994fea8e35c98195ef9ce7975618 | d8810c1499ef9353be6ef28cf179f6c7e1c5aff9 | /libs/reactivenav/include/mrpt/reactivenav/CPTG7.h | e136ec8c7b096781dbacf5ea4623ba08f53cf89d | [
"BSD-3-Clause"
] | permissive | DYFeng/mrpt | d7b995422cfe96f2ee44deab8c19b3780b895a1b | 82d9bb6dbb62746385aca7f6effbb48fe2be908f | refs/heads/master | 2021-01-21T15:52:38.064528 | 2013-10-20T09:39:27 | 2013-10-20T09:39:27 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,700 | h | /* +---------------------------------------------------------------------------+
| The Mobile Robot Programming Toolkit (MRPT) |
| |
| http://www.mrpt.org/ |
| |
| Copyright (c) 2005-2013, Individual contributors, see AUTHORS file |
| Copyright (c) 2005-2013, MAPIR group, University of Malaga |
| Copyright (c) 2012-2013, University of Almeria |
| All rights reserved. |
| |
| Redistribution and use in source and binary forms, with or without |
| modification, are permitted provided that the following conditions are |
| met: |
| * Redistributions of source code must retain the above copyright |
| notice, this list of conditions and the following disclaimer. |
| * Redistributions in binary form must reproduce the above copyright |
| notice, this list of conditions and the following disclaimer in the |
| documentation and/or other materials provided with the distribution. |
| * Neither the name of the copyright holders nor the |
| names of its contributors may be used to endorse or promote products |
| derived from this software without specific prior written permission.|
| |
| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
| TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR|
| PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE |
| FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL|
| DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR|
| SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
| STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
| ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| POSSIBILITY OF SUCH DAMAGE. |
+---------------------------------------------------------------------------+ */
#ifndef CPTG7_H
#define CPTG7_H
#include <mrpt/reactivenav/CParameterizedTrajectoryGenerator.h>
namespace mrpt
{
namespace reactivenav
{
/** A PTG for circular paths.
* \ingroup mrpt_reactivenav_grp
*/
class REACTIVENAV_IMPEXP CPTG7 : public CParameterizedTrajectoryGenerator
{
public:
/** Constructor: possible values in "params", those of CParameterizedTrajectoryGenerator plus:
* - cte_a0v, cte_a0w: Parameters of this PTG
*/
CPTG7(const TParameters<double> ¶ms );
/** The lambda function.
*/
void lambdaFunction( float x, float y, int &out_k, float &out_d );
/** Gets a short textual description of the PTG and its parameters.
*/
std::string getDescription() const;
bool PTG_IsIntoDomain( float x, float y );
void PTG_Generator( float alpha, float t,float x, float y, float phi, float &v, float &w );
protected:
float cte_a0v;
float cte_a0w;
};
}
}
#endif
| [
"joseluisblancoc@gmail.com"
] | joseluisblancoc@gmail.com |
38b99be393ce7792e538c1638ebbe67b9f33fa8a | 8facc09c0b8605a196c6c84929f61a9d61d9459e | /.vshistory/game.cpp/2021-01-22_15_53_19_774.cpp | 196ea264dc89f1067973c8da592cbb894dbebd5c | [] | no_license | Allinonepker/Tank-Simulation-Optimization | 49eefdc8ecb59b28f6c6e1eda38f23c041c1692e | d2387325763c04485ebbc7765a8e437af1666078 | refs/heads/master | 2023-02-18T23:44:57.272037 | 2021-01-24T00:47:33 | 2021-01-24T00:47:33 | 330,493,912 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 18,111 | cpp | #include "precomp.h" // include (only) this in every .cpp file
#define NUM_TANKS_BLUE 1000
#define NUM_TANKS_RED 1000
#define TANK_MAX_HEALTH 1000
#define ROCKET_HIT_VALUE 60
#define PARTICLE_BEAM_HIT_VALUE 50
#define TANK_MAX_SPEED 1.5
#define HEALTH_BARS_OFFSET_X 0
#define HEALTH_BAR_HEIGHT 70
#define HEALTH_BAR_WIDTH 1
#define HEALTH_BAR_SPACING 0
#define MAX_FRAMES 2000
//Global performance timer
#define REF_PERFORMANCE 73466 //UPDATE THIS WITH YOUR REFERENCE PERFORMANCE (see console after 2k frames)
static timer perf_timer;
static float duration;
//Load sprite files and initialize sprites
static Surface* background_img = new Surface("assets/Background_Grass.png");
static Surface* tank_red_img = new Surface("assets/Tank_Proj2.png");
static Surface* tank_blue_img = new Surface("assets/Tank_Blue_Proj2.png");
static Surface* rocket_red_img = new Surface("assets/Rocket_Proj2.png");
static Surface* rocket_blue_img = new Surface("assets/Rocket_Blue_Proj2.png");
static Surface* particle_beam_img = new Surface("assets/Particle_Beam.png");
static Surface* smoke_img = new Surface("assets/Smoke.png");
static Surface* explosion_img = new Surface("assets/Explosion.png");
static Sprite background(background_img, 1);
static Sprite tank_red(tank_red_img, 12);
static Sprite tank_blue(tank_blue_img, 12);
static Sprite rocket_red(rocket_red_img, 12);
static Sprite rocket_blue(rocket_blue_img, 12);
static Sprite smoke(smoke_img, 4);
static Sprite explosion(explosion_img, 9);
static Sprite particle_beam_sprite(particle_beam_img, 3);
const static vec2 tank_size(14, 18);
const static vec2 rocket_size(25, 24);
const static float tank_radius = 8.5f;
const static float rocket_radius = 10.f;
struct Timer
{
std::chrono::time_point<std::chrono::steady_clock> start, end;
std::chrono::duration<float> duration;
Timer() {
start = std::chrono::high_resolution_clock::now();
}
~Timer() {
end = std::chrono::high_resolution_clock::now();
duration = end - start;
float ms = duration.count() * 1.000f;
std::cout << "This operation took " << ms << "ms" << std::endl;
}
};
// -----------------------------------------------------------
// Initialize the application
// -----------------------------------------------------------
void Game::init()
{
frame_count_font = new Font("assets/digital_small.png", "ABCDEFGHIJKLMNOPQRSTUVWXYZ:?!=-0123456789.");
tanks.reserve(NUM_TANKS_BLUE + NUM_TANKS_RED);
uint rows = (uint)sqrt(NUM_TANKS_BLUE + NUM_TANKS_RED);
uint max_rows = 12;
float start_blue_x = tank_size.x + 10.0f;
float start_blue_y = tank_size.y + 80.0f;
float start_red_x = 980.0f;
float start_red_y = 100.0f;
float spacing = 15.0f;
//Spawn blue tanks
int id = 0;
for (int i = 0; i < NUM_TANKS_BLUE; i++) {
tanks.push_back(Tank(start_blue_x + ((i % max_rows) * spacing), start_blue_y + ((i / max_rows) * spacing), BLUE, &tank_blue, &smoke, 1200, 600, tank_radius, TANK_MAX_HEALTH, TANK_MAX_SPEED, id));
++id;
}
//Spawn red tanks
for (int i = 0; i < NUM_TANKS_RED; i++)
{
tanks.push_back(Tank(start_red_x + ((i % max_rows) * spacing), start_red_y + ((i / max_rows) * spacing), RED, &tank_red, &smoke, 80, 80, tank_radius, TANK_MAX_HEALTH, TANK_MAX_SPEED, id));
++id;
}
for (Tank& tank : tanks) {
int xGrid = ((int)tank.position.x / (SCRWIDTH / COLSIZE));
int yGrid = ((int)tank.position.y / (SCRHEIGHT / ROWSIZE));
tank.setXY(xGrid, yGrid);
tank_grid[xGrid][yGrid].insertTank(&tank);
}
particle_beams.push_back(Particle_beam(vec2(SCRWIDTH / 2, SCRHEIGHT / 2), vec2(100, 50), &particle_beam_sprite, PARTICLE_BEAM_HIT_VALUE));
particle_beams.push_back(Particle_beam(vec2(80, 80), vec2(100, 50), &particle_beam_sprite, PARTICLE_BEAM_HIT_VALUE));
particle_beams.push_back(Particle_beam(vec2(1200, 600), vec2(100, 50), &particle_beam_sprite, PARTICLE_BEAM_HIT_VALUE));
}
// -----------------------------------------------------------
// Close down application
// -----------------------------------------------------------
void Game::shutdown()
{
}
//// -----------------------------------------------------------
//// Iterates through all tanks and returns the closest enemy tank for the given tank
//// -----------------------------------------------------------
Tank*& Game::find_closest_enemy(Tank& current_tank)
{
int closest_grid_x(0);
int closest_grid_y(0);
float closest_distance = numeric_limits<float>::infinity();
int xPosCurrentTank = current_tank.xGrid;
int yPosCurrentTank = current_tank.yGrid;
for (pair<int, int> pair : (current_tank.allignment == RED) ? blueGrids : redGrids) {
float distance = sqrt((pow(abs(xPosCurrentTank - pair.first), 2) + (pow(abs(yPosCurrentTank - pair.second), 2))));
if (distance < closest_distance) {
closest_distance = distance;
closest_grid_x = pair.first;
closest_grid_y = pair.second;
}
}
closest_distance = numeric_limits<float>::infinity();
int closest_index = 0;
int index = 0;
for (Tank*& tank : tank_grid[closest_grid_x][closest_grid_y].tanks)
{
if (tank->active && tank->allignment != current_tank.allignment)
{
float sqr_dist = fabsf((tank->get_position() - current_tank.get_position()).sqr_length());
if (sqr_dist < closest_distance)
{
closest_distance = sqr_dist;
closest_index = index;
}
}
index++;
}
return tank_grid[closest_grid_x][closest_grid_y].tanks[closest_index];
}
// -----------------------------------------------------------
// Update the game state:
// Move all objects
// Update sprite frames
// Collision detection
// Targeting etc..
// -----------------------------------------------------------
void Game::update(float deltaTime)
{
updateGrids();
checkColors();
{
////Update tanks
for (Tank& tank : tanks)
{
if (tank.active)
{
//Check tank collision and nudge tanks away from each other
size_t x_grid = tank.xGrid;
size_t y_grid = tank.yGrid;
int x_bound_left, x_bound_right, y_bound_bottom, y_bound_top;
(x_grid == 0) ? x_bound_left = 0, x_bound_right = x_grid + 1 : (x_grid == SCRWIDTH / COLSIZE - 1) ? x_bound_right = x_grid, x_bound_left = x_grid - 1 : x_bound_left = x_grid - 1,
x_bound_right = x_grid + 1;
(y_grid == 0) ? y_bound_bottom = 0, y_bound_top = y_grid + 1 : (y_grid == SCRHEIGHT / ROWSIZE - 1) ? y_bound_top = y_grid, y_bound_bottom = y_grid - 1 : y_bound_bottom = y_grid - 1,
y_bound_top = y_grid + 1;
for (size_t i = x_bound_left; i <= x_bound_right; i++) {
for (size_t j = y_bound_bottom; j <= y_bound_top; j++) {
for (Tank*& tanko : tank_grid[i][j].tanks) {
if (tank.ID == tanko->ID) continue;
vec2 dir = tank.get_position() - tanko->get_position();
float dir_squared_len = dir.sqr_length();
float col_squared_len = (tank.get_collision_radius() + tanko->get_collision_radius());
col_squared_len *= col_squared_len;
if (dir_squared_len < col_squared_len)
{
tank.push(dir.normalized(), 1.f);
}
}
}
}
//Move tanks according to speed and nudges (see above) also reload
tank.tick();
//Shoot at closest target if reloaded
if (tank.rocket_reloaded())
{
//Tank& target = find_closest_enemy(tank);
Tank*& target = find_closest_enemy(tank);
//rockets.push_back(Rocket(tank.position, (target.get_position() - tank.position).normalized() * 3, rocket_radius, tank.allignment, ((tank.allignment == RED) ? &rocket_red : &rocket_blue)));
rockets.push_back(Rocket(tank.position, (target->get_position() - tank.position).normalized() * 3, rocket_radius, tank.allignment, ((tank.allignment == RED) ? &rocket_red : &rocket_blue)));
tank.reload_rocket();
}
}
}
}
//Update smoke plumes
for (Smoke& smoke : smokes)
{
smoke.tick();
}
for (Rocket& rocket : rockets)
{
rocket.tick();
bool mustbreak = false;
int x_grid_rocket = ((abs((int)rocket.position.x)) / (SCRWIDTH / COLSIZE) >= (SCRWIDTH / COLSIZE) - 1) ? (SCRWIDTH / COLSIZE) - 1 : (abs((int)rocket.position.x)) / (SCRWIDTH / COLSIZE);
int y_grid_rocket = ((abs((int)rocket.position.y)) / (SCRHEIGHT / ROWSIZE) >= (SCRHEIGHT / ROWSIZE) - 1) ? (SCRHEIGHT / ROWSIZE) - 1 : (abs((int)rocket.position.y)) / (SCRHEIGHT / ROWSIZE);
int x_bound_left_rocket, x_bound_right_rocket, y_bound_bottom_rocket, y_bound_top_rocket;
(x_grid_rocket == 0) ? x_bound_left_rocket = 0, x_bound_right_rocket = x_grid_rocket + 1 : (x_grid_rocket == SCRWIDTH / COLSIZE - 1) ? x_bound_right_rocket = x_grid_rocket, x_bound_left_rocket = x_grid_rocket - 1 : x_bound_left_rocket = x_grid_rocket - 1,
x_bound_right_rocket = x_grid_rocket + 1;
(y_grid_rocket == 0) ? y_bound_bottom_rocket = 0, y_bound_top_rocket = y_grid_rocket + 1 : (y_grid_rocket == SCRHEIGHT / ROWSIZE - 1) ? y_bound_top_rocket = y_grid_rocket, y_bound_bottom_rocket = y_grid_rocket - 1 : y_bound_bottom_rocket = y_grid_rocket - 1,
y_bound_top_rocket = y_grid_rocket + 1;
for (int i = x_bound_left_rocket; i <= x_bound_right_rocket; i++) {
if (mustbreak)
break;
for (int j = y_bound_bottom_rocket; j <= y_bound_top_rocket; j++) {
if (mustbreak)
break;
for (Tank*& tank : tank_grid[i][j].tanks) {
if (tank->active && (tank->allignment != rocket.allignment) && rocket.intersects(tank->position, tank->collision_radius)) {
explosions.push_back(Explosion(&explosion, tank->position));
if (tank->hit(ROCKET_HIT_VALUE))
{
smokes.push_back(Smoke(smoke, tank->position - vec2(0, 48)));
}
rocket.active = false;
mustbreak = true;
break;
}
}
}
}
//Remove exploded rockets with remove erase idiom
rockets.erase(std::remove_if(rockets.begin(), rockets.end(), [](const Rocket& rocket) { return !rocket.active; }), rockets.end());
}
//Update particle beams
for (Particle_beam& particle_beam : particle_beams)
{
particle_beam.tick(tanks);
////Damage all tanks within the damage window of the beam (the window is an axis-aligned bounding box)
size_t x_grid_min = ((abs((int)particle_beam.min_position.x)) / (SCRWIDTH / COLSIZE));
size_t x_grid_max = ((abs((int)particle_beam.min_position.x) + particle_beam.max_position.x) / (SCRWIDTH / COLSIZE));
size_t y_grid_min = ((abs((int)particle_beam.min_position.y)) / (SCRHEIGHT / ROWSIZE));
size_t y_grid_max = ((abs((int)particle_beam.max_position.y) + particle_beam.max_position.y) / (SCRHEIGHT / ROWSIZE));
if (x_grid_min < 0 || x_grid_max > SCRWIDTH / COLSIZE - 1 || y_grid_min < 0 || y_grid_max > SCRHEIGHT / ROWSIZE - 1)
continue;
for (size_t i = x_grid_min; i <= x_grid_max; i++) {
for (size_t j = y_grid_min; j <= y_grid_max; j++) {
for (Tank*& tanko : tank_grid[i][j].tanks) {
if (tanko->active && particle_beam.rectangle.intersects_circle(tanko->get_position(), tanko->get_collision_radius()))
{
if (tanko->hit(particle_beam.damage))
{
smokes.push_back(Smoke(smoke, tanko->position - vec2(0, 48)));
}
}
}
}
}
}
//Update explosion sprites and remove when done with remove erase idiom
for (Explosion& explosion : explosions)
{
explosion.tick();
}
explosions.erase(std::remove_if(explosions.begin(), explosions.end(), [](const Explosion& explosion) { return explosion.done(); }), explosions.end());
}
void Game::draw()
{
// clear the graphics window
screen->clear(0);
//Draw background
background.draw(screen, 0, 0);
//Draw sprites
for (int i = 0; i < NUM_TANKS_BLUE + NUM_TANKS_RED; i++)
{
tanks.at(i).draw(screen);
vec2 tank_pos = tanks.at(i).get_position();
// tread marks
if ((tank_pos.x >= 0) && (tank_pos.x < SCRWIDTH) && (tank_pos.y >= 0) && (tank_pos.y < SCRHEIGHT))
background.get_buffer()[(int)tank_pos.x + (int)tank_pos.y * SCRWIDTH] = sub_blend(background.get_buffer()[(int)tank_pos.x + (int)tank_pos.y * SCRWIDTH], 0x808080);
}
for (Rocket& rocket : rockets)
{
rocket.draw(screen);
}
for (Smoke& smoke : smokes)
{
smoke.draw(screen);
}
for (Particle_beam& particle_beam : particle_beams)
{
particle_beam.draw(screen);
}
for (Explosion& explosion : explosions)
{
explosion.draw(screen);
}
//Draw sorted health bars
for (int t = 0; t < 2; t++)
{
const int NUM_TANKS = ((t < 1) ? NUM_TANKS_BLUE : NUM_TANKS_RED);
const int begin = ((t < 1) ? 0 : NUM_TANKS_BLUE);
std::vector<const Tank*> sorted_tanks;
{
Timer timer; merge_sort_tanks_health(tanks);
}/*insertion_sort_tanks_health(tanks, sorted_tanks, begin, begin + NUM_TANKS);*/
for (int i = 0; i < NUM_TANKS; i++)
{
int health_bar_start_x = i * (HEALTH_BAR_WIDTH + HEALTH_BAR_SPACING) + HEALTH_BARS_OFFSET_X;
int health_bar_start_y = (t < 1) ? 0 : (SCRHEIGHT - HEALTH_BAR_HEIGHT) - 1;
int health_bar_end_x = health_bar_start_x + HEALTH_BAR_WIDTH;
int health_bar_end_y = (t < 1) ? HEALTH_BAR_HEIGHT : SCRHEIGHT - 1;
screen->bar(health_bar_start_x, health_bar_start_y, health_bar_end_x, health_bar_end_y, REDMASK);
//screen->bar(health_bar_start_x, health_bar_start_y + (int)((double)HEALTH_BAR_HEIGHT * (1 - ((double)sorted_tanks.at(i)->health / (double)TANK_MAX_HEALTH))), health_bar_end_x, health_bar_end_y, GREENMASK);
screen->bar(health_bar_start_x, health_bar_start_y + (int)((double)HEALTH_BAR_HEIGHT * (1 - ((double)tanks.at(i).health / (double)TANK_MAX_HEALTH))), health_bar_end_x, health_bar_end_y, GREENMASK);
}
}
}
// -----------------------------------------------------------
// Sort tanks by health value using insertion sort
// -----------------------------------------------------------
void Tmpl8::Game::insertion_sort_tanks_health(const std::vector<Tank>& original, std::vector<const Tank*>& sorted_tanks, int begin, int end)
{
//Timer timer;
const int NUM_TANKS = end - begin;
sorted_tanks.reserve(NUM_TANKS);
sorted_tanks.emplace_back(&original.at(begin));
for (int i = begin + 1; i < (begin + NUM_TANKS); i++)
{
const Tank& current_tank = original.at(i);
for (int s = (int)sorted_tanks.size() - 1; s >= 0; s--)
{
const Tank* current_checking_tank = sorted_tanks.at(s);
if ((current_checking_tank->compare_health(current_tank) <= 0))
{
sorted_tanks.insert(1 + sorted_tanks.begin() + s, ¤t_tank);
break;
}
if (s == 0)
{
sorted_tanks.insert(sorted_tanks.begin(), ¤t_tank);
break;
}
}
}
}
vector<Tank> Tmpl8::Game::merge_sort_tanks_health(vector<Tank> original)
{
Timer timer;
if (original.size() > 1) {
int mid = original.size() / 2;
//C++ Equivalent to using Python Slices
vector<Tank> lefthalf(original.begin(), original.begin() + mid);
vector<Tank> righthalf(original.begin() + mid, original.begin() + original.size());
lefthalf = merge_sort_tanks_health(lefthalf);
righthalf = merge_sort_tanks_health(righthalf);
unsigned i = 0;
unsigned j = 0;
unsigned k = 0;
while (i < lefthalf.size() && j < righthalf.size()) {
if (lefthalf[i].health < righthalf[j].health) {
original[k] = lefthalf[i];
i++;
}
else {
original[k] = righthalf[j];
j++;
}
k++;
}
while (i < lefthalf.size()) {
original[k] = lefthalf[i];
i++;
k++;
}
while (j < righthalf.size()) {
original[k] = righthalf[j];
j++;
k++;
}
}
return original;
}
// -----------------------------------------------------------
// When we reach MAX_FRAMES print the duration and speedup multiplier
// Updating REF_PERFORMANCE at the top of this file with the value
// on your machine gives you an idea of the speedup your optimizations give
// -----------------------------------------------------------
void Tmpl8::Game::measure_performance()
{
char buffer[128];
if (frame_count >= MAX_FRAMES)
{
if (!lock_update)
{
duration = perf_timer.elapsed();
cout << "Duration was: " << duration << " (Replace REF_PERFORMANCE with this value)" << endl;
lock_update = true;
}
frame_count--;
}
if (lock_update)
{
screen->bar(420, 170, 870, 430, 0x030000);
int ms = (int)duration % 1000, sec = ((int)duration / 1000) % 60, min = ((int)duration / 60000);
sprintf(buffer, "%02i:%02i:%03i", min, sec, ms);
frame_count_font->centre(screen, buffer, 200);
sprintf(buffer, "SPEEDUP: %4.1f", REF_PERFORMANCE / duration);
frame_count_font->centre(screen, buffer, 340);
}
}
void Tmpl8::Game::updateGrids()
{
int tanko = 0;
for (size_t i = 0; i < SCRWIDTH / COLSIZE; i++) {
for (size_t j = 0; j < SCRHEIGHT / ROWSIZE; j++) {
vector<Tank*>::iterator it;
for (it = tank_grid[i][j].tanks.begin(); it != tank_grid[i][j].tanks.end(); ) {
tanko++;
int xGrid = ((*it)->position.x / (SCRWIDTH / COLSIZE));
int yGrid = ((*it)->position.y / (SCRHEIGHT / ROWSIZE));
if ((*it)->xGrid != xGrid || (*it)->yGrid != yGrid) {
(*it)->setXY(xGrid, yGrid);
tank_grid[xGrid][yGrid].insertTank(*it);
it = tank_grid[i][j].tanks.erase(it);
}
else {
++it;
}
}
}
}
//cout << tanko << endl;
}
void Game::checkColors() {
redGrids.clear();
blueGrids.clear();
for (int i = 0; i < SCRWIDTH / COLSIZE; i++) {
for (int j = 0; j < SCRHEIGHT / ROWSIZE; j++) {
bool blue = false;
bool red = false;
for (Tank*& tank : tank_grid[i][j].tanks) {
if (!tank->active)
continue;
if (blue && red)
break;
if (tank->allignment == RED)
red = true;
if (tank->allignment == BLUE)
blue = true;
}
if (red)
redGrids.push_back(make_pair(i, j));
if (blue)
blueGrids.push_back(make_pair(i, j));
}
}
}
// -----------------------------------------------------------
// Main application tick function
// -----------------------------------------------------------
void Game::tick(float deltaTime)
{
if (!lock_update)
{
update(deltaTime);
}
draw();
measure_performance();
// print something in the graphics window
//screen->Print("hello world", 2, 2, 0xffffff);
// print something to the text window
//cout << "This goes to the console window." << std::endl;
//Print frame count
frame_count++;
string frame_count_string = "FRAME: " + std::to_string(frame_count);
frame_count_font->print(screen, frame_count_string.c_str(), 350, 580);
} | [
"56873636+Allinonepker@users.noreply.github.com"
] | 56873636+Allinonepker@users.noreply.github.com |
86dd3e1d802792d8ecd17bfc0ab93bdab29bb0da | 88d4848631ad8a1da888af159834580cd7360b95 | /sportdream/ios/DreamSDK/VideoOutput/live_packet_pool.cpp | 40c330d604e45d6c639d9bb64cbd5b925b093c04 | [] | no_license | lovesunstar/sport_native | feff91b00354851b5542e262f22c442859506731 | b81d1b96d5fbbc992892d52b50a123469ca2bce2 | refs/heads/master | 2020-12-22T21:52:12.264513 | 2018-09-01T23:34:52 | 2018-09-01T23:34:52 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,074 | cpp | //
// live_packet_pool.cpp
// sportdream
//
// Created by lili on 2018/3/28.
// Copyright © 2018年 Facebook. All rights reserved.
//
#include "live_packet_pool.hpp"
LivePacketPool::LivePacketPool(){
audioPacketQueue = NULL;
recordingVideoPacketQueue = NULL;
statistics = NULL;
buffer = NULL;
pthread_rwlock_init(&mRwlock, NULL);
}
LivePacketPool::~LivePacketPool() {
pthread_rwlock_destroy(&mRwlock);
}
//初始化静态成员
LivePacketPool* LivePacketPool::instance = new LivePacketPool();
LivePacketPool* LivePacketPool::GetInstance() {
return instance;
}
void LivePacketPool::initAudioPacketQueue(int audioSampleRate){
const char* name = "audioPacket queue";
audioPacketQueue = new LiveAudioPacketQueue(name);
this->audioSampleRate = audioSampleRate;
#ifdef __ANDROID__
this->channels = INPUT_CHANNEL_4_ANDROID;
#elif defined(__APPLE__) // IOS or OSX
this->channels = INPUT_CHANNEL_4_IOS;
#endif
bufferSize = audioSampleRate * channels * AUDIO_PACKET_DURATION_IN_SECS;
buffer = new short[bufferSize];
bufferCursor = 0;
}
void LivePacketPool::abortAudioPacketQueue(){
if(NULL != audioPacketQueue){
audioPacketQueue->abort();
}
}
void LivePacketPool::destoryAudioPacketQueue() {
if(NULL != audioPacketQueue){
delete audioPacketQueue;
audioPacketQueue = NULL;
}
if(buffer){
delete[] buffer;
buffer = NULL;
}
}
int LivePacketPool::getAudioPacket(LiveAudioPacket **audioPacket, bool block) {
int result = -1;
if(NULL != audioPacketQueue){
result = audioPacketQueue->get(audioPacket, block);
}
return result;
}
int LivePacketPool::getAudioPacketQueueSize() {
return audioPacketQueue->size();
}
bool LivePacketPool::discardAudioPacket() {
bool ret = false;
LiveAudioPacket *tempAudioPacket = NULL;
int resultCode = audioPacketQueue->get(&tempAudioPacket, true);
if (resultCode > 0) {
delete tempAudioPacket;
tempAudioPacket = NULL;
pthread_rwlock_wrlock(&mRwlock);
totalDiscardVideoPacketDuration -= (AUDIO_PACKET_DURATION_IN_SECS * 1000.0f);
pthread_rwlock_unlock(&mRwlock);
ret = true;
}
// LOGI("discard %d ms Audio Data And this time totalDiscardVideoPacketDuration is %d getAudioPacketQueueSize is %d", (int)(AUDIO_PACKET_DURATION_IN_SECS * 1000.0f), totalDiscardVideoPacketDuration, getAudioPacketQueueSize());
return ret;
}
void LivePacketPool::setStatistics(PublisherStatistics* statistics){
this->statistics = statistics;
}
bool LivePacketPool::detectDiscardAudioPacket() {
bool ret = false;
pthread_rwlock_wrlock(&mRwlock);
ret = totalDiscardVideoPacketDuration >= (AUDIO_PACKET_DURATION_IN_SECS * 1000.0f);
pthread_rwlock_unlock(&mRwlock);
return ret;
}
void LivePacketPool::pushAudioPacketToQueue(LiveAudioPacket* audioPacket) {
if(NULL != audioPacketQueue){
int audioPacketBufferCursor = 0;
// float position = audioPacket->position;
while(audioPacket->size > 0){
int audioBufferLength = bufferSize - bufferCursor;
int length = MIN(audioBufferLength, audioPacket->size);
memcpy(buffer + bufferCursor, audioPacket->buffer + audioPacketBufferCursor, length * sizeof(short));
audioPacket->size -= length;
bufferCursor += length;
audioPacketBufferCursor += length;
if(bufferCursor == bufferSize){
LiveAudioPacket* targetAudioPacket = new LiveAudioPacket();
targetAudioPacket->size = bufferSize;
short * audioBuffer = new short[bufferSize];
memcpy(audioBuffer, buffer, bufferSize * sizeof(short));
targetAudioPacket->buffer = audioBuffer;
// int consumeBufferCnt = audioPacketBufferCursor - length;
// float consumeBufferDuration = ((float)consumeBufferCnt / (float)(this->channels * audioSampleRate)) * 1000.0f;
// targetAudioPacket->position = position + consumeBufferDuration;
// LOGI("AudioPacket Split : targetAudioPacket->position is %.6f", targetAudioPacket->position);
audioPacketQueue->put(targetAudioPacket);
bufferCursor = 0;
}
}
delete audioPacket;
}
}
void LivePacketPool::initRecordingVideoPacketQueue() {
if(NULL == recordingVideoPacketQueue){
const char* name = "recording video yuv frame packet queue";
recordingVideoPacketQueue = new LiveVideoPacketQueue(name);
totalDiscardVideoPacketDuration = 0;
statistics = NULL;
tempVideoPacket = NULL;
tempVideoPacketRefCnt = 0;
}
}
void LivePacketPool::abortRecordingVideoPacketQueue() {
if (NULL != recordingVideoPacketQueue) {
recordingVideoPacketQueue->abort();
}
}
void LivePacketPool::destoryRecordingVideoPacketQueue() {
if (NULL != recordingVideoPacketQueue) {
delete recordingVideoPacketQueue;
recordingVideoPacketQueue = NULL;
if(tempVideoPacketRefCnt > 0){
delete tempVideoPacket;
tempVideoPacket = NULL;
}
}
}
int LivePacketPool::getRecordingVideoPacket(LiveVideoPacket **videoPacket,
bool block) {
int result = -1;
if (NULL != recordingVideoPacketQueue) {
result = recordingVideoPacketQueue->get(videoPacket, block);
}
return result;
}
bool LivePacketPool::detectDiscardVideoPacket(){
return recordingVideoPacketQueue->size() > VIDEO_PACKET_QUEUE_THRRESHOLD;
}
bool LivePacketPool::pushRecordingVideoPacketToQueue(LiveVideoPacket* videoPacket) {
bool dropFrame = false;
if (NULL != recordingVideoPacketQueue) {
while (detectDiscardVideoPacket()) {
dropFrame = true;
int discardVideoFrameCnt = 0;
int discardVideoFrameDuration = recordingVideoPacketQueue->discardGOP(&discardVideoFrameCnt);
if(discardVideoFrameDuration < 0){
break;
}
if(NULL != statistics){
statistics->discardVideoFrame(discardVideoFrameCnt);
}
this->recordDropVideoFrame(discardVideoFrameDuration);
// LOGI("discard a GOP Video Packet And totalDiscardVideoPacketSize is %d", totalDiscardVideoPacketSize);
}
//为了计算当前帧的Duration, 所以延迟一帧放入Queue中
if(NULL != tempVideoPacket){
int packetDuration = videoPacket->timeMills - tempVideoPacket->timeMills;
tempVideoPacket->duration = packetDuration;
recordingVideoPacketQueue->put(tempVideoPacket);
tempVideoPacketRefCnt = 0;
}
tempVideoPacket = videoPacket;
tempVideoPacketRefCnt = 1;
if(NULL != statistics){
statistics->pushVideoFrame();
}
}
return dropFrame;
}
void LivePacketPool::recordDropVideoFrame(int discardVideoPacketDuration){
pthread_rwlock_wrlock(&mRwlock);
totalDiscardVideoPacketDuration+=discardVideoPacketDuration;
pthread_rwlock_unlock(&mRwlock);
}
int LivePacketPool::getRecordingVideoPacketQueueSize() {
if (NULL != recordingVideoPacketQueue) {
return recordingVideoPacketQueue->size();
}
return 0;
}
void LivePacketPool::clearRecordingVideoPacketToQueue() {
if (NULL != recordingVideoPacketQueue) {
return recordingVideoPacketQueue->flush();
}
}
| [
"910680459@qq.com"
] | 910680459@qq.com |
253dff6af64ed245f32ff88d6257bda1ad297901 | 979cca5f17bc85120d9223b0eba88c5c5a154ea6 | /lib/CSmtp.h | 13324e4978580c85b27fc182883bec6b5d68db66 | [] | no_license | taicai/vfds | b76e6582bb3740cb8c29d392b11aba0d9783d655 | dd2bddc6cde727d99028f908e13af76506492473 | refs/heads/master | 2021-01-15T14:46:42.124781 | 2015-09-01T10:13:50 | 2015-09-01T10:13:50 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,693 | h | // CSmtp.h: interface for the Smtp class.
//
//////////////////////////////////////////////////////////////////////
#pragma once
#ifndef __CSMTP_H__
#define __CSMTP_H__
#include <vector>
#include <string.h>
#include <assert.h>
#ifdef LINUX
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <errno.h>
#include <stdio.h>
#include <iostream>
#define SOCKET_ERROR -1
#define INVALID_SOCKET -1
typedef unsigned short WORD;
typedef int SOCKET;
typedef struct sockaddr_in SOCKADDR_IN;
typedef struct hostent* LPHOSTENT;
typedef struct servent* LPSERVENT;
typedef struct in_addr* LPIN_ADDR;
typedef struct sockaddr* LPSOCKADDR;
#else
#include <winsock2.h>
#include <time.h>
#pragma comment(lib, "ws2_32.lib")
#endif
#define TIME_IN_SEC 10 // how long client will wait for server response in non-blocking mode
#define BUFFER_SIZE 10240 // SendData and RecvData buffers sizes
#define MSG_SIZE_IN_MB 5 // the maximum size of the message with all attachments
#define COUNTER_VALUE 100 // how many times program will try to receive data
const char BOUNDARY_TEXT[] = "__MESSAGE__ID__54yg6f6h6y456345";
enum CSmptXPriority
{
XPRIORITY_HIGH = 2,
XPRIORITY_NORMAL = 3,
XPRIORITY_LOW = 4
};
class ECSmtp
{
public:
enum CSmtpError
{
CSMTP_NO_ERROR = 0,
WSA_STARTUP = 100, // WSAGetLastError()
WSA_VER,
WSA_SEND,
WSA_RECV,
WSA_CONNECT,
WSA_GETHOSTBY_NAME_ADDR,
WSA_INVALID_SOCKET,
WSA_HOSTNAME,
WSA_IOCTLSOCKET,
WSA_SELECT,
BAD_IPV4_ADDR,
UNDEF_MSG_HEADER = 200,
UNDEF_MAIL_FROM,
UNDEF_SUBJECT,
UNDEF_RECIPIENTS,
UNDEF_LOGIN,
UNDEF_PASSWORD,
UNDEF_RECIPIENT_MAIL,
COMMAND_MAIL_FROM = 300,
COMMAND_EHLO,
COMMAND_AUTH_LOGIN,
COMMAND_DATA,
COMMAND_QUIT,
COMMAND_RCPT_TO,
MSG_BODY_ERROR,
CONNECTION_CLOSED = 400, // by server
SERVER_NOT_READY, // remote server
SERVER_NOT_RESPONDING,
SELECT_TIMEOUT,
FILE_NOT_EXIST,
MSG_TOO_BIG,
BAD_LOGIN_PASS,
UNDEF_XYZ_RESPONSE,
LACK_OF_MEMORY,
TIME_ERROR,
RECVBUF_IS_EMPTY,
SENDBUF_IS_EMPTY,
OUT_OF_MSG_RANGE
};
ECSmtp(CSmtpError err_) : ErrorCode(err_) {}
CSmtpError GetErrorNum(void) const {return ErrorCode;}
std::string GetErrorText(void) const;
private:
CSmtpError ErrorCode;
};
class CSmtp
{
public:
CSmtp();
virtual ~CSmtp();
void AddRecipient(const char *email, const char *name=NULL);
void AddBCCRecipient(const char *email, const char *name=NULL);
void AddCCRecipient(const char *email, const char *name=NULL);
void AddAttachment(const char *path);
void AddMsgLine(const char* text);
void DelRecipients(void);
void DelBCCRecipients(void);
void DelCCRecipients(void);
void DelAttachments(void);
void DelMsgLines(void);
void DelMsgLine(unsigned int line);
void ModMsgLine(unsigned int line,const char* text);
unsigned int GetBCCRecipientCount() const;
unsigned int GetCCRecipientCount() const;
unsigned int GetRecipientCount() const;
const char* GetLocalHostIP() const;
const char* GetLocalHostName() const;
const char* GetMsgLineText(unsigned int line) const;
unsigned int GetMsgLines(void) const;
const char* GetReplyTo() const;
const char* GetMailFrom() const;
const char* GetSenderName() const;
const char* GetSubject() const;
const char* GetXMailer() const;
CSmptXPriority GetXPriority() const;
void Send();
void SetSubject(const char*);
void SetSenderName(const char*);
void SetSenderMail(const char*);
void SetReplyTo(const char*);
void SetXMailer(const char*);
void SetLogin(const char*);
void SetPassword(const char*);
void SetXPriority(CSmptXPriority);
void SetSMTPServer(const char* server,const unsigned short port=0);
void SetMsgBody(const char *src);
void SetHeadFlag(int flag);
void CloseHandle();
private:
std::string m_sLocalHostName;
std::string m_sMailFrom;
std::string m_sNameFrom;
std::string m_sSubject;
std::string m_sXMailer;
std::string m_sReplyTo;
std::string m_sIPAddr;
std::string m_sLogin;
std::string m_sPassword;
std::string m_sSMTPSrvName;
unsigned short m_iSMTPSrvPort;
CSmptXPriority m_iXPriority;
char *SendBuf;
char *RecvBuf;
SOCKET hSocket;
struct Recipient
{
std::string Name;
std::string Mail;
};
std::vector<Recipient> Recipients;
std::vector<Recipient> CCRecipients;
std::vector<Recipient> BCCRecipients;
std::vector<std::string> Attachments;
std::vector<std::string> MsgBody;
const char *m_msgbody;
int m_headflag;
void ReceiveData();
void SendData();
void FormatHeader(char*);
int SmtpXYZdigits();
SOCKET ConnectRemoteServer(const char* server, const unsigned short port=0);
};
#endif // __CSMTP_H__
| [
"jingchun.zhang@code.(none)"
] | jingchun.zhang@code.(none) |
4aaeddd9178d433d685a0b326d4ee07452d57f74 | 9ed92547e15ddd53d0df5e1128880a805e7c4e63 | /algorithms/stringFunctionCalculation.cpp | eb6da7041702dc88774f27a674f30134f9ab4651 | [
"MIT"
] | permissive | kosmaz/HackerRank | 8ce91648f5d97a6e597ed9e2bbe912cbcd61543d | 1107804c8213d169070a5529de26b97eb190e06c | refs/heads/master | 2021-06-16T07:11:28.941274 | 2017-01-26T12:36:45 | 2017-01-26T12:36:45 | 32,648,229 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,425 | cpp | #include <iostream>
#include <string>
using namespace std;
class Node
{
public:
Node():fLeaf(false),fIndex(-1),fLeft(nullptr),fRight(nullptr){}
Node* left(){return fLeft;}
Node* right(){return fRight;}
int index(){return fIndex;}
bool isLeaf(){return fLeaf;}
string pattern(){return fPattern;}
void setIndex(int index){fIndex=index;}
void setLeaf(bool status){fLeaf=status;}
void setLeftNode(Node* left){fLeft=left;}
void setRightNode(Node* right){fRight=right;}
void setPattern(string pattern){fPattern=pattern;}
private:
Node(const Node&)=delete;
Node(Node&&)=delete;
Node& operator=(const Node&)=delete;
Node& operator=(const Node&&)=delete;
bool fLeaf;
int fIndex;
string fPattern;
Node* fLeft;
Node* fRight;
};
class suffixTree
{
public:
explicit suffixTree(string generate):fString(generate)
{
buildTree();
}
void buildTree()
{
}
private:
suffixTree(const suffixTree&)=delete;
suffixTree(suffixTree&&)=delete;
suffixTree& operator=(const suffixTree&)=delete;
suffixTree& operator=(const suffixTree&&)=delete;
string fString;
Node* root;
};
void Run()
{
string input;
getline(cin,input,'\n');
suffixTree tree=new suffixTree(input);
return;
}
int main()
{
Run();
return 0;
}
| [
"ezenwanne_cosmas@yahoo.com"
] | ezenwanne_cosmas@yahoo.com |
518cd334df108de7dc342a345ba543e8aa8e78f0 | 4051fbe4641bcc557d731a9c131affd7566fe47e | /VisualizationDirectX/Direct3D11/D3D11InfoQueue.cpp | 702432573c541af03e883566db088ce81ab362b2 | [] | no_license | sulerzh/directx | 1bef849a2a72aae68e2efe62fa693b9e75f7df26 | 225479355babdd31ff256eb37a237dccada23945 | refs/heads/master | 2020-05-20T03:13:22.857348 | 2015-05-25T05:47:23 | 2015-05-25T05:47:23 | 29,289,661 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,425 | cpp | // Copyright (c) Microsoft Corporation. All rights reserved.
#include "stdafx.h"
#include "D3D11InfoQueue.h"
using namespace msclr::interop;
using namespace Microsoft::Data::Visualization::DirectX::Utilities;
using namespace Microsoft::Data::Visualization::DirectX::Direct3D11;
void InfoQueue::AddApplicationMessage(MessageSeverity severity, String^ description)
{
IntPtr ptr = Marshal::StringToHGlobalAnsi(description);
try
{
Validate::VerifyResult(CastInterface<ID3D11InfoQueue>()->AddApplicationMessage(
static_cast<D3D11_MESSAGE_SEVERITY>(severity),
static_cast<char*>(ptr.ToPointer())));
}
finally
{
Marshal::FreeHGlobal(ptr);
}
}
void InfoQueue::AddMessage(MessageCategory Category, MessageSeverity Severity, MessageId ID, String^ description)
{
IntPtr ptr = Marshal::StringToHGlobalAnsi(description);
try
{
Validate::VerifyResult(CastInterface<ID3D11InfoQueue>()->AddMessage(
static_cast<D3D11_MESSAGE_CATEGORY>(Category),
static_cast<D3D11_MESSAGE_SEVERITY>(Severity),
static_cast<D3D11_MESSAGE_ID>(ID),
static_cast<char*>(ptr.ToPointer())));
}
finally
{
Marshal::FreeHGlobal(ptr);
}
}
void InfoQueue::ClearStoredMessages()
{
CastInterface<ID3D11InfoQueue>()->ClearStoredMessages();
}
Boolean InfoQueue::GetBreakOnCategory(MessageCategory Category)
{
return CastInterface<ID3D11InfoQueue>()->GetBreakOnCategory(static_cast<D3D11_MESSAGE_CATEGORY>(Category)) != 0;
}
Boolean InfoQueue::GetBreakOnId(MessageId ID)
{
return CastInterface<ID3D11InfoQueue>()->GetBreakOnID(static_cast<D3D11_MESSAGE_ID>(ID)) != 0;
}
Boolean InfoQueue::GetBreakOnSeverity(MessageSeverity Severity)
{
return CastInterface<ID3D11InfoQueue>()->GetBreakOnSeverity(static_cast<D3D11_MESSAGE_SEVERITY>(Severity)) != 0;
}
Message InfoQueue::GetMessage(UInt64 messageIndex)
{
// Get the size of the message
SIZE_T messageLength = 0;
Validate::VerifyResult(
CastInterface<ID3D11InfoQueue>()->GetMessage(
messageIndex,
NULL,
&messageLength));
// Allocate space and get the message
D3D11_MESSAGE * pMessage = (D3D11_MESSAGE*)malloc(messageLength);
try
{
Validate::VerifyResult(CastInterface<ID3D11InfoQueue>()->GetMessage(
messageIndex,
pMessage,
&messageLength));
return Message(pMessage);
}
finally
{
free(pMessage);
}
}
bool InfoQueue::TryGetMessage(UInt64 messageIndex, [System::Runtime::InteropServices::Out] Message % outMessage)
{
// Get the size of the message
SIZE_T messageLength = 0;
if (FAILED(CastInterface<ID3D11InfoQueue>()->GetMessage(messageIndex, NULL, &messageLength)))
{
outMessage = Message(NULL);
return false;
}
// Allocate space and get the message
D3D11_MESSAGE * pMessage = (D3D11_MESSAGE*)malloc(messageLength);
ZeroMemory(pMessage, messageLength);
try
{
if (SUCCEEDED(CastInterface<ID3D11InfoQueue>()->GetMessage(static_cast<UINT64>(messageIndex), pMessage, &messageLength)))
{
outMessage = Message(pMessage);
return true;
}
else
{
outMessage = Message(NULL);
return false;
}
}
finally
{
free(pMessage);
}
}
UInt64 InfoQueue::MessageCountLimit::get()
{
return CastInterface<ID3D11InfoQueue>()->GetMessageCountLimit();
}
Boolean InfoQueue::MuteDebugOutput::get()
{
return CastInterface<ID3D11InfoQueue>()->GetMuteDebugOutput() != 0;
}
UInt64 InfoQueue::AllowedByStorageFilterCount::get()
{
return CastInterface<ID3D11InfoQueue>()->GetNumMessagesAllowedByStorageFilter();
}
UInt64 InfoQueue::DeniedByStorageFilterCount::get()
{
return CastInterface<ID3D11InfoQueue>()->GetNumMessagesDeniedByStorageFilter();
}
UInt64 InfoQueue::DiscardedByMessageCountLimitCount::get()
{
return CastInterface<ID3D11InfoQueue>()->GetNumMessagesDiscardedByMessageCountLimit();
}
UInt64 InfoQueue::StoredCount::get()
{
return CastInterface<ID3D11InfoQueue>()->GetNumStoredMessages();
}
UInt64 InfoQueue::StoredAllowedByRetrievalFilterCount::get()
{
return CastInterface<ID3D11InfoQueue>()->GetNumStoredMessagesAllowedByRetrievalFilter();
}
void InfoQueue::SetBreakOnCategory(MessageCategory Category, Boolean bEnable)
{
Validate::VerifyResult(CastInterface<ID3D11InfoQueue>()->SetBreakOnCategory(static_cast<D3D11_MESSAGE_CATEGORY>(Category), safe_cast<BOOL>(bEnable)));
}
void InfoQueue::SetBreakOnId(MessageId ID, Boolean bEnable)
{
Validate::VerifyResult(CastInterface<ID3D11InfoQueue>()->SetBreakOnID(static_cast<D3D11_MESSAGE_ID>(ID), bEnable ? 1 : 0));
}
// REVIEW: if C++ supports indexers, then this kind of "Set..." method could be
// an indexer.
void InfoQueue::SetBreakOnSeverity(MessageSeverity Severity, Boolean bEnable)
{
Validate::VerifyResult(CastInterface<ID3D11InfoQueue>()->SetBreakOnSeverity(static_cast<D3D11_MESSAGE_SEVERITY>(Severity), safe_cast<BOOL>(bEnable)));
}
void InfoQueue::MessageCountLimit::set(UInt64 value)
{
Validate::VerifyResult(CastInterface<ID3D11InfoQueue>()->SetMessageCountLimit(value));
}
void InfoQueue::MuteDebugOutput::set(Boolean value)
{
CastInterface<ID3D11InfoQueue>()->SetMuteDebugOutput(value ? 1 : 0);
}
| [
"sulerzh@sina.com"
] | sulerzh@sina.com |
2130e44aba82700b3b959d847eb3df13d403747a | 679275e8dca75663a239cd0e11048cc6f9330596 | /native/Sparky-core/src/sp/graphics/buffers/IndexBuffer.cpp | 31d2d59f142d4cfd6ce012bb63786f8c85c0faed | [
"Apache-2.0"
] | permissive | Itay2805/Sparky4j-core | 1f9b8e8c30e769822068876e9d503cf075f0d6ba | 2035a05cefb51c2fe87e1dceb2f81d4b8205a4e0 | refs/heads/master | 2021-01-18T22:27:40.907273 | 2016-08-03T21:43:34 | 2016-08-03T21:43:34 | 49,773,827 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 721 | cpp | #include "IndexBuffer.h"
namespace sp { namespace graphics {
IndexBuffer::IndexBuffer(short* data, uint count)
: m_Count(count)
{
m_Buffer = new API::Buffer(GL_ELEMENT_ARRAY_BUFFER, GL_STATIC_DRAW);
m_Buffer->Bind();
m_Buffer->SetData(count * sizeof(short), data);
m_Buffer->Unbind();
}
IndexBuffer::IndexBuffer(uint* data, uint count)
: m_Count(count)
{
m_Buffer = new API::Buffer(GL_ELEMENT_ARRAY_BUFFER, GL_STATIC_DRAW);
m_Buffer->Bind();
m_Buffer->SetData(count * sizeof(uint), data);
m_Buffer->Unbind();
}
IndexBuffer::~IndexBuffer()
{
delete m_Buffer;
}
void IndexBuffer::Bind() const
{
m_Buffer->Bind();
}
void IndexBuffer::Unbind() const
{
m_Buffer->Unbind();
}
} } | [
"itay2805.il@gmail.com"
] | itay2805.il@gmail.com |
c46e022524b2e0392b0455bf3c3878d51e0af513 | d9a7afdf160f15a2a8bc5f07e07a0422c5d8da8b | /3-work/qt/qt-HMIClient/MESApp/src/Sqlite/Entity/UpXMLData/OtherSetInfo.h | cd7bb7ff4a6d45bab0a798026bf55995ec4e5601 | [] | no_license | programcj/programming_path | 964cd53fdef74041241ebe392eeb0c4566eb1d89 | 04a410492a9ee7173612122e367ac1c5b101d7ce | refs/heads/master | 2021-12-15T10:43:33.066541 | 2021-12-11T10:20:01 | 2021-12-11T10:20:01 | 184,296,551 | 1 | 5 | null | null | null | null | UTF-8 | C++ | false | false | 11,223 | h | /*
* OtherSetInfo.h
*
* Created on: 2015年1月29日
* Author: cj
*/
#ifndef OTHERSETINFO_H_
#define OTHERSETINFO_H_
#include "../absentity.h"
namespace entity {
/*
*ii. 发送其它设置信息
*ii. 0x00:升级文件
0x01:同步工单
0x02:调整工单
0x03:调整模穴数
0x04:调整原料
0x05:刷完停机卡计数
0x06:设备点检
0x07:电费统计
*ii.
*/
class OtherSetInfo: public AbsPropertyBase {
public:
enum SetType { //设置类型
AsUpgradeFile = 0x00, //:升级文件
AsAsyncOrder = 0x01, //:同步工单
AsAdjOrder = 0x02, //:调整工单
AsAdjSock = 0x03, //:调整模穴数
AsAdjMaterial = 0x04, //:调整原料
AsCardStopNo = 0x05, //:刷完停机卡计数
AsDevInspection = 0x06, //:设备点检
AsELEFeeCount = 0x07 //:电费统计
//其他:保留
};
//40、 升级文件(Set_Data_SIZE)
class UpgradeFile: public AbsPropertyBase {
public:
QString FileName; // 30 ASC 升级文件名
int Result; // 1 BYTE 反馈结果 参考附录一
UpgradeFile() {
FileName = "";
Result = 0;
}
UpgradeFile(const QString &name, int result) {
FileName = name;
Result = result;
}
virtual const char *getClassName() const {
return "UpgradeFile";
}
virtual void onBindProperty() {
addProperty("FileName", Property::AsQStr, &FileName);
addProperty("Result", Property::AsInt, &Result);
}
};
//42、 调整工单(Set_Data_SIZE)
class AdjOrder: public AbsPropertyBase {
public:
int SerialNumber; // 1 HEX 工单序号1
QString DispatchNo; // 20 ASC 派工单号1
QString DispatchPrior; // 30 ASC 派工项次1
AdjOrder() {
SerialNumber = 0;
DispatchNo = "";
DispatchPrior = "";
}
AdjOrder(int index, const QString &no, const QString &prior) {
SerialNumber = index;
DispatchNo = no;
DispatchPrior = prior;
}
virtual const char *getClassName() const {
return "AdjOrder";
}
virtual void onBindProperty() {
addProperty("SerialNumber", Property::AsInt, &SerialNumber);
addProperty("DispatchNo", Property::AsQStr, &DispatchNo);
addProperty("DispatchPrior", Property::AsQStr, &DispatchPrior);
}
private:
};
//44、 每件产品的数据格式PCS_Data
class ItemProduct: public AbsPropertyBase {
public:
QString MO; // 20 ASC 工单号
QString ItemNO; // 20 ASC 产品编号
int DispatchQty; // 4 DWORD 派工数量
int SocketNum; // 1 HEX 模穴数
ItemProduct() :
MO(""), ItemNO(""), DispatchQty(0), SocketNum(0) {
}
ItemProduct(const QString &mo, const QString &itemNo, int disQty,
int sock) :
MO(mo), ItemNO(itemNo), DispatchQty(disQty), SocketNum(sock) {
}
virtual const char *getClassName() const {
return "ItemProduct";
}
virtual void onBindProperty() {
addProperty("MO", Property::AsQStr, &MO);
addProperty("ItemNO", Property::AsQStr, &ItemNO);
addProperty("DispatchQty", Property::AsInt, &DispatchQty);
addProperty("SocketNum", Property::AsInt, &SocketNum);
}
};
//43、 调整模穴数(Set_Data_SIZE)
class AdjSock: public AbsPropertyBase {
public:
QString DispatchNo; // 20 ASC 派工单号
QString DispatchPrior; // 30 ASC 派工项次
QList<ItemProduct> productList;
AdjSock() {
DispatchNo = "";
DispatchPrior = "";
}
virtual const char *getClassName() const {
return "AdjSock";
}
virtual void onBindProperty() {
addProperty("DispatchNo", Property::AsQStr, &DispatchNo);
addProperty("DispatchPrior", Property::AsQStr, &DispatchPrior);
addProperty("productList", Property::AsQList_ItemProduct,
&productList);
}
};
//调整原料,每个原料信息
class ItemMaterial: public AbsPropertyBase {
public:
QString MaterialNO; // 50 ASC 原料1编号
QString MaterialName; // 100 ASC 原料1名称
QString BatchNO; // 50 ASC 原料1批次号
int FeedingQty; // 4 HEX 原料1投料数量
QString FeedingTime; // 6 HEX 原料1投料时间
ItemMaterial() :
MaterialNO(""), MaterialName(""), BatchNO(""), FeedingQty(0), FeedingTime(
"") {
}
virtual const char *getClassName() const {
return "ItemMaterial";
}
virtual void onBindProperty() {
addProperty("MaterialNO", Property::AsQStr, &MaterialNO);
addProperty("MaterialName", Property::AsQStr, &MaterialName);
addProperty("BatchNO", Property::AsQStr, &BatchNO);
addProperty("FeedingQty", Property::AsInt, &FeedingQty);
addProperty("FeedingTime", Property::AsQStr, &FeedingTime);
}
};
//45、 调整原料
class AdjMaterial: public AbsPropertyBase {
public:
//int MaterialCount;// 1 HEX 原料总数(N)
QString DispatchNo; // 20 ASC 派工单号
QString CardID; // 10 ASC 员工卡号
QList<ItemMaterial> MaterialList;
virtual const char *getClassName() const {
return "AdjMaterial";
}
virtual void onBindProperty() {
addProperty("DispatchNo", Property::AsQStr, &DispatchNo);
addProperty("CardID", Property::AsQStr, &CardID);
addProperty("MaterialList", Property::AsQList_ItemMaterial,
&MaterialList);
}
};
//46、 刷完停机卡计数
class CardStopNo: public AbsPropertyBase {
public:
QString DispatchNo; // 20 ASC 派工单号
QString DispatchPrior; // 30 ASC 派工项次
QString ProcCode; // 20 ASC 工序代码
QString StaCode; // 10 ASC 站别代码
int CardType; // 1 HEX 刷卡原因编号
QString CardDate; // 6 HEX 生产时间
CardStopNo() :
DispatchNo(""), DispatchPrior(""), ProcCode(""), StaCode(""), CardType(
0), CardDate("") {
}
virtual const char *getClassName() const {
return "CardStopNo";
}
virtual void onBindProperty() {
addProperty("DispatchNo", Property::AsQStr, &DispatchNo);
addProperty("DispatchPrior", Property::AsQStr, &DispatchPrior);
addProperty("ProcCode", Property::AsQStr, &ProcCode);
addProperty("StaCode", Property::AsQStr, &StaCode);
addProperty("CardType", Property::AsInt, &CardType);
addProperty("CardDate", Property::AsQStr, &CardDate);
}
};
//点检项目
class InspectionProj: public AbsPropertyBase {
public:
int NO; // 1 HEX 点检项目编号
int Result; //1 HEX 点检结果1:OK,0:NG
QString Brand;// 30 ASC 机器品牌
virtual const char *getClassName() const {
return "InspectionProj";
}
virtual void onBindProperty() {
addProperty("NO", Property::AsInt, &NO);
addProperty("Result", Property::AsInt, &Result);
addProperty("Brand", Property::AsQStr, &Brand);
}
};
//47、 设备点检
class DevInspection: public AbsPropertyBase {
public:
QString DispatchNo; // 20 ASC 派工单号
QString DispatchPrior; // 30 ASC 派工项次
QString ProcCode; // 20 ASC 工序代码
QString StaCode; // 10 ASC 站别代码
QString CardID; // 10 HEX 卡号
QString CardDate; // 6 HEX 点检时间
//int InspectNum;// 1 HEX 点检总数N(0< N <= 100)
//CC_Data N*PCS_Data_SIZE HEX N个点检项目
QList<InspectionProj> nDataList;
virtual const char *getClassName() const {
return "DevInspection";
}
virtual void onBindProperty() {
addProperty("DispatchNo", Property::AsQStr, &DispatchNo);
addProperty("DispatchPrior", Property::AsQStr, &DispatchPrior);
addProperty("ProcCode", Property::AsQStr, &ProcCode);
addProperty("StaCode", Property::AsQStr, &StaCode);
addProperty("CardID", Property::AsQStr, &CardID);
addProperty("CardDate", Property::AsQStr, &CardDate);
addProperty("nDataList", Property::AsQList_InspectionProj,
&nDataList);
}
};
//49、 电费统计
class ELEFeeCount: public AbsPropertyBase {
public:
QString DispatchNo; // 20 ASC 派工单号
QString DispatchPrior; // 30 ASC 派工项次
QString ProcCode; // 20 ASC 工序代码
QString StaCode; // 10 ASC 站别代码
QString CardID; // 10 HEX 录入人卡号
QString CardDate; // 6 HEX 录入时间
int ElecNum; // 4 HEX 当前班次电费
ELEFeeCount() :
ElecNum(0) {
}
virtual const char *getClassName() const {
return "ELEFeeCount";
}
virtual void onBindProperty() {
addProperty("DispatchNo", Property::AsQStr, &DispatchNo);
addProperty("DispatchPrior", Property::AsQStr, &DispatchPrior);
addProperty("ProcCode", Property::AsQStr, &ProcCode);
addProperty("StaCode", Property::AsQStr, &StaCode);
addProperty("CardID", Property::AsQStr, &CardID);
addProperty("CardDate", Property::AsQStr, &CardDate);
addProperty("ElecNum", Property::AsInt, &ElecNum);
}
};
private:
//int id;
// 0x00:升级文件
// 0x01:同步工单(UI调用 Thread)
// 0x02:调整工单
// 0x03:调整模穴数
// 0x04:调整原料
// 0x05:刷完停机卡计数
// 0x06:设备点检
// 0x07:电费统计
int DataType;
QString FDAT_Data;
void setDataType(int dataType) {
DataType = dataType;
}
void setFdatData(const QString& fdatData) {
FDAT_Data = fdatData;
}
public:
virtual const char *getClassName() const {
return GetThisClassName();
}
static const char *GetThisClassName() {
return "OtherSetInfo";
}
virtual void onBindProperty() {
addProperty("DataType", Property::AsInt, &DataType);
addProperty("FDAT_Data", Property::AsQStr, &FDAT_Data);
}
const QString& getFdatData() const {
return FDAT_Data;
}
int getDataType() const {
return DataType;
}
//40、 升级文件
QString setUpgradeFile(UpgradeFile &file) {
setDataType(AsUpgradeFile);
setFdatData(PropertyBaseToXML(file).toString());
return getFdatData();
}
bool toUpgradeFile(UpgradeFile &file) {
return XMLToPropertyBase(getFdatData(), file);
}
//42、 调整工单
QString setAdjOrderList(QList<AdjOrder> &list) {
QDomDocument doc;
setDataType(AsAdjOrder);
setFdatData(PropertyListToXML(doc, list).toString());
return getFdatData();
}
bool toAdjOrderList(QList<AdjOrder> &list) {
XMLToPropertList(getFdatData(), list);
return true;
}
//43、 调整模穴数
QString setAdjSock(AdjSock &info) {
setDataType(AsAdjSock);
setFdatData(PropertyBaseToXML(info).toString());
return getFdatData();
}
bool toAdjSock(AdjSock &info) {
return XMLToPropertyBase(getFdatData(), info);
}
//45、 调整原料
QString setAdjMaterial(AdjMaterial &info) {
setDataType(AsAdjMaterial);
setFdatData(PropertyBaseToXML(info).toString());
return getFdatData();
}
bool toAdjMaterial(AdjMaterial &info) {
return XMLToPropertyBase(getFdatData(), info);
}
//46、 刷完停机卡计数
QString setCardStopNo(CardStopNo &info) {
setDataType(AsCardStopNo);
setFdatData(PropertyBaseToXML(info).toString());
return getFdatData();
}
bool toCardStopNo(CardStopNo &info) {
return XMLToPropertyBase(getFdatData(), info);
}
//47、 设备点检
QString setDevInspection(DevInspection &info) {
setDataType(AsDevInspection);
setFdatData(PropertyBaseToXML(info).toString());
return getFdatData();
}
bool toDevInspection(DevInspection &info) {
return XMLToPropertyBase(getFdatData(), info);
}
//49、 电费统计
QString setELEFeeCount(ELEFeeCount &info) {
setDataType(AsELEFeeCount);
setFdatData(PropertyBaseToXML(info).toString());
return getFdatData();
}
bool toELEFeeCount(ELEFeeCount &info) {
return XMLToPropertyBase(getFdatData(), info);
}
};
} /* namespace entity */
#endif /* OTHERSETINFO_H_ */
| [
"aa"
] | aa |
00df4d280252020067993ef0d83eec8658535ee1 | ae45359c86a0e91364127824050de9894a614392 | /projects/osgEarthX_COM/COM/Utils/StaticUtils/EarthStaticUtils.h | cd756eef9413e18629ada8ca167d8b035b984397 | [] | no_license | hope815/osgEarthX | 6d6d084f907aaa0e6b832781dfc51a2f0c184eb9 | 7b7c5e98f82c82571cd1d0f306cecf05452315d5 | refs/heads/master | 2023-03-15T21:49:20.588996 | 2018-03-29T10:51:34 | 2018-03-29T10:51:34 | null | 0 | 0 | null | null | null | null | WINDOWS-1252 | C++ | false | false | 337 | h | /**
@brief ¾²Ì¬¹¤¾ßÀà
@author Hao Luo
@date 2015/03/23
*/
#ifndef EARTH_STATIC_UTILS_H
#define EARTH_STATIC_UTILS_H 1
#include "osgEarthX_COM_i.h"
class EarthStaticUtils
{
public:
static HRESULT createInstance( EarthClassType classType, IDispatch** ppIDispatch, void* innerParams = NULL);
protected:
private:
};
#endif | [
"luohao@hacksome.org"
] | luohao@hacksome.org |
8e7d7e44c9c53306d9d2bcf279bb8391e70d3640 | 3a2af230da7d699df36e06ac2358f1f240d47880 | /Scripts/disjointSet.cpp | 91af9f89b07a0a331575b741429750348eceba7c | [
"MIT"
] | permissive | zzz0906/LeetCode | 96e6baca4355cf842826d650e111a65b4f8d93b8 | 6c2ad7ecb91343033362bcb9e6e90766918bef5e | refs/heads/master | 2023-06-23T11:18:21.610633 | 2023-06-23T00:22:52 | 2023-06-23T00:22:52 | 93,714,713 | 22 | 0 | null | 2021-08-17T14:17:30 | 2017-06-08T06:26:02 | C++ | UTF-8 | C++ | false | false | 464 | cpp | # include <bits/stdc++.h>
using namespace std;
class disjointSet{
private:
vector<int> setArray;
public:
disjointSet(int maxLength){
vector<int> tmp(maxLength + 1);
setArray = tmp;
}
int modify(int x, int y){
setArray[findRoot(x)] = setArray[findRoot(y)];
}
int findRoot(int x) {
return setArray[x] == x ? x : (setArray[x] = findRoot(setArray[x]));
}
} | [
"zzz879978@outlook.com"
] | zzz879978@outlook.com |
42785cedcd6aecd0a0d0ac2a0bf607332012763e | e7df6d41d7e04dc1c4f4ed169bf530a8a89ff17c | /Vendors/tropter/tropter/optimalcontrol/transcription/HermiteSimpson.cpp | 3630a496dc7b31b3d5949d9aea3a2878e2eda3f9 | [
"Apache-2.0"
] | permissive | opensim-org/opensim-core | 2ba11c815df3072166644af2f34770162d8fc467 | aeaaf93b052d598247dd7d7922fdf8f2f2f4c0bb | refs/heads/main | 2023-09-04T05:50:54.783630 | 2023-09-01T22:44:04 | 2023-09-01T22:44:04 | 20,775,600 | 701 | 328 | Apache-2.0 | 2023-09-14T17:45:19 | 2014-06-12T16:57:56 | C++ | UTF-8 | C++ | false | false | 1,068 | cpp | // ----------------------------------------------------------------------------
// tropter: HermiteSimpson.cpp
// ----------------------------------------------------------------------------
// Copyright (c) 2017 tropter authors
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License. You may obtain a
// copy of the License at http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ----------------------------------------------------------------------------
#include "HermiteSimpson.hpp"
namespace tropter {
namespace transcription {
template class HermiteSimpson<double>;
template class HermiteSimpson<adouble>;
} // namespace transcription
} // namespace tropter
| [
"noreply@github.com"
] | noreply@github.com |
7ccfdf65cc0c9d2f545920386ebd5db47c96a0f3 | 862e1c50e51ceee34cfe21a20e234b1922d86166 | /chartfont.cpp | be0a9e0ad96a28db1675a3f8e3c85c68b4655109 | [] | no_license | cooling-technology-institute/UpdatedToolkitC- | c43ef34983b7e2f888551cd1567954470129a8d1 | 9cf4b77cf531cb78faa7c90e3b0d139758cbf309 | refs/heads/master | 2020-06-12T15:22:15.282340 | 2019-06-28T23:50:42 | 2019-06-28T23:50:42 | 194,345,196 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,916 | cpp | // Machine generated IDispatch wrapper class(es) created by Microsoft Visual C++
// NOTE: Do not modify the contents of this file. If this class is regenerated by
// Microsoft Visual C++, your modifications will be overwritten.
#include "stdafx.h"
#include "chartfont.h"
/////////////////////////////////////////////////////////////////////////////
// CChartFont properties
/////////////////////////////////////////////////////////////////////////////
// CChartFont operations
CString CChartFont::GetName()
{
CString result;
InvokeHelper(0x1, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL);
return result;
}
void CChartFont::SetName(LPCTSTR lpszNewValue)
{
static BYTE parms[] =
VTS_BSTR;
InvokeHelper(0x1, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms,
lpszNewValue);
}
long CChartFont::GetSize()
{
long result;
InvokeHelper(0x2, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL);
return result;
}
void CChartFont::SetSize(long nNewValue)
{
static BYTE parms[] =
VTS_I4;
InvokeHelper(0x2, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms,
nNewValue);
}
BOOL CChartFont::GetBold()
{
BOOL result;
InvokeHelper(0x3, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL);
return result;
}
void CChartFont::SetBold(BOOL bNewValue)
{
static BYTE parms[] =
VTS_BOOL;
InvokeHelper(0x3, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms,
bNewValue);
}
BOOL CChartFont::GetItalic()
{
BOOL result;
InvokeHelper(0x4, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL);
return result;
}
void CChartFont::SetItalic(BOOL bNewValue)
{
static BYTE parms[] =
VTS_BOOL;
InvokeHelper(0x4, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms,
bNewValue);
}
BOOL CChartFont::GetUnderline()
{
BOOL result;
InvokeHelper(0x5, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL);
return result;
}
void CChartFont::SetUnderline(BOOL bNewValue)
{
static BYTE parms[] =
VTS_BOOL;
InvokeHelper(0x5, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms,
bNewValue);
}
BOOL CChartFont::GetStrikethrough()
{
BOOL result;
InvokeHelper(0x6, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL);
return result;
}
void CChartFont::SetStrikethrough(BOOL bNewValue)
{
static BYTE parms[] =
VTS_BOOL;
InvokeHelper(0x6, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms,
bNewValue);
}
short CChartFont::GetCharset()
{
short result;
InvokeHelper(0x8, DISPATCH_PROPERTYGET, VT_I2, (void*)&result, NULL);
return result;
}
void CChartFont::SetCharset(short nNewValue)
{
static BYTE parms[] =
VTS_I2;
InvokeHelper(0x8, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms,
nNewValue);
}
unsigned long CChartFont::GetColor()
{
unsigned long result;
InvokeHelper(0x9, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL);
return result;
}
void CChartFont::SetColor(unsigned long newValue)
{
static BYTE parms[] =
VTS_I4;
InvokeHelper(0x9, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms,
newValue);
}
| [
"renee.geoffrion@hpe.com"
] | renee.geoffrion@hpe.com |
73ce5c9fd5bdf31fcce5b39f11a7ae4cdba64c0b | 60c275f5670d8a509421dbe53a704cdf85289035 | /Acmicpc/C++/BOJ11723.cpp | d7a5d1cace79dc0e656d04799121c9fdfff19177 | [
"MIT"
] | permissive | Cutyroach/Solve_Algorithms | f02f03c5ad146550b136e19292a3599b2eff6702 | 97d9f8bb65055fe5ad62d108a9359b91f0f40c49 | refs/heads/master | 2023-03-02T21:27:03.214056 | 2021-02-09T23:58:47 | 2021-02-09T23:58:47 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 952 | cpp | #include <bits/stdc++.h>
using namespace std;
int arr[21];
void sets(string str) {
switch(str[0]) {
case 'a':
for(int i = 1; i < 21; i++) if(!arr[i]) arr[i] = 1;
break;
case 'e':
for (int i = 1; i < 21; i++) if(arr[i]) arr[i] = 0;
break;
}
}
void sets(string str, int n) {
switch(str[0]) {
case 'a':
if(!arr[n]) arr[n] = 1;
break;
case 'r':
if(arr[n]) arr[n] = 0;
break;
case 'c':
cout << (arr[n] ? 1 : 0) << '\n';
break;
case 't':
arr[n] = arr[n]^1;
break;
}
return;
}
int main() {
ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
int t;
for(cin>>t;t--;) {
string str;
cin >> str;
if((str[0] == 'a' && str[1] == 'l') || str[0] == 'e') sets(str);
else {
int n;cin >> n;
sets(str, n);
}
}
return 0;
} | [
"spe0678@gmail.com"
] | spe0678@gmail.com |
ffa21fc3d9a8c72b3a7ec00d865c34591c615720 | d0c44dd3da2ef8c0ff835982a437946cbf4d2940 | /cmake-build-debug/programs_tiling/function14021/function14021_schedule_21/function14021_schedule_21.cpp | 845010e4b983129beffca89e58c6695bd422f934 | [] | no_license | IsraMekki/tiramisu_code_generator | 8b3f1d63cff62ba9f5242c019058d5a3119184a3 | 5a259d8e244af452e5301126683fa4320c2047a3 | refs/heads/master | 2020-04-29T17:27:57.987172 | 2019-04-23T16:50:32 | 2019-04-23T16:50:32 | 176,297,755 | 1 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 1,647 | cpp | #include <tiramisu/tiramisu.h>
using namespace tiramisu;
int main(int argc, char **argv){
tiramisu::init("function14021_schedule_21");
constant c0("c0", 128), c1("c1", 1024), c2("c2", 256);
var i0("i0", 0, c0), i1("i1", 0, c1), i2("i2", 0, c2), i01("i01"), i02("i02"), i03("i03"), i04("i04"), i05("i05"), i06("i06");
input input00("input00", {i1}, p_int32);
input input01("input01", {i0, i2}, p_int32);
input input02("input02", {i0}, p_int32);
input input03("input03", {i1}, p_int32);
input input04("input04", {i1, i2}, p_int32);
input input05("input05", {i0}, p_int32);
computation comp0("comp0", {i0, i1, i2}, input00(i1) + input01(i0, i2) + input02(i0) * input03(i1) + input04(i1, i2) * input05(i0));
comp0.tile(i0, i1, i2, 32, 64, 32, i01, i02, i03, i04, i05, i06);
comp0.parallelize(i01);
buffer buf00("buf00", {1024}, p_int32, a_input);
buffer buf01("buf01", {128, 256}, p_int32, a_input);
buffer buf02("buf02", {128}, p_int32, a_input);
buffer buf03("buf03", {1024}, p_int32, a_input);
buffer buf04("buf04", {1024, 256}, p_int32, a_input);
buffer buf05("buf05", {128}, p_int32, a_input);
buffer buf0("buf0", {128, 1024, 256}, p_int32, a_output);
input00.store_in(&buf00);
input01.store_in(&buf01);
input02.store_in(&buf02);
input03.store_in(&buf03);
input04.store_in(&buf04);
input05.store_in(&buf05);
comp0.store_in(&buf0);
tiramisu::codegen({&buf00, &buf01, &buf02, &buf03, &buf04, &buf05, &buf0}, "../data/programs/function14021/function14021_schedule_21/function14021_schedule_21.o");
return 0;
} | [
"ei_mekki@esi.dz"
] | ei_mekki@esi.dz |
9379b3fea38f4a90b3face225d39a3edf4e241ad | acc2f5336d768a7d86dbd2eec441283cfd11d52d | /src/Core/GCSkillToTileOK6.h | b6e5300de2b24e82e0bf31ad4e9ee2d7780b992b | [] | no_license | stevexk/server | 86df9e8c2448ad97db9c3ab86820beec507ef092 | 4ddb6e7cfa510bb13ccd87f56db008aa1be1baad | refs/heads/master | 2020-01-23T22:00:57.359964 | 2015-09-18T14:58:27 | 2015-09-18T14:58:27 | null | 0 | 0 | null | null | null | null | UHC | C++ | false | false | 5,026 | h | //////////////////////////////////////////////////////////////////////
//
// Filename : GCSkillToTileOK6.h
// Written By : elca@ewestsoft.com
// Description : 기술에 당했는데 사용자는 볼 수 없는 자가 받는 packet
//////////////////////////////////////////////////////////////////////
#ifndef __GC_SKILL_TO_TILE_OK_6_H__
#define __GC_SKILL_TO_TILE_OK_6_H__
// include files
#include "Types.h"
#include "Exception.h"
#include "ModifyInfo.h"
#include "PacketFactory.h"
//////////////////////////////////////////////////////////////////////
//
// class GCSkillToTileOK6;
//
//
//////////////////////////////////////////////////////////////////////
class GCSkillToTileOK6 : public ModifyInfo {
public :
// constructor
GCSkillToTileOK6() throw();
// destructor
~GCSkillToTileOK6() throw();
public :
// 입력스트림(버퍼)으로부터 데이타를 읽어서 패킷을 초기화한다.
void read(SocketInputStream & iStream) throw(ProtocolException, Error);
// 출력스트림(버퍼)으로 패킷의 바이너리 이미지를 보낸다.
void write(SocketOutputStream & oStream) const throw(ProtocolException, Error);
// execute packet's handler
void execute(Player* pPlayer) throw(ProtocolException, Error);
// get packet id
PacketID_t getPacketID() const throw() { return PACKET_GC_SKILL_TO_TILE_OK_6; }
// get packet's body size
// 최적화시, 미리 계산된 정수를 사용한다.
PacketSize_t getPacketSize() const throw() { return szCoord*2 + szSkillType + szCoord*2 + szRange + szDuration +
szBYTE + szObjectID* m_CListNum + szBYTE + ModifyInfo::getPacketSize(); }
//CListNum, SListNum, ListEle* CListNum, ListEle* SListNum* 2
// get packet's name
string getPacketName() const throw() { return "GCSkillToTileOK6"; }
// get packet's debug string
string toString() const throw();
// get orign x, y
Coord_t getOrgX() const throw() { return m_OrgX;}
Coord_t getOrgY() const throw() { return m_OrgY;}
// set origin x, y
void setOrgXY(Coord_t X, Coord_t Y) throw() { m_OrgX = X; m_OrgY = Y;}
// get / set SkillType
SkillType_t getSkillType() const throw() { return m_SkillType; }
void setSkillType(SkillType_t SkillType) throw() { m_SkillType = SkillType; }
// get / set X
Coord_t getX() const throw() { return m_X; }
void setX(Coord_t X) throw() { m_X = X; }
// get / set Y
Coord_t getY() const throw() { return m_Y; }
void setY(Coord_t Y) throw() { m_Y = Y; }
// get / set Range
Range_t getRange() const throw() { return m_Range; }
void setRange(Range_t r) throw() { m_Range = r; }
// get / set Duration
Duration_t getDuration() const throw() { return m_Duration; }
void setDuration(Duration_t Duration) throw() { m_Duration = Duration; }
// get / set Creature List Number
BYTE getCListNum() const throw() { return m_CListNum; }
void setCListNum(BYTE CListNum) throw() { m_CListNum = CListNum; }
// add / delete Creature List
void addCListElement(ObjectID_t ObjectID) throw();
// Clear Creature List
void clearCList() throw() { m_CList.clear(); m_CListNum = 0; }
// pop front Element in Status List
ObjectID_t popCListElement() throw() { ObjectID_t CreatureList = m_CList.front(); m_CList.pop_front(); return CreatureList; }
BYTE getGrade() const throw() { return m_Grade; }
void setGrade(BYTE grade ) throw() { m_Grade = grade; }
private :
// ObjectID
Coord_t m_OrgX, m_OrgY; // 기술 사용자의 위치.
// SkillType
SkillType_t m_SkillType;
// X, Y
Coord_t m_X;
Coord_t m_Y;
// Range
Range_t m_Range;
// Duration
Duration_t m_Duration;
// Creature List Num
BYTE m_CListNum;
// Creature List
list<ObjectID_t> m_CList;
BYTE m_Grade;
};
//////////////////////////////////////////////////////////////////////
//
// class GCSkillToTileOK6Factory;
//
// Factory for GCSkillToTileOK6
//
//////////////////////////////////////////////////////////////////////
class GCSkillToTileOK6Factory : public PacketFactory {
public :
// constructor
GCSkillToTileOK6Factory() throw() {}
// destructor
virtual ~GCSkillToTileOK6Factory() throw() {}
public :
// create packet
Packet* createPacket() throw() { return new GCSkillToTileOK6(); }
// get packet name
string getPacketName() const throw() { return "GCSkillToTileOK6"; }
// get packet id
PacketID_t getPacketID() const throw() { return Packet::PACKET_GC_SKILL_TO_TILE_OK_6; }
// get Pakcet Max Size
PacketSize_t getPacketMaxSize() const throw() { return szCoord*2 + szSkillType + szCoord*2 + szRange + szDuration +
szBYTE + szWORD + szObjectID + szBYTE + ModifyInfo::getPacketMaxSize(); }
};
//////////////////////////////////////////////////////////////////////
//
// class GCSkillToTileOK6Handler;
//
//////////////////////////////////////////////////////////////////////
class GCSkillToTileOK6Handler {
public :
// execute packet's handler
static void execute(GCSkillToTileOK6* pGCSkillToTileOK6, Player* pPlayer) throw(Error);
};
#endif
| [
"tiancaiamao@gmail.com"
] | tiancaiamao@gmail.com |
9a29360e8527f5653b1b3fd44aefdb7b05630cc9 | a53fc969c4e4838b338ac978e1e06d96c9a5ef7f | /src/components/transport_manager/src/bluetooth/bluetooth_device_win.cc | 0c29069e40f4d6f7f619d514cabb3e4269f11a42 | [] | no_license | LuxoftSDL/sdl_core_winport | 8dbe4ccca656469f9193c92fdfa871d577639b15 | d7a522bf71b6daf76f4fa9e5d8c7e4a7087ffbc1 | refs/heads/develop | 2016-08-12T18:08:20.570661 | 2016-04-07T07:23:32 | 2016-04-07T07:23:32 | 44,124,645 | 2 | 10 | null | 2016-06-06T09:43:51 | 2015-10-12T17:59:45 | C++ | UTF-8 | C++ | false | false | 4,652 | cc | /*
*
* Copyright (c) 2016, Ford Motor Company
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following
* disclaimer in the documentation and/or other materials provided with the
* distribution.
*
* Neither the name of the Ford Motor Company nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include "transport_manager/bluetooth/bluetooth_device.h"
#include "utils/bluetooth_win/bluetooth_utils.h"
#include <errno.h>
#include <sys/types.h>
#include <algorithm>
#include <limits>
#include "utils/logger.h"
namespace transport_manager {
namespace transport_adapter {
CREATE_LOGGERPTR_GLOBAL(logger_, "TransportManager")
bool BluetoothDevice::GetRfcommChannel(const ApplicationHandle app_handle,
uint8_t* channel_out) {
LOGGER_TRACE(logger_,
"enter. app_handle: " << app_handle
<< ", channel_out: " << channel_out);
if (app_handle < 0 || app_handle > std::numeric_limits<uint8_t>::max()) {
LOGGER_TRACE(logger_,
"exit with FALSE. Condition: app_handle < 0 || app_handle > "
"numeric_limits::max()");
return false;
}
const uint8_t channel = static_cast<uint8_t>(app_handle);
RfcommChannelVector::const_iterator it =
std::find(rfcomm_channels_.begin(), rfcomm_channels_.end(), channel);
if (it == rfcomm_channels_.end()) {
LOGGER_TRACE(
logger_,
"exit with FALSE. Condition: channel not found in RfcommChannelVector");
return false;
}
*channel_out = channel;
LOGGER_TRACE(logger_, "exit with TRUE");
return true;
}
std::string BluetoothDevice::GetUniqueDeviceId(
const BLUETOOTH_ADDR_INFO& device_address) {
LOGGER_TRACE(
logger_,
"enter. device_adress: " << utils::BthDeviceAddrToStr(device_address));
char device_address_string[32];
sprintf(device_address_string, "%ws", device_address.szName);
LOGGER_TRACE(logger_, "exit with BT-" << device_address_string);
return std::string("BT-") + device_address_string;
}
BluetoothDevice::BluetoothDevice(const BLUETOOTH_ADDR_INFO& device_address,
const char* device_name,
const RfcommChannelVector& rfcomm_channels,
const SOCKADDR_BTH& sock_addr_bth_server)
: Device(device_name, GetUniqueDeviceId(device_address))
, address_(device_address)
, rfcomm_channels_(rfcomm_channels)
, sock_addr_bth_server_(sock_addr_bth_server) {}
bool BluetoothDevice::IsSameAs(const Device* other) const {
LOGGER_TRACE(logger_, "enter. device: " << other);
bool result = false;
const BluetoothDevice* other_bluetooth_device =
dynamic_cast<const BluetoothDevice*>(other);
if (0 != other_bluetooth_device) {
if (0 == memcmp(&address_,
&other_bluetooth_device->address_,
sizeof(BTH_ADDR))) {
result = true;
}
}
if (result) {
LOGGER_TRACE(logger_, "exit with TRUE");
} else {
LOGGER_TRACE(logger_, "exit with FALSE");
}
return result;
}
SOCKADDR_BTH BluetoothDevice::getSocketBthAddr() {
return sock_addr_bth_server_;
}
ApplicationList BluetoothDevice::GetApplicationList() const {
return ApplicationList(rfcomm_channels_.begin(), rfcomm_channels_.end());
}
} // namespace transport_adapter
} // namespace transport_manager
| [
"OKrotenko@kiev.luxoft.com"
] | OKrotenko@kiev.luxoft.com |
5138538944c1c0b4e230a5a1000153b371607184 | b376715a5532a6babea6717073acd71972282947 | /source/PXXSimulationDataGenerator.cpp | c6fdf81e46ce4dc9bc79d318b3476047986e9475 | [] | no_license | hexfet/PXXAnalyzer | 78879d659674ca634749a27d4595f454095080a7 | 6ce4d758d65e53233981b04b3920030ef3f90156 | refs/heads/master | 2020-04-07T10:51:58.505643 | 2018-12-07T01:08:04 | 2018-12-07T01:08:04 | 158,303,218 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,618 | cpp | #include "PXXSimulationDataGenerator.h"
#include "PXXAnalyzerSettings.h"
#include <AnalyzerHelpers.h>
PXXSimulationDataGenerator::PXXSimulationDataGenerator()
: mPXXData{ 0x7E,0x0A,0x00,0x00,0xF9,0x73,0x3F,0x2D,0xB1,0x40,
0xEF,0x06,0x40,0x00,0x74,0x3F,0x18,0x12,0x7E,0x7E },
mStringIndex( 0 ),
mSimulationSampleRateHz( 0 ),
mSettings( 0 )
{
}
PXXSimulationDataGenerator::~PXXSimulationDataGenerator()
{
}
void PXXSimulationDataGenerator::Initialize( U32 simulation_sample_rate, PXXAnalyzerSettings* settings )
{
mSimulationSampleRateHz = simulation_sample_rate;
mSettings = settings;
mPXXSimulationData.SetChannel( mSettings->mInputChannel );
mPXXSimulationData.SetSampleRate( simulation_sample_rate );
mPXXSimulationData.SetInitialBitState( BIT_HIGH );
mPXXSimulationData.Advance(mSimulationSampleRateHz / 1000000 * 16);
}
U32 PXXSimulationDataGenerator::GenerateSimulationData( U64 largest_sample_requested, U32 sample_rate, SimulationChannelDescriptor** simulation_channel )
{
U64 adjusted_largest_sample_requested = AnalyzerHelpers::AdjustSimulationTargetSample( largest_sample_requested, sample_rate, mSimulationSampleRateHz );
U8 ones_count = 0;
adjusted_largest_sample_requested -= 10000;
while( mPXXSimulationData.GetCurrentSampleNumber() < adjusted_largest_sample_requested )
{
ones_count = CreatePXXByte(ones_count);
}
*simulation_channel = &mPXXSimulationData;
return 1;
}
U8 PXXSimulationDataGenerator::CreatePXXByte(U8 ones_count)
{
U32 samples_per_third = mSimulationSampleRateHz / 1000000 * 8;
U8 byte = mPXXData[ mStringIndex ];
U8 mask = 1 << 7;
for( U32 i=0; i<8; i++ )
{
mPXXSimulationData.Advance(samples_per_third); // start third - 8us high
mPXXSimulationData.Transition();
mPXXSimulationData.Advance(samples_per_third); // always 8us low
if (byte & mask) {
mPXXSimulationData.Advance(samples_per_third); // another 8us low for a 1
if (++ones_count == 5) { // stuff a 0
mPXXSimulationData.Transition();
mPXXSimulationData.Advance(samples_per_third); // start third - 8us high
mPXXSimulationData.Transition();
mPXXSimulationData.Advance(samples_per_third); // always 8us low
ones_count = 0;
}
}
else {
ones_count = 0;
}
// THIS REQUIRED STATEMENT CAUSES CRASH, DON'T KNOW WHY
//mPXXSimulationData.Transition();
mask = mask >> 1;
}
mStringIndex++;
if (mStringIndex == 20) {
mStringIndex = 0;
mPXXSimulationData.Advance(50 * samples_per_third);
}
mPXXSimulationData.TransitionIfNeeded( BIT_HIGH );
return ones_count;
}
| [
"jpublic123@yahoo.com"
] | jpublic123@yahoo.com |
ee56112a13f0ee0df8cf8b53fa968f8b832964f7 | a1c334e463c05844880efcf229c6f1f1e8520784 | /PDollarForCpp/PDollarForCpp.cpp | 51b908b42d584e976f04940a087ded7a13338367 | [] | no_license | nizihabi/PDollarForCpp | 10854da855da46880627dcbae582b6941229e276 | 2f9d044ea1e7932b7b917b3faadb85e64bc34146 | refs/heads/master | 2021-01-01T15:50:16.569942 | 2015-09-21T06:53:34 | 2015-09-21T06:53:34 | 42,840,591 | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 2,057 | cpp | // PDollarForCpp.cpp : 定义 DLL 应用程序的导出函数。
//
#include "stdafx.h"
#include "Headers\PDollarForCpp.h"
#include "Headers\Geometry.h"
Gesture *createGesture(vector<Point *> point, string gestureName)
{
return new Gesture(point, gestureName);
}
string classify(Gesture *gesture, vector<Gesture *> gestureSet)
{
double minDistance = DBL_MAX;
string gestureClass = "";
for (int i = 0; i < gestureSet.size(); i++)
{
double dist = cloudMatch(gesture->m_Points, gestureSet[i]->m_Points);
if (minDistance > dist)
{
minDistance = dist;
gestureClass = gestureSet[i]->m_Name;
}
}
return gestureClass;
}
double cloudMatch(vector<Point *> points1, vector<Point *> points2)
{
int n = points1.size(); //此时points1 和 points2 有着一样的点数
double eps = 0.5f;
int step = (int)(floor(pow(n, 1 - eps)));
double minDistance = DBL_MAX;
for (int i = 0; i < n; i+= step)
{
double dist1 = cloudDistance(points1, points2,i);
double dist2 = cloudDistance(points2, points1,i);
minDistance = min(minDistance, min(dist1, dist2));
}
return minDistance;
}
double cloudDistance(vector<Point *> points1, vector<Point *> points2, int startIndex)
{
int n = points1.size();
vector<bool> match(n);
match.clear();
double sum = 0; // computes the sum of distances between matched points (i.e., the distance between the two clouds)
int i = startIndex;
do
{
int index = -1;
double minDistance = DBL_MAX;
for (int j = 0; j < n; j++)
if (!match[j])
{
float dist = Geometry::SqrEuclideanDistance(points1[i], points2[j]); // use squared Euclidean distance to save some processing time
if (dist < minDistance)
{
minDistance = dist;
index = j;
}
}
match[index] = true; // point index from the 2nd cloud is matched to point i from the 1st cloud
double weight = 1 - ((i - startIndex + n) % n) / (1 * n);
sum += weight * minDistance; // weight each distance with a confidence coefficient that decreases from 1 to 0
i = (i + 1) % n;
} while (i != startIndex);
return sum;
}
| [
"nizihabi@qq.com"
] | nizihabi@qq.com |
94ced2b79abad0a98f280e762aecb947640ef95d | ecd252c3ca60df77e58b84870c403b2f5e4aec59 | /src/windows/libraries/ws2_32/functions/gethostbyname.cc | ea7ff3578f2a51f8d455791dad8f9a3b4c7ff0fc | [
"Apache-2.0"
] | permissive | srpape/IntroVirt | ffe81b7ed24029ee54acdd7702a7a20921ec8f3f | fe553221c40b8ef71f06e79c9d54d9e123a06c89 | refs/heads/main | 2022-07-29T02:34:20.216930 | 2021-03-19T23:10:38 | 2021-03-19T23:14:41 | 344,861,919 | 0 | 0 | Apache-2.0 | 2021-03-05T16:02:50 | 2021-03-05T16:02:50 | null | UTF-8 | C++ | false | false | 2,077 | cc | /*
* Copyright 2021 Assured Information Security, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <introvirt/windows/libraries/ws2_32/functions/gethostbyname.hh>
#include <boost/io/ios_state.hpp>
namespace introvirt {
namespace windows {
namespace ws2_32 {
/* Input arguments */
GuestVirtualAddress gethostbyname::pName() const { return pName_; }
void gethostbyname::pName(const GuestVirtualAddress& gva) {
set_address_argument(0, gva);
pName_ = gva;
}
/* Helpers */
std::string gethostbyname::name() const {
if (!pName_)
return std::string();
auto mapping = map_guest_cstr(pName_);
return std::string(mapping.get(), mapping.length());
}
GuestVirtualAddress gethostbyname::result_address() const {
return GuestVirtualAddress(raw_return_value());
}
std::unique_ptr<HOSTENT> gethostbyname::result() const {
GuestVirtualAddress pResult(result_address());
std::unique_ptr<HOSTENT> result;
if (pResult) {
result = HOSTENT::make_unique(pResult, x64());
}
return result;
}
const std::string& gethostbyname::function_name() const { return FunctionName; }
const std::string& gethostbyname::library_name() const { return LibraryName; }
void gethostbyname::write(std::ostream& os) const {
boost::io::ios_flags_saver ifs(os);
// TODO
}
gethostbyname::gethostbyname(Event& event) : WindowsFunctionCall(event, ArgumentCount) {
pName_ = get_address_argument(0);
}
gethostbyname::~gethostbyname() = default;
} // namespace ws2_32
} // namespace windows
} // namespace introvirt | [
"srpape@gmail.com"
] | srpape@gmail.com |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.