hexsha
stringlengths 40
40
| size
int64 7
1.05M
| ext
stringclasses 13
values | lang
stringclasses 1
value | max_stars_repo_path
stringlengths 4
269
| max_stars_repo_name
stringlengths 5
109
| max_stars_repo_head_hexsha
stringlengths 40
40
| max_stars_repo_licenses
listlengths 1
9
| max_stars_count
int64 1
191k
⌀ | max_stars_repo_stars_event_min_datetime
stringlengths 24
24
⌀ | max_stars_repo_stars_event_max_datetime
stringlengths 24
24
⌀ | max_issues_repo_path
stringlengths 4
269
| max_issues_repo_name
stringlengths 5
116
| max_issues_repo_head_hexsha
stringlengths 40
40
| max_issues_repo_licenses
listlengths 1
9
| max_issues_count
int64 1
48.5k
⌀ | max_issues_repo_issues_event_min_datetime
stringlengths 24
24
⌀ | max_issues_repo_issues_event_max_datetime
stringlengths 24
24
⌀ | max_forks_repo_path
stringlengths 4
269
| max_forks_repo_name
stringlengths 5
116
| max_forks_repo_head_hexsha
stringlengths 40
40
| max_forks_repo_licenses
listlengths 1
9
| max_forks_count
int64 1
105k
⌀ | max_forks_repo_forks_event_min_datetime
stringlengths 24
24
⌀ | max_forks_repo_forks_event_max_datetime
stringlengths 24
24
⌀ | content
stringlengths 7
1.05M
| avg_line_length
float64 1.21
330k
| max_line_length
int64 6
990k
| alphanum_fraction
float64 0.01
0.99
| author_id
stringlengths 2
40
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
03900391b39ebbac190e8d503c4f16e1759061c9
| 1,127
|
cpp
|
C++
|
LinkedList/27 Flatten a Linked List.cpp
|
i-am-grut/LoveBabbar-450-Questions
|
08faaa70198363c6ac481a67c548e1e7e4c7c591
|
[
"MIT"
] | 2
|
2021-06-25T07:26:23.000Z
|
2022-01-28T22:24:34.000Z
|
LinkedList/27 Flatten a Linked List.cpp
|
i-am-grut/LoveBabbar-450-Questions
|
08faaa70198363c6ac481a67c548e1e7e4c7c591
|
[
"MIT"
] | null | null | null |
LinkedList/27 Flatten a Linked List.cpp
|
i-am-grut/LoveBabbar-450-Questions
|
08faaa70198363c6ac481a67c548e1e7e4c7c591
|
[
"MIT"
] | null | null | null |
Node* merge(Node* head1, Node* head2){
if(head1==NULL){
return head2;
}
if(head2==NULL){
return head1;
}
Node* head;
Node* tail;
if(head1->data<head2->data){
head=head1;
head1=head1->bottom;
}
else{
head=head2;
head2=head2->bottom;
}
tail=head;
while(head1!=NULL && head2!=NULL){
if(head1->data<head2->data){
tail->bottom=head1;
head1=head1->bottom;
}
else{
tail->bottom=head2;
head2=head2->bottom;
}
tail=tail->bottom;
}
while(head1!=NULL){
tail->bottom=head1;
head1=head1->bottom;
tail=tail->bottom;
}
while(head2!=NULL){
tail->bottom=head2;
head2=head2->bottom;
tail=tail->bottom;
}
return head;
}
/* Function which returns the root of
the flattened linked list. */
Node *flatten(Node *root)
{
if(root==NULL || root->next==NULL){
return root;
}
root->next=flatten(root->next);
//Merge
root=merge(root,root->next);
return root;
}
| 20.490909
| 40
| 0.515528
|
i-am-grut
|
0393fe9403b7546e128cac1e9ab9542942c930c0
| 814
|
cpp
|
C++
|
source/GUIEventHandler.cpp
|
mackron/GTGameEngine
|
380d1e01774fe6bc2940979e4e5983deef0bf082
|
[
"BSD-3-Clause"
] | 31
|
2015-03-19T08:44:48.000Z
|
2021-12-15T20:52:31.000Z
|
source/GUIEventHandler.cpp
|
mackron/GTGameEngine
|
380d1e01774fe6bc2940979e4e5983deef0bf082
|
[
"BSD-3-Clause"
] | 19
|
2015-07-09T09:02:44.000Z
|
2016-06-09T03:51:03.000Z
|
source/GUIEventHandler.cpp
|
mackron/GTGameEngine
|
380d1e01774fe6bc2940979e4e5983deef0bf082
|
[
"BSD-3-Clause"
] | 3
|
2017-10-04T23:38:18.000Z
|
2022-03-07T08:27:13.000Z
|
// Copyright (C) 2011 - 2014 David Reid. See included LICENCE.
#include <GTGE/GUIEventHandler.hpp>
#include <GTGE/GTEngine.hpp>
namespace GT
{
GUIEventHandler::GUIEventHandler(Context &context)
: context(context)
{
}
GUIEventHandler::~GUIEventHandler()
{
}
void GUIEventHandler::OnError(const char* msg)
{
g_Context->LogErrorf("%s", msg);
}
void GUIEventHandler::OnWarning(const char* msg)
{
g_Context->Logf("%s", msg);
}
void GUIEventHandler::OnLog(const char* msg)
{
g_Context->Logf("%s", msg);
}
void GUIEventHandler::OnChangeCursor(Cursor cursor)
{
if (cursor != Cursor_None)
{
context.GetWindow()->SetCursor(cursor);
}
}
}
| 20.35
| 63
| 0.565111
|
mackron
|
03949325044207fb77e58a6a962d4325237da81e
| 6,311
|
cpp
|
C++
|
ibtk/src/solvers/interfaces/GeneralOperator.cpp
|
MSV-Project/IBAMR
|
3cf614c31bb3c94e2620f165ba967cba719c45ea
|
[
"BSD-3-Clause"
] | 2
|
2017-12-06T06:16:36.000Z
|
2021-03-13T12:28:08.000Z
|
ibtk/src/solvers/interfaces/GeneralOperator.cpp
|
MSV-Project/IBAMR
|
3cf614c31bb3c94e2620f165ba967cba719c45ea
|
[
"BSD-3-Clause"
] | null | null | null |
ibtk/src/solvers/interfaces/GeneralOperator.cpp
|
MSV-Project/IBAMR
|
3cf614c31bb3c94e2620f165ba967cba719c45ea
|
[
"BSD-3-Clause"
] | null | null | null |
// Filename: GeneralOperator.cpp
// Created on 18 Nov 2003 by Boyce Griffith
//
// Copyright (c) 2002-2013, Boyce Griffith
// 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 New York University 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.
/////////////////////////////// INCLUDES /////////////////////////////////////
#include <stddef.h>
#include <limits>
#include <ostream>
#include "GeneralOperator.h"
#include "SAMRAIVectorReal.h"
#include "ibtk/namespaces.h" // IWYU pragma: keep
/////////////////////////////// NAMESPACE ////////////////////////////////////
namespace IBTK
{
/////////////////////////////// STATIC ///////////////////////////////////////
/////////////////////////////// PUBLIC ///////////////////////////////////////
GeneralOperator::GeneralOperator(
const std::string& object_name,
bool homogeneous_bc)
: d_object_name(object_name),
d_is_initialized(false),
d_homogeneous_bc(homogeneous_bc),
d_solution_time(std::numeric_limits<double>::quiet_NaN()),
d_current_time(std::numeric_limits<double>::quiet_NaN()),
d_new_time(std::numeric_limits<double>::quiet_NaN()),
d_hier_math_ops(NULL),
d_hier_math_ops_external(false),
d_enable_logging(false)
{
// intentionally blank
return;
}// GeneralOperator()
GeneralOperator::~GeneralOperator()
{
deallocateOperatorState();
return;
}// ~GeneralOperator()
const std::string&
GeneralOperator::getName() const
{
return d_object_name;
}// getName
bool
GeneralOperator::getIsInitialized() const
{
return d_is_initialized;
}// getIsInitialized
void
GeneralOperator::setHomogeneousBc(
bool homogeneous_bc)
{
d_homogeneous_bc = homogeneous_bc;
return;
}// setHomogeneousBc
bool
GeneralOperator::getHomogeneousBc() const
{
return d_homogeneous_bc;
}// getHomogeneousBc
void
GeneralOperator::setSolutionTime(
double solution_time)
{
d_solution_time = solution_time;
return;
}// setSolutionTime
double
GeneralOperator::getSolutionTime() const
{
return d_solution_time;
}// getSolutionTime
void
GeneralOperator::setTimeInterval(
double current_time,
double new_time)
{
d_current_time = current_time;
d_new_time = new_time;
return;
}// setTimeInterval
std::pair<double,double>
GeneralOperator::getTimeInterval() const
{
return std::make_pair(d_current_time,d_new_time);
}// getTimeInterval
double
GeneralOperator::getDt() const
{
return d_new_time-d_current_time;
}// getDt
void
GeneralOperator::setHierarchyMathOps(
Pointer<HierarchyMathOps> hier_math_ops)
{
d_hier_math_ops = hier_math_ops;
d_hier_math_ops_external = d_hier_math_ops;
return;
}// setHierarchyMathOps
Pointer<HierarchyMathOps>
GeneralOperator::getHierarchyMathOps() const
{
return d_hier_math_ops;
}// getHierarchyMathOps
void
GeneralOperator::applyAdd(
SAMRAIVectorReal<NDIM,double>& x,
SAMRAIVectorReal<NDIM,double>& y,
SAMRAIVectorReal<NDIM,double>& z)
{
// Guard against the case that y == z.
Pointer<SAMRAIVectorReal<NDIM,double> > zz = z.cloneVector(z.getName());
zz->allocateVectorData();
zz->copyVector(Pointer<SAMRAIVectorReal<NDIM,double> >(&z,false));
apply(x,*zz);
z.add(Pointer<SAMRAIVectorReal<NDIM,double> >(&y,false),zz);
zz->freeVectorComponents();
zz.setNull();
return;
}// applyAdd
void
GeneralOperator::initializeOperatorState(
const SAMRAIVectorReal<NDIM,double>& /*in*/,
const SAMRAIVectorReal<NDIM,double>& /*out*/)
{
d_is_initialized = true;
return;
}// initializeOperatorState
void
GeneralOperator::deallocateOperatorState()
{
d_is_initialized = false;
return;
}// deallocateOperatorState
void
GeneralOperator::setLoggingEnabled(
bool enable_logging)
{
d_enable_logging = enable_logging;
return;
}// setLoggingEnabled
bool
GeneralOperator::getLoggingEnabled() const
{
return d_enable_logging;
}// getLoggingEnabled
void
GeneralOperator::printClassData(
std::ostream& stream)
{
stream << "\n"
<< "object_name = " << d_object_name << "\n"
<< "is_initialized = " << d_is_initialized << "\n"
<< "homogeneous_bc = " << d_homogeneous_bc << "\n"
<< "solution_time = " << d_solution_time << "\n"
<< "current_time = " << d_current_time << "\n"
<< "new_time = " << d_new_time << "\n"
<< "hier_math_ops = " << d_hier_math_ops.getPointer() << "\n"
<< "hier_math_ops_external = " << d_hier_math_ops_external << "\n"
<< "enable_logging = " << d_enable_logging << "\n";
return;
}// printClassData
/////////////////////////////// PRIVATE //////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
}// namespace IBTK
//////////////////////////////////////////////////////////////////////////////
| 28.427928
| 78
| 0.658533
|
MSV-Project
|
039f817ea9d050bc3e500b111467d3d27f79882a
| 19
|
cpp
|
C++
|
Direct2DNet/GUIDs.cpp
|
SansyHuman/Direct2DNet
|
345d981a07fd8cbdf7cf7e6ca9d7b493439dbd17
|
[
"MIT"
] | null | null | null |
Direct2DNet/GUIDs.cpp
|
SansyHuman/Direct2DNet
|
345d981a07fd8cbdf7cf7e6ca9d7b493439dbd17
|
[
"MIT"
] | null | null | null |
Direct2DNet/GUIDs.cpp
|
SansyHuman/Direct2DNet
|
345d981a07fd8cbdf7cf7e6ca9d7b493439dbd17
|
[
"MIT"
] | null | null | null |
#include "GUIDs.h"
| 9.5
| 18
| 0.684211
|
SansyHuman
|
03a280593c4e17359e982b44a061bdc4ee8562ed
| 860
|
cpp
|
C++
|
Dynamic Programming/Edit Distance.cpp
|
razouq/cses
|
82534f4ac37a690b5cd72ab094d5276bd01dd64e
|
[
"MIT"
] | 3
|
2021-03-14T18:47:13.000Z
|
2021-03-19T09:59:56.000Z
|
Dynamic Programming/Edit Distance.cpp
|
razouq/cses
|
82534f4ac37a690b5cd72ab094d5276bd01dd64e
|
[
"MIT"
] | null | null | null |
Dynamic Programming/Edit Distance.cpp
|
razouq/cses
|
82534f4ac37a690b5cd72ab094d5276bd01dd64e
|
[
"MIT"
] | null | null | null |
#include "bits/stdc++.h"
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#define ll long long
#define ull unsigned long long
#define F first
#define S second
#define PB push_back
#define POB pop_back
using namespace std;
int main(){
// freopen("input.in", "r", stdin);
// freopen("output.out", "w", stdout);
ios::sync_with_stdio(0);
cin.tie();
string a, b;
cin>>a>>b;
if(a.size() < b.size()) swap(a, b);
int n = a.size();
int m = b.size();
vector<vector<int>> mat(n+1, vector<int> (m+1, 0));
for(int i = 0; i <= n; i++) mat[i][0] = i;
for(int i = 0; i <= m; i++) mat[0][i] = i;
for(int i = 1; i <= n; i++) {
for(int j = 1; j <= m; j++) {
int diff = (a[i-1] != b[j-1]);
mat[i][j] = min(mat[i-1][j] + 1, mat[i][j-1] + 1);
mat[i][j] = min(mat[i][j], mat[i-1][j-1] + diff);
}
}
cout<<mat[n][m]<<endl;
return 0;
}
| 20
| 53
| 0.537209
|
razouq
|
03a63668aad34b79c614e7504a8601cee18e6fbc
| 4,172
|
cpp
|
C++
|
Step1/skip_list/calcSimilaritySL.cpp
|
ediston/Link-Clustering-Algorithm
|
e93a4b92f50bedae75c779937b5242d487075043
|
[
"Unlicense"
] | 2
|
2015-05-20T09:05:30.000Z
|
2017-11-08T09:23:54.000Z
|
Step1/skip_list/calcSimilaritySL.cpp
|
ediston/Link-Clustering-Algorithm
|
e93a4b92f50bedae75c779937b5242d487075043
|
[
"Unlicense"
] | null | null | null |
Step1/skip_list/calcSimilaritySL.cpp
|
ediston/Link-Clustering-Algorithm
|
e93a4b92f50bedae75c779937b5242d487075043
|
[
"Unlicense"
] | null | null | null |
#include <bits/stdc++.h>
#include <ctime>
using namespace std;
#define MAX_HIEGHT 32
#define ONEIN 2
#define INFINITY 99999999
//long long totalComparisons;
int getRandom(){
return rand() % ONEIN;
}
struct node{
long long nodeId;
node *next;
node *below;
};
struct skipList{
int height;
long long listId;
long long length;
node **head;
};
node *getNewNode(long long nodeId){
node * newnode = new node;
newnode->nodeId = nodeId;
newnode->next = NULL;
newnode->below = NULL;
return newnode;
}
skipList *getNewSkipList(){
skipList * newSkipList = new skipList;
newSkipList->height = 0;
// head has the maximum height
newSkipList->head = new node*[MAX_HIEGHT];
for(int i=0; i<MAX_HIEGHT; i++){
newSkipList->head[i] = getNewNode(-INFINITY);
if(i==0)
newSkipList->head[i]->below = NULL;
else
newSkipList->head[i]->below = newSkipList->head[i-1];
}
newSkipList->length = 0;
return newSkipList;
}
void printSkipList(skipList *s){
if(!s) return;
cout << "Skiplist #" << s->listId << endl;
node *current = getNewNode(0);
for(int lvl = s->height-1; lvl>= 0; lvl-- ){
cout << "Height " << lvl << ": ";
current = s->head[lvl];
while(current){
cout << " - " << current->nodeId ;
current = current->next;
}
cout << endl;
}
cout << endl;
}
void addNode(skipList *s, long long newNodeId){
// first we decide the height of the new node
// height = level+1
int newNodeLevel = 0, level ;
for(;getRandom() >= 1 ; newNodeLevel++) {
if(newNodeLevel==MAX_HIEGHT-1) {
break;
}
}
// change the height of the skiplist if needed
if(newNodeLevel+1 > s->height){
s->height = newNodeLevel+1;
}
node *prev = getNewNode(0); ;
node *current = getNewNode(0);
prev = NULL;
// start from max height of the skip list
level = s->height-1;
current = s->head[level];
// A good video explaining the insertion
// https://www.youtube.com/watch?v=Dx7Hk8-8Kdw
// Loop while we go through all levels
while(current){
// This will help us reach the appropriate node already
while(current->next && current->next->nodeId < newNodeId){
current = current->next;
}
// if this level is greater than new level
// then we add the a new node to next of current
if(level <= newNodeLevel){
node *newNode = getNewNode(newNodeId);
if(prev){
prev->below = newNode;
}
newNode->next = current->next;
current->next = newNode;
prev = newNode;
}
current = current->below;
level--;
}
// increase the length of the skip list
s->length++;
}
node * searchAndGetNearestNode(node *curr, long long &nodeId){
if(!curr) return NULL;
if(curr->nodeId >= nodeId)
return curr;
while(curr->next && curr->next->nodeId < nodeId){
curr = curr->next;
}
if(curr->nodeId >= nodeId)
return curr;
if(!curr->below)
return curr->next;
return searchAndGetNearestNode(curr->below, nodeId);
}
long long getCommonNodesCount(skipList *s1, skipList *s2){
long long count = 0;
int lvl1=0, lvl2= 0;
if(s1->length > s2->length)
swap(s1, s2);
node *nextn1 = getNewNode(0);
node *n1 = getNewNode(0);
node *n2 = getNewNode(0);
n1 = s1->head[0]->next;
n2 = s2->head[s2->height-1];
while(n1 && n2){
if(n1->nodeId > n2->nodeId){
n2 = searchAndGetNearestNode(n2, n1->nodeId);
}else if(n1->nodeId < n2->nodeId){
n1 = n1->next;
}else{
count++;
n1 = n1->next;
}
}
return count;
}
void deleteLL(skipList *s){
for(int i=0; i<s->height; i++){
node *ll1node = s->head[i];
node *ll2node = ll1node;
while(ll1node){
ll2node = ll1node;
ll1node = ll1node->next;
delete ll2node;
}
}
}
| 25.595092
| 66
| 0.55489
|
ediston
|
03aa24232976241ad41da7c39d7bcc78ffdd407a
| 125,010
|
cpp
|
C++
|
src/KScripts/New/assign_KSVGs.cpp
|
HonzaMD/Krkal2
|
e53e9b096d89d1441ec472deb6d695c45bcae41f
|
[
"OLDAP-2.5"
] | 1
|
2018-04-01T16:47:52.000Z
|
2018-04-01T16:47:52.000Z
|
src/KScripts/assign_KSVGs.cpp
|
HonzaMD/Krkal2
|
e53e9b096d89d1441ec472deb6d695c45bcae41f
|
[
"OLDAP-2.5"
] | null | null | null |
src/KScripts/assign_KSVGs.cpp
|
HonzaMD/Krkal2
|
e53e9b096d89d1441ec472deb6d695c45bcae41f
|
[
"OLDAP-2.5"
] | null | null | null |
//////////////////////////////////////////////////////////////////////////////
///
/// A s s i g n K S V G S
///
/// Pridam vsechny KSVGs a jejich alokacni a rirazovaci fce
/// do hashovaci tabulky
/// A:Generated Automatically
///
/////////////////////////////////////////////////////////////////////////////
void KSAssignKSVGs() {
CKSKSVG *tmp;
// New lines added 05/31/18 at 20:38:59.
tmp = new CKSKSVG("_KSVG_0_placeable_0001_FFFF_0001_0001",&KSAlloc_KSVG_0_placeable_0001_FFFF_0001_0001,&KSSetV_KSVG_0_placeable_0001_FFFF_0001_0001,sizeof(_KSVG_0_placeable_0001_FFFF_0001_0001));
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosX_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosY_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_APicture_0001_FFFF_0001_0001");
tmp = new CKSKSVG("_KSVG_1_smejdic_0001_FFFF_0001_0001",&KSAlloc_KSVG_1_smejdic_0001_FFFF_0001_0001,&KSSetV_KSVG_1_smejdic_0001_FFFF_0001_0001,sizeof(_KSVG_1_smejdic_0001_FFFF_0001_0001));
tmp->AddAttribute("_KSOV_smejdic_0001_FFFF_0001_0001__M__KN_ANoConnect_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosX_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosY_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_APicture_0001_FFFF_0001_0001");
tmp = new CKSKSVG("_KSVG_2_LezeNadVecma_0001_FFFF_0001_0001",&KSAlloc_KSVG_2_LezeNadVecma_0001_FFFF_0001_0001,&KSSetV_KSVG_2_LezeNadVecma_0001_FFFF_0001_0001,sizeof(_KSVG_2_LezeNadVecma_0001_FFFF_0001_0001));
tmp->AddAttribute("_KSOV_LezeNadVecma_0001_FFFF_0001_0001__M__KN_clzSubGr_0001_FFFF_0001_0001");
tmp = new CKSKSVG("_KSVG_3_Veci_0001_FFFF_0001_0001",&KSAlloc_KSVG_3_Veci_0001_FFFF_0001_0001,&KSSetV_KSVG_3_Veci_0001_FFFF_0001_0001,sizeof(_KSVG_3_Veci_0001_FFFF_0001_0001));
tmp->AddAttribute("_KSOV_Veci_0001_FFFF_0001_0001__M__KN_clzSubGr_0001_FFFF_0001_0001");
tmp = new CKSKSVG("_KSVG_4_floors_0001_FFFF_0001_0001",&KSAlloc_KSVG_4_floors_0001_FFFF_0001_0001,&KSSetV_KSVG_4_floors_0001_FFFF_0001_0001,sizeof(_KSVG_4_floors_0001_FFFF_0001_0001));
tmp->AddAttribute("_KSOV_floors_0001_FFFF_0001_0001__M__KN_CollisionCfg_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosX_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosY_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_APicture_0001_FFFF_0001_0001");
tmp = new CKSKSVG("_KSVG_5_floor_0001_FFFF_0001_0001",&KSAlloc_KSVG_5_floor_0001_FFFF_0001_0001,&KSSetV_KSVG_5_floor_0001_FFFF_0001_0001,sizeof(_KSVG_5_floor_0001_FFFF_0001_0001));
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosX_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosY_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_APicture_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_floors_0001_FFFF_0001_0001__M__KN_CollisionCfg_0001_FFFF_0001_0001");
tmp = new CKSKSVG("_KSVG_6_wall_0001_FFFF_0001_0001",&KSAlloc_KSVG_6_wall_0001_FFFF_0001_0001,&KSSetV_KSVG_6_wall_0001_FFFF_0001_0001,sizeof(_KSVG_6_wall_0001_FFFF_0001_0001));
tmp->AddAttribute("_KSOV_wall_0001_FFFF_0001_0001__M__KN_ANoConnect_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosX_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosY_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_APicture_0001_FFFF_0001_0001");
tmp = new CKSKSVG("_KSVG_7_EditTest_0001_FFFF_0001_0001",&KSAlloc_KSVG_7_EditTest_0001_FFFF_0001_0001,&KSSetV_KSVG_7_EditTest_0001_FFFF_0001_0001,sizeof(_KSVG_7_EditTest_0001_FFFF_0001_0001));
tmp->AddAttribute("_KSOV_EditTest_0001_FFFF_0001_0001__M__KN_ANoConnect_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_EditTest_0001_FFFF_0001_0001__M_a_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_EditTest_0001_FFFF_0001_0001__M_probability_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_EditTest_0001_FFFF_0001_0001__M_Affects_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_EditTest_0001_FFFF_0001_0001__M_Objects_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_EditTest_0001_FFFF_0001_0001__M_str_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_EditTest_0001_FFFF_0001_0001__M_ch_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_EditTest_0001_FFFF_0001_0001__M_obj_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_EditTest_0001_FFFF_0001_0001__M_inty_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_EditTest_0001_FFFF_0001_0001__M_chary_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_EditTest_0001_FFFF_0001_0001__M_doubly_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_EditTest_0001_FFFF_0001_0001__M_namesy_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosX_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosY_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_APicture_0001_FFFF_0001_0001");
tmp = new CKSKSVG("_KSVG_8_PAutoTest_0001_FFFF_0001_0001",&KSAlloc_KSVG_8_PAutoTest_0001_FFFF_0001_0001,&KSSetV_KSVG_8_PAutoTest_0001_FFFF_0001_0001,sizeof(_KSVG_8_PAutoTest_0001_FFFF_0001_0001));
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosX_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosY_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_APicture_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_floors_0001_FFFF_0001_0001__M__KN_CollisionCfg_0001_FFFF_0001_0001");
tmp = new CKSKSVG("_KSVG_9_otrigger_0001_FFFF_0001_0001",&KSAlloc_KSVG_9_otrigger_0001_FFFF_0001_0001,&KSSetV_KSVG_9_otrigger_0001_FFFF_0001_0001,sizeof(_KSVG_9_otrigger_0001_FFFF_0001_0001));
tmp->AddAttribute("_KSOV_otrigger_0001_FFFF_0001_0001__M__KN_ObjPosX_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_otrigger_0001_FFFF_0001_0001__M__KN_ObjPosY_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_otrigger_0001_FFFF_0001_0001__M__KN_CollisionCfg_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_otrigger_0001_FFFF_0001_0001__M__KN_NumCellX_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_otrigger_0001_FFFF_0001_0001__M__KN_NumCellY_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_otrigger_0001_FFFF_0001_0001__M__KN_clzAddGr_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_otrigger_0001_FFFF_0001_0001__M__KN_clzSubGr_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_otrigger_0001_FFFF_0001_0001__M__KN_MsgRedirect_0001_FFFF_0001_0001");
tmp = new CKSKSVG("_KSVG_10_ovybuch_0001_FFFF_0001_0001",&KSAlloc_KSVG_10_ovybuch_0001_FFFF_0001_0001,&KSSetV_KSVG_10_ovybuch_0001_FFFF_0001_0001,sizeof(_KSVG_10_ovybuch_0001_FFFF_0001_0001));
tmp->AddAttribute("_KSOV_ovybuch_0001_FFFF_0001_0001__M__KN_CollisionCfg_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_ovybuch_0001_FFFF_0001_0001__M__KN_NumCellX_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_ovybuch_0001_FFFF_0001_0001__M__KN_NumCellY_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_ovybuch_0001_FFFF_0001_0001__M__KN_clzAddGr_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosX_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosY_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_APicture_0001_FFFF_0001_0001");
tmp = new CKSKSVG("_KSVG_11_oVybuch1_0001_FFFF_0001_0001",&KSAlloc_KSVG_11_oVybuch1_0001_FFFF_0001_0001,&KSSetV_KSVG_11_oVybuch1_0001_FFFF_0001_0001,sizeof(_KSVG_11_oVybuch1_0001_FFFF_0001_0001));
tmp->AddAttribute("_KSOV_oVybuch1_0001_FFFF_0001_0001__M__KN_CollisionCfg_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oVybuch1_0001_FFFF_0001_0001__M__KN_ObjPosX_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oVybuch1_0001_FFFF_0001_0001__M__KN_ObjPosY_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oVybuch1_0001_FFFF_0001_0001__M__KN_clzAddGr_0001_FFFF_0001_0001");
tmp = new CKSKSVG("_KSVG_12_OPosmrtnaAnimace_0001_FFFF_0001_0001",&KSAlloc_KSVG_12_OPosmrtnaAnimace_0001_FFFF_0001_0001,&KSSetV_KSVG_12_OPosmrtnaAnimace_0001_FFFF_0001_0001,sizeof(_KSVG_12_OPosmrtnaAnimace_0001_FFFF_0001_0001));
tmp->AddAttribute("_KSOV_OPosmrtnaAnimace_0001_FFFF_0001_0001__M_StylGrafiky_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_OPosmrtnaAnimace_0001_FFFF_0001_0001__M_StylSmrti_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosX_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosY_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_APicture_0001_FFFF_0001_0001");
tmp = new CKSKSVG("_KSVG_13_oVybuchuje_0001_FFFF_0001_0001",&KSAlloc_KSVG_13_oVybuchuje_0001_FFFF_0001_0001,&KSSetV_KSVG_13_oVybuchuje_0001_FFFF_0001_0001,sizeof(_KSVG_13_oVybuchuje_0001_FFFF_0001_0001));
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosX_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosY_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_APicture_0001_FFFF_0001_0001");
tmp = new CKSKSVG("_KSVG_14_mina_0001_FFFF_0001_0001",&KSAlloc_KSVG_14_mina_0001_FFFF_0001_0001,&KSSetV_KSVG_14_mina_0001_FFFF_0001_0001,sizeof(_KSVG_14_mina_0001_FFFF_0001_0001));
tmp->AddAttribute("_KSOV_mina_0001_FFFF_0001_0001__M_triger_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosX_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosY_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_APicture_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_Veci_0001_FFFF_0001_0001__M__KN_clzSubGr_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_WillCalculate_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_Moving_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fsource_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fdir_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fpriority_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_ftype_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fspeed_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fstate_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_BlockedPath_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_BlockingObjs_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_LastDir_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_LastMTime_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_LSpeed_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oBouraDoSten_0001_FFFF_0001_0001__M_cas_0001_FFFF_0001_0001");
tmp = new CKSKSVG("_KSVG_15_oPointTr_0001_FFFF_0001_0001",&KSAlloc_KSVG_15_oPointTr_0001_FFFF_0001_0001,&KSSetV_KSVG_15_oPointTr_0001_FFFF_0001_0001,sizeof(_KSVG_15_oPointTr_0001_FFFF_0001_0001));
tmp->AddAttribute("_KSOV_oPointTr_0001_FFFF_0001_0001__M__KN_ObjPosX_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oPointTr_0001_FFFF_0001_0001__M__KN_ObjPosY_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oPointTr_0001_FFFF_0001_0001__M__KN_CollisionCfg_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oPointTr_0001_FFFF_0001_0001__M__KN_clzAddGr_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oPointTr_0001_FFFF_0001_0001__M__KN_clzSubGr_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oPointTr_0001_FFFF_0001_0001__M__KN_MsgRedirect_0001_FFFF_0001_0001");
tmp = new CKSKSVG("_KSVG_16_oDira_0001_FFFF_0001_0001",&KSAlloc_KSVG_16_oDira_0001_FFFF_0001_0001,&KSSetV_KSVG_16_oDira_0001_FFFF_0001_0001,sizeof(_KSVG_16_oDira_0001_FFFF_0001_0001));
tmp->AddAttribute("_KSOV_oDira_0001_FFFF_0001_0001__M_triger_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosX_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosY_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_APicture_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_floors_0001_FFFF_0001_0001__M__KN_CollisionCfg_0001_FFFF_0001_0001");
tmp = new CKSKSVG("_KSVG_17_oLava_0001_FFFF_0001_0001",&KSAlloc_KSVG_17_oLava_0001_FFFF_0001_0001,&KSSetV_KSVG_17_oLava_0001_FFFF_0001_0001,sizeof(_KSVG_17_oLava_0001_FFFF_0001_0001));
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosX_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosY_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_APicture_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_floors_0001_FFFF_0001_0001__M__KN_CollisionCfg_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oDira_0001_FFFF_0001_0001__M_triger_0001_FFFF_0001_0001");
tmp = new CKSKSVG("_KSVG_18_oPropadlo_0001_FFFF_0001_0001",&KSAlloc_KSVG_18_oPropadlo_0001_FFFF_0001_0001,&KSSetV_KSVG_18_oPropadlo_0001_FFFF_0001_0001,sizeof(_KSVG_18_oPropadlo_0001_FFFF_0001_0001));
tmp->AddAttribute("_KSOV_oPropadlo_0001_FFFF_0001_0001__M_triger_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oPropadlo_0001_FFFF_0001_0001__M_StavPropadnuti_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosX_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosY_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_APicture_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_floors_0001_FFFF_0001_0001__M__KN_CollisionCfg_0001_FFFF_0001_0001");
tmp = new CKSKSVG("_KSVG_19_oSeSmerem_0001_FFFF_0001_0001",&KSAlloc_KSVG_19_oSeSmerem_0001_FFFF_0001_0001,&KSSetV_KSVG_19_oSeSmerem_0001_FFFF_0001_0001,sizeof(_KSVG_19_oSeSmerem_0001_FFFF_0001_0001));
tmp->AddAttribute("_KSOV_oSeSmerem_0001_FFFF_0001_0001__M_smer_0001_FFFF_0001_0001");
tmp = new CKSKSVG("_KSVG_20_oSeSmerem2_0001_FFFF_0001_0001",&KSAlloc_KSVG_20_oSeSmerem2_0001_FFFF_0001_0001,&KSSetV_KSVG_20_oSeSmerem2_0001_FFFF_0001_0001,sizeof(_KSVG_20_oSeSmerem2_0001_FFFF_0001_0001));
tmp->AddAttribute("_KSOV_oSeSmerem2_0001_FFFF_0001_0001__M_smer_0001_FFFF_0001_0001");
tmp = new CKSKSVG("_KSVG_21_oMagnet_0001_FFFF_0001_0001",&KSAlloc_KSVG_21_oMagnet_0001_FFFF_0001_0001,&KSSetV_KSVG_21_oMagnet_0001_FFFF_0001_0001,sizeof(_KSVG_21_oMagnet_0001_FFFF_0001_0001));
tmp->AddAttribute("_KSOV_oMagnet_0001_FFFF_0001_0001__M_triger_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMagnet_0001_FFFF_0001_0001__M_mforce_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMagnet_0001_FFFF_0001_0001__M_x_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMagnet_0001_FFFF_0001_0001__M_y_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMagnet_0001_FFFF_0001_0001__M_x2_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMagnet_0001_FFFF_0001_0001__M_y2_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosX_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosY_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_APicture_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oSeSmerem_0001_FFFF_0001_0001__M_smer_0001_FFFF_0001_0001");
tmp = new CKSKSVG("_KSVG_22_oLaser_0001_FFFF_0001_0001",&KSAlloc_KSVG_22_oLaser_0001_FFFF_0001_0001,&KSSetV_KSVG_22_oLaser_0001_FFFF_0001_0001,sizeof(_KSVG_22_oLaser_0001_FFFF_0001_0001));
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosX_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosY_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_APicture_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oSeSmerem_0001_FFFF_0001_0001__M_smer_0001_FFFF_0001_0001");
tmp = new CKSKSVG("_KSVG_23_oklic_0001_FFFF_0001_0001",&KSAlloc_KSVG_23_oklic_0001_FFFF_0001_0001,&KSSetV_KSVG_23_oklic_0001_FFFF_0001_0001,sizeof(_KSVG_23_oklic_0001_FFFF_0001_0001));
tmp->AddAttribute("_KSOV_oklic_0001_FFFF_0001_0001__M_barva_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosX_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosY_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_APicture_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_Veci_0001_FFFF_0001_0001__M__KN_clzSubGr_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_WillCalculate_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_Moving_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fsource_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fdir_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fpriority_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_ftype_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fspeed_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fstate_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_BlockedPath_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_BlockingObjs_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_LastDir_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_LastMTime_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_LSpeed_0001_FFFF_0001_0001");
tmp = new CKSKSVG("_KSVG_24_oAreaTest_0001_FFFF_0001_0001",&KSAlloc_KSVG_24_oAreaTest_0001_FFFF_0001_0001,&KSSetV_KSVG_24_oAreaTest_0001_FFFF_0001_0001,sizeof(_KSVG_24_oAreaTest_0001_FFFF_0001_0001));
tmp->AddAttribute("_KSOV_oAreaTest_0001_FFFF_0001_0001__M_x1_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oAreaTest_0001_FFFF_0001_0001__M_y1_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oAreaTest_0001_FFFF_0001_0001__M_z1_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oAreaTest_0001_FFFF_0001_0001__M_x2_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oAreaTest_0001_FFFF_0001_0001__M_y2_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oAreaTest_0001_FFFF_0001_0001__M_z2_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oAreaTest_0001_FFFF_0001_0001__M_x_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oAreaTest_0001_FFFF_0001_0001__M_y_0001_FFFF_0001_0001");
tmp = new CKSKSVG("_KSVG_25_oStartsMove_0001_FFFF_0001_0001",&KSAlloc_KSVG_25_oStartsMove_0001_FFFF_0001_0001,&KSSetV_KSVG_25_oStartsMove_0001_FFFF_0001_0001,sizeof(_KSVG_25_oStartsMove_0001_FFFF_0001_0001));
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosX_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosY_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_APicture_0001_FFFF_0001_0001");
tmp = new CKSKSVG("_KSVG_26_oMoveable_0001_FFFF_0001_0001",&KSAlloc_KSVG_26_oMoveable_0001_FFFF_0001_0001,&KSSetV_KSVG_26_oMoveable_0001_FFFF_0001_0001,sizeof(_KSVG_26_oMoveable_0001_FFFF_0001_0001));
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_WillCalculate_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_Moving_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fsource_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fdir_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fpriority_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_ftype_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fspeed_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fstate_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_BlockedPath_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_BlockingObjs_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_LastDir_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_LastMTime_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_LSpeed_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosX_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosY_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_APicture_0001_FFFF_0001_0001");
tmp = new CKSKSVG("_KSVG_27_oMoves_0001_FFFF_0001_0001",&KSAlloc_KSVG_27_oMoves_0001_FFFF_0001_0001,&KSSetV_KSVG_27_oMoves_0001_FFFF_0001_0001,sizeof(_KSVG_27_oMoves_0001_FFFF_0001_0001));
tmp->AddAttribute("_KSOV_oMoves_0001_FFFF_0001_0001__M_banning_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoves_0001_FFFF_0001_0001__M_path_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoves_0001_FFFF_0001_0001__M_pathp_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoves_0001_FFFF_0001_0001__M_DeBlockAreaX1_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoves_0001_FFFF_0001_0001__M_DeBlockAreaY1_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoves_0001_FFFF_0001_0001__M_DeBlockAreaX2_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoves_0001_FFFF_0001_0001__M_DeBlockAreaY2_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoves_0001_FFFF_0001_0001__M_LastDirs_0001_FFFF_0001_0001");
tmp = new CKSKSVG("_KSVG_28_oBlockedPath_0001_FFFF_0001_0001",&KSAlloc_KSVG_28_oBlockedPath_0001_FFFF_0001_0001,&KSSetV_KSVG_28_oBlockedPath_0001_FFFF_0001_0001,sizeof(_KSVG_28_oBlockedPath_0001_FFFF_0001_0001));
tmp->AddAttribute("_KSOV_oBlockedPath_0001_FFFF_0001_0001__M_Father_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oBlockedPath_0001_FFFF_0001_0001__M__KN_ObjPosX_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oBlockedPath_0001_FFFF_0001_0001__M__KN_ObjPosY_0001_FFFF_0001_0001");
tmp = new CKSKSVG("_KSVG_29_oBlockedPath_0001_FFFF_0001_0001__M_Veci_0001_FFFF_0001_0001",&KSAlloc_KSVG_29_oBlockedPath_0001_FFFF_0001_0001__M_Veci_0001_FFFF_0001_0001,&KSSetV_KSVG_29_oBlockedPath_0001_FFFF_0001_0001__M_Veci_0001_FFFF_0001_0001,sizeof(_KSVG_29_oBlockedPath_0001_FFFF_0001_0001__M_Veci_0001_FFFF_0001_0001));
tmp->AddAttribute("_KSOV_Veci_0001_FFFF_0001_0001__M__KN_clzSubGr_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oBlockedPath_0001_FFFF_0001_0001__M_Father_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oBlockedPath_0001_FFFF_0001_0001__M__KN_ObjPosX_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oBlockedPath_0001_FFFF_0001_0001__M__KN_ObjPosY_0001_FFFF_0001_0001");
tmp = new CKSKSVG("_KSVG_30_oBlockedPath_0001_FFFF_0001_0001__M_LezeNadVecma_0001_FFFF_0001_0001",&KSAlloc_KSVG_30_oBlockedPath_0001_FFFF_0001_0001__M_LezeNadVecma_0001_FFFF_0001_0001,&KSSetV_KSVG_30_oBlockedPath_0001_FFFF_0001_0001__M_LezeNadVecma_0001_FFFF_0001_0001,sizeof(_KSVG_30_oBlockedPath_0001_FFFF_0001_0001__M_LezeNadVecma_0001_FFFF_0001_0001));
tmp->AddAttribute("_KSOV_LezeNadVecma_0001_FFFF_0001_0001__M__KN_clzSubGr_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oBlockedPath_0001_FFFF_0001_0001__M_Father_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oBlockedPath_0001_FFFF_0001_0001__M__KN_ObjPosX_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oBlockedPath_0001_FFFF_0001_0001__M__KN_ObjPosY_0001_FFFF_0001_0001");
tmp = new CKSKSVG("_KSVG_31_oPas_0001_FFFF_0001_0001",&KSAlloc_KSVG_31_oPas_0001_FFFF_0001_0001,&KSSetV_KSVG_31_oPas_0001_FFFF_0001_0001,sizeof(_KSVG_31_oPas_0001_FFFF_0001_0001));
tmp->AddAttribute("_KSOV_oPas_0001_FFFF_0001_0001__M_triger_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oPas_0001_FFFF_0001_0001__M_OnOff_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosX_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosY_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_APicture_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_floors_0001_FFFF_0001_0001__M__KN_CollisionCfg_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oSeSmerem_0001_FFFF_0001_0001__M_smer_0001_FFFF_0001_0001");
tmp = new CKSKSVG("_KSVG_32_oOnOff_0001_FFFF_0001_0001",&KSAlloc_KSVG_32_oOnOff_0001_FFFF_0001_0001,&KSSetV_KSVG_32_oOnOff_0001_FFFF_0001_0001,sizeof(_KSVG_32_oOnOff_0001_FFFF_0001_0001));
tmp->AddAttribute("_KSOV_oOnOff_0001_FFFF_0001_0001__M_OnOff_0001_FFFF_0001_0001");
tmp = new CKSKSVG("_KSVG_33_oLed_0001_FFFF_0001_0001",&KSAlloc_KSVG_33_oLed_0001_FFFF_0001_0001,&KSSetV_KSVG_33_oLed_0001_FFFF_0001_0001,sizeof(_KSVG_33_oLed_0001_FFFF_0001_0001));
tmp->AddAttribute("_KSOV_oLed_0001_FFFF_0001_0001__M_triger_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosX_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosY_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_APicture_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_floors_0001_FFFF_0001_0001__M__KN_CollisionCfg_0001_FFFF_0001_0001");
tmp = new CKSKSVG("_KSVG_34_oPrisera_0001_FFFF_0001_0001",&KSAlloc_KSVG_34_oPrisera_0001_FFFF_0001_0001,&KSSetV_KSVG_34_oPrisera_0001_FFFF_0001_0001,sizeof(_KSVG_34_oPrisera_0001_FFFF_0001_0001));
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosX_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosY_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_APicture_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_LezeNadVecma_0001_FFFF_0001_0001__M__KN_clzSubGr_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oSeSmerem_0001_FFFF_0001_0001__M_smer_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_WillCalculate_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_Moving_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fsource_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fdir_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fpriority_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_ftype_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fspeed_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fstate_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_BlockedPath_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_BlockingObjs_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_LastDir_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_LastMTime_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_LSpeed_0001_FFFF_0001_0001");
tmp = new CKSKSVG("_KSVG_35_oPriseraOt_0001_FFFF_0001_0001",&KSAlloc_KSVG_35_oPriseraOt_0001_FFFF_0001_0001,&KSSetV_KSVG_35_oPriseraOt_0001_FFFF_0001_0001,sizeof(_KSVG_35_oPriseraOt_0001_FFFF_0001_0001));
tmp->AddAttribute("_KSOV_oPriseraOt_0001_FFFF_0001_0001__M_Tocivost_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosX_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosY_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_APicture_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_LezeNadVecma_0001_FFFF_0001_0001__M__KN_clzSubGr_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oSeSmerem_0001_FFFF_0001_0001__M_smer_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_WillCalculate_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_Moving_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fsource_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fdir_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fpriority_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_ftype_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fspeed_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fstate_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_BlockedPath_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_BlockingObjs_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_LastDir_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_LastMTime_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_LSpeed_0001_FFFF_0001_0001");
tmp = new CKSKSVG("_KSVG_36_oLineTr_0001_FFFF_0001_0001",&KSAlloc_KSVG_36_oLineTr_0001_FFFF_0001_0001,&KSSetV_KSVG_36_oLineTr_0001_FFFF_0001_0001,sizeof(_KSVG_36_oLineTr_0001_FFFF_0001_0001));
tmp->AddAttribute("_KSOV_oLineTr_0001_FFFF_0001_0001__M__KN_ObjPosX_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oLineTr_0001_FFFF_0001_0001__M__KN_ObjPosY_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oLineTr_0001_FFFF_0001_0001__M__KN_CollisionCfg_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oLineTr_0001_FFFF_0001_0001__M__KN_NumCellX_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oLineTr_0001_FFFF_0001_0001__M__KN_NumCellY_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oLineTr_0001_FFFF_0001_0001__M__KN_clzAddGr_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oLineTr_0001_FFFF_0001_0001__M__KN_clzSubGr_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oLineTr_0001_FFFF_0001_0001__M__KN_MsgRedirect_0001_FFFF_0001_0001");
tmp = new CKSKSVG("_KSVG_37_oMagnetForce_0001_FFFF_0001_0001",&KSAlloc_KSVG_37_oMagnetForce_0001_FFFF_0001_0001,&KSSetV_KSVG_37_oMagnetForce_0001_FFFF_0001_0001,sizeof(_KSVG_37_oMagnetForce_0001_FFFF_0001_0001));
tmp->AddAttribute("_KSOV_oMagnetForce_0001_FFFF_0001_0001__M__KN_ObjPosX_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMagnetForce_0001_FFFF_0001_0001__M__KN_ObjPosY_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMagnetForce_0001_FFFF_0001_0001__M__KN_CollisionCfg_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMagnetForce_0001_FFFF_0001_0001__M__KN_NumCellX_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMagnetForce_0001_FFFF_0001_0001__M__KN_NumCellY_0001_FFFF_0001_0001");
tmp = new CKSKSVG("_KSVG_38_oAntiMagnet_0001_FFFF_0001_0001",&KSAlloc_KSVG_38_oAntiMagnet_0001_FFFF_0001_0001,&KSSetV_KSVG_38_oAntiMagnet_0001_FFFF_0001_0001,sizeof(_KSVG_38_oAntiMagnet_0001_FFFF_0001_0001));
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosX_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosY_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_APicture_0001_FFFF_0001_0001");
tmp = new CKSKSVG("_KSVG_40_oManik_0001_FFFF_0001_0001",&KSAlloc_KSVG_40_oManik_0001_FFFF_0001_0001,&KSSetV_KSVG_40_oManik_0001_FFFF_0001_0001,sizeof(_KSVG_40_oManik_0001_FFFF_0001_0001));
tmp->AddAttribute("_KSOV_oManik_0001_FFFF_0001_0001__M_muflon_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oManik_0001_FFFF_0001_0001__M_ziju_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oManik_0001_FFFF_0001_0001__M_SKlice_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oManik_0001_FFFF_0001_0001__M_triger_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oManik_0001_FFFF_0001_0001__M_SBomby_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oManik_0001_FFFF_0001_0001__M_SMiny_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oManik_0001_FFFF_0001_0001__M_KeyBombaDown_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oManik_0001_FFFF_0001_0001__M_KeyMinaDown_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oManik_0001_FFFF_0001_0001__M_koliznik_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oManik_0001_FFFF_0001_0001__M_cellX_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oManik_0001_FFFF_0001_0001__M_cellY_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oManik_0001_FFFF_0001_0001__M_Focus_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oManik_0001_FFFF_0001_0001__M_SZnacky_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oManik_0001_FFFF_0001_0001__M_KeyZnackyDown_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oManik_0001_FFFF_0001_0001__M_KeyZnackyDown1_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oManik_0001_FFFF_0001_0001__M_ZmacknutoA_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosX_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosY_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_APicture_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_LezeNadVecma_0001_FFFF_0001_0001__M__KN_clzSubGr_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oSeSmerem_0001_FFFF_0001_0001__M_smer_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_WillCalculate_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_Moving_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fsource_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fdir_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fpriority_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_ftype_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fspeed_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fstate_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_BlockedPath_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_BlockingObjs_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_LastDir_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_LastMTime_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_LSpeed_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oStrka_0001_FFFF_0001_0001__M_CoStrka_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oStrka_0001_FFFF_0001_0001__M__KN_clzFceGr_0001_FFFF_0001_0001");
tmp = new CKSKSVG("_KSVG_41_oDracek_0001_FFFF_0001_0001",&KSAlloc_KSVG_41_oDracek_0001_FFFF_0001_0001,&KSSetV_KSVG_41_oDracek_0001_FFFF_0001_0001,sizeof(_KSVG_41_oDracek_0001_FFFF_0001_0001));
tmp->AddAttribute("_KSOV_oDracek_0001_FFFF_0001_0001__M_VeVode_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oDracek_0001_FFFF_0001_0001__M_veVodeCounter_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oDracek_0001_FFFF_0001_0001__M_trigerVoda_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oDracek_0001_FFFF_0001_0001__M_trigerHelper_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosX_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosY_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_APicture_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_LezeNadVecma_0001_FFFF_0001_0001__M__KN_clzSubGr_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oSeSmerem_0001_FFFF_0001_0001__M_smer_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_WillCalculate_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_Moving_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fsource_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fdir_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fpriority_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_ftype_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fspeed_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fstate_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_BlockedPath_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_BlockingObjs_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_LastDir_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_LastMTime_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_LSpeed_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oManik_0001_FFFF_0001_0001__M_muflon_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oManik_0001_FFFF_0001_0001__M_ziju_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oManik_0001_FFFF_0001_0001__M_SKlice_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oManik_0001_FFFF_0001_0001__M_triger_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oManik_0001_FFFF_0001_0001__M_SBomby_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oManik_0001_FFFF_0001_0001__M_SMiny_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oManik_0001_FFFF_0001_0001__M_KeyBombaDown_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oManik_0001_FFFF_0001_0001__M_KeyMinaDown_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oManik_0001_FFFF_0001_0001__M_koliznik_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oManik_0001_FFFF_0001_0001__M_cellX_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oManik_0001_FFFF_0001_0001__M_cellY_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oManik_0001_FFFF_0001_0001__M_Focus_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oManik_0001_FFFF_0001_0001__M_SZnacky_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oManik_0001_FFFF_0001_0001__M_KeyZnackyDown_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oManik_0001_FFFF_0001_0001__M_KeyZnackyDown1_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oManik_0001_FFFF_0001_0001__M_ZmacknutoA_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oStrka_0001_FFFF_0001_0001__M_CoStrka_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oStrka_0001_FFFF_0001_0001__M__KN_clzFceGr_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oUmiraNaSlizu_0001_FFFF_0001_0001__M_SlizCount_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oUmiraNaSlizu_0001_FFFF_0001_0001__M_SlizSmrtCount_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oUmiraNaSlizu_0001_FFFF_0001_0001__M_SlizMez_0001_FFFF_0001_0001");
tmp = new CKSKSVG("_KSVG_42_oExit_0001_FFFF_0001_0001",&KSAlloc_KSVG_42_oExit_0001_FFFF_0001_0001,&KSSetV_KSVG_42_oExit_0001_FFFF_0001_0001,sizeof(_KSVG_42_oExit_0001_FFFF_0001_0001));
tmp->AddAttribute("_KSOV_oExit_0001_FFFF_0001_0001__M_triger_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosX_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosY_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_APicture_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_floors_0001_FFFF_0001_0001__M__KN_CollisionCfg_0001_FFFF_0001_0001");
tmp = new CKSKSVG("_KSVG_43_oManikControler_0001_FFFF_0001_0001",&KSAlloc_KSVG_43_oManikControler_0001_FFFF_0001_0001,&KSSetV_KSVG_43_oManikControler_0001_FFFF_0001_0001,sizeof(_KSVG_43_oManikControler_0001_FFFF_0001_0001));
tmp->AddAttribute("_KSOV_oManikControler_0001_FFFF_0001_0001__M_ManikCount_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oManikControler_0001_FFFF_0001_0001__M_ZmacknutTab_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oManikControler_0001_FFFF_0001_0001__M_Klic1_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oManikControler_0001_FFFF_0001_0001__M_Klic2_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oManikControler_0001_FFFF_0001_0001__M_Klic3_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oManikControler_0001_FFFF_0001_0001__M_Bomba_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oManikControler_0001_FFFF_0001_0001__M_Mina_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oManikControler_0001_FFFF_0001_0001__M_Znacky_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oManikControler_0001_FFFF_0001_0001__M_Manici_0001_FFFF_0001_0001");
tmp = new CKSKSVG("_KSVG_46_oHlina_0001_FFFF_0001_0001",&KSAlloc_KSVG_46_oHlina_0001_FFFF_0001_0001,&KSSetV_KSVG_46_oHlina_0001_FFFF_0001_0001,sizeof(_KSVG_46_oHlina_0001_FFFF_0001_0001));
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosX_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosY_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_APicture_0001_FFFF_0001_0001");
tmp = new CKSKSVG("_KSVG_49_oKamen_0001_FFFF_0001_0001",&KSAlloc_KSVG_49_oKamen_0001_FFFF_0001_0001,&KSSetV_KSVG_49_oKamen_0001_FFFF_0001_0001,sizeof(_KSVG_49_oKamen_0001_FFFF_0001_0001));
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosX_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosY_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_APicture_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_WillCalculate_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_Moving_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fsource_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fdir_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fpriority_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_ftype_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fspeed_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fstate_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_BlockedPath_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_BlockingObjs_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_LastDir_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_LastMTime_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_LSpeed_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oStrkatelne_0001_FFFF_0001_0001__M_LastStrkac_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oStrkatelne_0001_FFFF_0001_0001__M_StrkTime_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oStrkatelne_0001_FFFF_0001_0001__M_StrkTimeOut_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oStrkatelne_0001_FFFF_0001_0001__M_Time_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oBouraDoSten_0001_FFFF_0001_0001__M_cas_0001_FFFF_0001_0001");
tmp = new CKSKSVG("_KSVG_50_oZnicitelnaStena_0001_FFFF_0001_0001",&KSAlloc_KSVG_50_oZnicitelnaStena_0001_FFFF_0001_0001,&KSSetV_KSVG_50_oZnicitelnaStena_0001_FFFF_0001_0001,sizeof(_KSVG_50_oZnicitelnaStena_0001_FFFF_0001_0001));
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosX_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosY_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_APicture_0001_FFFF_0001_0001");
tmp = new CKSKSVG("_KSVG_51_oSebratelnaBomba_0001_FFFF_0001_0001",&KSAlloc_KSVG_51_oSebratelnaBomba_0001_FFFF_0001_0001,&KSSetV_KSVG_51_oSebratelnaBomba_0001_FFFF_0001_0001,sizeof(_KSVG_51_oSebratelnaBomba_0001_FFFF_0001_0001));
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosX_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosY_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_APicture_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_Veci_0001_FFFF_0001_0001__M__KN_clzSubGr_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_WillCalculate_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_Moving_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fsource_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fdir_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fpriority_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_ftype_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fspeed_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fstate_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_BlockedPath_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_BlockingObjs_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_LastDir_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_LastMTime_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_LSpeed_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oBouraDoSten_0001_FFFF_0001_0001__M_cas_0001_FFFF_0001_0001");
tmp = new CKSKSVG("_KSVG_52_oSebratelnaMina_0001_FFFF_0001_0001",&KSAlloc_KSVG_52_oSebratelnaMina_0001_FFFF_0001_0001,&KSSetV_KSVG_52_oSebratelnaMina_0001_FFFF_0001_0001,sizeof(_KSVG_52_oSebratelnaMina_0001_FFFF_0001_0001));
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosX_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosY_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_APicture_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_Veci_0001_FFFF_0001_0001__M__KN_clzSubGr_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_WillCalculate_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_Moving_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fsource_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fdir_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fpriority_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_ftype_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fspeed_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fstate_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_BlockedPath_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_BlockingObjs_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_LastDir_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_LastMTime_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_LSpeed_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oBouraDoSten_0001_FFFF_0001_0001__M_cas_0001_FFFF_0001_0001");
tmp = new CKSKSVG("_KSVG_53_oBomba_0001_FFFF_0001_0001",&KSAlloc_KSVG_53_oBomba_0001_FFFF_0001_0001,&KSSetV_KSVG_53_oBomba_0001_FFFF_0001_0001,sizeof(_KSVG_53_oBomba_0001_FFFF_0001_0001));
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosX_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosY_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_APicture_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_Veci_0001_FFFF_0001_0001__M__KN_clzSubGr_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_WillCalculate_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_Moving_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fsource_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fdir_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fpriority_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_ftype_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fspeed_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fstate_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_BlockedPath_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_BlockingObjs_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_LastDir_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_LastMTime_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_LSpeed_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oBouraDoSten_0001_FFFF_0001_0001__M_cas_0001_FFFF_0001_0001");
tmp = new CKSKSVG("_KSVG_54_oZamek_0001_FFFF_0001_0001",&KSAlloc_KSVG_54_oZamek_0001_FFFF_0001_0001,&KSSetV_KSVG_54_oZamek_0001_FFFF_0001_0001,sizeof(_KSVG_54_oZamek_0001_FFFF_0001_0001));
tmp->AddAttribute("_KSOV_oZamek_0001_FFFF_0001_0001__M_barva_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosX_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosY_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_APicture_0001_FFFF_0001_0001");
tmp = new CKSKSVG("_KSVG_55__KN_ScrollObj_0001_FFFF_0001_0001",&KSAlloc_KSVG_55__KN_ScrollObj_0001_FFFF_0001_0001,&KSSetV_KSVG_55__KN_ScrollObj_0001_FFFF_0001_0001,sizeof(_KSVG_55__KN_ScrollObj_0001_FFFF_0001_0001));
tmp->AddAttribute("_KSOV__KN_ScrollObj__M__KN_ObjPosX_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV__KN_ScrollObj__M__KN_ObjPosY_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV__KN_ScrollObj__M__KN_CollisionCfg_0001_FFFF_0001_0001");
tmp = new CKSKSVG("_KSVG_56_oVoda_0001_FFFF_0001_0001",&KSAlloc_KSVG_56_oVoda_0001_FFFF_0001_0001,&KSSetV_KSVG_56_oVoda_0001_FFFF_0001_0001,sizeof(_KSVG_56_oVoda_0001_FFFF_0001_0001));
tmp->AddAttribute("_KSOV_oVoda_0001_FFFF_0001_0001__M_triger_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosX_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosY_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_APicture_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_floors_0001_FFFF_0001_0001__M__KN_CollisionCfg_0001_FFFF_0001_0001");
tmp = new CKSKSVG("_KSVG_57_oKrabice_0001_FFFF_0001_0001",&KSAlloc_KSVG_57_oKrabice_0001_FFFF_0001_0001,&KSSetV_KSVG_57_oKrabice_0001_FFFF_0001_0001,sizeof(_KSVG_57_oKrabice_0001_FFFF_0001_0001));
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosX_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosY_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_APicture_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_WillCalculate_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_Moving_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fsource_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fdir_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fpriority_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_ftype_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fspeed_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fstate_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_BlockedPath_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_BlockingObjs_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_LastDir_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_LastMTime_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_LSpeed_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oStrkatelne_0001_FFFF_0001_0001__M_LastStrkac_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oStrkatelne_0001_FFFF_0001_0001__M_StrkTime_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oStrkatelne_0001_FFFF_0001_0001__M_StrkTimeOut_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oStrkatelne_0001_FFFF_0001_0001__M_Time_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oBouraDoSten_0001_FFFF_0001_0001__M_cas_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oPrulezny_0001_FFFF_0001_0001__M__KN_clzSubGr_0001_FFFF_0001_0001");
tmp = new CKSKSVG("_KSVG_58_oPneumatika_0001_FFFF_0001_0001",&KSAlloc_KSVG_58_oPneumatika_0001_FFFF_0001_0001,&KSSetV_KSVG_58_oPneumatika_0001_FFFF_0001_0001,sizeof(_KSVG_58_oPneumatika_0001_FFFF_0001_0001));
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosX_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosY_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_APicture_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_WillCalculate_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_Moving_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fsource_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fdir_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fpriority_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_ftype_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fspeed_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fstate_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_BlockedPath_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_BlockingObjs_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_LastDir_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_LastMTime_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_LSpeed_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oStrkatelne_0001_FFFF_0001_0001__M_LastStrkac_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oStrkatelne_0001_FFFF_0001_0001__M_StrkTime_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oStrkatelne_0001_FFFF_0001_0001__M_StrkTimeOut_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oStrkatelne_0001_FFFF_0001_0001__M_Time_0001_FFFF_0001_0001");
tmp = new CKSKSVG("_KSVG_59_oBalonek_0001_FFFF_0001_0001",&KSAlloc_KSVG_59_oBalonek_0001_FFFF_0001_0001,&KSSetV_KSVG_59_oBalonek_0001_FFFF_0001_0001,sizeof(_KSVG_59_oBalonek_0001_FFFF_0001_0001));
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosX_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosY_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_APicture_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_WillCalculate_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_Moving_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fsource_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fdir_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fpriority_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_ftype_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fspeed_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fstate_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_BlockedPath_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_BlockingObjs_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_LastDir_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_LastMTime_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_LSpeed_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oStrkatelne_0001_FFFF_0001_0001__M_LastStrkac_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oStrkatelne_0001_FFFF_0001_0001__M_StrkTime_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oStrkatelne_0001_FFFF_0001_0001__M_StrkTimeOut_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oStrkatelne_0001_FFFF_0001_0001__M_Time_0001_FFFF_0001_0001");
tmp = new CKSKSVG("_KSVG_60_oHemr_0001_FFFF_0001_0001",&KSAlloc_KSVG_60_oHemr_0001_FFFF_0001_0001,&KSSetV_KSVG_60_oHemr_0001_FFFF_0001_0001,sizeof(_KSVG_60_oHemr_0001_FFFF_0001_0001));
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosX_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosY_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_APicture_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_LezeNadVecma_0001_FFFF_0001_0001__M__KN_clzSubGr_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oSeSmerem_0001_FFFF_0001_0001__M_smer_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_WillCalculate_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_Moving_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fsource_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fdir_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fpriority_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_ftype_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fspeed_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fstate_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_BlockedPath_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_BlockingObjs_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_LastDir_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_LastMTime_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_LSpeed_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oManik_0001_FFFF_0001_0001__M_muflon_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oManik_0001_FFFF_0001_0001__M_ziju_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oManik_0001_FFFF_0001_0001__M_SKlice_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oManik_0001_FFFF_0001_0001__M_triger_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oManik_0001_FFFF_0001_0001__M_SBomby_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oManik_0001_FFFF_0001_0001__M_SMiny_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oManik_0001_FFFF_0001_0001__M_KeyBombaDown_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oManik_0001_FFFF_0001_0001__M_KeyMinaDown_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oManik_0001_FFFF_0001_0001__M_koliznik_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oManik_0001_FFFF_0001_0001__M_cellX_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oManik_0001_FFFF_0001_0001__M_cellY_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oManik_0001_FFFF_0001_0001__M_Focus_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oManik_0001_FFFF_0001_0001__M_SZnacky_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oManik_0001_FFFF_0001_0001__M_KeyZnackyDown_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oManik_0001_FFFF_0001_0001__M_KeyZnackyDown1_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oManik_0001_FFFF_0001_0001__M_ZmacknutoA_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oStrka_0001_FFFF_0001_0001__M_CoStrka_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oStrka_0001_FFFF_0001_0001__M__KN_clzFceGr_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oUmiraNaSlizu_0001_FFFF_0001_0001__M_SlizCount_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oUmiraNaSlizu_0001_FFFF_0001_0001__M_SlizSmrtCount_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oUmiraNaSlizu_0001_FFFF_0001_0001__M_SlizMez_0001_FFFF_0001_0001");
tmp = new CKSKSVG("_KSVG_61_oPasovec_0001_FFFF_0001_0001",&KSAlloc_KSVG_61_oPasovec_0001_FFFF_0001_0001,&KSSetV_KSVG_61_oPasovec_0001_FFFF_0001_0001,sizeof(_KSVG_61_oPasovec_0001_FFFF_0001_0001));
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosX_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosY_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_APicture_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_LezeNadVecma_0001_FFFF_0001_0001__M__KN_clzSubGr_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oSeSmerem_0001_FFFF_0001_0001__M_smer_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_WillCalculate_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_Moving_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fsource_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fdir_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fpriority_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_ftype_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fspeed_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fstate_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_BlockedPath_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_BlockingObjs_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_LastDir_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_LastMTime_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_LSpeed_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oManik_0001_FFFF_0001_0001__M_muflon_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oManik_0001_FFFF_0001_0001__M_ziju_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oManik_0001_FFFF_0001_0001__M_SKlice_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oManik_0001_FFFF_0001_0001__M_triger_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oManik_0001_FFFF_0001_0001__M_SBomby_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oManik_0001_FFFF_0001_0001__M_SMiny_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oManik_0001_FFFF_0001_0001__M_KeyBombaDown_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oManik_0001_FFFF_0001_0001__M_KeyMinaDown_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oManik_0001_FFFF_0001_0001__M_koliznik_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oManik_0001_FFFF_0001_0001__M_cellX_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oManik_0001_FFFF_0001_0001__M_cellY_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oManik_0001_FFFF_0001_0001__M_Focus_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oManik_0001_FFFF_0001_0001__M_SZnacky_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oManik_0001_FFFF_0001_0001__M_KeyZnackyDown_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oManik_0001_FFFF_0001_0001__M_KeyZnackyDown1_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oManik_0001_FFFF_0001_0001__M_ZmacknutoA_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oStrka_0001_FFFF_0001_0001__M_CoStrka_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oStrka_0001_FFFF_0001_0001__M__KN_clzFceGr_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oUmiraNaSlizu_0001_FFFF_0001_0001__M_SlizCount_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oUmiraNaSlizu_0001_FFFF_0001_0001__M_SlizSmrtCount_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oUmiraNaSlizu_0001_FFFF_0001_0001__M_SlizMez_0001_FFFF_0001_0001");
tmp = new CKSKSVG("_KSVG_62_oTeleport_0001_FFFF_0001_0001",&KSAlloc_KSVG_62_oTeleport_0001_FFFF_0001_0001,&KSSetV_KSVG_62_oTeleport_0001_FFFF_0001_0001,sizeof(_KSVG_62_oTeleport_0001_FFFF_0001_0001));
tmp->AddAttribute("_KSOV_oTeleport_0001_FFFF_0001_0001__M_DestX_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oTeleport_0001_FFFF_0001_0001__M_DestY_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosX_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosY_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_APicture_0001_FFFF_0001_0001");
tmp = new CKSKSVG("_KSVG_63_oStrkatelne_0001_FFFF_0001_0001",&KSAlloc_KSVG_63_oStrkatelne_0001_FFFF_0001_0001,&KSSetV_KSVG_63_oStrkatelne_0001_FFFF_0001_0001,sizeof(_KSVG_63_oStrkatelne_0001_FFFF_0001_0001));
tmp->AddAttribute("_KSOV_oStrkatelne_0001_FFFF_0001_0001__M_LastStrkac_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oStrkatelne_0001_FFFF_0001_0001__M_StrkTime_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oStrkatelne_0001_FFFF_0001_0001__M_StrkTimeOut_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oStrkatelne_0001_FFFF_0001_0001__M_Time_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosX_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosY_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_APicture_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_WillCalculate_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_Moving_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fsource_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fdir_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fpriority_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_ftype_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fspeed_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fstate_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_BlockedPath_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_BlockingObjs_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_LastDir_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_LastMTime_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_LSpeed_0001_FFFF_0001_0001");
tmp = new CKSKSVG("_KSVG_64_oStrka_0001_FFFF_0001_0001",&KSAlloc_KSVG_64_oStrka_0001_FFFF_0001_0001,&KSSetV_KSVG_64_oStrka_0001_FFFF_0001_0001,sizeof(_KSVG_64_oStrka_0001_FFFF_0001_0001));
tmp->AddAttribute("_KSOV_oStrka_0001_FFFF_0001_0001__M_CoStrka_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oStrka_0001_FFFF_0001_0001__M__KN_clzFceGr_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosX_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosY_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_APicture_0001_FFFF_0001_0001");
tmp = new CKSKSVG("_KSVG_65_oHajzl_0001_FFFF_0001_0001",&KSAlloc_KSVG_65_oHajzl_0001_FFFF_0001_0001,&KSSetV_KSVG_65_oHajzl_0001_FFFF_0001_0001,sizeof(_KSVG_65_oHajzl_0001_FFFF_0001_0001));
tmp->AddAttribute("_KSOV_oHajzl_0001_FFFF_0001_0001__M_MeniNa_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosX_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosY_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_APicture_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oTeleport_0001_FFFF_0001_0001__M_DestX_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oTeleport_0001_FFFF_0001_0001__M_DestY_0001_FFFF_0001_0001");
tmp = new CKSKSVG("_KSVG_67_oTeleport2_0001_FFFF_0001_0001",&KSAlloc_KSVG_67_oTeleport2_0001_FFFF_0001_0001,&KSSetV_KSVG_67_oTeleport2_0001_FFFF_0001_0001,sizeof(_KSVG_67_oTeleport2_0001_FFFF_0001_0001));
tmp->AddAttribute("_KSOV_oTeleport2_0001_FFFF_0001_0001__M_CoTeleportuje_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosX_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosY_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_APicture_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oTeleport_0001_FFFF_0001_0001__M_DestX_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oTeleport_0001_FFFF_0001_0001__M_DestY_0001_FFFF_0001_0001");
tmp = new CKSKSVG("_KSVG_68_oUmiraNaSlizu_0001_FFFF_0001_0001",&KSAlloc_KSVG_68_oUmiraNaSlizu_0001_FFFF_0001_0001,&KSSetV_KSVG_68_oUmiraNaSlizu_0001_FFFF_0001_0001,sizeof(_KSVG_68_oUmiraNaSlizu_0001_FFFF_0001_0001));
tmp->AddAttribute("_KSOV_oUmiraNaSlizu_0001_FFFF_0001_0001__M_SlizCount_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oUmiraNaSlizu_0001_FFFF_0001_0001__M_SlizSmrtCount_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oUmiraNaSlizu_0001_FFFF_0001_0001__M_SlizMez_0001_FFFF_0001_0001");
tmp = new CKSKSVG("_KSVG_69_oSliz_0001_FFFF_0001_0001",&KSAlloc_KSVG_69_oSliz_0001_FFFF_0001_0001,&KSSetV_KSVG_69_oSliz_0001_FFFF_0001_0001,sizeof(_KSVG_69_oSliz_0001_FFFF_0001_0001));
tmp->AddAttribute("_KSOV_oSliz_0001_FFFF_0001_0001__M_triger_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosX_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosY_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_APicture_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_floors_0001_FFFF_0001_0001__M__KN_CollisionCfg_0001_FFFF_0001_0001");
tmp = new CKSKSVG("_KSVG_70_oPriseraSNavadeci_0001_FFFF_0001_0001",&KSAlloc_KSVG_70_oPriseraSNavadeci_0001_FFFF_0001_0001,&KSSetV_KSVG_70_oPriseraSNavadeci_0001_FFFF_0001_0001,sizeof(_KSVG_70_oPriseraSNavadeci_0001_FFFF_0001_0001));
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosX_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosY_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_APicture_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_LezeNadVecma_0001_FFFF_0001_0001__M__KN_clzSubGr_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oSeSmerem_0001_FFFF_0001_0001__M_smer_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_WillCalculate_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_Moving_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fsource_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fdir_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fpriority_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_ftype_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fspeed_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fstate_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_BlockedPath_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_BlockingObjs_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_LastDir_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_LastMTime_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_LSpeed_0001_FFFF_0001_0001");
tmp = new CKSKSVG("_KSVG_71_oManikSliz_0001_FFFF_0001_0001",&KSAlloc_KSVG_71_oManikSliz_0001_FFFF_0001_0001,&KSSetV_KSVG_71_oManikSliz_0001_FFFF_0001_0001,sizeof(_KSVG_71_oManikSliz_0001_FFFF_0001_0001));
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosX_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosY_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_APicture_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_LezeNadVecma_0001_FFFF_0001_0001__M__KN_clzSubGr_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oSeSmerem_0001_FFFF_0001_0001__M_smer_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_WillCalculate_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_Moving_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fsource_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fdir_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fpriority_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_ftype_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fspeed_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fstate_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_BlockedPath_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_BlockingObjs_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_LastDir_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_LastMTime_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_LSpeed_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oManik_0001_FFFF_0001_0001__M_muflon_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oManik_0001_FFFF_0001_0001__M_ziju_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oManik_0001_FFFF_0001_0001__M_SKlice_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oManik_0001_FFFF_0001_0001__M_triger_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oManik_0001_FFFF_0001_0001__M_SBomby_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oManik_0001_FFFF_0001_0001__M_SMiny_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oManik_0001_FFFF_0001_0001__M_KeyBombaDown_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oManik_0001_FFFF_0001_0001__M_KeyMinaDown_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oManik_0001_FFFF_0001_0001__M_koliznik_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oManik_0001_FFFF_0001_0001__M_cellX_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oManik_0001_FFFF_0001_0001__M_cellY_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oManik_0001_FFFF_0001_0001__M_Focus_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oManik_0001_FFFF_0001_0001__M_SZnacky_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oManik_0001_FFFF_0001_0001__M_KeyZnackyDown_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oManik_0001_FFFF_0001_0001__M_KeyZnackyDown1_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oManik_0001_FFFF_0001_0001__M_ZmacknutoA_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oStrka_0001_FFFF_0001_0001__M_CoStrka_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oStrka_0001_FFFF_0001_0001__M__KN_clzFceGr_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oUmiraNaSlizu_0001_FFFF_0001_0001__M_SlizCount_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oUmiraNaSlizu_0001_FFFF_0001_0001__M_SlizSmrtCount_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oUmiraNaSlizu_0001_FFFF_0001_0001__M_SlizMez_0001_FFFF_0001_0001");
tmp = new CKSKSVG("_KSVG_72_oZnacky_0001_FFFF_0001_0001",&KSAlloc_KSVG_72_oZnacky_0001_FFFF_0001_0001,&KSSetV_KSVG_72_oZnacky_0001_FFFF_0001_0001,sizeof(_KSVG_72_oZnacky_0001_FFFF_0001_0001));
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosX_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosY_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_APicture_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_Veci_0001_FFFF_0001_0001__M__KN_clzSubGr_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_WillCalculate_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_Moving_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fsource_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fdir_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fpriority_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_ftype_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fspeed_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fstate_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_BlockedPath_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_BlockingObjs_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_LastDir_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_LastMTime_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_LSpeed_0001_FFFF_0001_0001");
tmp = new CKSKSVG("_KSVG_73_oZnSmerova_0001_FFFF_0001_0001",&KSAlloc_KSVG_73_oZnSmerova_0001_FFFF_0001_0001,&KSSetV_KSVG_73_oZnSmerova_0001_FFFF_0001_0001,sizeof(_KSVG_73_oZnSmerova_0001_FFFF_0001_0001));
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosX_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosY_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_APicture_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_Veci_0001_FFFF_0001_0001__M__KN_clzSubGr_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oSeSmerem_0001_FFFF_0001_0001__M_smer_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_WillCalculate_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_Moving_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fsource_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fdir_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fpriority_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_ftype_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fspeed_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fstate_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_BlockedPath_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_BlockingObjs_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_LastDir_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_LastMTime_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_LSpeed_0001_FFFF_0001_0001");
tmp = new CKSKSVG("_KSVG_74_oZnZakazVjezdu_0001_FFFF_0001_0001",&KSAlloc_KSVG_74_oZnZakazVjezdu_0001_FFFF_0001_0001,&KSSetV_KSVG_74_oZnZakazVjezdu_0001_FFFF_0001_0001,sizeof(_KSVG_74_oZnZakazVjezdu_0001_FFFF_0001_0001));
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosX_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosY_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_APicture_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_Veci_0001_FFFF_0001_0001__M__KN_clzSubGr_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_WillCalculate_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_Moving_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fsource_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fdir_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fpriority_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_ftype_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fspeed_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fstate_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_BlockedPath_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_BlockingObjs_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_LastDir_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_LastMTime_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_LSpeed_0001_FFFF_0001_0001");
tmp = new CKSKSVG("_KSVG_75_oZnSedesat_0001_FFFF_0001_0001",&KSAlloc_KSVG_75_oZnSedesat_0001_FFFF_0001_0001,&KSSetV_KSVG_75_oZnSedesat_0001_FFFF_0001_0001,sizeof(_KSVG_75_oZnSedesat_0001_FFFF_0001_0001));
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosX_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosY_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_APicture_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_Veci_0001_FFFF_0001_0001__M__KN_clzSubGr_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_WillCalculate_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_Moving_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fsource_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fdir_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fpriority_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_ftype_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fspeed_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fstate_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_BlockedPath_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_BlockingObjs_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_LastDir_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_LastMTime_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_LSpeed_0001_FFFF_0001_0001");
tmp = new CKSKSVG("_KSVG_76_oZnNeSedesat_0001_FFFF_0001_0001",&KSAlloc_KSVG_76_oZnNeSedesat_0001_FFFF_0001_0001,&KSSetV_KSVG_76_oZnNeSedesat_0001_FFFF_0001_0001,sizeof(_KSVG_76_oZnNeSedesat_0001_FFFF_0001_0001));
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosX_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosY_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_APicture_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_Veci_0001_FFFF_0001_0001__M__KN_clzSubGr_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_WillCalculate_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_Moving_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fsource_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fdir_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fpriority_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_ftype_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fspeed_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fstate_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_BlockedPath_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_BlockingObjs_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_LastDir_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_LastMTime_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_LSpeed_0001_FFFF_0001_0001");
tmp = new CKSKSVG("_KSVG_77_oPriseraZnackova_0001_FFFF_0001_0001",&KSAlloc_KSVG_77_oPriseraZnackova_0001_FFFF_0001_0001,&KSSetV_KSVG_77_oPriseraZnackova_0001_FFFF_0001_0001,sizeof(_KSVG_77_oPriseraZnackova_0001_FFFF_0001_0001));
tmp->AddAttribute("_KSOV_oPriseraZnackova_0001_FFFF_0001_0001__M_Rychlost_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosX_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosY_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_APicture_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_LezeNadVecma_0001_FFFF_0001_0001__M__KN_clzSubGr_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oSeSmerem_0001_FFFF_0001_0001__M_smer_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_WillCalculate_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_Moving_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fsource_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fdir_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fpriority_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_ftype_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fspeed_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fstate_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_BlockedPath_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_BlockingObjs_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_LastDir_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_LastMTime_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_LSpeed_0001_FFFF_0001_0001");
tmp = new CKSKSVG("_KSVG_78_oPriseraDopravni_0001_FFFF_0001_0001",&KSAlloc_KSVG_78_oPriseraDopravni_0001_FFFF_0001_0001,&KSSetV_KSVG_78_oPriseraDopravni_0001_FFFF_0001_0001,sizeof(_KSVG_78_oPriseraDopravni_0001_FFFF_0001_0001));
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosX_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosY_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_APicture_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_LezeNadVecma_0001_FFFF_0001_0001__M__KN_clzSubGr_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oSeSmerem_0001_FFFF_0001_0001__M_smer_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_WillCalculate_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_Moving_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fsource_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fdir_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fpriority_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_ftype_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fspeed_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fstate_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_BlockedPath_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_BlockingObjs_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_LastDir_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_LastMTime_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_LSpeed_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oPriseraZnackova_0001_FFFF_0001_0001__M_Rychlost_0001_FFFF_0001_0001");
tmp = new CKSKSVG("_KSVG_79_oPriseraKlaustrofobni_0001_FFFF_0001_0001",&KSAlloc_KSVG_79_oPriseraKlaustrofobni_0001_FFFF_0001_0001,&KSSetV_KSVG_79_oPriseraKlaustrofobni_0001_FFFF_0001_0001,sizeof(_KSVG_79_oPriseraKlaustrofobni_0001_FFFF_0001_0001));
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosX_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosY_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_APicture_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_LezeNadVecma_0001_FFFF_0001_0001__M__KN_clzSubGr_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oSeSmerem_0001_FFFF_0001_0001__M_smer_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_WillCalculate_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_Moving_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fsource_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fdir_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fpriority_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_ftype_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fspeed_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fstate_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_BlockedPath_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_BlockingObjs_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_LastDir_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_LastMTime_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_LSpeed_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oPriseraZnackova_0001_FFFF_0001_0001__M_Rychlost_0001_FFFF_0001_0001");
tmp = new CKSKSVG("_KSVG_84_oScriptedTest_0001_FFFF_0001_0001",&KSAlloc_KSVG_84_oScriptedTest_0001_FFFF_0001_0001,&KSSetV_KSVG_84_oScriptedTest_0001_FFFF_0001_0001,sizeof(_KSVG_84_oScriptedTest_0001_FFFF_0001_0001));
tmp->AddAttribute("_KSOV_oScriptedTest_0001_FFFF_0001_0001__M_blb_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oScriptedTest_0001_FFFF_0001_0001__M_chr_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oScriptedTest_0001_FFFF_0001_0001__M_pole_0001_FFFF_0001_0001");
tmp = new CKSKSVG("_KSVG_85_oPrepinace_0001_FFFF_0001_0001",&KSAlloc_KSVG_85_oPrepinace_0001_FFFF_0001_0001,&KSSetV_KSVG_85_oPrepinace_0001_FFFF_0001_0001,sizeof(_KSVG_85_oPrepinace_0001_FFFF_0001_0001));
tmp->AddAttribute("_KSOV_oPrepinace_0001_FFFF_0001_0001__M_PocetAkci_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oPrepinace_0001_FFFF_0001_0001__M_DruhAkce_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oPrepinace_0001_FFFF_0001_0001__M_Pusobnost_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oPrepinace_0001_FFFF_0001_0001__M_Prepina_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oPrepinace_0001_FFFF_0001_0001__M_Nekoliduj_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oPrepinace_0001_FFFF_0001_0001__M_Akce_0001_FFFF_0001_0001");
tmp = new CKSKSVG("_KSVG_86_oPrepinac_0001_FFFF_0001_0001",&KSAlloc_KSVG_86_oPrepinac_0001_FFFF_0001_0001,&KSSetV_KSVG_86_oPrepinac_0001_FFFF_0001_0001,sizeof(_KSVG_86_oPrepinac_0001_FFFF_0001_0001));
tmp->AddAttribute("_KSOV_oPrepinac_0001_FFFF_0001_0001__M_OnOff_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oPrepinac_0001_FFFF_0001_0001__M_prepnuto_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oPrepinac_0001_FFFF_0001_0001__M_time_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosX_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosY_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_APicture_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oPrepinace_0001_FFFF_0001_0001__M_PocetAkci_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oPrepinace_0001_FFFF_0001_0001__M_DruhAkce_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oPrepinace_0001_FFFF_0001_0001__M_Pusobnost_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oPrepinace_0001_FFFF_0001_0001__M_Prepina_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oPrepinace_0001_FFFF_0001_0001__M_Nekoliduj_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oPrepinace_0001_FFFF_0001_0001__M_Akce_0001_FFFF_0001_0001");
tmp = new CKSKSVG("_KSVG_87_oTriggerPrepinac_0001_FFFF_0001_0001",&KSAlloc_KSVG_87_oTriggerPrepinac_0001_FFFF_0001_0001,&KSSetV_KSVG_87_oTriggerPrepinac_0001_FFFF_0001_0001,sizeof(_KSVG_87_oTriggerPrepinac_0001_FFFF_0001_0001));
tmp->AddAttribute("_KSOV_oTriggerPrepinac_0001_FFFF_0001_0001__M_OnOff_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oTriggerPrepinac_0001_FFFF_0001_0001__M_citac_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oTriggerPrepinac_0001_FFFF_0001_0001__M_Reaguje_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oTriggerPrepinac_0001_FFFF_0001_0001__M_triger_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oPrepinace_0001_FFFF_0001_0001__M_PocetAkci_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oPrepinace_0001_FFFF_0001_0001__M_DruhAkce_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oPrepinace_0001_FFFF_0001_0001__M_Pusobnost_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oPrepinace_0001_FFFF_0001_0001__M_Prepina_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oPrepinace_0001_FFFF_0001_0001__M_Nekoliduj_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oPrepinace_0001_FFFF_0001_0001__M_Akce_0001_FFFF_0001_0001");
tmp = new CKSKSVG("_KSVG_88_oFotobunka_0001_FFFF_0001_0001",&KSAlloc_KSVG_88_oFotobunka_0001_FFFF_0001_0001,&KSSetV_KSVG_88_oFotobunka_0001_FFFF_0001_0001,sizeof(_KSVG_88_oFotobunka_0001_FFFF_0001_0001));
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosX_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosY_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_APicture_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oPrepinace_0001_FFFF_0001_0001__M_PocetAkci_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oPrepinace_0001_FFFF_0001_0001__M_DruhAkce_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oPrepinace_0001_FFFF_0001_0001__M_Pusobnost_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oPrepinace_0001_FFFF_0001_0001__M_Prepina_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oPrepinace_0001_FFFF_0001_0001__M_Nekoliduj_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oPrepinace_0001_FFFF_0001_0001__M_Akce_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oTriggerPrepinac_0001_FFFF_0001_0001__M_OnOff_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oTriggerPrepinac_0001_FFFF_0001_0001__M_citac_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oTriggerPrepinac_0001_FFFF_0001_0001__M_Reaguje_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oTriggerPrepinac_0001_FFFF_0001_0001__M_triger_0001_FFFF_0001_0001");
tmp = new CKSKSVG("_KSVG_89_oNaslapnaPodlaha_0001_FFFF_0001_0001",&KSAlloc_KSVG_89_oNaslapnaPodlaha_0001_FFFF_0001_0001,&KSSetV_KSVG_89_oNaslapnaPodlaha_0001_FFFF_0001_0001,sizeof(_KSVG_89_oNaslapnaPodlaha_0001_FFFF_0001_0001));
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosX_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosY_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_APicture_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_floors_0001_FFFF_0001_0001__M__KN_CollisionCfg_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oPrepinace_0001_FFFF_0001_0001__M_PocetAkci_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oPrepinace_0001_FFFF_0001_0001__M_DruhAkce_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oPrepinace_0001_FFFF_0001_0001__M_Pusobnost_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oPrepinace_0001_FFFF_0001_0001__M_Prepina_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oPrepinace_0001_FFFF_0001_0001__M_Nekoliduj_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oPrepinace_0001_FFFF_0001_0001__M_Akce_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oTriggerPrepinac_0001_FFFF_0001_0001__M_OnOff_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oTriggerPrepinac_0001_FFFF_0001_0001__M_citac_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oTriggerPrepinac_0001_FFFF_0001_0001__M_Reaguje_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oTriggerPrepinac_0001_FFFF_0001_0001__M_triger_0001_FFFF_0001_0001");
tmp = new CKSKSVG("_KSVG_90_oAreaTrigger_0001_FFFF_0001_0001",&KSAlloc_KSVG_90_oAreaTrigger_0001_FFFF_0001_0001,&KSSetV_KSVG_90_oAreaTrigger_0001_FFFF_0001_0001,sizeof(_KSVG_90_oAreaTrigger_0001_FFFF_0001_0001));
tmp->AddAttribute("_KSOV_oAreaTrigger_0001_FFFF_0001_0001__M__KN_ObjPosX_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oAreaTrigger_0001_FFFF_0001_0001__M__KN_ObjPosY_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oAreaTrigger_0001_FFFF_0001_0001__M__KN_CollisionCfg_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oAreaTrigger_0001_FFFF_0001_0001__M__KN_BCubeX1_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oAreaTrigger_0001_FFFF_0001_0001__M__KN_BCubeY1_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oAreaTrigger_0001_FFFF_0001_0001__M__KN_BCubeZ1_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oAreaTrigger_0001_FFFF_0001_0001__M__KN_BCubeX2_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oAreaTrigger_0001_FFFF_0001_0001__M__KN_BCubeY2_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oAreaTrigger_0001_FFFF_0001_0001__M__KN_BCubeZ2_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oAreaTrigger_0001_FFFF_0001_0001__M__KN_clzAddGr_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oAreaTrigger_0001_FFFF_0001_0001__M__KN_clzSubGr_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oAreaTrigger_0001_FFFF_0001_0001__M__KN_MsgRedirect_0001_FFFF_0001_0001");
tmp = new CKSKSVG("_KSVG_91_oDracekTriggerHelper_0001_FFFF_0001_0001",&KSAlloc_KSVG_91_oDracekTriggerHelper_0001_FFFF_0001_0001,&KSSetV_KSVG_91_oDracekTriggerHelper_0001_FFFF_0001_0001,sizeof(_KSVG_91_oDracekTriggerHelper_0001_FFFF_0001_0001));
tmp->AddAttribute("_KSOV_oDracekTriggerHelper_0001_FFFF_0001_0001__M_dracek_0001_FFFF_0001_0001");
tmp = new CKSKSVG("_KSVG_92_oGlobalniPrepinac_0001_FFFF_0001_0001",&KSAlloc_KSVG_92_oGlobalniPrepinac_0001_FFFF_0001_0001,&KSSetV_KSVG_92_oGlobalniPrepinac_0001_FFFF_0001_0001,sizeof(_KSVG_92_oGlobalniPrepinac_0001_FFFF_0001_0001));
tmp->AddAttribute("_KSOV_oGlobalniPrepinac_0001_FFFF_0001_0001__M_x1_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oGlobalniPrepinac_0001_FFFF_0001_0001__M_y1_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oGlobalniPrepinac_0001_FFFF_0001_0001__M_x2_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oGlobalniPrepinac_0001_FFFF_0001_0001__M_y2_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oGlobalniPrepinac_0001_FFFF_0001_0001__M_Reaguj_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oGlobalniPrepinac_0001_FFFF_0001_0001__M_Ignoruj_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oPrepinace_0001_FFFF_0001_0001__M_PocetAkci_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oPrepinace_0001_FFFF_0001_0001__M_DruhAkce_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oPrepinace_0001_FFFF_0001_0001__M_Pusobnost_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oPrepinace_0001_FFFF_0001_0001__M_Prepina_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oPrepinace_0001_FFFF_0001_0001__M_Nekoliduj_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oPrepinace_0001_FFFF_0001_0001__M_Akce_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oTriggerPrepinac_0001_FFFF_0001_0001__M_OnOff_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oTriggerPrepinac_0001_FFFF_0001_0001__M_citac_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oTriggerPrepinac_0001_FFFF_0001_0001__M_Reaguje_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oTriggerPrepinac_0001_FFFF_0001_0001__M_triger_0001_FFFF_0001_0001");
tmp = new CKSKSVG("_KSVG_93_oOpatrnaPrisera_0001_FFFF_0001_0001",&KSAlloc_KSVG_93_oOpatrnaPrisera_0001_FFFF_0001_0001,&KSSetV_KSVG_93_oOpatrnaPrisera_0001_FFFF_0001_0001,sizeof(_KSVG_93_oOpatrnaPrisera_0001_FFFF_0001_0001));
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosX_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosY_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_APicture_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_LezeNadVecma_0001_FFFF_0001_0001__M__KN_clzSubGr_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oSeSmerem_0001_FFFF_0001_0001__M_smer_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_WillCalculate_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_Moving_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fsource_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fdir_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fpriority_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_ftype_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fspeed_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fstate_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_BlockedPath_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_BlockingObjs_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_LastDir_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_LastMTime_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_LSpeed_0001_FFFF_0001_0001");
tmp = new CKSKSVG("_KSVG_94_oSvetlo_0001_FFFF_0001_0001",&KSAlloc_KSVG_94_oSvetlo_0001_FFFF_0001_0001,&KSSetV_KSVG_94_oSvetlo_0001_FFFF_0001_0001,sizeof(_KSVG_94_oSvetlo_0001_FFFF_0001_0001));
tmp->AddAttribute("_KSOV_oSvetlo_0001_FFFF_0001_0001__M_r_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oSvetlo_0001_FFFF_0001_0001__M_g_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oSvetlo_0001_FFFF_0001_0001__M_b_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oSvetlo_0001_FFFF_0001_0001__M_radius_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oSvetlo_0001_FFFF_0001_0001__M_vyska_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oSvetlo_0001_FFFF_0001_0001__M_svetlo_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oSvetlo_0001_FFFF_0001_0001__M__KN_CollisionCfg_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosX_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosY_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_APicture_0001_FFFF_0001_0001");
tmp = new CKSKSVG("_KSVG_95_oGlobalniSvetlo_0001_FFFF_0001_0001",&KSAlloc_KSVG_95_oGlobalniSvetlo_0001_FFFF_0001_0001,&KSSetV_KSVG_95_oGlobalniSvetlo_0001_FFFF_0001_0001,sizeof(_KSVG_95_oGlobalniSvetlo_0001_FFFF_0001_0001));
tmp->AddAttribute("_KSOV_oGlobalniSvetlo_0001_FFFF_0001_0001__M_r_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oGlobalniSvetlo_0001_FFFF_0001_0001__M_g_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oGlobalniSvetlo_0001_FFFF_0001_0001__M_b_0001_FFFF_0001_0001");
tmp = new CKSKSVG("_KSVG_96_oPriseraSeZvukem1_0001_FFFF_0001_0001",&KSAlloc_KSVG_96_oPriseraSeZvukem1_0001_FFFF_0001_0001,&KSSetV_KSVG_96_oPriseraSeZvukem1_0001_FFFF_0001_0001,sizeof(_KSVG_96_oPriseraSeZvukem1_0001_FFFF_0001_0001));
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosX_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosY_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_APicture_0001_FFFF_0001_0001");
tmp = new CKSKSVG("_KSVG_97_oPriseraSeZvukem2_0001_FFFF_0001_0001",&KSAlloc_KSVG_97_oPriseraSeZvukem2_0001_FFFF_0001_0001,&KSSetV_KSVG_97_oPriseraSeZvukem2_0001_FFFF_0001_0001,sizeof(_KSVG_97_oPriseraSeZvukem2_0001_FFFF_0001_0001));
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosX_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosY_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_APicture_0001_FFFF_0001_0001");
tmp = new CKSKSVG("_KSVG_98_oBouraDoSten_0001_FFFF_0001_0001",&KSAlloc_KSVG_98_oBouraDoSten_0001_FFFF_0001_0001,&KSSetV_KSVG_98_oBouraDoSten_0001_FFFF_0001_0001,sizeof(_KSVG_98_oBouraDoSten_0001_FFFF_0001_0001));
tmp->AddAttribute("_KSOV_oBouraDoSten_0001_FFFF_0001_0001__M_cas_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosX_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosY_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_APicture_0001_FFFF_0001_0001");
tmp = new CKSKSVG("_KSVG_99_oPrulezny_0001_FFFF_0001_0001",&KSAlloc_KSVG_99_oPrulezny_0001_FFFF_0001_0001,&KSSetV_KSVG_99_oPrulezny_0001_FFFF_0001_0001,sizeof(_KSVG_99_oPrulezny_0001_FFFF_0001_0001));
tmp->AddAttribute("_KSOV_oPrulezny_0001_FFFF_0001_0001__M__KN_clzSubGr_0001_FFFF_0001_0001");
tmp = new CKSKSVG("_KSVG_100_oProlejza_0001_FFFF_0001_0001",&KSAlloc_KSVG_100_oProlejza_0001_FFFF_0001_0001,&KSSetV_KSVG_100_oProlejza_0001_FFFF_0001_0001,sizeof(_KSVG_100_oProlejza_0001_FFFF_0001_0001));
tmp->AddAttribute("_KSOV_LezeNadVecma_0001_FFFF_0001_0001__M__KN_clzSubGr_0001_FFFF_0001_0001");
tmp = new CKSKSVG("_KSVG_101_oPruleznaStena_0001_FFFF_0001_0001",&KSAlloc_KSVG_101_oPruleznaStena_0001_FFFF_0001_0001,&KSSetV_KSVG_101_oPruleznaStena_0001_FFFF_0001_0001,sizeof(_KSVG_101_oPruleznaStena_0001_FFFF_0001_0001));
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosX_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosY_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_APicture_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oPrulezny_0001_FFFF_0001_0001__M__KN_clzSubGr_0001_FFFF_0001_0001");
tmp = new CKSKSVG("_KSVG_102_OMap_0001_000F_0001_1001",&KSAlloc_KSVG_102_OMap_0001_000F_0001_1001,&KSSetV_KSVG_102_OMap_0001_000F_0001_1001,sizeof(_KSVG_102_OMap_0001_000F_0001_1001));
tmp->AddAttribute("_KSOV_OMap_0001_000F_0001_1001__M_leftx_0001_000F_0001_1001");
tmp->AddAttribute("_KSOV_OMap_0001_000F_0001_1001__M_lefty_0001_000F_0001_1001");
tmp->AddAttribute("_KSOV_OMap_0001_000F_0001_1001__M_rightx_0001_000F_0001_1001");
tmp->AddAttribute("_KSOV_OMap_0001_000F_0001_1001__M_righty_0001_000F_0001_1001");
tmp->AddAttribute("_KSOV_OMap_0001_000F_0001_1001__M_lowerlevel_0001_000F_0001_1001");
tmp->AddAttribute("_KSOV_OMap_0001_000F_0001_1001__M_upperlevel_0001_000F_0001_1001");
tmp->AddAttribute("_KSOV_OMap_0001_000F_0001_1001__M_startx_0001_000F_0001_1001");
tmp->AddAttribute("_KSOV_OMap_0001_000F_0001_1001__M_starty_0001_000F_0001_1001");
tmp->AddAttribute("_KSOV_OMap_0001_000F_0001_1001__M_sizex_0001_000F_0001_1001");
tmp->AddAttribute("_KSOV_OMap_0001_000F_0001_1001__M_sizey_0001_000F_0001_1001");
tmp->AddAttribute("_KSOV_OMap_0001_000F_0001_1001__M_CellType_0001_000F_0001_1001");
tmp->AddAttribute("_KSOV_OMap_0001_000F_0001_1001__M_csizeX_0001_000F_0001_1001");
tmp->AddAttribute("_KSOV_OMap_0001_000F_0001_1001__M_csizeY_0001_000F_0001_1001");
tmp->AddAttribute("_KSOV_OMap_0001_000F_0001_1001__M_csizeZ_0001_000F_0001_1001");
tmp->AddAttribute("_KSOV_OMap_0001_000F_0001_1001__M_grid_0001_000F_0001_1001");
tmp = new CKSKSVG("_KSVG_103_oSkakavaStena_E3CB_FBA9_E57B_1ECD",&KSAlloc_KSVG_103_oSkakavaStena_E3CB_FBA9_E57B_1ECD,&KSSetV_KSVG_103_oSkakavaStena_E3CB_FBA9_E57B_1ECD,sizeof(_KSVG_103_oSkakavaStena_E3CB_FBA9_E57B_1ECD));
tmp->AddAttribute("_KSOV_oSkakavaStena_E3CB_FBA9_E57B_1ECD__M_stav_E3CB_FBA9_E57B_1ECD");
tmp->AddAttribute("_KSOV_oSkakavaStena_E3CB_FBA9_E57B_1ECD__M_faze_E3CB_FBA9_E57B_1ECD");
tmp->AddAttribute("_KSOV_oSkakavaStena_E3CB_FBA9_E57B_1ECD__M_PauzaPredZapnutim_E3CB_FBA9_E57B_1ECD");
tmp->AddAttribute("_KSOV_oSkakavaStena_E3CB_FBA9_E57B_1ECD__M_DobaSkoku_E3CB_FBA9_E57B_1ECD");
tmp->AddAttribute("_KSOV_oSkakavaStena_E3CB_FBA9_E57B_1ECD__M_DobaNaZemi_E3CB_FBA9_E57B_1ECD");
tmp->AddAttribute("_KSOV_oSkakavaStena_E3CB_FBA9_E57B_1ECD__M_OpravduSkace_E3CB_FBA9_E57B_1ECD");
tmp->AddAttribute("_KSOV_oSkakavaStena_E3CB_FBA9_E57B_1ECD__M_JaOdebiram_E3CB_FBA9_E57B_1ECD");
tmp->AddAttribute("_KSOV_oSkakavaStena_E3CB_FBA9_E57B_1ECD__M__KN_ObjPosZ_E3CB_FBA9_E57B_1ECD");
tmp->AddAttribute("_KSOV_oSkakavaStena_E3CB_FBA9_E57B_1ECD__M__KN_CollisionCfg_E3CB_FBA9_E57B_1ECD");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosX_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosY_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_APicture_0001_FFFF_0001_0001");
tmp = new CKSKSVG("_KSVG_104_oMenicGlobalnihoSvetla_3436_6AFC_3322_FB73",&KSAlloc_KSVG_104_oMenicGlobalnihoSvetla_3436_6AFC_3322_FB73,&KSSetV_KSVG_104_oMenicGlobalnihoSvetla_3436_6AFC_3322_FB73,sizeof(_KSVG_104_oMenicGlobalnihoSvetla_3436_6AFC_3322_FB73));
tmp->AddAttribute("_KSOV_oMenicGlobalnihoSvetla_3436_6AFC_3322_FB73__M_stav_3436_6AFC_3322_FB73");
tmp->AddAttribute("_KSOV_oMenicGlobalnihoSvetla_3436_6AFC_3322_FB73__M_r_3436_6AFC_3322_FB73");
tmp->AddAttribute("_KSOV_oMenicGlobalnihoSvetla_3436_6AFC_3322_FB73__M_g_3436_6AFC_3322_FB73");
tmp->AddAttribute("_KSOV_oMenicGlobalnihoSvetla_3436_6AFC_3322_FB73__M_b_3436_6AFC_3322_FB73");
tmp = new CKSKSVG("_KSVG_105_oDynamickeSvetlo_3436_6AFC_3322_FB73",&KSAlloc_KSVG_105_oDynamickeSvetlo_3436_6AFC_3322_FB73,&KSSetV_KSVG_105_oDynamickeSvetlo_3436_6AFC_3322_FB73,sizeof(_KSVG_105_oDynamickeSvetlo_3436_6AFC_3322_FB73));
tmp->AddAttribute("_KSOV_oDynamickeSvetlo_3436_6AFC_3322_FB73__M_svetlo_3436_6AFC_3322_FB73");
tmp->AddAttribute("_KSOV_oDynamickeSvetlo_3436_6AFC_3322_FB73__M_faze_3436_6AFC_3322_FB73");
tmp->AddAttribute("_KSOV_oDynamickeSvetlo_3436_6AFC_3322_FB73__M__KN_CollisionCfg_3436_6AFC_3322_FB73");
tmp->AddAttribute("_KSOV_oDynamickeSvetlo_3436_6AFC_3322_FB73__M_Spojak_3436_6AFC_3322_FB73");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosX_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosY_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_APicture_0001_FFFF_0001_0001");
tmp = new CKSKSVG("_KSVG_106_oCasovac_3436_6AFC_3322_FB73",&KSAlloc_KSVG_106_oCasovac_3436_6AFC_3322_FB73,&KSSetV_KSVG_106_oCasovac_3436_6AFC_3322_FB73,sizeof(_KSVG_106_oCasovac_3436_6AFC_3322_FB73));
tmp->AddAttribute("_KSOV_oCasovac_3436_6AFC_3322_FB73__M_Casy_3436_6AFC_3322_FB73");
tmp->AddAttribute("_KSOV_oCasovac_3436_6AFC_3322_FB73__M_NahRozptyl_3436_6AFC_3322_FB73");
tmp->AddAttribute("_KSOV_oCasovac_3436_6AFC_3322_FB73__M_NahRozptyly_3436_6AFC_3322_FB73");
tmp->AddAttribute("_KSOV_oCasovac_3436_6AFC_3322_FB73__M_Objekty_3436_6AFC_3322_FB73");
tmp->AddAttribute("_KSOV_oCasovac_3436_6AFC_3322_FB73__M_Zprava_3436_6AFC_3322_FB73");
tmp->AddAttribute("_KSOV_oCasovac_3436_6AFC_3322_FB73__M_Zpravy_3436_6AFC_3322_FB73");
tmp->AddAttribute("_KSOV_oCasovac_3436_6AFC_3322_FB73__M_Opakuj_3436_6AFC_3322_FB73");
tmp->AddAttribute("_KSOV_oCasovac_3436_6AFC_3322_FB73__M_faze_3436_6AFC_3322_FB73");
tmp->AddAttribute("_KSOV_oOnOff_0001_FFFF_0001_0001__M_OnOff_0001_FFFF_0001_0001");
tmp = new CKSKSVG("_KSVG_107_oHrbolataP_A1CF_6963_8DA6_D822",&KSAlloc_KSVG_107_oHrbolataP_A1CF_6963_8DA6_D822,&KSSetV_KSVG_107_oHrbolataP_A1CF_6963_8DA6_D822,sizeof(_KSVG_107_oHrbolataP_A1CF_6963_8DA6_D822));
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosX_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosY_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_APicture_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_floors_0001_FFFF_0001_0001__M__KN_CollisionCfg_0001_FFFF_0001_0001");
tmp = new CKSKSVG("_KSVG_108_oSeSmerem3_A1CF_6963_8DA6_D822",&KSAlloc_KSVG_108_oSeSmerem3_A1CF_6963_8DA6_D822,&KSSetV_KSVG_108_oSeSmerem3_A1CF_6963_8DA6_D822,sizeof(_KSVG_108_oSeSmerem3_A1CF_6963_8DA6_D822));
tmp->AddAttribute("_KSOV_oSeSmerem3_A1CF_6963_8DA6_D822__M_smer_A1CF_6963_8DA6_D822");
tmp = new CKSKSVG("_KSVG_109_oProud_A1CF_6963_8DA6_D822",&KSAlloc_KSVG_109_oProud_A1CF_6963_8DA6_D822,&KSSetV_KSVG_109_oProud_A1CF_6963_8DA6_D822,sizeof(_KSVG_109_oProud_A1CF_6963_8DA6_D822));
tmp->AddAttribute("_KSOV_oProud_A1CF_6963_8DA6_D822__M_Otec1_A1CF_6963_8DA6_D822");
tmp->AddAttribute("_KSOV_oProud_A1CF_6963_8DA6_D822__M_Otec2_A1CF_6963_8DA6_D822");
tmp->AddAttribute("_KSOV_oProud_A1CF_6963_8DA6_D822__M__KN_CollisionCfg_A1CF_6963_8DA6_D822");
tmp->AddAttribute("_KSOV_oProud_A1CF_6963_8DA6_D822__M_triger_A1CF_6963_8DA6_D822");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosX_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosY_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_APicture_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oSeSmerem3_A1CF_6963_8DA6_D822__M_smer_A1CF_6963_8DA6_D822");
tmp = new CKSKSVG("_KSVG_110_oElektroda_A1CF_6963_8DA6_D822",&KSAlloc_KSVG_110_oElektroda_A1CF_6963_8DA6_D822,&KSSetV_KSVG_110_oElektroda_A1CF_6963_8DA6_D822,sizeof(_KSVG_110_oElektroda_A1CF_6963_8DA6_D822));
tmp->AddAttribute("_KSOV_oElektroda_A1CF_6963_8DA6_D822__M_Prouduju_A1CF_6963_8DA6_D822");
tmp->AddAttribute("_KSOV_oElektroda_A1CF_6963_8DA6_D822__M_Proudy_A1CF_6963_8DA6_D822");
tmp->AddAttribute("_KSOV_oElektroda_A1CF_6963_8DA6_D822__M_StartDelay_A1CF_6963_8DA6_D822");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosX_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosY_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_APicture_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oSeSmerem_0001_FFFF_0001_0001__M_smer_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oOnOff_0001_FFFF_0001_0001__M_OnOff_0001_FFFF_0001_0001");
tmp = new CKSKSVG("_KSVG_111_oNitroGlycerin_A1CF_6963_8DA6_D822",&KSAlloc_KSVG_111_oNitroGlycerin_A1CF_6963_8DA6_D822,&KSSetV_KSVG_111_oNitroGlycerin_A1CF_6963_8DA6_D822,sizeof(_KSVG_111_oNitroGlycerin_A1CF_6963_8DA6_D822));
tmp->AddAttribute("_KSOV_oNitroGlycerin_A1CF_6963_8DA6_D822__M_cas2_A1CF_6963_8DA6_D822");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosX_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosY_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_APicture_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_WillCalculate_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_Moving_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fsource_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fdir_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fpriority_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_ftype_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fspeed_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fstate_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_BlockedPath_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_BlockingObjs_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_LastDir_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_LastMTime_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_LSpeed_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oStrkatelne_0001_FFFF_0001_0001__M_LastStrkac_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oStrkatelne_0001_FFFF_0001_0001__M_StrkTime_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oStrkatelne_0001_FFFF_0001_0001__M_StrkTimeOut_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oStrkatelne_0001_FFFF_0001_0001__M_Time_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oBouraDoSten_0001_FFFF_0001_0001__M_cas_0001_FFFF_0001_0001");
tmp = new CKSKSVG("_KSVG_112_oDvere_A1CF_6963_8DA6_D822",&KSAlloc_KSVG_112_oDvere_A1CF_6963_8DA6_D822,&KSSetV_KSVG_112_oDvere_A1CF_6963_8DA6_D822,sizeof(_KSVG_112_oDvere_A1CF_6963_8DA6_D822));
tmp->AddAttribute("_KSOV_oDvere_A1CF_6963_8DA6_D822__M_ReagujeNa_A1CF_6963_8DA6_D822");
tmp->AddAttribute("_KSOV_oDvere_A1CF_6963_8DA6_D822__M_citac_A1CF_6963_8DA6_D822");
tmp->AddAttribute("_KSOV_oDvere_A1CF_6963_8DA6_D822__M_triger_A1CF_6963_8DA6_D822");
tmp->AddAttribute("_KSOV_oDvere_A1CF_6963_8DA6_D822__M_blokovac_A1CF_6963_8DA6_D822");
tmp->AddAttribute("_KSOV_oDvere_A1CF_6963_8DA6_D822__M_OdebiramJa_A1CF_6963_8DA6_D822");
tmp->AddAttribute("_KSOV_oDvere_A1CF_6963_8DA6_D822__M__KN_CollisionCfg_A1CF_6963_8DA6_D822");
tmp->AddAttribute("_KSOV_oDvere_A1CF_6963_8DA6_D822__M_StavOtevreni_A1CF_6963_8DA6_D822");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosX_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosY_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_APicture_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oOnOff_0001_FFFF_0001_0001__M_OnOff_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oSeSmerem3_A1CF_6963_8DA6_D822__M_smer_A1CF_6963_8DA6_D822");
tmp = new CKSKSVG("_KSVG_113_oBlokovacProudu_A1CF_6963_8DA6_D822",&KSAlloc_KSVG_113_oBlokovacProudu_A1CF_6963_8DA6_D822,&KSSetV_KSVG_113_oBlokovacProudu_A1CF_6963_8DA6_D822,sizeof(_KSVG_113_oBlokovacProudu_A1CF_6963_8DA6_D822));
tmp->AddAttribute("_KSOV_oBlokovacProudu_A1CF_6963_8DA6_D822__M__KN_CollisionCfg_A1CF_6963_8DA6_D822");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosX_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosY_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_APicture_0001_FFFF_0001_0001");
tmp = new CKSKSVG("_KSVG_114_oSavePoint_A1CF_6963_8DA6_D822",&KSAlloc_KSVG_114_oSavePoint_A1CF_6963_8DA6_D822,&KSSetV_KSVG_114_oSavePoint_A1CF_6963_8DA6_D822,sizeof(_KSVG_114_oSavePoint_A1CF_6963_8DA6_D822));
tmp->AddAttribute("_KSOV_oSavePoint_A1CF_6963_8DA6_D822__M_triger_A1CF_6963_8DA6_D822");
tmp->AddAttribute("_KSOV_oSavePoint_A1CF_6963_8DA6_D822__M_JenJednou_A1CF_6963_8DA6_D822");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosX_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosY_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_APicture_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_floors_0001_FFFF_0001_0001__M__KN_CollisionCfg_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oOnOff_0001_FFFF_0001_0001__M_OnOff_0001_FFFF_0001_0001");
tmp = new CKSKSVG("_KSVG_115_oLedovaKoule_A1CF_6963_8DA6_D822",&KSAlloc_KSVG_115_oLedovaKoule_A1CF_6963_8DA6_D822,&KSSetV_KSVG_115_oLedovaKoule_A1CF_6963_8DA6_D822,sizeof(_KSVG_115_oLedovaKoule_A1CF_6963_8DA6_D822));
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosX_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_ObjPosY_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_placeable_0001_FFFF_0001_0001__M__KN_APicture_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_WillCalculate_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_Moving_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fsource_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fdir_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fpriority_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_ftype_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fspeed_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_fstate_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_BlockedPath_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_BlockingObjs_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_LastDir_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_LastMTime_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oMoveable_0001_FFFF_0001_0001__M_LSpeed_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oStrkatelne_0001_FFFF_0001_0001__M_LastStrkac_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oStrkatelne_0001_FFFF_0001_0001__M_StrkTime_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oStrkatelne_0001_FFFF_0001_0001__M_StrkTimeOut_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oStrkatelne_0001_FFFF_0001_0001__M_Time_0001_FFFF_0001_0001");
tmp->AddAttribute("_KSOV_oBouraDoSten_0001_FFFF_0001_0001__M_cas_0001_FFFF_0001_0001");
tmp = new CKSKSVG("_KSVG_116_oLevelIntro_A1CF_6963_8DA6_D822",&KSAlloc_KSVG_116_oLevelIntro_A1CF_6963_8DA6_D822,&KSSetV_KSVG_116_oLevelIntro_A1CF_6963_8DA6_D822,sizeof(_KSVG_116_oLevelIntro_A1CF_6963_8DA6_D822));
tmp->AddAttribute("_KSOV_oLevelIntro_A1CF_6963_8DA6_D822__M_FileName_A1CF_6963_8DA6_D822");
tmp->AddAttribute("_KSOV_oLevelIntro_A1CF_6963_8DA6_D822__M_Header_A1CF_6963_8DA6_D822");
}
| 93.710645
| 358
| 0.891873
|
HonzaMD
|
03b42bb2a9da0dbde0aed8332502363b92e2161c
| 870
|
cpp
|
C++
|
0461. Hamming Distance.cpp
|
RickTseng/Cpp_LeetCode
|
6a710b8abc268eba767bc17d91d046b90a7e34a9
|
[
"MIT"
] | 1
|
2021-09-13T00:58:59.000Z
|
2021-09-13T00:58:59.000Z
|
0461. Hamming Distance.cpp
|
RickTseng/Cpp_LeetCode
|
6a710b8abc268eba767bc17d91d046b90a7e34a9
|
[
"MIT"
] | null | null | null |
0461. Hamming Distance.cpp
|
RickTseng/Cpp_LeetCode
|
6a710b8abc268eba767bc17d91d046b90a7e34a9
|
[
"MIT"
] | null | null | null |
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <queue>
using namespace std;
class Solution {
public:
int hammingDistance(int x, int y) {
vector<unsigned long> table(32,1);
for(int i = 1;i<32;i++){
table[i] = table[i-1] * 2;
}
unsigned long z = x^y;
int idx = 31;
int count = 0;
while (z>0)
{
while (table[idx]>z)
{
idx--;
}
z-=table[idx];
count++;
}
return count;
}
};
int main(){
Solution sol;
int ans = sol.hammingDistance(7,0);
}
/*
0 <= x, y <= 2^31 - 1
Runtime: 0 ms, faster than 100.00% of C++ online submissions for Hamming Distance.
Memory Usage: 6 MB, less than 24.75% of C++ online submissions for Hamming Distance.
*/
| 21.219512
| 84
| 0.502299
|
RickTseng
|
03b52bc22b044d681d96ac4ed7ba0b1670943a4d
| 5,351
|
cpp
|
C++
|
src/bindings/swig/wrapped/WrappedInterpreterMonitor.cpp
|
alexzhornyak/uscxml
|
82b44ceeefbe1dc12fc606dc1948f9cebaf67a08
|
[
"BSD-2-Clause"
] | 1
|
2020-01-09T13:51:21.000Z
|
2020-01-09T13:51:21.000Z
|
src/bindings/swig/wrapped/WrappedInterpreterMonitor.cpp
|
galaxy1978/uscxml
|
8be7b9cb67177bb0e34ca5c5cdb8508319bcda2d
|
[
"BSD-2-Clause"
] | 1
|
2021-05-18T12:13:30.000Z
|
2021-05-18T12:14:50.000Z
|
src/bindings/swig/wrapped/WrappedInterpreterMonitor.cpp
|
galaxy1978/uscxml
|
8be7b9cb67177bb0e34ca5c5cdb8508319bcda2d
|
[
"BSD-2-Clause"
] | 1
|
2021-04-08T08:57:40.000Z
|
2021-04-08T08:57:40.000Z
|
/**
* @file
* @author 2012-2014 Stefan Radomski (stefan.radomski@cs.tu-darmstadt.de)
* @copyright Simplified BSD
*
* @cond
* This program is free software: you can redistribute it and/or modify
* it under the terms of the FreeBSD license as published by the FreeBSD
* project.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the FreeBSD license along with this
* program. If not, see <http://www.opensource.org/licenses/bsd-license>.
* @endcond
*/
#include "WrappedInterpreterMonitor.h"
#include "uscxml/util/Predicates.h"
#include "uscxml/util/DOM.h"
#include <xercesc/dom/DOM.hpp>
#include <ostream>
namespace uscxml {
using namespace XERCESC_NS;
WrappedInterpreterMonitor::WrappedInterpreterMonitor() {}
WrappedInterpreterMonitor::~WrappedInterpreterMonitor() {}
void WrappedInterpreterMonitor::beforeExitingState(Interpreter& interpreter, const XERCESC_NS::DOMElement* state) {
std::stringstream ss;
ss << *state;
beforeExitingState(ATTR(state, kXMLCharId), DOMUtils::xPathForNode(state), ss.str());
}
void WrappedInterpreterMonitor::afterExitingState(Interpreter& interpreter, const XERCESC_NS::DOMElement* state) {
std::stringstream ss;
ss << *state;
afterExitingState(ATTR(state, kXMLCharId), DOMUtils::xPathForNode(state), ss.str());
}
void WrappedInterpreterMonitor::beforeExecutingContent(Interpreter& interpreter, const XERCESC_NS::DOMElement* content) {
std::stringstream ss;
ss << *content;
beforeExecutingContent(TAGNAME(content), DOMUtils::xPathForNode(content), ss.str());
}
void WrappedInterpreterMonitor::afterExecutingContent(Interpreter& interpreter, const XERCESC_NS::DOMElement* content) {
std::stringstream ss;
ss << *content;
afterExecutingContent(TAGNAME(content), DOMUtils::xPathForNode(content), ss.str());
}
void WrappedInterpreterMonitor::beforeUninvoking(Interpreter& interpreter, const XERCESC_NS::DOMElement* invoker, const std::string& invokeid) {
std::stringstream ss;
ss << *invoker;
std::string invokeId;
if (invoker->getUserData(kXMLCharInvokeId) != NULL) {
invokeId = (char*)invoker->getUserData(kXMLCharInvokeId);
}
beforeUninvoking(DOMUtils::xPathForNode(invoker), invokeId, ss.str());
}
void WrappedInterpreterMonitor::afterUninvoking(Interpreter& interpreter, const XERCESC_NS::DOMElement* invoker, const std::string& invokeid) {
std::stringstream ss;
ss << *invoker;
std::string invokeId;
if (invoker->getUserData(kXMLCharInvokeId) != NULL) {
invokeId = (char*)invoker->getUserData(kXMLCharInvokeId);
}
afterUninvoking(DOMUtils::xPathForNode(invoker), invokeId, ss.str());
}
void WrappedInterpreterMonitor::beforeTakingTransition(Interpreter& interpreter, const XERCESC_NS::DOMElement* transition) {
XERCESC_NS::DOMElement* sourceState = getSourceState(transition);
const XERCESC_NS::DOMElement* root = DOMUtils::getNearestAncestor(transition, "scxml");
std::list<XERCESC_NS::DOMElement*> targetStates = getTargetStates(transition, root);
std::stringstream ss;
ss << *transition;
std::list<std::string> targets;
for (auto t : targetStates) {
targets.push_back(ATTR_CAST(t, kXMLCharId));
}
beforeTakingTransition(DOMUtils::xPathForNode(transition), ATTR_CAST(sourceState, kXMLCharId), targets, ss.str());
}
void WrappedInterpreterMonitor::afterTakingTransition(Interpreter& interpreter, const XERCESC_NS::DOMElement* transition) {
XERCESC_NS::DOMElement* sourceState = getSourceState(transition);
const XERCESC_NS::DOMElement* root = DOMUtils::getNearestAncestor(transition, "scxml");
std::list<XERCESC_NS::DOMElement*> targetStates = getTargetStates(transition, root);
std::stringstream ss;
ss << *transition;
std::list<std::string> targets;
for (auto t : targetStates) {
targets.push_back(ATTR_CAST(t, kXMLCharId));
}
afterTakingTransition(DOMUtils::xPathForNode(transition), ATTR_CAST(sourceState, kXMLCharId), targets, ss.str());
}
void WrappedInterpreterMonitor::beforeEnteringState(Interpreter& interpreter, const XERCESC_NS::DOMElement* state) {
std::stringstream ss;
ss << *state;
beforeEnteringState(ATTR(state, kXMLCharId), DOMUtils::xPathForNode(state), ss.str());
}
void WrappedInterpreterMonitor::afterEnteringState(Interpreter& interpreter, const XERCESC_NS::DOMElement* state) {
std::stringstream ss;
ss << *state;
afterEnteringState(ATTR(state, kXMLCharId), DOMUtils::xPathForNode(state), ss.str());
}
void WrappedInterpreterMonitor::beforeInvoking(Interpreter& interpreter, const XERCESC_NS::DOMElement* invoker, const std::string& invokeid) {
std::stringstream ss;
ss << *invoker;
std::string invokeId;
if (invoker->getUserData(kXMLCharInvokeId) != NULL) {
invokeId = (char*)invoker->getUserData(kXMLCharInvokeId);
}
beforeInvoking(DOMUtils::xPathForNode(invoker), invokeId, ss.str());
}
void WrappedInterpreterMonitor::afterInvoking(Interpreter& interpreter, const XERCESC_NS::DOMElement* invoker, const std::string& invokeid) {
std::stringstream ss;
ss << *invoker;
std::string invokeId;
if (invoker->getUserData(kXMLCharInvokeId) != NULL) {
invokeId = (char*)invoker->getUserData(kXMLCharInvokeId);
}
afterInvoking(DOMUtils::xPathForNode(invoker), invokeId, ss.str());
}
}
| 36.155405
| 144
| 0.766773
|
alexzhornyak
|
03b7ea5a8fac86854d23be6a42d2ca35a016276e
| 9,127
|
cpp
|
C++
|
Plugin/Popup.cpp
|
wuzijing111/EU4dll
|
5bc107bb7c1f90296bddc1e8643b89f3a7283ef9
|
[
"MIT"
] | 483
|
2018-08-17T12:44:22.000Z
|
2022-03-30T16:49:44.000Z
|
Plugin/Popup.cpp
|
Dawn-of-Higaara/EU4dll
|
c516f00bf729dc2c95cccedb65508c05283e1268
|
[
"MIT"
] | 111
|
2018-08-24T18:43:15.000Z
|
2022-03-07T11:20:10.000Z
|
Plugin/Popup.cpp
|
hangingman/EU4dll
|
e0d2e15eaa10b4642f4f76474c678044acbc9cdd
|
[
"MIT"
] | 95
|
2018-09-17T07:56:04.000Z
|
2022-03-19T04:56:27.000Z
|
#include "stdinc.h"
#include "byte_pattern.h"
// これはpopup windowではなくて、map上で浮かび上がる文字の部分の修正
namespace PopupCharOnMap {
/*-----------------------------------------------*/
uintptr_t func1_v125_end;
__declspec(naked) void func1_v125_start()
{
__asm {
mov eax, [eax + edi];
mov[ebp - 0x5C], eax;
lea ecx, [ebp - 0xAC];
push func1_v125_end;
ret;
}
}
uintptr_t func2_v125_end;
__declspec(naked) void func2_v125_start()
{
__asm {
cmp byte ptr[eax], ESCAPE_SEQ_1;
jz x_4;
cmp byte ptr[eax], ESCAPE_SEQ_2;
jz x_4;
cmp byte ptr[eax], ESCAPE_SEQ_3;
jz x_4;
cmp byte ptr[eax], ESCAPE_SEQ_4;
jz x_4;
jmp x_3;
x_4:
mov ecx, [ebp - 0x5C];
mov[eax], ecx;
lea ecx, [eax];
mov byte ptr[ecx + 0x10], 3;
x_3:
push 0xFFFFFFFF;
push 0;
push eax;
push func2_v125_end;
ret;
}
}
uintptr_t func1_v127_end;
__declspec(naked) void func1_v127_start()
{
__asm {
mov eax, [eax + edi];
mov[ebp - 0x28], eax;
lea ecx, [ebp - 0xD8];
push func1_v127_end;
ret;
}
}
uintptr_t func2_v127_end;
__declspec(naked) void func2_v127_start()
{
__asm {
cmp byte ptr[eax], ESCAPE_SEQ_1;
jz x_4;
cmp byte ptr[eax], ESCAPE_SEQ_2;
jz x_4;
cmp byte ptr[eax], ESCAPE_SEQ_3;
jz x_4;
cmp byte ptr[eax], ESCAPE_SEQ_4;
jz x_4;
jmp x_3;
x_4:
mov ecx, [ebp - 0x28];
mov[eax], ecx;
lea ecx, [eax];
mov byte ptr[ecx + 0x10], 3;
x_3:
push 0xFFFFFFFF;
push 0;
push eax;
push func2_v127_end;
ret;
}
}
/*-----------------------------------------------*/
errno_t func1_2_hook(EU4Version version) {
std::string desc = "func1,2";
switch (version) {
case v1_28_3:
case v1_28_X:
case v1_27_X:
byte_pattern::temp_instance().find_pattern("8A 04 38 8D 8D 28 FF FF FF 88 45 D8");
if (byte_pattern::temp_instance().has_size(1, desc)) {
// mov al,[eax+edi]
injector::MakeJMP(byte_pattern::temp_instance().get_first().address(), func1_v127_start);
// push [ebp+var_28]
func1_v127_end = byte_pattern::temp_instance().get_first().address(0xC);
// push 0FFFFFFFFh
injector::MakeJMP(byte_pattern::temp_instance().get_first().address(0x14), func2_v127_start);
// lea ecx,[ebp+var_AC]
func2_v127_end = byte_pattern::temp_instance().get_first().address(0x19);
}
else return EU4_ERROR1;
return NOERROR;
case v1_25_X:
case v1_26_X:
byte_pattern::temp_instance().find_pattern("8A 04 38 8D 8D 54");
if (byte_pattern::temp_instance().has_size(2, desc)) {
// mov al,[eax+edi]
injector::MakeJMP(byte_pattern::temp_instance().get_first().address(), func1_v125_start);
// push [ebp+var_5C]
func1_v125_end = byte_pattern::temp_instance().get_first().address(0xC);
// push 0FFFFFFFFh
injector::MakeJMP(byte_pattern::temp_instance().get_first().address(0x14), func2_v125_start);
// lea ecx,[ebp+var_7C]
func2_v125_end = byte_pattern::temp_instance().get_first().address(0x19);
}
else return EU4_ERROR1;
return NOERROR;
}
return EU4_ERROR1;
}
/*-----------------------------------------------*/
uintptr_t func3_v125_end;
__declspec(naked) void func3_v125_start()
{
__asm {
cmp byte ptr[eax + edi], ESCAPE_SEQ_1;
jz y_10;
cmp byte ptr[eax + edi], ESCAPE_SEQ_2;
jz y_11;
cmp byte ptr[eax + edi], ESCAPE_SEQ_3;
jz y_12;
cmp byte ptr[eax + edi], ESCAPE_SEQ_4;
jz y_13;
jmp y_7;
y_10:
movzx eax, word ptr[eax + edi + 1];
jmp y_1x;
y_11:
movzx eax, word ptr[eax + edi + 1];
sub eax, SHIFT_2;
jmp y_1x;
y_12:
movzx eax, word ptr[eax + edi + 1];
add eax, SHIFT_3;
jmp y_1x;
y_13:
movzx eax, word ptr[eax + edi + 1];
add eax, SHIFT_4;
y_1x:
movzx eax, ax;
cmp eax, NO_FONT;
ja y_4;
mov eax, NOT_DEF;
y_4:
add edi, 2;
jmp y_6;
y_7:
mov al, [eax + edi];
movzx eax, al;
y_6:
push func3_v125_end;
ret;
}
}
uintptr_t func3_v127_end;
__declspec(naked) void func3_v127_start()
{
__asm {
cmp byte ptr[eax + edi], ESCAPE_SEQ_1;
jz y_10;
cmp byte ptr[eax + edi], ESCAPE_SEQ_2;
jz y_11;
cmp byte ptr[eax + edi], ESCAPE_SEQ_3;
jz y_12;
cmp byte ptr[eax + edi], ESCAPE_SEQ_4;
jz y_13;
jmp y_7;
y_10:
movzx eax, word ptr[eax + edi + 1];
jmp y_1x;
y_11:
movzx eax, word ptr[eax + edi + 1];
sub eax, SHIFT_2;
jmp y_1x;
y_12:
movzx eax, word ptr[eax + edi + 1];
add eax, SHIFT_3;
jmp y_1x;
y_13:
movzx eax, word ptr[eax + edi + 1];
add eax, SHIFT_4;
y_1x:
movzx eax, ax;
cmp eax, NO_FONT;
ja y_4;
mov eax, NOT_DEF;
y_4:
add edi, 2;
jmp y_6;
y_7:
mov al, [eax + edi];
movzx eax, al;
y_6:
mov ecx, [ebp - 0x10];
add ecx, 0xB4;
mov[ebp - 0x20], ecx;
push func3_v127_end;
ret;
}
}
/*-----------------------------------------------*/
errno_t func3_hook(EU4Version version) {
std::string desc = "func 3";
switch (version) {
case v1_28_3:
case v1_28_X:
case v1_27_X:
byte_pattern::temp_instance().find_pattern("8A 04 38 8B 4D F0");
if (byte_pattern::temp_instance().has_size(1, desc)) {
// mov al, [eax+edi]
injector::MakeJMP(byte_pattern::temp_instance().get_first().address(), func3_v127_start);
// mov ecx, [ecx+eax*4]
func3_v127_end = byte_pattern::temp_instance().get_first().address(0x12);
}
else return EU4_ERROR1;
return NOERROR;
case v1_25_X:
case v1_26_X:
byte_pattern::temp_instance().find_pattern("8A 04 38 0F B6");
if (byte_pattern::temp_instance().has_size(1, desc)) {
// mov al, [eax+edi]
injector::MakeJMP(byte_pattern::temp_instance().get_first().address(), func3_v125_start);
// mov edx, [ebx+eax*4+0xB4]
func3_v125_end = byte_pattern::temp_instance().get_first().address(0x6);
}
else return EU4_ERROR1;
return NOERROR;
}
return EU4_ERROR1;
}
/*-----------------------------------------------*/
uintptr_t func4_v125_end;
__declspec(naked) void func4_v125_start()
{
__asm {
cmp byte ptr[eax + esi], ESCAPE_SEQ_1;
jz z_10;
cmp byte ptr[eax + esi], ESCAPE_SEQ_2;
jz z_11;
cmp byte ptr[eax + esi], ESCAPE_SEQ_3;
jz z_12;
cmp byte ptr[eax + esi], ESCAPE_SEQ_4;
jz z_13;
jmp z_5;
z_10:
movzx eax, word ptr[eax + esi + 1];
jmp z_1x;
z_11:
movzx eax, word ptr[eax + esi + 1];
sub eax, SHIFT_2;
jmp z_1x;
z_12:
movzx eax, word ptr[eax + esi + 1];
add eax, SHIFT_3;
jmp z_1x;
z_13:
movzx eax, word ptr[eax + esi + 1];
add eax, SHIFT_4;
z_1x:
movzx eax, ax;
cmp eax, NO_FONT;
ja z_4;
mov eax, NOT_DEF;
z_4:
add esi, 2;
z_6:
mov edx, [edx + eax * 4];
push func4_v125_end;
ret;
z_5:
movzx eax, byte ptr[eax + esi];
jmp z_6;
}
}
uintptr_t func4_v127_end;
__declspec(naked) void func4_v127_start()
{
__asm {
cmp byte ptr[eax + esi], ESCAPE_SEQ_1;
jz z_10;
cmp byte ptr[eax + esi], ESCAPE_SEQ_2;
jz z_11;
cmp byte ptr[eax + esi], ESCAPE_SEQ_3;
jz z_12;
cmp byte ptr[eax + esi], ESCAPE_SEQ_4;
jz z_13;
movzx eax, byte ptr[eax + esi];
jmp z_6;
z_10:
movzx eax, word ptr[eax + esi + 1];
jmp z_1x;
z_11:
movzx eax, word ptr[eax + esi + 1];
sub eax, SHIFT_2;
jmp z_1x;
z_12:
movzx eax, word ptr[eax + esi + 1];
add eax, SHIFT_3;
jmp z_1x;
z_13:
movzx eax, word ptr[eax + esi + 1];
add eax, SHIFT_4;
z_1x:
movzx eax, ax;
cmp eax, NO_FONT;
ja z_4;
mov eax, NOT_DEF;
z_4:
add esi, 2;
mov dword ptr[ebp - 0x2C], esi; // ローカル変数更新
z_6:
movss [ebp - 0xBC], xmm4;
mov eax, [ecx + eax * 4 + 0xB4];
push func4_v127_end;
ret;
}
}
/*-----------------------------------------------*/
errno_t func4_hook(EU4Version version) {
std::string desc = "func 4";
switch (version) {
case v1_28_3:
case v1_28_X:
case v1_27_X:
byte_pattern::temp_instance().find_pattern("0F B6 04 30 F3 0F 11 A5 44 FF FF FF");
if (byte_pattern::temp_instance().has_size(1, desc)) {
// movzx eax, byte ptr [eax+esi]
injector::MakeJMP(byte_pattern::temp_instance().get_first().address(), func4_v127_start);
// mov [ebp+var_20],eax
func4_v127_end = byte_pattern::temp_instance().get_first().address(0x13);
}
else return EU4_ERROR1;
return NOERROR;
case v1_25_X:
case v1_26_X:
byte_pattern::temp_instance().find_pattern("0F B6 04 30 8B 14 82 89 55");
if (byte_pattern::temp_instance().has_size(1, desc)) {
// movzx eax, byte ptr [eax+esi]
injector::MakeJMP(byte_pattern::temp_instance().get_first().address(), func4_v125_start);
// mov [ebp+var_34],edx
func4_v125_end = byte_pattern::temp_instance().get_first().address(0x7);
}
else return EU4_ERROR1;
return NOERROR;
}
return EU4_ERROR1;
}
/*-----------------------------------------------*/
errno_t init(EU4Version version) {
errno_t result = 0;
byte_pattern::temp_instance().debug_output2("popup char on map fix");
//
result |= func1_2_hook(version);
//
result |= func3_hook(version);
//
result |= func4_hook(version);
return result;
}
}
| 20.743182
| 97
| 0.610058
|
wuzijing111
|
03c7850465d7a16defa548b1eb42750238879a4b
| 30,853
|
cpp
|
C++
|
src/SDIMCompiler/Parser.cpp
|
DamienHenderson/SDIM
|
623ac00402a68a504451c3b7c76cd16fde2fa57e
|
[
"MIT"
] | null | null | null |
src/SDIMCompiler/Parser.cpp
|
DamienHenderson/SDIM
|
623ac00402a68a504451c3b7c76cd16fde2fa57e
|
[
"MIT"
] | null | null | null |
src/SDIMCompiler/Parser.cpp
|
DamienHenderson/SDIM
|
623ac00402a68a504451c3b7c76cd16fde2fa57e
|
[
"MIT"
] | null | null | null |
#include "Parser.hpp"
#include <Utils.hpp>
#include <random>
#include <unordered_map>
#include "BytecodeGenerator.hpp"
namespace SDIM
{
Token GetToken(const std::vector<Token>& tokens, size_t idx)
{
if (idx >= tokens.size())
{
Utils::Log("Attempted to read past end of tokens");
return Token(TokenType::Unknown, "");
}
return tokens[idx];
}
Parser::Parser()
{
rng_ = std::make_unique<std::default_random_engine>((std::random_device())());
}
Parser::~Parser()
{
}
bool Parser::Parse(const std::vector<SDIM::Token>& tokens, std::vector<unsigned char>& program_data, Generator* generator)
{
#ifdef SDIM_VERBOSE
// for (const auto& token : tokens )
// {
// Utils::Log(token.ToString());
// }
#endif
// Utilises pratt parsing
// inspired by this webpage http://journal.stuffwithstuff.com/2011/03/19/pratt-parsers-expression-parsing-made-easy/
// also inspired by this webpage http://craftinginterpreters.com/compiling-expressions.html
// also inspired by other sources
current_token = 0;
bool res = ParseModuleDeclaration(tokens, program_data, generator);
generator->WriteHaltInstruction(program_data);
return res;
}
bool Parser::ParseModuleDeclaration(const std::vector<SDIM::Token>& tokens, std::vector<unsigned char>& program_data, Generator* generator)
{
Token expect_module_token = GetToken(tokens, current_token++);
if (!MatchToken(expect_module_token, TokenType::Module))
{
Error(expect_module_token, "Expected module keyword");
return false;
}
// module so the following token should be an identifier
Token expect_module_name_token = GetToken(tokens, current_token++);
if (MatchToken(expect_module_name_token, TokenType::Identifier))
{
Token expect_left_brace = GetToken(tokens, current_token++);
if (MatchToken(expect_left_brace, TokenType::LeftBrace))
{
// brackets_.push(expect_left_brace.token_type);
// correctly formed module statement
// scopes_.push_back(ScopingBlock(expect_module_name_token.lexeme));
// TODO: handle modules correctly
Utils::Log("Found module: ", expect_module_name_token.lexeme);
OpenScope();
// TODO: ParseTopLevelScope Function
// Top level scopes should only contain functions
while (ParseFunctionDeclaration(tokens, program_data, generator))
{
}
--current_token;
CloseScope();
return ConsumeToken(tokens, TokenType::RightBrace, "Expected } before EOF token");
}
else
{
Error(expect_module_name_token, "Expected { to open scoping block for module");
return false;
}
}
else
{
// Module names must be an identifier
Error(expect_module_name_token, "Expected module name");
return false;
}
}
bool Parser::ParseExpression(const std::vector<SDIM::Token>& tokens, std::vector<unsigned char>& program_data, Generator* generator)
{
bool res = ParsePrecedence(tokens, program_data, generator, Precedence::Assignment);
if (!res)
{
return false;
}
return true;
// return ConsumeToken(tokens, TokenType::SemiColon, "Expected ;");
/*
#ifdef SDIM_VERBOSE
for (const auto& it : scopes_)
{
// newlines between scopes
Utils::Log("");
it.PrintScope();
}
#endif
Utils::Log("");
if (GetToken(tokens, .empty())
{
Utils::Log("No GetToken(tokens, found in compilation input");
return false;
}
if (current_token >= GetToken(tokens, .size())
{
Utils::Log("Reached end of GetToken(tokens, ");
return true;
}
Token next_token = GetToken(tokens, [current_token];
Utils::Log("Parsing token ", next_token.ToString());
// TODO: move all of these into functions to make this tidier
if (next_token.token_type == TokenType::NumericLiteral)
{
bool res = ParseNumericLiteral(tokens, program_data, generator);
if (!res)
{
Utils::Log("Failed to parse numeric literal");
}
// return ParseExpression(tokens, program_data, generator, current_token + 1);
}
if (next_token.token_type == TokenType::Return)
{
// return
// return will need to process an expression stopping at a semicolon
// for now do it the hacky way
// TODO: string returns?
// TODO: return value in variable
if (GetToken(tokens, [current_token + 1].token_type == TokenType::NumericLiteral && GetToken(tokens, [current_token + 2].token_type == TokenType::SemiColon)
{
Advance();
bool res = ParseNumericLiteral(tokens, program_data, generator);
if (!res)
{
Utils::Log("Failed to parse numeric literal following return statement");
}
}
generator->WriteReturnInstruction(program_data);
}
if (next_token.token_type == TokenType::Identifier)
{
ScopingBlock& current_scope = scopes_.back();
// test against built in types
for (UInt8 i = 0; i < Utils::VariableTypeToUInt8(VariableType::Unknown); i++)
{
if (next_token.lexeme == variable_type_strings[i])
{
Utils::Log("Found Type specifier for type: ", variable_type_strings[i]);
Token expect_identifier_token = GetToken(tokens, [current_token + 1];
if (expect_identifier_token.token_type == TokenType::Identifier)
{
// found identifier for type declaration good
std::string var_name = expect_identifier_token.lexeme;
Token expect_bracket_or_equal_token = GetToken(tokens, [current_token + 2];
// TODO: process args
if (expect_bracket_or_equal_token.token_type == TokenType::LeftBracket)
{
// function
// add the left bracket to the bracket matching
brackets_.push(expect_bracket_or_equal_token.token_type);
// size_t next_token_idx = 0;
bool res = ParseFunctionDeclaration(tokens, program_data, generator, static_cast<VariableType>(i), var_name);
if (!res)
{
// malformed function declaration
}
return ParseExpression(tokens, program_data, generator);
}
else if (expect_bracket_or_equal_token.token_type == TokenType::Equal)
{
// var assignment
// need to verify validity of assignment
Utils::Log("Attempting declaration and assignment of ", var_name, " in scope ", current_scope.GetName());
// temporary
current_token += 4;
return ParseExpression(tokens, program_data, generator);
}
else if (expect_bracket_or_equal_token.token_type == TokenType::SemiColon)
{
// just declaration without initialisation
// ScopingBlock& current_scope = scopes_.back();
Utils::Log("Attempting to add variable to scope ", current_scope.GetName());
bool res = current_scope.AddVariable(var_name, SDIM::Variable(static_cast<VariableType>(i)));
if (!res)
{
Utils::Log("Attempt to redeclare ", var_name);
}
Utils::Log("Added variable ", var_name, " to scope ", current_scope.GetName());
switch (static_cast<VariableType>(i))
{
case VariableType::UInt8:
generator->WritePushUInt8Instruction(program_data, 0);
break;
case VariableType::UInt16:
generator->WritePushUInt16Instruction(program_data, 0);
break;
case VariableType::UInt32:
generator->WritePushUInt32Instruction(program_data, 0);
break;
case VariableType::UInt64:
generator->WritePushUInt64Instruction(program_data, 0);
break;
case VariableType::Int8:
generator->WritePushInt8Instruction(program_data, 0);
break;
case VariableType::Int16:
generator->WritePushInt16Instruction(program_data, 0);
break;
case VariableType::Int32:
generator->WritePushInt32Instruction(program_data, 0);
break;
case VariableType::Int64:
generator->WritePushInt64Instruction(program_data, 0);
break;
case VariableType::F32:
generator->WritePushF32Instruction(program_data, 0.0f);
break;
case VariableType::F64:
generator->WritePushF64Instruction(program_data, 0.0);
break;
default:
break;
}
return ParseExpression(tokens, program_data, generator);
}
else
{
Utils::Log("Malformed variable or function definition ", var_name);
// malformed
return ParseExpression(tokens, program_data, generator);
}
}
// TODO: process type specifier for function and variable declarations
return ParseExpression(tokens, program_data, generator);
}
}
}
++current_token;
return ParseExpression(tokens, program_data, generator);
// return true;
*/
}
bool Parser::ParseFunctionDeclaration(const std::vector<SDIM::Token>& tokens, std::vector<unsigned char>& program_data, Generator* generator)
{
(void)program_data;
(void)generator;
if (current_token >= tokens.size())
{
Error(GetToken(tokens, tokens.size() - 1), "Reached end of file");
return false;
}
Token expect_type = GetToken(tokens, current_token++);
if (!MatchToken(expect_type, TokenType::Identifier))
{
Error(expect_type, "Expected type specifier for function declaration");
return false;
}
VariableType func_return = TokenToVariableType(expect_type);
if (func_return == VariableType::Unknown)
{
Error(expect_type, "Expected type specifier for function declaration");
return false;
}
Token expect_func_name = GetToken(tokens, current_token++);
if (!MatchToken(expect_type, TokenType::Identifier))
{
Error(expect_func_name, "Expected function name for function declaration");
return false;
}
std::string func_name = expect_func_name.lexeme;
Function func;
func.name = func_name;
for (const auto& it : funcs_)
{
if (it.name == func.name)
{
Error(expect_func_name, "Redefinition of previously defined function (SDIM does not currently support overloaded functions)");
return false;
}
}
func.addr = program_data.size();
func.func_ret = func_return;
funcs_.push_back(func);
Utils::Log("Found func: ", func_name);
// TODO: make this function handle function scope generating bytecode under a function
// Is that even necessary because the bytecode for a function will be written after the function declaration is processed anyway
// separate scopes for args and the function to allow redecleration of variables in function scope which exist in args scope
// this pattern follows the way C++ does it, not in terms of scope naming however
// the best part of this is the scope name doesn't even have to be unique so name collisions with other functions and modules are not an issue
if (!ConsumeToken(tokens, TokenType::LeftBracket, "Expected left bracket for function declaration"))
{
return false;
}
// Parse args list here
if (!ConsumeToken(tokens, TokenType::RightBracket, "Expected right bracket to close function args list declaration"))
{
return false;
}
const char* entrypoint_name = "Main";
Utils::Log("Function ", variable_type_strings[static_cast<UInt8>(func_return)], " ", func_name, " defined at bytecode address ", program_data.size());
if (func_name == entrypoint_name)
{
// found main
Utils::Log("Found entrypoint at: ", program_data.size());
BytecodeGenerator* gen = (BytecodeGenerator*)generator;
gen->GetHeader().entrypoint_idx = program_data.size();
}
// args scope
OpenScope();
// scopes_.push_back(func_args_scope);
// handle args list
ConsumeToken(tokens, TokenType::LeftBrace, "Expected opening brace for function scope");
// func scope
bool res = ParseBlock(tokens, program_data, generator);
if (!res)
{
return false;
}
ConsumeToken(tokens, TokenType::RightBrace, "Expected closing brace for function scope");
// pop func scope
// CloseScope();
// pop args scope
CloseScope();
// next_token_idx = current_token + 1;
return true;
}
bool Parser::ParseNumericLiteral(const std::vector<SDIM::Token> & tokens, std::vector<unsigned char> & program_data, Generator * generator)
{
Token token = GetToken(tokens, current_token - 1);
Utils::Log("Numeric literal: ", token.lexeme);
if (token.lexeme.find(".") != token.lexeme.npos)
{
if (token.lexeme.find("f") != token.lexeme.npos)
{
// 32 bit float
F32 num = static_cast<F32>(std::atof(token.lexeme.c_str()));
generator->WritePushF32Instruction(program_data, num);
}
else
{
// 64 bit float
F64 num = std::atof(token.lexeme.c_str());
generator->WritePushF64Instruction(program_data, num);
}
}
else
{
// integer literal
Int64 num = std::atoll(token.lexeme.c_str());
generator->WritePushInt64Instruction(program_data, num);
}
return true;
}
bool Parser::ParseStringLiteral(const std::vector<SDIM::Token> & tokens, std::vector<unsigned char> & program_data, Generator * generator)
{
Token expect_string = GetToken(tokens, current_token - 1);
if (!MatchToken(expect_string, TokenType::StringLiteral))
{
Error(expect_string, "Expected string literal");
return false;
}
generator->WritePushStringInstruction(program_data, expect_string.lexeme.c_str());
// Advance();
return true;
}
/*
bool Parser::ParseVariableDeclaration(const std::vector<SDIM::Token> & tokens, std::vector<unsigned char> & program_data, Generator * generator)
{
(void)tokens;
(void)program_data;
(void)generator;
return false;
}
*/
bool Parser::ParseAssignment(const std::vector<SDIM::Token> & tokens, std::vector<unsigned char> & program_data, Generator * generator)
{
(void)tokens;
(void)program_data;
(void)generator;
// TODO: handle assignment
bool res = ParseExpression(tokens, program_data, generator);
if (!res)
{
return false;
}
return true;
}
bool Parser::ParseGrouping(const std::vector<SDIM::Token> & tokens, std::vector<unsigned char> & program_data, Generator * generator)
{
bool res = ParseExpression(tokens, program_data, generator);
if (!res)
{
return false;
}
bool close_bracket = MatchToken(GetToken(tokens, current_token), TokenType::RightBracket);
if (!close_bracket)
{
Error(GetToken(tokens, current_token), "Expected closing right bracket in grouped expression");
return false;
}
Advance();
return true;
}
bool Parser::ParseUnary(const std::vector<SDIM::Token> & tokens, std::vector<unsigned char> & program_data, Generator * generator)
{
TokenType op_type = GetToken(tokens, current_token - 1).token_type;
// evaluate the rest of the expression the unary operator is operating on
bool res = ParseExpression(tokens, program_data, generator);
if (!res)
{
return false;
}
if (op_type == TokenType::Minus)
{
generator->WriteNegateInstruction(program_data);
return true;
}
else if (op_type == TokenType::MinusMinus)
{
generator->WritePushInt64Instruction(program_data, -1);
generator->WriteSubtractInstruction(program_data);
return true;
}
else if (op_type == TokenType::PlusPlus)
{
generator->WritePushUInt64Instruction(program_data, 1);
generator->WriteAddInstruction(program_data);
return true;
}
else
{
return false;
}
}
bool Parser::ParsePrecedence(const std::vector<SDIM::Token> & tokens, std::vector<unsigned char> & program_data, Generator * generator, Precedence current_precedence)
{
(void)tokens;
(void)program_data;
(void)generator;
(void)current_precedence;
// handle prefix expressions
// if(GetToken(tokens, [current_token])
Token prev = GetToken(tokens, current_token);
Advance();
ParseFunc prefix_func = GetParseRule(prev.token_type).prefix;
if (prefix_func == nullptr)
{
Error(prev, "Expected prefix expression");
return false;
}
bool res = prefix_func(this, tokens, program_data, generator);
if (!res)
{
Error(prev, "Expected prefix expression");
return false;
}
while (current_precedence <= GetParseRule(GetToken(tokens, current_token).token_type).prec)
{
Advance();
ParseFunc infix_func = GetParseRule(GetToken(tokens, current_token - 1).token_type).infix;
// if (infix_func == nullptr)
// {
// Error(GetToken(tokens, current_token), "Expression is not a valid infix expression");
// return false;
// }
infix_func(this, tokens, program_data, generator);
}
return true;
}
bool Parser::ParseReturn(const std::vector<SDIM::Token>& tokens, std::vector<unsigned char>& program_data, Generator* generator)
{
Token op = GetToken(tokens, current_token - 1);
if (op.token_type != TokenType::Return)
{
Error(op, "Expected return keyword");
}
// parse operators with higher precedence
bool res = ParseExpression(tokens, program_data, generator);
if (!res)
{
return false;
}
generator->WriteReturnInstruction(program_data);
return true;
}
bool Parser::ParseBlock(const std::vector<SDIM::Token>& tokens, std::vector<unsigned char>& program_data, Generator* generator)
{
(void)tokens;
(void)program_data;
(void)generator;
OpenScope();
while (!MatchToken(tokens[current_token], TokenType::RightBrace) && !MatchToken(tokens[current_token], TokenType::EOFToken))
{
bool res = ParseDeclaration(tokens, program_data, generator);
if (!res)
{
return false;
}
}
ConsumeToken(tokens, TokenType::RightBrace, "Expected closing brace for scoping block");
CloseScope();
return true;
}
bool Parser::ParseDeclaration(const std::vector<SDIM::Token>& tokens, std::vector<unsigned char>& program_data, Generator* generator)
{
if (MatchToken(GetToken(tokens, current_token), TokenType::Identifier))
{
// declaration
Token expect_type = GetToken(tokens, current_token);
if (IsBuiltInType(expect_type))
{
bool res = DeclareVariable(tokens, program_data, generator);
if (!res)
{
return false;
}
return ConsumeToken(tokens, TokenType::SemiColon, "expect ; at end of declaration");
}
else
{
return ExpressionStatement(tokens, program_data, generator);
}
}
else
{
// statement
return ParseStatement(tokens, program_data, generator);
}
// return false;
}
bool Parser::ParseStatement(const std::vector<SDIM::Token>& tokens, std::vector<unsigned char>& program_data, Generator* generator)
{
(void)tokens;
(void)program_data;
(void)generator;
Utils::Log("Statement");
Token curr = GetToken(tokens, current_token);
Advance();
if (MatchToken(curr, TokenType::Return))
{
return ParseReturn(tokens, program_data, generator);
}
else if (MatchToken(curr, TokenType::Print))
{
return ParsePrint(tokens, program_data, generator);
}
else if (MatchToken(curr, TokenType::For))
{
return ParseFor(tokens, program_data, generator);
}
else if (MatchToken(curr, TokenType::Identifier))
{
return ExpressionStatement(tokens, program_data, generator);
}
return false;
}
bool Parser::ParseIdentifier(const std::vector<SDIM::Token>& tokens, std::vector<unsigned char>& program_data, Generator* generator)
{
(void)tokens;
(void)program_data;
(void)generator;
Token expect_type_or_identifier = GetToken(tokens, current_token - 1);
if (IsBuiltInType(expect_type_or_identifier))
{
Utils::Log("Found type specifier ", expect_type_or_identifier.lexeme);
// var declaration
Token expect_var_name = GetToken(tokens, current_token);
if (!MatchToken(expect_var_name, TokenType::Identifier))
{
Error(expect_var_name, "Expected Identifier in variable declaration");
return false;
}
Token next_token = GetToken(tokens, current_token + 1);
if (MatchToken(next_token, TokenType::SemiColon))
{
// ScopingBlock current_scope = scopes_.back();
// just declaration
LocalVar var;
var.var = Variable(TokenToVariableType(expect_type_or_identifier));
generator->WriteLocalVarInstruction(program_data, locals_.size());
var.scope = scope_idx_;
locals_.push_back(var);
}
bool res = ParsePrecedence(tokens, program_data, generator, Precedence::Assignment);
if (!res)
{
return false;
}
}
else if(expect_type_or_identifier.token_type == TokenType::Identifier)
{
Utils::Log("Found identifier ", expect_type_or_identifier.lexeme);
// generator->WritePushLocalInstruction(program_data, it->second);
bool res = ParseExpression(tokens, program_data, generator);
if (!res)
{
return false;
}
}
return true;
}
bool Parser::BinaryExpression(const std::vector<SDIM::Token> & tokens, std::vector<unsigned char> & program_data, Generator * generator)
{
Token op = GetToken(tokens, current_token - 1);
// parse operators with higher precedence
bool res = ParsePrecedence(tokens, program_data, generator, GetPrecedence(op.token_type));
if (!res)
{
return false;
}
Utils::Log("Wrote instruction for binary operator ", Utils::TokenTypeToString(op.token_type));
switch (op.token_type)
{
// arithmetic
case TokenType::Plus:
generator->WriteAddInstruction(program_data);
Utils::Log("Wrote add instruction");
return true;
case TokenType::Minus:
generator->WriteSubtractInstruction(program_data);
return true;
case TokenType::Asterisk:
generator->WriteMultiplyInstruction(program_data);
return true;
case TokenType::ForwardSlash:
generator->WriteDivideInstruction(program_data);
return true;
case TokenType::Percent:
generator->WriteModuloInstruction(program_data);
return true;
case TokenType::Ampersand:
generator->WriteAndInstruction(program_data);
return true;
case TokenType::VerticalBar:
generator->WriteOrInstruction(program_data);
return true;
case TokenType::Caret:
generator->WriteXorInstruction(program_data);
return true;
//logical
case TokenType::EqualEqual:
generator->WriteEqualInstruction(program_data);
return true;
case TokenType::BangEqual:
generator->WriteNotEqualInstruction(program_data);
return true;
case TokenType::Bang:
generator->WriteNotInstruction(program_data);
return true;
// relational
case TokenType::LessThan:
generator->WriteLessInstruction(program_data);
return true;
case TokenType::LessEqual:
generator->WriteLessEqualInstruction(program_data);
return true;
case TokenType::GreaterThan:
generator->WriteGreaterInstruction(program_data);
return true;
case TokenType::GreaterEqual:
generator->WriteGreaterEqualInstruction(program_data);
return true;
//case TokenType::Tilde:
// generator->WriteBitwiseNotInstruction(program_data);
default:
Error(op, "Expected binary operator");
return false;
}
return false;
}
bool Parser::DeclareVariable(const std::vector<SDIM::Token>& tokens, std::vector<unsigned char>& program_data, Generator* generator)
{
Token type_token = GetToken(tokens, current_token);
VariableType var_type = TokenToVariableType(type_token);
Advance();
Token name_token = GetToken(tokens, current_token);
Advance();
Token expect_equal_or_semicolon = GetToken(tokens, current_token);
if (MatchToken(expect_equal_or_semicolon, TokenType::Equal))
{
Advance();
ParseExpression(tokens, program_data, generator);
}
else
{
// TODO: do this properly based on the type of the variable being declared
generator->WritePushInt64Instruction(program_data, 0);
}
LocalVar local_var;
local_var.var.type = var_type;
local_var.name = name_token.lexeme;
local_var.scope = scope_idx_;
local_var.local_idx = locals_.size();
// check for name conflicts
if (AddLocal(local_var))
{
locals_.push_back(local_var);
Utils::Log("Added local var ", variable_type_strings[static_cast<UInt8>(local_var.var.type)], " ", local_var.name);
generator->WriteLocalVarInstruction(program_data, locals_.size());
// ConsumeToken(tokens, TokenType::SemiColon, "Expected ; at end of variable declaration");
return true;
}
return false;
}
bool Parser::ParsePrint(const std::vector<SDIM::Token>& tokens, std::vector<unsigned char>& program_data, Generator* generator)
{
Token print = GetToken(tokens, current_token - 1);
if (!MatchToken(print, TokenType::Print))
{
Error(print, "Expected print statement");
return false;
}
bool res = ParseExpression(tokens, program_data, generator);
if (!res)
{
return false;
}
return ConsumeToken(tokens, TokenType::SemiColon, "Expected semicolon to end print statement");
}
bool Parser::ExpressionStatement(const std::vector<SDIM::Token>& tokens, std::vector<unsigned char>& program_data, Generator* generator)
{
(void)tokens;
(void)program_data;
(void)generator;
bool res = ParseExpression(tokens, program_data, generator);
if (!res)
{
return false;
}
return ConsumeToken(tokens, TokenType::SemiColon, "Expected ; at end of expression statement");
}
bool Parser::ParseFor(const std::vector<SDIM::Token>& tokens, std::vector<unsigned char>& program_data, Generator* generator)
{
(void)program_data;
(void)generator;
if (!ConsumeToken(tokens, TokenType::LeftBracket, "Expected ( to open for loop declaration"))
{
return false;
}
bool res = ParseDeclaration(tokens, program_data, generator);
if (!res)
{
Error(GetToken(tokens, current_token), "Malformed for loop");
return false;
}
if (!ConsumeToken(tokens, TokenType::SemiColon, "Malformed for loop statement"))
{
return false;
}
return true;
}
void Parser::OpenScope()
{
++scope_idx_;
}
void Parser::CloseScope()
{
--scope_idx_;
if (locals_.empty())
{
return;
}
for (auto it = locals_.begin(); it != locals_.end();)
{
if (it->scope > scope_idx_)
{
it = locals_.erase(it);
}
else
{
++it;
}
}
}
bool Parser::ConsumeToken(const std::vector<SDIM::Token> & tokens, TokenType expect, const char* error_message)
{
Token consume = GetToken(tokens, current_token);
if (consume.token_type == expect)
{
// handle brackets here
// bool res = HandleBrackets(GetToken(tokens, );
// if (!res)
// {
// return false;
// }
Advance();
return true;
}
Error(GetToken(tokens, current_token), error_message);
return false;
}
/*
bool Parser::HandleBrackets(const std::vector<SDIM::Token>& GetToken(tokens, )
{
Token token = GetToken(tokens, [current_token];
if (Utils::IsOpeningBracket(token.token_type))
{
brackets_.push(token.token_type);
return true;
}
else if (Utils::IsClosingBracket(token.token_type))
{
if (brackets_.empty())
{
Utils::Log("Closing bracket: ", token.lexeme, " found with no matching opening bracket");
return false;
}
TokenType current_bracket = brackets_.top();
if (!Utils::IsMatchingBracketPair(current_bracket, token.token_type))
{
Utils::Log("Expected matching bracket for ", Utils::TokenTypeToString(current_bracket), " but got ", Utils::TokenTypeToString(token.token_type), "Instead");
return false;
}
Utils::Log("Matched opening bracket ", Utils::TokenTypeToString(current_bracket), " with ", Utils::TokenTypeToString(token.token_type));
if (token.token_type == TokenType::RightBrace)
{
// close scope
ScopingBlock closed_scope = scopes_.back();
Utils::Log("Closed Scoping block ", closed_scope.GetName());
scopes_.pop_back();
}
brackets_.pop();
}
return false;
}
*/
bool Parser::MatchToken(const Token & token, TokenType expect)
{
return token.token_type == expect;
}
bool Parser::AddLocal(const LocalVar& local)
{
for (auto it = locals_.begin(); it != locals_.end(); it++)
{
if (it->scope == local.scope && it->name == local.name)
{
// var exists in same scope
return false;
}
}
return true;
}
void Parser::Advance()
{
++current_token;
}
bool Parser::IsBuiltInType(const Token & token)
{
for (UInt8 i = 0; i < Utils::VariableTypeToUInt8(VariableType::Unknown); i++)
{
if (token.lexeme == variable_type_strings[i])
{
return true;
}
}
return false;
}
void Parser::Error(const Token & at, const char* message)
{
Utils::Log("[ERROR] line(", at.line, "):column(", at.col, ") near ", at.lexeme, ": ", message);
}
VariableType Parser::TokenToVariableType(const Token & token)
{
for (UInt8 i = 0; i < Utils::VariableTypeToUInt8(VariableType::Unknown); i++)
{
if (token.lexeme == variable_type_strings[i])
{
return static_cast<VariableType>(i);
}
}
return VariableType::Unknown;
}
// make it quicker to type parser rules
#define DefParseRule(token, prefix, infix) {token, {infix, prefix, GetPrecedence(token)}}
ParseRule Parser::GetParseRule(TokenType token)
{
static const std::unordered_map<TokenType, ParseRule> parse_rules =
{
// brackets
DefParseRule(TokenType::LeftBracket, &Parser::ParseGrouping, nullptr),
// {TokenType::LeftBracket, {nullptr, &Parser::ParseGrouping, GetPrecedence(TokenType::LeftBracket)} },
// arithmetic
DefParseRule(TokenType::PlusPlus, &Parser::ParseUnary, nullptr),
DefParseRule(TokenType::MinusMinus, &Parser::ParseUnary, nullptr),
DefParseRule(TokenType::Minus, &Parser::ParseUnary, &Parser::BinaryExpression),
DefParseRule(TokenType::Plus, nullptr, &Parser::BinaryExpression),
DefParseRule(TokenType::Asterisk, nullptr, &Parser::BinaryExpression),
DefParseRule(TokenType::ForwardSlash, nullptr, &Parser::BinaryExpression),
DefParseRule(TokenType::Percent, nullptr, &Parser::BinaryExpression),
DefParseRule(TokenType::Ampersand, nullptr, &Parser::BinaryExpression),
DefParseRule(TokenType::VerticalBar, nullptr, &Parser::BinaryExpression),
DefParseRule(TokenType::Caret, nullptr, &Parser::BinaryExpression),
DefParseRule(TokenType::Tilde, &Parser::ParseUnary, nullptr),
// logical
DefParseRule(TokenType::EqualEqual, &Parser::ParseUnary, nullptr),
DefParseRule(TokenType::BangEqual, &Parser::ParseUnary, nullptr),
DefParseRule(TokenType::GreaterThan, &Parser::ParseUnary, &Parser::BinaryExpression),
DefParseRule(TokenType::LessThan, nullptr, &Parser::BinaryExpression),
DefParseRule(TokenType::GreaterEqual, nullptr, &Parser::BinaryExpression),
DefParseRule(TokenType::LessEqual, nullptr, &Parser::BinaryExpression),
DefParseRule(TokenType::Bang, &Parser::ParseUnary, nullptr),
// literals
DefParseRule(TokenType::StringLiteral, &Parser::ParseStringLiteral, nullptr),
DefParseRule(TokenType::NumericLiteral, &Parser::ParseNumericLiteral, nullptr),
// Assignment
DefParseRule(TokenType::Equal, nullptr, &Parser::ParseAssignment),
// semicolon
DefParseRule(TokenType::SemiColon, nullptr, nullptr),
// return
DefParseRule(TokenType::Return, &Parser::ParseReturn, nullptr),
// variables and types
DefParseRule(TokenType::Identifier, &Parser::ParseIdentifier, nullptr)
};
const auto& it = parse_rules.find(token);
if(it == parse_rules.cend())
{
return ParseRule{ nullptr, nullptr, Precedence::None };
}
return it->second;
}
}
| 29.38381
| 167
| 0.699835
|
DamienHenderson
|
03c9bf4181ba5a15a8a686021ecae98ec1e0489f
| 531
|
cpp
|
C++
|
tests/template_named_values.cpp
|
riskybacon/cpp-named-params
|
da72b3556e5c5ed31e2ac47976db283c7e394e93
|
[
"MIT"
] | null | null | null |
tests/template_named_values.cpp
|
riskybacon/cpp-named-params
|
da72b3556e5c5ed31e2ac47976db283c7e394e93
|
[
"MIT"
] | null | null | null |
tests/template_named_values.cpp
|
riskybacon/cpp-named-params
|
da72b3556e5c5ed31e2ac47976db283c7e394e93
|
[
"MIT"
] | null | null | null |
#define BOOST_TEST_DYN_LINK
#define BOOST_TEST_MODULE "template_named_values"
#include <boost/test/unit_test.hpp>
#include <iostream>
#include <cpp_named_params/template_named_values.hpp>
BOOST_AUTO_TEST_CASE(test_named_values) {
using namespace rb;
rectangle<
width < 10 >,
height < 30 >,
scale < 1, 3 >
> rect;
BOOST_CHECK(rect.width() == 10);
BOOST_CHECK(rect.height() == 30);
BOOST_CHECK(rect.area() == 10 * 30);
BOOST_CHECK(rect.scale() == float(1) / float(3));
}
| 24.136364
| 53
| 0.653484
|
riskybacon
|
03cdcf420c5680fb327da8c84945c8a869dd134f
| 4,732
|
cpp
|
C++
|
Fogo.cpp
|
Ivan-Sandro/Fire_Doom_Algorithm
|
f33af2826f8d16cd8b8cc6086f8ba8b3ba21733f
|
[
"MIT"
] | null | null | null |
Fogo.cpp
|
Ivan-Sandro/Fire_Doom_Algorithm
|
f33af2826f8d16cd8b8cc6086f8ba8b3ba21733f
|
[
"MIT"
] | null | null | null |
Fogo.cpp
|
Ivan-Sandro/Fire_Doom_Algorithm
|
f33af2826f8d16cd8b8cc6086f8ba8b3ba21733f
|
[
"MIT"
] | null | null | null |
#include "Fogo.h"
#include <iostream>
void FOGO::_Get_Paleta_Regular_Cor(const char* Nome_Paleta, int Ponto_Inicial_X, int Ponto_Inicial_Y, int Distancia_Pixeis_X, int Distancia_Pixeis_Y, int Matriz_Paleta_X, int Matriz_Paleta_Y){
ALLEGRO_BITMAP *Paleta = NULL;
Paleta = al_load_bitmap(Nome_Paleta);
if(!Paleta){
_Erro_Box("Erro ao carregar a Paleta do Fogo");
system("pause");
return;
}
for (int Y = Ponto_Inicial_Y ; Y < Ponto_Inicial_Y + Matriz_Paleta_Y * Distancia_Pixeis_Y ; Y += Distancia_Pixeis_Y){
for (int X = Ponto_Inicial_X ; X < Ponto_Inicial_X + Matriz_Paleta_X * Distancia_Pixeis_X ; X += Distancia_Pixeis_X){
Paleta_Cores.push_back(al_get_pixel(Paleta, X, Y));
}
}
al_destroy_bitmap(Paleta);
}
void FOGO::_Definir_Matriz_Fogo(int X, int Y, short int Tamanho_Quadrados_Fogo){
Px_Tamanho_Quadrados_Fogo = Tamanho_Quadrados_Fogo;
Chance_Fogo_Esquerda = 40;
Chance_Fogo_Subir = 70;
Intensidade_Esquerda = 3;
Intensidade_Subir = 2;
Largura_Matriz = 1 + int(X/Tamanho_Quadrados_Fogo);
Altura_Matriz = 1 + int(Y/Tamanho_Quadrados_Fogo);
std::vector <char> Linha;
for(int A = 0 ; A < Largura_Matriz ; A++){
Linha.push_back(0);
}
for(int B = 0 ; B < Altura_Matriz ; B++){
Matriz_Fogo.push_back(Linha);
}
}
void FOGO::_Mover_Fogo(){
for(int X = 0 ; X < Largura_Matriz ; X++){
for(int Y = 0 ; Y < Altura_Matriz ; Y++){
if(rand() % 100 < Chance_Fogo_Subir && Y > 0){
Matriz_Fogo[Y-1][X] = Matriz_Fogo[Y][X] -rand() % Intensidade_Subir;
if(Matriz_Fogo[Y-1][X] < 0)Matriz_Fogo[Y-1][X] = 0;
}
if(rand () % 100 < Chance_Fogo_Esquerda && X > 0 && Y > 0){
Matriz_Fogo[Y-1][X-1] = Matriz_Fogo[Y][X]-rand() % Intensidade_Esquerda;
if(Matriz_Fogo[Y-1][X-1] < 0)Matriz_Fogo[Y-1][X-1] = 0;
}
}
}
}
void FOGO::_Desenhar_Fogo(void){
int X_Quadrado_Fogo;
int Y_Quadrado_Fogo;
for(int X = 0 ; X < Largura_Matriz ; X++){
for(int Y = 0 ; Y < Altura_Matriz ; Y++){
if(Matriz_Fogo[Y][X] > 0){
X_Quadrado_Fogo = X * Px_Tamanho_Quadrados_Fogo;
Y_Quadrado_Fogo = Y * Px_Tamanho_Quadrados_Fogo;
al_draw_filled_rectangle(X_Quadrado_Fogo, Y_Quadrado_Fogo, X_Quadrado_Fogo + Px_Tamanho_Quadrados_Fogo, Y_Quadrado_Fogo + Px_Tamanho_Quadrados_Fogo,
Paleta_Cores[Matriz_Fogo[Y][X]]);
}
}
}
}
void FOGO::_Desenhar_Com_Mouse(int X, int Y){
short int dX, dY;
short int lugar_Pintado_X = X/Px_Tamanho_Quadrados_Fogo;
short int lugar_Pintado_Y = Y/Px_Tamanho_Quadrados_Fogo;
for(dX = -2 ; dX < 3 ; dX++){
for(dY = -2 ; dY < 3; dY++){
if(dX + lugar_Pintado_X < 0 || dX + lugar_Pintado_X > Largura_Matriz-2 ||
dY + lugar_Pintado_Y < 0 || dY + lugar_Pintado_Y > Altura_Matriz-1)
break;
else
Matriz_Fogo[dY + lugar_Pintado_Y][dX + lugar_Pintado_X] = Paleta_Cores.size()-1;
}
}
}
void FOGO::_Manter_Fogo_Padrao(void){
for(int A = 0 ; A < Largura_Matriz-1 ; A++)
Matriz_Fogo[Altura_Matriz-1][A] = Paleta_Cores.size()-1;
}
void FOGO::_Apagar_Fogo(void){
for(int X = 0 ; X < Largura_Matriz ; X++){
for(int Y = 0 ; Y < Altura_Matriz ; Y++){
Matriz_Fogo[Y][X] = 0;
}
}
}
void FOGO::_Zerar_Ultima_Fileira_Fogo(void){
for(int X = 0 ; X < Largura_Matriz ; X++)
Matriz_Fogo[Altura_Matriz-1][X] = 0;
}
void FOGO::_Aumentar_Chance_Fogo_Subir (void){
if(Chance_Fogo_Subir < 100)
Chance_Fogo_Subir += 1;
}
void FOGO::_Diminuir_Chance_Fogo_Subir (void){
if(Chance_Fogo_Subir > 0)
Chance_Fogo_Subir -= 1;
}
void FOGO::_Aumentar_Chance_Fogo_Esquerda (void){
if(Chance_Fogo_Esquerda < 100)
Chance_Fogo_Esquerda += 1;
}
void FOGO::_Diminuir_Chance_Fogo_Esquerda (void){
if(Chance_Fogo_Esquerda > 0)
Chance_Fogo_Esquerda -= 1;
}
void FOGO::_Aumentar_Subtrair_Subir (void){
if(Intensidade_Subir < 10)
Intensidade_Subir += 1;
}
void FOGO::_Diminuir_Subtrair_Subir (void){
if(Intensidade_Subir > 1)
Intensidade_Subir -= 1;
}
void FOGO::_Aumentar_Subtrair_Esquerda (void){
if(Intensidade_Esquerda < 10)
Intensidade_Esquerda += 1;
}
void FOGO::_Diminuir_Subtrair_Esquerda (void){
if(Intensidade_Esquerda > 1)
Intensidade_Esquerda -= 1;
}
| 31.758389
| 193
| 0.60186
|
Ivan-Sandro
|
03d0c1fb4f771720ff38a0c2b21e32944057ea13
| 565
|
cpp
|
C++
|
1-100/124. Binary Tree Maximum Path Sum.cpp
|
erichuang1994/leetcode-solution
|
d5b3bb3ce2a428a3108f7369715a3700e2ba699d
|
[
"MIT"
] | null | null | null |
1-100/124. Binary Tree Maximum Path Sum.cpp
|
erichuang1994/leetcode-solution
|
d5b3bb3ce2a428a3108f7369715a3700e2ba699d
|
[
"MIT"
] | null | null | null |
1-100/124. Binary Tree Maximum Path Sum.cpp
|
erichuang1994/leetcode-solution
|
d5b3bb3ce2a428a3108f7369715a3700e2ba699d
|
[
"MIT"
] | null | null | null |
/**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode(int x) : val(x), left(NULL), right(NULL) {}
* };
*/
class Solution
{
public:
int maxPathSum(TreeNode *root)
{
int ret = INT_MIN;
dfs(root, ret);
return ret;
}
int dfs(TreeNode *root, int &ret)
{
if (root == NULL)
return 0;
auto l = max(0, dfs(root->left, ret));
auto r = max(0, dfs(root->right, ret));
ret = max(ret, l + r + root->val);
return max(l, r) + root->val;
}
};
| 20.178571
| 59
| 0.541593
|
erichuang1994
|
03d0d2cb120465470c82d73346407232d581923d
| 6,519
|
hpp
|
C++
|
renderer/ocean.hpp
|
VulkanWorks/Granite-scene-graph-gui-ffmpeg-dsp
|
a725ec78eeb5de2d3c25257b1a9372f5e38910f6
|
[
"MIT"
] | 1,003
|
2017-08-13T17:47:04.000Z
|
2022-03-29T15:56:55.000Z
|
renderer/ocean.hpp
|
VulkanWorks/Granite-scene-graph-gui-ffmpeg-dsp
|
a725ec78eeb5de2d3c25257b1a9372f5e38910f6
|
[
"MIT"
] | 10
|
2017-08-14T19:11:35.000Z
|
2021-12-10T12:51:53.000Z
|
renderer/ocean.hpp
|
VulkanWorks/Granite-scene-graph-gui-ffmpeg-dsp
|
a725ec78eeb5de2d3c25257b1a9372f5e38910f6
|
[
"MIT"
] | 107
|
2017-08-16T16:13:26.000Z
|
2022-03-03T06:42:19.000Z
|
/* Copyright (c) 2017-2020 Hans-Kristian Arntzen
*
* 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.
*/
#pragma once
#include "abstract_renderable.hpp"
#include "scene.hpp"
#include "application_wsi_events.hpp"
#include "fft/glfft.hpp"
#include "glfft_granite_interface.hpp"
#include "application_events.hpp"
#include <vector>
namespace Granite
{
class RenderTextureResource;
class RenderBufferResource;
static constexpr unsigned MaxOceanLayers = 4;
struct OceanConfig
{
unsigned fft_resolution = 512;
unsigned displacement_downsample = 1;
unsigned grid_count = 32;
unsigned grid_resolution = 128;
vec2 ocean_size = vec2(512.0f);
vec2 wind_velocity = vec2(10.0f, 5.0f);
float normal_mod = 7.3f;
float amplitude = 0.2f;
struct
{
std::string input;
float uv_scale = 0.01f;
float depth[MaxOceanLayers] = { 2.0f, 4.0f, 6.0f, 8.0f };
float emissive_mod = 1.0f;
bool bandlimited_pixel = false;
bool input_is_render_graph = false;
} refraction;
};
class Ocean : public AbstractRenderable,
public PerFrameRefreshable,
public RenderPassCreator,
public EventHandler
{
public:
Ocean(const OceanConfig &config);
struct Handles
{
Entity *entity;
Ocean *ocean;
};
static Handles add_to_scene(Scene &scene, const OceanConfig &config = {});
enum { FrequencyBands = 8 };
void set_frequency_band_amplitude(unsigned band, float amplitude);
void set_frequency_band_modulation(bool enable);
private:
OceanConfig config;
void on_device_created(const Vulkan::DeviceCreatedEvent &e);
void on_device_destroyed(const Vulkan::DeviceCreatedEvent &);
bool on_frame_tick(const FrameTickEvent &e);
std::unique_ptr<GLFFT::FFT> height_fft;
std::unique_ptr<GLFFT::FFT> normal_fft;
std::unique_ptr<GLFFT::FFT> displacement_fft;
FFTInterface fft_iface;
FFTDeferredCommandBuffer deferred_cmd;
float frequency_bands[FrequencyBands];
bool freq_band_modulation = false;
bool has_static_aabb() const override
{
return false;
}
void get_render_info(const RenderContext &context,
const RenderInfoComponent *transform,
RenderQueue &queue) const override;
const RenderContext *context = nullptr;
void refresh(const RenderContext &context, TaskComposer &composer) override;
void add_render_passes(RenderGraph &graph) override;
void set_base_renderer(const RendererSuite *suite) override;
void set_base_render_context(const RenderContext *context) override;
void setup_render_pass_dependencies(RenderGraph &graph,
RenderPass &target) override;
void setup_render_pass_resources(RenderGraph &graph) override;
void set_scene(Scene *scene) override;
std::vector<Vulkan::ImageViewHandle> vertex_mip_views;
std::vector<Vulkan::ImageViewHandle> fragment_mip_views;
std::vector<Vulkan::ImageViewHandle> normal_mip_views;
Vulkan::BufferHandle distribution_buffer;
Vulkan::BufferHandle distribution_buffer_displacement;
Vulkan::BufferHandle distribution_buffer_normal;
RenderTextureResource *ocean_lod = nullptr;
RenderBufferResource *lod_data = nullptr;
RenderBufferResource *lod_data_counters = nullptr;
RenderBufferResource *height_fft_input = nullptr;
RenderBufferResource *displacement_fft_input = nullptr;
RenderBufferResource *normal_fft_input = nullptr;
RenderTextureResource *height_fft_output = nullptr;
RenderTextureResource *displacement_fft_output = nullptr;
RenderTextureResource *normal_fft_output = nullptr;
RenderTextureResource *height_displacement_output = nullptr;
RenderTextureResource *gradient_jacobian_output = nullptr;
RenderGraph *graph = nullptr;
void build_lod_map(Vulkan::CommandBuffer &cmd);
void cull_blocks(Vulkan::CommandBuffer &cmd);
void init_counter_buffer(Vulkan::CommandBuffer &cmd);
void update_lod_pass(Vulkan::CommandBuffer &cmd);
void update_fft_pass(Vulkan::CommandBuffer &cmd);
void update_fft_input(Vulkan::CommandBuffer &cmd);
void compute_fft(Vulkan::CommandBuffer &cmd);
void bake_maps(Vulkan::CommandBuffer &cmd);
void generate_mipmaps(Vulkan::CommandBuffer &cmd);
vec3 last_camera_position = vec3(0.0f);
double current_time = 0.0;
vec2 wind_direction;
float phillips_L;
struct LOD
{
Vulkan::BufferHandle vbo;
Vulkan::BufferHandle ibo;
unsigned count;
};
std::vector<LOD> quad_lod;
Vulkan::BufferHandle border_vbo;
Vulkan::BufferHandle border_ibo;
unsigned border_count = 0;
VkIndexType index_type = VK_INDEX_TYPE_UINT16;
void build_buffers(Vulkan::Device &device);
void build_lod(Vulkan::Device &device, unsigned size, unsigned stride);
void init_distributions(Vulkan::Device &device);
void build_border(std::vector<vec3> &positions, std::vector<uint16_t> &indices,
ivec2 base, ivec2 dx, ivec2 dy);
void build_corner(std::vector<vec3> &positions, std::vector<uint16_t> &indices,
ivec2 base, ivec2 dx, ivec2 dy);
void build_fill_edge(std::vector<vec3> &positions, std::vector<uint16_t> &indices,
vec2 base_outer, vec2 end_outer,
ivec2 base_inner, ivec2 delta, ivec2 corner_delta);
void add_lod_update_pass(RenderGraph &graph);
void add_fft_update_pass(RenderGraph &graph);
vec2 get_snapped_grid_center() const;
vec2 get_grid_size() const;
ivec2 get_grid_base_coord() const;
vec2 heightmap_world_size() const;
vec2 normalmap_world_size() const;
Vulkan::ImageView *refraction = nullptr;
RenderTextureResource *refraction_resource = nullptr;
};
}
| 33.777202
| 83
| 0.762694
|
VulkanWorks
|
03d1a2055d5a71db2b12661f975ee6018fa00eab
| 117
|
cpp
|
C++
|
WithMemento/SchoolBackup.cpp
|
mateusz-talma/MementoPattern
|
9ea3cd819822cc4521faa63ed1fd4a116ef34c4e
|
[
"MIT"
] | null | null | null |
WithMemento/SchoolBackup.cpp
|
mateusz-talma/MementoPattern
|
9ea3cd819822cc4521faa63ed1fd4a116ef34c4e
|
[
"MIT"
] | null | null | null |
WithMemento/SchoolBackup.cpp
|
mateusz-talma/MementoPattern
|
9ea3cd819822cc4521faa63ed1fd4a116ef34c4e
|
[
"MIT"
] | null | null | null |
#include "SchoolBackup.hpp"
#include "School.hpp"
SchoolBackup::SchoolBackup(School school)
: school_(school) {}
| 23.4
| 41
| 0.74359
|
mateusz-talma
|
03d3b489a6b62f9d642c8ccb9bc5ecaa54db0d4b
| 664
|
cpp
|
C++
|
0090_Subsets_II/solution.cpp
|
Heliovic/LeetCode_Solutions
|
73d5a7aaffe62da9a9cd8a80288b260085fda08f
|
[
"MIT"
] | 2
|
2019-02-18T15:32:57.000Z
|
2019-03-18T12:55:35.000Z
|
0090_Subsets_II/solution.cpp
|
Heliovic/LeetCode_Solutions
|
73d5a7aaffe62da9a9cd8a80288b260085fda08f
|
[
"MIT"
] | null | null | null |
0090_Subsets_II/solution.cpp
|
Heliovic/LeetCode_Solutions
|
73d5a7aaffe62da9a9cd8a80288b260085fda08f
|
[
"MIT"
] | null | null | null |
class Solution {
public:
vector<vector<int>> ans;
void dfs(vector<int>& v, int pos, vector<int>& nums)
{
ans.push_back(v);
for (int i = pos; i < nums.size();)
{
v.push_back(nums[i]);
dfs(v, i + 1, nums);
v.pop_back();
i++;
while (i < nums.size() && nums[i] == nums[i - 1])
i++;
}
}
vector<vector<int>> subsetsWithDup(vector<int>& nums) {
sort(nums.begin(), nums.end());
vector<int> tmp;
dfs(tmp, 0, nums);
return ans;
}
};
| 20.121212
| 61
| 0.391566
|
Heliovic
|
03d5135a91778fbf5fc9e4d9a41d689974658487
| 1,290
|
cpp
|
C++
|
atto/tests/opengl/0-glfw/color.cpp
|
ubikoo/libfish
|
7f0b5e06b2bf1d6ff490ddfda9cc7aab69cdbf39
|
[
"MIT"
] | null | null | null |
atto/tests/opengl/0-glfw/color.cpp
|
ubikoo/libfish
|
7f0b5e06b2bf1d6ff490ddfda9cc7aab69cdbf39
|
[
"MIT"
] | null | null | null |
atto/tests/opengl/0-glfw/color.cpp
|
ubikoo/libfish
|
7f0b5e06b2bf1d6ff490ddfda9cc7aab69cdbf39
|
[
"MIT"
] | null | null | null |
/*
* color.cpp
*
* Copyright (c) 2020 Carlos Braga
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the MIT License.
*
* See accompanying LICENSE.md or https://opensource.org/licenses/MIT.
*/
#include "atto/opengl/opengl.hpp"
#include "color.hpp"
using namespace atto;
/** ---------------------------------------------------------------------------
* Color::Color
*/
Color::Color()
: r(0.0f)
, g(0.0f)
, b(0.0f)
, a(1.0f)
, d(1.0f)
{}
/** ---------------------------------------------------------------------------
* Color::handle
*/
void Color::handle(const gl::Event &event)
{}
/** ---------------------------------------------------------------------------
* Color::draw
*/
void Color::draw(void *data)
{
GLFWwindow *window = gl::Renderer::window();
if (window == nullptr) {
return;
}
/*
* Update OpenGL color and depth buffer values.
*/
{
const double wr = 0.3;
const double wg = 0.2;
const double wb = 0.1;
const double t = glfwGetTime();
r = 0.5*(std::cos(wr*t) + 1.0);
g = 0.5*(std::cos(wg*t) + 1.0);
b = 0.5*(std::cos(wb*t) + 1.0);
a = 1.0;
}
gl::Renderer::clear(r, g, b, a, 1.0);
}
| 21.864407
| 79
| 0.44186
|
ubikoo
|
03d5a36a9d28886bdee82fe15d23e667e3c14bcd
| 1,861
|
cpp
|
C++
|
leetcode/239.sliding-window-maximum.cpp
|
geemaple/algorithm
|
68bc5032e1ee52c22ef2f2e608053484c487af54
|
[
"MIT"
] | 177
|
2017-08-21T08:57:43.000Z
|
2020-06-22T03:44:22.000Z
|
leetcode/239.sliding-window-maximum.cpp
|
geemaple/algorithm
|
68bc5032e1ee52c22ef2f2e608053484c487af54
|
[
"MIT"
] | 2
|
2018-09-06T13:39:12.000Z
|
2019-06-03T02:54:45.000Z
|
leetcode/239.sliding-window-maximum.cpp
|
geemaple/algorithm
|
68bc5032e1ee52c22ef2f2e608053484c487af54
|
[
"MIT"
] | 23
|
2017-08-23T06:01:28.000Z
|
2020-04-20T03:17:36.000Z
|
/*
* @lc app=leetcode id=239 lang=cpp
*
* [239] Sliding Window Maximum
*
* https://leetcode.com/problems/sliding-window-maximum/description/
*
* algorithms
* Hard (36.17%)
* Total Accepted: 151.8K
* Total Submissions: 401.3K
* Testcase Example: '[1,3,-1,-3,5,3,6,7]\n3'
*
* Given an array nums, there is a sliding window of size k which is moving
* from the very left of the array to the very right. You can only see the k
* numbers in the window. Each time the sliding window moves right by one
* position. Return the max sliding window.
*
* Example:
*
*
* Input: nums = [1,3,-1,-3,5,3,6,7], and k = 3
* Output: [3,3,5,5,6,7]
* Explanation:
*
* Window position Max
* --------------- -----
* [1 3 -1] -3 5 3 6 7 3
* 1 [3 -1 -3] 5 3 6 7 3
* 1 3 [-1 -3 5] 3 6 7 5
* 1 3 -1 [-3 5 3] 6 7 5
* 1 3 -1 -3 [5 3 6] 7 6
* 1 3 -1 -3 5 [3 6 7] 7
*
*
* Note:
* You may assume k is always valid, 1 ≤ k ≤ input array's size for non-empty
* array.
*
* Follow up:
* Could you solve it in linear time?
*/
class Solution {
public:
vector<int> maxSlidingWindow(vector<int>& nums, int k) {
vector<int> results;
deque<int> q;
for (int i = 0; i < nums.size(); i++) {
// detect if front shoud move out of window
// i - j + 1 = k + 1, so j = i + 1 - k
if (!q.empty() && i - k == q.front()) {
q.pop_front();
}
while (!q.empty() && nums[q.back()] < nums[i]) {
q.pop_back();
}
q.push_back(i);
if (i >= k - 1) {
results.push_back(nums[q.front()]);
}
}
return results;
}
};
| 26.585714
| 77
| 0.468565
|
geemaple
|
03d6a111cde580b535d3ec5c7a65950cb38de8d0
| 296
|
hpp
|
C++
|
source/Objects/Edge.hpp
|
1pkg/halfo
|
a57dc4b68d29165d6ab7ed36c7886326e414e269
|
[
"MIT"
] | null | null | null |
source/Objects/Edge.hpp
|
1pkg/halfo
|
a57dc4b68d29165d6ab7ed36c7886326e414e269
|
[
"MIT"
] | null | null | null |
source/Objects/Edge.hpp
|
1pkg/halfo
|
a57dc4b68d29165d6ab7ed36c7886326e414e269
|
[
"MIT"
] | null | null | null |
#ifndef OBJECTS_EDGE
#define OBJECTS_EDGE
#include "include.hpp"
#include "Views/Object/Edge.hpp"
namespace Objects
{
class Edge : public Application::Object
{
public:
Edge();
Views::Object::Edge * view() const override;
private:
std::unique_ptr<Views::Object::Edge> _view;
};
}
#endif
| 12.333333
| 45
| 0.719595
|
1pkg
|
03da52fe2bbe06f3814fc799a37c2290cada142a
| 221
|
cpp
|
C++
|
src/10.DarkChannelPriorHazeRemoval/main.cpp
|
rzwm/OpenCVImageProcessing
|
192c6c62acb0c03f606f7d468276a5f1d78925eb
|
[
"Apache-2.0"
] | 35
|
2017-12-15T04:34:40.000Z
|
2022-03-20T13:37:40.000Z
|
src/10.DarkChannelPriorHazeRemoval/main.cpp
|
Sevryy/OpenCVImageProcessing
|
192c6c62acb0c03f606f7d468276a5f1d78925eb
|
[
"Apache-2.0"
] | null | null | null |
src/10.DarkChannelPriorHazeRemoval/main.cpp
|
Sevryy/OpenCVImageProcessing
|
192c6c62acb0c03f606f7d468276a5f1d78925eb
|
[
"Apache-2.0"
] | 20
|
2018-04-08T08:04:56.000Z
|
2021-09-17T08:48:45.000Z
|
// http://blog.csdn.net/matrix_space/article/details/40652883
// 暗通道先验去雾
#include "opencv2/core/core.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
int main()
{
// TODO
return 0;
}
| 18.416667
| 62
| 0.728507
|
rzwm
|
03df8967b85406e89b7c4ed866aa22d0d16e4a6b
| 1,214
|
cc
|
C++
|
onnxruntime/core/platform/posix/ort_mutex.cc
|
codemzs/onnxruntime
|
c69194ec4c8c9674368113aa6044d0db708cd813
|
[
"MIT"
] | 4
|
2019-06-06T23:48:57.000Z
|
2021-06-03T11:51:45.000Z
|
onnxruntime/core/platform/posix/ort_mutex.cc
|
codemzs/onnxruntime
|
c69194ec4c8c9674368113aa6044d0db708cd813
|
[
"MIT"
] | 17
|
2020-07-21T11:13:27.000Z
|
2022-03-27T02:37:05.000Z
|
onnxruntime/core/platform/posix/ort_mutex.cc
|
Surfndez/onnxruntime
|
9d748afff19e9604a00632d66b97159b917dabb2
|
[
"MIT"
] | 3
|
2019-05-07T01:29:04.000Z
|
2020-08-09T08:36:12.000Z
|
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#include "core/platform/ort_mutex.h"
#include <assert.h>
#include <stdexcept>
#include <system_error>
#include <sstream>
namespace onnxruntime {
void OrtCondVar::timed_wait_impl(std::unique_lock<OrtMutex>& lk,
std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds> tp) {
using namespace std::chrono;
#ifndef NDEBUG
if (!lk.owns_lock())
throw std::runtime_error("condition_variable::timed wait: mutex not locked");
#endif
nanoseconds d = tp.time_since_epoch();
timespec abs_deadline;
seconds s = duration_cast<seconds>(d);
using ts_sec = decltype(abs_deadline.tv_sec);
constexpr ts_sec ts_sec_max = std::numeric_limits<ts_sec>::max();
if (s.count() < ts_sec_max) {
abs_deadline.tv_sec = static_cast<ts_sec>(s.count());
abs_deadline.tv_nsec = static_cast<decltype(abs_deadline.tv_nsec)>((d - s).count());
} else {
abs_deadline.tv_sec = ts_sec_max;
abs_deadline.tv_nsec = 999999999;
}
nsync::nsync_cv_wait_with_deadline(&native_cv_object, lk.mutex()->native_handle(), abs_deadline, nullptr);
}
} // namespace onnxruntime
| 36.787879
| 115
| 0.718287
|
codemzs
|
03e190045fc10fc3452fbecb0cb3a9cb239152fc
| 1,451
|
hh
|
C++
|
z2/inc/LZespolona.hh
|
PatrykAlexGajda/TestLiczbZespolonych
|
0b070182368e64aff405d16d2461e8ed75b4d1f2
|
[
"MIT"
] | null | null | null |
z2/inc/LZespolona.hh
|
PatrykAlexGajda/TestLiczbZespolonych
|
0b070182368e64aff405d16d2461e8ed75b4d1f2
|
[
"MIT"
] | null | null | null |
z2/inc/LZespolona.hh
|
PatrykAlexGajda/TestLiczbZespolonych
|
0b070182368e64aff405d16d2461e8ed75b4d1f2
|
[
"MIT"
] | null | null | null |
#ifndef LZESPOLONA_HH
#define LZESPOLONA_HH
#include "Statystyka.hh"
#include <iostream>
/*! Plik zawiera definicje struktury LZesplona oraz zapowiedzi
* przeciazen operatorow arytmetycznych dzialajacych na tej
* strukturze. */
/*! Modeluje pojecie liczby zespolonej */
struct LZespolona {
double re; /*! Pole repezentuje czesc rzeczywista. */
double im; /*! Pole repezentuje czesc urojona. */
};
/* Naglowki funkcji dzialajacych na liczbach zespolonych
lub liczacych je na podstawie zawartosci struktury LZespolona */
LZespolona Utworz(double x, double y);
LZespolona Sprzezenie (LZespolona Skl);
double Modul(LZespolona Skl);
/* Naglowki przeciazen operatorow ktore pozwalaja im operowac na strukturze
liczb zespolonych */
std::ostream &operator<<(std::ostream &str, const LZespolona &zesp);
std::istream &operator>>(std::istream &str, LZespolona &zesp);
/* Naglowki przeciazen operatorow ktore pozwalaja im obliczac wyniki
wyrazen zespolonych. */
LZespolona operator + (LZespolona Skl1, LZespolona Skl2);
LZespolona operator - (LZespolona Skl1, LZespolona Skl2);
LZespolona operator * (LZespolona Skl1, LZespolona Skl2);
LZespolona operator / (LZespolona Skl1, LZespolona Skl2);
LZespolona operator / (LZespolona Skl, double r);
/* Naglowki przeciazen operatorow porownujacych liczby zespolone. */
bool operator == (LZespolona Skl1, LZespolona Skl2);
bool operator != (LZespolona Skl1, LZespolona Skl2);
#endif
| 30.87234
| 75
| 0.7643
|
PatrykAlexGajda
|
03e3ef5daddd90928567222cdc393c2dd7126773
| 47
|
cpp
|
C++
|
Physx.NetCore/Source/ContactPatch.cpp
|
ronbrogan/Physx.NetCore
|
ac788494b6aefc4b6633c46e857f199e6ab0a47a
|
[
"MIT"
] | 187
|
2015-01-02T15:58:10.000Z
|
2022-02-20T05:23:13.000Z
|
PhysX.Net-3.4/PhysX.Net-3/Source/ContactPatch.cpp
|
Golangltd/PhysX.Net
|
fb71e0422d441a16a05ed51348d8afb0328d4b90
|
[
"MIT"
] | 37
|
2015-01-10T04:38:23.000Z
|
2022-03-18T00:52:27.000Z
|
PhysX.Net-3.4/PhysX.Net-3/Source/ContactPatch.cpp
|
Golangltd/PhysX.Net
|
fb71e0422d441a16a05ed51348d8afb0328d4b90
|
[
"MIT"
] | 63
|
2015-01-11T12:12:44.000Z
|
2022-02-05T14:12:49.000Z
|
#include "StdAfx.h"
#include "ContactPatch.h"
| 11.75
| 25
| 0.723404
|
ronbrogan
|
03e63dae25e3b1a91752f52f0d52243f14172447
| 572
|
cpp
|
C++
|
source/ShaderAST/Stmt/StmtSpecialisationConstantDecl.cpp
|
Praetonus/ShaderWriter
|
1c5b3961e3e1b91cb7158406998519853a4add07
|
[
"MIT"
] | 148
|
2018-10-11T16:51:37.000Z
|
2022-03-26T13:55:08.000Z
|
source/ShaderAST/Stmt/StmtSpecialisationConstantDecl.cpp
|
Praetonus/ShaderWriter
|
1c5b3961e3e1b91cb7158406998519853a4add07
|
[
"MIT"
] | 30
|
2019-11-30T11:43:07.000Z
|
2022-01-25T21:09:47.000Z
|
source/ShaderAST/Stmt/StmtSpecialisationConstantDecl.cpp
|
Praetonus/ShaderWriter
|
1c5b3961e3e1b91cb7158406998519853a4add07
|
[
"MIT"
] | 8
|
2020-04-17T13:18:30.000Z
|
2021-11-20T06:24:44.000Z
|
/*
See LICENSE file in root folder
*/
#include "ShaderAST/Stmt/StmtSpecialisationConstantDecl.hpp"
#include "ShaderAST/Stmt/StmtVisitor.hpp"
namespace ast::stmt
{
SpecialisationConstantDecl::SpecialisationConstantDecl( var::VariablePtr variable
, uint32_t location
, expr::LiteralPtr value )
: Stmt{ Kind::eSpecialisationConstantDecl }
, m_variable{ std::move( variable ) }
, m_location{ location }
, m_value{ std::move( value ) }
{
}
void SpecialisationConstantDecl::accept( VisitorPtr vis )
{
vis->visitSpecialisationConstantDeclStmt( this );
}
}
| 22.88
| 82
| 0.744755
|
Praetonus
|
03e6eb8645c643bc5dc467bb8e34cd43d88a9508
| 35
|
cpp
|
C++
|
CullingModule/MaskedSWOcclusionCulling/Utility/DepthValueComputer.cpp
|
SungJJinKang/Parallel_Culling
|
17d1302f500bd38df75583c81a7091b975a3ef91
|
[
"MIT"
] | 10
|
2021-12-25T09:22:39.000Z
|
2022-02-27T19:39:45.000Z
|
CullingModule/MaskedSWOcclusionCulling/Utility/DepthValueComputer.cpp
|
SungJJinKang/Parallel_Culling
|
17d1302f500bd38df75583c81a7091b975a3ef91
|
[
"MIT"
] | 1
|
2021-11-17T03:15:13.000Z
|
2021-11-18T02:51:55.000Z
|
CullingModule/MaskedSWOcclusionCulling/Utility/DepthValueComputer.cpp
|
SungJJinKang/Parallel_Culling
|
17d1302f500bd38df75583c81a7091b975a3ef91
|
[
"MIT"
] | 1
|
2022-01-09T23:14:30.000Z
|
2022-01-09T23:14:30.000Z
|
#include "DepthValueComputer.h"
| 7
| 31
| 0.742857
|
SungJJinKang
|
03eb4a7dcb331f1c214bd6b6e5051672697fb7c3
| 1,774
|
cc
|
C++
|
3rdparty.old/libcvd/cvd_src/draw.cc
|
BeLioN-github/PTAM
|
436ebc2d78ace26644f296cd2d3ddd185bb0370e
|
[
"Intel",
"X11"
] | 14
|
2015-01-19T15:36:37.000Z
|
2016-09-17T15:19:05.000Z
|
3rdparty.old/libcvd/cvd_src/draw.cc
|
Pandinosaurus/PTAM-opencv
|
1281564b9737dcc29ccacfbf7dc88a85916f7cc6
|
[
"Intel",
"X11"
] | 2
|
2015-03-20T01:04:53.000Z
|
2015-07-27T07:01:38.000Z
|
3rdparty.old/libcvd/cvd_src/draw.cc
|
Pandinosaurus/PTAM-opencv
|
1281564b9737dcc29ccacfbf7dc88a85916f7cc6
|
[
"Intel",
"X11"
] | 14
|
2015-04-29T19:27:49.000Z
|
2016-12-07T06:10:20.000Z
|
/*
This file is part of the CVD Library.
Copyright (C) 2005 The Authors
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <cvd/draw.h>
namespace CVD {
std::vector<ImageRef> getCircle(int radius) {
std::vector<ImageRef> points;
int y = 0;
for (int x=-radius; x<=0; x++) {
int nexty2 = radius*radius - ((x+1)*(x+1));
while (true) {
points.push_back(ImageRef(x,y));
if (y*y >= nexty2)
break;
++y;
}
}
size_t i;
for (i=points.size()-1;i>0;i--)
points.push_back(ImageRef(-points[i-1].x, points[i-1].y));
for (i=points.size()-1;i>1;i--)
points.push_back(ImageRef(points[i-1].x, -points[i-1].y));
return points;
}
std::vector<ImageRef> getDisc(float radius)
{
std::vector<ImageRef> points;
int r = (int)ceil(radius + 1);
for(ImageRef p(0,-r); p.y <= r; p.y++)
for(p.x = -r; p.x <= r; p.x++)
if(p.mag_squared() <= radius*radius)
points.push_back(p);
return points;
}
};
| 28.612903
| 75
| 0.616122
|
BeLioN-github
|
03f044e8409affc3fbf02b51a3b68ca2649b3a59
| 568
|
cpp
|
C++
|
vkcup2016qual/b.cpp
|
vladshablinsky/algo
|
815392708d00dc8d3159b4866599de64fa9d34fa
|
[
"MIT"
] | 1
|
2021-10-24T00:46:37.000Z
|
2021-10-24T00:46:37.000Z
|
vkcup2016qual/b.cpp
|
vladshablinsky/algo
|
815392708d00dc8d3159b4866599de64fa9d34fa
|
[
"MIT"
] | null | null | null |
vkcup2016qual/b.cpp
|
vladshablinsky/algo
|
815392708d00dc8d3159b4866599de64fa9d34fa
|
[
"MIT"
] | null | null | null |
#include <iostream>
#include <map>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
map<string, int> mp;
vector<pair<int, string> > ans;
int main() {
int n;
cin >> n;
for (int i = 0; i < n; ++i) {
string s;
cin >> s;
mp[s] = i + 1;
}
for (map<string, int>::iterator it = mp.begin(); it != mp.end(); ++it) {
ans.push_back(make_pair(it->second, it->first));
}
sort(ans.begin(), ans.end());
for (int i = ans.size() - 1; i >= 0; --i) {
cout << ans[i].second << "\n";
}
return 0;
}
| 18.322581
| 74
| 0.545775
|
vladshablinsky
|
03f0cedc2ecc5455e338fc01ca4aaf265a168c20
| 3,212
|
cpp
|
C++
|
tab/json/cgeneratejson.cpp
|
YujieChuck/QT_HPC_study0723
|
01b1926bf09bf3e6b85de07a7149467932b15d29
|
[
"MIT"
] | null | null | null |
tab/json/cgeneratejson.cpp
|
YujieChuck/QT_HPC_study0723
|
01b1926bf09bf3e6b85de07a7149467932b15d29
|
[
"MIT"
] | null | null | null |
tab/json/cgeneratejson.cpp
|
YujieChuck/QT_HPC_study0723
|
01b1926bf09bf3e6b85de07a7149467932b15d29
|
[
"MIT"
] | null | null | null |
#include "cgeneratejson.h"
#include "Poco/File.h"
#include "Poco/Logger.h"
#include "Poco/FileStream.h"
CGenerateJson::CGenerateJson(QWidget *parent) : QWidget(parent)
{
}
int CGenerateJson::ParseJson(const std::string& jsonFile, JSON::Object::Ptr &jsonObj)
{
int parserStatus=0;
//此处判断是否是json还是其中的内容对象
Poco::File jf(jsonFile);
std::string jsonStr;
size_t preIndex=jsonFile.find_first_of("{");
size_t rearIndex=jsonFile.find_last_of("}");
if (preIndex!=-1&&rearIndex!=-1)
{
jsonStr=jsonFile;
}else
{
if (!jf.exists()){
Poco::Logger::get("TraceLog").error("Cannot find the json.");
parserStatus=-201;
// exit(-1);
}
Poco::FileInputStream fis(jsonFile);
std::ostringstream ostr;
StreamCopier::copyStream(fis, ostr);
jsonStr= ostr.str();
}
Poco::JSON::Parser sparser;
Poco::Dynamic::Var result;
try
{
result = sparser.parse(jsonStr);
}
catch (Poco::JSON::JSONException* jsone)
{
Poco::Logger::get("TraceLog").fatal(jsone->displayText());
// exit(-1);
}
catch (Poco::Exception& e)
{
Poco::Logger::get("TraceLog").fatal(e.displayText());
parserStatus=-203;
// exit(-1);
}
if (result.type() == typeid(Poco::JSON::Object::Ptr))
{
jsonObj = result.extract<Poco::JSON::Object::Ptr>();
}
else
{
Poco::Logger::get("TraceLog").fatal("Error json format.");
parserStatus=-202;
// exit(-1);
}
return parserStatus;
}
int CGenerateJson::testSetArrayElement(std::string &strJson)
{
std::string json = "[]";
Parser parser;
Var result = parser.parse(json);
Poco::JSON::Array::Ptr array = result.extract<Poco::JSON::Array::Ptr>();
Poco::Dynamic::Array dynArray = *array;
assert(dynArray.size() == 0);
// array[0] = 7
array->set(0, 7);
assert(array->size() == 1);
assert(array->getElement<int>(0) == 7);
dynArray = *array;
assert(dynArray.size() == 1);
assert(dynArray[0] == 7);
// array[2] = "foo"
array->set(2, std::string("foo"));
assert(array->size() == 3);
assert(array->getElement<int>(0) == 7);
assert(array->isNull(1));
assert(array->getElement<std::string>(2) == "foo");
dynArray = *array;
assert(dynArray.size() == 3);
assert(dynArray[0] == 7);
assert(dynArray[1].isEmpty());
assert(dynArray[2] == "foo");
// array[1] = 13
array->set(1, 13);
assert(array->size() == 3);
assert(array->getElement<int>(0) == 7);
assert(array->getElement<int>(1) == 13);
assert(array->getElement<std::string>(2) == "foo");
//Json object to string
JSON::Object jsnObj;
jsnObj.set("ArrayData",array);
std::stringstream jsnString;
jsnObj.stringify(jsnString, 3);
strJson = jsnString.str();
//#ifdef POCO_ENABLE_CPP11
// dynArray = std::move(*array);
// assert(dynArray.size() == 3);
// assert(dynArray[0] == 7);
// assert(dynArray[1] == 13);
// assert(dynArray[2] == "foo");
//#endif // POCO_ENABLE_CPP11
// dynArray.clear();
// assert(dynArray.size() == 0);
return 0;
}
| 24.519084
| 85
| 0.578456
|
YujieChuck
|
03f2f78abb1ec817c11f8f97da13bce6e6f7e45b
| 2,142
|
hh
|
C++
|
Trajectory/ClosestApproachData.hh
|
orionning676/KinKal
|
689ec932155b7fe31d46c398bcb78bcac93581d7
|
[
"Apache-1.1"
] | 2
|
2020-04-21T18:24:55.000Z
|
2020-09-24T19:01:47.000Z
|
Trajectory/ClosestApproachData.hh
|
orionning676/KinKal
|
689ec932155b7fe31d46c398bcb78bcac93581d7
|
[
"Apache-1.1"
] | 45
|
2020-03-16T18:27:59.000Z
|
2022-01-13T05:18:35.000Z
|
Trajectory/ClosestApproachData.hh
|
orionning676/KinKal
|
689ec932155b7fe31d46c398bcb78bcac93581d7
|
[
"Apache-1.1"
] | 15
|
2020-02-21T01:10:49.000Z
|
2022-03-24T12:13:35.000Z
|
#ifndef KinKal_ClosestApproachData_hh
#define KinKal_ClosestApproachData_hh
//
// data payload for CA calculations
//
#include "KinKal/General/Vectors.hh"
#include <string>
#include <vector>
#include <ostream>
namespace KinKal {
struct ClosestApproachData {
enum TPStat{converged=0,unconverged,oscillating,diverged,pocafailed,invalid};
static std::string const& statusName(TPStat status);
//accessors
VEC4 const& particlePoca() const { return partCA_; }
VEC4 const& sensorPoca() const { return sensCA_; }
double particleToca() const { return partCA_.T(); }
double sensorToca() const { return sensCA_.T(); }
VEC3 const& particleDirection() const { return pdir_; }
VEC3 const& sensorDirection() const { return sdir_; }
TPStat status() const { return status_; }
std::string const& statusName() const { return statusName(status_); }
double doca() const { return doca_; } // DOCA signed by angular momentum
double docaVar() const { return docavar_; } // uncertainty on doca due to particle trajectory parameter uncertainties (NOT sensory uncertainties)
double tocaVar() const { return tocavar_; } // uncertainty on toca due to particle trajectory parameter uncertainties (NOT sensory uncertainties)
double dirDot() const { return pdir_.Dot(sdir_); }
double lSign() const { return lsign_; } // sign of angular momentum
// utility functions
VEC4 delta() const { return sensCA_-partCA_; } // measurement - prediction convention
double deltaT() const { return sensCA_.T() - partCA_.T(); }
bool usable() const { return status_ < diverged; }
ClosestApproachData() : status_(invalid), doca_(-1.0), docavar_(-1.0), tocavar_(-1.0) {}
TPStat status_; // status of computation
double doca_, docavar_, tocavar_, lsign_;
VEC3 pdir_, sdir_; // particle and sensor directions at CA, signed by time propagation
VEC4 partCA_, sensCA_; //CA for particle and sensor
void reset() {status_ = unconverged;}
const static std::vector<std::string> statusNames_;
};
std::ostream& operator << (std::ostream& ost, ClosestApproachData const& cadata);
}
#endif
| 48.681818
| 149
| 0.715219
|
orionning676
|
03f6798e427da5b86552649e7a6eae02ec32f92f
| 3,011
|
cpp
|
C++
|
tc 160+/ChatTranscript.cpp
|
ibudiselic/contest-problem-solutions
|
88082981b4d87da843472e3ca9ed5f4c42b3f0aa
|
[
"BSD-2-Clause"
] | 3
|
2015-05-25T06:24:37.000Z
|
2016-09-10T07:58:00.000Z
|
tc 160+/ChatTranscript.cpp
|
ibudiselic/contest-problem-solutions
|
88082981b4d87da843472e3ca9ed5f4c42b3f0aa
|
[
"BSD-2-Clause"
] | null | null | null |
tc 160+/ChatTranscript.cpp
|
ibudiselic/contest-problem-solutions
|
88082981b4d87da843472e3ca9ed5f4c42b3f0aa
|
[
"BSD-2-Clause"
] | 5
|
2015-05-25T06:24:40.000Z
|
2021-08-19T19:22:29.000Z
|
#include <algorithm>
#include <cassert>
#include <cstdio>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <cstring>
using namespace std;
bool sw(const string &a, const string &b) {
if (a.size() < b.size())
return false;
for (int i=0; i<(int)b.size(); ++i)
if (a[i] != b[i])
return false;
return true;
}
class ChatTranscript {
public:
int howMany(vector <string> transcript, string name) {
name += ':';
int sol = 0;
for (int i=0; i<(int)transcript.size(); ++i)
sol += sw(transcript[i], name);
return sol;
}
// BEGIN CUT HERE
public:
void run_test(int Case) { if ((Case == -1) || (Case == 0)) test_case_0(); if ((Case == -1) || (Case == 1)) test_case_1(); if ((Case == -1) || (Case == 2)) test_case_2(); if ((Case == -1) || (Case == 3)) test_case_3(); if ((Case == -1) || (Case == 4)) test_case_4(); }
private:
template <typename T> string print_array(const vector<T> &V) { ostringstream os; os << "{ "; for (typename vector<T>::const_iterator iter = V.begin(); iter != V.end(); ++iter) os << '\"' << *iter << "\","; os << " }"; return os.str(); }
void verify_case(int Case, const int &Expected, const int &Received) { cerr << "Test Case #" << Case << "..."; if (Expected == Received) cerr << "PASSED" << endl; else { cerr << "FAILED" << endl; cerr << "\tExpected: \"" << Expected << '\"' << endl; cerr << "\tReceived: \"" << Received << '\"' << endl; } }
void test_case_0() { string Arr0[] = {
"Bob: Hello Tim.",
"Tim: Hello Bob.",
"Bob: How are ya Tim?",
"Frank: Stop chatting!"
}; vector <string> Arg0(Arr0, Arr0 + (sizeof(Arr0) / sizeof(Arr0[0]))); string Arg1 = "Bob"; int Arg2 = 2; verify_case(0, Arg2, howMany(Arg0, Arg1)); }
void test_case_1() { string Arr0[] = {
"Bob: This is a long",
"sentence that takes 2 lines.",
"Tim: Yes it is.",
"Bob : I am not Bob.",
"Frank: No you aren't!",
" Bob: Neither am I."
}; vector <string> Arg0(Arr0, Arr0 + (sizeof(Arr0) / sizeof(Arr0[0]))); string Arg1 = "Bob"; int Arg2 = 1; verify_case(1, Arg2, howMany(Arg0, Arg1)); }
void test_case_2() { string Arr0[] = {
"Crazy1010: !@LK%#L%K @#L%K @#L%K@#L%K2kl53k2",
"Bob: You are crazy.",
"Crazy1010 Yup #@LK%$L!K%LK%!K% !K afmas,"
}; vector <string> Arg0(Arr0, Arr0 + (sizeof(Arr0) / sizeof(Arr0[0]))); string Arg1 = "Crazy1010"; int Arg2 = 1; verify_case(2, Arg2, howMany(Arg0, Arg1)); }
void test_case_3() { string Arr0[] = {
"A:A:A:A:A:A:A:A:A",
"b:b:b:b:b:b:b:b:b"
}; vector <string> Arg0(Arr0, Arr0 + (sizeof(Arr0) / sizeof(Arr0[0]))); string Arg1 = "B"; int Arg2 = 0; verify_case(3, Arg2, howMany(Arg0, Arg1)); }
void test_case_4() { string Arr0[] = {"A:A:A:A:A:A:A:A:A"}; vector <string> Arg0(Arr0, Arr0 + (sizeof(Arr0) / sizeof(Arr0[0]))); string Arg1 = "A"; int Arg2 = 1; verify_case(4, Arg2, howMany(Arg0, Arg1)); }
// END CUT HERE
};
// BEGIN CUT HERE
int main()
{
ChatTranscript ___test;
___test.run_test(-1);
}
// END CUT HERE
| 36.719512
| 309
| 0.580206
|
ibudiselic
|
03fc84a50e04e2d8e75f2c8d959ca73530426dd9
| 5,450
|
cpp
|
C++
|
dependencies/MyGui/Tools/SkinEditor/SeparatorListControl.cpp
|
amvb/GUCEF
|
08fd423bbb5cdebbe4b70df24c0ae51716b65825
|
[
"Apache-2.0"
] | 5
|
2016-04-18T23:12:51.000Z
|
2022-03-06T05:12:07.000Z
|
dependencies/MyGui/Tools/SkinEditor/SeparatorListControl.cpp
|
amvb/GUCEF
|
08fd423bbb5cdebbe4b70df24c0ae51716b65825
|
[
"Apache-2.0"
] | 2
|
2015-10-09T19:13:25.000Z
|
2018-12-25T17:16:54.000Z
|
dependencies/MyGui/Tools/SkinEditor/SeparatorListControl.cpp
|
amvb/GUCEF
|
08fd423bbb5cdebbe4b70df24c0ae51716b65825
|
[
"Apache-2.0"
] | 15
|
2015-02-23T16:35:28.000Z
|
2022-03-25T13:40:33.000Z
|
/*!
@file
@author Albert Semenov
@date 08/2010
*/
#include "Precompiled.h"
#include "SeparatorListControl.h"
#include "SkinManager.h"
#include "Binary.h"
#include "Localise.h"
namespace tools
{
enum SeparatorPreset
{
SeparatorPresetScale = Binary<0>::value,
SeparatorPreset9Slice = Binary<1111>::value,
SeparatorPreset3SliceHorScale = Binary<1100>::value,
SeparatorPreset3SliceVertScale = Binary<11>::value
};
SeparatorListControl::SeparatorListControl(MyGUI::Widget* _parent) :
wraps::BaseLayout("SeparatorListControl.layout", _parent),
mList(nullptr),
mPresets(nullptr)
{
mTypeName = MyGUI::utility::toString((size_t)this);
assignWidget(mList, "List");
assignWidget(mPresets, "Presets");
fillPresets();
mList->eventListChangePosition += MyGUI::newDelegate(this, &SeparatorListControl::notifyChangePosition);
mPresets->eventComboChangePosition += MyGUI::newDelegate(this, &SeparatorListControl::notifyComboChangePosition);
initialiseAdvisor();
}
SeparatorListControl::~SeparatorListControl()
{
shutdownAdvisor();
mPresets->eventComboChangePosition -= MyGUI::newDelegate(this, &SeparatorListControl::notifyComboChangePosition);
mList->eventListChangePosition -= MyGUI::newDelegate(this, &SeparatorListControl::notifyChangePosition);
}
void SeparatorListControl::notifyChangePosition(MyGUI::ListBox* _sender, size_t _index)
{
if (getCurrentSkin() != nullptr)
{
SeparatorItem* item = nullptr;
if (_index != MyGUI::ITEM_NONE)
item = *mList->getItemDataAt<SeparatorItem*>(_index);
getCurrentSkin()->getSeparators().setItemSelected(item);
}
}
void SeparatorListControl::updateSeparatorProperty(Property* _sender, const MyGUI::UString& _owner)
{
if (_sender->getName() == "Visible")
updateList();
if (_owner != mTypeName)
updatePreset();
}
void SeparatorListControl::updateSeparatorProperties()
{
updateList();
}
void SeparatorListControl::updateSkinProperties()
{
updatePreset();
}
void SeparatorListControl::updateList()
{
if (getCurrentSkin() != nullptr)
{
SeparatorItem* selectedItem = getCurrentSkin()->getSeparators().getItemSelected();
size_t selectedIndex = MyGUI::ITEM_NONE;
size_t index = 0;
ItemHolder<SeparatorItem>::EnumeratorItem separators = getCurrentSkin()->getSeparators().getChildsEnumerator();
while (separators.next())
{
SeparatorItem* item = separators.current();
MyGUI::UString name;
if (item->getPropertySet()->getPropertyValue("Visible") != "True")
name = replaceTags("ColourDisabled") + item->getName();
else
name = item->getName();
if (index < mList->getItemCount())
{
mList->setItemNameAt(index, name);
mList->setItemDataAt(index, item);
}
else
{
mList->addItem(name, item);
}
if (item == selectedItem)
selectedIndex = index;
index ++;
}
while (index < mList->getItemCount())
mList->removeItemAt(mList->getItemCount() - 1);
mList->setIndexSelected(selectedIndex);
}
}
void SeparatorListControl::fillPresets()
{
mPresets->removeAllItems();
mPresets->addItem(replaceTags("PresetRegionOneScale"), SeparatorPresetScale);
mPresets->addItem(replaceTags("PresetRegion9Grid"), SeparatorPreset9Slice);
mPresets->addItem(replaceTags("PresetRegion3Hor"), SeparatorPreset3SliceHorScale);
mPresets->addItem(replaceTags("PresetRegion3Vert"), SeparatorPreset3SliceVertScale);
mPresets->beginToItemFirst();
}
void SeparatorListControl::notifyComboChangePosition(MyGUI::ComboBox* _sender, size_t _index)
{
if (getCurrentSkin() == nullptr)
return;
if (_index == MyGUI::ITEM_NONE)
return;
SeparatorPreset preset = *_sender->getItemDataAt<SeparatorPreset>(_index);
size_t index = 0;
ItemHolder<SeparatorItem>::EnumeratorItem separators = getCurrentSkin()->getSeparators().getChildsEnumerator();
while (separators.next())
{
SeparatorItem* item = separators.current();
MyGUI::UString value = ((preset & (1 << index)) != 0) ? "True" : "False";
item->getPropertySet()->setPropertyValue("Visible", value, mTypeName);
++index;
}
// для обновления пропертей
getCurrentSkin()->getSeparators().setItemSelected(nullptr);
updateList();
}
void SeparatorListControl::updatePreset()
{
mPresets->setEnabled(getCurrentSkin() != nullptr);
if (getCurrentSkin() != nullptr)
{
int currentPreset = 0;
int bitIndex = 0;
ItemHolder<SeparatorItem>::EnumeratorItem separators = getCurrentSkin()->getSeparators().getChildsEnumerator();
while (separators.next())
{
SeparatorItem* item = separators.current();
bool visible = item->getPropertySet()->getPropertyValue("Visible") == "True";
if (visible)
currentPreset |= (1 << bitIndex);
++ bitIndex;
}
size_t indexSelected = MyGUI::ITEM_NONE;
size_t count = mPresets->getItemCount();
for (size_t index = 0; index < count; ++index)
{
SeparatorPreset preset = *mPresets->getItemDataAt<SeparatorPreset>(index);
if (preset == currentPreset)
{
indexSelected = index;
break;
}
}
mPresets->setIndexSelected(indexSelected);
mPresets->setEnabled(true);
}
else
{
mPresets->setEnabled(false);
}
}
} // namespace tools
| 26.585366
| 116
| 0.682569
|
amvb
|
03ff25390780aa564c57c1f4fba9cd900c2cde99
| 1,350
|
cpp
|
C++
|
attacker/SSL/AttackSplitPacket.cpp
|
satadriver/attacker
|
24e4434d8a836e040e48df195f2ca8919ab52609
|
[
"Apache-2.0"
] | null | null | null |
attacker/SSL/AttackSplitPacket.cpp
|
satadriver/attacker
|
24e4434d8a836e040e48df195f2ca8919ab52609
|
[
"Apache-2.0"
] | null | null | null |
attacker/SSL/AttackSplitPacket.cpp
|
satadriver/attacker
|
24e4434d8a836e040e48df195f2ca8919ab52609
|
[
"Apache-2.0"
] | 1
|
2022-03-20T03:21:00.000Z
|
2022-03-20T03:21:00.000Z
|
#include "AttackSplitPacket.h"
#include "../HttpUtils.h"
char *iqiyiandroidhdr = "GET /fusion/3.0/plugin?";
int iqiyiandroidhdrlen = lstrlenA(iqiyiandroidhdr);
char * qqnewshdr = "GET /getVideoSo?version=";
int qqnewshdrlen = lstrlenA(qqnewshdr);
int AttackSplitPacket::splitPacket(char * recvbuf, int &icount, LPHTTPPROXYPARAM lphttp,
string & httphdr, char ** httpdata, string &url, string & host, int &port) {
for(int i = 0; i < 8; i ++)
{
if (icount >= 8192)
{
break;
}
int nextlen = recv(lphttp->sockToClient, recvbuf + icount, NETWORK_BUFFER_SIZE - icount, 0);
if (nextlen <= 0)
{
break;
}
else {
icount += nextlen;
*(recvbuf + icount) = 0;
}
}
int type = 0;
return HttpUtils::parseHttpHdr(recvbuf, icount, type, httphdr, httpdata, url, host, port);
}
int AttackSplitPacket::splitPacket(char * recvbuf, int &icount, LPSSLPROXYPARAM lpssl,
string & httphdr, char ** httpdata, string &url, string &host, int &port) {
for (int i = 0; i < 8; i++) {
if (icount >= 8192)
{
break;
}
int nextlen = SSL_read(lpssl->SSLToClient, recvbuf + icount, NETWORK_BUFFER_SIZE - icount);
if (nextlen <= 0)
{
break;
}
else {
icount += nextlen;
*(recvbuf + icount) = 0;
}
}
int type = 0;
return HttpUtils::parseHttpHdr(recvbuf, icount, type, httphdr, httpdata, url, host, port);
}
| 21.774194
| 94
| 0.651852
|
satadriver
|
ff00326efae8a6e4994ce48a01ba5c5cf6a8a509
| 10,086
|
ipp
|
C++
|
protean/detail/data_table_variant_iterator.ipp
|
llawall/protean
|
31496f177704dc31b24cda5863e5ca921f5f0945
|
[
"BSL-1.0"
] | null | null | null |
protean/detail/data_table_variant_iterator.ipp
|
llawall/protean
|
31496f177704dc31b24cda5863e5ca921f5f0945
|
[
"BSL-1.0"
] | null | null | null |
protean/detail/data_table_variant_iterator.ipp
|
llawall/protean
|
31496f177704dc31b24cda5863e5ca921f5f0945
|
[
"BSL-1.0"
] | null | null | null |
// (C) Copyright Johan Ditmar, Karel Hruda, Paul O'Neill & Luke Stedman 2009.
// Use, modification and distribution are subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt).
#include <algorithm>
namespace protean { namespace detail {
/* Column iterator implementations */
/***********************************/
template <typename T, typename IteratorTraits>
data_table_column_variant_iterator_interface<T, IteratorTraits>::
data_table_column_variant_iterator_interface(const source_iterator_type& iterator)
: m_iterator(iterator)
{}
template <typename T, typename IteratorTraits>
const std::string& data_table_column_variant_iterator_interface<T, IteratorTraits>::key() const
{
boost::throw_exception(variant_error("Attempt to call key() on data table column variant iterator"));
}
template <typename T, typename IteratorTraits>
//const typename data_table_column_variant_iterator_interface<T, IteratorTraits>::base::date_time_t&
const typename data_table_column_variant_iterator_interface<T, IteratorTraits>::date_time_type&
data_table_column_variant_iterator_interface<T, IteratorTraits>::time() const
{
boost::throw_exception(variant_error("Attempt to call time() on data table column variant iterator"));
}
template <typename T, typename IteratorTraits>
typename data_table_column_variant_iterator_interface<T, IteratorTraits>::reference
data_table_column_variant_iterator_interface<T, IteratorTraits>::value() const
{
make_copy<T>();
return m_copy;
}
template <typename T, typename IteratorTraits>
void data_table_column_variant_iterator_interface<T, IteratorTraits>::increment()
{
++m_iterator;
}
template <typename T, typename IteratorTraits>
void data_table_column_variant_iterator_interface<T, IteratorTraits>::decrement()
{
--m_iterator;
}
template <typename T, typename IteratorTraits>
bool data_table_column_variant_iterator_interface<T, IteratorTraits>::equal(const variant_const_iterator_base* rhs) const
{
const data_table_column_variant_iterator_interface<T>* cast_rhs =
dynamic_cast<const data_table_column_variant_iterator_interface<T>*>(rhs);
if (cast_rhs == 0)
boost::throw_exception(variant_error("Unable to convert iterator to data table column variant iterator"));
return m_iterator == cast_rhs->m_iterator;
}
template <typename T, typename IteratorTraits>
typename data_table_column_variant_iterator_interface<T, IteratorTraits>::base*
data_table_column_variant_iterator_interface<T, IteratorTraits>::clone()
{
return new data_table_column_variant_iterator_interface(m_iterator);
}
template <typename T, typename IteratorTraits>
variant_const_iterator_base* data_table_column_variant_iterator_interface<T, IteratorTraits>::to_const() const
{
return new data_table_column_variant_iterator_interface<T, const_iterator_traits>(m_iterator);
}
/* Variant column specialization */
/*********************************/
template <typename IteratorTraits>
data_table_column_variant_iterator_interface<variant, IteratorTraits>::
data_table_column_variant_iterator_interface(const source_iterator_type& iterator)
: m_iterator(iterator)
{}
template <typename IteratorTraits>
const std::string& data_table_column_variant_iterator_interface<variant, IteratorTraits>::key() const
{
boost::throw_exception(variant_error("Attempt to call key() on data table column variant iterator"));
}
template <typename IteratorTraits>
const typename data_table_column_variant_iterator_interface<variant, IteratorTraits>::date_time_type&
data_table_column_variant_iterator_interface<variant, IteratorTraits>::time() const
{
boost::throw_exception(variant_error("Attempt to call time() on data table column variant iterator"));
}
template <typename IteratorTraits>
typename data_table_column_variant_iterator_interface<variant, IteratorTraits>::reference
data_table_column_variant_iterator_interface<variant, IteratorTraits>::value() const
{
return *m_iterator;
}
template <typename IteratorTraits>
void data_table_column_variant_iterator_interface<variant, IteratorTraits>::increment()
{
++m_iterator;
}
template <typename IteratorTraits>
void data_table_column_variant_iterator_interface<variant, IteratorTraits>::decrement()
{
--m_iterator;
}
template <typename IteratorTraits>
bool data_table_column_variant_iterator_interface<variant, IteratorTraits>::
equal(const variant_const_iterator_base* rhs) const
{
const data_table_column_variant_iterator_interface<variant>* cast_rhs =
dynamic_cast<const data_table_column_variant_iterator_interface<variant>*>(rhs);
if (cast_rhs == 0)
boost::throw_exception(variant_error("Unable to convert iterator to data table column variant iterator"));
return m_iterator == cast_rhs->m_iterator;
}
template <typename IteratorTraits>
typename data_table_column_variant_iterator_interface<variant, IteratorTraits>::base*
data_table_column_variant_iterator_interface<variant, IteratorTraits>::clone()
{
return new data_table_column_variant_iterator_interface(m_iterator);
}
template <typename IteratorTraits>
variant_const_iterator_base* data_table_column_variant_iterator_interface<variant, IteratorTraits>::
to_const() const
{
return new data_table_column_variant_iterator_interface<variant, const_iterator_traits>(m_iterator);
}
/* Row iterator implementations */
/********************************/
template <
typename IteratorTraits,
typename Base
>
data_table_variant_iterator_interface<IteratorTraits, Base>::
data_table_variant_iterator_interface(const column_iterator_container& column_iterators)
: m_column_iterators(column_iterators)
{}
template <
typename IteratorTraits,
typename Base
>
const std::string& data_table_variant_iterator_interface<IteratorTraits, Base>::key() const
{
boost::throw_exception(variant_error("Attempt to call key() on data table variant iterator"));
}
template <
typename IteratorTraits,
typename Base
>
const typename Base::date_time_t& data_table_variant_iterator_interface<IteratorTraits, Base>::time() const
{
boost::throw_exception(variant_error("Attempt to call time() on data table"));
}
template <
typename IteratorTraits,
typename Base
>
typename data_table_variant_iterator_interface<IteratorTraits, Base>::reference
data_table_variant_iterator_interface<IteratorTraits, Base>::value() const
{
variant tuple(variant_base::Tuple, m_column_iterators.size());
for (size_t i = 0; i < m_column_iterators.size(); ++i)
tuple.at(i) = *(m_column_iterators[i]);
m_copy = tuple;
return m_copy;
}
template <
typename IteratorTraits,
typename Base
>
void data_table_variant_iterator_interface<IteratorTraits, Base>::increment()
{
for (typename column_iterator_container::iterator iter = m_column_iterators.begin()
; iter != m_column_iterators.end()
; ++iter)
++(*iter);
}
template <
typename IteratorTraits,
typename Base
>
void data_table_variant_iterator_interface<IteratorTraits, Base>::decrement()
{
for (typename column_iterator_container::iterator iter = m_column_iterators.begin()
; iter != m_column_iterators.end()
; ++iter)
--(*iter);
}
template <
typename IteratorTraits,
typename Base
>
bool data_table_variant_iterator_interface<IteratorTraits, Base>::equal(const variant_const_iterator_base* rhs) const
{
const data_table_variant_iterator_interface<const_iterator_traits>* cast_rhs =
dynamic_cast<const data_table_variant_iterator_interface<const_iterator_traits>*>(rhs);
if (cast_rhs == 0)
boost::throw_exception(variant_error("Unable to convert iterator to data table variant iterator"));
if (m_column_iterators.size() != cast_rhs->m_column_iterators.size())
boost::throw_exception(variant_error("Unable to compare variant iterators of two DataTables that have a different number of columns"));
for (size_t i = 0; i < m_column_iterators.size(); ++i)
if (m_column_iterators[i] != cast_rhs->m_column_iterators[i])
return false;
return true;
}
template <
typename IteratorTraits,
typename Base
>
Base* data_table_variant_iterator_interface<IteratorTraits, Base>::clone()
{
return new data_table_variant_iterator_interface(m_column_iterators);
}
template <
typename IteratorTraits,
typename Base
>
variant_const_iterator_base* data_table_variant_iterator_interface<IteratorTraits, Base>::to_const() const
{
typedef typename data_table_variant_iterator_interface<const_iterator_traits>::column_iterator_container
const_column_iterator_container;
const_column_iterator_container const_column_iterators;
const_column_iterators.reserve( m_column_iterators.size() );
std::copy( m_column_iterators.begin(), m_column_iterators.end(), std::back_inserter( const_column_iterators ) );
return new data_table_variant_iterator_interface<const_iterator_traits>(const_column_iterators);
}
}} // namespace protean::detail
| 38.496183
| 147
| 0.706226
|
llawall
|
ff01803da7289057a631b20c6010fef2a9131fac
| 6,822
|
cpp
|
C++
|
src/unit_tests/test_rexi_pde2x2.cpp
|
valentinaschueller/sweet
|
27e99c7a110c99deeadee70688c186d82b39ac90
|
[
"MIT"
] | 6
|
2017-11-20T08:12:46.000Z
|
2021-03-11T15:32:36.000Z
|
src/unit_tests/test_rexi_pde2x2.cpp
|
valentinaschueller/sweet
|
27e99c7a110c99deeadee70688c186d82b39ac90
|
[
"MIT"
] | 4
|
2018-02-02T21:46:33.000Z
|
2022-01-11T11:10:27.000Z
|
src/unit_tests/test_rexi_pde2x2.cpp
|
valentinaschueller/sweet
|
27e99c7a110c99deeadee70688c186d82b39ac90
|
[
"MIT"
] | 12
|
2016-03-01T18:33:34.000Z
|
2022-02-08T22:20:31.000Z
|
/*
* test_rexi_file.cpp
*
* Created on: 25 Dec 2018
* Author: Martin Schreiber <schreiberx@gmail.com>
*/
#include <iostream>
#include <sweet/SimulationVariables.hpp>
#include <quadmath.h>
#include <rexi/EXPFunctions.hpp>
#include <rexi/REXI.hpp>
#include <rexi/REXICoefficients.hpp>
#define TEST_REXI_PDE_QUADPRECISION 0
#if TEST_REXI_PDE_QUADPRECISION
typedef __float128 T;
#else
typedef double T;
#endif
EXPFunctions<T> rexiFunctions;
std::complex<double> fromTtoComplexDouble(
const std::complex<T> &i_value
)
{
std::complex<double> value;
value.real(i_value.real());
value.imag(i_value.imag());
return value;
}
std::complex<T> fromComplexDoubleToT(
const std::complex<double> &i_value
)
{
std::complex<T> value;
value.real(i_value.real());
value.imag(i_value.imag());
return value;
}
typedef std::complex<T> Tcomplex;
void solveLalpha(
const Tcomplex i_lambda, ///< stiffness
const T i_dt, ///< timestep size
const Tcomplex &i_alpha, ///< REXI shift
const Tcomplex &i_beta, ///< REXI shift
const Tcomplex i_u[2], ///< state variable
Tcomplex o_u[2] ///< output after REXI computation
)
{
Tcomplex i(0, 1);
const Tcomplex alpha = i_alpha/i_dt;
const Tcomplex beta = i_beta/i_dt;
Tcomplex val = Tcomplex(1.0)/(i_lambda*i_lambda - alpha*alpha);
Tcomplex ia = i*i_lambda;
o_u[0] = beta*(val*(alpha*i_u[0] + ia*i_u[1]));
o_u[1] = beta*(val*(-ia*i_u[0] + alpha*i_u[1]));
}
void computeLU(
const Tcomplex &i_lambda,
const Tcomplex i_u[2], ///< state variable
Tcomplex o_LU[2] ///< output after REXI computation
)
{
o_LU[0] = (i_u[1]*i_lambda);
o_LU[1] = (-i_u[0]*i_lambda);
}
void analyticalIntegration(
const Tcomplex &i_lambda, ///< stiffness
T i_dt, ///< timestep size
const Tcomplex i_u[2], ///< state variable
Tcomplex o_u[2] ///< output after REXI computation
)
{
Tcomplex I(0, 1);
Tcomplex tmp[2];
tmp[0] = Tcomplex(0.5)*(-I*i_u[0] + i_u[1]);
tmp[1] = Tcomplex(0.5)*(I*i_u[0] + i_u[1]);
Tcomplex K = i_dt*i_lambda;
tmp[0] = rexiFunctions.eval(K)*tmp[0];
tmp[1] = rexiFunctions.eval(-K)*tmp[1];
o_u[0] = I*tmp[0] - I*tmp[1];
o_u[1] = tmp[0] + tmp[1];
}
void rexiIntegrationBasedOnPDE(
const Tcomplex &i_lambda, ///< stiffness
T i_dt, ///< timestep size
const REXICoefficients<T> &i_rexiCoefficients,
Tcomplex io_u[2] ///< state variable
)
{
Tcomplex o_u[2] = {0.0, 0.0};
for (std::size_t i = 0; i < i_rexiCoefficients.alphas.size(); i++)
{
Tcomplex ru[2];
solveLalpha(
i_lambda, ///< stiffness
i_dt,
i_rexiCoefficients.alphas[i], ///< REXI shift
i_rexiCoefficients.betas[i],
io_u, ///< state variable
ru
);
o_u[0] += ru[0];
o_u[1] += ru[1];
}
o_u[0] += i_rexiCoefficients.gamma * io_u[0];
o_u[1] += i_rexiCoefficients.gamma * io_u[1];
io_u[0] = o_u[0];
io_u[1] = o_u[1];
}
/**
* \return \f$ Re(cos(x) + i*sin(x)) = cos(x) \f$
*/
std::complex<T> approx_returnComplex(
std::vector< std::complex<T> > &alpha,
std::vector< std::complex<T> > &beta_re,
T i_x
)
{
std::complex<T> sum = 0;
std::size_t S = alpha.size();
for (std::size_t n = 0; n < S; n++)
sum += beta_re[n] / (std::complex<T>(0, i_x) - alpha[n]);
return sum;
}
double lmax(
const Tcomplex Uanal[2],
const Tcomplex U[2]
)
{
return std::max(
std::abs( (double)Uanal[0].real() - (double)U[0].real() ),
std::abs( (double)Uanal[1].real() - (double)U[1].real() )
);
}
int main(
int i_argc,
char *const i_argv[]
)
{
SimulationVariables simVars;
if (!simVars.setupFromMainParameters(i_argc, i_argv, nullptr, false))
return -1;
simVars.outputConfig();
if (simVars.rexi.exp_method != "file")
{
if (simVars.rexi.exp_method == "terry")
{
simVars.rexi.p_rexi_files_processed.push_back(EXP_SimulationVariables::REXIFile("phi0", ""));
}
else if (simVars.rexi.exp_method == "ci")
{
std::string function_names[9] =
{
"phi0",
"phi1",
"phi2",
"phi3",
"phi4",
"phi5",
"ups1",
"ups2",
"ups3",
};
for (int i = 0; i < 9; i++)
simVars.rexi.p_rexi_files_processed.push_back(EXP_SimulationVariables::REXIFile(function_names[i], ""));
}
else
{
SWEETError("rexi_method not supported");
}
}
T max_error_threshold = 1e-8;
for (std::size_t i = 0; i < simVars.rexi.p_rexi_files_processed.size(); i++)
{
const std::string &function_name = simVars.rexi.p_rexi_files_processed[i].function_name;
std::cout << "******************************************************" << std::endl;
std::cout << " Function name: " << function_name << std::endl;
std::cout << "******************************************************" << std::endl;
rexiFunctions.setup(function_name);
REXICoefficients<T> rexiCoefficients;
REXI<T>::load(
&simVars.rexi,
function_name,
rexiCoefficients,
simVars.misc.verbosity
);
/*
* Initial conditions: U(0)
*
* Note, that this is a real-valued initial condition
*/
Tcomplex U0[2];
U0[0] = 1.0;
U0[1] = 0.0;
/*
* Current state: U(t)
*/
Tcomplex U[2];
U[0] = U0[0];
U[1] = U0[1];
/*
* Stiffness is specified here
*
* Oscillatory stiffness: imaginary-only
*/
Tcomplex lambda = {0.0, 1.0/M_PI};
/*
* Analytic solution
*/
Tcomplex Uanal[2];
double timestep_size = 0.3;
double simtime = 0;
//cplx evalue = lambda*timestep_size;
//std::cout << "Effective stiffness (lambda*dt): " << fromTtoComplexDouble(evalue) << std::endl;
int tnr_max = 100;
//int tnr_max = (int)(M_PI*2.0/(timestep_size*lambda.imag()));
int tnr = 0;
while (tnr < tnr_max)
{
tnr++;
simtime += timestep_size;
analyticalIntegration(
lambda,
simtime,
U0,
Uanal
);
if (function_name == "phi0")
{
rexiIntegrationBasedOnPDE(
lambda,
timestep_size,
rexiCoefficients,
U
);
}
else
{
/*
* Integrate over entire interval since there's a damping,
* hence a memorization of the current state
*/
U[0] = U0[0];
U[1] = U0[1];
rexiIntegrationBasedOnPDE(
lambda,
simtime,
rexiCoefficients,
U
);
}
U[0].imag(0);
U[1].imag(0);
double error = lmax(Uanal, U);
std::cout << "t = " << (double)simtime;
std::cout << "\tU=(" << fromTtoComplexDouble(U[0]) << ", " << fromTtoComplexDouble(U[1]) << ")";
std::cout << "\tUanal=(" << fromTtoComplexDouble(Uanal[0]) << ", " << fromTtoComplexDouble(Uanal[1]) << ")";
// std::cout << "\tUreallen=(" << (double)lenreal(U[0], U[1]) << ")";
// std::cout << "\tUanalreallen=(" << (double)lenreal(Uanal[0], Uanal[1]) << ")";
std::cout << "\tlmax=" << error << "";
std::cout << std::endl;
#if 1
if (error > max_error_threshold)
SWEETError("Error too high");
#endif
}
}
return 0;
}
| 19.831395
| 111
| 0.602316
|
valentinaschueller
|
ff062297f7959320468560f260d19a14159c15ca
| 793
|
cpp
|
C++
|
src/AST/expressions/ternary.cpp
|
Asixa/Dragonfly
|
ef599c8a7f9d756159cd80a61dcc70fd128ef67f
|
[
"Apache-2.0"
] | 2
|
2020-10-23T08:17:47.000Z
|
2020-10-25T06:36:58.000Z
|
src/AST/expressions/ternary.cpp
|
Asixa/Dragonfly
|
ef599c8a7f9d756159cd80a61dcc70fd128ef67f
|
[
"Apache-2.0"
] | null | null | null |
src/AST/expressions/ternary.cpp
|
Asixa/Dragonfly
|
ef599c8a7f9d756159cd80a61dcc70fd128ef67f
|
[
"Apache-2.0"
] | null | null | null |
#include "AST/expressions/ternary.h"
#include "frontend/debug.h"
#include "AST/program.h"
namespace AST {
void expr::Ternary::ToString() {
*Debugger::out << "[";
a->ToString();
*Debugger::out << "?";
b->ToString();
*Debugger::out << ":";
c->ToString();
*Debugger::out << "]";
}
std::shared_ptr<AST::Type> expr::Ternary::Analysis(std::shared_ptr<DFContext>) { return nullptr; }
std::shared_ptr<expr::Expr> expr::Ternary::Parse() {
const auto a = Binary::Sub7();
if (Lexer::token->type != '?')return a;
Lexer::Next();
const auto b = Binary::Sub7();
Lexer::Match(':');
const auto c = Binary::Sub7();
return std::make_shared<Ternary>(a, b, c);
}
llvm::Value* expr::Ternary::Gen(std::shared_ptr<DFContext> context, bool is_ptr) {
return nullptr;
}
}
| 24.030303
| 102
| 0.620429
|
Asixa
|
ff0bcb30decfd7c4567b5cc7aa703492752432dc
| 2,495
|
cpp
|
C++
|
src/Base64.cpp
|
kgbook/tupu-cpp-sdk
|
4b3449ff3914cd05b628e39ded41197e8492c5eb
|
[
"MIT"
] | 2
|
2016-12-29T01:36:58.000Z
|
2018-06-08T16:03:39.000Z
|
src/Base64.cpp
|
kgbook/tupu-cpp-sdk
|
4b3449ff3914cd05b628e39ded41197e8492c5eb
|
[
"MIT"
] | null | null | null |
src/Base64.cpp
|
kgbook/tupu-cpp-sdk
|
4b3449ff3914cd05b628e39ded41197e8492c5eb
|
[
"MIT"
] | 4
|
2017-03-21T01:40:06.000Z
|
2021-07-07T12:20:20.000Z
|
/******************************************************************************
* TUPU Recognition API SDK
* Copyright(c)2013-2016, TUPU Technology
* http://www.tuputech.com
*****************************************************************************/
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <limits.h>
// #include <stdexcept>
// #include <cctype>
#include <iostream>
#include <openssl/evp.h>
#include <openssl/bio.h>
#include <openssl/buffer.h>
#include "Base64.hpp"
using namespace std;
string TUPU::base64_encode(const void * input, size_t input_len)
{
BIO *bmem, *b64;
BUF_MEM * bptr = NULL;
b64 = BIO_new(BIO_f_base64());
bmem = BIO_new(BIO_s_mem());
b64 = BIO_push(b64, bmem);
//Ignore newlines - write everything in one line
BIO_set_flags(b64, BIO_FLAGS_BASE64_NO_NL);
BIO_write(b64, input, input_len);
if (BIO_flush(b64) != 1) {
BIO_free_all(b64);
return "";
}
BIO_get_mem_ptr(b64, &bptr);
char * buffer = (char *)malloc(bptr->length + 1);
memcpy(buffer, bptr->data, bptr->length);
buffer[bptr->length] = 0;
string result(buffer, bptr->length + 1);
free(buffer);
//BIO_set_close(b64, BIO_NOCLOSE);
BIO_free_all(b64);
return result;
}
//Calculates the length of a decoded string
size_t calcDecodeLength(const char* b64input)
{
size_t len = strlen(b64input),
padding = 0;
if (b64input[len-1] == '=' && b64input[len-2] == '=') //last two chars are =
padding = 2;
else if (b64input[len-1] == '=') //last char is =
padding = 1;
return (len*3)/4 - padding;
}
int TUPU::base64_decode(const string & ascdata, void **buf_ptr, size_t *but_len)
{
BIO *bmem, *b64;
size_t input_len = ascdata.size() + 1;
char *input = (char *)malloc(input_len);
memset(input, 0, input_len);
strcpy(input, ascdata.c_str());
int length = calcDecodeLength(input);
unsigned char *buffer = (unsigned char*)malloc(length + 1);
memset(buffer, 0, length + 1);
b64 = BIO_new(BIO_f_base64());
bmem = BIO_new_mem_buf(input, -1);
b64 = BIO_push(b64, bmem);
//Do not use newlines to flush buffer
BIO_set_flags(b64, BIO_FLAGS_BASE64_NO_NL);
size_t len = BIO_read(b64, buffer, length);
assert(len == (size_t)length);
//string result((char*)buffer, length);
//free(buffer);
BIO_free_all(b64);
*buf_ptr = buffer;
*but_len = length;
free(input);
return 0;
}
| 24.70297
| 80
| 0.593186
|
kgbook
|
ff0c608a22e5866bb12a0d90baf14d7eea58689e
| 863
|
cpp
|
C++
|
src/services.tests/depend.cpp
|
moducom/services
|
fc148e5f72c403481951f0063c639b58377187f7
|
[
"MIT"
] | null | null | null |
src/services.tests/depend.cpp
|
moducom/services
|
fc148e5f72c403481951f0063c639b58377187f7
|
[
"MIT"
] | null | null | null |
src/services.tests/depend.cpp
|
moducom/services
|
fc148e5f72c403481951f0063c639b58377187f7
|
[
"MIT"
] | null | null | null |
#include "catch2/catch.hpp"
#include "services.h"
using namespace moducom::services;
TEST_CASE("dependency")
{
EventGenerator eventGenerator;
entt::registry registry;
agents::EnttHelper enttHelper(registry, registry.create());
agents::Event<Event1> agent1(enttHelper);
agents::Event<Event1> agent2(enttHelper);
SECTION("Depends 1")
{
agents::Depender depender;
depender.add(agent1);
REQUIRE(depender.anyNotRunning());
REQUIRE(!depender.satisfied());
depender.add(agent2);
agent1.construct(eventGenerator);
REQUIRE(depender.anyNotRunning());
REQUIRE(!depender.satisfied());
agent2.construct(eventGenerator);
REQUIRE(!depender.anyNotRunning());
REQUIRE(depender.satisfied());
agent1.destruct();
agent2.destruct();
}
}
| 22.128205
| 63
| 0.648899
|
moducom
|
ff0d262b9c112571acbfdb3b78ae896c50a79944
| 20,538
|
cpp
|
C++
|
src/core/unittest/UnitTestPolyElements.cpp
|
AnthonyTudorov/PALISADE-SizeOf-Fork
|
05e9903da0971933adb1ba0b9c98398c9722a45c
|
[
"BSD-2-Clause"
] | 1
|
2021-09-02T07:20:28.000Z
|
2021-09-02T07:20:28.000Z
|
src/core/unittest/UnitTestPolyElements.cpp
|
uishi/Modified_PALISADEv1.9.2
|
d8bf4739144e53340481721b1df83dfff2f65cd8
|
[
"BSD-2-Clause"
] | null | null | null |
src/core/unittest/UnitTestPolyElements.cpp
|
uishi/Modified_PALISADEv1.9.2
|
d8bf4739144e53340481721b1df83dfff2f65cd8
|
[
"BSD-2-Clause"
] | 3
|
2021-09-02T07:21:06.000Z
|
2022-01-19T15:24:20.000Z
|
/*
* @file
* @author TPOC: contact@palisade-crypto.org
*
* @copyright Copyright (c) 2019, New Jersey Institute of Technology (NJIT)
* All rights reserved.
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice, this
* list of conditions and the following disclaimer in the documentation and/or other
* materials provided with the distribution.
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
/*
This code tests the transform feature of the PALISADE lattice encryption library.
*/
#include "include/gtest/gtest.h"
#include <iostream>
#include <vector>
#include "math/backend.h"
#include "lattice/backend.h"
#include "utils/inttypes.h"
#include "math/distrgen.h"
#include "utils/parmfactory.h"
#include "lattice/elemparamfactory.h"
using namespace std;
using namespace lbcrypto;
/*-TESTING METHODS OF LATTICE ELEMENTS ----------------*/
// these tests only work on Poly, and have not been ported to DCRT
// NOTE tests that only work on Poly because DCRT versions have not been
// coded are here
// When they are completed and run for both types, they move to
// UnitTestCommonElements.cpp
template<typename Element>
void rounding_ops(const string& msg) {
DEBUG_FLAG(false);
using VecType = typename Element::Vector;
using ParmType = typename Element::Params;
usint m = 8;
typename VecType::Integer q("73");
typename VecType::Integer primitiveRootOfUnity("22");
typename VecType::Integer p("8");
shared_ptr<ParmType> ilparams( new ParmType(m, q, primitiveRootOfUnity) );
//temporary larger modulus that is used for polynomial multiplication before rounding
typename VecType::Integer q2("16417");
typename VecType::Integer primitiveRootOfUnity2("13161");
shared_ptr<ParmType> ilparams2( new ParmType(m, q2, primitiveRootOfUnity2) );
Element ilvector2n1(ilparams,COEFFICIENT);
ilvector2n1 = { "31","21","15","34"};
DEBUGEXP(ilvector2n1);
//test for bug where length was 0
EXPECT_EQ(ilvector2n1.GetLength(), m/2)
<< msg << " Failure: ={init list string}";
Element ilvector2n2(ilparams,COEFFICIENT);
ilvector2n2 = { "21","11","35","32" };
DEBUGEXP(ilvector2n2);
DEBUG("unit test for MultiplyAndRound");
Element roundingCorrect1(ilparams, COEFFICIENT);
roundingCorrect1 = { "3","2","2","4" };
DEBUGEXP(ilvector2n1);
Element rounding1 = ilvector2n1.MultiplyAndRound(p, q);
EXPECT_EQ(roundingCorrect1, rounding1)
<< msg << " Failure: Rounding p*polynomial/q";
DEBUG("unit test for MultiplyAndRound after a polynomial");
DEBUG("multiplication using the larger modulus");
Element roundingCorrect2(ilparams2, COEFFICIENT);
roundingCorrect2 = { "16316","16320","60","286" };
ilvector2n1.SwitchModulus(q2, primitiveRootOfUnity2);
ilvector2n2.SwitchModulus(q2, primitiveRootOfUnity2);
DEBUGEXP(ilvector2n1);
DEBUGEXP(ilvector2n2);
ilvector2n1.SwitchFormat();
ilvector2n2.SwitchFormat();
DEBUGEXP(ilvector2n1);
DEBUGEXP(ilvector2n2);
Element rounding2 = ilvector2n1 * ilvector2n2;
DEBUGEXP(rounding2);
rounding2.SwitchFormat();
DEBUGEXP(rounding2);
rounding2 = rounding2.MultiplyAndRound(p, q);
DEBUGEXP(rounding2);
EXPECT_EQ(roundingCorrect2, rounding2)
<< msg << " Failure: Rounding p*polynomial1*polynomial2/q";
DEBUG("makes sure the result is correct after");
DEBUG("going back to the original modulus");
rounding2.SwitchModulus(q, primitiveRootOfUnity);
DEBUGEXP(rounding2);
Element roundingCorrect3(ilparams, COEFFICIENT);
roundingCorrect3 = { "45","49","60","67" };
EXPECT_EQ(roundingCorrect3, rounding2)
<< msg << " Failure p*polynomial1*polynomial2/q (mod q)";
}
// instantiate various test for rounding_ops()
TEST(UTPoly, rounding_ops) {
RUN_ALL_POLYS(rounding_ops, "Poly rounding_ops");
}
// FIXME DCRTPoly needs an assignment op/ctor
TEST(UTDCRTPoly, rounding_ops) {
//std::cerr<<"*** skipping DCRT rounding_ops till MultiplyAndRound is coded"<<std::endl;
//RUN_BIG_DCRTPOLYS(rounding_ops, "DCRT rounding_ops");
}
//template for set_get_values()
template<typename Element>
void set_get_values(const string& msg) {
DEBUG_FLAG(false);
using VecType = typename Element::Vector;
using ParmType = typename Element::Params;
usint m = 8;
typename VecType::Integer primeModulus("73");
typename VecType::Integer primitiveRootOfUnity("22");
shared_ptr<ParmType> ilparams( new ParmType(m, primeModulus, primitiveRootOfUnity) );
{ //test SetValues()
Element ilvector2n(ilparams);
VecType bbv(m/2, primeModulus);
bbv = { "3","0","0","0"};
ilvector2n.SetValues(bbv, Format::COEFFICIENT);
DEBUGEXP(ilvector2n);
//test for bug where length was 0
EXPECT_EQ(ilvector2n.GetLength(), m/2)
<< msg << " Failure: ={init list string}";
Element ilvector2n2(ilparams);
VecType bbv2(m/2, primeModulus);
bbv2={"3","3","3","3"};
ilvector2n2.SetValues(bbv2, Format::COEFFICIENT);
// test SetValues()
EXPECT_NE(ilvector2n, ilvector2n2) << msg << " Failure: SetValues NE";
bbv2=bbv;
ilvector2n2.SetValues(bbv2, Format::COEFFICIENT);
EXPECT_EQ(ilvector2n, ilvector2n2) << msg << " Failure: SetValues EQ";
}
{//test GetValue() and at()
Element ilvector2n(ilparams);
ilvector2n = {"1", "2", "0", "1"};
Element bbv(ilparams);
bbv = {"1", "2", "0", "1"};
DEBUGEXP(ilvector2n);
DEBUGEXP(bbv);
EXPECT_EQ(bbv.GetValues(), ilvector2n.GetValues())
<<msg<< "Failure: GetValues()";
usint index = 3;
bbv[index] = 11;
for (usint i = 0; i < m/2; ++i) {
if (i ==index) {
EXPECT_NE(bbv.at(i),
ilvector2n.at(i))
<<msg<< " Failure: lhs[] at("<<i<< ")";
}else{
EXPECT_EQ(bbv.at(i),
ilvector2n.at(i))
<<msg<< " Failure: lhs[] at("<<i<< ")";
}
}
}
}
// instantiate various test for set_get_values()
TEST(UTPoly, set_get_values) {
RUN_ALL_POLYS(set_get_values, "Poly set_get_values");
}
// FIXME DCRTPoly needs a set_get_values()
TEST(UTDCRTPoly, set_get_values) {
//std::cerr<<"*** skipping DCRT set_get_values till coded"<<std::endl;
//RUN_BIG_DCRTPOLYS(set_get_values, "DCRT set_values");
}
//template for at()
template<typename Element>
void at(const string& msg) {
DEBUG_FLAG(false);
using VecType = typename Element::Vector;
using ParmType = typename Element::Params;
usint m = 8;
typename VecType::Integer primeModulus("73");
typename VecType::Integer primitiveRootOfUnity("22");
shared_ptr<ParmType> ilparams( new ParmType(m, primeModulus, primitiveRootOfUnity) );
{//test and at() and []
Element ilvector2n(ilparams);
ilvector2n = {"1", "2", "0", "1"};
Element bbv(ilparams);
bbv = {"1", "2", "0", "1"};
DEBUGEXP(ilvector2n);
DEBUGEXP(bbv);
//test for bug where length was 0
EXPECT_EQ(ilvector2n.GetLength(), m/2)
<< msg << " Failure: ={init list string}";
usint index = 3;
bbv[index] = 11;
for (usint i = 0; i < m/2; ++i) {
if (i ==index) {
EXPECT_NE(bbv.at(i),
ilvector2n.at(i))
<<msg<< " Failure: lhs[] at("<<i<< ")";
}else{
EXPECT_EQ(bbv.at(i),
ilvector2n.at(i))
<<msg<< " Failure: lhs[] at("<<i<< ")";
}
}
bbv.at(index) = 1;
for (usint i = 0; i < m/2; ++i) {
EXPECT_EQ(bbv.at(i),
ilvector2n.at(i))
<<msg<< " Failure: lhs[] at("<<i<< ")";
}
}
}
// instantiate various test for at()
TEST(UTPoly, at) {
RUN_ALL_POLYS(at, "Poly at");
}
// FIXME DCRTPoly needs a at() and []
TEST(UTDCRTPoly, at) {
//std::cerr<<"*** skipping DCRT at till coded"<<std::endl;
//RUN_BIG_DCRTPOLYS(at, "DCRT at");
}
//template for switch_modulus
template<typename Element>
void switch_modulus(const string& msg) {
DEBUG_FLAG(false);
using VecType = typename Element::Vector;
using ParmType = typename Element::Params;
//using IntType = typename Element::Vector::Integer;
usint m = 8;
typename VecType::Integer primeModulus("73");
typename VecType::Integer primitiveRootOfUnity("22");
shared_ptr<ParmType> ilparams( new ParmType(m, primeModulus, primitiveRootOfUnity) );
DEBUG("SwitchModulus");
{
Element ilv(ilparams, COEFFICIENT);
ilv ={"56","1","37","2"};
//test for bug where length was 0
EXPECT_EQ(ilv.GetLength(), m/2)
<< msg << " Failure: ={init list string}";
typename VecType::Integer modulus("17");
typename VecType::Integer rootOfUnity("15");
ilv.SwitchModulus(modulus, rootOfUnity);
shared_ptr<ParmType> ilparams2( new ParmType(m,
modulus,
rootOfUnity) );
Element expected(ilparams2,COEFFICIENT);
expected = {"0","1","15","2"};
EXPECT_EQ(expected, ilv)
<< msg << " Failure: SwitchModulus()";
Element ilv1(ilparams, COEFFICIENT);
ilv1 ={"56","43","35","28"};
typename VecType::Integer modulus1("193");
typename VecType::Integer rootOfUnity1("150");
ilv1.SwitchModulus(modulus1, rootOfUnity1);
shared_ptr<ParmType> ilparams3( new ParmType(m,
modulus1,
rootOfUnity1) );
Element expected2(ilparams3,COEFFICIENT);
expected2 = {"176","163","35","28"};
EXPECT_EQ(expected2, ilv1)
<< msg << " Failure: SwitchModulus()";
}
}
//instantiations for switch_modulus()
TEST(UTPoly, switch_modulus) {
RUN_ALL_POLYS(switch_modulus, "Poly switch_modulus");
}
TEST(UTDCRTPoly, switch_modulus) {
//std::cerr<<"*** skipping DCRT switch_modulus till coded"<<std::endl; //RUN_BIG_DCRTPOLYS(switch_modulus, "Poly switch_modulus");
}
//template fore rn_generators()
template<typename Element>
void rn_generators(const string& msg) {
using VecType = typename Element::Vector;
using ParmType = typename Element::Params;
DEBUG_FLAG(false);
usint m = 8;
typename VecType::Integer primeModulus("73");
typename VecType::Integer primitiveRootOfUnity("22");
float stdDev = 4.0;
typename Element::DggType dgg(stdDev);
typename Element::BugType bug;
typename Element::DugType dug;
dug.SetModulus(primeModulus);
shared_ptr<ParmType> ilparams( new ParmType(m, primeModulus, primitiveRootOfUnity) );
DEBUG("DestroyPreComputedSamples");
{
Element ilv(ilparams, COEFFICIENT);
ilv = {"2","1","3","2"};
//test for bug where length was 0
EXPECT_EQ(ilv.GetLength(), m/2)
<< msg << " Failure: ={init list string}";
Element ilvector2n1(ilparams);
Element ilvector2n2(ilparams);
Element ilvector2n3(ilv);
Element ilvector2n4(dgg, ilparams);
Element ilvector2n5(bug, ilparams);
Element ilvector2n6(dug, ilparams);
EXPECT_EQ(true, ilvector2n1.IsEmpty())
<< msg << " Failure: DestroyPreComputedSamples() 2n1";
EXPECT_EQ(true, ilvector2n2.IsEmpty())
<< msg << " Failure: DestroyPreComputedSamples() 2n2";
EXPECT_EQ(false, ilvector2n3.IsEmpty())
<< msg << " Failure: DestroyPreComputedSamples() 2n3";
EXPECT_EQ(false, ilvector2n4.IsEmpty())
<< msg << " Failure: DestroyPreComputedSamples() 2n4";
EXPECT_EQ(false, ilvector2n5.IsEmpty())
<< msg << " Failure: DestroyPreComputedSamples() 2n5";
EXPECT_EQ(false, ilvector2n6.IsEmpty())
<< msg << " Failure: DestroyPreComputedSamples() 2n6";
}
}
//Instantiations of rn_generators()
TEST(UTPoly, rn_generators) {
RUN_ALL_POLYS(rn_generators, "Poly rn_generators");
}
TEST(UTDCRTPoly, rn_generators) {
//std::cerr<<"*** skipping DCRT rn_generators till coded"<<std::endl;
//RUN_BIG_DCRTPOLYS(rn_generators, "DCRT rn_generators");
}
//template fore poly_other_methods()
template<typename Element>
void poly_other_methods(const string& msg) {
using VecType = typename Element::Vector;
using ParmType = typename Element::Params;
DEBUG_FLAG(false);
usint m = 8;
typename VecType::Integer primeModulus("73");
typename VecType::Integer primitiveRootOfUnity("22");
shared_ptr<ParmType> ilparams( new ParmType(m, primeModulus, primitiveRootOfUnity) );
Element ilvector2n(ilparams);
ilvector2n = {"2","1","3","2"};
//test for bug where length was 0
EXPECT_EQ(ilvector2n.GetLength(), m/2)
<< msg << " Failure: ={init list string}";
DEBUG("SwitchFormat");
{
Element ilv(ilparams,COEFFICIENT);
ilv = {"2","1","3","2"};
ilv.SwitchFormat();
EXPECT_EQ(primeModulus, ilv.GetModulus())
<< msg << " Failure: SwitchFormat() ilv modulus";
EXPECT_EQ(primitiveRootOfUnity, ilv.GetRootOfUnity())
<< msg << " Failure: SwitchFormat() ilv rootOfUnity";
EXPECT_EQ(Format::EVALUATION, ilv.GetFormat())
<< msg << " Failure: SwitchFormat() ilv format";
Element expected(ilparams);
expected = {"69","65","44","49"};
EXPECT_EQ(expected, ilv)
<< msg << " Failure: ivl.SwitchFormat() values";
Element ilv1(ilparams, EVALUATION);
ilv1 = {"2","3","1","2"};
ilv1.SwitchFormat();
EXPECT_EQ(primeModulus, ilv1.GetModulus())
<< msg << " Failure: SwitchFormat() ilv1 modulus";
EXPECT_EQ(primitiveRootOfUnity, ilv1.GetRootOfUnity())
<< msg << " Failure: SwitchFormat() ilv1 rootOfUnity";
EXPECT_EQ(Format::COEFFICIENT, ilv1.GetFormat())
<< msg << " Failure: SwitchFormat() ilv1 format";
Element expected2(ilparams,COEFFICIENT);
expected2 = {"2","3","50","3"};
EXPECT_EQ(expected2, ilv1)
<< msg << " Failure: ivl1.SwitchFormat() values";
}
DEBUG("MultiplicativeInverse");
{
Element ilv1(ilparams, EVALUATION);
ilv1 = {"2","4","3","2"};
Element ilvInverse1 = ilv1.MultiplicativeInverse();
Element ilvProduct1 = ilv1 * ilvInverse1;
for (usint i = 0; i < m/2; ++i)
{
EXPECT_EQ(ilvProduct1.at(i), typename Element::Integer(1))
<< msg << " Failure: ilvProduct1.MultiplicativeInverse() @ index "<<i;
}
}
DEBUG("Norm");
{
Element ilv(ilparams, COEFFICIENT);
ilv = {"56","1","37","1"};
EXPECT_EQ(36, ilv.Norm()) << msg << " Failure: Norm()";
}
}
//Instantiations of poly_other_methods()
TEST(UTPoly, poly_other_methods) {
RUN_ALL_POLYS(poly_other_methods, "poly_other_methods");
}
//FIXME
TEST(UTDCRTPoly, poly_other_methods) {
//std::cerr<<"*** skipping DCRT poly_other_methods till these functions are coded"<<std::endl;
// RUN_BIG_DCRTPOLYS(poly_other_methods, "DCRT poly_other_methods");
}
// Signed mod must handle the modulo operation for both positive and negative numbers
// It is used in decoding/decryption of homomorphic encryption schemes
template<typename Element>
void signed_mod(const string& msg) {
using VecType = typename Element::Vector;
using ParmType = typename Element::Params;
usint m = 8;
typename VecType::Integer primeModulus("73");
typename VecType::Integer primitiveRootOfUnity("22");
shared_ptr<ParmType> ilparams( new ParmType(m, primeModulus, primitiveRootOfUnity) );
Element ilvector2n1(ilparams,COEFFICIENT);
ilvector2n1 = {"62","7","65","8"};
//test for bug where length was 0
EXPECT_EQ(ilvector2n1.GetLength(), m/2)
<< msg << " Failure: ={init list string}";
{
Element ilv1(ilparams, COEFFICIENT);
ilv1 = ilvector2n1.Mod(2);
Element expected(ilparams, COEFFICIENT);
expected = {"1","1","0","0"};
EXPECT_EQ(expected, ilv1)
<< msg << " Failure: ilv1.Mod(TWO)";
}
{
Element ilv1(ilparams, COEFFICIENT);
ilv1 = ilvector2n1.Mod(5);
Element expected(ilparams, COEFFICIENT);
expected = {"4","2","2","3"};
EXPECT_EQ(expected, ilv1)
<< msg << " Failure: ilv1.Mod(FIVE)";
}
}
//Instantiations of signed_mod()
TEST(UTPoly, signed_mod) {
RUN_ALL_POLYS(signed_mod, "signed_mod");
}
// FIXME
TEST(UTDCRTPoly, signed_mod) {
//std::cerr<<"*** skipping DCRT signed_mod till coded"<<std::endl;
// RUN_BIG_DCRTPOLYS(signed_mod, "signed_mod");
}
//template fore automorphismTransform()
template<typename Element>
void automorphismTransform(const string& msg) {
using VecType = typename Element::Vector;
using ParmType = typename Element::Params;
DEBUG_FLAG(false);
usint m = 8;
typename VecType::Integer primeModulus("73");
typename VecType::Integer primitiveRootOfUnity("22");
shared_ptr<ParmType> ilparams( new ParmType(m, primeModulus, primitiveRootOfUnity) );
Element ilvector2n(ilparams);
ilvector2n = {"2","1","3","2"};
//test for bug where length was 0
EXPECT_EQ(ilvector2n.GetLength(), m/2)
<< msg << " Failure: ={init list string}";
DEBUG("AutomorphismTransform");
{
Element ilv(ilparams, COEFFICIENT);
ilv = {"56","1","37","2"};
usint index = 3;
Element ilvAuto(ilv.AutomorphismTransform(index));
Element expected(ilparams,COEFFICIENT);
expected = {"56","2","36","1"};
EXPECT_EQ(expected, ilvAuto)
<< msg << " Failure: AutomorphismTransform()";
}
}
//Instantiations of automorphismTransform()
TEST(UTPoly, automorphismTransform) {
RUN_ALL_POLYS(automorphismTransform, "Poly automorphismTransform");
}
// FIXME
TEST(UTDCRTPoly, automorphismTransform) {
//std::cerr<<"*** skipping DCRT automorphismTransform till coded"<<std::endl;
// RUN_BIG_DCRTPOLYS(automorphismTransform, "DCRT automorphismTransform");
}
template<typename Element>
void transposition(const string& msg) {
using VecType = typename Element::Vector;
using ParmType = typename Element::Params;
DEBUG_FLAG(false);
usint m = 8;
typename VecType::Integer q("73");
typename VecType::Integer primitiveRootOfUnity("22");
shared_ptr<ParmType> ilparams(new ParmType(m, q, primitiveRootOfUnity));
Element ilvector2n1(ilparams, COEFFICIENT);
ilvector2n1 = {"31","21","15","34"};
//test for bug where length was 0
EXPECT_EQ(ilvector2n1.GetLength(), m/2)
<< msg << " Failure: ={init list string}";
// converts to evaluation representation
ilvector2n1.SwitchFormat();
DEBUG("ilvector2n1 a "<<ilvector2n1);
ilvector2n1 = ilvector2n1.Transpose();
DEBUG("ilvector2n1 b "<<ilvector2n1);
// converts back to coefficient representation
ilvector2n1.SwitchFormat();
DEBUG("ilvector2n1 c "<<ilvector2n1);
Element ilvector2n2(ilparams,COEFFICIENT);
ilvector2n2 = {"31","39","58","52"};
DEBUG("ilvector2n2 a "<<ilvector2n2);
EXPECT_EQ(ilvector2n2, ilvector2n1)
<< msg << " Failure: transposition test";
}
//Instantiations of transposition()
TEST(UTPoly, transposition) {
RUN_ALL_POLYS(transposition, "transposition");
}
// FIXME
TEST(UTDCRTPoly, transposition) {
//std::cerr<<"*** skipping DCRT transposition till coded"<<std::endl;
// RUN_BIG_DCRTPOLYS(transposition, "transposition");
}
template<typename Element>
void Poly_mod_ops_on_two_elements(const string& msg) {
using VecType = typename Element::Vector;
using ParmType = typename Element::Params;
usint order = 8;
usint nBits = 7;
typename VecType::Integer primeModulus = lbcrypto::FirstPrime<typename VecType::Integer>(nBits, order);
typename VecType::Integer primitiveRootOfUnity = lbcrypto::RootOfUnity<typename VecType::Integer>(order, primeModulus);
shared_ptr<ParmType> ilparams( new ParmType(order, primeModulus, primitiveRootOfUnity) );
typename Element::DugType distrUniGen = typename Element::DugType();
distrUniGen.SetModulus(primeModulus);
Element ilv1(distrUniGen, ilparams);
VecType bbv1 (ilv1.GetValues());
Element ilv2(distrUniGen, ilparams);
VecType bbv2(ilv2.GetValues());
{
Element ilvResult = ilv1 + ilv2;
VecType bbvResult(ilvResult.GetValues());
for (usint i=0; i<order/2; i++) {
EXPECT_EQ(bbvResult.at(i), (bbv1.at(i) + bbv2.at(i)).Mod(primeModulus)) << msg << " Poly + operation returns incorrect results.";
}
}
{
Element ilvResult = ilv1 * ilv2;
VecType bbvResult(ilvResult.GetValues());
for (usint i=0; i<order/2; i++) {
EXPECT_EQ(bbvResult.at(i), (bbv1.at(i) * bbv2.at(i)).Mod(primeModulus)) << msg << " Poly * operation returns incorrect results.";
}
}
}
TEST(UTPoly, Poly_mod_ops_on_two_elements) {
RUN_ALL_POLYS(Poly_mod_ops_on_two_elements, "Poly Poly_mod_ops_on_two_elements");
}
| 29.895197
| 132
| 0.700701
|
AnthonyTudorov
|
ff13fc3a814bedf56af5a149937e1d1d912ed8cb
| 439
|
cpp
|
C++
|
InputOutputTemplate/WhyWhileCinWorks.cpp
|
zyzkevin/C-Programming-and-Algorithms
|
be9642b62a3285341990c25bdc3c124c4dd8c38b
|
[
"MIT"
] | null | null | null |
InputOutputTemplate/WhyWhileCinWorks.cpp
|
zyzkevin/C-Programming-and-Algorithms
|
be9642b62a3285341990c25bdc3c124c4dd8c38b
|
[
"MIT"
] | null | null | null |
InputOutputTemplate/WhyWhileCinWorks.cpp
|
zyzkevin/C-Programming-and-Algorithms
|
be9642b62a3285341990c25bdc3c124c4dd8c38b
|
[
"MIT"
] | null | null | null |
#include <iostream>
using namespace std;
class MyCin
{
// 在此处补充你的代码
bool input = true;
public:
MyCin & operator >> ( int & n)
{
cin >> n;
if (n == -1) input = false;
return *this;
}
operator bool()
{
return input;
}
};
int main()
{
MyCin m;
int n1,n2;
while( m >> n1 >> n2)
cout << n1 << " " << n2 << endl;
system("pause");
return 0;
}
| 15.137931
| 41
| 0.451025
|
zyzkevin
|
d438a41ab0350358d0614e6742f915b043b820ce
| 17,511
|
cpp
|
C++
|
Siv3D/src/ThirdParty/lunasvg/svgpaintelement.cpp
|
Siv3D/siv6
|
090e82b2f6398640638dfa43da3f829ba977d0e2
|
[
"MIT"
] | 2
|
2020-07-26T05:14:33.000Z
|
2020-08-11T08:00:54.000Z
|
Siv3D/src/ThirdParty/lunasvg/svgpaintelement.cpp
|
Siv3D/siv6
|
090e82b2f6398640638dfa43da3f829ba977d0e2
|
[
"MIT"
] | 6
|
2020-03-03T04:01:10.000Z
|
2020-09-27T14:33:19.000Z
|
Siv3D/src/ThirdParty/lunasvg/svgpaintelement.cpp
|
Siv3D/siv6
|
090e82b2f6398640638dfa43da3f829ba977d0e2
|
[
"MIT"
] | 5
|
2020-03-03T03:34:27.000Z
|
2020-09-05T18:42:55.000Z
|
#include "svgpaintelement.h"
#include "svgdocumentimpl.h"
#include "svgstopelement.h"
#include "svgcolor.h"
#include "rendercontext.h"
namespace lunasvg {
SVGPaintElement::SVGPaintElement(DOMElementID elementId, SVGDocument* document)
: SVGStyledElement(elementId, document)
{
}
void SVGPaintElement::render(RenderContext& context) const
{
context.skipElement();
}
SVGGradientElement::SVGGradientElement(DOMElementID elementId, SVGDocument* document)
: SVGPaintElement(elementId, document),
SVGURIReference (this),
m_gradientTransform(DOMPropertyIdGradientTransform),
m_spreadMethod(DOMPropertyIdSpreadMethod),
m_gradientUnits(DOMPropertyIdGradientUnits)
{
addToPropertyMap(m_gradientTransform);
addToPropertyMap(m_spreadMethod);
addToPropertyMap(m_gradientUnits);
}
void SVGGradientElement::setGradientAttributes(GradientAttributes& attributes) const
{
if(!attributes.gradientTransform && m_gradientTransform.isSpecified())
attributes.gradientTransform = m_gradientTransform.property();
if(!attributes.spreadMethod && m_spreadMethod.isSpecified())
attributes.spreadMethod = m_spreadMethod.property();
if(!attributes.gradientUnits && m_gradientUnits.isSpecified())
attributes.gradientUnits = m_gradientUnits.property();
if(attributes.gradientStops.empty())
{
const SVGElementImpl* e = next;
while(e != tail)
{
if(e->elementId()==DOMElementIdStop)
attributes.gradientStops.push_back(to<SVGStopElement>(e));
e = e->next;
}
}
}
GradientStops SVGGradientElement::buildGradientStops(const std::vector<const SVGStopElement*>& gradientStops) const
{
GradientStops stops(gradientStops.size());
double prevOffset = 0.0;
for(unsigned int i = 0;i < gradientStops.size();i++)
{
const SVGStopElement* stop = gradientStops[i];
double offset = std::min(std::max(prevOffset, stop->offsetValue()), 1.0);
prevOffset = offset;
stops[i] = GradientStop(offset, stop->stopColorWithOpacity());
}
return stops;
}
SVGLinearGradientElement::SVGLinearGradientElement(SVGDocument* document)
: SVGGradientElement(DOMElementIdLinearGradient, document),
m_x1(DOMPropertyIdX1, LengthModeWidth, AllowNegativeLengths),
m_y1(DOMPropertyIdY1, LengthModeHeight, AllowNegativeLengths),
m_x2(DOMPropertyIdX2, LengthModeWidth, AllowNegativeLengths),
m_y2(DOMPropertyIdY2, LengthModeHeight, AllowNegativeLengths)
{
m_x2.setDefaultValue(hundredPercent());
addToPropertyMap(m_x1);
addToPropertyMap(m_y1);
addToPropertyMap(m_x2);
addToPropertyMap(m_y2);
}
void SVGLinearGradientElement::collectGradientAttributes(LinearGradientAttributes& attributes) const
{
std::set<const SVGGradientElement*> processedGradients;
const SVGGradientElement* current = this;
while(true)
{
current->setGradientAttributes(attributes);
if(current->elementId() == DOMElementIdLinearGradient)
{
const SVGLinearGradientElement* linear = to<SVGLinearGradientElement>(current);
if(!attributes.x1 && linear->m_x1.isSpecified())
attributes.x1 = linear->m_x1.property();
if(!attributes.y1 && linear->m_y1.isSpecified())
attributes.y1 = linear->m_y1.property();
if(!attributes.x2 && linear->m_x2.isSpecified())
attributes.x2 = linear->m_x2.property();
if(!attributes.y2 && linear->m_y2.isSpecified())
attributes.y2 = linear->m_y2.property();
}
processedGradients.insert(current);
SVGElementImpl* ref = document()->impl()->resolveIRI(current->hrefValue());
if(!ref || !ref->isSVGGradientElement())
break;
current = to<SVGGradientElement>(ref);
if(processedGradients.find(current)!=processedGradients.end())
break;
}
}
Paint SVGLinearGradientElement::getPaint(const RenderState& state) const
{
LinearGradientAttributes attributes;
collectGradientAttributes(attributes);
if(attributes.gradientStops.empty())
return Paint();
double x1, y1, x2, y2;
UnitType units = attributes.gradientUnits ? attributes.gradientUnits->enumValue() : UnitTypeObjectBoundingBox;
if(units == UnitTypeObjectBoundingBox)
{
x1 = attributes.x1 ? attributes.x1->value(state, 1) : 0.0;
y1 = attributes.y1 ? attributes.y1->value(state, 1) : 0.0;
x2 = attributes.x2 ? attributes.x2->value(state, 1) : 1.0;
y2 = attributes.y2 ? attributes.y2->value(state, 1) : 0.0;
}
else
{
x1 = attributes.x1 ? attributes.x1->valueX(state) : 0.0;
y1 = attributes.y1 ? attributes.y1->valueY(state) : 0.0;
x2 = attributes.x2 ? attributes.x2->valueX(state) : hundredPercent()->valueX(state);
y2 = attributes.y2 ? attributes.y2->valueY(state) : 0.0;
}
GradientStops stops = buildGradientStops(attributes.gradientStops);
if((x1 == x2 && y1 == y2) || stops.size() == 1)
return stops.back().second;
SpreadMethod spread = attributes.spreadMethod ? attributes.spreadMethod->enumValue() : SpreadMethodPad;
AffineTransform matrix;
if(units == UnitTypeObjectBoundingBox)
{
matrix.translate(state.bbox.x, state.bbox.y);
matrix.scale(state.bbox.width, state.bbox.height);
}
if(attributes.gradientTransform)
matrix.multiply(attributes.gradientTransform->value());
LinearGradient gradient(x1, y1, x2, y2);
gradient.setStops(stops);
gradient.setSpread(spread);
gradient.setMatrix(matrix);
return gradient;
}
SVGElementImpl* SVGLinearGradientElement::clone(SVGDocument* document) const
{
SVGLinearGradientElement* e = new SVGLinearGradientElement(document);
baseClone(*e);
return e;
}
SVGRadialGradientElement::SVGRadialGradientElement(SVGDocument* document)
: SVGGradientElement(DOMElementIdRadialGradient, document),
m_cx(DOMPropertyIdCx, LengthModeWidth, AllowNegativeLengths),
m_cy(DOMPropertyIdCy, LengthModeHeight, AllowNegativeLengths),
m_r(DOMPropertyIdR, LengthModeBoth, ForbidNegativeLengths),
m_fx(DOMPropertyIdFx, LengthModeWidth, AllowNegativeLengths),
m_fy(DOMPropertyIdFy, LengthModeHeight, AllowNegativeLengths)
{
m_cx.setDefaultValue(fiftyPercent());
m_cy.setDefaultValue(fiftyPercent());
m_r.setDefaultValue(fiftyPercent());
addToPropertyMap(m_cx);
addToPropertyMap(m_cy);
addToPropertyMap(m_r);
addToPropertyMap(m_fx);
addToPropertyMap(m_fy);
}
void SVGRadialGradientElement::collectGradientAttributes(RadialGradientAttributes& attributes) const
{
std::set<const SVGGradientElement*> processedGradients;
const SVGGradientElement* current = this;
while(true)
{
current->setGradientAttributes(attributes);
if(current->elementId() == DOMElementIdRadialGradient)
{
const SVGRadialGradientElement* radial = to<SVGRadialGradientElement>(current);
if(!attributes.cx && radial->m_cx.isSpecified())
attributes.cx = radial->m_cx.property();
if(!attributes.cy && radial->m_cy.isSpecified())
attributes.cy = radial->m_cy.property();
if(!attributes.r && radial->m_r.isSpecified())
attributes.r = radial->m_r.property();
if(!attributes.fx && radial->m_fx.isSpecified())
attributes.fx = radial->m_fx.property();
if(!attributes.fy && radial->m_fy.isSpecified())
attributes.fy = radial->m_fy.property();
}
processedGradients.insert(current);
SVGElementImpl* ref = document()->impl()->resolveIRI(current->hrefValue());
if(!ref || !ref->isSVGGradientElement())
break;
current = to<SVGGradientElement>(ref);
if(processedGradients.find(current)!=processedGradients.end())
break;
}
}
Paint SVGRadialGradientElement::getPaint(const RenderState& state) const
{
RadialGradientAttributes attributes;
collectGradientAttributes(attributes);
if(attributes.gradientStops.empty())
return Paint();
double cx, cy, r, fx, fy;
UnitType units = attributes.gradientUnits ? attributes.gradientUnits->enumValue() : UnitTypeObjectBoundingBox;
if(units == UnitTypeObjectBoundingBox)
{
cx = attributes.cx ? attributes.cx->value(state, 1) : 0.5;
cy = attributes.cy ? attributes.cy->value(state, 1) : 0.5;
r = attributes.r ? attributes.r->value(state, 1) : 0.5;
fx = attributes.fx ? attributes.fx->value(state, 1) : cx;
fy = attributes.fy ? attributes.fy->value(state, 1) : cy;
}
else
{
cx = attributes.cx ? attributes.cx->valueX(state) : fiftyPercent()->valueX(state);
cy = attributes.cy ? attributes.cy->valueY(state) : fiftyPercent()->valueY(state);
r = attributes.r ? attributes.r->value(state) : fiftyPercent()->value(state);
fx = attributes.fx ? attributes.fx->valueX(state) : cx;
fy = attributes.fy ? attributes.fy->valueY(state) : cy;
}
GradientStops stops = buildGradientStops(attributes.gradientStops);
if(r == 0.0 || stops.size() == 1)
return stops.back().second;
SpreadMethod spread = attributes.spreadMethod ? attributes.spreadMethod->enumValue() : SpreadMethodPad;
AffineTransform matrix;
if(units == UnitTypeObjectBoundingBox)
{
matrix.translate(state.bbox.x, state.bbox.y);
matrix.scale(state.bbox.width, state.bbox.height);
}
if(attributes.gradientTransform)
matrix.multiply(attributes.gradientTransform->value());
RadialGradient gradient(cx, cy, r, fx, fy);
gradient.setStops(stops);
gradient.setSpread(spread);
gradient.setMatrix(matrix);
return gradient;
}
SVGElementImpl* SVGRadialGradientElement::clone(SVGDocument* document) const
{
SVGRadialGradientElement* e = new SVGRadialGradientElement(document);
baseClone(*e);
return e;
}
SVGPatternElement::SVGPatternElement(SVGDocument* document)
: SVGPaintElement(DOMElementIdPattern, document),
SVGURIReference(this),
SVGFitToViewBox(this),
m_x(DOMPropertyIdX, LengthModeWidth, AllowNegativeLengths),
m_y(DOMPropertyIdY, LengthModeHeight, AllowNegativeLengths),
m_width(DOMPropertyIdWidth, LengthModeWidth, ForbidNegativeLengths),
m_height(DOMPropertyIdHeight, LengthModeHeight, ForbidNegativeLengths),
m_patternTransform(DOMPropertyIdPatternTransform),
m_patternUnits(DOMPropertyIdPatternUnits),
m_patternContentUnits(DOMPropertyIdPatternContentUnits)
{
addToPropertyMap(m_x);
addToPropertyMap(m_y);
addToPropertyMap(m_width);
addToPropertyMap(m_height);
addToPropertyMap(m_patternTransform);
addToPropertyMap(m_patternUnits);
addToPropertyMap(m_patternContentUnits);
}
void SVGPatternElement::collectPatternAttributes(PatternAttributes& attributes) const
{
std::set<const SVGPatternElement*> processedGradients;
const SVGPatternElement* current = this;
while(true)
{
if(!attributes.x && current->x().isSpecified())
attributes.x = current->x().property();
if(!attributes.y && current->y().isSpecified())
attributes.y = current->y().property();
if(!attributes.width && current->width().isSpecified())
attributes.width = current->width().property();
if(!attributes.height && current->height().isSpecified())
attributes.height = current->height().property();
if(!attributes.patternTransform && current->patternTransform().isSpecified())
attributes.patternTransform = current->patternTransform().property();
if(!attributes.patternUnits && current->patternUnits().isSpecified())
attributes.patternUnits = current->patternUnits().property();
if(!attributes.patternContentUnits && current->patternContentUnits().isSpecified())
attributes.patternContentUnits = current->patternContentUnits().property();
if(!attributes.viewBox && current->viewBox().isSpecified())
attributes.viewBox = current->viewBox().property();
if(!attributes.preserveAspectRatio && current->preserveAspectRatio().isSpecified())
attributes.preserveAspectRatio = current->preserveAspectRatio().property();
if(!attributes.patternContentElement && current->next != current->tail)
attributes.patternContentElement = current;
processedGradients.insert(current);
SVGElementImpl* ref = document()->impl()->resolveIRI(current->hrefValue());
if(!ref || ref->elementId() != DOMElementIdPattern)
break;
current = to<SVGPatternElement>(ref);
if(processedGradients.find(current)!=processedGradients.end())
break;
}
}
Paint SVGPatternElement::getPaint(const RenderState& state) const
{
PatternAttributes attributes;
collectPatternAttributes(attributes);
double x, y, w, h;
UnitType units = attributes.patternUnits ? attributes.patternUnits->enumValue() : UnitTypeObjectBoundingBox;
if(units == UnitTypeObjectBoundingBox)
{
x = attributes.x ? state.bbox.x + attributes.x->value(state, 1) * state.bbox.width : 0;
y = attributes.y ? state.bbox.y + attributes.y->value(state, 1) * state.bbox.height : 0;
w = attributes.width ? attributes.width->value(state, 1) * state.bbox.width : 0;
h = attributes.height ? attributes.height->value(state, 1) * state.bbox.height : 0;
}
else
{
x = attributes.x ? attributes.x->valueX(state) : 0;
y = attributes.y ? attributes.y->valueY(state) : 0;
w = attributes.width ? attributes.width->valueX(state) : 0;
h = attributes.height ? attributes.height->valueY(state) : 0;
}
AffineTransform transform(state.matrix);
if(attributes.patternTransform)
transform.multiply(attributes.patternTransform->value());
const double* m = transform.getMatrix();
double scalex = std::sqrt(m[0] * m[0] + m[2] * m[2]);
double scaley = std::sqrt(m[1] * m[1] + m[3] * m[3]);
double width = w * scalex;
double height = h * scaley;
if(width == 0.0 || height == 0.0 || attributes.patternContentElement == nullptr || RenderBreaker::hasElement(this))
return Paint();
RenderContext newContext(this, RenderModeDisplay);
RenderState& newState = newContext.state();
newState.element = this;
newState.canvas.reset(std::uint32_t(std::ceil(width)), std::uint32_t(std::ceil(height)));
newState.style.add(style());
newState.matrix.scale(scalex, scaley);
newState.viewPort = state.viewPort;
newState.color = KRgbBlack;
newState.dpi = state.dpi;
if(attributes.viewBox)
{
const SVGPreserveAspectRatio* positioning = attributes.preserveAspectRatio ? attributes.preserveAspectRatio : SVGPreserveAspectRatio::defaultValue();
newState.matrix.multiply(positioning->getMatrix(Rect(0, 0, w, h), attributes.viewBox->value()));
newState.viewPort = attributes.viewBox->value();
}
else if(attributes.patternContentUnits && attributes.patternContentUnits->enumValue() == UnitTypeObjectBoundingBox)
{
newState.matrix.scale(state.bbox.width, state.bbox.height);
newState.viewPort = Rect(0, 0, 1, 1);
}
RenderBreaker::registerElement(this);
newContext.render(attributes.patternContentElement->next, attributes.patternContentElement->tail->prev);
RenderBreaker::unregisterElement(this);
AffineTransform matrix(1.0/scalex, 0, 0, 1.0/scaley, x, y);
if(attributes.patternTransform)
matrix.postmultiply(attributes.patternTransform->value());
Pattern pattern(newState.canvas);
pattern.setTileMode(TileModeRepeat);
pattern.setMatrix(matrix);
return pattern;
}
SVGElementImpl* SVGPatternElement::clone(SVGDocument* document) const
{
SVGPatternElement* e = new SVGPatternElement(document);
baseClone(*e);
return e;
}
SVGSolidColorElement::SVGSolidColorElement(SVGDocument* document)
: SVGPaintElement(DOMElementIdSolidColor, document)
{
}
Paint SVGSolidColorElement::getPaint(const RenderState&) const
{
if(!style().isSpecified())
return KRgbBlack;
Rgb color;
if(const CSSPropertyBase* item = style().property()->getItem(CSSPropertyIdSolid_Color))
{
const SVGPropertyBase* property = !item->isInherited() ? item->property() : findInheritedProperty(CSSPropertyIdSolid_Color);
if(property)
{
const SVGColor* solidColor = to<SVGColor>(property);
color = solidColor->colorType() == ColorTypeCurrentColor ? currentColor() : solidColor->value();
}
}
if(const CSSPropertyBase* item = style().property()->getItem(CSSPropertyIdSolid_Opacity))
{
const SVGPropertyBase* property = !item->isInherited() ? item->property() : findInheritedProperty(CSSPropertyIdSolid_Opacity);
if(property)
{
const SVGNumber* solidOpacity = to<SVGNumber>(property);
color.a = std::uint8_t(solidOpacity->value() * 255.0);
}
}
return color;
}
SVGElementImpl* SVGSolidColorElement::clone(SVGDocument* document) const
{
SVGSolidColorElement* e = new SVGSolidColorElement(document);
baseClone(*e);
return e;
}
} // namespace lunasvg
| 38.233624
| 157
| 0.685226
|
Siv3D
|
d4392fcf9791eda5469f1cbfe7851256bbeaa0c7
| 493
|
hpp
|
C++
|
include/SequentialSink.hpp
|
Modzeleczek/WebcamFilter
|
7af1a54565b405eae681f90dd59e22b099ead9f0
|
[
"MIT"
] | null | null | null |
include/SequentialSink.hpp
|
Modzeleczek/WebcamFilter
|
7af1a54565b405eae681f90dd59e22b099ead9f0
|
[
"MIT"
] | null | null | null |
include/SequentialSink.hpp
|
Modzeleczek/WebcamFilter
|
7af1a54565b405eae681f90dd59e22b099ead9f0
|
[
"MIT"
] | null | null | null |
#ifndef SequentialSink_HPP
#define SequentialSink_HPP
#include "Runner.hpp"
class SequentialSink : public Runner // przetwarzanie sekwencyjne bez bufora wyjściowego, do którego byśmy jawnie zapisywali w niniejszym programie
{
public:
SequentialSink(ISource &source, InPlaceProcessor &ipp, OutOfPlaceProcessor &oopp, ITarget &target);
SequentialSink(const SequentialSink &) = delete;
virtual ~SequentialSink();
virtual void Start() override;
};
#endif // SequentialSink_HPP
| 29
| 147
| 0.778905
|
Modzeleczek
|
d43b1b8b09d88a60e081f908d544e0b3f2aa2276
| 3,260
|
cpp
|
C++
|
src/OpenCascadeTest/OpenCascadeTest/OpenCascadeTest.cpp
|
devel0/SearchAThing.Solid
|
4731d5fd90d2ba7ce5f14e8b8ac0633024983064
|
[
"MIT"
] | 9
|
2019-08-15T08:35:56.000Z
|
2022-02-08T09:15:16.000Z
|
src/OpenCascadeTest/OpenCascadeTest/OpenCascadeTest.cpp
|
simutaroman/SearchAThing.Solid
|
19e1ba46fabc6b3267e7724acec48c24d0f96a92
|
[
"MIT"
] | 2
|
2020-05-05T12:46:08.000Z
|
2020-10-02T08:16:03.000Z
|
src/OpenCascadeTest/OpenCascadeTest/OpenCascadeTest.cpp
|
simutaroman/SearchAThing.Solid
|
19e1ba46fabc6b3267e7724acec48c24d0f96a92
|
[
"MIT"
] | 6
|
2018-12-19T08:15:36.000Z
|
2020-10-01T14:30:09.000Z
|
#include "stdafx.h"
#include <gp_Pnt.hxx>
#include <gp_Lin.hxx>
#include <STEPControl_Controller.hxx>
#include <STEPControl_Writer.hxx>
#include <IGESControl_Controller.hxx>
#include <IGESControl_Writer.hxx>
#include <BRepBuilderAPI_MakeEdge.hxx>
#include <BRepBuilderAPI_MakeWire.hxx>
#include <BRepBuilderAPI_MakeFace.hxx>
#include <BRepBuilderAPI_MakePolygon.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Wire.hxx>
#include <TopoDS_Shape.hxx>
#include <TopoDS_Face.hxx>
#include <GeomAPI_IntSS.hxx>
#include <GeomAPI_Interpolate.hxx>
#include <Geom_Line.hxx>
#include <TopOpeBRep_ShapeIntersector.hxx>
#include <BRepFill_FaceAndOrder.hxx>
#include <BRepTools.hxx>
#include <BRepTools_Modifier.hxx>
#include <BRepBuilderAPI_NurbsConvert.hxx>
#include <BRepOffset_Offset.hxx>
#include <BRepLib_FindSurface.hxx>
#include <BRepFill.hxx>
#include <BRep_TVertex.hxx>
#include <Geom_Curve.hxx>
#include <TopoDS.hxx>
#include <TopExp.hxx>
#include <BRep_Tool.hxx>
#include <GeomLProp_SLProps.hxx>
int main()
{
STEPControl_Controller::Init();
STEPControl_Writer STW;
IGESControl_Controller::Init();
IGESControl_Writer ICW("MM", 0);
TopoDS_Face face1;
TopoDS_Face face2;
{
gp_Pnt p1(0, 0, 0);
gp_Pnt p2(10, 0, 0);
gp_Pnt p3(0, 10, 0);
gp_Pnt p4(10, 10, 5);
auto edge12 = BRepBuilderAPI_MakeEdge(p1, p2);
auto edge23 = BRepBuilderAPI_MakeEdge(p2, p3);
auto edge34 = BRepBuilderAPI_MakeEdge(p3, p4);
auto edge41 = BRepBuilderAPI_MakeEdge(p4, p1);
face1 = BRepFill::Face(edge12, edge34);
ICW.AddShape(face1);
}
{
gp_Pnt p1(7.5, -5, -5);
gp_Pnt p2(7.5, 15, -5);
gp_Pnt p3(7.5, -5, 15);
gp_Pnt p4(7.5, 15, 15);
auto edge12 = BRepBuilderAPI_MakeEdge(p1, p2); auto edge21 = BRepBuilderAPI_MakeEdge(p2, p1);
auto edge34 = BRepBuilderAPI_MakeEdge(p3, p4); auto edge43 = BRepBuilderAPI_MakeEdge(p4, p3);
face2 = BRepFill::Face(edge12, edge34);
auto face2b = BRepFill::Face(edge21, edge43);
ICW.AddShape(face2);
ICW.AddShape(face2b);
{
auto umin = 0.0;
auto umax = 0.0;
auto vmin = 0.0;
auto vmax = 0.0;
BRepTools::UVBounds(face2, umin, umax, vmin, vmax);
auto surf = BRep_Tool::Surface(face2);
GeomLProp_SLProps props(surf, umin, vmin, 1, .01);
gp_Dir normal = props.Normal();
}
{
auto umin = 0.0;
auto umax = 0.0;
auto vmin = 0.0;
auto vmax = 0.0;
BRepTools::UVBounds(face2b, umin, umax, vmin, vmax);
auto surf = BRep_Tool::Surface(face2b);
GeomLProp_SLProps props(surf, umin, vmin, 1, .01);
gp_Dir normal = props.Normal();
}
auto off = BRepOffset_Offset(face2, 2);
ICW.AddShape(off.Face());
}
auto s1 = BRepLib_FindSurface(face1);
auto s2 = BRepLib_FindSurface(face2);
auto a = GeomAPI_IntSS(s1.Surface(), s2.Surface(), 1e-1);
printf("IsDone=%d\n", a.IsDone());
printf("lines = %d\n", a.NbLines());
Handle(Geom_Curve) C = a.Line(1);
BRepBuilderAPI_MakeEdge edge(C, C->FirstParameter(), C->LastParameter());
auto v1 = edge.Vertex1();
auto v2 = edge.Vertex2();
auto p1 = BRep_Tool::Pnt(v1);
auto p2 = BRep_Tool::Pnt(v2);
printf("Intersection line = (%f,%f,%f)-(%f,%f,%f)",
p1.X(), p1.Y(), p1.Z(),
p2.X(), p2.Y(), p2.Z());
ICW.AddGeom(C);
ICW.ComputeModel();
auto OK = ICW.Write("MyFile.igs");
return 0;
}
| 23.285714
| 97
| 0.692331
|
devel0
|
d43c4bc1cb701bbf58ad995bc57abf1680c17e26
| 351
|
cpp
|
C++
|
Brickjoon_Src/Silver3/11659.cpp
|
waixxt3213/Brickjoon
|
66b38d7026febb090d47db1c8c56793ff1e54617
|
[
"MIT"
] | 1
|
2021-07-29T14:27:44.000Z
|
2021-07-29T14:27:44.000Z
|
Brickjoon_Src/Silver3/11659.cpp
|
naixt1478/Brickjoon
|
3aa8c7121baf508128ce4f7cbb2ba44ca8745a87
|
[
"MIT"
] | null | null | null |
Brickjoon_Src/Silver3/11659.cpp
|
naixt1478/Brickjoon
|
3aa8c7121baf508128ce4f7cbb2ba44ca8745a87
|
[
"MIT"
] | 1
|
2020-10-10T14:35:59.000Z
|
2020-10-10T14:35:59.000Z
|
#include <bits/stdc++.h>
using namespace std;
int main()
{
cin.tie(nullptr);
ios_base::sync_with_stdio(false);
int m, n, i, j;
cin >> m >> n;
vector<int> num(m+1), sum(m+1);
for (int k = 1; k <= m; k++)
{
cin >> num[k];
sum[k] = sum[k - 1] + num[k];
}
while (n--)
{
cin >> i >> j;
cout << sum[j] - sum[i-1] << '\n';
}
}
// solve
| 14.04
| 36
| 0.492877
|
waixxt3213
|
d43e06a7e34f4f23ea46aa6feebd3779f78587e1
| 203
|
cpp
|
C++
|
L09-AVL/main.cpp
|
tlyon3/CS235
|
2bdb8eaf66c9adbfe7ec59c0535852fd1cc30eda
|
[
"MIT"
] | 1
|
2018-03-04T02:58:55.000Z
|
2018-03-04T02:58:55.000Z
|
L09-AVL/main.cpp
|
tlyon3/CS235
|
2bdb8eaf66c9adbfe7ec59c0535852fd1cc30eda
|
[
"MIT"
] | 1
|
2015-02-09T21:29:12.000Z
|
2015-02-09T21:32:06.000Z
|
L09-AVL/main.cpp
|
tlyon3/CS235
|
2bdb8eaf66c9adbfe7ec59c0535852fd1cc30eda
|
[
"MIT"
] | 4
|
2019-05-20T02:57:47.000Z
|
2021-02-11T15:41:15.000Z
|
#include "./Student_Code/avl.cpp"
#include "./Student_Code/node.cpp"
using namespace std;
int main()
{
AVL myavl;
myavl.add(0);
//cout<<"Height of root: "<<myavl.height(myavl.getRootNode())<<endl;
}
| 18.454545
| 69
| 0.684729
|
tlyon3
|
d43e97b044036098211d498133d3ded5befcc95e
| 309
|
cpp
|
C++
|
Notebook/codes/estruturas/busca_vector.cpp
|
rodrigoAMF7/Notebook---Maratonas
|
06b38197a042bfbd27b20f707493e0a19fda7234
|
[
"MIT"
] | 4
|
2019-01-25T21:22:55.000Z
|
2019-03-20T18:04:01.000Z
|
Notebook/codes/estruturas/busca_vector.cpp
|
rodrigoAMF/competitive-programming-notebook
|
06b38197a042bfbd27b20f707493e0a19fda7234
|
[
"MIT"
] | null | null | null |
Notebook/codes/estruturas/busca_vector.cpp
|
rodrigoAMF/competitive-programming-notebook
|
06b38197a042bfbd27b20f707493e0a19fda7234
|
[
"MIT"
] | null | null | null |
iterator find(iterator first, iterator last, const T &value);
iterator find_if(iterator first, iterator last, const T &value, TestFunction test);
bool binary_search(iterator first, iterator last, const T &value);
bool binary_search(iterator first, iterator last, const T &value, LessThanOrEqualFunction comp);
| 77.25
| 96
| 0.802589
|
rodrigoAMF7
|
d445b98d3828228e3ff991f917e244f31462b2b0
| 288
|
cpp
|
C++
|
AtCoder/abc028/a/main.cpp
|
H-Tatsuhiro/Com_Pro-Cpp
|
fd79f7821a76b11f4a6f83bbb26a034db577a877
|
[
"MIT"
] | null | null | null |
AtCoder/abc028/a/main.cpp
|
H-Tatsuhiro/Com_Pro-Cpp
|
fd79f7821a76b11f4a6f83bbb26a034db577a877
|
[
"MIT"
] | 1
|
2021-10-19T08:47:23.000Z
|
2022-03-07T05:23:56.000Z
|
AtCoder/abc028/a/main.cpp
|
H-Tatsuhiro/Com_Pro-Cpp
|
fd79f7821a76b11f4a6f83bbb26a034db577a877
|
[
"MIT"
] | null | null | null |
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
int N; cin >> N;
if (N <= 59) cout << "Bad";
else if (N <= 89) cout << "Good";
else if (N <= 99) cout << "Great";
else cout << "Perfect";
cout << endl;
}
| 20.571429
| 38
| 0.548611
|
H-Tatsuhiro
|
d45532baa763a37b78fe4ce88d348bba9f8e259f
| 4,065
|
cpp
|
C++
|
src/projections/cass.cpp
|
mlptownsend/PROJ
|
4920c22637d05cd7aa0aecc6de69736dd4c6845b
|
[
"MIT"
] | 653
|
2015-03-27T10:12:52.000Z
|
2019-06-03T02:00:49.000Z
|
src/projections/cass.cpp
|
mlptownsend/PROJ
|
4920c22637d05cd7aa0aecc6de69736dd4c6845b
|
[
"MIT"
] | 987
|
2019-06-05T11:42:40.000Z
|
2022-03-31T20:35:18.000Z
|
src/projections/cass.cpp
|
mlptownsend/PROJ
|
4920c22637d05cd7aa0aecc6de69736dd4c6845b
|
[
"MIT"
] | 360
|
2019-06-20T23:50:36.000Z
|
2022-03-31T11:47:00.000Z
|
#define PJ_LIB__
#include <errno.h>
#include <math.h>
#include "proj.h"
#include "proj_internal.h"
PROJ_HEAD(cass, "Cassini") "\n\tCyl, Sph&Ell";
# define C1 .16666666666666666666
# define C2 .00833333333333333333
# define C3 .04166666666666666666
# define C4 .33333333333333333333
# define C5 .06666666666666666666
namespace { // anonymous namespace
struct cass_data {
double *en;
double m0;
bool hyperbolic;
};
} // anonymous namespace
static PJ_XY cass_e_forward (PJ_LP lp, PJ *P) { /* Ellipsoidal, forward */
PJ_XY xy = {0.0, 0.0};
struct cass_data *Q = static_cast<struct cass_data*>(P->opaque);
const double sinphi = sin (lp.phi);
const double cosphi = cos (lp.phi);
const double M = pj_mlfn (lp.phi, sinphi, cosphi, Q->en);
const double nu_square = 1./(1. - P->es * sinphi*sinphi);
const double nu = sqrt(nu_square);
const double tanphi = tan(lp.phi);
const double T = tanphi * tanphi;
const double A = lp.lam * cosphi;
const double C = P->es * (cosphi * cosphi) / (1 - P->es);
const double A2 = A * A;
xy.x = nu * A * (1. - A2 * T *
(C1 - (8. - T + 8. * C) * A2 * C2));
xy.y = M - Q->m0 + nu * tanphi * A2 *
(.5 + (5. - T + 6. * C) * A2 * C3);
if( Q->hyperbolic )
{
const double rho = nu_square * (1. - P->es) * nu;
xy.y -= xy.y * xy.y * xy.y / (6 * rho * nu);
}
return xy;
}
static PJ_XY cass_s_forward (PJ_LP lp, PJ *P) { /* Spheroidal, forward */
PJ_XY xy = {0.0, 0.0};
xy.x = asin (cos (lp.phi) * sin (lp.lam));
xy.y = atan2 (tan (lp.phi), cos (lp.lam)) - P->phi0;
return xy;
}
static PJ_LP cass_e_inverse (PJ_XY xy, PJ *P) { /* Ellipsoidal, inverse */
PJ_LP lp = {0.0, 0.0};
struct cass_data *Q = static_cast<struct cass_data*>(P->opaque);
const double phi1 = pj_inv_mlfn (P->ctx, Q->m0 + xy.y, P->es, Q->en);
const double tanphi1 = tan (phi1);
const double T1 = tanphi1*tanphi1;
const double sinphi1 = sin (phi1);
const double nu1_square = 1. / (1. - P->es * sinphi1 * sinphi1);
const double nu1 = sqrt (nu1_square);
const double rho1 = nu1_square * (1. - P->es) * nu1;
const double D = xy.x / nu1;
const double D2 = D * D;
lp.phi = phi1 - (nu1 * tanphi1 / rho1) * D2 *
(.5 - (1. + 3. * T1) * D2 * C3);
lp.lam = D * (1. + T1 * D2 *
(-C4 + (1. + 3. * T1) * D2 * C5)) / cos (phi1);
if( Q->hyperbolic )
{
// EPSG guidance note 7-2 suggests a custom approximation for the
// 'Vanua Levu 1915 / Vanua Levu Grid' case, but better use the
// generic inversion method
lp = pj_generic_inverse_2d(xy, P, lp);
}
return lp;
}
static PJ_LP cass_s_inverse (PJ_XY xy, PJ *P) { /* Spheroidal, inverse */
PJ_LP lp = {0.0,0.0};
double dd;
lp.phi = asin(sin(dd = xy.y + P->phi0) * cos(xy.x));
lp.lam = atan2(tan(xy.x), cos(dd));
return lp;
}
static PJ *destructor (PJ *P, int errlev) { /* Destructor */
if (nullptr==P)
return nullptr;
if (nullptr==P->opaque)
return pj_default_destructor (P, errlev);
free (static_cast<struct cass_data*>(P->opaque)->en);
return pj_default_destructor (P, errlev);
}
PJ *PROJECTION(cass) {
/* Spheroidal? */
if (0==P->es) {
P->inv = cass_s_inverse;
P->fwd = cass_s_forward;
return P;
}
/* otherwise it's ellipsoidal */
auto Q = static_cast<struct cass_data*>(calloc (1, sizeof (struct cass_data)));
P->opaque = Q;
if (nullptr==P->opaque)
return pj_default_destructor (P, PROJ_ERR_OTHER /*ENOMEM*/);
P->destructor = destructor;
Q->en = pj_enfn (P->es);
if (nullptr==Q->en)
return pj_default_destructor (P, PROJ_ERR_OTHER /*ENOMEM*/);
Q->m0 = pj_mlfn (P->phi0, sin (P->phi0), cos (P->phi0), Q->en);
if (pj_param_exists(P->params, "hyperbolic"))
Q->hyperbolic = true;
P->inv = cass_e_inverse;
P->fwd = cass_e_forward;
return P;
}
| 27.842466
| 83
| 0.568512
|
mlptownsend
|
d4567ccd5f10992e55fca02a409dee0c28290648
| 1,810
|
hpp
|
C++
|
zen/fs.hpp
|
ZenLibraries/ZenLibraries
|
ae189b5080c75412cbd4f33cf6cfb51e15f6ee66
|
[
"Apache-2.0"
] | null | null | null |
zen/fs.hpp
|
ZenLibraries/ZenLibraries
|
ae189b5080c75412cbd4f33cf6cfb51e15f6ee66
|
[
"Apache-2.0"
] | 2
|
2020-02-06T17:01:39.000Z
|
2020-02-12T17:50:14.000Z
|
zen/fs.hpp
|
ZenLibraries/ZenLibraries
|
ae189b5080c75412cbd4f33cf6cfb51e15f6ee66
|
[
"Apache-2.0"
] | null | null | null |
#ifndef INFERA_FS_HPP
#define INFERA_FS_HPP
#include <string>
#include <memory>
#include "zen/config.h"
#include "zen/either.hpp"
ZEN_NAMESPACE_START
namespace fs {
template<typename T>
using Result = Either<int, T>;
using Path = std::string;
class File;
struct FileHandle;
struct FileContentsHandle;
/// @brief Represents the contents of an open file
///
/// This class efficiently shares resources with its clones so that the file
/// needs to be mapped into memory only once.
class FileContents {
friend class File;
std::shared_ptr<FileContentsHandle> handle;
inline FileContents(std::shared_ptr<FileContentsHandle> handle):
handle(handle) {}
public:
/// Create a freshly allocated std::string that will contain the entire
/// file contents.
std::string as_string() const;
/// Convert the contents of the associated file to a string
std::string_view as_string_view() const;
};
/// @brief A reference to a single regular file on the file system
///
/// This class cannot be directly constructed. Instead, you should obtain a
/// copy from a function such as `path::open`.
class File {
friend Result<File> file_from_path(Path p);
std::shared_ptr<FileHandle> handle;
inline File(std::shared_ptr<FileHandle> handle):
handle(handle) {}
public:
/// @brief Get a structure for querying the contents of this file
///
/// This method will try to use the operating system's best available APIs
/// to map the file into memory, falling back to a full scan if no
/// specialised functions exist.
Result<FileContents> get_contents();
};
Result<std::string> read_file(Path p);
Result<File> file_from_path(Path p);
}
ZEN_NAMESPACE_END
#endif // of #ifndef INFERA_FS_HPP
| 22.345679
| 78
| 0.696685
|
ZenLibraries
|
d4584c43dfd1ca98047edf85344f6e0615c9b90a
| 3,530
|
cpp
|
C++
|
elenasrc2/ide/gtk-linux32/main.cpp
|
drkameleon/elena-lang
|
8585e93a3bc0b19f8d60029ffbe01311d0b711a3
|
[
"MIT"
] | 193
|
2015-07-03T22:23:27.000Z
|
2022-03-15T18:56:02.000Z
|
elenasrc2/ide/gtk-linux32/main.cpp
|
drkameleon/elena-lang
|
8585e93a3bc0b19f8d60029ffbe01311d0b711a3
|
[
"MIT"
] | 531
|
2015-05-07T09:39:42.000Z
|
2021-09-27T07:51:38.000Z
|
elenasrc2/ide/gtk-linux32/main.cpp
|
drkameleon/elena-lang
|
8585e93a3bc0b19f8d60029ffbe01311d0b711a3
|
[
"MIT"
] | 31
|
2015-09-30T13:07:36.000Z
|
2021-10-15T13:08:04.000Z
|
//---------------------------------------------------------------------------
// E L E N A P r o j e c t: ELENA IDE
// Linux-GTK+ program entry
// (C)2005-2016, by Alexei Rakov
//---------------------------------------------------------------------------
#include "gtkide.h"
////#include "gtkideconst.h"
#include "../appwindow.h"
#include "../settings.h"
using namespace _GUI_;
//#pragma GCC diagnostic ignored "-Wwrite-strings"
// --- command line arguments ---
#define CMD_CONFIG_PATH _T("-c")
//// --- getBasePath --
//
//void getBasePath(_path_t* path)
//{
// pid_t pid = getpid();
//
// _ELENA_::String<char, 50> link;
//
// link.copy("/proc/");
// link.appendInt(pid);
// link.append("/exe");
//
// char proc[512];
// int ch = readlink(link, proc, 512);
// if (ch != -1) {
// proc[ch] = 0;
// int index = _ELENA_::StringHelper::findLast(proc, '/');
// _ELENA_::StringHelper::copy(path, proc, index);
// path[index] = 0;
// }
// else path[0] = 0;
//}
// --- loadCommandLine ---
inline void setOption(Model* model, const char* parameter)
{
if (parameter[0]!='-') {
if (_ELENA_::Path::checkExtension(parameter, "l")) {
model->defaultFiles.add(_ELENA_::StrFactory::clone(parameter));
}
else if (_ELENA_::Path::checkExtension(parameter, "prj")) {
model->defaultProject.copy(parameter);
}
}
}
void loadCommandLine(Model* model, int argc, char *argv[], _ELENA_::Path& configPath)
{
for (int i = 1 ; i < argc ; i++) {
if (_ELENA_::ident_t(argv[i]).compare(CMD_CONFIG_PATH, _ELENA_::getlength(CMD_CONFIG_PATH))) {
configPath.copy(argv[i] + _ELENA_::getlength(CMD_CONFIG_PATH));
}
else setOption(model, argv[i]);
}
}
// --- loadSettings ---
//void loadSettings(const _path_t* path, IDE& appWindow)
void loadSettings(_ELENA_::path_t path, Model* model, GTKIDEWindow* view)
{
_ELENA_::IniConfigFile file;
if (file.load(path, _ELENA_::feUTF8)) {
Settings::load(model, file);
// !! temporal
//view->appWindow.loadHistory(file, RECENTFILES_SECTION, RECENTRPOJECTS_SECTION);
//view->appWindow.reloadSettings();
}
}
// --- saveSettings ---
void saveSettings(_ELENA_::path_t path, Model* model, GTKIDEWindow* view)
{
_ELENA_::IniConfigFile file;
Settings::save(model, file);
// !! temporal
//view->appWindow.saveHistory(file, RECENTFILES_SECTION, RECENTRPOJECTS_SECTION);
file.save(path, _ELENA_::feUTF8);
}
// --- main ---
int main( int argc, char *argv[])
{
Model model;
// // get app path
// _path_t appPath[FILENAME_MAX];
// getBasePath(appPath);
//
// // get default path
// _path_t defPath[FILENAME_MAX];
// getcwd(defPath, FILENAME_MAX);
Gtk::Main kit(argc, argv);
// init paths & settings
// Paths::init(&model, appPath, defPath);
Settings::init(&model, "/usr/elena-lang/src/elena/src40", "/usr/lib/elena/lib40");
_ELENA_::Path configPath("/etc/elena");
configPath.combine(_T("ide.config"));
// load command line argiments
loadCommandLine(&model, argc, argv, configPath);
IDEController ide;
GTKIDEWindow view("IDE", &ide, &model);
// init IDE settings
loadSettings(configPath.str(), &model, &view);
// controller.assign(ide.getAppWindow());
// start IDE
ide.start(&view, &view, &model);
Gtk::Main::run(view);
saveSettings(configPath.str(), &model, &view);
// Font::releaseFontCache();
return 0;
}
| 25.035461
| 100
| 0.589518
|
drkameleon
|
d465d01615e353378dec5d8f64839fdcc1b3010f
| 2,233
|
cpp
|
C++
|
BZOJ/2595/code.cpp
|
sjj118/OI-Code
|
964ea6e799d14010f305c7e4aee269d860a781f7
|
[
"MIT"
] | null | null | null |
BZOJ/2595/code.cpp
|
sjj118/OI-Code
|
964ea6e799d14010f305c7e4aee269d860a781f7
|
[
"MIT"
] | null | null | null |
BZOJ/2595/code.cpp
|
sjj118/OI-Code
|
964ea6e799d14010f305c7e4aee269d860a781f7
|
[
"MIT"
] | null | null | null |
#include<iostream>
#include<cstdio>
#include<queue>
#define maxn 11
#define inf 1e9
using namespace std;
const int dir[4][2]={{0,1},{0,-1},{1,0},{-1,0}};
int n,m,map[maxn][maxn],dp[1<<maxn][maxn][maxn],pre[1<<maxn][maxn][maxn],s[maxn][maxn],k;
int st[maxn][maxn];
queue<int> Q;int inq[maxn*maxn<<maxn];
inline void push(int x){if(!inq[x])Q.push(x);inq[x]=1;}
inline void pop(){inq[Q.front()]=0;Q.pop();}
inline int h(int sta,int x,int y){return sta*maxn*maxn+x*maxn+y;}
inline void fh(int h,int&sta,int&x,int&y){y=h%maxn;h/=maxn;x=h%maxn;h/=maxn;sta=h;}
inline bool avail(int x,int y){return x>=1&&x<=n&&y>=1&&y<=m;}
inline bool updata(int&x,int y){if(y<x){x=y;return 1;}return 0;}
void spfa(){
while(Q.size()){
int sta,x,y;fh(Q.front(),sta,x,y);pop();
for(int i=0;i<4;++i)if(avail(x+dir[i][0],y+dir[i][1])/*&&((sta|s[x+dir[i][0]][y+dir[i][1]])==sta)*/){
if(updata(dp[sta][x+dir[i][0]][y+dir[i][1]],dp[sta][x][y]+map[x+dir[i][0]][y+dir[i][1]]))push(h(sta,x+dir[i][0],y+dir[i][1])),pre[sta][x+dir[i][0]][y+dir[i][1]]=h(sta,x,y);
}
}
}
void go(int p){
if(!p)return;
int sta,x,y;fh(p,sta,x,y);
if(!st[x][y])st[x][y]=-1;
go(pre[sta][x][y]);
if(pre[sta][x][y]/maxn/maxn!=sta)go(pre[sta^(pre[sta][x][y]/maxn/maxn)][x][y]);
}
int main(){
scanf("%d%d",&n,&m);
for(int i=1;i<=n;++i)for(int j=1;j<=m;++j){scanf("%d",&map[i][j]);if(!map[i][j])st[i][j]=1<<k,s[i][j]=++k;}
for(int x=0;x<maxn;++x)for(int y=0;y<maxn;++y)dp[0][x][y]=map[x][y];
for(int i=0;i<1<<maxn;++i){
for(int x=1;x<=n;++x)for(int y=1;y<=m;++y){
dp[i][x][y]=inf;
if(st[x][y]==i)dp[i][x][y]=0;
}
}
for(int sta=1;sta<1<<k;++sta){
for(int x=1;x<=n;++x){
for(int y=1;y<=m;++y){
for(int j=(sta-1)&sta;j;j=(j-1)&sta)if(updata(dp[sta][x][y],dp[j][x][y]+dp[sta^j][x][y]-map[x][y]))pre[sta][x][y]=h(j,x,y);
if(dp[sta][x][y]<inf)push(h(sta,x,y));
}
}
spfa();
}
int ans=inf,p;
for(int x=1;x<=n;++x)for(int y=1;y<=m;++y)ans=min(ans,dp[(1<<k)-1][x][y]);
printf("%d\n",ans);
for(int i=1;i<=n;++i)for(int j=1;j<=m;++j)if(st[i][j]){p=h((1<<k)-1,i,j);}
go(p);
for(int i=1;i<=n;++i){
for(int j=1;j<=m;++j){
if(st[i][j]==-1)printf("o");
else if(st[i][j]==0)printf("_");
else printf("x");
}
printf("\n");
}
return 0;
}
| 32.362319
| 175
| 0.537394
|
sjj118
|
d46ca70032d9ca0e77631267eff8f921b909c4bf
| 3,187
|
cpp
|
C++
|
src/Loaders/HeaderBLoader.cpp
|
driftyz700/EAlayer3-nfsw
|
0bfe05ae18e5f1eb25917751c2772cfa49b60342
|
[
"BSD-3-Clause"
] | 8
|
2021-01-26T15:30:21.000Z
|
2021-08-29T19:44:26.000Z
|
src/Loaders/HeaderBLoader.cpp
|
driftyz700/EAlayer3-nfsw
|
0bfe05ae18e5f1eb25917751c2772cfa49b60342
|
[
"BSD-3-Clause"
] | 1
|
2020-10-31T00:40:01.000Z
|
2020-10-31T00:40:01.000Z
|
src/Loaders/HeaderBLoader.cpp
|
Bo98/ealayer3
|
ec3df1e5b4f27e91c919d1be6cb43fc992f37ece
|
[
"BSD-3-Clause"
] | 2
|
2021-01-27T14:24:01.000Z
|
2021-02-12T10:51:42.000Z
|
/*
EA Layer 3 Extractor/Decoder
Copyright (C) 2010, Ben Moench.
See License.txt
*/
#include "Internal.h"
#include "HeaderBLoader.h"
#include "../Parsers/ParserVersion6.h"
elHeaderBLoader::elHeaderBLoader() :
m_SampleRate(0),
m_UseParser6(true)
{
return;
}
elHeaderBLoader::~elHeaderBLoader()
{
return;
}
const std::string elHeaderBLoader::GetName() const
{
return "Header B";
}
bool elHeaderBLoader::Initialize(std::istream* Input)
{
elBlockLoader::Initialize(Input);
// Read the small header
uint16_t BlockType;
uint16_t BlockSize;
m_Input->read((char*)&BlockType, 2);
m_Input->read((char*)&BlockSize, 2);
Swap(BlockType);
Swap(BlockSize);
if (BlockType != 0x4800)
{
VERBOSE("L: header B loader incorrect because of block type");
return false;
}
if (BlockSize < 8)
{
VERBOSE("L: header B loader incorrect because of block size");
return false;
}
// Read in the contents of the block
uint8_t Compression;
uint16_t SampleRate;
m_Input->read((char*)&Compression, 1);
m_Input->get();
m_Input->read((char*)&SampleRate, 2);
Swap(SampleRate);
// Different parsers for different values
if (Compression == 0x15)
{
m_UseParser6 = false;
}
else if (Compression == 0x16)
{
m_UseParser6 = true;
}
else
{
VERBOSE("L: header B loader incorrect because of compression");
return false;
}
m_SampleRate = SampleRate;
m_Input->seekg(BlockSize - 8, std::ios_base::cur);
VERBOSE("L: header B loader correct");
return true;
}
bool elHeaderBLoader::ReadNextBlock(elBlock& Block)
{
if (!m_Input)
{
return false;
}
if (m_Input->eof())
{
return false;
}
uint16_t BlockType;
uint16_t BlockSize;
uint32_t Samples;
const std::streamoff Offset = m_Input->tellg();
m_Input->read((char*)&BlockType, 2);
m_Input->read((char*)&BlockSize, 2);
m_Input->read((char*)&Samples, 4);
if (m_Input->eof())
{
return false;
}
Swap(BlockType);
Swap(BlockSize);
Swap(Samples);
if (BlockType == 0x4500)
{
return false;
}
else if (BlockType != 0x4400)
{
VERBOSE("L: header B invalid block type");
return false;
}
if (BlockSize <= 8)
{
VERBOSE("L: header B block too small");
return false;
}
BlockSize -= 8;
shared_array<uint8_t> Data(new uint8_t[BlockSize]);
m_Input->read((char*)Data.get(), BlockSize);
Block.Clear();
Block.Data = Data;
Block.SampleCount = Samples;
Block.Size = BlockSize;
Block.Offset = Offset;
m_CurrentBlockIndex++;
return true;
}
shared_ptr<elParser> elHeaderBLoader::CreateParser() const
{
if (m_UseParser6)
{
return make_shared<elParserVersion6>();
}
return make_shared<elParser>();
}
void elHeaderBLoader::ListSupportedParsers(std::vector<std::string>& Names) const
{
Names.push_back(make_shared<elParser>()->GetName());
Names.push_back(make_shared<elParserVersion6>()->GetName());
return;
}
| 20.044025
| 81
| 0.613743
|
driftyz700
|
d46e4e6978cd34916711731f7a420ddbc62e140c
| 416
|
hpp
|
C++
|
galaxy/src/galaxy/platform/specific/Unix.hpp
|
reworks/rework
|
90508252c9a4c77e45a38e7ce63cfd99f533f42b
|
[
"Apache-2.0"
] | 6
|
2018-07-21T20:37:01.000Z
|
2018-10-31T01:49:35.000Z
|
galaxy/src/galaxy/platform/specific/Unix.hpp
|
reworks/rework
|
90508252c9a4c77e45a38e7ce63cfd99f533f42b
|
[
"Apache-2.0"
] | null | null | null |
galaxy/src/galaxy/platform/specific/Unix.hpp
|
reworks/rework
|
90508252c9a4c77e45a38e7ce63cfd99f533f42b
|
[
"Apache-2.0"
] | null | null | null |
///
/// Unix.hpp
/// galaxy
///
/// Refer to LICENSE.txt for more details.
///
#ifndef GALAXY_PLATFORM_SPECIFIC_UNIX_HPP_
#define GALAXY_PLATFORM_SPECIFIC_UNIX_HPP_
#include "galaxy/utils/Globals.hpp"
#ifdef GALAXY_UNIX_PLATFORM
namespace galaxy
{
namespace platform
{
///
/// Sets up debug terminal.
///
void configure_terminal() noexcept;
} // namespace platform
} // namespace galaxy
#endif
#endif
| 15.407407
| 42
| 0.721154
|
reworks
|
d4726579794ff4318095d0b016a11686668b65c6
| 4,213
|
cpp
|
C++
|
test/template_vulkan-dynamic/flextVk.cpp
|
mosra/flextGL
|
bc3d4da8fc087cba17d64e9d908ae35b7e40f4fe
|
[
"MIT"
] | 119
|
2018-05-31T19:11:17.000Z
|
2022-03-29T04:56:46.000Z
|
test/template_vulkan-dynamic/flextVk.cpp
|
ginkgo/flextGL
|
bc3d4da8fc087cba17d64e9d908ae35b7e40f4fe
|
[
"MIT"
] | 5
|
2015-01-16T12:24:22.000Z
|
2018-05-27T14:52:45.000Z
|
test/template_vulkan-dynamic/flextVk.cpp
|
mosra/flextGL
|
bc3d4da8fc087cba17d64e9d908ae35b7e40f4fe
|
[
"MIT"
] | 8
|
2015-01-29T13:27:13.000Z
|
2017-01-31T09:20:03.000Z
|
/*
This file was generated using https://github.com/mosra/flextgl:
path/to/flextGLgen.py -D generated -t somepath profile-vk.txt
Do not edit directly, modify the template or profile and regenerate.
*/
#include "flextVk.h"
/* The following definitions and flextDynamicLoader are borrowed/modified from vulkan.hpp DynamicLoader */
// Copyright (c) 2015-2020 The Khronos Group Inc.
//
// SPDX-License-Identifier: Apache-2.0 OR MIT
//
#if defined(__linux__) || defined(__APPLE__)
#include <dlfcn.h>
#elif defined(_WIN32)
typedef struct HINSTANCE__ *HINSTANCE;
#if defined(_WIN64)
typedef int64_t(__stdcall *FARPROC)();
#else
typedef int(__stdcall *FARPROC)();
#endif
extern "C" __declspec(dllimport) HINSTANCE __stdcall LoadLibraryA(char const *lpLibFileName);
extern "C" __declspec(dllimport) int __stdcall FreeLibrary(HINSTANCE hLibModule);
extern "C" __declspec(dllimport) FARPROC __stdcall GetProcAddress(HINSTANCE hModule, const char *lpProcName);
#endif
class flextDynamicLoader {
public:
flextDynamicLoader() : m_success(false), m_library(nullptr) {
}
~flextDynamicLoader() {
if (m_library) {
#if defined(__linux__) || defined(__APPLE__)
dlclose(m_library);
#elif defined(_WIN32)
::FreeLibrary(m_library);
#else
#error unsupported platform
#endif
}
}
bool init() {
if (m_success) return true;
#if defined(__linux__)
m_library = dlopen("libvulkan.so", RTLD_NOW | RTLD_LOCAL);
if (m_library == nullptr) {
m_library = dlopen("libvulkan.so.1", RTLD_NOW | RTLD_LOCAL);
}
m_success = (m_library != nullptr);
#elif defined(__APPLE__)
m_library = dlopen("libvulkan.dylib", RTLD_NOW | RTLD_LOCAL);
m_success = (m_library != nullptr);
#elif defined(_WIN32)
m_library = ::LoadLibraryA("vulkan-1.dll");
m_success = (m_library != nullptr);
#else
#error unsupported platform
#endif
return m_success;
}
#if defined(__linux__) || defined(__APPLE__)
void*
#elif defined(_WIN32)
FARPROC
#else
#error unsupported platform
#endif
getProcAddress(const char *function) const {
#if defined(__linux__) || defined(__APPLE__)
return dlsym(m_library, function);
#elif defined(_WIN32)
return ::GetProcAddress(m_library, function);
#else
#error unsupported platform
#endif
}
private:
bool m_success;
#if defined(__linux__) || defined(__APPLE__)
void *m_library;
#elif defined(_WIN32)
::HINSTANCE m_library;
#else
#error unsupported platform
#endif
};
VkResult(VKAPI_PTR *flextvkAcquireNextImageKHR)(VkDevice, VkSwapchainKHR, uint64_t, VkSemaphore, VkFence, uint32_t*) = nullptr;
VkResult(VKAPI_PTR *flextvkCreateBuffer)(VkDevice, const VkBufferCreateInfo*, const VkAllocationCallbacks*, VkBuffer*) = nullptr;
PFN_vkVoidFunction(VKAPI_PTR *flextvkGetDeviceProcAddr)(VkDevice, const char*) = nullptr;
PFN_vkVoidFunction(VKAPI_PTR *flextvkGetInstanceProcAddr)(VkInstance, const char*) = nullptr;
VkResult(VKAPI_PTR *flextvkEnumerateInstanceVersion)(uint32_t*) = nullptr;
bool flextVkInit() {
static flextDynamicLoader loader;
if (!loader.init()) return false;
flextvkGetInstanceProcAddr = reinterpret_cast<PFN_vkVoidFunction(VKAPI_PTR*)(VkInstance, const char*)>(loader.getProcAddress("vkGetInstanceProcAddr"));
if (flextvkGetInstanceProcAddr) {
flextvkEnumerateInstanceVersion = reinterpret_cast<VkResult(VKAPI_PTR*)(uint32_t*)>(flextvkGetInstanceProcAddr(nullptr, "vkEnumerateInstanceVersion"));
}
return true;
}
void flextVkInitInstance(VkInstance instance) {
flextvkAcquireNextImageKHR = reinterpret_cast<VkResult(VKAPI_PTR*)(VkDevice, VkSwapchainKHR, uint64_t, VkSemaphore, VkFence, uint32_t*)>(flextvkGetInstanceProcAddr(instance, "vkAcquireNextImageKHR"));
flextvkCreateBuffer = reinterpret_cast<VkResult(VKAPI_PTR*)(VkDevice, const VkBufferCreateInfo*, const VkAllocationCallbacks*, VkBuffer*)>(flextvkGetInstanceProcAddr(instance, "vkCreateBuffer"));
flextvkGetDeviceProcAddr = reinterpret_cast<PFN_vkVoidFunction(VKAPI_PTR*)(VkDevice, const char*)>(flextvkGetInstanceProcAddr(instance, "vkGetDeviceProcAddr"));
}
| 36.634783
| 204
| 0.733919
|
mosra
|
d4733c9efc905f1b6dfc769ea7e49836be28cbca
| 7,594
|
cpp
|
C++
|
src/ClassOverviewVisitor.cpp
|
Gregofi/metrics
|
a8da292a98b66a36329f1e5c9423ec01d86c07a1
|
[
"MIT"
] | null | null | null |
src/ClassOverviewVisitor.cpp
|
Gregofi/metrics
|
a8da292a98b66a36329f1e5c9423ec01d86c07a1
|
[
"MIT"
] | 1
|
2022-02-05T09:52:40.000Z
|
2022-02-05T09:52:40.000Z
|
src/ClassOverviewVisitor.cpp
|
Gregofi/metrics
|
a8da292a98b66a36329f1e5c9423ec01d86c07a1
|
[
"MIT"
] | null | null | null |
#include "include/metrics/ClassOverviewVisitor.hpp"
#include "include/Logging.hpp"
#include "include/ASTMatcherVisitor.hpp"
#include "include/Utility.hpp"
bool ClassOverviewVisitor::VisitCXXRecordDecl(clang::CXXRecordDecl *decl)
{
/* Skip declarations that have no body and that aren't in main file */
if(!decl || !decl->isThisDeclarationADefinition() || ctx->getSourceManager().isInSystemHeader(decl->getLocation())
/* Also skip declarations which represents lambdas and classes that we already added(this happens if they are
* included from multiple files */
|| decl->isLambda() || classes.count(decl->getQualifiedNameAsString())
|| (!decl->isClass() && !decl->isStruct()))
return true;
/* Create new class in map, this is important because if there is an empty class (class A{};), it
* wouldn't be added otherwise */
if(!classes.count(decl->getQualifiedNameAsString()))
classes[decl->getQualifiedNameAsString()];
for(const auto &base : decl->bases())
{
/* Base can also be template argument, only count if its concrete class */
if(base.getType()->getAsCXXRecordDecl())
{
classes[base.getType()->getAsCXXRecordDecl()->getQualifiedNameAsString()].children_count += 1;
classes[decl->getQualifiedNameAsString()].inheritance_chain.emplace_back(base.getType()->getAsCXXRecordDecl()->getQualifiedNameAsString());
}
}
CalculateLorKiddMetrics(decl);
return true;
}
bool ClassOverviewVisitor::VisitCXXMethodDecl(clang::CXXMethodDecl *decl)
{
if(!decl || !decl->isThisDeclarationADefinition()
|| ctx->getSourceManager().isInSystemHeader(decl->getLocation()) || decl->getParent()->isLambda())
return true;
ASTMatcherVisitor vis(ctx);
MethodCallback callback(decl->getParent()->getQualifiedNameAsString(), &classes);
vis.AddMatchers({cxxMemberCallExpr().bind("member_call"), memberExpr().bind("member_access")}, &callback);
vis.TraverseDecl(decl);
classes[decl->getParent()->getQualifiedNameAsString()].functions.emplace_back(callback.GetInstanceVars());
auto vars = callback.GetInstanceVars();
return true;
}
int ClassOverviewVisitor::GetInheritanceChainLen(const std::string &s) const
{
const auto &chain = classes.at(s).inheritance_chain;
if(chain.empty())
return 0;
int res = 0;
for(const auto &c : chain)
res = std::max(GetInheritanceChainLen(c) + 1, res);
return res;
}
bool ClassOverviewVisitor::Similar(const std::set<std::string> &s1, const std::set<std::string> &s2)
{
for(auto it1 = s1.begin(), it2 = s2.begin(); it1 != s1.end() && it2 != s2.end();)
{
if(*it1 == *it2)
return true;
if(*it1 < *it2)
++it1;
else
++it2;
}
return false;
}
int ClassOverviewVisitor::LackOfCohesion(const std::string &s) const
{
auto c = classes.at(s);
c.functions.size();
int LOC = 0;
for(size_t i = 0; i < c.functions.size(); ++ i)
for(size_t j = i + 1; j < c.functions.size(); ++ j)
LOC += Similar(c.functions[i], c.functions[j]) ? -1 : 1;
return std::max(LOC, 0);
}
void MethodCallback::run(const MatchFinder::MatchResult &Result)
{
if(const auto *call = Result.Nodes.getNodeAs<CXXMemberCallExpr>("member_call"))
{
/* If this class calls method from other class its coupled with it. Check if the called
* method is from other class then this one */
if(const auto &s = call->getMethodDecl()->getParent()->getQualifiedNameAsString(); s != currClass)
{
(*classes)[currClass].fan_in.insert(s);
(*classes)[s].fan_out.insert(currClass);
}
}
if(const auto *access = Result.Nodes.getNodeAs<MemberExpr>("member_access"))
{
/* Check if member is from CXXClass (it can also be from enum or union) */
if(access->getMemberDecl()->isCXXClassMember())
{
const FieldDecl *d = llvm::dyn_cast<FieldDecl>(access->getMemberDecl());
if(d)
{
std::string parent_name = d->getParent()->getQualifiedNameAsString();
/* Get id of the class that the member belongs to, check its this class id */
if(parent_name == currClass)
{
instance_vars.insert(d->getNameAsString());
}
}
}
}
}
void ClassOverviewVisitor::CalculateLorKiddMetrics(clang::CXXRecordDecl *decl)
{
auto name = decl->getQualifiedNameAsString();
for(const auto &m : decl->methods())
{
if(!m->isDefaulted())
{
classes[name].methods_count += 1;
classes[name].public_methods_count += m->getAccess() == clang::AccessSpecifier::AS_public;
classes[name].overriden_methods_count += !m->overridden_methods().empty();
}
}
for(const auto &d: decl->fields())
{
if(d->isCXXInstanceMember())
{
classes[name].public_instance_vars_count += d->getAccess() == clang::AccessSpecifier::AS_public;
classes[name].instance_vars_count += 1;
}
}
}
void ClassOverviewVisitor::CalcMetrics(clang::ASTContext *ctx)
{
this->ctx = ctx;
TraverseDecl(ctx->getTranslationUnitDecl());
this->ctx = nullptr;
}
std::ostream &ClassOverviewVisitor::Export(const std::string &s, std::ostream &os) const
{
const auto& c = classes.at(s);
os << "Size:\n"
<< " Number of methods: " << c.methods_count << ", " << c.public_methods_count << " are public.\n"
<< " Number of attributes: " << c.instance_vars_count << ", " << c.public_instance_vars_count << " are public.\n"
<< "\n"
<< "Inheritance:\n"
<< " Number of children: " << c.children_count << "\n"
<< " Longest inheritance chain length: " << GetInheritanceChainLen(s) << "\n"
<< " Overriden methods: " << c.overriden_methods_count << "\n"
<< "Other:\n"
<< " fan in: " << c.fan_in.size() << "\n"
<< " fan out: " << c.fan_out.size() << "\n"
<< " Lack of cohesion: " << LackOfCohesion(s) << "\n";
return os;
}
template <typename T>
size_t UnionSize(const std::set<T> &s1, const std::set<T> s2)
{
std::vector<T> res;
std::set_union(s1.begin(), s1.end(), s2.begin(), s2.end(), std::back_inserter(res));
return res.size();
}
std::ostream &ClassOverviewVisitor::ExportXML(const std::string &s, std::ostream &os) const
{
const auto& c = classes.at(s);
os << Tag("size",
"\n"
+ Tag("methods", c.methods_count)
+ Tag("public_methods", c.public_methods_count)
+ Tag("attributes", c.instance_vars_count)
+ Tag("public_attributes", c.public_instance_vars_count))
<< Tag("inheritance",
"\n"
+ Tag("children", c.children_count)
+ Tag("inheritance_chain", GetInheritanceChainLen(s))
+ Tag("overriden_methods", c.overriden_methods_count))
<< Tag("other",
"\n"
+ Tag("fan_in", c.fan_in.size())
+ Tag("fan_out", c.fan_out.size())
+ Tag("coupling", UnionSize(c.fan_in, c.fan_out))
+ Tag("lack_of_cohesion", LackOfCohesion(s)));
return os;
}
bool ClassOverviewVisitor::TraverseDecl(clang::Decl *decl)
{
/* Skip files that are in system files */
if(!decl || ctx->getSourceManager().isInSystemHeader(decl->getLocation()))
return true;
return RecursiveASTVisitor::TraverseDecl(decl);
}
| 37.97
| 151
| 0.613642
|
Gregofi
|
d473b02889735c9d1c07fce5cd2f55f0a3572637
| 13,568
|
cpp
|
C++
|
src/Core/Unicode.cpp
|
akumetsuv/flood
|
e0d6647df9b7fac72443a0f65c0003b0ead7ed3a
|
[
"BSD-2-Clause"
] | null | null | null |
src/Core/Unicode.cpp
|
akumetsuv/flood
|
e0d6647df9b7fac72443a0f65c0003b0ead7ed3a
|
[
"BSD-2-Clause"
] | null | null | null |
src/Core/Unicode.cpp
|
akumetsuv/flood
|
e0d6647df9b7fac72443a0f65c0003b0ead7ed3a
|
[
"BSD-2-Clause"
] | 1
|
2021-05-23T16:33:11.000Z
|
2021-05-23T16:33:11.000Z
|
/* ================================================================ */
/*
File: ConvertUTF.C
Author: Mark E. Davis
Copyright (C) 1994 Taligent, Inc. All rights reserved.
This code is copyrighted. Under the copyright laws, this code may not
be copied, in whole or part, without prior written consent of Taligent.
Taligent grants the right to use or reprint this code as long as this
ENTIRE copyright notice is reproduced in the code or reproduction.
The code is provided AS-IS, AND TALIGENT DISCLAIMS ALL WARRANTIES,
EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN
NO EVENT WILL TALIGENT BE LIABLE FOR ANY DAMAGES WHATSOEVER (INCLUDING,
WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS
INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY
LOSS) ARISING OUT OF THE USE OR INABILITY TO USE THIS CODE, EVEN
IF TALIGENT HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
BECAUSE SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF
LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES, THE ABOVE
LIMITATION MAY NOT APPLY TO YOU.
RESTRICTED RIGHTS LEGEND: Use, duplication, or disclosure by the
government is subject to restrictions as set forth in subparagraph
(c)(l)(ii) of the Rights in Technical Data and Computer Software
clause at DFARS 252.227-7013 and FAR 52.227-19.
This code may be protected by one or more U.S. and International
Patents.
TRADEMARKS: Taligent and the Taligent Design Mark are registered
trademarks of Taligent, Inc.
*/
/* ================================================================ */
#include "Core/API.h"
#include "Core/Unicode.h"
#ifdef COMPILER_MSVC
#pragma warning(disable: 4244)
#endif
/* ================================================================ */
static const int halfShift = 10;
static const UCS4 halfBase = 0x0010000UL;
static const UCS4 halfMask = 0x3FFUL;
static const UCS4 kSurrogateHighStart = 0xD800UL;
static const UCS4 kSurrogateHighEnd = 0xDBFFUL;
static const UCS4 kSurrogateLowStart = 0xDC00UL;
static const UCS4 kSurrogateLowEnd = 0xDFFFUL;
/* ================================================================ */
UnicodeConversionResult::Enum
ConvertUCS4toUTF16(UCS4** sourceStart, const UCS4* sourceEnd,
UTF16** targetStart, const UTF16* targetEnd)
{
UnicodeConversionResult::Enum result = UnicodeConversionResult::OK;
register UCS4* source = *sourceStart;
register UTF16* target = *targetStart;
while (source < sourceEnd) {
register UCS4 ch;
if (target >= targetEnd) {
result = UnicodeConversionResult::TargetExhausted; break;
};
ch = *source++;
if (ch <= kMaximumUCS2) {
*target++ = ch;
} else if (ch > kMaximumUTF16) {
*target++ = kReplacementCharacter;
} else {
if (target + 1 >= targetEnd) {
result = UnicodeConversionResult::TargetExhausted; break;
};
ch -= halfBase;
*target++ = (ch >> halfShift) + kSurrogateHighStart;
*target++ = (ch & halfMask) + kSurrogateLowStart;
};
};
*sourceStart = source;
*targetStart = target;
return result;
};
/* ================================================================ */
UnicodeConversionResult::Enum ConvertUTF16toUCS4(UTF16** sourceStart, UTF16* sourceEnd,
UCS4** targetStart, const UCS4* targetEnd)
{
UnicodeConversionResult::Enum result = UnicodeConversionResult::OK;
register UTF16* source = *sourceStart;
register UCS4* target = *targetStart;
while (source < sourceEnd) {
register UCS4 ch;
ch = *source++;
if (ch >= kSurrogateHighStart &&
ch <= kSurrogateHighEnd &&
source < sourceEnd) {
register UCS4 ch2 = *source;
if (ch2 >= kSurrogateLowStart && ch2 <= kSurrogateLowEnd) {
ch = ((ch - kSurrogateHighStart) << halfShift)
+ (ch2 - kSurrogateLowStart) + halfBase;
++source;
};
};
if (target >= targetEnd) {
result = UnicodeConversionResult::TargetExhausted; break;
};
*target++ = ch;
};
*sourceStart = source;
*targetStart = target;
return result;
};
/* ================================================================ */
static UCS4 offsetsFromUTF8[6] = {
0x00000000UL, 0x00003080UL, 0x000E2080UL,
0x03C82080UL, 0xFA082080UL, 0x82082080UL
};
static char bytesFromUTF8[256] = {
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, 3,3,3,3,3,3,3,3,4,4,4,4,5,5,5,5
};
static UTF8 firstByteMark[7] = {0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC};
/* ================================================================ */
/* This code is similar in effect to making successive calls on the
mbtowc and wctomb routines in FSS-UTF. However, it is considerably
different in code:
* it is adapted to be consistent with UTF16,
* the interface converts a whole buffer to avoid function-call overhead
* constants have been gathered.
* loops & conditionals have been removed as much as possible for
efficiency, in favor of drop-through switch statements.
*/
/* ================================================================ */
int NSConvertUTF16toUTF8(unichar **sourceStart,
const unichar *sourceEnd,
unsigned char **targetStart,
const unsigned char *targetEnd)
{
UnicodeConversionResult::Enum result = UnicodeConversionResult::OK;
register UTF16* source = *sourceStart;
register UTF8* target = *targetStart;
while (source < sourceEnd) {
register UCS4 ch;
register unsigned short bytesToWrite = 0;
register const UCS4 byteMask = 0xBF;
register const UCS4 byteMark = 0x80;
ch = *source++;
if (ch >= kSurrogateHighStart && ch <= kSurrogateHighEnd
&& source < sourceEnd) {
register UCS4 ch2 = *source;
if (ch2 >= kSurrogateLowStart && ch2 <= kSurrogateLowEnd) {
ch = ((ch - kSurrogateHighStart) << halfShift)
+ (ch2 - kSurrogateLowStart) + halfBase;
++source;
};
};
if (ch < 0x80) { bytesToWrite = 1;
} else if (ch < 0x800) { bytesToWrite = 2;
} else if (ch < 0x10000) { bytesToWrite = 3;
} else if (ch < 0x200000) { bytesToWrite = 4;
} else if (ch < 0x4000000) { bytesToWrite = 5;
} else if (ch <= kMaximumUCS4){ bytesToWrite = 6;
} else { bytesToWrite = 2;
ch = kReplacementCharacter;
}; /* I wish there were a smart way to avoid this conditional */
target += bytesToWrite;
if (target > targetEnd) {
target -= bytesToWrite; result = UnicodeConversionResult::TargetExhausted; break;
};
switch (bytesToWrite) { /* note: code falls through cases! */
case 6: *--target = (ch | byteMark) & byteMask; ch >>= 6;
case 5: *--target = (ch | byteMark) & byteMask; ch >>= 6;
case 4: *--target = (ch | byteMark) & byteMask; ch >>= 6;
case 3: *--target = (ch | byteMark) & byteMask; ch >>= 6;
case 2: *--target = (ch | byteMark) & byteMask; ch >>= 6;
case 1: *--target = ch | firstByteMark[bytesToWrite];
};
target += bytesToWrite;
};
*sourceStart = source;
*targetStart = target;
return result;
};
/* ================================================================ */
int NSConvertUTF8toUTF16(unsigned char **sourceStart, unsigned char *sourceEnd,
unichar **targetStart, const unichar *targetEnd)
{
UnicodeConversionResult::Enum result = UnicodeConversionResult::OK;
register UTF8 *source = *sourceStart;
register UTF16 *target = *targetStart;
while (source < sourceEnd) {
register UCS4 ch = 0;
register unsigned short extraBytesToWrite = bytesFromUTF8[*source];
if (source + extraBytesToWrite > sourceEnd) {
result = UnicodeConversionResult::SourceExhausted; break;
};
switch(extraBytesToWrite) { /* note: code falls through cases! */
case 5: ch += *source++; ch <<= 6;
case 4: ch += *source++; ch <<= 6;
case 3: ch += *source++; ch <<= 6;
case 2: ch += *source++; ch <<= 6;
case 1: ch += *source++; ch <<= 6;
case 0: ch += *source++;
};
ch -= offsetsFromUTF8[extraBytesToWrite];
if (target >= targetEnd) {
result = UnicodeConversionResult::TargetExhausted; break;
};
if (ch <= kMaximumUCS2) {
*target++ = ch;
} else if (ch > kMaximumUTF16) {
*target++ = kReplacementCharacter;
} else {
if (target + 1 >= targetEnd) {
result = UnicodeConversionResult::TargetExhausted; break;
};
ch -= halfBase;
*target++ = (ch >> halfShift) + kSurrogateHighStart;
*target++ = (ch & halfMask) + kSurrogateLowStart;
};
};
*sourceStart = source;
*targetStart = target;
return result;
};
/* ================================================================ */
UnicodeConversionResult::Enum ConvertUCS4toUTF8 ( UCS4** sourceStart, const UCS4* sourceEnd,
UTF8** targetStart, const UTF8* targetEnd)
{
UnicodeConversionResult::Enum result = UnicodeConversionResult::OK;
register UCS4* source = *sourceStart;
register UTF8* target = *targetStart;
while (source < sourceEnd) {
register UCS4 ch;
register unsigned short bytesToWrite = 0;
register const UCS4 byteMask = 0xBF;
register const UCS4 byteMark = 0x80;
ch = *source++;
if (ch >= kSurrogateHighStart && ch <= kSurrogateHighEnd
&& source < sourceEnd) {
register UCS4 ch2 = *source;
if (ch2 >= kSurrogateLowStart && ch2 <= kSurrogateLowEnd) {
ch = ((ch - kSurrogateHighStart) << halfShift)
+ (ch2 - kSurrogateLowStart) + halfBase;
++source;
};
};
if (ch < 0x80) { bytesToWrite = 1;
} else if (ch < 0x800) { bytesToWrite = 2;
} else if (ch < 0x10000) { bytesToWrite = 3;
} else if (ch < 0x200000) { bytesToWrite = 4;
} else if (ch < 0x4000000) { bytesToWrite = 5;
} else if (ch <= kMaximumUCS4){ bytesToWrite = 6;
} else { bytesToWrite = 2;
ch = kReplacementCharacter;
}; /* I wish there were a smart way to avoid this conditional */
target += bytesToWrite;
if (target > targetEnd) {
target -= bytesToWrite; result = UnicodeConversionResult::TargetExhausted; break;
};
switch (bytesToWrite) { /* note: code falls through cases! */
case 6: *--target = (ch | byteMark) & byteMask; ch >>= 6;
case 5: *--target = (ch | byteMark) & byteMask; ch >>= 6;
case 4: *--target = (ch | byteMark) & byteMask; ch >>= 6;
case 3: *--target = (ch | byteMark) & byteMask; ch >>= 6;
case 2: *--target = (ch | byteMark) & byteMask; ch >>= 6;
case 1: *--target = ch | firstByteMark[bytesToWrite];
};
target += bytesToWrite;
};
*sourceStart = source;
*targetStart = target;
return result;
};
/* ================================================================ */
UnicodeConversionResult::Enum ConvertUTF8toUCS4 (UTF8** sourceStart, UTF8* sourceEnd,
UCS4** targetStart, const UCS4* targetEnd)
{
UnicodeConversionResult::Enum result = UnicodeConversionResult::OK;
register UTF8* source = *sourceStart;
register UCS4* target = *targetStart;
while (source < sourceEnd) {
register UCS4 ch = 0;
register unsigned short extraBytesToWrite = bytesFromUTF8[*source];
if (source + extraBytesToWrite > sourceEnd) {
result = UnicodeConversionResult::SourceExhausted; break;
};
switch(extraBytesToWrite) { /* note: code falls through cases! */
case 5: ch += *source++; ch <<= 6;
case 4: ch += *source++; ch <<= 6;
case 3: ch += *source++; ch <<= 6;
case 2: ch += *source++; ch <<= 6;
case 1: ch += *source++; ch <<= 6;
case 0: ch += *source++;
};
ch -= offsetsFromUTF8[extraBytesToWrite];
if (target >= targetEnd) {
result = UnicodeConversionResult::TargetExhausted; break;
};
if (ch <= kMaximumUCS2) {
*target++ = ch;
} else if (ch > kMaximumUCS4) {
*target++ = kReplacementCharacter;
} else {
if (target + 1 >= targetEnd) {
result = UnicodeConversionResult::TargetExhausted; break;
};
ch -= halfBase;
*target++ = (ch >> halfShift) + kSurrogateHighStart;
*target++ = (ch & halfMask) + kSurrogateLowStart;
};
};
*sourceStart = source;
*targetStart = target;
return result;
};
| 39.327536
| 94
| 0.568028
|
akumetsuv
|
d473bb37ac3a542f4099d8a3968beb3cc1f8dca6
| 552
|
cpp
|
C++
|
BAC_2nd/ch10/UVa12716.cpp
|
Anyrainel/aoapc-code
|
e787a01380698fb9236d933462052f97b20e6132
|
[
"Apache-2.0"
] | 3
|
2017-08-15T06:00:01.000Z
|
2018-12-10T09:05:53.000Z
|
BAC_2nd/ch10/UVa12716.cpp
|
Anyrainel/aoapc-related-code
|
e787a01380698fb9236d933462052f97b20e6132
|
[
"Apache-2.0"
] | null | null | null |
BAC_2nd/ch10/UVa12716.cpp
|
Anyrainel/aoapc-related-code
|
e787a01380698fb9236d933462052f97b20e6132
|
[
"Apache-2.0"
] | 2
|
2017-09-16T18:46:27.000Z
|
2018-05-22T05:42:03.000Z
|
// UVa12716 GCD XOR
// Rujia Liu
#include<cstdio>
#include<cstring>
using namespace std;
const int M = 30000000;
int cnt[M+1], sum[M+1];
void init() {
memset(cnt, 0, sizeof(cnt));
for(int c = 1; c <= M; c++)
for(int a = c*2; a <= M; a += c) {
int b = a - c;
if(c == (a ^ b)) cnt[a]++;
}
sum[0] = 0;
for(int i = 1; i <= M; i++) sum[i] = sum[i-1] + cnt[i];
}
int main() {
init();
int T, n, kase = 0;
scanf("%d", &T);
while(T--) {
scanf("%d", &n);
printf("Case %d: %d\n", ++kase, sum[n]);
}
return 0;
}
| 17.25
| 57
| 0.471014
|
Anyrainel
|
d47b9c18a4ec755d80009918d43ad3a5a0a0627c
| 902
|
cpp
|
C++
|
rw_rh_engine_lib/rw_engine/rw_api_injectors.cpp
|
petrgeorgievsky/gtaRenderHook
|
124358410c3edca56de26381e239ca29aa6dc1cc
|
[
"MIT"
] | 232
|
2016-08-29T00:33:32.000Z
|
2022-03-29T22:39:51.000Z
|
rw_rh_engine_lib/rw_engine/rw_api_injectors.cpp
|
petrgeorgievsky/gtaRenderHook
|
124358410c3edca56de26381e239ca29aa6dc1cc
|
[
"MIT"
] | 10
|
2021-01-02T12:40:49.000Z
|
2021-08-31T06:31:04.000Z
|
rw_rh_engine_lib/rw_engine/rw_api_injectors.cpp
|
petrgeorgievsky/gtaRenderHook
|
124358410c3edca56de26381e239ca29aa6dc1cc
|
[
"MIT"
] | 40
|
2017-12-18T06:14:39.000Z
|
2022-01-29T16:35:23.000Z
|
#include "rw_api_injectors.h"
#include "common_headers.h"
#include "rw_raster/rw_raster.h"
#include "rw_stream/rw_stream.h"
#include "rw_texture/rw_texture.h"
namespace rh::rw::engine
{
RwTexture *RwTextureSetNameStub( RwTexture *texture, const char *name )
{
strncpy_s( texture->name, name, strlen( name ) );
return texture;
}
RwTexture *RwTextureSetMaskStub( RwTexture *texture, const char *name )
{
strncpy_s( texture->mask, name, strlen( name ) );
return texture;
}
RwTexturePointerTable g_pTexture_API = { RwTextureCreate, RwTextureSetNameStub,
RwTextureSetMaskStub };
RwIOPointerTable g_pIO_API = { RwStreamFindChunk, RwStreamRead };
RwRasterPointerTable g_pRaster_API = {
reinterpret_cast<RwRasterCreate_FN>( RwRasterCreate ),
reinterpret_cast<RwRasterDestroy_FN>( RwRasterDestroy ) };
} // namespace rh::rw::engine
| 31.103448
| 79
| 0.717295
|
petrgeorgievsky
|
d47c4fdd486eec7ba372d2a56ae0b434fac6d0ba
| 52,350
|
cpp
|
C++
|
lib/KSpace/KSpaceSolverElastic.cpp
|
xschrodingerscat/kspaceFirstOrder
|
99f326d420a5488693bcf9fdd633d2eff7447cca
|
[
"RSA-MD"
] | null | null | null |
lib/KSpace/KSpaceSolverElastic.cpp
|
xschrodingerscat/kspaceFirstOrder
|
99f326d420a5488693bcf9fdd633d2eff7447cca
|
[
"RSA-MD"
] | null | null | null |
lib/KSpace/KSpaceSolverElastic.cpp
|
xschrodingerscat/kspaceFirstOrder
|
99f326d420a5488693bcf9fdd633d2eff7447cca
|
[
"RSA-MD"
] | null | null | null |
#include <KSpace/KSpaceSolver.h>
#include <KSpace/KInterp.h>
using std::ios;
/* Shortcut for Simulation dimensions. */
using SD = Parameters::SimulationDimension;
/* Shortcut for Matrix id in the container. */
using MI = MatrixContainer::MatrixIdx;
/* Shortcut for Output stream id in the container. */
using OI = OutputStreamContainer::OutputStreamIdx;
KSpaceSolverElastic::ComputeElasticImp KSpaceSolverElastic::sComputeElasticImp
{
/*2D cases: SD rho0 bOnA c0 s0 alpha */
{
std::make_tuple(SD::k2D, false, false, false, false, false),
&KSpaceSolverElastic::computeElastic<SD::k2D,
false, false, false, false, false>
}
};
void
KSpaceSolverElastic::allocateMemory()
{
// Add matrices into the container and create all matrices
mMatrixContainer.init();
mMatrixContainer.createMatrices();
// Add output streams into container
mOutputStreamContainer.init(mMatrixContainer);
}
void
KSpaceSolverElastic::loadInputData()
{
// Load data from the input file
mMatrixContainer.loadDataFromKConfig();
Hdf5File &outputFile = mParameters.getOutputFile();
auto &koutput = mParameters.getKOutput();
auto filename = koutput.getOutputFileName();
if (koutput.isOutputToFileFlag() && !outputFile.canAccess(filename))
outputFile.create(filename);
mOutputStreamContainer.createStreams();
}
void
KSpaceSolverElastic::compute()
{
/* Initialize all used FFTW plans */
initializeFftwPlans();
preProcessing<SD::k2D>();
#if 0
std::cout << mParameters.getRho0ScalarFlag() << std::endl;
std::cout << mParameters.getBOnAScalarFlag() << std::endl;
std::cout << mParameters.getC0ScalarFlag() << std::endl;
std::cout << mParameters.getS0ScalarFlag() << std::endl;
std::cout << mParameters.getAlphaPower() << std::endl;
#endif
sComputeElasticImp[std::make_tuple(
mParameters.getSimulationDimension(),
mParameters.getRho0ScalarFlag(),
mParameters.getBOnAScalarFlag(),
mParameters.getC0ScalarFlag(),
mParameters.getS0ScalarFlag(),
mParameters.getAlphaCoeffScalarFlag())]
(*this);
/* Post processing phase */
// mPostProcessingTime.start();
postProcessing();
}
template <Parameters::SimulationDimension simulationDimension,
bool rho0ScalarFlag,
bool bOnAScalarFlag,
bool c0ScalarFlag,
bool s0ScalarFlag,
bool alphaCoefScalarFlag>
void
KSpaceSolverElastic::computeElastic()
{
auto ¶ms = mParameters;
mActPercent = 0;
// Set the actual progress percentage to correspond the time index
// after recovery
if (params.getTimeIndex() > 0)
mActPercent = (100 * params.getTimeIndex()) / params.getNt();
// Progress header
Logger::log(Logger::LogLevel::kBasic, kOutFmtSimulationHeader);
mIterationTime.start();
params.setTimeIndex(0);
// Execute main loop
while (params.getTimeIndex() < params.getNt()
&& !params.isTimeToCheckpoint(mTotalTime)) {
const size_t timeIndex = params.getTimeIndex();
computePressureGradient<simulationDimension>();
computeSplitVelocity<simulationDimension>();
computeVelocity<simulationDimension>();
// Compute gradient of velocity
computeVelocityGradient<simulationDimension>();
computeSplitPressure<simulationDimension>();
// Calculate initial pressure
if ((timeIndex <= 1) && (mParameters.getInitialPressureSourceFlag() == 1))
addInitialPressureSource<simulationDimension, rho0ScalarFlag,
c0ScalarFlag, s0ScalarFlag>();
// Compute new pressure
computePressure<simulationDimension,
rho0ScalarFlag,
bOnAScalarFlag,
c0ScalarFlag,
s0ScalarFlag,
alphaCoefScalarFlag>();
storeSensorData();
printStatistics();
mParameters.incrementTimeIndex();
} // Time loop
}
template <Parameters::SimulationDimension simulationDimension>
void
KSpaceSolverElastic::preProcessing()
{
// Get the correct sensor mask and recompute indices
auto ¶ms = mParameters;
// smooth
smooth<SD::k2D>(MI::kInitialPressureSourceInput, true);
smooth<SD::k2D>(MI::kRho0, false);
smooth<SD::k2D>(MI::kDtRho0Sgx, false);
smooth<SD::k2D>(MI::kDtRho0Sgy, false);
// smooth<SD::k2D>(MI::kC2, false);
// smooth<SD::k2D>(MI::kS2, false);
#ifndef __KSPACE_DEBUG__
const size_t nElements = mParameters.getFullDimensionSizes().nElements();
double *dtRho0Sgx = getRealData(MI::kDtRho0Sgx);
double *rho0 = getRealData(MI::kRho0);
double dtRho0Sgx_norm = 0;
double rho0_norm = 0;
for (size_t i = 0; i < nElements; ++ i)
{
dtRho0Sgx_norm += std::abs(dtRho0Sgx[i]);
rho0_norm += std::abs(rho0[i]);
}
std::cout << "dtRho0Sgx_norm = " << dtRho0Sgx_norm << std::endl;
std::cout << "rho0_norm = " << rho0_norm << std::endl;
#endif
if (params.getSensorMaskType() == Parameters::SensorMaskType::kIndex)
getIndexMatrix(MI::kSensorMaskIndex).recomputeIndicesToCPP();
if (!params.getRho0ScalarFlag()) {
getRealMatrix(MI::kDtRho0Sgx).scalarDividedBy(params.getDt());
getRealMatrix(MI::kDtRho0Sgy).scalarDividedBy(params.getDt());
}
// Generate shift variables
generateDerivativeOperators();
// Generate absorption variables and kappa
switch (mParameters.getAbsorbingFlag()) {
case Parameters::AbsorptionType::kLossless:
generateKappa();
break;
default:
assert(false);
}
// Generate PML
generatePml();
generateLameConstant();
}
void
KSpaceSolverElastic::generateDerivativeOperators()
{
const DimensionSizes &dimensionSizes =
mParameters.getFullDimensionSizes();
const DimensionSizes &reducedDimensionSizes =
mParameters.getReducedDimensionSizes();
constexpr FloatComplex imagUnit = FloatComplex(0, 1);
constexpr FloatComplex posExp = FloatComplex(0, 1);
constexpr FloatComplex negExp = FloatComplex(0, -1);
constexpr double pi2 = 2.0f * double(M_PI);
const double dx = mParameters.getDx();
const double dy = mParameters.getDy();
FloatComplex *ddxKShiftPos = getComplexData(MI::kDdxKShiftPosR);
FloatComplex *ddyKShiftPos = getComplexData(MI::kDdyKShiftPos);
FloatComplex *ddxKShiftNeg = getComplexData(MI::kDdxKShiftNegR);
FloatComplex *ddyKShiftNeg = getComplexData(MI::kDdyKShiftNeg);
// Calculate ifft shift
auto iFftShift = [](ptrdiff_t i, ptrdiff_t size)
{
return (i + (size / 2)) % size - (size / 2);
};// end of iFftShift
for (size_t i = 0; i < reducedDimensionSizes.nx; i++) {
const ptrdiff_t shift = iFftShift(i, dimensionSizes.nx);
const double kx = (pi2 / dx) * (double(shift)
/ double(dimensionSizes.nx));
const double exponent = kx * dx * 0.5f;
ddxKShiftPos[i] = imagUnit * kx * std::exp(posExp * exponent);
ddxKShiftNeg[i] = imagUnit * kx * std::exp(negExp * exponent);
}
// ddyKShiftPos, ddyKShiftPos
for (size_t i = 0; i < dimensionSizes.ny; i++) {
const ptrdiff_t shift = iFftShift(i, dimensionSizes.ny);
const double ky = (pi2 / dy) * (double(shift)
/ double(dimensionSizes.ny));
const double exponent = ky * dy * 0.5f;
ddyKShiftPos[i] = imagUnit * ky * std::exp(posExp * exponent);
ddyKShiftNeg[i] = imagUnit * ky * std::exp(negExp * exponent);
}
}
template <Parameters::SimulationDimension simulationDimension,
bool rho0ScalarFlag,
bool c0ScalarFlag,
bool s0ScalarFlag>
void
KSpaceSolverElastic::addInitialPressureSource()
{
const size_t nElements = mParameters.getFullDimensionSizes().nElements();
const DimensionSizes &dimensionSizes = mParameters.getFullDimensionSizes();
double *p0 = getRealData(MI::kInitialPressureSourceInput);
double *tmp1 = getRealData(MI::kSxxSplitX);
double *tmp2 = getRealData(MI::kSxxSplitY);
double *tmp3 = getRealData(MI::kSyySplitX);
double *tmp4 = getRealData(MI::kSyySplitY);
assert(dimensionSizes.is2D());
double N = 2.0;
for (size_t i = 0; i < nElements; i++) {
auto delta = -p0[i] / 2. / N;
tmp1[i] += delta;
tmp2[i] += delta;
tmp3[i] += delta;
tmp4[i] += delta;
}
#if 0
double* sxxSplitX = getRealData(MI::kSxxSplitX);
double* sxxSplitY = getRealData(MI::kSxxSplitY);
double* syySplitX = getRealData(MI::kSyySplitX);
double* syySplitY = getRealData(MI::kSyySplitY);
double* pmat = getRealData(MI::kSxxSplitY);
#endif
}
template <Parameters::SimulationDimension simulationDimension,
bool rho0ScalarFlag,
bool bOnAScalarFlag,
bool c0ScalarFlag,
bool s0ScalarFlag,
bool alphaCoefScalarFlag>
void
KSpaceSolverElastic::computePressure()
{
const auto &fullDimSizes = mParameters.getFullDimensionSizes();
double *p = getRealData(MI::kP);
const double *sxxSplitX = getRealData(MI::kSxxSplitX);
const double *sxxSplitY = getRealData(MI::kSxxSplitY);
const double *syySplitX = getRealData(MI::kSyySplitX);
const double *syySplitY = getRealData(MI::kSyySplitY);
/*
p = -(sxx_split_x + sxx_split_y + syy_split_x + syy_split_y) / 2;
*/
for (size_t i = 0; i < fullDimSizes.nElements(); ++i) {
p[i] = -(sxxSplitX[i] + sxxSplitY[i] + syySplitX[i] + syySplitY[i]) / 2;
}
#ifdef __KSPACE_DEBUG__
double p_norm = 0.0;
for (size_t i = 0; i < fullDimSizes.nElements(); ++i) {
p_norm += std::abs(p[i]);
}
std::cout << "p_norm = " << p_norm << std::endl;
#endif
}
template <Parameters::SimulationDimension simulationDimension>
void
KSpaceSolverElastic::computePressureGradient()
{
const auto ¶ms = mParameters;
const auto &fullDimSizes = params.getFullDimensionSizes();
const FloatComplex *ddxKShiftPos = getComplexData(MI::kDdxKShiftPosR);
const FloatComplex *ddyKShiftPos = getComplexData(MI::kDdyKShiftPos);
const FloatComplex *ddxKShiftNeg = getComplexData(MI::kDdxKShiftNegR);
const FloatComplex *ddyKShiftNeg = getComplexData(MI::kDdyKShiftNeg);
double *tmpReal1 = getRealData(MI::kTmpReal1);
double *tmpReal2 = getRealData(MI::kTmpReal2);
double *tmpReal3 = getRealData(MI::kTmpReal3);
double *tmpReal4 = getRealData(MI::kTmpReal4);
FloatComplex *ifftXXdx = getComplexData(MI::kTmpFftwXXdx);
FloatComplex *ifftYYdy = getComplexData(MI::kTmpFftwYYdy);
FloatComplex *ifftXYdx = getComplexData(MI::kTmpFftwXYdx);
FloatComplex *ifftXYdy = getComplexData(MI::kTmpFftwXYdy);
const double *sxxSplitX = getRealData(MI::kSxxSplitX);
const double *sxxSplitY = getRealData(MI::kSxxSplitY);
const double *syySplitX = getRealData(MI::kSyySplitX);
const double *syySplitY = getRealData(MI::kSyySplitY);
const double *sxySplitX = getRealData(MI::kSxySplitX);
const double *sxySPlitY = getRealData(MI::kSxySplitY);
auto nx = params.getFullDimensionSizes().nx;
auto ny = params.getFullDimensionSizes().ny;
const double dividerX = 1.0f / static_cast<double>(nx);
const double dividerY = 1.0f / static_cast<double>(ny);
/*
dsxxdx = real( ifft( bsxfun(@times, ddx_k_shift_pos,
fft(sxx_split_x + sxx_split_y, [], 1)), [], 1) );
dsyydy = real( ifft( bsxfun(@times, ddy_k_shift_pos,
fft(syy_split_x + syy_split_y, [], 2)), [], 2) );
dsxydx = real( ifft( bsxfun(@times, ddx_k_shift_neg,
fft(sxy_split_x + sxy_split_y, [], 1)), [], 1) );
dsxydy = real( ifft( bsxfun(@times, ddy_k_shift_neg,
fft(sxy_split_x + sxy_split_y, [], 2)), [], 2) );
*/
/* tmpRet = sxx_split_x + sxx_split_y */
for (size_t i = 0; i < fullDimSizes.nElements(); i++) {
tmpReal1[i] = sxxSplitX[i] + sxxSplitY[i];
tmpReal2[i] = syySplitX[i] + syySplitY[i];
tmpReal3[i] = sxySplitX[i] + sxySPlitY[i];
tmpReal4[i] = sxySplitX[i] + sxySPlitY[i];
}
/* tmpRet = fft(tmpRet, [], 1) */
getTempFftwXXdx().computeR2CFft1DX(getRealMatrix(MI::kTmpReal1));
getTempFftwYYdy().computeR2CFft1DY(getRealMatrix(MI::kTmpReal2));
getTempFftwXYdx().computeR2CFft1DX(getRealMatrix(MI::kTmpReal3));
getTempFftwXYdy().computeR2CFft1DY(getRealMatrix(MI::kTmpReal4));
/* tmpRet = bsxfun(@times, ddx_k_shift_pos, tmpRet) */
auto reducedDimXSizes = params.getReducedXDimensionSizes();
for (size_t z = 0; z < reducedDimXSizes.nz; z++) {
for (size_t y = 0; y < reducedDimXSizes.ny; y++) {
for (size_t x = 0; x < reducedDimXSizes.nx; x++) {
const size_t i = get1DIndex(z, y, x, reducedDimXSizes);
ifftXXdx[i] = ifftXXdx[i] * ddxKShiftPos[x] * dividerX;
ifftXYdx[i] = ifftXYdx[i] * ddxKShiftNeg[x] * dividerX;
}
}
}
auto reducedDimYSizes = params.getReducedYDimensionSizes();
for (size_t z = 0; z < reducedDimYSizes.nz; z++) {
for (size_t y = 0; y < reducedDimYSizes.ny; y++) {
for (size_t x = 0; x < reducedDimYSizes.nx; x++) {
const size_t i = get1DIndex(z, y, x, reducedDimYSizes);
ifftYYdy[i] = ifftYYdy[i] * ddyKShiftPos[y] * dividerY;
ifftXYdy[i] = ifftXYdy[i] * ddyKShiftNeg[y] * dividerY;
}
}
}
/* real(ifft(tmpRet)) */
getTempFftwXXdx().computeC2RFft1DX(getRealMatrix(MI::kDSxxdx));
getTempFftwYYdy().computeC2RFft1DY(getRealMatrix(MI::kDSyydy));
getTempFftwXYdx().computeC2RFft1DX(getRealMatrix(MI::kDSxydx));
getTempFftwXYdy().computeC2RFft1DY(getRealMatrix(MI::kDSxydy));
#ifdef __KSPACE_DEBUG__
auto pmat1 = getRealData(MI::kDSxxdx);
auto pmat2 = getRealData(MI::kDSyydy);
auto pmat3 = getRealData(MI::kDSxydx);
auto pmat4 = getRealData(MI::kDSxydy);
const size_t nElements = mParameters.getFullDimensionSizes().nElements();
double dSxxdx_norm = 0;
double dSyydy_norm = 0;
double dSxydx_norm = 0;
double dSxydy_norm = 0;
for (size_t i = 0; i < nElements; ++i) {
dSxxdx_norm += std::abs(pmat1[i]);
dSyydy_norm += std::abs(pmat2[i]);
dSxydx_norm += std::abs(pmat3[i]);
dSxydy_norm += std::abs(pmat4[i]);
}
std::cout << "dSxxdx_norm = " << dSxxdx_norm << std::endl;
std::cout << "dSyydy_norm = " << dSyydy_norm << std::endl;
std::cout << "dSxydx_norm = " << dSxydx_norm << std::endl;
std::cout << "dSxydy_norm = " << dSxydy_norm << std::endl;
#endif
}
template <Parameters::SimulationDimension simulationDimension>
void
KSpaceSolverElastic::computeSplitVelocity()
{
const auto &fullDimSizes = mParameters.getFullDimensionSizes();
double *dsXXdx = getRealData(MI::kDSxxdx);
double *dsYYdy = getRealData(MI::kDSyydy);
double *dsXYdx = getRealData(MI::kDSxydx);
double *dsXYdy = getRealData(MI::kDSxydy);
double *mPmlX = getRealData(MI::kMPmlX);
double *mPmlY = getRealData(MI::kMPmlY);
double *mPmlXSgx = getRealData(MI::kMPmlXSgx);
double *mPmlYSgy = getRealData(MI::kMPmlYSgy);
double *pmlX = getRealData(MI::kPmlX);
double *pmlY = getRealData(MI::kPmlY);
double *pmlXSgx = getRealData(MI::kPmlXSgx);
double *pmlYSgy = getRealData(MI::kPmlYSgy);
double *uxSplitX = getRealData(MI::kUxSplitX);
double *uxSplitY = getRealData(MI::kUxSplitY);
double *uySplitX = getRealData(MI::kUySplitX);
double *uySplitY = getRealData(MI::kUySplitY);
double *dtRho0Sgx = getRealData(MI::kDtRho0Sgx);
double *dtRho0Sgy = getRealData(MI::kDtRho0Sgy);
/*
ux_split_x = bsxfun(@times, mpml_y, ...
bsxfun(@times, pml_x_sgx, ...
bsxfun(@times, mpml_y, ...
bsxfun(@times, pml_x_sgx, ux_split_x) ...
) + kgrid.dt .* rho0_sgx_inv .* dsxxdx ...
) ...
);
ux_split_y = bsxfun(@times, mpml_x_sgx, bsxfun(@times, pml_y, ...
bsxfun(@times, mpml_x_sgx, bsxfun(@times, pml_y, ux_split_y)) ...
+ kgrid.dt .* rho0_sgx_inv .* dsxydy));
uy_split_x = bsxfun(@times, mpml_y_sgy, bsxfun(@times, pml_x, ...
bsxfun(@times, mpml_y_sgy, bsxfun(@times, pml_x, uy_split_x)) ...
+ kgrid.dt .* rho0_sgy_inv .* dsxydx));
uy_split_y = bsxfun(@times, mpml_x, bsxfun(@times, pml_y_sgy, ...
bsxfun(@times, mpml_x, bsxfun(@times, pml_y_sgy, uy_split_y)) ...
+ kgrid.dt .* rho0_sgy_inv .* dsyydy));
*/
for (size_t z = 0; z < fullDimSizes.nz; z++)
for (size_t y = 0; y < fullDimSizes.ny; y++)
for (size_t x = 0; x < fullDimSizes.nx; x++) {
const size_t i = get1DIndex(z, y, x, fullDimSizes);
auto coef = mPmlY[y] * pmlXSgx[x];
auto expr = coef * uxSplitX[i] + dtRho0Sgx[i] * dsXXdx[i];
uxSplitX[i] = coef * expr;
coef = mPmlXSgx[x] * pmlY[y];
expr = coef * uxSplitY[i] + dtRho0Sgx[i] * dsXYdy[i];
uxSplitY[i] = coef * expr;
coef = mPmlYSgy[y] * pmlX[x];
expr = coef * uySplitX[i] + dtRho0Sgy[i] * dsXYdx[i];
uySplitX[i] = coef * expr;
coef = mPmlX[x] * pmlYSgy[y];
expr = coef * uySplitY[i] + dtRho0Sgy[i] * dsYYdy[i];
uySplitY[i] = coef * expr;
}
#ifdef __KSPACE_DEBUG__
const size_t nElements = mParameters.getFullDimensionSizes().nElements();
double uxSplitX_norm = 0;
double uxSplitY_norm = 0;
double uySplitX_norm = 0;
double uySplitY_norm = 0;
double dtRho0Sgx_norm = 0;
for (size_t i = 0; i < nElements; ++i) {
uxSplitX_norm += std::abs(uxSplitX[i]);
uxSplitY_norm += std::abs(uxSplitY[i]);
uySplitX_norm += std::abs(uySplitX[i]);
uySplitY_norm += std::abs(uySplitY[i]);
dtRho0Sgx_norm += std::abs(dtRho0Sgx[i]);
}
std::cout << "uxSplitX_norm = " << uxSplitX_norm << std::endl;
std::cout << "uxSplitY_norm = " << uxSplitY_norm << std::endl;
std::cout << "uySplitX_norm = " << uySplitX_norm << std::endl;
std::cout << "uySplitY_norm = " << uySplitY_norm << std::endl;
std::cout << "dtRho0Sgx_norm = " << dtRho0Sgx_norm << std::endl;
#endif
}
template <Parameters::SimulationDimension simulationDimension>
void
KSpaceSolverElastic::computeVelocity()
{
const auto &fullDimSizes = mParameters.getFullDimensionSizes();
double *uxSplitX = getRealData(MI::kUxSplitX);
double *uxSplitY = getRealData(MI::kUxSplitY);
double *uySplitX = getRealData(MI::kUySplitX);
double *uySplitY = getRealData(MI::kUySplitY);
double *uxSgx = getRealData(MI::kUxSgx);
double *uySgy = getRealData(MI::kUySgy);
/* ux_sgx = ux_split_x + ux_split_y;
uy_sgy = uy_split_x + uy_split_y;
*/
for (size_t i = 0; i < fullDimSizes.nElements(); ++i) {
uxSgx[i] = uxSplitX[i] + uxSplitY[i];
uySgy[i] = uySplitX[i] + uySplitY[i];
}
#ifdef __KSPACE_DEBUG__
double uxSgx_norm = 0;
double uySgy_norm = 0;
for (size_t i = 0; i < fullDimSizes.nElements(); ++i) {
uxSgx_norm += std::abs(uxSgx[i]);
uySgy_norm += std::abs(uySgy[i]);
}
std::cout << "uxSgx_norm = " << uxSgx_norm << std::endl;
std::cout << "uySgy_norm = " << uySgy_norm << std::endl;
#endif
}
template <Parameters::SimulationDimension simulationDimension>
void
KSpaceSolverElastic::computeVelocityGradient()
{
const auto ¶ms = mParameters;
auto nx = params.getFullDimensionSizes().nx;
auto ny = params.getFullDimensionSizes().ny;
const double dividerX = 1.0f / static_cast<double>(nx);
const double dividerY = 1.0f / static_cast<double>(ny);
const FloatComplex *ddxKShiftPos = getComplexData(MI::kDdxKShiftPosR);
const FloatComplex *ddyKShiftPos = getComplexData(MI::kDdyKShiftPos);
const FloatComplex *ddxKShiftNeg = getComplexData(MI::kDdxKShiftNegR);
const FloatComplex *ddyKShiftNeg = getComplexData(MI::kDdyKShiftNeg);
FloatComplex *ifftXXdx = getComplexData(MI::kTmpFftwXXdx);
FloatComplex *ifftXXdy = getComplexData(MI::kTmpFftwXXdy);
FloatComplex *ifftYYdx = getComplexData(MI::kTmpFftwYYdx);
FloatComplex *ifftYYdy = getComplexData(MI::kTmpFftwYYdy);
/*
duxdx = real( ifft( bsxfun(@times, ddx_k_shift_neg,
fft(ux_sgx, [], 1)), [], 1));
duxdy = real( ifft( bsxfun(@times, ddy_k_shift_pos,
fft(ux_sgx, [], 2)), [], 2));
duydx = real( ifft( bsxfun(@times, ddx_k_shift_pos,
fft(uy_sgy, [], 1)), [], 1));
duydy = real( ifft( bsxfun(@times, ddy_k_shift_neg,
fft(uy_sgy, [], 2)), [], 2));
*/
getTempFftwXXdx().computeR2CFft1DX(getRealMatrix(MI::kUxSgx));
getTempFftwXXdy().computeR2CFft1DY(getRealMatrix(MI::kUxSgx));
getTempFftwYYdx().computeR2CFft1DX(getRealMatrix(MI::kUySgy));
getTempFftwYYdy().computeR2CFft1DY(getRealMatrix(MI::kUySgy));
auto reducedDimXSizes = params.getReducedXDimensionSizes();
for (size_t z = 0; z < reducedDimXSizes.nz; z++)
for (size_t y = 0; y < reducedDimXSizes.ny; y++)
for (size_t x = 0; x < reducedDimXSizes.nx; x++) {
const size_t i = get1DIndex(z, y, x, reducedDimXSizes);
ifftXXdx[i] *= ddxKShiftNeg[x] * dividerX;
ifftYYdx[i] *= ddxKShiftPos[x] * dividerX;
}
auto reducedDimYSizes = params.getReducedYDimensionSizes();
for (size_t z = 0; z < reducedDimYSizes.nz; z++)
for (size_t y = 0; y < reducedDimYSizes.ny; y++)
for (size_t x = 0; x < reducedDimYSizes.nx; x++) {
const size_t i = get1DIndex(z, y, x, reducedDimYSizes);
ifftXXdy[i] *= ddyKShiftPos[y] * dividerY;
ifftYYdy[i] *= ddyKShiftNeg[y] * dividerY;
}
getTempFftwXXdx().computeC2RFft1DX(getRealMatrix(MI::kDuxdx));
getTempFftwXXdy().computeC2RFft1DY(getRealMatrix(MI::kDuxdy));
getTempFftwYYdx().computeC2RFft1DX(getRealMatrix(MI::kDuydx));
getTempFftwYYdy().computeC2RFft1DY(getRealMatrix(MI::kDuydy));
#ifdef __KSPACE_DEBUG__
// double *duxdx = getRealData(MI::kDuxdx);
// double *duxdy = getRealData(MI::kDuxdy);
// double *duydx = getRealData(MI::kDuydx);
// double *duydy = getRealData(MI::kDuydy);
auto pmat1 = getRealData(MI::kDuxdx);
auto pmat2 = getRealData(MI::kDuydx);
auto pmat3 = getRealData(MI::kDuxdy);
auto pmat4 = getRealData(MI::kDuydy);
double duxdx_norm = 0;
double duydx_norm = 0;
double duxdy_norm = 0;
double duydy_norm = 0;
auto nElements = mParameters.getFullDimensionSizes().nElements();
for (size_t i = 0; i < nElements; ++i) {
duxdx_norm += std::abs(pmat1[i]);
duydx_norm += std::abs(pmat2[i]);
duxdy_norm += std::abs(pmat3[i]);
duydy_norm += std::abs(pmat4[i]);
}
std::cout << "duxdx_norm = " << duxdx_norm << std::endl;
std::cout << "duydx_norm = " << duydx_norm << std::endl;
std::cout << "duxdy_norm = " << duxdy_norm << std::endl;
std::cout << "duydy_norm = " << duydy_norm << std::endl;
#endif
}
template <Parameters::SimulationDimension simulationDimension>
void
KSpaceSolverElastic::computeSplitPressure()
{
const auto &fullDimSizes = mParameters.getFullDimensionSizes();
const double dt = mParameters.getDt();
double *mu = getRealData(MI::kMu);
double *lambda = getRealData(MI::kLambda);
double *musgxy = getRealData(MI::kMuSgxy);
double *sxxSplitX = getRealData(MI::kSxxSplitX);
double *sxxSplitY = getRealData(MI::kSxxSplitY);
double *syySplitX = getRealData(MI::kSyySplitX);
double *syySplitY = getRealData(MI::kSyySplitY);
double *sxySplitX = getRealData(MI::kSxySplitX);
double *sxySplitY = getRealData(MI::kSxySplitY);
double *mPmlX = getRealData(MI::kMPmlX);
double *mPmlY = getRealData(MI::kMPmlY);
double *mPmlXSgx = getRealData(MI::kMPmlXSgx);
double *mPmlYSgy = getRealData(MI::kMPmlYSgy);
double *pmlX = getRealData(MI::kPmlX);
double *pmlY = getRealData(MI::kPmlY);
double *pmlXSgx = getRealData(MI::kPmlXSgx);
double *pmlYSgy = getRealData(MI::kPmlYSgy);
double *duxdx = getRealData(MI::kDuxdx);
double *duxdy = getRealData(MI::kDuxdy);
double *duydx = getRealData(MI::kDuydx);
double *duydy = getRealData(MI::kDuydy);
/*
sxx_split_x = bsxfun(@times, mpml_y, ...
bsxfun(@times, pml_x, ...
bsxfun(@times, mpml_y, bsxfun(@times, pml_x, sxx_split_x)) ...
+ kgrid.dt .* (2 .* mu + lambda) .* duxdx ));
sxx_split_y = bsxfun(@times, mpml_x, bsxfun(@times, pml_y, ...
bsxfun(@times, mpml_x, bsxfun(@times, pml_y, sxx_split_y)) ...
+ kgrid.dt .* lambda .* duydy ));
syy_split_x = bsxfun(@times, mpml_y, bsxfun(@times, pml_x, ...
bsxfun(@times, mpml_y, bsxfun(@times, pml_x, syy_split_x)) ...
+ kgrid.dt .* lambda .* duxdx));
syy_split_y = bsxfun(@times, mpml_x, bsxfun(@times, pml_y, ...
bsxfun(@times, mpml_x, bsxfun(@times, pml_y, syy_split_y)) ...
+ kgrid.dt .* (2 .* mu + lambda) .* duydy ));
sxy_split_x = bsxfun(@times, mpml_y_sgy, bsxfun(@times, pml_x_sgx, ...
bsxfun(@times, mpml_y_sgy, bsxfun(@times, pml_x_sgx, sxy_split_x)) ...
+ kgrid.dt .* mu_sgxy .* duydx));
sxy_split_y = bsxfun(@times, mpml_x_sgx, bsxfun(@times, pml_y_sgy, ...
bsxfun(@times, mpml_x_sgx, bsxfun(@times, pml_y_sgy, sxy_split_y)) ...
+ kgrid.dt .* mu_sgxy .* duxdy));
*/
for (size_t z = 0; z < fullDimSizes.nz; z++)
for (size_t y = 0; y < fullDimSizes.ny; y++)
for (size_t x = 0; x < fullDimSizes.nx; x++) {
const size_t i = get1DIndex(z, y, x, fullDimSizes);
auto moduli = (2.f * mu[i] + lambda[i]);
auto coef = mPmlY[y] * pmlX[x];
auto expr = coef * sxxSplitX[i] + dt * moduli * duxdx[i];
sxxSplitX[i] = coef * expr;
coef = mPmlX[x] * pmlY[y];
expr = coef * sxxSplitY[i] + dt * lambda[i] * duydy[i];
sxxSplitY[i] = coef * expr;
coef = mPmlY[y] * pmlX[x];
expr = coef * syySplitX[i] + dt * lambda[i] * duxdx[i];
syySplitX[i] = coef * expr;
coef = mPmlX[x] * pmlY[y];
expr = coef * syySplitY[i] + dt * moduli * duydy[i];
syySplitY[i] = coef * expr;
coef = mPmlYSgy[y] * pmlXSgx[x];
expr = coef * sxySplitX[i] + dt * musgxy[i] * duydx[i];
sxySplitX[i] = coef * expr;
coef = mPmlXSgx[x] * pmlYSgy[y];
expr = coef * sxySplitY[i] + dt * musgxy[i] * duxdy[i];
sxySplitY[i] = coef * expr;
}
#ifdef __KSPACE_DEBUG__
double sxxSplitX_norm = 0;
double sxxSplitY_norm = 0;
double syySplitX_norm = 0;
double syySplitY_norm = 0;
double sxySplitX_norm = 0;
double sxySplitY_norm = 0;
for (size_t i = 0; i < fullDimSizes.nElements(); ++i)
{
sxxSplitX_norm += std::abs(sxxSplitX[i]);
sxxSplitY_norm += std::abs(sxxSplitY[i]);
syySplitX_norm += std::abs(syySplitX[i]);
syySplitY_norm += std::abs(syySplitY[i]);
sxySplitX_norm += std::abs(sxySplitX[i]);
sxySplitY_norm += std::abs(sxySplitY[i]);
}
std::cout << "sxxSplitX_norm = " << sxxSplitX_norm << std::endl;
std::cout << "sxxSplitY_norm = " << sxxSplitY_norm << std::endl;
std::cout << "syySplitX_norm = " << syySplitX_norm << std::endl;
std::cout << "syySplitY_norm = " << syySplitY_norm << std::endl;
std::cout << "sxySplitX_norm = " << sxySplitX_norm << std::endl;
std::cout << "sxySplitY_norm = " << sxySplitY_norm << std::endl;
#endif
}
void
KSpaceSolverElastic::generateLameConstant()
{
auto ¶ms = mParameters;
if (!params.getElasticFlag() || params.getC0ScalarFlag()
|| params.getS0ScalarFlag() || params.getRho0ScalarFlag())
return;
const size_t nElements = mParameters.getFullDimensionSizes().nElements();
auto c2 = getRealData(MI::kC2);
auto s2 = getRealData(MI::kS2);
auto rho0 = getRealData(MI::kRho0);
auto mu = getRealData(MI::kMu);
auto lambda = getRealData(MI::kLambda);
auto musgxy = getRealData(MI::kMuSgxy);
for (size_t i = 0; i < nElements; i++) {
mu[i] = s2[i] * s2[i] * rho0[i];
lambda[i] = c2[i] * c2[i] * rho0[i] - 2 * mu[i];
musgxy[i] = mu[i];
}
#if 1
double rho0_norm = 0;
for (size_t i = 0; i < nElements; i++) {
rho0_norm += std::abs(rho0[i]);
}
std::cout << "rho0_norm = " << rho0_norm << std::endl;
#endif
}
void
KSpaceSolverElastic::generatePml()
{
const DimensionSizes dimensionSizes = mParameters.getFullDimensionSizes();
double pmlXAlpha = mParameters.getPmlXAlpha();
double pmlYAlpha = mParameters.getPmlYAlpha();
const size_t pmlXSize = mParameters.getPmlXSize();
const size_t pmlYSize = mParameters.getPmlYSize();
const double cRefDx = mParameters.getCRef() / mParameters.getDx();
const double cRefDy = mParameters.getCRef() / mParameters.getDy();
const double dt2 = mParameters.getDt() * 0.5f;
double *pmlX = getRealData(MI::kPmlX);
double *pmlY = getRealData(MI::kPmlY);
double *pmlXSgx = getRealData(MI::kPmlXSgx);
double *pmlYSgy = getRealData(MI::kPmlYSgy);
auto mPmlX = getRealData(MI::kMPmlX);
auto mPmlY = getRealData(MI::kMPmlY);
auto mPmlXSgx = getRealData(MI::kMPmlXSgx);
auto mPmlYSgy = getRealData(MI::kMPmlYSgy);
auto multiAxialPmlRatio = mParameters.getMultiAxialPmlRatio();
// Init arrays
auto initPml = [](double *pml, double *pmlSg, size_t size)
{
for (size_t i = 0; i < size; i++) {
pml[i] = 1.0f;
pmlSg[i] = 1.0f;
}
};// end of initPml
// Calculate left value of PML exponent,
// for staggered use i + 0.5f, i shifted by -1 (Matlab indexing).
auto pmlLeft = [dt2](double i, double cRef, double pmlAlpha, double pmlSize)
{
return exp(-dt2 * pmlAlpha * cRef * pow((i - pmlSize) / (-pmlSize), 4));
};// end of pmlLeft.
// Calculate right value of PML exponent,
// for staggered use i + 0.5f, i shifted by +1 (Matlab indexing).
auto pmlRight = [dt2](double i, double cRef, double pmlAlpha, double pmlSize)
{
return exp(-dt2 * pmlAlpha * cRef * pow((i + 1.0f) / pmlSize, 4));
};// end of pmlRight.
// PML in x dimension
initPml(pmlX, pmlXSgx, dimensionSizes.nx);
// Too difficult for SIMD
for (size_t i = 0; i < pmlXSize; i++) {
pmlX[i] = pmlLeft(double(i), cRefDx, pmlXAlpha, pmlXSize);
pmlXSgx[i] = pmlLeft(double(i) + 0.5f, cRefDx, pmlXAlpha, pmlXSize);
const size_t iR = dimensionSizes.nx - pmlXSize + i;
pmlX[iR] = pmlRight(double(i), cRefDx, pmlXAlpha, pmlXSize);
pmlXSgx[iR] = pmlRight(double(i) + 0.5f, cRefDx, pmlXAlpha, pmlXSize);
}
// PML in y dimension
initPml(pmlY, pmlYSgy, dimensionSizes.ny);
// Too difficult for SIMD
for (size_t i = 0; i < pmlYSize; i++) {
if (!mParameters.isSimulationAS()) { // for axisymmetric code the PML is only on the outer side
pmlY[i] = pmlLeft(double(i), cRefDy, pmlYAlpha, pmlYSize);
pmlYSgy[i] = pmlLeft(double(i) + 0.5f, cRefDy, pmlYAlpha, pmlYSize);
}
const size_t iR = dimensionSizes.ny - pmlYSize + i;
pmlY[iR] = pmlRight(double(i), cRefDy, pmlYAlpha, pmlYSize);
pmlYSgy[iR] = pmlRight(double(i) + 0.5f, cRefDy, pmlYAlpha, pmlYSize);
}
pmlXAlpha *= multiAxialPmlRatio;
pmlYAlpha *= multiAxialPmlRatio;
initPml(mPmlX, mPmlXSgx, dimensionSizes.nx);
// Too difficult for SIMD
for (size_t i = 0; i < pmlXSize; i++) {
mPmlX[i] = pmlLeft(double(i), cRefDx, pmlXAlpha, pmlXSize);
mPmlXSgx[i] = pmlLeft(double(i) + 0.5f, cRefDx, pmlXAlpha, pmlXSize);
const size_t iR = dimensionSizes.nx - pmlXSize + i;
mPmlX[iR] = pmlRight(double(i), cRefDx, pmlXAlpha, pmlXSize);
mPmlXSgx[iR] = pmlRight(double(i) + 0.5f, cRefDx, pmlXAlpha, pmlXSize);
}
// PML in y dimension
initPml(mPmlY, mPmlYSgy, dimensionSizes.ny);
// Too difficult for SIMD
for (size_t i = 0; i < pmlYSize; i++) {
if (!mParameters.isSimulationAS()) { // for axisymmetric code the PML is only on the outer side
mPmlY[i] = pmlLeft(double(i), cRefDy, pmlYAlpha, pmlYSize);
mPmlYSgy[i] = pmlLeft(double(i) + 0.5f, cRefDy, pmlYAlpha, pmlYSize);
}
const size_t iR = dimensionSizes.ny - pmlYSize + i;
mPmlY[iR] = pmlRight(double(i), cRefDy, pmlYAlpha, pmlYSize);
mPmlYSgy[iR] = pmlRight(double(i) + 0.5f, cRefDy, pmlYAlpha, pmlYSize);
}
#if 0
// double *pmlX = getRealData(MI::kPmlX);
// double *pmlY = getRealData(MI::kPmlY);
//
// double *pmlXSgx = getRealData(MI::kPmlXSgx);
// double *pmlYSgy = getRealData(MI::kPmlYSgy);
//
// auto mPmlX = getRealData(MI::kMPmlX);
// auto mPmlY = getRealData(MI::kMPmlY);
//
// auto mPmlXSgx = getRealData(MI::kMPmlXSgx);
// auto mPmlYSgy = getRealData(MI::kMPmlYSgy);
const size_t nElements = dimensionSizes.nElements();
double pmlX_norm = 0;
double pmlY_norm = 0;
double mPmlX_norm = 0;
double mPmlY_norm = 0;
double pmlXSgx_norm = 0;
double pmlYSgy_norm = 0;
double mPmlXSgx_norm = 0;
double mPmlYSgy_norm = 0;
for (size_t i = 0; i < dimensionSizes.nx; ++i) {
pmlX_norm += std::abs(pmlX[i]);
pmlY_norm += std::abs(pmlY[i]);
mPmlX_norm += std::abs(mPmlX[i]);
mPmlY_norm += std::abs(mPmlY[i]);
pmlXSgx_norm += std::abs(pmlXSgx[i]);
pmlYSgy_norm += std::abs(pmlYSgy[i]);
mPmlXSgx_norm += std::abs(mPmlXSgx[i]);
mPmlYSgy_norm += std::abs(mPmlYSgy[i]);
}
double max_pmlX = *std::max_element(pmlX, pmlX+nElements);
std::cout << "pmlX_norm = " << pmlX_norm << std::endl;
std::cout << "pmlXSgx_norm = " << pmlXSgx_norm << std::endl;
std::cout << "pmlY_norm = " << pmlY_norm << std::endl;
std::cout << "pmlYSgy_norm = " << pmlYSgy_norm << std::endl;
std::cout << "mPmlX_norm = " << mPmlX_norm << std::endl;
std::cout << "mPmlXSgx_norm = " << mPmlXSgx_norm << std::endl;
std::cout << "mPmlY_norm = " << mPmlY_norm << std::endl;
std::cout << "mPmlYSgy_norm = " << mPmlYSgy_norm << std::endl;
#endif
}
void KSpaceSolverElastic::storeSensorInfo()
{
// Unless the time for sampling has come, exit.
if (mParameters.getTimeIndex() >= mParameters.getSamplingStartTimeIndex()) {
if (mParameters.getStoreVelocityNonStaggeredRawFlag()) {
if (mParameters.isSimulation3D()) {
computeShiftedVelocity<SD::k3D>();
} else {
computeShiftedVelocity<SD::k2D>();
}
}
mOutputStreamContainer.sampleStreams();
}
}
void KSpaceSolverElastic::postProcessing()
{
auto ¶ms = mParameters;
auto koutput = params.getKOutput();
if (koutput.isOutputToFileFlag()) {
if (mParameters.getStorePressureFinalAllFlag()) {
getRealMatrix(MI::kP).writeData(mParameters.getOutputFile(),
mOutputStreamContainer.getStreamHdf5Name(OI::kFinalPressure),
mParameters.getCompressionLevel());
}// p_final
// Apply post-processing and close
mOutputStreamContainer.postProcessStreams();
mOutputStreamContainer.closeStreams();
writeOutputDataInfo();
params.getOutputFile().close();
}
}
std::pair<KSpaceSolverElastic::MatrixType, std::vector<double>>
KSpaceSolverElastic::getWindow(std::vector<size_t> a, std::vector<bool> s)
{
auto cosineSeries = [](std::vector<double> &n, double N, std::vector<double> &coef)
{
std::vector<double> r(n.size());
std::transform(n.begin(), n.end(), r.begin(),
[&](double &i)
{
// series = series + (-1)^(index-1) * coeffs(index) * cos((index - 1) * 2 * pi * n / (N - 1));
const auto pi = M_PI;
return coef[0]
- (coef[1] * std::cos(1. * 2. * pi * i / (N - 1.)))
+ (coef[2] * std::cos(2. * 2. * pi * i / (N - 1.)));
});
return std::move(r);
};
assert(a.size() == s.size());
const auto param = 0.16;
std::transform(a.cbegin(), a.cend(), s.cbegin(), a.begin(), [](size_t a, bool b) { return a + 1 * (!b); });
switch (a.size()) {
case 1: {
auto N = a[0];
auto symmetric = s[0];
auto coef = std::vector<double>{(1 - param) / 2, 0.5, param / 2};
struct f {
double operator()() { return init++; }
double init = 0;
};
auto n = std::vector<double>(N);
std::generate(n.begin(), n.end(), f());
auto win = cosineSeries(n, N, coef);
N = N - 1 * (!symmetric);
win.resize(N);
return std::make_pair(MatrixType(), std::move(win));
}
case 2: {
auto linearSpace = [](double b, double e, int n)
{
assert(n > 1 && e > b);
std::vector<double> r(n);
auto i = 0;
std::transform(r.begin(), r.end(), r.begin(), [&](double) { return b + (e - b) * i++ / (n - 1); });
return std::move(r);
};
auto ndGrid = [](std::vector<double> xx, std::vector<double> yy)
{
auto x = MatrixType(yy.size(), std::vector<double>(xx.size(), 0));
auto y = MatrixType(yy.size(), std::vector<double>(xx.size(), 0));
std::for_each(x.begin(), x.end(), [&](std::vector<double> &v) { v = xx; });
auto i = 0;
std::for_each(y.begin(), y.end(), [&](std::vector<double> &v)
{
std::fill(v.begin(), v.end(), yy[i++]);
});
return std::make_pair(x, y);
};
auto L = *std::max_element(a.begin(), a.end());
auto t = getWindow(std::vector<size_t>{L}, std::vector<bool>{true});
auto win_lin = std::get<1>(t);
auto radius = (L - 1) / 2.;
auto ll = linearSpace(-radius, radius, L);
auto xx = linearSpace(-radius, radius, a[0]);
auto yy = linearSpace(-radius, radius, a[1]);
auto xy = ndGrid(xx, yy);
auto x = std::get<0>(xy);
auto y = std::get<1>(xy);
auto r = x;
assert(x.size() > 0);
for (size_t i = 0; i < x.size(); ++i)
for (size_t j = 0; j < x[0].size(); ++j) {
auto ret = std::sqrt(x[i][j] * x[i][j] + y[i][j] * y[i][j]);
r[i][j] = ret > radius ? radius : ret;
}
auto win = r;
LinearInterp<double> interPn(ll, win_lin);
for (size_t i = 0; i < win.size(); ++i)
for (size_t j = 0; j < win[0].size(); ++j) {
win[i][j] = interPn.interp(r[i][j]);
if (win[i][j] <= radius)
win[i][j] = interPn.interp(r[i][j]);
}
std::transform(a.cbegin(), a.cend(), s.cbegin(), a.begin(), [](size_t a, bool b) { return a - 1 * (!b); });
win.resize(a[1]);
std::for_each(win.begin(), win.end(), [&](std::vector<double> &v) { v.resize(a[0]); });
return std::make_pair(win, std::vector<double>());
}
default:
assert(false);
return std::make_pair(MatrixType(), std::vector<double>());
}
/* error. */
}
/*
* matrixIdx : [in] and [out]
*/
template <Parameters::SimulationDimension simulationDimension>
void
KSpaceSolverElastic::smooth(const MatrixContainer::MatrixIdx matrixIdx, bool isRestoreMax)
{
const auto ¶ms = mParameters;
auto nx = params.getFullDimensionSizes().nx;
auto ny = params.getFullDimensionSizes().ny;
const double dividerX = 1.0f / static_cast<double>(nx);
const double dividerY = 1.0f / static_cast<double>(ny);
auto *mat = getRealData(matrixIdx);
auto *mat_sam = getRealData(MI::kTmpReal1);
auto *t = getRealData(MI::kTmpReal2);
// auto *win = getRealData(MI::kTmpReal3);
auto matrixPrint = [&](double *m)
{
const DimensionSizes &dimensionSizes = mParameters.getFullDimensionSizes();
for (size_t z = 0; z < dimensionSizes.nz; ++z)
for (size_t x = 0; x < dimensionSizes.nx; ++x) {
for (size_t y = 0; y < dimensionSizes.ny; ++y) {
const size_t i = get1DIndex(z, y, x, dimensionSizes);
std::cout << std::setw(8) << m[i] << " ";
}
std::cout << std::endl;
}
};
FloatComplex *iFftwX = getComplexData(MI::kTempFftwX);
const size_t nElements = mParameters.getFullDimensionSizes().nElements();
const DimensionSizes &dimensionSizes = mParameters.getFullDimensionSizes();
const DimensionSizes &reducedDimensionSizes = mParameters.getReducedDimensionSizes();
std::vector<size_t> grid_size{dimensionSizes.nx, dimensionSizes.ny};
std::vector<bool> window_symmetry;
std::transform(grid_size.begin(), grid_size.end(), std::back_inserter(window_symmetry),
[](size_t i) { return i % 2 == 1; });
// assert(grid_size[0] == 8 && grid_size[1] == 8);
// assert(window_symmetry[0] == false && window_symmetry[1] == false);
// get the window
auto ret = getWindow(grid_size, window_symmetry);
auto twin = std::get<0>(ret);
std::for_each(twin.begin(), twin.end(),
[](std::vector<double> &v)
{
std::for_each(v.begin(), v.end(), [](double &i) { i = std::abs(i); });
});
getTempFftwX().computeR2CFftND(getRealMatrix(matrixIdx));
auto iFftShift = [](size_t i, size_t size)
{
return (i + (size / 2)) % size;
};
auto ifft_twin = twin;
for (size_t z = 0; z < dimensionSizes.nz; ++z)
for (size_t y = 0; y < dimensionSizes.ny; ++y)
for (size_t x = 0; x < dimensionSizes.nx; ++x) {
const size_t i = get1DIndex(z, y, x, dimensionSizes);
size_t x_pos = iFftShift(x, dimensionSizes.nx);
size_t y_pos = iFftShift(y, dimensionSizes.ny);
ifft_twin[y][x] = twin[y_pos][x_pos];
}
// for (size_t z = 0; z < dimensionSizes.nz; ++z)
// for (size_t x = 0; x < dimensionSizes.nx; ++x)
// {
// for (size_t y = 0; y < dimensionSizes.ny; ++y)
// {
// const size_t i = get1DIndex(z, y, x, dimensionSizes);
// std::cout << std::setw(12) << ifft_twin[y][x] << " ";
// }
// std::cout << std::endl;
// }
for (size_t z = 0; z < reducedDimensionSizes.nz; ++z)
for (size_t y = 0; y < reducedDimensionSizes.ny; ++y)
for (size_t x = 0; x < reducedDimensionSizes.nx; ++x) {
const size_t i = get1DIndex(z, y, x, reducedDimensionSizes);
iFftwX[i] = iFftwX[i] * ifft_twin[y][x] * dividerX * dividerY;
}
// for (size_t z = 0; z < reducedDimensionSizes.nz; ++z)
// for (size_t x = 0; x < reducedDimensionSizes.nx; ++x)
// {
// for (size_t y = 0; y < reducedDimensionSizes.ny; ++y)
// {
// const size_t i = get1DIndex(z, y, x, reducedDimensionSizes);
// std::cout << iFftwX[i] << " ";
// }
// std::cout << std::endl;
// }
getTempFftwX().computeC2RFftND(getRealMatrix(MI::kTmpReal1));
// auto p0 = getRealData(matrixIdx);
//
// for (size_t z = 0; z < dimensionSizes.nz; ++z)
// for (size_t x = 0; x < dimensionSizes.nx; ++x)
// {
// for (size_t y = 0; y < dimensionSizes.ny; ++y)
// {
// const size_t i = get1DIndex(z, y, x, dimensionSizes);
// std::cout << p0[i] << " ";
// }
// std::cout << std::endl;
// }
if (isRestoreMax) {
std::transform(mat, mat + nElements, t, [](double &i) { return std::abs(i); });
auto mat_max = *std::max_element(t, t + nElements);
std::transform(mat_sam, mat_sam + nElements, t, [](double &i) { return std::abs(i); });
auto mat_sam_max = *std::max_element(t, t + nElements);
auto ratio = mat_max / mat_sam_max;
std::transform(mat_sam, mat_sam + nElements, mat_sam, [ratio](double &i) { return ratio * i; });
}
getRealMatrix(matrixIdx).copyData(getRealMatrix(MI::kTmpReal1));
// auto p0 = getRealData(matrixIdx);
// for (size_t z = 0; z < dimensionSizes.nz; ++z)
// for (size_t x = 0; x < dimensionSizes.nx; ++x)
// {
// for (size_t y = 0; y < dimensionSizes.ny; ++y)
// {
// const size_t i = get1DIndex(z, y, x, dimensionSizes);
// std::cout << p0[i] << " ";
// }
// std::cout << std::endl;
// }
}
void
KSpaceSolverElastic::debugVariableNorm()
{
const size_t nElements = mParameters.getFullDimensionSizes().nElements();
double *pmlX = getRealData(MI::kPmlX);
double *pmlY = getRealData(MI::kPmlY);
double *pmlXSgx = getRealData(MI::kPmlXSgx);
double *pmlYSgy = getRealData(MI::kPmlYSgy);
auto mPmlX = getRealData(MI::kMPmlX);
auto mPmlY = getRealData(MI::kMPmlY);
auto mPmlXSgx = getRealData(MI::kMPmlXSgx);
auto mPmlYSgy = getRealData(MI::kMPmlYSgy);
const double *sxxSplitX = getRealData(MI::kSxxSplitX);
const double *sxxSplitY = getRealData(MI::kSxxSplitY);
const double *syySplitX = getRealData(MI::kSyySplitX);
const double *syySplitY = getRealData(MI::kSyySplitY);
const double *sxySplitX = getRealData(MI::kSxySplitX);
const double *sxySPlitY = getRealData(MI::kSxySplitY);
double *p = getRealData(MI::kP);
}
void
KSpaceSolverElastic::miscVerify()
{
initializeFftwPlans();
std::cout << "KSpaceSolverElastic::miscVerify" << std::endl;
const size_t nElements = mParameters.getFullDimensionSizes().nElements();
smooth<SD::k2D>(MI::kInitialPressureSourceInput, true);
}
void
KSpaceSolverElastic::fftwVerify()
{
// initializeFftwPlans();
// generateDerivativeOperators();
#if 0
FloatComplex *fftx = getComplexData(MI::kTmpFftwXXdx);
double *x = getRealData(MI::kTmpReal1);
x[49] = -5;
x[49 + 128 - 3] = -5;
x[49 + 128 - 2] = -5;
x[49 + 128 - 1] = -5;
x[49 + 128] = -5;
x[49 + 128 + 1] = -5;
x[49 + 128 + 2] = -5;
x[49 + 128 + 3] = -5;
getTempFftwXXdx().computeR2CFft1DX(getRealMatrix(MI::kTmpReal1));
std::cout << fftx[0] << std::endl;
std::cout << fftx[1] << std::endl;
std::cout << " -------------------- " << std::endl;
std::cout << fftx[62] << std::endl;
std::cout << fftx[63] << std::endl;
std::cout << fftx[64] << std::endl;
std::cout << fftx[65] << std::endl;
std::cout << fftx[66] << std::endl;
std::cout << " -------------------- " << std::endl;
std::cout << fftx[64] << std::endl;
std::cout << fftx[65] << std::endl;
std::cout << " -------------------- " << std::endl;
std::cout << fftx[64+62] << std::endl;
std::cout << fftx[64+63] << std::endl;
std::cout << fftx[64+64] << std::endl;
std::cout << fftx[64+65] << std::endl;
std::cout << fftx[64+66] << std::endl;
#endif
#if 0
FloatComplex *fftx = getComplexData(MI::kTmpFftwXXdx);
const double divider = 1.0f / double(mParameters.getFullDimensionSizes().nElements());
const auto & dimSizes = mParameters.getFullDimensionSizes();
const size_t nElements = mParameters.getFullDimensionSizes().nElements();
const DimensionSizes& reducedDimSizes= mParameters.getReducedDimensionSizes();
double *p0 = getRealData(MI::kInitialPressureSourceInput);
double* sxxSplitX = getRealData(MI::kSxxSplitX);
double* sxxSplitY = getRealData(MI::kSxxSplitY);
double* tmp = getRealData(MI::kTmpReal1);
for (size_t i = 0; i < nElements; i++) {
tmp[i] = -p0[i] / 2.f;
}
getRealMatrix(MI::kSxxSplitX).copyData(getRealMatrix(MI::kTmpReal1));
getRealMatrix(MI::kSxxSplitY).copyData(getRealMatrix(MI::kTmpReal1));
double *tmpReal1 = getRealData(MI::kTmpReal1);
for (size_t i = 0; i < dimSizes.nElements(); i ++)
{
tmpReal1[i] = sxxSplitX[i] + sxxSplitY[i];
}
tmpReal1[49] = - 5;
getTempFftwXXdx().computeR2CFft1DX(getRealMatrix(MI::kTmpReal1));
for (size_t z = 0; z < reducedDimSizes.nz; z++)
{
for (size_t y = 0; y < reducedDimSizes.ny; y++)
{
for (size_t x = 0; x < reducedDimSizes.nx; x++)
{
const size_t i = get1DIndex(z, y, x, reducedDimSizes);
fftx[i] *= divider;
}
}
}
getTempFftwXXdx().computeC2RFft1DX(getRealMatrix(MI::kDSxxdx));
double *dsxxdx = getRealData(MI::kDSxxdx);
//std::cout << fftx[0 + 128] << std::endl;
//std::cout << fftx[1 + 128] << std::endl;
//std::cout << fftx[2 + 128] << std::endl;
#endif
#if 0
FloatComplex *ffty = getComplexData(MI::kTmpFftwYYdy);
const FloatComplex* ddyKShiftPos = getComplexData(MI::kDdyKShiftPos);
const auto & dimSizes = mParameters.getFullDimensionSizes();
const size_t nElements = mParameters.getFullDimensionSizes().nElements();
const DimensionSizes& reducedDimSizes= mParameters.getReducedDimensionSizes();
auto ny = dimSizes.ny;
const double divider = 1.f / static_cast<double>(ny);
double *p0 = getRealData(MI::kInitialPressureSourceInput);
double* syySplitX = getRealData(MI::kSyySplitX);
double* syySplitY = getRealData(MI::kSyySplitY);
double* tmp = getRealData(MI::kTmpReal2);
for (size_t i = 0; i < nElements; i++) {
tmp[i] = -p0[i] / 2.f;
}
getRealMatrix(MI::kSyySplitX).copyData(getRealMatrix(MI::kTmpReal2));
getRealMatrix(MI::kSyySplitY).copyData(getRealMatrix(MI::kTmpReal2));
double *tmpReal2 = getRealData(MI::kTmpReal2);
for (size_t i = 0; i < dimSizes.nElements(); i ++)
{
tmpReal2[i] = syySplitX[i] + syySplitY[i];
}
// tmpReal2[49 * 128 + 41] = - 5;
getTempFftwYYdy().computeR2CFft1DY(getRealMatrix(MI::kTmpReal2));
for (size_t z = 0; z < reducedDimSizes.nz; z++)
{
for (size_t y = 0; y < reducedDimSizes.ny; y++)
{
for (size_t x = 0; x < reducedDimSizes.nx; x++)
{
const size_t i = get1DIndex(z, y, x, reducedDimSizes);
ffty[i] *= ddyKShiftPos[y];
}
}
}
getTempFftwYYdy().computeC2RFft1DY(getRealMatrix(MI::kDSyydy));
double *dsyydy = getRealData(MI::kDSyydy);
for (size_t i = 0; i < nElements; ++ i)
dsyydy[i] *= divider;
//std::cout << fftx[0 + 128] << std::endl;
//std::cout << fftx[1 + 128] << std::endl;
//std::cout << fftx[2 + 128] << std::endl;
#endif
}
| 34.923282
| 121
| 0.590602
|
xschrodingerscat
|
d4810b526a50894f5cea3a652b48ae4b1c99cc53
| 3,624
|
hpp
|
C++
|
dependencies/glm/glm/gtc/integer.hpp
|
Noaheasley/Bootstrap
|
fbcf53bffa42fe41233726ba42218568ce0dba60
|
[
"MIT"
] | 13
|
2017-03-06T22:25:10.000Z
|
2022-01-31T00:19:03.000Z
|
dependencies/glm/glm/gtc/integer.hpp
|
Noaheasley/Bootstrap
|
fbcf53bffa42fe41233726ba42218568ce0dba60
|
[
"MIT"
] | 12
|
2016-12-03T01:36:31.000Z
|
2019-12-11T00:40:02.000Z
|
dependencies/glm/glm/gtc/integer.hpp
|
Noaheasley/Bootstrap
|
fbcf53bffa42fe41233726ba42218568ce0dba60
|
[
"MIT"
] | 37
|
2016-10-27T14:55:34.000Z
|
2022-01-31T00:19:08.000Z
|
/// @ref gtc_integer
/// @file glm/gtc/integer.hpp
///
/// @see core (dependence)
/// @see gtc_integer (dependence)
///
/// @defgroup gtc_integer GLM_GTC_integer
/// @ingroup gtc
///
/// @brief Allow to perform bit operations on integer values
///
/// <glm/gtc/integer.hpp> need to be included to use these functionalities.
#pragma once
// Dependencies
#include "../detail/setup.hpp"
#include "../detail/precision.hpp"
#include "../detail/func_common.hpp"
#include "../detail/func_integer.hpp"
#include "../detail/func_exponential.hpp"
#include <limits>
#if GLM_MESSAGES == GLM_MESSAGES_ENABLED && !defined(GLM_EXT_INCLUDED)
# pragma message("GLM: GLM_GTC_integer extension included")
#endif
namespace glm
{
/// @addtogroup gtc_integer
/// @{
/// Returns the log2 of x for integer values. Can be reliably using to compute mipmap count from the texture size.
/// @see gtc_integer
template<typename genIUType>
GLM_FUNC_DECL genIUType log2(genIUType x);
/// Modulus. Returns x % y
/// for each component in x using the floating point value y.
///
/// @tparam genIUType Integer-point scalar or vector types.
///
/// @see gtc_integer
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/mod.xml">GLSL mod man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
template<typename genIUType>
GLM_FUNC_DECL genIUType mod(genIUType x, genIUType y);
/// Modulus. Returns x % y
/// for each component in x using the floating point value y.
///
/// @tparam T Integer scalar types.
///
/// @see gtc_integer
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/mod.xml">GLSL mod man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
template<length_t L, typename T, precision P>
GLM_FUNC_DECL vec<L, T, P> mod(vec<L, T, P> const& x, T y);
/// Modulus. Returns x % y
/// for each component in x using the floating point value y.
///
/// @tparam T Integer scalar types.
///
/// @see gtc_integer
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/mod.xml">GLSL mod man page</a>
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.3 Common Functions</a>
template<length_t L, typename T, precision P>
GLM_FUNC_DECL vec<L, T, P> mod(vec<L, T, P> const& x, vec<L, T, P> const& y);
/// Returns a value equal to the nearest integer to x.
/// The fraction 0.5 will round in a direction chosen by the
/// implementation, presumably the direction that is fastest.
///
/// @param x The values of the argument must be greater or equal to zero.
/// @tparam T floating point scalar types.
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/round.xml">GLSL round man page</a>
/// @see gtc_integer
template<length_t L, typename T, precision P>
GLM_FUNC_DECL vec<L, int, P> iround(vec<L, T, P> const& x);
/// Returns a value equal to the nearest integer to x.
/// The fraction 0.5 will round in a direction chosen by the
/// implementation, presumably the direction that is fastest.
///
/// @param x The values of the argument must be greater or equal to zero.
/// @tparam T floating point scalar types.
///
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/round.xml">GLSL round man page</a>
/// @see gtc_integer
template<length_t L, typename T, precision P>
GLM_FUNC_DECL vec<L, uint, P> uround(vec<L, T, P> const& x);
/// @}
} //namespace glm
#include "integer.inl"
| 36.606061
| 137
| 0.694536
|
Noaheasley
|
d481a18ca51734ceac9efaf66743070806af8035
| 979
|
cpp
|
C++
|
SwapNodesinPairs/SwapNodesinPairs_2.cpp
|
yergen/leetcode
|
7b6dac49ac44e0bf43a4ecb4795ea8cfe6afa4ab
|
[
"MIT"
] | null | null | null |
SwapNodesinPairs/SwapNodesinPairs_2.cpp
|
yergen/leetcode
|
7b6dac49ac44e0bf43a4ecb4795ea8cfe6afa4ab
|
[
"MIT"
] | null | null | null |
SwapNodesinPairs/SwapNodesinPairs_2.cpp
|
yergen/leetcode
|
7b6dac49ac44e0bf43a4ecb4795ea8cfe6afa4ab
|
[
"MIT"
] | null | null | null |
#include<iostream>
#include<string>
using namespace::std;
struct ListNode {
int val;
ListNode *next;
ListNode(int x) : val(x), next(NULL) {}
};
class Solution {
public:
ListNode* swapPairs(ListNode* head) {
ListNode **pp = &head, *first, *second;
//a->b->c->d->e->f
while ((first = *pp) && (second = first->next))
{
first->next = second->next;//*pp/head->a->c->d->e->f //b->*pp/a->c->e->f
second->next = first; //b->a->c->d->e->f //d->c->e->f
*pp = second; //*pp/head->b->a->c->d->e->f //b->*pp/a->d->c->e->f
pp = &(first->next); //b->*pp/a->c->d->e->f //b->a->d->*pp/c->e->f
}
return head;
}
};
int main()
{
int a[4] = { 1, 2, 3, 4 };
ListNode *head = new ListNode(0), *point = head;
for (int i = 0; i < 4; i++)
{
point->next = new ListNode(a[i]);
point = point->next;
}
Solution sol;
point = sol.swapPairs(head->next);
while (point)
{
cout << point->val;
point = point->next;
}
cout << endl;
return 0;
}
| 20.829787
| 79
| 0.52809
|
yergen
|
d48302fcce0a0ff2c394d6154b1b0a45d755315d
| 2,256
|
hpp
|
C++
|
rmf_task/include/rmf_task/Request.hpp
|
Rouein/rmf_task
|
32de25ff127aed754ca760ef462ef8c3e7dd56a1
|
[
"Apache-2.0"
] | null | null | null |
rmf_task/include/rmf_task/Request.hpp
|
Rouein/rmf_task
|
32de25ff127aed754ca760ef462ef8c3e7dd56a1
|
[
"Apache-2.0"
] | null | null | null |
rmf_task/include/rmf_task/Request.hpp
|
Rouein/rmf_task
|
32de25ff127aed754ca760ef462ef8c3e7dd56a1
|
[
"Apache-2.0"
] | null | null | null |
/*
* Copyright (C) 2020 Open Source Robotics Foundation
*
* 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 RMF_TASK__REQUEST_HPP
#define RMF_TASK__REQUEST_HPP
#include <memory>
#include <rmf_task/Task.hpp>
#include <rmf_utils/impl_ptr.hpp>
namespace rmf_task {
//==============================================================================
class Request
{
public:
/// Constructor
///
/// \param[in] earliest_start_time
/// The desired start time for this request
///
/// \param[in] priority
/// The priority for this request. This is provided by the Priority Scheme.
/// For requests that do not have any priority this is a nullptr.
///
/// \param[in] description
/// The description for this request
///
/// \param[in] automatic
/// True if this request is auto-generated
//
// TODO(MXG): Deprecate this constructor?
Request(
const std::string& id,
rmf_traffic::Time earliest_start_time,
ConstPriorityPtr priority,
Task::ConstDescriptionPtr description,
bool automatic = false);
/// Constructor
///
/// \param[in] booking
/// Booking information for this request
///
/// \param[in] description
/// Description for this request
Request(
Task::ConstBookingPtr booking,
Task::ConstDescriptionPtr description);
/// Get the tag of this request
const Task::ConstBookingPtr& booking() const;
/// Get the description of this request
const Task::ConstDescriptionPtr& description() const;
class Implementation;
private:
rmf_utils::impl_ptr<Implementation> _pimpl;
};
using RequestPtr = std::shared_ptr<Request>;
using ConstRequestPtr = std::shared_ptr<const Request>;
} // namespace rmf_task
#endif // RMF_TASK__REQUEST_HPP
| 26.857143
| 80
| 0.684397
|
Rouein
|
d487d715d6ea719fc27db2f8bf137b50190f395b
| 1,740
|
cpp
|
C++
|
Dynamic_Memory_Allocation/Dynamic_Memory_Allocation/main.cpp
|
b01703020/Financial_Computing
|
d98d4f6e784997129ece15cdaf33c506e0f35c9e
|
[
"MIT"
] | null | null | null |
Dynamic_Memory_Allocation/Dynamic_Memory_Allocation/main.cpp
|
b01703020/Financial_Computing
|
d98d4f6e784997129ece15cdaf33c506e0f35c9e
|
[
"MIT"
] | null | null | null |
Dynamic_Memory_Allocation/Dynamic_Memory_Allocation/main.cpp
|
b01703020/Financial_Computing
|
d98d4f6e784997129ece15cdaf33c506e0f35c9e
|
[
"MIT"
] | null | null | null |
//
// main.cpp
// Dynamic_Memory_Allocation
//
// Created by wu yen sun on 2022/2/4.
//
#include <iostream>
using namespace std;
int* getNum1() // Should not return the address of a local variable
{
int num = 10; // num i s a local variable
num += 1;
return # // its address is not reliable once the function is complete
}
int getNum2() // no issue
{
int num = 10;
num += 1;
return num; // the value of num is copied and the copy is returned to main function
}
void getNum3(int* ptr) // call by pointer, no issue
{ // address of y is passed to pointer ptr
*ptr += 1;
}
int* getNum4()
{
int* ptr = new int; // dynamic allocation
*ptr = 10; // deference and assign to 10
*ptr += 1; // deference and add 1
//delete ptr; // can not free memory inside the function as the pointer will be used in main as ptr2
//ptr = NULL;
return ptr; // return the pointer
}
int main()
{
// int* ptr1 = getNum1();
// *ptr1 += 1;
// cout << "*ptr1=" << *ptr1 << endl;
// Function must not return a pointer to a local variable in the function
int x = getNum2();
x += 1;
cout << "x=" << x << endl; // 12
int y = 10;
getNum3(&y);
y += 1;
cout << "y=" << y << endl; // 12
int* ptr2 = nullptr;
ptr2 = getNum4(); // ptr2 is pointing to the allocated memory
*ptr2 += 1;
cout << "*ptr2=" << *ptr2 << endl;
// 12 after comment out free memory and preventing dangling
// free memory before preventing dangling
delete ptr2; // free alocated memory
ptr2 = NULL; // prevent dangling
return 0;
}
| 23.513514
| 110
| 0.551149
|
b01703020
|
d48b278d8eee1f8400c0e54d46afe8fdefb1baff
| 1,164
|
cpp
|
C++
|
Core/src/latest/main/cpp/Capture/Camera.cpp
|
CJBuchel/CJ-Vision
|
60fad66b807c6082fdcf01df9972b42dfc5c5ecc
|
[
"MIT"
] | 1
|
2020-09-07T09:15:15.000Z
|
2020-09-07T09:15:15.000Z
|
Core/src/latest/main/cpp/Capture/Camera.cpp
|
CJBuchel/CJ-Vision
|
60fad66b807c6082fdcf01df9972b42dfc5c5ecc
|
[
"MIT"
] | null | null | null |
Core/src/latest/main/cpp/Capture/Camera.cpp
|
CJBuchel/CJ-Vision
|
60fad66b807c6082fdcf01df9972b42dfc5c5ecc
|
[
"MIT"
] | 1
|
2020-09-02T02:02:11.000Z
|
2020-09-02T02:02:11.000Z
|
#include "Capture/Camera.h"
namespace CJ {
Camera::~Camera() {
CJ_CORE_PRINT_WARN("Destroyed Camera, cap released");
cap.release();
}
int Camera::init() {
CJ_CORE_PRINT_INFO("Creating OpenCV Cap");
cap.set(cv::CAP_PROP_FPS, config.fps);
cap.open(config.port, config.apiID);
if (!cap.isOpened()) {
CJ_CORE_PRINT_ERROR(config.name + " Failed to open on port: " + std::to_string(config.port));
return 1;
}
CJ_CORE_PRINT_INFO("Setting frame res");
cap.set(cv::CAP_PROP_FRAME_HEIGHT, config.resHeight);
cap.set(cv::CAP_PROP_FRAME_WIDTH, config.resWidth);
if (config.autoExposure) {
CJ_CORE_PRINT_INFO("Auto exposure enabled");
cap.set(cv::CAP_PROP_AUTO_EXPOSURE, config.cap_prop_autoExpose);
} else {
CJ_CORE_PRINT_INFO("Auto exposure disabled");
cap.set(cv::CAP_PROP_AUTO_EXPOSURE, config.cap_prop_manualExpose);
cap.set(cv::CAP_PROP_EXPOSURE, config.exposure);
CJ_CORE_PRINT_INFO("Exposure: " + std::to_string(config.exposure));
}
return 0;
}
void Camera::capture(Image &image) {
cap.read(image.data);
if (image.data.empty()) {
CJ_CORE_PRINT_ERROR("Cannot get input image. Image empty");
}
}
}
| 27.714286
| 96
| 0.710481
|
CJBuchel
|
d48f288d1cdeabbfc1745184bf55da6e1ad44958
| 2,867
|
inl
|
C++
|
MathLib/Include/GaussianQuadrature.inl
|
bgin/MissileSimulation
|
90adcbf1c049daafb939f3fe9f9dfe792f26d5df
|
[
"MIT"
] | 23
|
2016-08-28T23:20:12.000Z
|
2021-12-15T14:43:58.000Z
|
MathLib/Include/GaussianQuadrature.inl
|
bgin/MissileSimulation
|
90adcbf1c049daafb939f3fe9f9dfe792f26d5df
|
[
"MIT"
] | 1
|
2018-06-02T21:29:51.000Z
|
2018-06-05T05:59:31.000Z
|
MathLib/Include/GaussianQuadrature.inl
|
bgin/MissileSimulation
|
90adcbf1c049daafb939f3fe9f9dfe792f26d5df
|
[
"MIT"
] | 1
|
2019-07-04T22:38:22.000Z
|
2019-07-04T22:38:22.000Z
|
template<typename _Ty> __forceinline mathlib::GaussianQdrtr<_Ty>::GaussianQdrtr(const _Ty integr, const _Ty err) : integral(integr),
error(err)
{
}
template<typename _Ty> template<typename Function> __forceinline mathlib::GaussianQdrtr<_Ty> mathlib::GaussianQdrtr<_Ty>::integrate(Function f,
_Ty a, _Ty b)
{
_Ty sum = 0.0 , err = std::numeric_limits<_Ty>::quiet_NaN();
static const _Ty x_vals[] = {
0.1488743389816, 0.4333953941292,
0.6794095682990, 0.8650633666889,
0.9739065285171
};
static const _Ty w_vals[] = {
0.2955242247147, 0.26926671930999,
0.2190863625159, 0.14945134915058,
0.0666713443086
};
_Ty arg_m = 0.5 * (b - a);
_Ty arg_r = 0.5 * (b + a);
const int num_iter = 5;
for (auto i = 0; i != num_iter; ++i)
{
_Ty x = arg_r * x_vals[i];
sum += w_vals[i] * (f(arg_m + x) + f(arg_m - x));
}
return mathlib::GaussianQdrtr<_Ty>((sum * arg_r), err);
}
template<typename _Ty> __forceinline _Ty mathlib::GaussianQdrtr<_Ty>::get_integral() const
{
return this->integral;
}
template<typename _Ty> __forceinline _Ty mathlib::GaussianQdrtr<_Ty>::get_error() const
{
return this->error;
}
template<typename _Ty> __forceinline mathlib::GaussQuadrature<_Ty>::GaussQuadrature()
{
}
template<typename _Ty> __forceinline mathlib::GaussQuadrature<_Ty>::GaussQuadrature(const double aa, const double bb, _Ty &Func) : a(aa),
b(bb), functor(Func), integral(std::numeric_limits<double>::quiet_NaN())
{
}
template<typename _Ty> __forceinline mathlib::GaussQuadrature<_Ty>::GaussQuadrature(const mathlib::GaussQuadrature<_Ty> &rhs) : a(rhs.a),
b(rhs.b), functor(rhs.functor), integral(rhs.integral)
{
}
template<typename _Ty> __forceinline mathlib::GaussQuadrature<_Ty> & mathlib::GaussQuadrature<_Ty>::integrate()
{
static const double x[] =
{
0.1488743389816L, 0.4333953941292L,
0.6794095682990L, 0.8650633666889L,
0.9739065285171L
};
static const double w[] =
{
0.2955242247147L, 0.26926671930999L,
0.2190863625159L, 0.14945134915058L,
0.0666713443086L
};
double arg_m = 0.5L * (this->b - this->a);
double arg_r = 0.5L * (this->b + this->a);
const int num_iter = 5;
for (auto i = 0; i != num_iter; ++i)
{
double x = arg_r * x[i];
this->integral += w[i] * (this->functor(arg_m + x) + this->functor(arg_m - x));
}
this->integral *= arg_r;
return *this;
}
template<typename _Ty> __forceinline double mathlib::GaussQuadrature<_Ty>::get_a() const
{
return this->a;
}
template<typename _Ty> __forceinline double mathlib::GaussQuadrature<_Ty>::get_b() const
{
return this->b;
}
template<typename _Ty> __forceinline double mathlib::GaussQuadrature<_Ty>::get_integral() const
{
return this->integral;
}
template<typename _Ty> __forceinline std::function<double(double)> mathlib::GaussQuadrature<_Ty>::get_functor() const
{
return std::function<double(double)>{this->functor};
}
| 26.546296
| 145
| 0.705964
|
bgin
|
d4918f230082dd2cbec38248041103e55285940d
| 499
|
cpp
|
C++
|
src/RE/BSExtraData/ExtraCharge.cpp
|
thallada/CommonLibSSE
|
b092c699c3ccd1af6d58d05f677f2977ec054cfe
|
[
"MIT"
] | 1
|
2021-08-30T20:33:43.000Z
|
2021-08-30T20:33:43.000Z
|
src/RE/BSExtraData/ExtraCharge.cpp
|
thallada/CommonLibSSE
|
b092c699c3ccd1af6d58d05f677f2977ec054cfe
|
[
"MIT"
] | null | null | null |
src/RE/BSExtraData/ExtraCharge.cpp
|
thallada/CommonLibSSE
|
b092c699c3ccd1af6d58d05f677f2977ec054cfe
|
[
"MIT"
] | 1
|
2020-10-08T02:48:33.000Z
|
2020-10-08T02:48:33.000Z
|
#include "RE/BSExtraData/ExtraCharge.h"
namespace RE
{
ExtraCharge::ExtraCharge() :
BSExtraData(),
charge(0.0F),
pad14(0)
{
REL::Relocation<std::uintptr_t> vtbl{ Offset::ExtraCharge::Vtbl };
((std::uintptr_t*)this)[0] = vtbl.address();
}
ExtraDataType ExtraCharge::GetType() const
{
return ExtraDataType::kCannotWear;
}
bool ExtraCharge::IsNotEqual(const BSExtraData* a_rhs) const
{
auto rhs = static_cast<const ExtraCharge*>(a_rhs);
return charge != rhs->charge;
}
}
| 17.821429
| 68
| 0.693387
|
thallada
|
d49304852272523f2d86c823870a53154a52a1e3
| 5,112
|
hpp
|
C++
|
src/mgmt/nfd/forwarder-status.hpp
|
alvyC/ndn-cxx-vanet-ext
|
48e8b214416d1b9d3534d26d28c147867f35d311
|
[
"OpenSSL"
] | 1
|
2021-09-07T04:12:15.000Z
|
2021-09-07T04:12:15.000Z
|
src/mgmt/nfd/forwarder-status.hpp
|
alvyC/ndn-cxx-vanet-ext
|
48e8b214416d1b9d3534d26d28c147867f35d311
|
[
"OpenSSL"
] | null | null | null |
src/mgmt/nfd/forwarder-status.hpp
|
alvyC/ndn-cxx-vanet-ext
|
48e8b214416d1b9d3534d26d28c147867f35d311
|
[
"OpenSSL"
] | 1
|
2020-07-15T06:21:03.000Z
|
2020-07-15T06:21:03.000Z
|
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2013-2017 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
* ndn-cxx library is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later version.
*
* ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received copies of the GNU General Public License and GNU Lesser
* General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see
* <http://www.gnu.org/licenses/>.
*
* See AUTHORS.md for complete list of ndn-cxx authors and contributors.
*/
#ifndef NDN_MGMT_NFD_FORWARDER_STATUS_HPP
#define NDN_MGMT_NFD_FORWARDER_STATUS_HPP
#include "../../encoding/block.hpp"
#include "../../util/time.hpp"
namespace ndn {
namespace nfd {
/**
* \ingroup management
* \brief represents NFD General Status dataset
* \sa https://redmine.named-data.net/projects/nfd/wiki/ForwarderStatus#General-Status-Dataset
*/
class ForwarderStatus
{
public:
class Error : public tlv::Error
{
public:
explicit
Error(const std::string& what)
: tlv::Error(what)
{
}
};
ForwarderStatus();
explicit
ForwarderStatus(const Block& payload);
/** \brief prepend ForwarderStatus as a Content block to the encoder
*
* The outermost Content element isn't part of ForwarderStatus structure.
*/
template<encoding::Tag TAG>
size_t
wireEncode(EncodingImpl<TAG>& encoder) const;
/** \brief encode ForwarderStatus as a Content block
*
* The outermost Content element isn't part of ForwarderStatus structure.
*/
const Block&
wireEncode() const;
/** \brief decode ForwarderStatus from a Content block
*
* The outermost Content element isn't part of ForwarderStatus structure.
*/
void
wireDecode(const Block& wire);
public: // getters & setters
const std::string&
getNfdVersion() const
{
return m_nfdVersion;
}
ForwarderStatus&
setNfdVersion(const std::string& nfdVersion);
const time::system_clock::TimePoint&
getStartTimestamp() const
{
return m_startTimestamp;
}
ForwarderStatus&
setStartTimestamp(const time::system_clock::TimePoint& startTimestamp);
const time::system_clock::TimePoint&
getCurrentTimestamp() const
{
return m_currentTimestamp;
}
ForwarderStatus&
setCurrentTimestamp(const time::system_clock::TimePoint& currentTimestamp);
size_t
getNNameTreeEntries() const
{
return m_nNameTreeEntries;
}
ForwarderStatus&
setNNameTreeEntries(size_t nNameTreeEntries);
size_t
getNFibEntries() const
{
return m_nFibEntries;
}
ForwarderStatus&
setNFibEntries(size_t nFibEntries);
size_t
getNPitEntries() const
{
return m_nPitEntries;
}
ForwarderStatus&
setNPitEntries(size_t nPitEntries);
size_t
getNMeasurementsEntries() const
{
return m_nMeasurementsEntries;
}
ForwarderStatus&
setNMeasurementsEntries(size_t nMeasurementsEntries);
size_t
getNCsEntries() const
{
return m_nCsEntries;
}
ForwarderStatus&
setNCsEntries(size_t nCsEntries);
uint64_t
getNInInterests() const
{
return m_nInInterests;
}
ForwarderStatus&
setNInInterests(uint64_t nInInterests);
uint64_t
getNInData() const
{
return m_nInData;
}
ForwarderStatus&
setNInData(uint64_t nInData);
uint64_t
getNInNacks() const
{
return m_nInNacks;
}
ForwarderStatus&
setNInNacks(uint64_t nInNacks);
uint64_t
getNOutInterests() const
{
return m_nOutInterests;
}
ForwarderStatus&
setNOutInterests(uint64_t nOutInterests);
uint64_t
getNOutData() const
{
return m_nOutData;
}
ForwarderStatus&
setNOutData(uint64_t nOutData);
uint64_t
getNOutNacks() const
{
return m_nOutNacks;
}
ForwarderStatus&
setNOutNacks(uint64_t nOutNacks);
private:
std::string m_nfdVersion;
time::system_clock::TimePoint m_startTimestamp;
time::system_clock::TimePoint m_currentTimestamp;
size_t m_nNameTreeEntries;
size_t m_nFibEntries;
size_t m_nPitEntries;
size_t m_nMeasurementsEntries;
size_t m_nCsEntries;
uint64_t m_nInInterests;
uint64_t m_nInData;
uint64_t m_nInNacks;
uint64_t m_nOutInterests;
uint64_t m_nOutData;
uint64_t m_nOutNacks;
mutable Block m_wire;
};
NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS(ForwarderStatus);
bool
operator==(const ForwarderStatus& a, const ForwarderStatus& b);
inline bool
operator!=(const ForwarderStatus& a, const ForwarderStatus& b)
{
return !(a == b);
}
std::ostream&
operator<<(std::ostream& os, const ForwarderStatus& status);
} // namespace nfd
} // namespace ndn
#endif // NDN_MGMT_NFD_FORWARDER_STATUS_HPP
| 21.3
| 94
| 0.730243
|
alvyC
|
d49785c624ce4f7e8d5b88b8429f87a36083d462
| 7,107
|
cpp
|
C++
|
PineApple/Implment/StrFormat.cpp
|
BleedingChips/PineApple
|
1133d40e93eb3bbad0bde8697f7e8002649c833d
|
[
"MIT"
] | null | null | null |
PineApple/Implment/StrFormat.cpp
|
BleedingChips/PineApple
|
1133d40e93eb3bbad0bde8697f7e8002649c833d
|
[
"MIT"
] | null | null | null |
PineApple/Implment/StrFormat.cpp
|
BleedingChips/PineApple
|
1133d40e93eb3bbad0bde8697f7e8002649c833d
|
[
"MIT"
] | null | null | null |
#include "../Interface/StrFormat.h"
#include "../Interface/Nfa.h"
#include "../Interface/CharEncode.h"
namespace PineApple::StrFormat
{
static std::u32string_view PatternRex[] = {
UR"([^\{\}]+)",
UR"(\{\{)",
UR"(\}\})",
UR"(\{[^\{]*?\})",
};
static Nfa::Table table = Nfa::CreateTableFromRex(PatternRex, 4);
PatternRef CreatePatternRef(std::u32string_view Ref)
{
try {
auto Result = Nfa::Process(table, Ref);
std::vector<PatternRef::Element> patterns;
for (auto& ite : Result)
{
switch (ite.acception)
{
case 0: {
patterns.push_back({ PatternType::NormalString, ite.capture });
} break;
case 1: {
patterns.push_back({ PatternType::LeftBrace, ite.capture });
} break;
case 2: {
patterns.push_back({ PatternType::RightBrace, ite.capture });
} break;
case 3: {
patterns.push_back({ PatternType::Parameter, {ite.capture.data() + 1, ite.capture.size() - 2} });
} break;
default: assert(false);
}
}
return { std::move(patterns) };
}
catch (Nfa::Error::UnaccaptableString const& str)
{
throw Error::UnsupportPatternString{str.TotalString};
}
}
namespace Implement
{
std::tuple<size_t, size_t> LocateParmeters(PatternRef const& pattern, size_t pattern_index)
{
size_t Sum = 0;
for (; pattern_index < pattern.patterns.size(); ++pattern_index)
{
auto& [Type, str] = pattern.patterns[pattern_index];
switch (Type)
{
case PatternType::NormalString: {Sum += str.size(); } break;
case PatternType::RightBrace: {Sum += 1;} break;
case PatternType::LeftBrace: {Sum += 1; } break;
case PatternType::Parameter: {return { pattern_index, Sum}; } break;
default:
break;
}
}
return { pattern_index, Sum};
}
size_t FormatImp(PatternRef const& pattern, size_t pattern_index, std::vector<std::u32string>& output)
{
auto [PIndex, Sum] = LocateParmeters(pattern, pattern_index);
if (PIndex < pattern.patterns.size())
throw Error::LackOfFormatParas{ ExceptionLink(pattern) };
return Sum;
}
std::u32string Link(size_t require_space, PatternRef const& pattern, std::vector<std::u32string>& output)
{
std::u32string Result;
Result.resize(require_space);
size_t Sum = 0;
size_t ParasUsed = 0;
for (auto& ite : pattern.patterns)
{
auto [type, str] = ite;
switch (type)
{
case PatternType::NormalString:
assert(Sum + str.size()<= require_space);
std::memcpy(Result.data() + Sum, str.data(), str.size() * sizeof(char32_t));
Sum += str.size();
break;
case PatternType::Parameter:
if (ParasUsed < output.size())
{
auto& Str = output[ParasUsed++];
assert(Sum + Str.size() <= require_space);
std::memcpy(Result.data() + Sum, Str.data(), Str.size() * sizeof(char32_t));
Sum += Str.size();
}
else {
assert(false);
}
break;
case PatternType::LeftBrace:
assert(Sum + 1 <= require_space);
Result[Sum++] = U'{';
break;
case PatternType::RightBrace:
assert(Sum + 1 <= require_space);
Result[Sum++] = U'}';
break;
default:
assert(false);
break;
}
}
return std::move(Result);
}
std::u32string ExceptionLink(PatternRef const& pattern)
{
size_t size = 0;
for (auto [type, str] : pattern.patterns)
{
switch (type)
{
case PatternType::NormalString:
size += str.size();
break;
case PatternType::LeftBrace:
case PatternType::Parameter:
case PatternType::RightBrace:
size += 2;
break;
default:
assert(false);
break;
}
}
std::u32string Resource;
Resource.reserve(size);
for (auto [type, str] : pattern.patterns)
{
switch (type)
{
case PatternType::NormalString:
Resource += str;
break;
case PatternType::Parameter:
Resource += U"{}";
break;
case PatternType::LeftBrace:
Resource += U"{{";
break;
case PatternType::RightBrace:
Resource += U"}}";
break;
default:
assert(false);
break;
}
}
return Resource;
}
}
}
namespace PineApple::StrFormat
{
static std::u32string_view FormatRex[] = {
UR"(\s)",
UR"(-hex)",
//UR"(-e)"
};
static Nfa::Table FormatTable = Nfa::CreateTableFromRexReversal(FormatRex, 2);
struct Paras
{
bool IsHex = false;
};
Paras ParasTranslate(std::u32string_view Code)
{
Paras Result;
//std::optional<std::string> size_require;
auto Re = Nfa::Process(FormatTable, Code);
for (auto& ite : Re)
{
switch (ite.acception)
{
case 0: {} break;
case 1: {Result.IsHex = true; } break;
//case 2: {IsE = true; } break;
//case 3: {size_require = Encoding::EncodingWrapper<char32_t>({ ite.capture.data() + 1, ite.capture.size() - 1 }).To<char>();} break;
default:
break;
}
}
return Result;
}
std::u32string Formatter<char32_t*>::operator()(std::u32string_view par, char32_t const* Input) { return std::u32string(Input); }
std::u32string Formatter<std::u32string>::operator()(std::u32string_view par, std::u32string Input) { return std::move(Input); }
std::u32string Formatter<float>::operator()(std::u32string_view par, float input) {
char Buffer[100];
size_t t = sprintf_s(Buffer, 100, "%f", input);
return CharEncode::Wrapper<char>(std::string_view{Buffer, t}).To<char32_t>();
}
std::u32string Formatter<double>::operator()(std::u32string_view par, double input) {
char Buffer[100];
size_t t = sprintf_s(Buffer, 100, "%lf", input);
return CharEncode::Wrapper<char>(std::string_view{ Buffer, t }).To<char32_t>();
}
std::u32string Formatter<uint32_t>::operator()(std::u32string_view par, uint32_t input) {
Paras state = ParasTranslate(par);
char const* TarString = nullptr;
if (state.IsHex)
TarString = "%I32x";
else
TarString = "%I32u";
char Buffer[100];
size_t t = sprintf_s(Buffer, 100, TarString, input);
return CharEncode::Wrapper<char>(std::string_view{ Buffer, t }).To<char32_t>();
}
std::u32string Formatter<int32_t>::operator()(std::u32string_view par, int32_t input) {
//Paras state = ParasTranslate(par);
char const* TarString = nullptr;
TarString = "%I32d";
char Buffer[100];
size_t t = sprintf_s(Buffer, 100, TarString, input);
return CharEncode::Wrapper<char>(std::string_view{ Buffer, t }).To<char32_t>();
}
std::u32string Formatter<uint64_t>::operator()(std::u32string_view par, uint64_t input) {
Paras state = ParasTranslate(par);
char const* TarString = nullptr;
if (state.IsHex)
TarString = "%I64x";
else
TarString = "%I64u";
char Buffer[100];
size_t t = sprintf_s(Buffer, 100, TarString, input);
return CharEncode::Wrapper<char>(std::string_view{ Buffer, t }).To<char32_t>();
}
std::u32string Formatter<int64_t>::operator()(std::u32string_view par, int64_t input) {
//Paras state = ParasTranslate(par);
char const* TarString = nullptr;
TarString = "%I64d";
char Buffer[100];
size_t t = sprintf_s(Buffer, 100, TarString, input);
return CharEncode::Wrapper<char>(std::string_view{ Buffer, t }).To<char32_t>();
}
}
| 27.761719
| 136
| 0.638525
|
BleedingChips
|
d4988c9dd0bdd35136e8902ce052e10cffa63e3d
| 3,267
|
cpp
|
C++
|
src/MirkoInterface.cpp
|
stephan2nd/cpp-accelerator-toolkit
|
1c82f87b50199ec216a0d8968ed320fa9a52c48f
|
[
"MIT"
] | null | null | null |
src/MirkoInterface.cpp
|
stephan2nd/cpp-accelerator-toolkit
|
1c82f87b50199ec216a0d8968ed320fa9a52c48f
|
[
"MIT"
] | null | null | null |
src/MirkoInterface.cpp
|
stephan2nd/cpp-accelerator-toolkit
|
1c82f87b50199ec216a0d8968ed320fa9a52c48f
|
[
"MIT"
] | null | null | null |
#include "MirkoInterface.hpp"
#include "DriftTube.hpp"
#include "QuadrupoleMagnet.hpp"
#include "Screen.hpp"
#include "HKick.hpp"
#include "VKick.hpp"
#include "RectangularDipoleMagnet.hpp"
#include <sstream>
#include <fstream>
#include <cmath>
MirkoInterface::MirkoInterface() :
m_devices()
{ }
MirkoInterface::~MirkoInterface()
{ }
string
MirkoInterface::toString(unsigned int indent) const
{
string indention = "";
for( unsigned int i=0; i<indent; i++ ){
indention = indention + "\t";
}
stringstream ss;
ss << indention << toLine();
return ss.str();
}
string
MirkoInterface::toLine(void) const
{
return "MirkoInterface";
}
ostream&
operator<<(ostream& os, const MirkoInterface& mirkoInterface)
{
return os << mirkoInterface.toLine();
}
void
MirkoInterface::readMixFile(const string& filename)
{
const unsigned int STATE_UNKNOWN = 0;
const unsigned int STATE_DEVICES = 1;
unsigned int state = STATE_UNKNOWN;
ifstream file(filename);
string line;
while( std::getline(file, line) )
{
if( line.substr(0, 1) == "!" ){
;
} else if( line.substr(0, 1) == "$" ){
if( line.substr(0, 9) == "$ELEMENTE" ){
state = STATE_DEVICES;
} else {
state = STATE_UNKNOWN;
}
} else if( state == STATE_DEVICES ){
parseDeviceFromMixFileLine(line);
}
}
}
void
MirkoInterface::parseDeviceFromMixFileLine(const string& line)
{
string name = line.substr(3,16);
int vcode = 0;
int type = 0;
int sub = 1;
double arg1 = 0.0;
double arg2= 0.0;
double arg3 = 0.0;
double arg4 = 0.0;
try{
vcode = stoi(line.substr(19,4));
} catch( exception& e){
vcode = 0;
}
try{
type = stoi(line.substr(23,4));
} catch( exception& e){
type = 0;
cout << __FILE__ << " line " << __LINE__ << ": cannot parse type \"" << line.substr(23,4) << "\" to int, " << e.what() << endl;
}
try{
sub = stoi(line.substr(27,4));
} catch( exception& e){
sub = 1;
}
try{
arg1 = stod(line.substr(31,17));
} catch( exception& e){
arg1 = 0.0;
}
try{
arg2 = stod(line.substr(48,17));
} catch( exception& e){
arg2 = 0.0;
}
try{
arg3 = stod(line.substr(65,12));
} catch( exception& e){
arg3 = 0.0;
}
try{
arg4 = stod(line.substr(77,12));
} catch( exception& e){
arg4 = 0.0;
}
addDevice(name, vcode, type, sub, arg1, arg2, arg3, arg4);
}
void
MirkoInterface::addDevice(const string& name, int vcode, int type, int sub, double arg1, double arg2, double arg3, double arg4)
{
switch (type){
case 2:
m_devices.push_back( new DriftTube(name, 0.2, 0.2, arg1) );
break;
case 3:
m_devices.push_back( new QuadrupoleMagnet(name, arg3, arg4, arg1, 1000000*arg2*arg2) );
break;
case 5:
m_devices.push_back( new RectangularDipoleMagnet(name, arg3, arg4, arg2 * M_PI * arg1/180., M_PI * arg1/180.) );
break;
case 21:
m_devices.push_back( new HKick(name, arg1) );
break;
case 22:
m_devices.push_back( new VKick(name, arg1) );
break;
case 29:
m_devices.push_back( new Screen(name, 0.2, 0.2) );
break;
case 30:
break;
default:
cout << "MirkoInterface, unkown device type " << type << ". skipped!" << endl;
}
}
vector<Device*>
MirkoInterface::getDevices() const
{
return m_devices;
}
| 17.852459
| 129
| 0.628099
|
stephan2nd
|
d49e38623b5d6e90c87c2688271bcf77c07f9954
| 557
|
cpp
|
C++
|
Userland/Libraries/LibC/sys/statvfs.cpp
|
r00ster91/serenity
|
f8387dea2689d564aff612bfd4ec5086393fac35
|
[
"BSD-2-Clause"
] | 19,438
|
2019-05-20T15:11:11.000Z
|
2022-03-31T23:31:32.000Z
|
Userland/Libraries/LibC/sys/statvfs.cpp
|
r00ster91/serenity
|
f8387dea2689d564aff612bfd4ec5086393fac35
|
[
"BSD-2-Clause"
] | 7,882
|
2019-05-20T01:03:52.000Z
|
2022-03-31T23:26:31.000Z
|
Userland/Libraries/LibC/sys/statvfs.cpp
|
r00ster91/serenity
|
f8387dea2689d564aff612bfd4ec5086393fac35
|
[
"BSD-2-Clause"
] | 2,721
|
2019-05-23T00:44:57.000Z
|
2022-03-31T22:49:34.000Z
|
/*
* Copyright (c) 2021, Justin Mietzner <sw1tchbl4d3@sw1tchbl4d3.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <errno.h>
#include <string.h>
#include <sys/statvfs.h>
#include <syscall.h>
extern "C" {
int statvfs(const char* path, struct statvfs* buf)
{
Syscall::SC_statvfs_params params { { path, strlen(path) }, buf };
int rc = syscall(SC_statvfs, ¶ms);
__RETURN_WITH_ERRNO(rc, rc, -1);
}
int fstatvfs(int fd, struct statvfs* buf)
{
int rc = syscall(SC_fstatvfs, fd, buf);
__RETURN_WITH_ERRNO(rc, rc, -1);
}
}
| 20.62963
| 70
| 0.669659
|
r00ster91
|
d49fd5316b7717073e4885c3b434b6ccb590196c
| 11,669
|
hpp
|
C++
|
control/zone.hpp
|
msbarth/phosphor-fan-presence
|
9f5330e691ae2baa4c26fff8c828dcfcb04d5be8
|
[
"Apache-2.0"
] | null | null | null |
control/zone.hpp
|
msbarth/phosphor-fan-presence
|
9f5330e691ae2baa4c26fff8c828dcfcb04d5be8
|
[
"Apache-2.0"
] | null | null | null |
control/zone.hpp
|
msbarth/phosphor-fan-presence
|
9f5330e691ae2baa4c26fff8c828dcfcb04d5be8
|
[
"Apache-2.0"
] | 1
|
2017-02-14T01:46:05.000Z
|
2017-02-14T01:46:05.000Z
|
#pragma once
#include <chrono>
#include <vector>
#include <algorithm>
#include <sdbusplus/bus.hpp>
#include "fan.hpp"
#include "types.hpp"
#include "timer.hpp"
namespace phosphor
{
namespace fan
{
namespace control
{
/**
* The mode fan control will run in:
* - init - only do the initialization steps
* - control - run normal control algorithms
*/
enum class Mode
{
init,
control
};
/**
* @class Represents a fan control zone, which is a group of fans
* that behave the same.
*/
class Zone
{
public:
Zone() = delete;
Zone(const Zone&) = delete;
Zone(Zone&&) = default;
Zone& operator=(const Zone&) = delete;
Zone& operator=(Zone&&) = delete;
~Zone() = default;
/**
* Constructor
* Creates the appropriate fan objects based on
* the zone definition data passed in.
*
* @param[in] mode - mode of fan control
* @param[in] bus - the dbus object
* @param[in] events - sd_event pointer
* @param[in] def - the fan zone definition data
*/
Zone(Mode mode,
sdbusplus::bus::bus& bus,
phosphor::fan::event::EventPtr& events,
const ZoneDefinition& def);
/**
* Sets all fans in the zone to the speed
* passed in when the zone is active
*
* @param[in] speed - the fan speed
*/
void setSpeed(uint64_t speed);
/**
* Sets the zone to full speed regardless of zone's active state
*/
void setFullSpeed();
/**
* @brief Sets the automatic fan control allowed active state
*
* @param[in] group - A group that affects the active state
* @param[in] isActiveAllow - Active state according to group
*/
void setActiveAllow(const Group* group, bool isActiveAllow);
/**
* @brief Sets a given object's property value
*
* @param[in] object - Name of the object containing the property
* @param[in] interface - Interface name containing the property
* @param[in] property - Property name
* @param[in] value - Property value
*/
template <typename T>
void setPropertyValue(const char* object,
const char* interface,
const char* property,
T value)
{
_properties[object][interface][property] = value;
};
/**
* @brief Get the value of an object's property
*
* @param[in] object - Name of the object containing the property
* @param[in] interface - Interface name containing the property
* @param[in] property - Property name
*
* @return - The property value
*/
template <typename T>
inline auto getPropertyValue(const std::string& object,
const std::string& interface,
const std::string& property)
{
return sdbusplus::message::variant_ns::get<T>(
_properties.at(object).at(interface).at(property));
};
/**
* @brief Get the object's property variant
*
* @param[in] object - Name of the object containing the property
* @param[in] interface - Interface name containing the property
* @param[in] property - Property name
*
* @return - The property variant
*/
inline auto getPropValueVariant(const std::string& object,
const std::string& interface,
const std::string& property)
{
return _properties.at(object).at(interface).at(property);
};
/**
* @brief Initialize a set speed event properties and actions
*
* @param[in] event - Set speed event
*/
void initEvent(const SetSpeedEvent& event);
/**
* @brief Removes all the set speed event properties and actions
*
* @param[in] event - Set speed event
*/
void removeEvent(const SetSpeedEvent& event);
/**
* @brief Get the default floor speed
*
* @return - The defined default floor speed
*/
inline auto getDefFloor()
{
return _defFloorSpeed;
};
/**
* @brief Get the ceiling speed
*
* @return - The current ceiling speed
*/
inline auto& getCeiling() const
{
return _ceilingSpeed;
};
/**
* @brief Set the ceiling speed to the given speed
*
* @param[in] speed - Speed to set the ceiling to
*/
inline void setCeiling(uint64_t speed)
{
_ceilingSpeed = speed;
};
/**
* @brief Swaps the ceiling key value with what's given and
* returns the value that was swapped.
*
* @param[in] keyValue - New ceiling key value
*
* @return - Ceiling key value prior to swapping
*/
inline auto swapCeilingKeyValue(int64_t keyValue)
{
std::swap(_ceilingKeyValue, keyValue);
return keyValue;
};
/**
* @brief Get the increase speed delta
*
* @return - The current increase speed delta
*/
inline auto getIncSpeedDelta() const
{
return _incSpeedDelta;
};
/**
* @brief Get the decrease speed delta
*
* @return - The current decrease speed delta
*/
inline auto getDecSpeedDelta() const
{
return _decSpeedDelta;
};
/**
* @brief Set the floor speed to the given speed and increase target
* speed to the floor when target is below floor.
*
* @param[in] speed - Speed to set the floor to
*/
void setFloor(uint64_t speed);
/**
* @brief Calculate the requested target speed from the given delta
* and increase the fan speeds, not going above the ceiling.
*
* @param[in] targetDelta - The delta to increase the target speed by
*/
void requestSpeedIncrease(uint64_t targetDelta);
/**
* @brief Calculate the requested target speed from the given delta
* and increase the fan speeds, not going above the ceiling.
*
* @param[in] targetDelta - The delta to increase the target speed by
*/
void requestSpeedDecrease(uint64_t targetDelta);
/**
* @brief Callback function for the increase timer that delays
* processing of requested speed increases while fans are increasing
*/
void incTimerExpired();
/**
* @brief Callback function for the decrease timer that processes any
* requested speed decreases if allowed
*/
void decTimerExpired();
/**
* @brief Callback function for event timers that processes the given
* action for a group
*
* @param[in] eventGroup - Group to process action on
* @param[in] eventAction - Event action to run
*/
void timerExpired(Group eventGroup, std::vector<Action> eventActions);
private:
/**
* The dbus object
*/
sdbusplus::bus::bus& _bus;
/**
* Full speed for the zone
*/
const uint64_t _fullSpeed;
/**
* The zone number
*/
const size_t _zoneNum;
/**
* The default floor speed for the zone
*/
const uint64_t _defFloorSpeed;
/**
* The default ceiling speed for the zone
*/
const uint64_t _defCeilingSpeed;
/**
* The floor speed to not go below
*/
uint64_t _floorSpeed = _defFloorSpeed;
/**
* The ceiling speed to not go above
*/
uint64_t _ceilingSpeed = _defCeilingSpeed;
/**
* The previous sensor value for calculating the ceiling
*/
int64_t _ceilingKeyValue = 0;
/**
* Automatic fan control active state
*/
bool _isActive = true;
/**
* Target speed for this zone
*/
uint64_t _targetSpeed = _fullSpeed;
/**
* Speed increase delta
*/
uint64_t _incSpeedDelta = 0;
/**
* Speed decrease delta
*/
uint64_t _decSpeedDelta = 0;
/**
* Speed increase delay in seconds
*/
std::chrono::seconds _incDelay;
/**
* Speed decrease interval in seconds
*/
std::chrono::seconds _decInterval;
/**
* The increase timer object
*/
phosphor::fan::util::Timer _incTimer;
/**
* The decrease timer object
*/
phosphor::fan::util::Timer _decTimer;
/**
* Dbus event used on set speed event timers
*/
phosphor::fan::event::EventPtr& _sdEvents;
/**
* The vector of fans in this zone
*/
std::vector<std::unique_ptr<Fan>> _fans;
/**
* @brief Map of object property values
*/
std::map<std::string,
std::map<std::string,
std::map<std::string,
PropertyVariantType>>> _properties;
/**
* @brief Map of active fan control allowed by groups
*/
std::map<const Group, bool> _active;
/**
* @brief List of signal event arguments and Dbus matches for callbacks
*/
std::vector<SignalEvent> _signalEvents;
/**
* @brief List of timers for events
*/
std::vector<std::unique_ptr<phosphor::fan::util::Timer>> _timerEvents;
/**
* @brief Refresh the given property's cached value
*
* @param[in] bus - the bus to use
* @param[in] path - the dbus path name
* @param[in] iface - the dbus interface name
* @param[in] prop - the property name
*/
void refreshProperty(sdbusplus::bus::bus& bus,
const std::string& path,
const std::string& iface,
const std::string& prop);
/**
* @brief Get a property value from the path/interface given
*
* @param[in] bus - the bus to use
* @param[in] path - the dbus path name
* @param[in] iface - the dbus interface name
* @param[in] prop - the property name
* @param[out] value - the value of the property
*/
static void getProperty(sdbusplus::bus::bus& bus,
const std::string& path,
const std::string& iface,
const std::string& prop,
PropertyVariantType& value);
/**
* @brief Dbus signal change callback handler
*
* @param[in] msg - Expanded sdbusplus message data
* @param[in] eventData - The single event's data
*/
void handleEvent(sdbusplus::message::message& msg,
const EventData* eventData);
};
}
}
}
| 28.530562
| 79
| 0.520439
|
msbarth
|
d4a3962642aa1fe238a3adba316f0ea1a6b559cd
| 1,513
|
cpp
|
C++
|
SPOJ/SPOJ Easy Longest Increasing Subsequence.cpp
|
akash246/Competitive-Programming-Solutions
|
68db69ba8a771a433e5338bc4e837a02d3f89823
|
[
"MIT"
] | 28
|
2017-11-08T11:52:11.000Z
|
2021-07-16T06:30:02.000Z
|
SPOJ/SPOJ Easy Longest Increasing Subsequence.cpp
|
akash246/Competitive-Programming-Solutions
|
68db69ba8a771a433e5338bc4e837a02d3f89823
|
[
"MIT"
] | null | null | null |
SPOJ/SPOJ Easy Longest Increasing Subsequence.cpp
|
akash246/Competitive-Programming-Solutions
|
68db69ba8a771a433e5338bc4e837a02d3f89823
|
[
"MIT"
] | 30
|
2017-09-01T09:14:27.000Z
|
2021-04-12T12:08:56.000Z
|
//#Name: Sofen Hoque Anonta #Problm:
#include <bits/stdc++.h>
using namespace std;
//FOLD ME
namespace{
typedef long long LL;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef unsigned long long ULL;
//Macros
int CC_;
#define sf scanf
#define pf printf
#define PP cin.get();
#define NL cout<<endl;
#define all(container) container.begin(),container.end()
#define DC(x_) cout<<">>> "<<#x_<<"\n";DA(x_.begin(), x_.end());
#define DD(x_) cout<<">>>>( "<<++CC_<<" ) "<<#x_<<": "<<x_<<endl;
#define SS printf(">_<LOOOOOK@MEEEEEEEEEEEEEEE<<( %d )>>\n",++CC_);
#define EXT(st_) cout<<"\n>>>Exicution Time: "<<(double)(clock()-st_)/CLOCKS_PER_SEC<<endl;
#define DM(MT,n_,m_)pf("Matrix %s:\n ", #MT);for(int i_= 0;i_<m_;i_++)pf("%4d ", i_);NL;NL;for(int r_=0;r_<n_;r_++){pf("%2d ", r_);for(int c_= 0;c_<m_;c_++)pf("%4d ", MT[r_][c_]);NL}
#define mem(a_,b_)(a_, b_, sizeof(a_));
//constants
const double EPS= 1E-9;
const double PI= 2*acos(0.0);
const long long MOD= 1000000007;
}
const int sss= 1E6;
int a[21];
int N;
int MX= 0;
int lis(int x, int s, int prev){
if(x < 0) return s;
int p= lis(x-1, s, prev);
int q= 0;
if(a[x] < prev) q= lis(x-1, s+1, a[x]);
return max(p,q);
}
void solve(void){
int n;
cin>>n;
N= n;
for(int i=0; i<n; i++)cin>>a[i];
cout<< lis(n-1, 0, INT_MAX) <<endl;
}
int main(void){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
// freopen("D:/input.txt", "r", stdin);
solve();
return 0;
}
| 21.927536
| 184
| 0.582287
|
akash246
|
d4ac17c9e7fc0c91a40fff2d3328d669baa8a7f1
| 3,222
|
cpp
|
C++
|
src/main.cpp
|
ThorNielsen/loxint
|
a5456afad37f22973e2b1292aff0276ac2c6fcdd
|
[
"MIT"
] | 7
|
2018-03-09T10:10:39.000Z
|
2021-12-23T07:19:39.000Z
|
src/main.cpp
|
ThorNielsen/loxint
|
a5456afad37f22973e2b1292aff0276ac2c6fcdd
|
[
"MIT"
] | 1
|
2021-12-23T07:19:29.000Z
|
2021-12-23T07:19:29.000Z
|
src/main.cpp
|
ThorNielsen/loxint
|
a5456afad37f22973e2b1292aff0276ac2c6fcdd
|
[
"MIT"
] | 1
|
2019-06-09T21:00:46.000Z
|
2019-06-09T21:00:46.000Z
|
#include <iostream>
#include <fstream>
#include <string>
#include <stdexcept>
#include "lexer.hpp"
#include "resolver.hpp"
#include "astprinter.hpp"
#include "parser.hpp"
#include "interpreter.hpp"
int run(Interpreter& interpreter, std::string source, bool repl = false)
{
try
{
Parser p;
Lexer lex;
auto stmts = p.parse(lex.scanTokens(source), repl);
if (p.hadError())
{
if (p.continuable())
{
return 1;
}
return 2;
}
/*ASTPrinter printer;
for (auto& stmt : stmts)
{
printer.print(stmt.get());
}*/
Resolver r;
if (!r.resolve(stmts, interpreter))
{
return 4;
}
interpreter.interpret(std::move(stmts));
return 0;
}
catch (LoxError err)
{
if (repl) return 3;
throw;
}
}
bool isspace(std::string s)
{
for (auto& c : s)
{
switch(c)
{
case '\n': case '\r': case '\t': case ' ':
break;
default:
return false;
}
}
return true;
}
void runPrompt()
{
Interpreter interpreter;
std::string prevCode = "";
while (std::cin.good())
{
if (!isspace(prevCode)) std::cout << ". ";
else std::cout << "> ";
std::string line;
std::getline(std::cin, line, '\n');
// If the user wants to stop appending code to previous code, they enter
// a blank line (one consisting entirely of whitespace) in which case we
// want to show them all errors in the previous code.
if (isspace(line) && !isspace(prevCode))
{
run(interpreter, prevCode, false);
prevCode = "";
continue;
}
if (run(interpreter, prevCode+line, true) == 1)
{
prevCode += (prevCode.empty() ? "" : "\n") + line;
}
else
{
prevCode = "";
}
}
}
bool runFile(std::string path)
{
std::ifstream in(path);
if (!in.is_open())
{
throw std::runtime_error("Couldn't open " + path);
}
std::string code;
auto start = in.tellg();
in.seekg(std::ios::beg, std::ios::end);
auto end = in.tellg();
in.seekg(std::ios::beg, std::ios::beg);
code.resize(end - start);
in.read(&code[0], end - start);
Interpreter interpreter;
return run(interpreter, code) == 0;
}
int main(int argc, char* argv[])
{
if (argc > 2)
{
std::string execName = argv[0];
auto loc = execName.rfind('/');
if (loc == std::string::npos)
{
loc = execName.rfind('\\');
if (loc == std::string::npos)
{
loc = 0;
}
else
{
++loc;
}
}
else
{
++loc;
}
std::cout << "Usage: " + execName.substr(loc) + " [file]" << std::endl;
return 1;
}
else if (argc == 2)
{
return runFile(argv[1]) ? 0 : 'm'^'a'^'g'^'i'^'c';
}
else
{
runPrompt();
return 0;
}
}
| 21.337748
| 80
| 0.463377
|
ThorNielsen
|
d4b3ba2ae4316a10d30d66c346a077b9734a5768
| 6,428
|
cpp
|
C++
|
kernel/src/drivers/pci.cpp
|
ArdenyUser/ArdenWareOS
|
e09261093ba469d2291554c026037351bba28ab0
|
[
"MIT"
] | 1,574
|
2015-01-15T16:35:30.000Z
|
2022-03-29T07:27:49.000Z
|
kernel/src/drivers/pci.cpp
|
bgwilf/thor-os
|
2dc0fef72595598aff7e5f950809042104f29b48
|
[
"MIT"
] | 43
|
2016-08-23T16:22:29.000Z
|
2022-03-09T10:28:05.000Z
|
kernel/src/drivers/pci.cpp
|
bgwilf/thor-os
|
2dc0fef72595598aff7e5f950809042104f29b48
|
[
"MIT"
] | 196
|
2016-02-17T10:52:24.000Z
|
2022-03-28T17:41:29.000Z
|
//=======================================================================
// Copyright Baptiste Wicht 2013-2018.
// Distributed under the terms of the MIT License.
// (See accompanying file LICENSE or copy at
// http://www.opensource.org/licenses/MIT)
//=======================================================================
#include "drivers/pci.hpp"
#include "kernel_utils.hpp"
#include "logging.hpp"
#include "fs/sysfs.hpp"
namespace {
std::vector<pci::device_descriptor> devices;
#define PCI_CONFIG_ADDRESS 0xCF8
#define PCI_CONFIG_DATA 0xCFC
uint16_t get_vendor_id(uint8_t bus, uint8_t device, uint8_t function){
// read "device id | vendor id"
auto large = pci::read_config_dword(bus, device, function, 0);
// extract vendor id
return large;
}
uint16_t get_device_id(uint8_t bus, uint8_t device, uint8_t function){
// read "device id | vendor id"
auto large = pci::read_config_dword(bus, device, function, 0);
// extract device id
return large >> 16;
}
uint8_t get_class_code(uint8_t bus, uint8_t device, uint8_t function){
// read "class code | subclass | prog if | revision id"
auto large = pci::read_config_dword(bus, device, function, 8);
// extract class code only
return large >> 24 & 0xFF;
}
uint8_t get_subclass(uint8_t bus, uint8_t device, uint8_t function){
// read "class code | subclass | prog if | revision id"
auto large = pci::read_config_dword(bus, device, function, 8);
// extract subclass only
return large >> 16 & 0xFF;
}
uint8_t get_header_type(uint8_t bus, uint8_t device, uint8_t function){
// read "BIST | header type | latency timer | cache line size"
auto large = pci::read_config_dword(bus, device, function, 12);
// extract header type only
return large >> 16 & 0xFF;
}
void check_function(uint8_t bus, uint8_t device, uint8_t function){
auto vendor_id = get_vendor_id(bus, device, function);
if(vendor_id == 0xFFFF) {
return;
}
auto device_id = get_device_id(bus, device, function);
auto class_code = get_class_code(bus, device, function);
auto sub_class = get_subclass(bus, device, function);
logging::logf(logging::log_level::DEBUG, "Found device pci:%u:%u:%u (vendor:%u class:%u subclass:%u) \n",
uint64_t(bus), uint64_t(device), uint64_t(function), uint64_t(vendor_id), uint64_t(class_code), uint64_t(sub_class));
auto& device_desc = devices.emplace_back();
device_desc.bus = bus;
device_desc.device = device;
device_desc.function = function;
device_desc.vendor_id = vendor_id;
device_desc.device_id = device_id;
device_desc.class_code = class_code;
device_desc.sub_class = sub_class;
if (class_code < static_cast<uint8_t>(pci::device_class_type::RESERVED)) {
device_desc.class_type = static_cast<pci::device_class_type>(class_code);
} else if (class_code < static_cast<uint8_t>(pci::device_class_type::UNKNOWN)) {
device_desc.class_type = pci::device_class_type::RESERVED;
} else {
device_desc.class_type = pci::device_class_type::UNKNOWN;
}
std::string pci_name = "pci:" + std::to_string(bus) + ':' + std::to_string(device) + ':' + std::to_string(function);
auto p = path("/pci") / pci_name;
sysfs::set_constant_value(sysfs::get_sys_path(), p / "vendor", std::to_string(vendor_id));
sysfs::set_constant_value(sysfs::get_sys_path(), p / "device", std::to_string(device_id));
sysfs::set_constant_value(sysfs::get_sys_path(), p / "class", std::to_string(class_code));
sysfs::set_constant_value(sysfs::get_sys_path(), p / "subclass", std::to_string(sub_class));
}
void check_device(uint8_t bus, uint8_t device) {
check_function(bus, device, 0);
auto header_type = get_header_type(bus, device, 0);
if((header_type & 0x80) != 0){
for(uint8_t function = 1; function < 8; ++function){
check_function(bus, device, function);
}
}
}
void brute_force_check_all_buses(){
for(uint16_t bus = 0; bus < 256; ++bus) {
for(uint8_t device = 0; device < 32; ++device) {
check_device(bus, device);
}
}
}
} //end of anonymous namespace
void pci::detect_devices(){
brute_force_check_all_buses();
}
size_t pci::number_of_devices(){
return devices.size();
}
pci::device_descriptor& pci::device(size_t index){
return devices[index];
}
uint8_t pci::read_config_byte(uint8_t bus, uint8_t device, uint8_t function, uint8_t offset){
auto value = read_config_dword(bus, device, function, offset);
return (value >> ((offset & 3) * 8)) & 0xff;
}
uint16_t pci::read_config_word(uint8_t bus, uint8_t device, uint8_t function, uint8_t offset){
auto value = read_config_dword(bus, device, function, offset);
return (value >> ((offset & 3) * 8)) & 0xffff;
}
uint32_t pci::read_config_dword(uint8_t bus, uint8_t device, uint8_t function, uint8_t offset){
uint32_t address =
static_cast<uint32_t>(1 << 31) //enabled
| (uint32_t(bus) << 16) //bus number
| (uint32_t(device) << 11) //device number
| (uint32_t(function) << 8) //function number
| ((uint32_t(offset) ) & 0xfc); //Register number
out_dword(PCI_CONFIG_ADDRESS, address);
return in_dword(PCI_CONFIG_DATA);
}
void pci::write_config_byte(uint8_t bus, uint8_t device, uint8_t function, uint8_t offset, uint8_t value){
auto tmp = read_config_dword(bus, device, function, offset);
tmp &= ~(0xff << ((offset & 3) * 8));
tmp |= (value << ((offset & 3) * 8));
write_config_dword(bus, device, function, offset, tmp);
}
void pci::write_config_word(uint8_t bus, uint8_t device, uint8_t function, uint8_t offset, uint16_t value){
auto tmp = read_config_dword(bus, device, function, offset);
tmp &= ~(0xffff << ((offset & 3) * 8));
tmp |= (value << ((offset & 3) * 8));
write_config_dword(bus, device, function, offset, tmp);
}
void pci::write_config_dword (uint8_t bus, uint8_t device, uint8_t function, uint8_t offset, uint32_t value){
uint32_t address =
static_cast<uint32_t>(1 << 31) //enabled
| (uint32_t(bus) << 16) //bus number
| (uint32_t(device) << 11) //device number
| (uint32_t(function) << 8) //function number
| ((uint32_t(offset) ) & 0xfc); //Register number
out_dword(PCI_CONFIG_ADDRESS, address);
out_dword(PCI_CONFIG_DATA, value);
}
| 34.934783
| 125
| 0.660236
|
ArdenyUser
|
d4c5da0c305d13cd514283378584234bcacd26bf
| 18,902
|
cpp
|
C++
|
src/parser/expr.cpp
|
RauliL/snek
|
ad530c0485addaf71fd01469860b83a16d16bf9d
|
[
"BSD-2-Clause"
] | null | null | null |
src/parser/expr.cpp
|
RauliL/snek
|
ad530c0485addaf71fd01469860b83a16d16bf9d
|
[
"BSD-2-Clause"
] | null | null | null |
src/parser/expr.cpp
|
RauliL/snek
|
ad530c0485addaf71fd01469860b83a16d16bf9d
|
[
"BSD-2-Clause"
] | null | null | null |
/*
* Copyright (c) 2020, Rauli Laine
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <snek/ast/expr/binary.hpp>
#include <snek/ast/expr/bool.hpp>
#include <snek/ast/expr/call.hpp>
#include <snek/ast/expr/field.hpp>
#include <snek/ast/expr/float.hpp>
#include <snek/ast/expr/func.hpp>
#include <snek/ast/expr/id.hpp>
#include <snek/ast/expr/int.hpp>
#include <snek/ast/expr/list.hpp>
#include <snek/ast/expr/null.hpp>
#include <snek/ast/expr/record.hpp>
#include <snek/ast/expr/str.hpp>
#include <snek/ast/expr/subscript.hpp>
#include <snek/ast/expr/unary.hpp>
#include <snek/ast/parameter.hpp>
#include <snek/ast/record.hpp>
#include <snek/ast/stmt/block.hpp>
#include <snek/ast/stmt/return.hpp>
#include <snek/parser.hpp>
namespace snek::parser::expr
{
using expr_list_result_type = peelo::result<
std::vector<std::shared_ptr<ast::expr::RValue>>,
Error
>;
static expr_list_result_type
parse_expr_list(
State& state,
const ast::Position& position,
cst::Kind separator,
const std::u32string& what
)
{
std::vector<std::shared_ptr<ast::expr::RValue>> list;
for (;;)
{
if (state.eof())
{
return expr_list_result_type::error({
position,
U"Unterminated " +
what +
U"; Missing " +
cst::to_string(separator)
+ U"."
});
}
else if (state.peek_read(separator))
{
break;
} else {
const auto expr = parse(state);
if (expr)
{
list.push_back(expr.value());
if (!state.peek(cst::Kind::Comma) && !state.peek(separator))
{
return expr_list_result_type::error({
expr.value()->position(),
U"Unterminated " +
what + +
U"; Missing " +
cst::to_string(separator) +
U"."
});
}
state.peek_read(cst::Kind::Comma);
} else {
return expr_list_result_type::error(expr.error());
}
}
}
return expr_list_result_type::ok(list);
}
static result_type
parse_list_expr(State& state)
{
const auto position = state.current++->position();
const auto elements = parse_expr_list(
state,
position,
cst::Kind::RightBracket,
U"list literal"
);
if (!elements)
{
return result_type::error(elements.error());
}
return result_type::ok(std::make_shared<ast::expr::List>(
position,
elements.value()
));
}
static result_type
parse_record_expr(State& state)
{
const auto position = state.current++->position();
ast::expr::Record::container_type fields;
for (;;)
{
if (state.eof())
{
return result_type::error({
position,
U"Unterminated record; Missing `}'."
});
}
else if (state.peek_read(cst::Kind::RightBrace))
{
break;
} else {
const auto field = record::parse(state, position);
if (!field)
{
return result_type::error(field.error());
}
fields.push_back(field.value());
if (!state.peek(cst::Kind::Comma) &&
!state.peek(cst::Kind::RightBrace))
{
return result_type::error({
field.value()->position(),
U"Unterminated record; Missing `}'."
});
}
state.peek_read(cst::Kind::Comma);
}
}
return result_type::ok(std::make_shared<ast::expr::Record>(
position,
fields
));
}
result_type
parse_func(State& state)
{
const auto position = state.current->position();
std::vector<std::shared_ptr<ast::Parameter>> parameters;
std::shared_ptr<ast::stmt::Base> body;
std::optional<std::shared_ptr<ast::type::Base>> return_type;
if (const auto error = parse_parameter_list(state, parameters, position))
{
return result_type::error(*error);
}
if (state.peek_read(cst::Kind::Arrow))
{
const auto result = type::parse(state, position);
if (!result)
{
return result_type::error(result.error());
}
return_type = result.value();
}
if (state.peek_read(cst::Kind::FatArrow))
{
const auto expr = parse(state, position);
if (!expr)
{
return result_type::error(expr.error());
}
// Possibly not the greatest idea. It's really context specific whether
// new line should be followed by the expression.
state.peek_read(cst::Kind::NewLine);
body = std::make_shared<ast::stmt::Return>(
expr.value()->position(),
expr.value()
);
}
else if (state.peek_read(cst::Kind::Colon))
{
const auto block = stmt::parse_block(state, position);
if (!block)
{
return result_type::error(block.error());
}
body = block.value();
} else {
return result_type::error({
position,
U"Missing `:' after function declaration."
});
}
return result_type::ok(std::make_shared<ast::expr::Func>(
position,
parameters,
body,
return_type
));
}
static result_type
parse_parenthesized_expr(State& state)
{
const auto position = state.current++->position();
const auto expression = parse(state, position);
if (!expression)
{
return expression;
}
else if (!state.peek_read(cst::Kind::RightParen))
{
return result_type::error({
position,
U"Unterminated parenthesized expression; Missing `)'."
});
}
return expression;
}
static result_type
parse_primary_expr(
State& state,
const std::optional<ast::Position>& position
)
{
std::shared_ptr<ast::expr::RValue> expr;
if (state.eof())
{
return result_type::error({
position,
U"Unexpected end of input; Missing expression."
});
}
switch (state.current->kind())
{
case cst::Kind::Float:
// TODO: Deal with thrown exceptions.
expr = std::make_shared<ast::expr::Float>(
state.current->position(),
std::strtod(
peelo::unicode::encoding::utf8::encode(
*state.current->text()
).c_str(),
nullptr
)
);
break;
case cst::Kind::Int:
// TODO: Deal with thrown exceptions.
expr = std::make_shared<ast::expr::Int>(
state.current->position(),
std::strtoll(
peelo::unicode::encoding::utf8::encode(
*state.current->text()
).c_str(),
nullptr,
10
)
);
break;
case cst::Kind::Str:
expr = std::make_shared<ast::expr::Str>(
state.current->position(),
*state.current->text()
);
break;
case cst::Kind::Id:
expr = std::make_shared<ast::expr::Id>(
state.current->position(),
*state.current->text()
);
break;
case cst::Kind::LeftBracket:
return parse_list_expr(state);
case cst::Kind::LeftBrace:
return parse_record_expr(state);
case cst::Kind::LeftParen:
return state.peek_func()
? parse_func(state)
: parse_parenthesized_expr(state);
case cst::Kind::KeywordNull:
expr = std::make_shared<ast::expr::Null>(state.current->position());
break;
case cst::Kind::KeywordFalse:
expr = std::make_shared<ast::expr::Bool>(
state.current->position(),
false
);
break;
case cst::Kind::KeywordTrue:
expr = std::make_shared<ast::expr::Bool>(
state.current->position(),
true
);
break;
default:
return result_type::error({
state.current->position(),
U"Unexpected " +
cst::to_string(state.current->kind())
+ U"; Missing expression."
});
}
++state.current;
return result_type::ok(expr);
}
static result_type
parse_call_expr(
State& state,
const ast::Position& position,
const std::shared_ptr<ast::expr::RValue>& callee,
bool optional
)
{
const auto arguments = parse_expr_list(
state,
position,
cst::Kind::RightParen,
U"argument list"
);
if (!arguments)
{
return result_type::error(arguments.error());
}
return result_type::ok(std::make_shared<ast::expr::Call>(
position,
callee,
arguments.value(),
optional
));
}
static result_type
parse_field_expr(
State& state,
const ast::Position& position,
const std::shared_ptr<ast::expr::RValue>& record,
bool optional
)
{
if (state.eof() || state.current->kind() != cst::Kind::Id)
{
return result_type::error({
position,
U"Missing identifier after `.'."
});
}
return result_type::ok(std::make_shared<ast::expr::Field>(
position,
record,
*(state.current++)->text(),
optional
));
}
static result_type
parse_subscript_expr(
State& state,
const ast::Position& position,
const std::shared_ptr<ast::expr::RValue>& record,
bool optional
)
{
const auto field_result = parse(state, position);
if (!field_result)
{
return field_result;
}
else if (!state.peek_read(cst::Kind::RightBracket))
{
return result_type::error({
position,
U"Missing `]' after the expression.",
});
}
return result_type::ok(std::make_shared<ast::expr::Subscript>(
position,
record,
field_result.value(),
optional
));
}
static result_type
parse_conditional_selector(
State& state,
const std::shared_ptr<ast::expr::RValue>& target
)
{
const auto position = state.current++->position();
if (state.eof())
{
return result_type::error({
position,
U"Unexpected end of input after `?.'."
});
}
switch (state.current->kind())
{
case cst::Kind::Id:
return parse_field_expr(
state,
state.current->position(),
target,
true
);
case cst::Kind::LeftBracket:
return parse_subscript_expr(
state,
state.current++->position(),
target,
true
);
case cst::Kind::LeftParen:
return parse_call_expr(
state,
state.current++->position(),
target,
true
);
default:
return result_type::error({
position,
U"Unexpected " +
cst::to_string(state.current->kind()) +
U" after `?.'."
});
}
}
static result_type
parse_selector(
State& state,
const std::shared_ptr<ast::expr::RValue>& target
)
{
const auto& selector = *state.current++;
if (selector.kind() == cst::Kind::LeftParen)
{
return parse_call_expr(state, selector.position(), target, false);
}
else if (selector.kind() == cst::Kind::Dot)
{
return parse_field_expr(state, selector.position(), target, false);
} else {
return parse_subscript_expr(state, selector.position(), target, false);
}
}
static result_type
parse_unary_expr(
State& state,
const std::optional<ast::Position>& position
)
{
if (state.peek(cst::Kind::Not) ||
state.peek(cst::Kind::Add) ||
state.peek(cst::Kind::Sub) ||
state.peek(cst::Kind::BitwiseNot))
{
const auto kind = state.current->kind();
const auto new_position = state.current++->position();
const auto expression = parse_unary_expr(state, new_position);
if (!expression)
{
return expression;
}
return result_type::ok(std::make_shared<ast::expr::Unary>(
new_position,
kind == cst::Kind::Not
? ast::expr::UnaryOperator::Not
: kind == cst::Kind::Add
? ast::expr::UnaryOperator::Add
: kind == cst::Kind::Sub
? ast::expr::UnaryOperator::Sub
: ast::expr::UnaryOperator::BitwiseNot,
expression.value()
));
} else {
auto result = parse_primary_expr(state, position);
if (!result)
{
return result;
}
while (state.peek(cst::Kind::Dot) ||
state.peek(cst::Kind::LeftParen) ||
state.peek(cst::Kind::LeftBracket) ||
state.peek(cst::Kind::ConditionalDot))
{
if (state.peek(cst::Kind::ConditionalDot))
{
if (!(result = parse_conditional_selector(state, result.value())))
{
return result;
}
}
else if (!(result = parse_selector(state, result.value())))
{
return result;
}
}
return result;
}
}
static result_type
parse_multiplicative_expr(
State& state,
const std::optional<ast::Position>& position
)
{
auto expression = parse_unary_expr(state, position);
if (!expression)
{
return expression;
}
while (state.peek(cst::Kind::Mul) ||
state.peek(cst::Kind::Div) ||
state.peek(cst::Kind::Mod) ||
state.peek(cst::Kind::BitwiseXor) ||
state.peek(cst::Kind::LeftShift) ||
state.peek(cst::Kind::RightShift) ||
state.peek(cst::Kind::LogicalAnd) ||
state.peek(cst::Kind::LogicalOr))
{
const auto new_position = state.current->position();
const auto kind = state.current++->kind();
const auto operand = parse_unary_expr(state, new_position);
if (!operand)
{
return operand;
}
expression = result_type::ok(std::make_shared<ast::expr::Binary>(
new_position,
expression.value(),
kind == cst::Kind::Mul
? ast::expr::BinaryOperator::Mul
: kind == cst::Kind::Div
? ast::expr::BinaryOperator::Div
: kind == cst::Kind::Mod
? ast::expr::BinaryOperator::Mod
: kind == cst::Kind::BitwiseXor
? ast::expr::BinaryOperator::BitwiseXor
: kind == cst::Kind::LeftShift
? ast::expr::BinaryOperator::LeftShift
: kind == cst::Kind::RightShift
? ast::expr::BinaryOperator::RightShift
: kind == cst::Kind::LogicalAnd
? ast::expr::BinaryOperator::LogicalAnd
: ast::expr::BinaryOperator::LogicalOr,
operand.value()
));
}
return expression;
}
static result_type
parse_additive_expression(
State& state,
const std::optional<ast::Position>& position
)
{
auto expression = parse_multiplicative_expr(state, position);
if (!expression)
{
return expression;
}
while (state.peek(cst::Kind::Add) || state.peek(cst::Kind::Sub))
{
const auto new_position = state.current->position();
const auto kind = state.current++->kind();
const auto operand = parse_multiplicative_expr(state, new_position);
if (!operand)
{
return operand;
}
expression = result_type::ok(std::make_shared<ast::expr::Binary>(
new_position,
expression.value(),
kind == cst::Kind::Add
? ast::expr::BinaryOperator::Add
: ast::expr::BinaryOperator::Sub,
operand.value()
));
}
return expression;
}
static result_type
parse_relational_expr(
State& state,
const std::optional<ast::Position>& position
)
{
auto expression = parse_additive_expression(state, position);
if (!expression)
{
return expression;
}
while (state.peek(cst::Kind::Lt) ||
state.peek(cst::Kind::Gt) ||
state.peek(cst::Kind::Lte) ||
state.peek(cst::Kind::Gte))
{
const auto new_position = state.current->position();
const auto kind = state.current++->kind();
const auto operand = parse_additive_expression(state, new_position);
if (!operand)
{
return operand;
}
expression = result_type::ok(std::make_shared<ast::expr::Binary>(
new_position,
expression.value(),
kind == cst::Kind::Lt
? ast::expr::BinaryOperator::Lt
: kind == cst::Kind::Gt
? ast::expr::BinaryOperator::Gt
: kind == cst::Kind::Lte
? ast::expr::BinaryOperator::Lte
: ast::expr::BinaryOperator::Gte,
operand.value()
));
}
return expression;
}
static result_type
parse_equality_expr(
State& state,
const std::optional<ast::Position>& position
)
{
auto expression = parse_relational_expr(state, position);
if (!expression)
{
return expression;
}
while (state.peek(cst::Kind::Eq) || state.peek(cst::Kind::Ne))
{
const auto new_position = state.current->position();
const auto kind = state.current++->kind();
const auto operand = parse_relational_expr(state, new_position);
if (!operand)
{
return operand;
}
expression = result_type::ok(std::make_shared<ast::expr::Binary>(
new_position,
expression.value(),
kind == cst::Kind::Eq
? ast::expr::BinaryOperator::Eq
: ast::expr::BinaryOperator::Ne,
operand.value()
));
}
return expression;
}
result_type
parse(State& state, const std::optional<ast::Position>& position)
{
return parse_equality_expr(state, position);
}
}
| 25.543243
| 79
| 0.577082
|
RauliL
|
d4c65ed64bf7348080b11a9e4a280d06404a084c
| 912
|
hpp
|
C++
|
concepts/ComponentEntity/GeneratedEntity_TestEntity.hpp
|
hyfloac/TauEngine
|
1559b2a6e6d1887b8ee02932fe0aa6e5b9d5652c
|
[
"MIT"
] | 1
|
2020-04-22T04:07:01.000Z
|
2020-04-22T04:07:01.000Z
|
concepts/ComponentEntity/GeneratedEntity_TestEntity.hpp
|
hyfloac/TauEngine
|
1559b2a6e6d1887b8ee02932fe0aa6e5b9d5652c
|
[
"MIT"
] | null | null | null |
concepts/ComponentEntity/GeneratedEntity_TestEntity.hpp
|
hyfloac/TauEngine
|
1559b2a6e6d1887b8ee02932fe0aa6e5b9d5652c
|
[
"MIT"
] | null | null | null |
#pragma once
#include "Entity.hpp"
#include <cstdint>
#include "./ForwardComponent.hpp"
#include "./FloatComponent.hpp"
class TestEntity : public Entity {
public:
ForwardComponent* _comp0;
FloatComponent* _comp1;
TestEntity() {
std::uint8_t* rawBuf = new std::uint8_t[8];
_comp0 = new(rawBuf + 0) ForwardComponent;
_comp1 = new(rawBuf + 4) FloatComponent;
}
~TestEntity() {
_comp0->~ForwardComponent();
_comp1->~FloatComponent();
delete _comp0;
}
void onEvent(Event& event) override {
_comp0->onEvent(event, this);
_comp1->onEvent(event, this);
}
void onUpdate(float fixedDelta) override {
_comp0->onUpdate(fixedDelta, this);
_comp1->onUpdate(fixedDelta, this);
}
void onRender(float delta) override {
_comp0->onRender(delta, this);
_comp1->onRender(delta, this);
}
};
| 28.5
| 51
| 0.626096
|
hyfloac
|
d4c7113d488d4ed7caaf366990672537dd03ca9e
| 2,755
|
cpp
|
C++
|
src/App.cpp
|
nirustim/openGLproject
|
51cdd160694be055dcca2ec97d1f74963c9e0796
|
[
"MIT"
] | null | null | null |
src/App.cpp
|
nirustim/openGLproject
|
51cdd160694be055dcca2ec97d1f74963c9e0796
|
[
"MIT"
] | null | null | null |
src/App.cpp
|
nirustim/openGLproject
|
51cdd160694be055dcca2ec97d1f74963c9e0796
|
[
"MIT"
] | null | null | null |
#include "App.hpp"
App::App()
{
Engine::Log("Object Made");
}
App::~App()
{
Engine::Log("Object Destroyed");
}
void App::Run()
{
if (appState == AppState::ON)
Engine::FatalError("App already running.");
Engine::Init();
unsigned int windowFlags = 0;
// windowFlags |= Engine::WindowFlags::FULLSCREEN;
// windowFlags |= Engine::WindowFlags::BORDERLESS;
window.Create("Engine", 800, 600, windowFlags);
Load();
appState = AppState::ON;
Loop();
}
void App::Load()
{
// build and compile shader program
shader.Compile("assets/shaders/3.1.shader.vs", "assets/shaders/3.1.shader.fs");
shader.Link();
float vertices[] = {
// first triangle
-0.5f, -0.5f, 0.0f, // left
0.5f, -0.5f, 0.0f, // right
0.0f, 0.5f, 0.0f, // top
-0.25f, 0.f, 0.0f, // left middle
0.0f, -0.5f, 0.0f, // center bottom
0.25f, 0.0f, 0.0f, // right middle
};
// VBO VAO
glGenVertexArrays(1, &VAO);
glGenBuffers(1, &VBO);
// binding vertex array object
glBindVertexArray(VAO);
// copying vertices array to a buffer
glBindBuffer(GL_ARRAY_BUFFER, VBO);
glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
// setting vertex attribute pointers
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float), (void *)0);
glEnableVertexAttribArray(0);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindVertexArray(0); // unbind vertex
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
}
void App::Loop()
{
while (appState == AppState::ON)
{
Update();
Draw();
// Get SDL to swap our buffer
window.SwapBuffer();
LateUpdate();
FixedUpdate(0.0f);
InputUpdate();
}
}
void App::Update() {}
void App::Draw()
{
glClearColor(0.2f, 0.3f, 0.3f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
// take care to activate shader program before calling to uniforms
shader.Use();
// update shader uniform
double timeValue = SDL_GetTicks() / 1000;
float greenValue = static_cast<float>(sin(timeValue) / 2.0 + 0.5);
// int vertexColorLocation = glGetUniformLocation(shaderProgram, "ourColor");
// glUniform4f(vertexColorLocation, 0.0f, greenValue, 0.0f, 1.0f);
shader.SetVec4("ourColor", glm::vec4(0.0f, greenValue, 0.0f, 1.0f));
// rendering triangle to window
glBindVertexArray(VAO);
glDrawArrays(GL_TRIANGLES, 0, 6);
glBindVertexArray(0);
shader.UnUse();
}
void App::LateUpdate() {}
void App::FixedUpdate(float _delta_time) {}
void App::InputUpdate()
{
SDL_Event event;
while (SDL_PollEvent(&event))
{
switch (event.type)
{
case SDL_QUIT:
appState = AppState::OFF;
break;
case SDL_MOUSEMOTION:
break;
case SDL_KEYUP:
break;
case SDL_KEYDOWN:
break;
}
}
}
| 22.04
| 81
| 0.645735
|
nirustim
|
d4cd8498727cc0992fb635801b77c94cbe85b855
| 11,384
|
cpp
|
C++
|
Source/src/Modules/ModuleRender.cpp
|
Erick9Thor/Engine3D
|
32d78f79723fb7c319f79d5e26cdc26481d5cb35
|
[
"MIT"
] | 1
|
2021-11-17T19:20:07.000Z
|
2021-11-17T19:20:07.000Z
|
Source/src/Modules/ModuleRender.cpp
|
Erick9Thor/Engine3D
|
32d78f79723fb7c319f79d5e26cdc26481d5cb35
|
[
"MIT"
] | null | null | null |
Source/src/Modules/ModuleRender.cpp
|
Erick9Thor/Engine3D
|
32d78f79723fb7c319f79d5e26cdc26481d5cb35
|
[
"MIT"
] | null | null | null |
#include "../Globals.h"
#include "../Application.h"
#include "../Utils/Logger.h"
#include "ModuleRender.h"
#include "ModuleWindow.h"
#include "ModuleProgram.h"
#include "ModuleCamera.h"
#include "ModuleDebugDraw.h"
#include "ModuleSceneManager.h"
#include "ModuleEditor.h"
#include "../Scene.h"
#include "../Skybox.h"
#include "../Quadtree.h"
#include "../GameObject.h"
#include "../Components/ComponentCamera.h"
#include "SDL.h"
#include "glew.h"
#include "MathGeoLib.h"
#include "il.h"
#include "ilu.h"
#include "imgui.h"
#include "imgui_impl_sdl.h"
#include "imgui_impl_opengl3.h"
ModuleRender::ModuleRender()
{
}
ModuleRender::~ModuleRender()
{
}
void __stdcall OurOpenGLErrorFunction(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* message, const void* userParam);
bool ModuleRender::Init()
{
LOG("Init Module render");
CreateContext();
RetrieveGpuInfo();
RetrieveLibVersions();
SetGLOptions();
GenerateFrameBuffer();
#ifdef _DEBUG
glEnable(GL_DEBUG_OUTPUT); // Enable output callback
glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
glDebugMessageCallback(&OurOpenGLErrorFunction, nullptr); // Set the callback
glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, nullptr, true); // Filter notifications
#endif
fps_log = std::vector<float>(n_bins);
ms_log = std::vector<float>(n_bins);
return true;
}
void ModuleRender::GenerateFrameBuffer()
{
glGenFramebuffers(1, &frame_buffer);
glBindFramebuffer(GL_FRAMEBUFFER, frame_buffer);
glGenTextures(1, &fb_texture);
glBindTexture(GL_TEXTURE_2D, fb_texture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 800, 600, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL);
glBindTexture(GL_TEXTURE_2D, 0);
//Depth and stencil buffer
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, fb_texture, 0);
glGenRenderbuffers(1, &depth_stencil_buffer);
glBindRenderbuffer(GL_RENDERBUFFER, depth_stencil_buffer);
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, 800, 600);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, depth_stencil_buffer);
if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
{
LOG("Error creating frame buffer");
}
glBindRenderbuffer(GL_RENDERBUFFER, 0);
glBindFramebuffer(GL_FRAMEBUFFER, 0);
}
void ModuleRender::ResizeFrameBuffer(int heigth, int width)
{
glBindTexture(GL_TEXTURE_2D, fb_texture);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, heigth, width, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
glBindTexture(GL_TEXTURE_2D, 0);
glBindRenderbuffer(GL_RENDERBUFFER, depth_stencil_buffer);
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, heigth, width);
glBindRenderbuffer(GL_RENDERBUFFER, 0);
}
void ModuleRender::ManageResolution(ComponentCamera* camera)
{
unsigned res_x, res_y;
camera->GetResolution(res_x, res_y);
if (res_x != fb_height || res_y != fb_width) {
ResizeFrameBuffer(res_x, res_y);
glViewport(0, 0, res_x, res_y);
fb_height = res_x;
fb_width = res_y;
}
}
void ModuleRender::CreateContext()
{
LOG("Creating Renderer context");
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 4); // desired version
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 6);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_COMPATIBILITY);
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); // we want a double buffer
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24); // we want to have a depth buffer with 24 bits
SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8); // we want to have a stencil buffer with 8 bits
SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_DEBUG_FLAG); // enable context debug
context = SDL_GL_CreateContext(App->window->GetWindow());
GLenum err = glewInit();
clear_color = float4(0.1f, 0.1f, 0.1f, 1.0f);
}
void ModuleRender::SetGLOptions()
{
glEnable(GL_DEPTH_TEST); // Enable depth test
glEnable(GL_CULL_FACE); // Enable cull backward faces
glFrontFace(GL_CCW); // Front faces will be counter clockwise
glEnable(GL_STENCIL_TEST); // Enable stencil test
glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE); // Only replace stencil value if stencil and depth tests pass
}
update_status ModuleRender::Update(const float delta)
{
ComponentCamera* camera = App->camera->GetMainCamera();
// Using debug camera to test culling
App->program->UpdateCamera(camera);
Scene* active_scene = App->scene_manager->GetActiveScene();
ComponentCamera* culling = active_scene->GetCullingCamera();
ComponentDirLight* dir_light = nullptr;
if (active_scene->dir_lights.size() > 0)
dir_light = active_scene->dir_lights[0];
App->program->UpdateLights(dir_light, active_scene->point_lights, active_scene->spot_lights);
Draw(App->scene_manager->GetActiveScene(), camera, culling);
return UPDATE_CONTINUE;
}
void ModuleRender::Draw(Scene* scene, ComponentCamera* camera, ComponentCamera* culling)
{
glBindFramebuffer(GL_FRAMEBUFFER, frame_buffer);
ManageResolution(camera);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
glStencilFunc(GL_ALWAYS, 1, 0XFF);
glStencilMask(0x00); // Prevent background from filling stencil
if (draw_skybox)
scene->GetSkybox()->Draw(camera);
else
glClearColor(clear_color[0], clear_color[1], clear_color[2], clear_color[3]);
float4x4 view = camera->GetViewMatrix();
float4x4 proj = camera->GetProjectionMatrix();
glStencilMask(0XFF);
App->debug_draw->Draw(view, proj, fb_height, fb_width);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
//Draw alternatives 0 optiomization, no quadtree
// GameObject* root = scene->GetRoot();
//root->DrawAll(camera);
//render_list.Update(culling, root);
render_list.Update(culling, scene->GetQuadtree()->GetRoot());
Program* program = App->program->GetMainProgram();
program->Activate();
GameObject* selected_go = App->editor->GetSelectedGO();
RenderTarget* outline_target = nullptr;
for (RenderTarget& target : render_list.GetNodes())
{
target.game_object->Draw(camera, program);
if (selected_go && target.game_object == selected_go)
{
outline_target = ⌖
}
}
program->Deactivate();
if (outline_selection && outline_target)
{
glStencilFunc(GL_NOTEQUAL, 1, 0XFF);
glStencilMask(0X00);
glDisable(GL_DEPTH_TEST);
Program* outline_program = App->program->GetStencilProgram();
outline_program->Activate();
outline_target->game_object->DrawStencil(camera, outline_program);
outline_program->Deactivate();
glStencilMask(0XFF);
glStencilFunc(GL_ALWAYS, 0, 0xFF);
glEnable(GL_DEPTH_TEST);
}
glBindFramebuffer(GL_FRAMEBUFFER, 0);
}
update_status ModuleRender::PostUpdate(const float delta)
{
SDL_GL_SwapWindow(App->window->GetWindow());
AddFrame(delta);
return UPDATE_CONTINUE;
}
void GLOptionCheck(GLenum option, bool enable)
{
if (enable)
glEnable(option);
else
glDisable(option);
}
void ModuleRender::OptionsMenu()
{
ImGui::TextColored(ImVec4(1.0f, 1.0f, 0.0f, 1.0f), "Draw Options");
ImGui::Checkbox("Debug Draw", &App->debug_draw->debug_draw);
ImGui::Checkbox("Quadtree", &App->debug_draw->draw_quadtree);
ImGui::Checkbox("Skybox", &draw_skybox);
if (!draw_skybox)
ImGuiUtils::CompactColorPicker("Background Color", &clear_color[0]);
}
void ModuleRender::PerformanceMenu()
{
glGetIntegerv(GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX, &vram_free);
float vram_free_mb = vram_free / 1024.0f;
float vram_usage_mb = gpu.vram_budget_mb - vram_free_mb;
ImGui::Text("VRAM Budget: %.1f Mb", gpu.vram_budget_mb);
ImGui::Text("Vram Usage: %.1f Mb", vram_usage_mb);
ImGui::Text("Vram Avaliable: %.1f Mb", vram_free_mb);
ImGui::Separator();
FpsGraph();
}
void ModuleRender::FpsGraph()
{
ImGui::Text("Fps: %.1f", current_fps);
char title[25];
sprintf_s(title, 25, "Framerate %.1f", current_fps);
ImGui::PlotHistogram("##framerate", &fps_log[0], (int) fps_log.size(), 0, title, 0.0f, 1000.f, ImVec2(310, 100));
sprintf_s(title, 25, "Milliseconds %0.1f", current_ms);
ImGui::PlotHistogram("##milliseconds", &ms_log[0], (int) ms_log.size(), 0, title, 0.0f, 20.0f, ImVec2(310, 100));
}
void ModuleRender::AddFrame(const float delta)
{
static const float update_frequency_seconds = 0.5f;
static int filled_bins = 0;
static int frames = 0;
static float time = 0;
++frames;
time += delta;
if (time >= update_frequency_seconds)
{
if (filled_bins == n_bins)
{
for (int i = 0; i < n_bins - 1; ++i)
{
fps_log[i] = fps_log[i + 1];
ms_log[i] = ms_log[i + 1];
}
}
else
{
++filled_bins;
}
fps_log[filled_bins - 1] = float(frames) / time;
current_fps = fps_log[filled_bins - 1];
ms_log[filled_bins - 1] = time * 1000.0f / float(frames);
current_ms = ms_log[filled_bins - 1];
time = 0;
frames = 0;
}
}
void ModuleRender::RetrieveLibVersions()
{
gl.glew = (unsigned char*) glewGetString(GLEW_VERSION);
gl.opengl = (unsigned char*) glGetString(GL_VERSION);
gl.glsl = (unsigned char*) glGetString(GL_SHADING_LANGUAGE_VERSION);
LOG("Using Glew %s", gl.glew);
LOG("OpenGL version supported %s", gl.opengl);
LOG("GLSL: %s", gl.glsl);
}
void ModuleRender::RetrieveGpuInfo()
{
gpu.name = (unsigned char*) glGetString(GL_RENDERER);
gpu.brand = (unsigned char*) glGetString(GL_VENDOR);
int vram_budget;
glGetIntegerv(GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX, &vram_budget);
gpu.vram_budget_mb = (float) vram_budget / 1024.0f;
}
bool ModuleRender::CleanUp()
{
//LOG("Destroying renderer");
SDL_GL_DeleteContext(context);
return true;
}
void __stdcall OurOpenGLErrorFunction(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* message, const void* userParam)
{
const char *tmp_source = "", *tmp_type = "", *tmp_severity = "";
switch (source)
{
case GL_DEBUG_SOURCE_API:
tmp_source = "API";
break;
case GL_DEBUG_SOURCE_WINDOW_SYSTEM:
tmp_source = "Window System";
break;
case GL_DEBUG_SOURCE_SHADER_COMPILER:
tmp_source = "Shader Compiler";
break;
case GL_DEBUG_SOURCE_THIRD_PARTY:
tmp_source = "Third Party";
break;
case GL_DEBUG_SOURCE_APPLICATION:
tmp_source = "Application";
break;
case GL_DEBUG_SOURCE_OTHER:
tmp_source = "Other";
break;
};
switch (type)
{
case GL_DEBUG_TYPE_ERROR:
tmp_type = "Error";
break;
case GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR:
tmp_type = "Deprecated Behaviour";
break;
case GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR:
tmp_type = "Undefined Behaviour";
break;
case GL_DEBUG_TYPE_PORTABILITY:
tmp_type = "Portability";
break;
case GL_DEBUG_TYPE_PERFORMANCE:
tmp_type = "Performance";
break;
case GL_DEBUG_TYPE_MARKER:
tmp_type = "Marker";
break;
case GL_DEBUG_TYPE_PUSH_GROUP:
tmp_type = "Push Group";
break;
case GL_DEBUG_TYPE_POP_GROUP:
tmp_type = "Pop Group";
break;
case GL_DEBUG_TYPE_OTHER:
tmp_type = "Other";
break;
};
switch (severity)
{
case GL_DEBUG_SEVERITY_HIGH:
tmp_severity = "high";
break;
case GL_DEBUG_SEVERITY_MEDIUM:
tmp_severity = "medium";
break;
case GL_DEBUG_SEVERITY_LOW:
return;
// case GL_DEBUG_SEVERITY_NOTIFICATION: tmp_severity = "notification"; break;
default:
return;
};
LOG("<Source:%s> <Type:%s> <Severity:%s> <ID:%d> <Message:%s>\n", tmp_source, tmp_type, tmp_severity, id, message);
}
| 27.765854
| 156
| 0.746486
|
Erick9Thor
|
d4dadf6e20689466e1c472ef39b47de2f9bb8cb7
| 3,538
|
cpp
|
C++
|
gui-firmware/devices/Display.cpp
|
Danfx/BR-Ventilador
|
052524803e35a8e5db8b1c3f72c16dc91c19ca54
|
[
"MIT"
] | null | null | null |
gui-firmware/devices/Display.cpp
|
Danfx/BR-Ventilador
|
052524803e35a8e5db8b1c3f72c16dc91c19ca54
|
[
"MIT"
] | null | null | null |
gui-firmware/devices/Display.cpp
|
Danfx/BR-Ventilador
|
052524803e35a8e5db8b1c3f72c16dc91c19ca54
|
[
"MIT"
] | null | null | null |
/*
* LICENSE MIT - https://tldrlegal.com/license/mit-license
*
* Copyright Daniel Fussia, https://github.com/Danfx
*
* 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 "../hdr/devices/Display.h"
#include "../hdr/hardware.h"
#include "Arduino.h"
#include "Main.cpp"
#include "../hdr/defines.h"
Display::Display():lcd(LCD_RESET,LCD_EN,LCD_D4,LCD_D5,LCD_D6,LCD_D7){
}
void Display::begin() {
lcd.begin(LCD_COLS,LCD_ROWS);
}
void Display::printMenu(int cursor,config_t* mode,config_t* cfg,size_t cfg_len){
int k=0;
for(size_t i=0;i<cfg_len;i++){
if( cfg[i].visibility == SHOW_ALWAYS || mode->value == cfg[i].visibility ){
if( cursor == k++ ){
Serial.print("> ");
}
Serial.print(cfg[i].label);
Serial.print(" : ");
#if 1
if( cfg[i].key == "mode" ){
if( cfg[i].value == MODE_PCV ){
Serial.println("PCV");
} else if( cfg[i].value == MODE_VCV ){
Serial.println("VCV");
}
} else {
Serial.println(cfg[i].value);
}
#else
// exibe somente valores
Serial.println(cfg[i].value);
#endif
}
}
}
void Display::printPressure(double press, double plim, double peep, double i_ms, int frequencia){
char buffer[10];
press = press < 0 ? 0 : press;
dtostrf(press,2,2,buffer);
// Turn on the display:
lcd.display();
lcd.clear();
// row 0
lcd.setCursor(5, 0);
lcd.print("MODO PCV");
// row 1
lcd.setCursor(0, 1);
lcd.print("Patual:");
lcd.print(buffer);
lcd.setCursor(12, 1);
lcd.print(" [cmH2O]");
//row 2
lcd.setCursor(0, 2);
lcd.print("Plim:");
lcd.print(plim);
lcd.setCursor(11, 2);
lcd.print("PEEP:");
lcd.print(peep);
//row 3
lcd.setCursor(0, 3);
lcd.print("Freq:");
lcd.print(frequencia);
lcd.setCursor(11, 3);
lcd.print("Ti:");
lcd.print(i_ms);
lcd.setCursor(17, 3);
lcd.print("[s]");
}
void Display::printFlow(double flow,int mode){
//char buffer[10];
//press = press < 0 ? 0 : press;
//dtostrf(press,2,2,buffer);
// Turn on the display:
lcd.display();
lcd.clear();
// row 0
lcd.setCursor(5, 0);
lcd.print("MODO VCV");
// row 1
lcd.setCursor(0, 1);
lcd.print("Fluxo atual:");
lcd.print(flow);
lcd.setCursor(12, 1);
lcd.print(" [L/s]");
//row 2
lcd.setCursor(1, 2);
lcd.print("Plim:");
lcd.print("15");
lcd.setCursor(11, 2);
lcd.print("PEEP:");
lcd.print("5");
//row 3
lcd.setCursor(1, 3);
lcd.print("Fluxo:");
lcd.print("15");
lcd.setCursor(11, 3);
lcd.print("Vol:");
lcd.print("300");
lcd.setCursor(17, 3);
lcd.print("mL]");
//&dataMain = cb_Display();
//lcd.print(cb_Display());
}
| 26.402985
| 97
| 0.665065
|
Danfx
|
d4dd0afd948698afa9d16f3a5e98beb464d4f3ff
| 6,104
|
cpp
|
C++
|
src/reconstruction/Image.cpp
|
ShnitzelKiller/Reverse-Engineering-Carpentry
|
585b5ff053c7e3bf286b663a584bc83687691bd6
|
[
"MIT"
] | 3
|
2021-09-08T07:28:13.000Z
|
2022-03-02T21:12:40.000Z
|
src/reconstruction/Image.cpp
|
ShnitzelKiller/Reverse-Engineering-Carpentry
|
585b5ff053c7e3bf286b663a584bc83687691bd6
|
[
"MIT"
] | 1
|
2021-09-21T14:40:55.000Z
|
2021-09-26T01:19:38.000Z
|
src/reconstruction/Image.cpp
|
ShnitzelKiller/Reverse-Engineering-Carpentry
|
585b5ff053c7e3bf286b663a584bc83687691bd6
|
[
"MIT"
] | null | null | null |
//
// Created by James Noeckel on 12/10/19.
//
#include "Image.h"
#include <fstream>
#include <memory>
#include "parsing.hpp"
#include <iostream>
#include <utility>
std::unordered_map<int32_t, Image> Image::parse_file(const std::string &filename, const std::string &image_path, const std::string &depth_path, double scale) {
size_t size;
std::unique_ptr<char[]> memblock = read_file(filename, size);
const char* ptr = memblock.get();
std::unordered_map<int32_t, Image> images;
if (!ptr) return images;
uint64_t num_images;
ptr = read_object(ptr, num_images);
for (size_t i=0; i<num_images; i++) {
Image image;
image.scale_ = scale;
image.image_path_ = image_path;
image.depth_path_ = depth_path;
int32_t image_id;
ptr = read_object(ptr, image_id);
Eigen::Vector4d qvec;
ptr = read_object(ptr, qvec);
image.rot_ = Eigen::Quaterniond(qvec(0), qvec(1), qvec(2), qvec(3));
ptr = read_object(ptr, image.trans_);
ptr = read_object(ptr, image.camera_id_);
ptr = read_object(ptr, image.image_name_);
image.depth_name_ = image.image_name_ + ".geometric.bin";
uint64_t num_points2D;
ptr = read_object(ptr, num_points2D);
image.xys_.resize(num_points2D);
image.point3D_ids_.resize(num_points2D);
for (size_t j=0; j<num_points2D; j++) {
ptr = read_object(ptr, image.xys_[j]);
ptr = read_object(ptr, image.point3D_ids_[j]);
}
std::cout << "Image " << image_id << ": " << image << std::endl;
images.insert(std::make_pair(image_id, image));
}
return images;
}
Eigen::Vector3d Image::origin() const {
return -(rot_.conjugate() * trans_);
}
Eigen::Vector3d Image::direction() const {
return rot_.conjugate() * Eigen::Vector3d(0, 0, 1);
}
cv::Mat Image::getImage(bool grayscale) {
if (!loaded_image_) {
std::cout << "loading " << image_path_ + image_name_ << std::endl;
img_ = cv::imread(image_path_ + image_name_);
if (grayscale) {
cv::cvtColor(img_, img_, CV_BGR2GRAY);
}
if (scale_ != 1) {
cv::Mat temp;
cv::resize(img_, temp, cv::Size(), scale_, scale_);
img_ = temp;
}
loaded_grayscale_ = grayscale;
loaded_image_ = true;
} else if (grayscale != loaded_grayscale_) {
loaded_image_ = false;
getImage(grayscale);
}
return img_;
}
cv::Mat Image::getDepthGeometric() {
if (!loaded_depth_geom_) {
std::string ending = depth_name_.substr(depth_name_.rfind('.') + 1);
std::transform(ending.begin(), ending.end(), ending.begin(),
[](unsigned char c) -> unsigned char { return std::tolower(c); });
std::string filename = depth_path_ + depth_name_;
if (ending == "exr") {
depth_geom_ = cv::imread(filename, cv::IMREAD_ANYDEPTH | cv::IMREAD_GRAYSCALE);
if (!depth_geom_.empty()) {
loaded_depth_geom_ = true;
} else {
std::cerr << "failed to load " << filename << std::endl;
}
} else if (ending == "bin") {
std::string num;
size_t offset;
int width, height, channels;
std::ifstream is(filename);
if (!is) {
std::cerr << "file not found: \"" << filename << '"' << std::endl;
return depth_geom_;
}
try {
std::getline(is, num, '&');
width = std::stoi(num);
std::getline(is, num, '&');
height = std::stoi(num);
std::getline(is, num, '&');
channels = std::stoi(num);
offset = is.tellg();
} catch (std::invalid_argument &exc) {
std::cerr << "error reading header of " << filename << std::endl;
return depth_geom_;
}
if (channels != 1) {
std::cerr << "wrong number of channels in depth image" << std::endl;
return depth_geom_;
}
size_t size;
std::unique_ptr<char[]> memblock = read_file(filename, size, offset);
if (size < width * height * 4) {
std::cerr << "not enough image data for dimensions " << width << "x" << height << std::endl;
return depth_geom_;
}
const char *ptr = memblock.get();
depth_geom_ = cv::Mat(height, width, CV_32FC1);
for (int i = 0; i < height; i++) {
for (int j = 0; j < width; j++) {
ptr = read_object(ptr, depth_geom_.at<float>(i, j));
depth_geom_.at<float>(i, j) *= depth_scale_;
}
}
loaded_depth_geom_ = true;
} else {
std::cerr << "unrecognized file type " << ending << " for " << filename << std::endl;
}
}
return depth_geom_;
}
void Image::clearImages() {
img_ = cv::Mat();
depth_geom_ = cv::Mat();
derivative_x_ = cv::Mat();
derivative_y_ = cv::Mat();
loaded_image_ = false;
loaded_depth_geom_ = false;
computed_derivative_ = false;
}
cv::Mat Image::getDerivativeX() {
if (!computed_derivative_) {
computeDerivatives();
}
return derivative_x_;
}
cv::Mat Image::getDerivativeY() {
if (!computed_derivative_) {
computeDerivatives();
}
return derivative_y_;
}
void Image::computeDerivatives() {
cv::Mat img = getImage(true);
cv::Scharr(img, derivative_x_, CV_16S, 1, 0);
cv::Scharr(img, derivative_y_, CV_16S, 0, 1);
computed_derivative_ = true;
}
std::ostream &operator<<(std::ostream &o, const Image &im) {
o << "rot (" << im.rot_.w() << ", " << im.rot_.x() << ", " << im.rot_.y() << ", " << im.rot_.z() << "), trans (" << im.trans_.transpose() << "), camera ID: " << im.camera_id_ << ", image name: " << im.image_name_ << ", num points: " << im.point3D_ids_.size();
return o;
}
| 35.08046
| 263
| 0.544233
|
ShnitzelKiller
|
d4de32547d2bf6774e0645816f83923e2ca9a3fb
| 913
|
cpp
|
C++
|
C_C++/oop_assignment/contest/week1Contest/date.cpp
|
oneofsunshine/program_learning
|
5afc2e5e6e7a6604d4bd9c8e102822e1cf751c0b
|
[
"Apache-2.0"
] | 1
|
2018-02-10T03:53:45.000Z
|
2018-02-10T03:53:45.000Z
|
C_C++/oop_assignment/contest/week1Contest/date.cpp
|
oneofsunshine/program_learning
|
5afc2e5e6e7a6604d4bd9c8e102822e1cf751c0b
|
[
"Apache-2.0"
] | null | null | null |
C_C++/oop_assignment/contest/week1Contest/date.cpp
|
oneofsunshine/program_learning
|
5afc2e5e6e7a6604d4bd9c8e102822e1cf751c0b
|
[
"Apache-2.0"
] | null | null | null |
#include<iostream>
using namespace std;
int ap[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int ar[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int date(int s, int rOrP, int m, int d)
{
int t = s;
if(rOrP)
{
for(int i = 0; i < m - 1; i++)
t += ar[i];
t += d;
}// 润年从第一天到目标日期总天数(多1);
else
{
for(int i = 0; i < m -1; i++)
t += ap[i];
t += d;
}// 平年从第一天到目标日期总天数(多1);
return t % 7 - 1;
}
int main()
{
int start, month, day;
char rp;
cin>>start>>rp>>month>>day;
switch(date(start, (int)rp - 'p', month, day))
{
case 0:cout<<"SUN";break;
case 1:cout<<"MON";break;
case 2:cout<<"TUE";break;
case 3:cout<<"WED";break;
case 4:cout<<"THU";break;
case 5:cout<<"FRI";break;
case 6:cout<<"SAT";break;
default:cout<<"wrong";
}
}
| 23.410256
| 62
| 0.463308
|
oneofsunshine
|
d4e11eed102183d3ddb1cf50c75b0bde7504b6d5
| 1,049
|
cpp
|
C++
|
tests/eventloop_test.cpp
|
lddddd1997/NetServer
|
940b84bef7d0856bc2fe5f16164bfe041e4d4c9f
|
[
"MIT"
] | null | null | null |
tests/eventloop_test.cpp
|
lddddd1997/NetServer
|
940b84bef7d0856bc2fe5f16164bfe041e4d4c9f
|
[
"MIT"
] | null | null | null |
tests/eventloop_test.cpp
|
lddddd1997/NetServer
|
940b84bef7d0856bc2fe5f16164bfe041e4d4c9f
|
[
"MIT"
] | null | null | null |
// #include <EventLoopThread.h>
// #include <iostream>
// #include <unistd.h>
// using namespace std;
// // g++ eventloop_test.cpp EventLoopThread.cpp EventLoop.cpp Channel.cpp Epoller.cpp -I . -pthread
// void print(EventLoop *p = nullptr)
// {
// printf("print: pid = %d, tid = %ld, loop = %p\n",
// getpid(), this_thread::get_id(), p);
// }
// void quit(EventLoop* p)
// {
// print(p);
// p->CommitTaskToLoop(std::bind(print, p));
// // p->Quit();
// }
// int main()
// {
// print();
// {
// EventLoopThread thr1; // never start
// }
// // {
// // // dtor calls quit()
// // EventLoopThread thr2;
// // EventLoop* loop = thr2.StartLoop();
// // loop->CommitTaskToLoop(std::bind(print, loop));
// // // sleep(5);
// // }
// {
// // quit() before dtor
// EventLoopThread thr3;
// EventLoop* loop = thr3.StartLoop();
// loop->CommitTaskToLoop(std::bind(quit, loop));
// sleep(5);
// }
// return 0;
// }
| 22.804348
| 100
| 0.503337
|
lddddd1997
|
d4e42d3f21202f45938ecfb54efe2260b204a37d
| 10,259
|
cpp
|
C++
|
logdevice/clients/python/logdevice_reader.cpp
|
mickvav/LogDevice
|
24a8b6abe4576418eceb72974083aa22d7844705
|
[
"BSD-3-Clause"
] | 1
|
2021-05-19T23:01:58.000Z
|
2021-05-19T23:01:58.000Z
|
logdevice/clients/python/logdevice_reader.cpp
|
mickvav/LogDevice
|
24a8b6abe4576418eceb72974083aa22d7844705
|
[
"BSD-3-Clause"
] | null | null | null |
logdevice/clients/python/logdevice_reader.cpp
|
mickvav/LogDevice
|
24a8b6abe4576418eceb72974083aa22d7844705
|
[
"BSD-3-Clause"
] | null | null | null |
/**
* Copyright (c) 2017-present, Facebook, Inc. and its affiliates.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*/
#include <algorithm>
#include <atomic>
#include <chrono>
#include <cmath>
#include <boost/make_shared.hpp>
#include "logdevice/clients/python/util/util.h"
#include "logdevice/include/Client.h"
using namespace boost::python;
using namespace facebook::logdevice;
// A class that implements the Python iterator interface, and treats the
// LogDevice Reader.read method as an infinite iterator -- returning one
// record at a time, from the internal buffer that the Reader already
// contains, and returns it.
//
// This has some inter-thread communication overhead, so we might need to do a
// little less calling into Reader, and a bit more "serve out of our own
// buffer", to reduce that overhead -- since we can be non-locking in here,
// while they have to be locking.
class ReaderWrapper : boost::noncopyable {
public:
explicit ReaderWrapper(std::unique_ptr<Reader> reader)
: reader_(std::move(reader)), keep_reading_(true) {
// this determines the minimum delay to shut down reading from outside,
// once LogDevice have a method to break out (thread-)safely from
// iteration, this can go away in favour of not emulating their timeout.
auto timeout = std::chrono::milliseconds(1000);
reader_->setTimeout(timeout);
};
/**
* Return the next (DataRecord, GapRecord) pair, in which exactly one of the
* two is not None.
*
* Ownership of a DataRecord or GapRecord is handed to Python in a
* boost::shared_ptr, which will arrange to destroy it when the Python
* object wrapper goes out of scope and is garbage collected.
*/
boost::python::tuple next() {
std::vector<std::unique_ptr<DataRecord>> record;
GapRecord gap;
while (keep_reading_ && reader_->isReadingAny()) {
// check for signals using Python layer, and raise if one was found;
// the PyErr_CheckSignals function sets the error indicator.
if (PyErr_CheckSignals() != 0)
throw_python_exception();
// read one record, which is a blocking operation, so ensure that we
// don't hold the Python GIL while we do it. we reacquire it at the end
// of the read because we are doing things (like Python exception
// handling) that require the lock.
ssize_t n = 0;
{
gil_release_and_guard guard;
n = reader_->read(1, &record, &gap);
}
if (n < 0) {
if (err == E::GAP) {
return boost::python::make_tuple(object(), // DataRecord is None
boost::make_shared<GapRecord>(gap));
}
throw_logdevice_exception();
throw std::runtime_error("unpossible, the line above always throws!");
}
if (n > 0) {
// Got a data record
return boost::python::make_tuple(
// TODO boost::shared_ptr(std::unique_ptr) constructor requires
// Boost >= 1.57 which not all of our deps are ready for.
// boost::shared_ptr<DataRecord>(std::move(record[0])),
boost::shared_ptr<DataRecord>(record[0].release()),
object() // GapRecord is None
);
}
// no records found in our logs before the timeout, so we exited
// just to check if we should terminate iteration early, and then
// go back to waiting.
}
// this is how you tell Python we ran out of things to do.
throw_python_exception(PyExc_StopIteration, "No more data.");
throw std::runtime_error("unpossible, the line above always throws!");
}
bool stop_iteration() {
keep_reading_ = false;
return true; // yes, we did stop as you requested
}
bool start_reading(logid_t logid, lsn_t from, lsn_t until = LSN_MAX) {
if (reader_->startReading(logid, from, until) == 0)
return true;
throw_logdevice_exception();
throw std::runtime_error("unpossible, the line above always throws!");
}
bool stop_reading(logid_t logid) {
if (reader_->stopReading(logid) == 0)
return true;
throw_logdevice_exception();
throw std::runtime_error("unpossible, the line above always throws!");
}
bool is_connection_healthy(logid_t logid) {
switch (reader_->isConnectionHealthy(logid)) {
case 1:
return true;
case 0:
return false;
default:
throw_logdevice_exception();
throw std::runtime_error("unpossible, the line above always throws!");
};
}
bool without_payload() {
reader_->withoutPayload();
return true;
}
private:
// our reader
std::unique_ptr<Reader> reader_;
// should we break out from reading?
std::atomic<bool> keep_reading_;
};
// helper function to wrap a reader for return to Python -- helps hide the
// class, which nobody else needs to know about
object wrap_logdevice_reader(std::unique_ptr<Reader> reader) {
// boost::shared_ptr is used because boost::python understands it, but does
// not understand std::shared_ptr.
auto wrapper =
boost::shared_ptr<ReaderWrapper>(new ReaderWrapper(std::move(reader)));
return object(wrapper);
}
// The Python iterator protocol requires that we return ourself from a method
// call; this simply returns the existing Python object, which allows that
// to work.
object identity(object const& o) {
return o;
}
// Generate overloads to handle the optional argument to start_reading()
#pragma GCC diagnostic ignored "-Wunused-local-typedefs"
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(start_reading_overloads,
ReaderWrapper::start_reading,
2,
3)
void register_logdevice_reader() {
class_<ReaderWrapper, boost::shared_ptr<ReaderWrapper>, boost::noncopyable>(
"Reader",
R"DOC(
A LogDevice reader, able to read from one or more logs and return records from
them. If reading more than one log there is no assurance of sequencing
between logs, but records in any individual log will be strictly ordered.
The reader yields (data, gap) pairs. In each pair, exactly one of the two is
not None. If a data record is available, the first element is a DataRecord
instance. Otherwise, there is a gap in the numbering sequence; the second
element is a GapRecord instance.
This class is NOT thread safe, and you MUST NOT call any method on it from
another thread. This includes calling any method while iterating on log
entries with the read() method!
)DOC",
no_init)
.def("__iter__", &identity)
.def(NEXT_METHOD,
&ReaderWrapper::next,
R"DOC(
Implement the 'next' operation from the Python iterator protocol.
This will read until the 'stop_iteration()' method is called
from Python, or a record (data or gap) can be returned.
)DOC")
.def("stop_iteration",
&ReaderWrapper::stop_iteration,
"Stop iteration immediately, breaking out of any wait.\n"
"This is thread-safe.")
.def("start_reading",
&ReaderWrapper::start_reading,
start_reading_overloads(args("logid", "from", "until"),
"Start reading log LOGID from LSN FROM "
"through LSN UNTIL (optional)"))
.def("stop_reading",
&ReaderWrapper::stop_reading,
R"DOC(Stop reading log LOGID.
WARNING: This is not suitable for breaking out early from reading
on the log! This will cause internal corruption and SEVs.
)DOC")
.def("is_connection_healthy",
&ReaderWrapper::is_connection_healthy,
R"DOC(
Checks if the connection to the LogDevice cluster for a log appears
healthy. When a read() call times out, this can be used to make an
informed guess whether this is because there is no data or because there
a service interruption.
NOTE: this is not 100% accurate but will expose common issues like losing
network connectivity.
This returns True if everything looked healthy when checked, or False if
something went wrong talking to the cluster.
It can also raise an exception if something terrible goes wrong during
the process of checking.
)DOC")
// TODO: danielp 2015-03-17: disabled until LogDevice has a native "break
// out
// of read early" function that is thread-safe, since we use timeout
// internally. If this is actually needed in code we can emulate it, but
// until then lets disable it but keep the code present.
//
// .def("set_timeout", [](ReaderWrapper &self, double seconds) {
// auto ts = std::chrono::milliseconds(
// // support -1 == unlimited convention
// seconds == -1 ? -1 : lround(seconds * 1000)
// );
// if (self.reader->setTimeout(ts) == 0)
// return true;
// throw_logdevice_exception(); // TODO: danielp 2015-03-13: I
// assume
// // this is set when this failure
// // happens, because it is for
// // everything else.
// },
// R"DOC(
// Sets the limit on how long the iterator returned from read() may wait
// for
// records to become available. A timeout of -1 means no limit (infinite
// timeout). A timeout of 0 means no waiting (nonblocking reads).
//
// When the timeout is hit without new records being returned the iterator
// will reach the 'end' of the iteration, and the Python for loop will
// return.
//
// If you set an infinite timeout there is no way to break out early from
// reading, so be careful about your decisions.
// )DOC"
// )
.def("without_payload",
&ReaderWrapper::without_payload,
R"DOC(
If called, data records read by this Reader will not include payloads.
This makes reading more efficient when payloads are not needed (they won't
be transmitted over the network).
)DOC");
}
| 36.902878
| 80
| 0.651915
|
mickvav
|
d4e6742e509a534b5d9f6b7fd58d812161159754
| 694
|
cpp
|
C++
|
cpp_dsgn_pattern_n_derivatives_pricing/chapter16/exercise16_1/exercise16_1/TreeProductsDecoupling.cpp
|
calvin456/intro_derivative_pricing
|
0841fbc0344bee00044d67977faccfd2098b5887
|
[
"MIT"
] | 5
|
2016-12-28T16:07:38.000Z
|
2022-03-11T09:55:57.000Z
|
cpp_dsgn_pattern_n_derivatives_pricing/chapter16/exercise16_1/exercise16_1/TreeProductsDecoupling.cpp
|
calvin456/intro_derivative_pricing
|
0841fbc0344bee00044d67977faccfd2098b5887
|
[
"MIT"
] | null | null | null |
cpp_dsgn_pattern_n_derivatives_pricing/chapter16/exercise16_1/exercise16_1/TreeProductsDecoupling.cpp
|
calvin456/intro_derivative_pricing
|
0841fbc0344bee00044d67977faccfd2098b5887
|
[
"MIT"
] | 5
|
2017-06-04T04:50:47.000Z
|
2022-03-17T17:41:16.000Z
|
//TreeProductsDecoupling.cpp
#include "TreeProductsDecoupling.h"
TreeProduct::TreeProduct(double FinalTime_)
: FinalTime(FinalTime_)
{
}
double TreeProduct::GetFinalTime() const
{
return FinalTime;
}
/*
*
* Copyright (c) 2002
* Mark Joshi
*
* Permission to use, copy, modify, distribute and sell this
* software for any purpose is hereby
* granted without fee, provided that the above copyright notice
* appear in all copies and that both that copyright notice and
* this permission notice appear in supporting documentation.
* Mark Joshi makes no representations about the
* suitability of this software for any purpose. It is provided
* "as is" without express or implied warranty.
*/
| 23.133333
| 63
| 0.772334
|
calvin456
|
d4e934f1a0b756729dc58ef03910e155318d58dd
| 517
|
cpp
|
C++
|
runtime/indirect_heap/indirect_heap.cpp
|
cwang64/compute-runtime
|
440520ffdc5807574f0abfbf64b3790d1c0547e4
|
[
"MIT"
] | 3
|
2019-09-20T23:26:36.000Z
|
2019-10-03T17:44:12.000Z
|
runtime/indirect_heap/indirect_heap.cpp
|
cwang64/compute-runtime
|
440520ffdc5807574f0abfbf64b3790d1c0547e4
|
[
"MIT"
] | 1
|
2019-09-17T08:06:24.000Z
|
2019-09-17T08:06:24.000Z
|
runtime/indirect_heap/indirect_heap.cpp
|
cwang64/compute-runtime
|
440520ffdc5807574f0abfbf64b3790d1c0547e4
|
[
"MIT"
] | 3
|
2019-05-16T07:22:51.000Z
|
2019-11-11T03:05:32.000Z
|
/*
* Copyright (C) 2017-2019 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "indirect_heap.h"
namespace NEO {
IndirectHeap::IndirectHeap(GraphicsAllocation *gfxAllocation) : BaseClass(gfxAllocation) {
}
IndirectHeap::IndirectHeap(GraphicsAllocation *gfxAllocation, bool canBeUtilizedAs4GbHeap) : BaseClass(gfxAllocation), canBeUtilizedAs4GbHeap(canBeUtilizedAs4GbHeap) {
}
IndirectHeap::IndirectHeap(void *buffer, size_t bufferSize) : BaseClass(buffer, bufferSize) {
}
} // namespace NEO
| 23.5
| 167
| 0.777563
|
cwang64
|
d4eaa86b9b2429aa8e8f8a30748d0c6aebffea37
| 5,533
|
hpp
|
C++
|
config/Templates/FslUtil.Vulkan/Template_header0.hpp
|
Unarmed1000/RAIIGen
|
2516ab5949c1fb54ca1b6e51e5e99e15ecfebbfb
|
[
"BSD-3-Clause"
] | 8
|
2016-11-02T14:08:51.000Z
|
2021-03-25T02:00:00.000Z
|
config/Templates/FslUtil.Vulkan/Template_header0.hpp
|
Unarmed1000/RAIIGen
|
2516ab5949c1fb54ca1b6e51e5e99e15ecfebbfb
|
[
"BSD-3-Clause"
] | 4
|
2016-08-23T12:37:17.000Z
|
2016-09-30T01:58:20.000Z
|
config/Templates/FslUtil.Vulkan/Template_header0.hpp
|
Unarmed1000/RAIIGen
|
2516ab5949c1fb54ca1b6e51e5e99e15ecfebbfb
|
[
"BSD-3-Clause"
] | null | null | null |
#ifndef FSLUTIL_##NAMESPACE_NAME!##_##CLASS_NAME!##_HPP
#define FSLUTIL_##NAMESPACE_NAME!##_##CLASS_NAME!##_HPP
/****************************************************************************************************************************************************
* Copyright (c) 2016 Freescale Semiconductor, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of the Freescale Semiconductor, Inc. nor the names of
* its contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************************************************************************************/
// ##AG_TOOL_STATEMENT##
// Auto generation template based on RapidVulkan https://github.com/Unarmed1000/RapidVulkan with permission.
#include <FslUtil/##NAMESPACE_NAME##/ClaimMode.hpp>
#include <FslUtil/##NAMESPACE_NAME##/Common.hpp>
#include <FslUtil/##NAMESPACE_NAME##/Util.hpp>##ADDITIONAL_INCLUDES##
#include <FslBase/Attributes.hpp>
#include <vulkan/vulkan.h>
#include <cassert>
namespace Fsl
{
namespace Vulkan
{
//! This object is movable so it can be thought of as behaving in the same was as a unique_ptr and is compatible with std containers
class ##CLASS_NAME##
{##CLASS_ADDITIONAL_MEMBER_VARIABLES##
##RESOURCE_TYPE## ##RESOURCE_MEMBER_NAME##;
public:
##CLASS_NAME##(const ##CLASS_NAME##&) = delete;
##CLASS_NAME##& operator=(const ##CLASS_NAME##&) = delete;
//! @brief Move assignment operator
##CLASS_NAME##& operator=(##CLASS_NAME##&& other)
{
if (this != &other)
{
// Free existing resources then transfer the content of other to this one and fill other with default values
if (IsValid())
Reset();
// Claim ownership here##MOVE_ASSIGNMENT_CLAIM_MEMBERS##
// Remove the data from other##MOVE_ASSIGNMENT_INVALIDATE_MEMBERS##
}
return *this;
}
//! @brief Move constructor
//! Transfer ownership from other to this
##CLASS_NAME##(##CLASS_NAME##&& other)##MOVE_CONSTRUCTOR_MEMBER_INITIALIZATION##
{
// Remove the data from other##MOVE_CONSTRUCTOR_INVALIDATE_MEMBERS##
}
//! @brief Create a 'invalid' instance (use Reset to populate it)
##CLASS_NAME##()##DEFAULT_CONSTRUCTOR_MEMBER_INITIALIZATION##
{
}
//! @brief Assume control of the ##CLASS_NAME## (this object becomes responsible for releasing it)
explicit ##CLASS_NAME##(##MEMBER_PARAMETERS##)
: ##CLASS_NAME##()
{
Reset(##MEMBER_PARAMETER_NAMES##);
}
##CLASS_EXTRA_CONSTRUCTORS_HEADER##
~##CLASS_NAME##()
{
Reset();
}
//! @brief returns the managed handle and releases the ownership.
##RESOURCE_TYPE## Release() FSL_FUNC_POSTFIX_WARN_UNUSED_RESULT
{
const auto resource = ##RESOURCE_MEMBER_NAME##;##RESET_INVALIDATE_MEMBERS##
return resource;
}
//! @brief Destroys any owned resources and resets the object to its default state.
void Reset()
{
if (! IsValid())
return;
##RESET_MEMBER_ASSERTIONS##
##DESTROY_FUNCTION##(##DESTROY_FUNCTION_ARGUMENTS##);##RESET_INVALIDATE_MEMBERS##
}
//! @brief Destroys any owned resources and assume control of the ##CLASS_NAME## (this object becomes responsible for releasing it)
void Reset(##MEMBER_PARAMETERS##)
{
if (IsValid())
Reset();
##RESET_SET_MEMBERS_NORMAL##
}
##CLASS_EXTRA_RESET_METHODS_HEADER####CLASS_ADDITIONAL_GET_MEMBER_VARIABLE_METHODS##
//! @brief Get the associated resource handle
##RESOURCE_TYPE## Get() const
{
return ##RESOURCE_MEMBER_NAME##;
}
//! @brief Get a pointer to the associated resource handle
const ##RESOURCE_TYPE##* GetPointer() const
{
return &##RESOURCE_MEMBER_NAME##;
}
//! @brief Check if this object contains a valid resource
inline bool IsValid() const
{
return ##RESOURCE_MEMBER_NAME## != ##DEFAULT_VALUE##;
}##ADDITIONAL_METHODS_HEADER##
};
}
}
#endif
| 37.134228
| 149
| 0.646665
|
Unarmed1000
|
d4ee1d1d4809b78f5db59b951bf03a4f9400e971
| 921
|
cpp
|
C++
|
lib/openGL/src/Evenement.cpp
|
benjyup/cpp_arcade
|
4b755990b64156148e529da1c39efe8a8c0c5d1f
|
[
"MIT"
] | null | null | null |
lib/openGL/src/Evenement.cpp
|
benjyup/cpp_arcade
|
4b755990b64156148e529da1c39efe8a8c0c5d1f
|
[
"MIT"
] | null | null | null |
lib/openGL/src/Evenement.cpp
|
benjyup/cpp_arcade
|
4b755990b64156148e529da1c39efe8a8c0c5d1f
|
[
"MIT"
] | null | null | null |
//
// Created by florian on 4/5/17.
//
#include "Evenement.hpp"
arcade::Evenement::Evenement(IEvenement::KeyCode keycode) : _keyCode(keycode),
_action(IEvenement::Action::KeyPressDown),
_score(0)
{}
arcade::Evenement::~Evenement()
{}
arcade::IEvenement::Action arcade::Evenement::getAction() const { return (_action); }
arcade::IEvenement::KeyCode arcade::Evenement::getKeyCode() const { return (_keyCode); }
uint64_t arcade::Evenement::getScore() const { return (_score);}
void arcade::Evenement::setAction(const IEvenement::Action action) { _action = action; }
void arcade::Evenement::setKeyCode(const IEvenement::KeyCode keyCode) { _keyCode = keyCode; }
void arcade::Evenement::setScore(const uint64_t score) { _score = score; }
int32_t arcade::Evenement::getData(void) const { return (0); }
| 38.375
| 101
| 0.641694
|
benjyup
|
d4ef889e0b5e9c454d6a0fffc270440b1b149fae
| 41,279
|
cpp
|
C++
|
src/EHooker.cpp
|
cxxjava/CxxFiber
|
0558eb2f070f9e36859050f9d0fec89ef9d19982
|
[
"Apache-2.0"
] | 14
|
2016-12-13T08:23:17.000Z
|
2020-03-29T23:28:46.000Z
|
src/EHooker.cpp
|
cxxjava/CxxFiber
|
0558eb2f070f9e36859050f9d0fec89ef9d19982
|
[
"Apache-2.0"
] | null | null | null |
src/EHooker.cpp
|
cxxjava/CxxFiber
|
0558eb2f070f9e36859050f9d0fec89ef9d19982
|
[
"Apache-2.0"
] | 8
|
2017-02-09T09:56:20.000Z
|
2019-02-19T07:22:11.000Z
|
/*
* EHooker.cpp
*
* Created on: 2016-5-12
* Author: cxxjava@163.com
*/
#include "./EHooker.hh"
#include "./EIoWaiter.hh"
#include "./EFileContext.hh"
#include "../inc/EFiberLocal.hh"
#include "../inc/EFiberScheduler.hh"
#include "eco_ae.h"
#include <dlfcn.h>
#include <poll.h>
#include <signal.h>
#include <unistd.h>
#include <resolv.h>
#include <netdb.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <sys/fcntl.h>
#include <sys/ioctl.h>
#include <sys/uio.h>
#ifdef __linux__
#include "elf_hook.h"
#include <bits/signum.h> //__SIGRTMAX
#include <sys/epoll.h>
#include <sys/sendfile.h>
#endif
#ifdef __APPLE__
#include "mach_hook.h"
#include <sys/event.h>
#endif
namespace efc {
namespace eco {
extern "C" {
typedef void (*sig_t) (int);
typedef void (*signal_t)(int sig, sig_t func);
typedef unsigned int (*sleep_t)(unsigned int seconds);
typedef int (*usleep_t)(useconds_t usec);
typedef int (*nanosleep_t)(const struct timespec *req, struct timespec *rem);
typedef int (*close_t)(int);
typedef int (*fcntl_t)(int fd, int cmd, ...);
typedef int (*ioctl_t)(int fd, unsigned long int request, ...);
typedef int (*setsockopt_t)(int sockfd, int level, int optname,
const void *optval, socklen_t optlen);
typedef int (*dup2_t)(int oldfd, int newfd);
typedef int (*poll_t)(struct pollfd *fds, nfds_t nfds, int timeout);
typedef int (*select_t)(int nfds, fd_set *readfds, fd_set *writefds,
fd_set *exceptfds, struct timeval *timeout);
typedef int (*connect_t)(int fd, const struct sockaddr *addr, socklen_t addrlen);
typedef int (*accept_t)(int sockfd, struct sockaddr *addr, socklen_t *addrlen);
typedef ssize_t (*read_t)(int fd, void *buf, size_t count);
typedef ssize_t (*readv_t)(int fd, const struct iovec *iov, int iovcnt);
typedef ssize_t (*recv_t)(int sockfd, void *buf, size_t len, int flags);
typedef ssize_t (*recvfrom_t)(int sockfd, void *buf, size_t len, int flags,
struct sockaddr *src_addr, socklen_t *addrlen);
typedef ssize_t (*recvmsg_t)(int sockfd, struct msghdr *msg, int flags);
typedef ssize_t (*write_t)(int fd, const void *buf, size_t count);
typedef ssize_t (*writev_t)(int fd, const struct iovec *iov, int iovcnt);
typedef ssize_t (*send_t)(int sockfd, const void *buf, size_t len, int flags);
typedef ssize_t (*sendto_t)(int sockfd, const void *buf, size_t len, int flags,
const struct sockaddr *dest_addr, socklen_t addrlen);
typedef ssize_t (*sendmsg_t)(int sockfd, const struct msghdr *msg, int flags);
typedef size_t (*fread_t)(void *ptr, size_t size, size_t nitems, FILE *stream);
typedef size_t (*fwrite_t)(const void *ptr, size_t size, size_t nitems, FILE *stream);
typedef ssize_t (*pread_t)(int fd, void *buf, size_t count, off_t offset);
typedef ssize_t (*pwrite_t)(int fd, const void *buf, size_t count, off_t offset);
typedef void* (*dlopen_t)(const char* path, int mode);
#ifdef __linux__
typedef int (*dup3_t)(int oldfd, int newfd, int flags);
typedef hostent* (*gethostbyname_t)(const char *name);
typedef res_state (*__res_state_t)();
typedef int (*__poll_t)(struct pollfd fds[], nfds_t nfds, int timeout);
typedef int (*epoll_wait_t)(int epfd, struct epoll_event *events,
int maxevents, int timeout);
typedef ssize_t (*sendfile_t)(int out_fd, int in_fd, off_t *offset, size_t count);
#endif
#ifdef __APPLE__
typedef int (*kevent_t)(int kq, const struct kevent *changelist, int nchanges,
struct kevent *eventlist, int nevents, const struct timespec *timeout);
typedef int (*kevent64_t)(int kq, const struct kevent64_s *changelist,
int nchanges, struct kevent64_s *eventlist, int nevents,
unsigned int flags, const struct timespec *timeout);
typedef int (*sendfile_t)(int fd, int s, off_t offset, off_t *len, struct sf_hdtr *hdtr, int flags);
#endif
//=============================================================================
static signal_t signal_f = NULL;
static sleep_t sleep_f = NULL;
static usleep_t usleep_f = NULL;
static nanosleep_t nanosleep_f = NULL;
static close_t close_f = NULL;
/*static*/ fcntl_t fcntl_f = NULL;
static ioctl_t ioctl_f = NULL;
static setsockopt_t setsockopt_f = NULL;
static dup2_t dup2_f = NULL;
static poll_t poll_f = NULL;
static select_t select_f = NULL;
static connect_t connect_f = NULL;
static accept_t accept_f = NULL;
/*static*/ read_t read_f = NULL;
static readv_t readv_f = NULL;
static recv_t recv_f = NULL;
static recvfrom_t recvfrom_f = NULL;
static recvmsg_t recvmsg_f = NULL;
/*static*/ write_t write_f = NULL;
static writev_t writev_f = NULL;
static send_t send_f = NULL;
static sendto_t sendto_f = NULL;
static sendmsg_t sendmsg_f = NULL;
static fread_t fread_f = NULL;
static fwrite_t fwrite_f = NULL;
static pread_t pread_f = NULL;
static pwrite_t pwrite_f = NULL;
static sendfile_t sendfile_f = NULL;
static dlopen_t dlopen_f = NULL;
#ifdef __linux__
static dup3_t dup3_f = NULL;
static gethostbyname_t gethostbyname_f = NULL;
static __res_state_t __res_state_f = NULL;
static __poll_t __poll_f = NULL;
/*static*/ epoll_wait_t epoll_wait_f = NULL;
#endif
#ifdef __APPLE__
/*static*/ kevent_t kevent_f = NULL;
static kevent64_t kevent64_f = NULL;
#endif
} //!C
//=============================================================================
//@see: http://docs.oracle.com/cd/E19253-01/819-7050/chapter3-24/
DEFINE_STATIC_INITZZ_BEGIN(EHooker)
signal_f = (signal_t)dlsym(RTLD_NEXT, "signal");
sleep_f = (sleep_t)dlsym(RTLD_NEXT, "sleep");
usleep_f = (usleep_t)dlsym(RTLD_NEXT, "usleep");
nanosleep_f = (nanosleep_t)dlsym(RTLD_NEXT, "nanosleep");
close_f = (close_t)dlsym(RTLD_NEXT, "close");
fcntl_f = (fcntl_t)dlsym(RTLD_NEXT, "fcntl");
ioctl_f = (ioctl_t)dlsym(RTLD_NEXT, "ioctl");
setsockopt_f = (setsockopt_t)dlsym(RTLD_NEXT, "setsockopt");
dup2_f = (dup2_t)dlsym(RTLD_NEXT, "dup2");
poll_f = (poll_t)dlsym(RTLD_NEXT, "poll");
select_f = (select_t)dlsym(RTLD_NEXT, "select");
connect_f = (connect_t)dlsym(RTLD_NEXT, "connect");
accept_f = (accept_t)dlsym(RTLD_NEXT, "accept");
read_f = (read_t)dlsym(RTLD_NEXT, "read");
readv_f = (readv_t)dlsym(RTLD_NEXT, "readv");
recv_f = (recv_t)dlsym(RTLD_NEXT, "recv");
recvfrom_f = (recvfrom_t)dlsym(RTLD_NEXT, "recvfrom");
recvmsg_f = (recvmsg_t)dlsym(RTLD_NEXT, "recvmsg");
write_f = (write_t)dlsym(RTLD_NEXT, "write");
writev_f = (writev_t)dlsym(RTLD_NEXT, "writev");
send_f = (send_t)dlsym(RTLD_NEXT, "send");
sendto_f = (sendto_t)dlsym(RTLD_NEXT, "sendto");
sendmsg_f = (sendmsg_t)dlsym(RTLD_NEXT, "sendmsg");
fread_f = (fread_t)dlsym(RTLD_NEXT, "fread");
fwrite_f = (fwrite_t)dlsym(RTLD_NEXT, "fwrite");
pread_f = (pread_t)dlsym(RTLD_NEXT, "pread");
pwrite_f = (pwrite_t)dlsym(RTLD_NEXT, "pwrite");
sendfile_f = (sendfile_t)dlsym(RTLD_NEXT, "sendfile");
dlopen_f = (dlopen_t)dlsym(RTLD_NEXT, "dlopen");
#ifdef __linux__
dup3_f = (dup3_t)dlsym(RTLD_NEXT, "dup3");
gethostbyname_f = (gethostbyname_t)dlsym(RTLD_NEXT, "gethostbyname");
__res_state_f = (__res_state_t)dlsym(RTLD_NEXT,"__res_state");
__poll_f = (__poll_t)dlsym(RTLD_NEXT, "__poll");
epoll_wait_f = (epoll_wait_t)dlsym(RTLD_NEXT, "epoll_wait");
#endif
#ifdef __APPLE__
kevent_f = (kevent_t)dlsym(RTLD_NEXT, "kevent");
kevent64_f = (kevent64_t)dlsym(RTLD_NEXT, "kevent64");
#endif
DEFINE_STATIC_INITZZ_END
//=============================================================================
extern "C" {
static boolean process_signaled = false;
static llong interrupt_escaped_time = 0L;
static EThreadLocalStorage thread_signaled;
#ifndef __SIGRTMAX
#define __SIGRTMAX 64
#endif
static sig_t sigfunc_map[__SIGRTMAX] = {0};
static void sigfunc(int sig_no) {
process_signaled = true;
llong t1 = ESystem::currentTimeMillis();
ES_ASSERT(sig_no < __SIGRTMAX);
if (sig_no < __SIGRTMAX) {
sig_t func = sigfunc_map[sig_no];
if (func) {
func(sig_no);
}
} else {
fprintf(stderr, "sig_no >= %d\n", __SIGRTMAX);
}
llong t2 = ESystem::currentTimeMillis();
interrupt_escaped_time = t2 - t1;
process_signaled = false;
}
static uint32_t PollEvent2EEvent(short events)
{
uint32_t e = 0;
if (events & POLLIN) e |= ECO_POLL_READABLE;
if (events & POLLOUT) e |= ECO_POLL_WRITABLE;
return e;
}
static short EEvent2PollEvent(uint32_t events)
{
short e = 0;
if (events & ECO_POLL_READABLE) e |= POLLIN;
if (events & ECO_POLL_WRITABLE) e |= POLLOUT;
return e;
}
} //!C
//=============================================================================
extern "C" {
sig_t signal(int sig, sig_t func)
{
EHooker::_initzz_();
ES_ASSERT(sig < __SIGRTMAX);
if (sig < __SIGRTMAX) {
if ((long)func > 512) { //special defined sig_t is always less 512 ?
sigfunc_map[sig] = func;
signal_f(sig, sigfunc);
} else {
signal_f(sig, func);
}
return func;
}
fprintf(stderr, "sig_no > %d\n", __SIGRTMAX);
return NULL;
}
unsigned int sleep(unsigned int seconds)
{
EHooker::_initzz_();
EFiberScheduler* scheduler = EFiberScheduler::currentScheduler();
if (!scheduler || EHooker::isInterrupted()) {
return sleep_f(seconds);
}
llong milliseconds = seconds * 1000;
EFiber::sleep(milliseconds);
return 0;
}
int usleep(useconds_t usec) {
EHooker::_initzz_();
EFiberScheduler* scheduler = EFiberScheduler::currentScheduler();
if (!scheduler || EHooker::isInterrupted()) {
return usleep_f(usec);
}
llong milliseconds = usec / 1000;
EFiber::sleep(milliseconds);
return 0;
}
int nanosleep(const struct timespec *req, struct timespec *rem) {
EHooker::_initzz_();
if (!req) {
errno = EINVAL;
return -1;
}
EFiberScheduler* scheduler = EFiberScheduler::currentScheduler();
if (!scheduler || EHooker::isInterrupted()) {
return nanosleep_f(req, rem);
}
llong milliseconds = req->tv_sec * 1000 + req->tv_nsec / 1000000;
EFiber::sleep(milliseconds);
return 0;
}
int close(int fd)
{
EHooker::_initzz_();
EFiberScheduler* scheduler = EFiberScheduler::currentScheduler();
if (scheduler && EFileContext::isStreamFile(fd) && !EHooker::isInterrupted()) {
scheduler->delFileContext(fd);
}
return close_f(fd);
}
int fcntl(int fd, int cmd, ...)
{
EHooker::_initzz_();
va_list args;
va_start(args, cmd);
void* arg = va_arg(args, void*);
va_end(args);
EFiberScheduler* scheduler = EFiberScheduler::currentScheduler();
if (scheduler && EFileContext::isStreamFile(fd) && !EHooker::isInterrupted()) {
sp<EFileContext> fdctx = scheduler->getFileContext(fd);
if (!fdctx) {
return -1;
}
if (cmd == F_SETFL) {
int flags = (int)((long)(arg));
fdctx->setUserNonBlock(flags & O_NONBLOCK);
return 0;
}
if (cmd == F_GETFL) {
int flags = fcntl_f(fd, cmd);
if (fdctx->isUserNonBlocked())
return flags | O_NONBLOCK;
else
return flags & ~O_NONBLOCK;
}
}
return fcntl_f(fd, cmd, arg);
}
int ioctl(int fd, unsigned long int request, ...)
{
EHooker::_initzz_();
va_list va;
va_start(va, request);
void* arg = va_arg(va, void*);
va_end(va);
EFiberScheduler* scheduler = EFiberScheduler::currentScheduler();
if (scheduler && (request == FIONBIO) && EFileContext::isStreamFile(fd) && !EHooker::isInterrupted()) {
sp<EFileContext> fdctx = scheduler->getFileContext(fd);
if (!fdctx) {
return -1;
}
boolean nonblock = !!*(int*)arg;
fdctx->setUserNonBlock(nonblock);
return 0;
}
return ioctl_f(fd, request, arg);
}
int setsockopt(int sockfd, int level, int optname, const void *optval, socklen_t optlen)
{
EHooker::_initzz_();
if (level == SOL_SOCKET) {
if (optname == SO_RCVTIMEO || optname == SO_SNDTIMEO) {
EFiberScheduler* scheduler = EFiberScheduler::currentScheduler();
if (scheduler && EFileContext::isStreamFile(sockfd) && !EHooker::isInterrupted()) {
sp<EFileContext> fdctx = scheduler->getFileContext(sockfd);
if (!fdctx) {
return -1;
}
if (optname == SO_RCVTIMEO)
fdctx->setRecvTimeout((const timeval*)optval);
if (optname == SO_SNDTIMEO)
fdctx->setSendTimeout((const timeval*)optval);
}
}
}
return setsockopt_f(sockfd, level, optname, optval, optlen);
}
int dup2(int oldfd, int newfd)
{
EHooker::_initzz_();
if (oldfd == newfd) {
return 0;
}
EFiberScheduler* scheduler = EFiberScheduler::currentScheduler();
if (scheduler && EFileContext::isStreamFile(newfd) && !EHooker::isInterrupted()) {
scheduler->delFileContext(newfd);
}
return dup2_f(oldfd, newfd);
}
#ifdef __linux__
int dup3(int oldfd, int newfd, int flags)
{
EHooker::_initzz_();
if (oldfd == newfd) {
errno = EINVAL;
return -1;
}
EFiberScheduler* scheduler = EFiberScheduler::currentScheduler();
if (scheduler && EFileContext::isStreamFile(newfd) && !EHooker::isInterrupted()) {
scheduler->delFileContext(newfd);
}
return dup3_f(oldfd, newfd, flags);
}
#endif
int poll(struct pollfd *fds, nfds_t nfds, int timeout)
{
EHooker::_initzz_();
EFiberScheduler* scheduler = EFiberScheduler::currentScheduler();
if (!scheduler || EHooker::isInterrupted()) {
return poll_f(fds, nfds, timeout);
}
if (timeout == 0)
return poll_f(fds, nfds, timeout);
boolean invalide_all = true;
for (nfds_t i = 0; i < nfds; ++i) {
invalide_all &= (fds[i].fd < 0);
}
if (invalide_all) {
EFiber::sleep(timeout);
return 0;
}
#if 1
// try once at immediately.
int ret = poll_f(fds, nfds, 0);
if (ret != 0) {
return ret;
}
#endif
EIoWaiter* ioWaiter = EFiberScheduler::currentIoWaiter();
sp<EFiber> fiber = EFiber::currentFiber()->shared_from_this();
boolean none = true;
for (nfds_t i = 0; i < nfds; ++i) {
if (fds[i].fd < 0) continue;
ioWaiter->setFileEvent(fds[i].fd, PollEvent2EEvent(fds[i].events), fiber);
none = false;
}
if (none) {
errno = 0;
return nfds;
}
llong timerID = -1;
if (timeout > 0) {
timerID = ioWaiter->setupTimer(timeout, fiber);
}
ioWaiter->swapOut(fiber); // pause the fiber.
if (timerID != -1) {
ioWaiter->cancelTimer(timerID);
}
if (fiber->isWaitTimeout()) {
for (nfds_t i = 0; i < nfds; ++i) {
ioWaiter->delFileEvent(fds[i].fd, ECO_POLL_ALL_EVENTS);
}
return 0;
} else {
int n = 0;
for (nfds_t i = 0; i < nfds; ++i) {
fds[i].revents = EEvent2PollEvent(ioWaiter->getFileEvent(fds[i].fd));
ioWaiter->delFileEvent(fds[i].fd, ECO_POLL_ALL_EVENTS);
if (fds[i].revents) n++;
}
errno = 0;
return n;
}
}
int select(int nfds, fd_set *readfds, fd_set *writefds,
fd_set *exceptfds, struct timeval *timeout)
{
EHooker::_initzz_();
EFiberScheduler* scheduler = EFiberScheduler::currentScheduler();
if (!scheduler || EHooker::isInterrupted()) {
return select_f(nfds, readfds, writefds, exceptfds, timeout);
}
llong milliseconds = ELLong::MAX_VALUE;
if (timeout)
milliseconds = timeout->tv_sec * 1000 + timeout->tv_usec / 1000;
if (milliseconds == 0)
return select_f(nfds, readfds, writefds, exceptfds, timeout);
if (nfds == 0 || (!readfds && !writefds && !exceptfds)) {
EFiber::sleep(milliseconds);
return 0;
}
nfds = ES_MIN(nfds, FD_SETSIZE);
#if 1
// try once at immediately.
timeval zero_tv = {0, 0};
int ret = select_f(nfds, readfds, writefds, exceptfds, &zero_tv);
if (ret != 0) {
return ret;
}
#endif
//FIXME: to support exceptfds.
EIoWaiter* ioWaiter = EFiberScheduler::currentIoWaiter();
sp<EFiber> fiber = EFiber::currentFiber()->shared_from_this();
EArrayList<int> pfds;
short events = 0;
for (int fd = 0; fd < nfds; fd++) {
if (readfds && FD_ISSET(fd, readfds)) {
events = ECO_POLL_READABLE;
}
if (writefds && FD_ISSET(fd, writefds)) {
events = ECO_POLL_WRITABLE;
}
if (events == 0) {
continue;
}
ioWaiter->setFileEvent(fd, events, fiber);
pfds.add(fd);
}
// clear the old.
if (readfds) FD_ZERO(readfds);
if (writefds) FD_ZERO(writefds);
if (exceptfds) FD_ZERO(exceptfds);
llong timerID = -1;
if (milliseconds > 0) {
timerID = ioWaiter->setupTimer(milliseconds, fiber);
}
ioWaiter->swapOut(fiber); // pause the fiber.
if (timerID != -1) {
ioWaiter->cancelTimer(timerID);
}
if (fiber->isWaitTimeout()) {
for (int i = 0; i < pfds.size(); i++) {
int fd = pfds.getAt(i);
ioWaiter->delFileEvent(fd, ECO_POLL_ALL_EVENTS);
}
return 0;
} else {
int n = 0;
for (int i = 0; i < pfds.size(); i++) {
int fd = pfds.getAt(i);
events = ioWaiter->getFileEvent(fd);
if (events) n++;
if (readfds && (events & ECO_POLL_READABLE)) {
FD_SET(fd, readfds);
}
if (writefds && (events & ECO_POLL_WRITABLE)) {
FD_SET(fd, writefds);
}
ioWaiter->delFileEvent(fd, ECO_POLL_ALL_EVENTS);
}
errno = 0;
return n;
}
}
int connect(int fd, const struct sockaddr *addr, socklen_t addrlen)
{
EHooker::_initzz_();
EFiberScheduler* scheduler = EFiberScheduler::currentScheduler();
if (!scheduler /*|| !EFileContext::isStreamFile(fd)*/ || EHooker::isInterrupted()) {
return connect_f(fd, addr, addrlen);
}
sp<EFileContext> fdctx = scheduler->getFileContext(fd);
if (!fdctx) {
//errno = EBADF;
return -1;
//return connect_f(fd, addr, addrlen);
}
if (fdctx->isUserNonBlocked()) {
return connect_f(fd, addr, addrlen);
}
int n = connect_f(fd, addr, addrlen);
if (n == 0) {
// success immediately
return 0;
} else if (n == -1 && errno == EINPROGRESS) {
// waiting
EIoWaiter* ioWaiter = EFiberScheduler::currentIoWaiter();
sp<EFiber> fiber = EFiber::currentFiber()->shared_from_this();
ioWaiter->setFileEvent(fd, ECO_POLL_WRITABLE, fiber);
ioWaiter->swapOut(fiber); // pause the fiber.
ioWaiter->delFileEvent(fd, ECO_POLL_WRITABLE);
// re-check
int err = 0;
socklen_t optlen = sizeof(int);
if (getsockopt(fd, SOL_SOCKET, SO_ERROR, (void *)&err, &optlen) == -1) {
return -1;
}
if (!err)
return 0;
else {
errno = err;
return -1;
}
} else {
// error
return n;
}
}
int accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen)
{
#ifdef CPP11_SUPPORT
return EHooker::comm_io_on_fiber(accept_f, "accept", POLLIN, sockfd, sockfd, addr, addrlen);
#else
return EHooker::comm_io_on_fiber(accept_f, "accept", POLLIN, sockfd, addr, addrlen);
#endif
}
ssize_t read(int fd, void *buf, size_t count)
{
#ifdef CPP11_SUPPORT
return EHooker::comm_io_on_fiber(read_f, "read", POLLIN, fd, fd, buf, count);
#else
return EHooker::comm_io_on_fiber(read_f, "read", POLLIN, fd, buf, count);
#endif
}
ssize_t readv(int fd, const struct iovec *iov, int iovcnt)
{
#ifdef CPP11_SUPPORT
return EHooker::comm_io_on_fiber(readv_f, "readv", POLLIN, fd, fd, iov, iovcnt);
#else
return EHooker::comm_io_on_fiber(readv_f, "readv", POLLIN, fd, iov, iovcnt);
#endif
}
ssize_t recv(int sockfd, void *buf, size_t len, int flags)
{
#ifdef CPP11_SUPPORT
return EHooker::comm_io_on_fiber(recv_f, "recv", POLLIN, sockfd, sockfd, buf, len, flags);
#else
return EHooker::comm_io_on_fiber(recv_f, "recv", POLLIN, sockfd, buf, len, flags);
#endif
}
ssize_t recvfrom(int sockfd, void *buf, size_t len, int flags,
struct sockaddr *src_addr, socklen_t *addrlen)
{
#ifdef CPP11_SUPPORT
return EHooker::comm_io_on_fiber(recvfrom_f, "recvfrom", POLLIN, sockfd, sockfd, buf, len, flags, src_addr, addrlen);
#else
return EHooker::comm_io_on_fiber(recvfrom_f, "recvfrom", POLLIN, sockfd, buf, len, flags, src_addr, addrlen);
#endif
}
ssize_t recvmsg(int sockfd, struct msghdr *msg, int flags)
{
#ifdef CPP11_SUPPORT
return EHooker::comm_io_on_fiber(recvmsg_f, "recvmsg", POLLIN, sockfd, sockfd, msg, flags);
#else
return EHooker::comm_io_on_fiber(recvmsg_f, "recvmsg", POLLIN, sockfd, msg, flags);
#endif
}
ssize_t write(int fd, const void *buf, size_t count)
{
#ifdef CPP11_SUPPORT
return EHooker::comm_io_on_fiber(write_f, "write", POLLOUT, fd, fd, buf, count);
#else
return EHooker::comm_io_on_fiber(write_f, "write", POLLOUT, fd, buf, count);
#endif
}
ssize_t writev(int fd, const struct iovec *iov, int iovcnt)
{
#ifdef CPP11_SUPPORT
return EHooker::comm_io_on_fiber(writev_f, "writev", POLLOUT, fd, fd, iov, iovcnt);
#else
return EHooker::comm_io_on_fiber(writev_f, "writev", POLLOUT, fd, iov, iovcnt);
#endif
}
ssize_t send(int sockfd, const void *buf, size_t len, int flags)
{
#ifdef CPP11_SUPPORT
return EHooker::comm_io_on_fiber(send_f, "send", POLLOUT, sockfd, sockfd, buf, len, flags);
#else
return EHooker::comm_io_on_fiber(send_f, "send", POLLOUT, sockfd, buf, len, flags);
#endif
}
ssize_t sendto(int sockfd, const void *buf, size_t len, int flags,
const struct sockaddr *dest_addr, socklen_t addrlen)
{
#ifdef CPP11_SUPPORT
return EHooker::comm_io_on_fiber(sendto_f, "sendto", POLLOUT, sockfd, sockfd, buf, len, flags, dest_addr, addrlen);
#else
return EHooker::comm_io_on_fiber(sendto_f, "sendto", POLLOUT, sockfd, buf, len, flags, dest_addr, addrlen);
#endif
}
ssize_t sendmsg(int sockfd, const struct msghdr *msg, int flags)
{
#ifdef CPP11_SUPPORT
return EHooker::comm_io_on_fiber(sendmsg_f, "sendmsg", POLLOUT, sockfd, sockfd, msg, flags);
#else
return EHooker::comm_io_on_fiber(sendmsg_f, "sendmsg", POLLOUT, sockfd, msg, flags);
#endif
}
ssize_t pread(int fd, void *buf, size_t count, off_t offset)
{
#ifdef CPP11_SUPPORT
return EHooker::comm_io_on_fiber(pread_f, "pread", POLLIN, fd, fd, buf, count, offset);
#else
return EHooker::comm_io_on_fiber(pread_f, "pread", POLLIN, fd, buf, count, offset);
#endif
}
ssize_t pwrite(int fd, const void *buf, size_t count, off_t offset)
{
#ifdef CPP11_SUPPORT
return EHooker::comm_io_on_fiber(pwrite_f, "pwrite", POLLOUT, fd, fd, buf, count, offset);
#else
return EHooker::comm_io_on_fiber(pwrite_f, "pwrite", POLLOUT, fd, buf, count, offset);
#endif
}
size_t fread(void *ptr, size_t size, size_t nitems, FILE *stream)
{
return EHooker::comm_io_on_fiber(fread_f, "fread", POLLIN, eso_fileno(stream), ptr, size, nitems, stream);
}
size_t fwrite(const void *ptr, size_t size, size_t nitems, FILE *stream)
{
return EHooker::comm_io_on_fiber(fwrite_f, "fwrite", POLLOUT, eso_fileno(stream), ptr, size, nitems, stream);
}
//=============================================================================
#ifdef __linux__
struct hostbuf_wrap
{
struct hostent host;
char* buffer;
size_t iBufferSize;
int host_errno;
};
static void fiber_destroyed_callback_to_free_res_state(void* data) {
if (data) {
res_state w = (res_state)data;
if (w) free(w);
}
}
static void fiber_destroyed_callback_to_free_hostbuf_wrap(void* data) {
if (data) {
hostbuf_wrap* w = (hostbuf_wrap*)data;
if (w->buffer) free(w->buffer);
free(w);
}
}
static EFiberLocal<res_state> res_state_local(fiber_destroyed_callback_to_free_res_state);
static EFiberLocal<hostbuf_wrap*> hostbuf_wrap_local(fiber_destroyed_callback_to_free_hostbuf_wrap);
res_state __res_state()
{
EHooker::_initzz_();
EFiberScheduler* scheduler = EFiberScheduler::currentScheduler();
if (!scheduler || EHooker::isInterrupted()) {
return __res_state_f();
}
res_state rs = res_state_local.get();
if (!rs) {
rs = (res_state)malloc(sizeof(struct __res_state));
res_state_local.set(rs);
}
return rs;
}
struct hostent *gethostbyname(const char *name)
{
if (!name) {
return NULL;
}
EHooker::_initzz_();
EFiberScheduler* scheduler = EFiberScheduler::currentScheduler();
if (!scheduler || EHooker::isInterrupted()) {
return gethostbyname_f(name);
}
hostbuf_wrap* hw = hostbuf_wrap_local.get();
if (!hw) {
hw = (hostbuf_wrap*)calloc(1, sizeof(hostbuf_wrap));
hostbuf_wrap_local.set(hw);
}
if (hw->buffer && hw->iBufferSize > 1024) {
free(hw->buffer);
hw->buffer = NULL;
}
if (!hw->buffer) {
hw->buffer = (char*)malloc(1024);
hw->iBufferSize = 1024;
}
struct hostent *host = &hw->host;
struct hostent *result = NULL;
int *h_errnop = &(hw->host_errno);
RETRY:
#ifdef __GLIBC__
gethostbyname_r(name, host, hw->buffer, hw->iBufferSize, &result, h_errnop);
#else
result = gethostbyname_r(name, host, hw->buffer, hw->iBufferSize, h_errnop);
#endif
while (result == NULL && errno == ERANGE) {
hw->iBufferSize = hw->iBufferSize * 2;
hw->buffer = (char*)realloc(hw->buffer, hw->iBufferSize);
goto RETRY;
}
return result;
}
int __poll(struct pollfd fds[], nfds_t nfds, int timeout)
{
return poll(fds, nfds, timeout);
}
int epoll_wait(int epfd, struct epoll_event *events,
int maxevents, int timeout)
{
EHooker::_initzz_();
EFiberScheduler* scheduler = EFiberScheduler::currentScheduler();
if (!scheduler || timeout == 0 || EHooker::isInterrupted()) {
return epoll_wait_f(epfd, events, maxevents, timeout);
}
// waiting for events signal
EIoWaiter* ioWaiter = EFiberScheduler::currentIoWaiter();
sp<EFiber> fiber = EFiber::currentFiber()->shared_from_this();
ioWaiter->setFileEvent(epfd, ECO_POLL_READABLE, fiber);
llong milliseconds = (timeout > 0) ? timeout : EInteger::MAX_VALUE;
llong timerID = ioWaiter->setupTimer(milliseconds, fiber);
ioWaiter->swapOut(fiber); // pause the fiber.
ioWaiter->cancelTimer(timerID);
ioWaiter->delFileEvent(epfd, ECO_POLL_ALL_EVENTS);
if (fiber->isWaitTimeout()) {
errno = EINVAL;
return -1;
} else {
return epoll_wait_f(epfd, events, maxevents, 0);
}
}
ssize_t sendfile(int out_fd, int in_fd, off_t *offset, size_t count)
{
EHooker::_initzz_();
EFiberScheduler* scheduler = EFiberScheduler::currentScheduler();
if (!scheduler || !EFileContext::isStreamFile(out_fd) || EHooker::isInterrupted()) {
return sendfile_f(out_fd, in_fd, offset, count);
}
sp<EFileContext> fdctx = scheduler->getFileContext(out_fd);
if (!fdctx) {
return -1;
}
boolean isUNB = fdctx->isUserNonBlocked();
if (isUNB) {
return sendfile_f(out_fd, in_fd, offset, count);
}
int milliseconds = fdctx->getSendTimeout();
if (milliseconds == 0) milliseconds = -1;
off_t offset_ = offset ? *offset : 0;
RETRY:
pollfd pfd;
pfd.fd = out_fd;
pfd.events = POLLOUT;
pfd.revents = 0;
ssize_t ret = poll(&pfd, 1, milliseconds);
if (ret == 1) { //success
ret = sendfile_f(out_fd, in_fd, &offset_, count);
if (ret > 0) count -= ret;
if ((ret >= 0 && count > 0)
|| (ret == -1 && (errno == EAGAIN || errno == EWOULDBLOCK))) {
if (count > 0) goto RETRY;
}
} else if (ret == 0) { //timeout
ret = -1;
errno = isUNB ? EAGAIN : ETIMEDOUT;
}
if (offset) *offset = offset_;
if (ret == 0) errno = 0;
return ret;
}
#else // __APPLE__
// gethostbyname() is asynchronous already, @see libinfo/mdns_module.c:_mdns_search():kqueue!
int kevent(int kq, const struct kevent *changelist, int nchanges,
struct kevent *eventlist, int nevents, const struct timespec *timeout)
{
EHooker::_initzz_();
EFiberScheduler* scheduler = EFiberScheduler::currentScheduler();
if (!scheduler || EHooker::isInterrupted()) {
return kevent_f(kq, changelist, nchanges, eventlist, nevents, timeout);
}
if ((timeout && timeout->tv_sec == 0 && timeout->tv_nsec == 0) || !eventlist || nevents == 0) {
// try at immediately.
return kevent_f(kq, changelist, nchanges, eventlist, nevents, timeout);
}
// waiting for events signal
if (changelist && nchanges > 0) {
kevent_f(kq, changelist, nchanges, NULL, 0, NULL);
}
EIoWaiter* ioWaiter = EFiberScheduler::currentIoWaiter();
sp<EFiber> fiber = EFiber::currentFiber()->shared_from_this();
ioWaiter->setFileEvent(kq, ECO_POLL_READABLE, fiber);
llong milliseconds = timeout ? (timeout->tv_sec * 1000 + timeout->tv_nsec / 1000000) : EInteger::MAX_VALUE;
llong timerID = ioWaiter->setupTimer(milliseconds, fiber);
ioWaiter->swapOut(fiber); // pause the fiber.
ioWaiter->cancelTimer(timerID);
ioWaiter->delFileEvent(kq, ECO_POLL_ALL_EVENTS);
if (fiber->isWaitTimeout()) {
errno = EINVAL;
return -1;
} else {
struct timespec zerotv = {0, 0};
return kevent_f(kq, NULL, 0, eventlist, nevents, &zerotv);
}
}
int kevent64(int kq, const struct kevent64_s *changelist, int nchanges,
struct kevent64_s *eventlist, int nevents, unsigned int flags,
const struct timespec *timeout)
{
EHooker::_initzz_();
EFiberScheduler* scheduler = EFiberScheduler::currentScheduler();
if (!scheduler || EHooker::isInterrupted()) {
return kevent64_f(kq, changelist, nchanges, eventlist, nevents, flags, timeout);
}
if ((timeout && timeout->tv_sec == 0 && timeout->tv_nsec == 0) || !eventlist || nevents == 0) {
// try once at immediately.
return kevent64_f(kq, changelist, nchanges, eventlist, nevents, flags, timeout);
}
// waiting for events signal
if (changelist && nchanges > 0) {
kevent64_f(kq, changelist, nchanges, NULL, 0, flags, NULL);
}
EIoWaiter* ioWaiter = EFiberScheduler::currentIoWaiter();
sp<EFiber> fiber = EFiber::currentFiber()->shared_from_this();
ioWaiter->setFileEvent(kq, ECO_POLL_READABLE, fiber);
llong milliseconds = timeout ? (timeout->tv_sec * 1000 + timeout->tv_nsec / 1000000) : EInteger::MAX_VALUE;
llong timerID = ioWaiter->setupTimer(milliseconds, fiber);
ioWaiter->swapOut(fiber); // pause the fiber.
ioWaiter->cancelTimer(timerID);
ioWaiter->delFileEvent(kq, ECO_POLL_ALL_EVENTS);
if (fiber->isWaitTimeout()) {
errno = EINVAL;
return -1;
} else {
struct timespec zerotv = {0, 0};
return kevent64_f(kq, NULL, 0, eventlist, nevents, flags, &zerotv);
}
}
int sendfile(int fd, int s, off_t offset, off_t *len, struct sf_hdtr *hdtr, int flags)
{
EHooker::_initzz_();
EFiberScheduler* scheduler = EFiberScheduler::currentScheduler();
if (!scheduler || !EFileContext::isStreamFile(s) || EHooker::isInterrupted()) {
return sendfile_f(fd, s, offset, len, hdtr, flags);
}
sp<EFileContext> fdctx = scheduler->getFileContext(s);
if (!fdctx) {
return -1;
}
boolean isUNB = fdctx->isUserNonBlocked();
if (isUNB) {
return sendfile_f(fd, s, offset, len, hdtr, flags);
}
int milliseconds = fdctx->getSendTimeout();
if (milliseconds == 0) milliseconds = -1;
off_t inlen = len ? *len : 0;
off_t outlen;
RETRY:
pollfd pfd;
pfd.fd = s;
pfd.events = POLLOUT;
pfd.revents = 0;
int ret = poll(&pfd, 1, milliseconds);
if (ret == 1) { //success
outlen = inlen;
ret = sendfile_f(fd, s, offset, &outlen, hdtr, flags);
if (ret == -1 && (errno == EAGAIN || errno == EWOULDBLOCK)) {
if (outlen > 0) {
offset += outlen;
inlen -= outlen;
}
if (inlen > 0) goto RETRY;
}
} else if (ret == 0) { //timeout
ret = -1;
errno = isUNB ? EAGAIN : ETIMEDOUT;
}
if (ret == 0) errno = 0;
return ret;
}
#endif
} //!C
//=============================================================================
boolean EHooker::isInterrupted() {
return process_signaled;
}
llong EHooker::interruptEscapedTime() {
return interrupt_escaped_time;
}
#ifdef CPP11_SUPPORT
template <typename F, typename ... Args>
ssize_t EHooker::comm_io_on_fiber(F fn, const char* name, int event, int fd, Args&&... args) {
EHooker::_initzz_();
EFiberScheduler* scheduler = EFiberScheduler::currentScheduler();
if (!scheduler || !EFileContext::isStreamFile(fd) || EHooker::isInterrupted()) {
return fn(std::forward<Args>(args)...);
}
sp<EFileContext> fdctx = scheduler->getFileContext(fd);
if (!fdctx) {
return -1;
}
boolean isUNB = fdctx->isUserNonBlocked();
if (isUNB) {
return fn(std::forward<Args>(args)...);
}
ssize_t ret = -1;
if ((event & POLLOUT) == POLLOUT) {
// try once at immediately.
ret = fn(std::forward<Args>(args)...);
if (ret >= 0) { //success?
goto SUCCESS;
}
}
// try io wait.
{
int milliseconds = (event == POLLIN) ? fdctx->getRecvTimeout() : fdctx->getSendTimeout();
if (milliseconds == 0) milliseconds = -1;
RETRY:
pollfd pfd;
pfd.fd = fd;
pfd.events = event;
pfd.revents = 0;
ret = poll(&pfd, 1, milliseconds);
if (ret == 1) { //success
ret = fn(std::forward<Args>(args)...);
if (ret == -1 && (errno == EAGAIN || errno == EWOULDBLOCK)) {
goto RETRY;
}
} else if (ret == 0) { //timeout
ret = -1;
errno = isUNB ? EAGAIN : ETIMEDOUT;
}
}
SUCCESS:
if (ret >= 0 && ((intptr_t)fn == (intptr_t)accept_f)) {
// if listen socket is non-blocking then accepted socket also non-blocking,
// we need reset it to back.
int socket = (int)ret;
int flags = fcntl_f(socket, F_GETFL);
fcntl_f(socket, F_SETFL, flags & ~O_NONBLOCK);
}
return ret;
}
#else //!
template <typename F>
static ssize_t call_fn(EFileContext* fdctx, F fn, int fd, va_list _args) {
ssize_t ret = -1;
va_list args;
#ifdef va_copy
va_copy(args, _args);
#else
args = _args;
#endif
if ((intptr_t)fn == (intptr_t)accept_f) {
struct sockaddr* addr = va_arg(args, struct sockaddr*);
socklen_t* addrlen = va_arg(args, socklen_t*);
int socket = accept_f(fd, addr, addrlen);
if (socket >= 0 && fdctx != null && !fdctx->isUserNonBlocked()) {
// if listen socket is non-blocking then accepted socket also non-blocking,
// we need reset it to back.
int flags = fcntl_f(socket, F_GETFL);
fcntl_f(socket, F_SETFL, flags & ~O_NONBLOCK);
}
ret = socket;
}
else if ((intptr_t)fn == (intptr_t)read_f) {
void* buf = va_arg(args, void*);
size_t count = va_arg(args, size_t);
ret = read_f(fd, buf, count);
}
else if ((intptr_t)fn == (intptr_t)readv_f) {
struct iovec* iov = va_arg(args, struct iovec*);
int iovcnt = va_arg(args, int);
ret = readv_f(fd, iov, iovcnt);
}
else if ((intptr_t)fn == (intptr_t)recv_f) {
void *buf = va_arg(args, void*);
size_t len = va_arg(args, size_t);
int flags = va_arg(args, int);
ret = recv_f(fd, buf, len, flags);
}
else if ((intptr_t)fn == (intptr_t)recvfrom_f) {
void *buf = va_arg(args, void*);
size_t len = va_arg(args, size_t);
int flags = va_arg(args, int);
struct sockaddr *src_addr = va_arg(args, struct sockaddr*);
socklen_t *addrlen = va_arg(args, socklen_t*);
ret = recvfrom_f(fd, buf, len, flags, src_addr, addrlen);
}
else if ((intptr_t)fn == (intptr_t)recvmsg_f) {
struct msghdr *msg = va_arg(args, struct msghdr*);
int flags = va_arg(args, int);
ret = recvmsg_f(fd, msg, flags);
}
else if ((intptr_t)fn == (intptr_t)write_f) {
void* buf = va_arg(args, void*);
size_t count = va_arg(args, size_t);
ret = write_f(fd, buf, count);
}
else if ((intptr_t)fn == (intptr_t)writev_f) {
struct iovec* iov = va_arg(args, struct iovec*);
int iovcnt = va_arg(args, int);
ret = writev_f(fd, iov, iovcnt);
}
else if ((intptr_t)fn == (intptr_t)send_f) {
void *buf = va_arg(args, void*);
size_t len = va_arg(args, size_t);
int flags = va_arg(args, int);
ret = send_f(fd, buf, len, flags);
}
else if ((intptr_t)fn == (intptr_t)sendto_f) {
void *buf = va_arg(args, void*);
size_t len = va_arg(args, size_t);
int flags = va_arg(args, int);
struct sockaddr *dest_addr = va_arg(args, struct sockaddr*);
socklen_t addrlen = va_arg(args, socklen_t);
ret = sendto_f(fd, buf, len, flags, dest_addr, addrlen);
}
else if ((intptr_t)fn == (intptr_t)sendmsg_f) {
struct msghdr *msg = va_arg(args, struct msghdr*);
int flags = va_arg(args, int);
ret = sendmsg_f(fd, msg, flags);
}
else if ((intptr_t)fn == (intptr_t)fread_f) { //fread
void *ptr = va_arg(args, void*);
size_t size = va_arg(args, size_t);
size_t nitems = va_arg(args, size_t);
FILE *stream = va_arg(args, FILE*);
ret = fread_f(ptr, size, nitems, stream);
}
else if ((intptr_t)fn == (intptr_t)fwrite_f) { //fwrite
void *ptr = va_arg(args, void*);
size_t size = va_arg(args, size_t);
size_t nitems = va_arg(args, size_t);
FILE *stream = va_arg(args, FILE*);
ret = fwrite_f(ptr, size, nitems, stream);
}
else if ((intptr_t)fn == (intptr_t)pread_f) {
void *buf = va_arg(args, void*);
size_t count = va_arg(args, size_t);
off_t offset = va_arg(args, off_t);
ret = pread_f(fd, buf, count, offset);
}
else if ((intptr_t)fn == (intptr_t)pwrite_f) {
void *buf = va_arg(args, void*);
size_t count = va_arg(args, size_t);
off_t offset = va_arg(args, off_t);
ret = pwrite_f(fd, buf, count, offset);
}
else {
#ifdef va_copy
va_end(args);
#endif
throw EUnsupportedOperationException(__FILE__, __LINE__);
}
#ifdef va_copy
va_end(args);
#endif
return ret;
}
template <typename F>
ssize_t EHooker::comm_io_on_fiber(F fn, const char* name, int event, int fd, ...) {
EHooker::_initzz_();
ssize_t ret;
va_list args;
va_start(args, fd);
EFiberScheduler* scheduler = EFiberScheduler::currentScheduler();
if (!scheduler || !EFileContext::isStreamFile(fd) || EHooker::isInterrupted()) {
ret = call_fn(null, fn, fd, args);
va_end(args);
return ret;
}
sp<EFileContext> fdctx = scheduler->getFileContext(fd);
if (!fdctx) {
va_end(args);
return -1;
}
boolean isUNB = fdctx->isUserNonBlocked();
if (isUNB) {
ret = call_fn(null, fn, fd, args);
va_end(args);
return ret;
}
if ((event & POLLOUT) == POLLOUT) {
// try once at immediately.
ret = call_fn(fdctx.get(), fn, fd, args);
if (ret >= 0) { //success?
va_end(args);
return ret;
}
}
int milliseconds = (event == POLLIN) ? fdctx->getRecvTimeout() : fdctx->getSendTimeout();
if (milliseconds == 0) milliseconds = -1;
RETRY:
pollfd pfd;
pfd.fd = fd;
pfd.events = event;
pfd.revents = 0;
ret = poll(&pfd, 1, milliseconds);
if (ret == 1) { //success
ret = call_fn(fdctx.get(), fn, fd, args);
if (ret == -1 && (errno == EAGAIN || errno == EWOULDBLOCK)) {
goto RETRY;
}
} else if (ret == 0) { //timeout
ret = -1;
errno = isUNB ? EAGAIN : ETIMEDOUT;
}
va_end(args);
return ret;
}
#endif //!CPP11_SUPPORT
//=============================================================================
extern "C" {
struct rebinding __rebinding[] = {
{ "signal", (void*) signal, NULL },
{ "sleep", (void*) sleep, NULL },
{ "usleep", (void*) usleep, NULL },
{ "nanosleep", (void*) nanosleep, NULL },
{ "close", (void*) close, NULL },
{ "fcntl", (void*) fcntl, NULL },
{ "setsockopt", (void*) setsockopt, NULL },
{ "dup2", (void*) dup2, NULL },
{ "poll", (void*) poll, NULL },
{ "select", (void*) select, NULL },
{ "connect", (void*) connect, NULL },
{ "accept", (void*) accept, NULL },
{ "read", (void*) read, NULL },
{ "readv", (void*) readv, NULL },
{ "recvfrom", (void*) recvfrom, NULL },
{ "recvmsg", (void*) recvmsg, NULL },
{ "write", (void*) write, NULL },
{ "writev", (void*) writev, NULL },
{ "send", (void*) send, NULL },
{ "sendto", (void*) sendto, NULL },
{ "sendmsg", (void*) sendmsg, NULL },
{ "fread", (void*) fread, NULL },
{ "fwrite", (void*) fwrite, NULL },
{ "pread", (void*) pread, NULL },
{ "pwrite", (void*) pwrite, NULL },
{ "sendfile", (void*) sendfile, NULL },
{ "dlopen", (void*) dlopen, NULL }
#ifdef __linux__
,
{ "dup3", (void*) dup3, NULL },
{ "gethostbyname", (void*) gethostbyname, NULL },
{ "__res_state", (void*) __res_state, NULL },
{ "__poll", (void*) __poll, NULL },
{ "epoll_wait", (void*) epoll_wait, NULL }
#endif
#ifdef __APPLE__
,
{ "kevent", (void*) kevent, NULL },
{ "kevent64", (void*) kevent64, NULL }
#endif
};
#ifdef __linux__
void* dlopen(const char* path, int mode)
{
void* handle = dlopen_f(path, mode);
if (handle) {
rebind_symbols_image(path, handle, __rebinding, ES_ARRAY_LEN(__rebinding));
}
return handle;
}
#else //__APPLE__
static const char * first_external_symbol_for_image(
const mach_header_t *header) {
Dl_info info;
if (dladdr(header, &info) == 0)
return NULL;
segment_command_t *seg_linkedit = NULL;
segment_command_t *seg_text = NULL;
struct symtab_command *symtab = NULL;
struct load_command *cmd = (struct load_command *) ((intptr_t) header
+ sizeof(mach_header_t));
for (uint32_t i = 0; i < header->ncmds;
i++, cmd = (struct load_command *) ((intptr_t) cmd + cmd->cmdsize)) {
switch (cmd->cmd) {
case LC_SEGMENT:
case LC_SEGMENT_64:
if (!strcmp(((segment_command_t *) cmd)->segname, SEG_TEXT))
seg_text = (segment_command_t *) cmd;
else if (!strcmp(((segment_command_t *) cmd)->segname,
SEG_LINKEDIT))
seg_linkedit = (segment_command_t *) cmd;
break;
case LC_SYMTAB:
symtab = (struct symtab_command *) cmd;
break;
}
}
if ((seg_text == NULL) || (seg_linkedit == NULL) || (symtab == NULL))
return NULL;
intptr_t file_slide = ((intptr_t) seg_linkedit->vmaddr
- (intptr_t) seg_text->vmaddr) - seg_linkedit->fileoff;
intptr_t strings = (intptr_t) header + (symtab->stroff + file_slide);
nlist_t *sym = (nlist_t *) ((intptr_t) header
+ (symtab->symoff + file_slide));
for (uint32_t i = 0; i < symtab->nsyms; i++, sym++) {
if ((sym->n_type & N_EXT) != N_EXT || !sym->n_value)
continue;
return (const char *) strings + sym->n_un.n_strx;
}
return NULL;
}
void* dlopen(const char* path, int mode) {
void* h = dlopen_f(path, mode); //!
if (h) {
/**
* in order to trigger findExportedSymbol instead of findExportedSymbolInImageOrDependentImages.
* See `dlsym` implementation at http://opensource.apple.com/source/dyld/dyld-239.3/src/dyldAPIs.cpp
*/
void* handle = (void *) ((intptr_t) h | 1);
for (int32_t i = _dyld_image_count(); i >= 0; i--) {
const char *first_symbol = first_external_symbol_for_image(
(const mach_header_t *) _dyld_get_image_header(i));
if (first_symbol && *first_symbol) {
first_symbol++; // in order to remove the leading underscore
void *address = dlsym(handle, first_symbol);
if (address) {
Dl_info info;
if (dladdr(address, &info)) {
rebind_symbols_image(info.dli_fbase,
_dyld_get_image_vmaddr_slide(i),
__rebinding, ES_ARRAY_LEN(__rebinding));
}
break; //!
}
}
}
}
return h;
}
#endif //!
} //!C
} /* namespace eco */
} /* namespace efc */
| 26.944517
| 118
| 0.672473
|
cxxjava
|
d4f08af725ac4c4915603a9ee3da04b2cbda6646
| 4,269
|
hpp
|
C++
|
modules/viz/include/opencv2/viz.hpp
|
Nerei/opencv
|
92d5f8744c872ccf63b17334f018343973353e47
|
[
"BSD-3-Clause"
] | 1
|
2015-04-22T14:10:46.000Z
|
2015-04-22T14:10:46.000Z
|
modules/viz/include/opencv2/viz.hpp
|
ameydhar/opencv
|
1c3bfae2121f689535ab1a17284f40f5d64e0927
|
[
"BSD-3-Clause"
] | null | null | null |
modules/viz/include/opencv2/viz.hpp
|
ameydhar/opencv
|
1c3bfae2121f689535ab1a17284f40f5d64e0927
|
[
"BSD-3-Clause"
] | 2
|
2018-05-03T21:08:19.000Z
|
2020-09-26T06:27:08.000Z
|
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// * The name of the copyright holders may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors "as is" and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
// Authors:
// * Ozan Tonkal, ozantonkal@gmail.com
// * Anatoly Baksheev, Itseez Inc. myname.mysurname <> mycompany.com
//
// OpenCV Viz module is complete rewrite of
// PCL visualization module (www.pointclouds.org)
//
//M*/
#ifndef __OPENCV_VIZ_HPP__
#define __OPENCV_VIZ_HPP__
#include <opencv2/viz/types.hpp>
#include <opencv2/viz/widgets.hpp>
#include <opencv2/viz/viz3d.hpp>
namespace cv
{
namespace viz
{
//! takes coordiante frame data and builds transfrom to global coordinate frame
CV_EXPORTS Affine3f makeTransformToGlobal(const Vec3f& axis_x, const Vec3f& axis_y, const Vec3f& axis_z, const Vec3f& origin = Vec3f::all(0));
//! constructs camera pose from position, focal_point and up_vector (see gluLookAt() for more infromation)
CV_EXPORTS Affine3f makeCameraPose(const Vec3f& position, const Vec3f& focal_point, const Vec3f& y_dir);
//! retrieves a window by its name. If no window with such name, then it creates new.
CV_EXPORTS Viz3d get(const String &window_name);
//! Unregisters all Viz windows from internal database. After it 'get()' will create new windows instead getting existing from the database.
CV_EXPORTS void unregisterAllWindows();
//! checks float value for Nan
inline bool isNan(float x)
{
unsigned int *u = reinterpret_cast<unsigned int *>(&x);
return ((u[0] & 0x7f800000) == 0x7f800000) && (u[0] & 0x007fffff);
}
//! checks double value for Nan
inline bool isNan(double x)
{
unsigned int *u = reinterpret_cast<unsigned int *>(&x);
return (u[1] & 0x7ff00000) == 0x7ff00000 && (u[0] != 0 || (u[1] & 0x000fffff) != 0);
}
//! checks vectors for Nans
template<typename _Tp, int cn> inline bool isNan(const Vec<_Tp, cn>& v)
{ return isNan(v.val[0]) || isNan(v.val[1]) || isNan(v.val[2]); }
//! checks point for Nans
template<typename _Tp> inline bool isNan(const Point3_<_Tp>& p)
{ return isNan(p.x) || isNan(p.y) || isNan(p.z); }
} /* namespace viz */
} /* namespace cv */
#endif /* __OPENCV_VIZ_HPP__ */
| 43.561224
| 150
| 0.676037
|
Nerei
|
d4f8b23421ac1afb4535fd401b3ac24b99887c11
| 6,131
|
cpp
|
C++
|
code/wxWidgets/src/motif/colour.cpp
|
Bloodknight/NeuTorsion
|
a5890e9ca145a8c1b6bec7b70047a43d9b1c29ea
|
[
"MIT"
] | 38
|
2016-02-20T02:46:28.000Z
|
2021-11-17T11:39:57.000Z
|
code/wxWidgets/src/motif/colour.cpp
|
Dwarf-King/TorsionEditor
|
e6887d1661ebaf4ccbf1d09f2690e2bf805fbb50
|
[
"MIT"
] | 17
|
2016-02-20T02:19:55.000Z
|
2021-02-08T15:15:17.000Z
|
code/wxWidgets/src/motif/colour.cpp
|
Dwarf-King/TorsionEditor
|
e6887d1661ebaf4ccbf1d09f2690e2bf805fbb50
|
[
"MIT"
] | 46
|
2016-02-20T02:47:33.000Z
|
2021-01-31T15:46:05.000Z
|
/////////////////////////////////////////////////////////////////////////////
// Name: colour.cpp
// Purpose: wxColour class
// Author: Julian Smart
// Modified by:
// Created: 17/09/98
// RCS-ID: $Id: colour.cpp,v 1.16 2005/02/06 17:38:29 MBN Exp $
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
//// TODO: make wxColour a ref-counted object,
//// so pixel values get shared.
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma implementation "colour.h"
#endif
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#include "wx/gdicmn.h"
#include "wx/colour.h"
#include "wx/app.h"
#ifdef __VMS__
#pragma message disable nosimpint
#endif
#include <Xm/Xm.h>
#ifdef __VMS__
#pragma message enable nosimpint
#endif
#include "wx/motif/private.h"
IMPLEMENT_DYNAMIC_CLASS(wxColour, wxObject)
// Colour
void wxColour::Init()
{
m_isInit = false;
m_red =
m_blue =
m_green = 0;
m_pixel = -1;
}
wxColour::wxColour()
{
Init();
}
wxColour::wxColour(const wxColour& col)
{
*this = col;
}
wxColour& wxColour::operator =(const wxColour& col)
{
m_red = col.m_red;
m_green = col.m_green;
m_blue = col.m_blue;
m_isInit = col.m_isInit;
m_pixel = col.m_pixel;
return *this;
}
void wxColour::InitFromName(const wxString& name)
{
if ( wxTheColourDatabase )
{
wxColour col = wxTheColourDatabase->Find(name);
if ( col.Ok() )
{
*this = col;
return;
}
}
// leave invalid
Init();
}
/* static */
wxColour wxColour::CreateByName(const wxString& name)
{
wxColour col;
Display *dpy = wxGlobalDisplay();
WXColormap colormap = wxTheApp->GetMainColormap( dpy );
XColor xcol;
if ( XParseColor( dpy, (Colormap)colormap, name.mb_str(), &xcol ) )
{
col.m_red = xcol.red & 0xff;
col.m_green = xcol.green & 0xff;
col.m_blue = xcol.blue & 0xff;
col.m_isInit = true;
col.m_pixel = -1;
}
return col;
}
wxColour::~wxColour()
{
}
void wxColour::Set(unsigned char r, unsigned char g, unsigned char b)
{
m_red = r;
m_green = g;
m_blue = b;
m_isInit = true;
m_pixel = -1;
}
// Allocate a colour, or nearest colour, using the given display.
// If realloc is true, ignore the existing pixel, otherwise just return
// the existing one.
// Returns the old or allocated pixel.
// TODO: can this handle mono displays? If not, we should have an extra
// flag to specify whether this should be black or white by default.
int wxColour::AllocColour(WXDisplay* display, bool realloc)
{
if ((m_pixel != -1) && !realloc)
return m_pixel;
XColor color;
color.red = (unsigned short) Red ();
color.red |= color.red << 8;
color.green = (unsigned short) Green ();
color.green |= color.green << 8;
color.blue = (unsigned short) Blue ();
color.blue |= color.blue << 8;
color.flags = DoRed | DoGreen | DoBlue;
WXColormap cmap = wxTheApp->GetMainColormap(display);
if (!XAllocColor ((Display*) display, (Colormap) cmap, &color))
{
m_pixel = wxGetBestMatchingPixel((Display*) display, &color,(Colormap) cmap);
return m_pixel;
}
else
{
m_pixel = (int) color.pixel;
return m_pixel;
}
}
/*-------------------------------------------
Markus Emmenegger <mege@iqe.ethz.ch>
Find the pixel value with an assigned color closest to the desired color
Used if color cell allocation fails
As the returned pixel value may be in use by another application,
the color might change anytime.
But in many cases, that is still better than always using black.
--
Chris Breeze <chris@hel.co.uk>
Improvements:
1) More efficient calculation of RGB distance of colour cell from
the desired colour. There is no need to take the sqrt of 'dist', and
since we are only interested in the top 8-bits of R, G and B we
can perform integer arithmetic.
2) Attempt to allocate a read-only colour when a close match is found.
A read-only colour will not change.
3) Fall back to the closest match if no read-only colours are available.
Possible further improvements:
1) Scan the lookup table and sort the colour cells in order of
increasing
distance from the desired colour. Then attempt to allocate a
read-only
colour starting from the nearest match.
2) Linear RGB distance is not a particularly good method of colour
matching
(though it is quick). Converting the colour to HLS and then comparing
may give better matching.
-------------------------------------------*/
int wxGetBestMatchingPixel(Display *display, XColor *desiredColor, Colormap cmap)
{
if (cmap == (Colormap) NULL)
cmap = (Colormap) wxTheApp->GetMainColormap(display);
int numPixVals = XDisplayCells(display, DefaultScreen (display));
int mindist = 256 * 256 * 3;
int bestpixel = (int) BlackPixel (display, DefaultScreen (display));
int red = desiredColor->red >> 8;
int green = desiredColor->green >> 8;
int blue = desiredColor->blue >> 8;
const int threshold = 2 * 2 * 3; // allow an error of up to 2 in R,G & B
for (int pixelcount = 0; pixelcount < numPixVals; pixelcount++)
{
XColor matching_color;
matching_color.pixel = pixelcount;
XQueryColor(display,cmap,&matching_color);
int delta_red = red - (matching_color.red >> 8);
int delta_green = green - (matching_color.green >> 8);
int delta_blue = blue - (matching_color.blue >> 8);
int dist = delta_red * delta_red +
delta_green * delta_green +
delta_blue * delta_blue;
if (dist <= threshold)
{
// try to allocate a read-only colour...
if (XAllocColor (display, cmap, &matching_color))
{
return matching_color.pixel;
}
}
if (dist < mindist)
{
bestpixel = pixelcount;
mindist = dist;
}
}
return bestpixel;
}
| 26.890351
| 85
| 0.619801
|
Bloodknight
|
d4fb7098083ee0f3440c9361171afbb35927a570
| 8,970
|
hpp
|
C++
|
dsa/include/dsa/list.hpp
|
Abstract-Everything/dsa
|
fcbc0f4fa1eb3493f0e1b8f05d7f159ea6f2342c
|
[
"Unlicense"
] | null | null | null |
dsa/include/dsa/list.hpp
|
Abstract-Everything/dsa
|
fcbc0f4fa1eb3493f0e1b8f05d7f159ea6f2342c
|
[
"Unlicense"
] | null | null | null |
dsa/include/dsa/list.hpp
|
Abstract-Everything/dsa
|
fcbc0f4fa1eb3493f0e1b8f05d7f159ea6f2342c
|
[
"Unlicense"
] | null | null | null |
#ifndef DSA_LIST_HPP
#define DSA_LIST_HPP
#include <dsa/allocator_traits.hpp>
#include <dsa/default_allocator.hpp>
#include <dsa/node.hpp>
#include <cstddef>
#include <memory>
namespace dsa
{
namespace detail
{
template<typename Satellite_t, template<typename> typename Allocator_Base>
class List_Node
{
private:
friend class Node_Traits<List_Node>;
using Alloc_Traits = Allocator_Traits<Allocator_Base<List_Node>>;
using Allocator = typename Alloc_Traits::Allocator;
using Pointer = typename Alloc_Traits::Pointer;
using Const_Pointer = typename Alloc_Traits::Const_Pointer;
using Satellite_Alloc_Traits = Allocator_Traits<Allocator_Base<Satellite_t>>;
using Satellite = typename Satellite_Alloc_Traits::Value;
using Satellite_Pointer = typename Satellite_Alloc_Traits::Reference;
using Satellite_Const_Pointer = typename Satellite_Alloc_Traits::Const_Reference;
using Satellite_Reference = typename Satellite_Alloc_Traits::Reference;
using Satellite_Const_Reference = typename Satellite_Alloc_Traits::Const_Reference;
template<bool Is_Const>
class Iterator_Detail
{
private:
using Node_Pointer = std::conditional_t<
Is_Const,
typename List_Node::Const_Pointer,
typename List_Node::Pointer>;
using Pointer = std::conditional_t<
Is_Const,
typename List_Node::Satellite_Const_Pointer,
typename List_Node::Satellite_Pointer>;
using Reference = std::conditional_t<
Is_Const,
typename List_Node::Satellite_Const_Reference,
typename List_Node::Satellite_Reference>;
public:
explicit Iterator_Detail(Node_Pointer node) : m_node(node)
{
}
Iterator_Detail operator++()
{
m_node = m_node->m_next;
Iterator_Detail iterator(m_node);
return iterator;
}
bool operator==(Iterator_Detail const &iterator) const
{
return m_node == iterator.m_node;
}
bool operator!=(Iterator_Detail const &iterator) const
{
return !this->operator==(iterator);
}
Reference operator*() const
{
return m_node->m_satellite;
}
Pointer operator->() const
{
return m_node->m_satellite;
}
private:
Node_Pointer m_node;
};
public:
using Iterator = Iterator_Detail<false>;
using Const_Iterator = Iterator_Detail<true>;
Satellite m_satellite;
Pointer m_next;
void initialise()
{
m_next = nullptr;
}
};
} // namespace detail
// ToDo: Use iterators to make insertion/ deletion constant time
/**
* @brief Holds a set of non contigious elements in a singly linked list.
*
* @ingroup containers
*
* @tparam Value_t: The type of element to store
* @tparam Pointer_Base: The type of pointer used to refer to memory
* @tparam Allocator_Base: The type of allocator used for memory management
*
*/
template<typename Value_t, template<typename> typename Allocator_Base = Default_Allocator>
class List
{
private:
using Node = detail::List_Node<Value_t, Allocator_Base>;
using Node_Traits = detail::Node_Traits<Node>;
using Node_Allocator = typename Node_Traits::Allocator;
using Node_Pointer = typename Node_Traits::Pointer;
using Node_Const_Pointer = typename Node_Traits::Const_Pointer;
using Alloc_Traits = Allocator_Traits<Allocator_Base<Value_t>>;
public:
using Allocator = typename Alloc_Traits::Allocator;
using Value = typename Alloc_Traits::Value;
using Pointer = typename Alloc_Traits::Pointer;
using Const_Pointer = typename Alloc_Traits::Const_Pointer;
using Iterator = typename Node::Iterator;
using Const_Iterator = typename Node::Const_Iterator;
/**
* @brief Constructs an empty list
*/
explicit List(const Allocator &allocator = Allocator{})
: m_allocator(allocator)
{
}
/**
* @brief Constructs a list filled with the given values
*/
List(
std::initializer_list<Value_t> values,
const Allocator &allocator = Allocator())
: m_allocator(allocator)
{
Node_Pointer *next = &m_head;
for (auto value : values)
{
Node_Pointer &to = *next;
to = Node_Traits::create_node(m_allocator, value);
next = &to->m_next;
}
}
~List()
{
clear();
}
List(List const &list) : m_allocator(list.m_allocator)
{
Node_Pointer from = list.m_head;
Node_Pointer *next = &m_head;
while (from != nullptr)
{
Node_Pointer &to = *next;
to = Node_Traits::create_node(
m_allocator,
from->m_satellite);
next = &to->m_next;
from = from->m_next;
}
}
friend void swap(List &lhs, List &rhs)
{
using std::swap;
swap(lhs.m_allocator, rhs.m_allocator);
swap(lhs.m_head, rhs.m_head);
}
List(List &&list) noexcept : m_allocator(list.m_allocator)
{
swap(*this, list);
}
List &operator=(List list) noexcept
{
swap(*this, list);
return *this;
}
[[nodiscard]] Iterator begin()
{
return Iterator(m_head);
}
[[nodiscard]] Const_Iterator begin() const
{
return Const_Iterator(m_head);
}
[[nodiscard]] Iterator end()
{
return Iterator(nullptr);
}
[[nodiscard]] Const_Iterator end() const
{
return Const_Iterator(nullptr);
}
[[nodiscard]] Value &operator[](std::size_t index)
{
return at(index)->m_satellite;
}
[[nodiscard]] const Value &operator[](std::size_t index) const
{
return at(index)->m_satellite;
}
/**
* @brief Gets the number of elements currently in the list.
* Note: This operation is not constant as the size is not cached
*/
[[nodiscard]] std::size_t size() const
{
std::size_t list_size = 0;
Node_Pointer node = m_head;
while (node != nullptr)
{
node = node->m_next;
list_size++;
}
return list_size;
}
/**
* @brief Gets the first element in the list. This is undefined
* behaviour if the list is empty
*/
[[nodiscard]] Value &front()
{
return m_head->m_satellite;
}
/**
* @brief Gets the first element in the list. This is undefined
* behaviour if the list is empty
*/
[[nodiscard]] const Value &front() const
{
return m_head->m_satellite;
}
/**
* @brief Returns true if the list contains no elements
*/
[[nodiscard]] bool empty() const
{
return m_head == nullptr;
}
/**
* @brief Clears all elements from the list
*/
void clear()
{
Node_Pointer node = m_head;
while (node != nullptr)
{
Node_Pointer next = node->m_next;
Node_Traits::destroy_node(m_allocator, node);
node = next;
}
m_head = nullptr;
}
/**
* @brief Inserts the given value at the front of the list
*/
void prepend(Value value)
{
insert(0, std::move(value));
}
/**
* @brief Inserts the given value at the given index. The behaviour is
* undefined if the index is outside of the range: [0, size()]
*/
void insert(std::size_t index, Value value)
{
Node_Pointer node =
Node_Traits::create_node(m_allocator, std::move(value));
if (index == 0)
{
node->m_next = m_head;
m_head = node;
return;
}
Node_Pointer previous = at(index - 1);
node->m_next = previous->m_next;
previous->m_next = node;
}
/**
* @brief Erases the value at the front of the list. The behaviour is
* undefined if the list is empty
*/
void detatch_front()
{
erase(0);
}
/**
* @brief Erases the value at the given index. The behaviour is
* undefined if the index is outside of the list size.
*/
void erase(std::size_t index)
{
if (index == 0)
{
Node_Pointer remove = m_head;
m_head = m_head->m_next;
Node_Traits::destroy_node(m_allocator, remove);
return;
}
Node_Pointer previous = at(index - 1);
Node_Pointer remove = previous->m_next;
previous->m_next = remove->m_next;
Node_Traits::destroy_node(m_allocator, remove);
}
friend bool operator==(List const &lhs, List const &rhs) noexcept
{
Node_Pointer lhs_node = lhs.m_head;
Node_Pointer rhs_node = rhs.m_head;
while (lhs_node != nullptr && rhs_node != nullptr)
{
if (lhs_node->m_satellite != rhs_node->m_satellite)
{
return false;
}
lhs_node = lhs_node->m_next;
rhs_node = rhs_node->m_next;
}
return lhs_node == nullptr && rhs_node == nullptr;
}
friend bool operator!=(List const &lhs, List const &rhs) noexcept
{
return !(lhs == rhs);
}
private:
Node_Allocator m_allocator;
Node_Pointer m_head = nullptr;
/**
* @brief Gets the node at the given index. The behaviour is undefined
* if the index is outside of the list range
*/
Node_Pointer at(std::size_t index)
{
Node_Pointer node = m_head;
for (std::size_t i = 0; i < index; ++i)
{
node = node->m_next;
}
return node;
}
/**
* @brief Gets the node at the given index. The behaviour is undefined
* if the index is outside of the list range
*/
Node_Const_Pointer at(std::size_t index) const
{
Node_Const_Pointer node = m_head;
for (std::size_t i = 0; i < index; ++i)
{
node = node->m_next;
}
return node;
}
};
} // namespace dsa
#endif
| 22.039312
| 90
| 0.676589
|
Abstract-Everything
|
be08967d395cde607e5d9366c78185f3167c8d62
| 6,505
|
hxx
|
C++
|
OCC/opencascade-7.2.0/x64/debug/inc/SelectMgr_Selection.hxx
|
jiaguobing/FastCAE
|
2348ab87e83fe5c704e4c998cf391229c25ac5d5
|
[
"BSD-3-Clause"
] | 2
|
2020-02-21T01:04:35.000Z
|
2020-02-21T03:35:37.000Z
|
OCC/opencascade-7.2.0/x64/debug/inc/SelectMgr_Selection.hxx
|
Sunqia/FastCAE
|
cbc023fe07b6e306ceefae8b8bd7c12bc1562acb
|
[
"BSD-3-Clause"
] | 1
|
2020-03-06T04:49:42.000Z
|
2020-03-06T04:49:42.000Z
|
OCC/opencascade-7.2.0/x64/debug/inc/SelectMgr_Selection.hxx
|
Sunqia/FastCAE
|
cbc023fe07b6e306ceefae8b8bd7c12bc1562acb
|
[
"BSD-3-Clause"
] | 1
|
2021-11-21T13:03:26.000Z
|
2021-11-21T13:03:26.000Z
|
// Created on: 1995-02-16
// Created by: Mister rmi
// Copyright (c) 1995-1999 Matra Datavision
// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _SelectMgr_Selection_HeaderFile
#define _SelectMgr_Selection_HeaderFile
#include <NCollection_Vector.hxx>
#include <Standard.hxx>
#include <Standard_Type.hxx>
#include <Standard_Type.hxx>
#include <SelectMgr_TypeOfUpdate.hxx>
#include <Standard_Transient.hxx>
#include <SelectMgr_SensitiveEntity.hxx>
#include <SelectMgr_StateOfSelection.hxx>
#include <SelectMgr_TypeOfBVHUpdate.hxx>
class Standard_NullObject;
class SelectBasics_SensitiveEntity;
//! Represents the state of a given selection mode for a
//! Selectable Object. Contains all the sensitive entities available for this mode.
//! An interactive object can have an indefinite number of
//! modes of selection, each representing a
//! "decomposition" into sensitive primitives; each
//! primitive has an Owner (SelectMgr_EntityOwner)
//! which allows us to identify the exact entity which has
//! been detected. Each Selection mode is identified by
//! an index. The set of sensitive primitives which
//! correspond to a given mode is stocked in a
//! SelectMgr_Selection object. By Convention, the
//! default selection mode which allows us to grasp the
//! Interactive object in its entirety will be mode 0.
//! AIS_Trihedron : 4 selection modes
//! - mode 0 : selection of a trihedron
//! - mode 1 : selection of the origin of the trihedron
//! - mode 2 : selection of the axes
//! - mode 3 : selection of the planes XOY, YOZ, XOZ
//! when you activate one of modes 1 2 3 4 , you pick AIS objects of type:
//! - AIS_Point
//! - AIS_Axis (and information on the type of axis)
//! - AIS_Plane (and information on the type of plane).
//! AIS_PlaneTrihedron offers 3 selection modes:
//! - mode 0 : selection of the whole trihedron
//! - mode 1 : selection of the origin of the trihedron
//! - mode 2 : selection of the axes - same remarks as for the Trihedron.
//! AIS_Shape : 7 maximum selection modes, depending
//! on the complexity of the shape :
//! - mode 0 : selection of the AIS_Shape
//! - mode 1 : selection of the vertices
//! - mode 2 : selection of the edges
//! - mode 3 : selection of the wires
//! - mode 4 : selection of the faces
//! - mode 5 : selection of the shells
//! - mode 6 : selection of the constituent solids.
class SelectMgr_Selection : public Standard_Transient
{
public:
//! Constructs a selection object defined by the selection mode IdMode.
//! The default setting 0 is the selection mode for a shape in its entirety.
Standard_EXPORT SelectMgr_Selection (const Standard_Integer theModeIdx = 0);
Standard_EXPORT ~SelectMgr_Selection();
Standard_EXPORT void Destroy();
//! Adds the sensitive primitive aprimitive to the list of
//! stored entities in this object.
//! Raises NullObject if the primitive is a null handle.
Standard_EXPORT void Add (const Handle(SelectBasics_SensitiveEntity)& theSensitive);
//! empties the selection from all the stored entities
Standard_EXPORT void Clear();
//! returns true if no sensitive entity is stored.
Standard_EXPORT Standard_Boolean IsEmpty() const;
//! returns the selection mode represented by this selection
Standard_Integer Mode() const;
//! Begins an iteration scanning for sensitive primitives.
void Init();
//! Continues the iteration scanning for sensitive
//! primitives with the mode defined in this framework.
Standard_Boolean More() const;
//! Returns the next sensitive primitive found in the
//! iteration. This is a scan for entities with the mode
//! defined in this framework.
void Next();
//! Returns any sensitive primitive in this framework.
const Handle(SelectMgr_SensitiveEntity)& Sensitive() const;
//! Returns the flag UpdateFlag.
//! This flage gives the update status of this framework
//! in a ViewerSelector object:
//! - full
//! - partial, or
//! - none.
SelectMgr_TypeOfUpdate UpdateStatus() const;
void UpdateStatus (const SelectMgr_TypeOfUpdate theStatus);
void UpdateBVHStatus (const SelectMgr_TypeOfBVHUpdate theStatus);
SelectMgr_TypeOfBVHUpdate BVHUpdateStatus() const;
//! Returns status of selection
Standard_EXPORT SelectMgr_StateOfSelection GetSelectionState() const;
//! Sets status of selection
Standard_EXPORT void SetSelectionState (const SelectMgr_StateOfSelection theState) const;
//! Returns sensitivity of the selection
Standard_EXPORT Standard_Integer Sensitivity() const;
//! Changes sensitivity of the selection and all its entities to the given value.
//! IMPORTANT: This method does not update any outer selection structures, so for
//! proper updates use SelectMgr_SelectionManager::SetSelectionSensitivity method.
Standard_EXPORT void SetSensitivity (const Standard_Integer theNewSens);
DEFINE_STANDARD_RTTIEXT(SelectMgr_Selection,Standard_Transient)
protected:
//! Returns sensitive entity stored by index theIdx in entites vector
Standard_EXPORT Handle(SelectMgr_SensitiveEntity)& GetEntityById (const Standard_Integer theIdx);
private:
NCollection_Vector<Handle(SelectMgr_SensitiveEntity)> myEntities;
NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator myEntityIter;
Standard_Integer myMode;
SelectMgr_TypeOfUpdate myUpdateStatus;
mutable SelectMgr_StateOfSelection mySelectionState;
mutable SelectMgr_TypeOfBVHUpdate myBVHUpdateStatus;
Standard_Integer mySensFactor;
Standard_Boolean myIsCustomSens;
};
DEFINE_STANDARD_HANDLE(SelectMgr_Selection, Standard_Transient)
#include <SelectMgr_Selection.lxx>
#endif
| 39.664634
| 99
| 0.733897
|
jiaguobing
|
be09d8e4cbbad885c4ba4fd8b910550976ada034
| 10,093
|
cpp
|
C++
|
Sources/Tools/EPI/Document/ContentInfo/SplineRepresentation.cpp
|
benkaraban/anima-games-engine
|
8aa7a5368933f1b82c90f24814f1447119346c3b
|
[
"BSD-3-Clause"
] | 2
|
2015-04-16T01:05:53.000Z
|
2019-08-26T07:38:43.000Z
|
Sources/Tools/EPI/Document/ContentInfo/SplineRepresentation.cpp
|
benkaraban/anima-games-engine
|
8aa7a5368933f1b82c90f24814f1447119346c3b
|
[
"BSD-3-Clause"
] | null | null | null |
Sources/Tools/EPI/Document/ContentInfo/SplineRepresentation.cpp
|
benkaraban/anima-games-engine
|
8aa7a5368933f1b82c90f24814f1447119346c3b
|
[
"BSD-3-Clause"
] | null | null | null |
/*
* Copyright (c) 2010, Anima Games, Benjamin Karaban, Laurent Schneider,
* Jérémie Comarmond, Didier Colin.
* 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 holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "SplineRepresentation.h"
#include <Universe/World.h>
#include <EPI/Document/Properties/PtyTrajectory/PtyTrajectory.moc.h>
#include <Core/Math/Splines/CatmullRom.h>
#include <Core/List.h>
#include <Core/Math/Splines/Trajectory.h>
#include <Assets/GeometricPrimitive.h>
#include <Assets/Tool.h>
#include <EPI/Document/ContentInfo/SplineRepresentation.h>
#include <EPI/Constants.h>
namespace EPI
{
const String tagNodeSpline = L"SplineRepresentationTrajectory";
//const String tagNodeGroupDecal = L"GroupDecalRepresentationTrajectory";
const String tagNodeLocalAxis = L"CheckPointLocalAxis";
const String SPLINE_ARROW_MODEL_NAME = L"$SplineArrow";
const String SPLINE_ARROW_MESH_NAME = L"$SplineArrowMesh";
const float SPLINE_ARROW_SIZE_FACTOR = 2.6f;
//-----------------------------------------------------------------------------
void createSplineModels(Ptr<Universe::RessourcePool> pPool)
{
//arrow
Ptr<Assets::ModelMesh> arrow (new Assets::ModelMesh());
Assets::VerticeSet & vsetArrow = arrow->getLODByID(0);
Assets::createArrow(vsetArrow, SPLINE_ARROW_SIZE_FACTOR);
Assets::makeTBNBasis(vsetArrow, false);
arrow->cleanup();
Ptr<Assets::Model> pArrowModel (new Assets::Model());
pArrowModel->addMesh(SPLINE_ARROW_MESH_NAME, *arrow);
pPool->addModel(SPLINE_ARROW_MODEL_NAME, pArrowModel);
}
//-----------------------------------------------------------------------------
Ptr<Universe::NodeGroup> createSplineUniverseRepresentation(const Ptr<Universe::World>& pWorld)
{
Ptr<Universe::NodeGroup> pRet;
pRet = pWorld->createGroup();
Ptr<Universe::NodeSpline> pNodeSpline = pWorld->createSpline();
pNodeSpline->addTag(tagNodeSpline);
pNodeSpline->setColor(Core::Vector4f(0.8f,0.8f,0.8f,1.f));
Ptr<Universe::NodeGroup> pGroup = pWorld->createGroup();
pGroup->setFixedSize(true, 1/20.f);
pGroup->addTag(tagNodeLocalAxis);
Ptr<Universe::NodeMesh> pNodeArrowAxeX = pWorld->createMesh(SPLINE_ARROW_MODEL_NAME, SPLINE_ARROW_MESH_NAME);
Ptr<Universe::NodeMesh> pNodeArrowAxeY = pWorld->createMesh(SPLINE_ARROW_MODEL_NAME, SPLINE_ARROW_MESH_NAME);
Ptr<Universe::NodeMesh> pNodeArrowAxeZ = pWorld->createMesh(SPLINE_ARROW_MODEL_NAME, SPLINE_ARROW_MESH_NAME);
pNodeArrowAxeX->getMeshInstance()->setMaterial(RdrConst::sMatAxisX);
pNodeArrowAxeY->getMeshInstance()->setMaterial(RdrConst::sMatAxisY);
pNodeArrowAxeZ->getMeshInstance()->setMaterial(RdrConst::sMatAxisZ);
pNodeArrowAxeX->beginMatrixUpdate();
pNodeArrowAxeX->localRoll(-f_PI_DIV_2);
pNodeArrowAxeX->setLocalPosition(Core::Vector3f(SPLINE_ARROW_SIZE_FACTOR,0,0));
pNodeArrowAxeX->endMatrixUpdate();
pNodeArrowAxeY->beginMatrixUpdate();
pNodeArrowAxeY->setLocalPosition(Core::Vector3f(0,SPLINE_ARROW_SIZE_FACTOR,0));
pNodeArrowAxeY->endMatrixUpdate();
pNodeArrowAxeZ->beginMatrixUpdate();
pNodeArrowAxeZ->localPitch(f_PI_DIV_2);
pNodeArrowAxeZ->setLocalPosition(Core::Vector3f(0,0,SPLINE_ARROW_SIZE_FACTOR));
pNodeArrowAxeZ->endMatrixUpdate();
pGroup->addChild(pNodeArrowAxeX);
pGroup->addChild(pNodeArrowAxeY);
pGroup->addChild(pNodeArrowAxeZ);
pRet->addChild(pNodeSpline);
pRet->addChild(pGroup);
return pRet;
}
//-----------------------------------------------------------------------------
SplineRepresentation::SplineRepresentation(const Ptr<Universe::World>& pWorld, const Ptr<Universe::Node>& pNodeToRepresent):
IContentRepresentation(),
_mode(SELECTION_REPRESENTATION),
_pWorld(pWorld)
{
createSplineModels(_pWorld->getRessourcesPool());
_pNodeRepresentation = createSplineUniverseRepresentation(_pWorld);
pNodeToRepresent->addGhostChild(_pNodeRepresentation);
}
//-----------------------------------------------------------------------------
SplineRepresentation::SplineRepresentation(const SplineRepresentation& other):
IContentRepresentation(other),
_pWorld(other._pWorld)
{
//TODO
LM_ASSERT(false);
}
//-----------------------------------------------------------------------------
SplineRepresentation::~SplineRepresentation()
{
_pNodeRepresentation->kill();
}
//-----------------------------------------------------------------------------
void SplineRepresentation::updateObjectRepresentation(const Property& pPty)
{
const PtyTrajectory& pPtyT = static_cast<const PtyTrajectory&>(pPty);
Ptr<Universe::NodeSpline> pNodeSpline = LM_DEBUG_PTR_CAST<Universe::NodeSpline>(_pNodeRepresentation->getChildWithTag(tagNodeSpline));
const Core::Trajectory& traj = pPtyT.getTrajectory();
const Core::List<Core::CheckPoint> & cp = traj.getCheckPoints();
/*
Ptr<Universe::Node> pNode = ((const PtyNode&)(pPty)).getUniverseNode();
_pNodeRepresentation->setWorldPosition(pNode->getWorldPosition());
_pNodeRepresentation->setLocalOrientation(pNode->getLocalOrient());*/
//Spline
Core::List<Core::Vector3f> pos;
for (int32 ii=0; ii<cp.size(); ++ii)
{
pos.push_back(cp[ii].position);
if (ii==0 || ii==cp.size()-1)
{
pos.push_back(cp[ii].position);
pos.push_back(cp[ii].position);
}
}
Core::CRSpline sp(pos);
pNodeSpline->setSpline(sp);
pNodeSpline->setResolution(10*pos.size());
/*
//Decal
Ptr<Universe::NodeGroup > pNodeGroupDecal = LM_DEBUG_PTR_CAST<Universe::NodeGroup>(_pNodeRepresentation->getChildWithTag(tagNodeGroupDecal));
if (pNodeGroupDecal->getChildCount() < cp.size())
{
int32 nbNewDecal = cp.size()-pNodeGroupDecal->getChildCount();
for (int32 ii=0; ii<nbNewDecal; ++ii)
{
pNodeGroupDecal->addChild(_pWorld->createDecal());
}
}
else
{
int32 nbDecalToDelete = pNodeGroupDecal->getChildCount()-cp.size();
for (int32 ii=0; ii<nbDecalToDelete; ++ii)
{
pNodeGroupDecal->removeChild(pNodeGroupDecal->getChildren().back());
}
}
for (int32 ii=0; ii<cp.size(); ++ii)
{
LM_DEBUG_PTR_CAST<Universe::NodeDecal>(pNodeGroupDecal->getChild(ii))->setBillboard(true);
LM_DEBUG_PTR_CAST<Universe::NodeDecal>(pNodeGroupDecal->getChild(ii))->setSize(0.1f);
pNodeGroupDecal->getChild(ii)->setWorldPosition(cp[ii].position);
pNodeGroupDecal->getChild(ii)->setFixedSize(true);
}*/
}
//-----------------------------------------------------------------------------
void SplineRepresentation::setRepresentationMode(ECRMode mode)
{
_mode = mode;
Ptr<Universe::NodeSpline> pNodeSpline = LM_DEBUG_PTR_CAST<Universe::NodeSpline>(_pNodeRepresentation->getChildWithTag(tagNodeSpline));
// Ptr<Universe::NodeGroup > pNodeGroupDecal = LM_DEBUG_PTR_CAST<Universe::NodeGroup>(_pNodeRepresentation->getChildWithTag(tagNodeGroupDecal));
if (_mode==OBJECT_REPRESENTATION)
{
pNodeSpline->setVisible(true);
// pNodeGroupDecal->setVisible(true);
}
else
{
pNodeSpline->setVisible(true);
// pNodeGroupDecal->setVisible(false);
}
}
//-----------------------------------------------------------------------------
const Ptr<Universe::NodeGroup>& SplineRepresentation::getNodeRepresentation()
{
return _pNodeRepresentation;
}
//-----------------------------------------------------------------------------
bool SplineRepresentation::isItMe(const Ptr<Universe::Node>& pNode)
{
if (pNode==_pNodeRepresentation) return true;
return false;
}
//-----------------------------------------------------------------------------
Ptr<IContentRepresentation> SplineRepresentation::clone()
{
Ptr<SplineRepresentation> pRet = Ptr<SplineRepresentation>(new SplineRepresentation (*this));
return pRet;
}
//-----------------------------------------------------------------------------
void SplineRepresentation::setNodeToRepresent(const Ptr<Universe::Node>& pNode)
{
pNode->addGhostChild(_pNodeRepresentation);
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
} // namespace EPI
| 41.028455
| 148
| 0.635886
|
benkaraban
|
be0a10874dda4946544813fa28b986dc9a86ae50
| 9,353
|
cpp
|
C++
|
VC2010Samples/MFC/Visual C++ 2008 Feature Pack/VisualStudioDemo/PropertiesViewBar.cpp
|
alonmm/VCSamples
|
6aff0b4902f5027164d593540fcaa6601a0407c3
|
[
"MIT"
] | 300
|
2019-05-09T05:32:33.000Z
|
2022-03-31T20:23:24.000Z
|
VC2010Samples/MFC/Visual C++ 2008 Feature Pack/VisualStudioDemo/PropertiesViewBar.cpp
|
JaydenChou/VCSamples
|
9e1d4475555b76a17a3568369867f1d7b6cc6126
|
[
"MIT"
] | 9
|
2016-09-19T18:44:26.000Z
|
2018-10-26T10:20:05.000Z
|
VC2010Samples/MFC/Visual C++ 2008 Feature Pack/VisualStudioDemo/PropertiesViewBar.cpp
|
JaydenChou/VCSamples
|
9e1d4475555b76a17a3568369867f1d7b6cc6126
|
[
"MIT"
] | 633
|
2019-05-08T07:34:12.000Z
|
2022-03-30T04:38:28.000Z
|
// This is a part of the Microsoft Foundation Classes C++ library.
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// This source code is only intended as a supplement to the
// Microsoft Foundation Classes Reference and related
// electronic documentation provided with the library.
// See these sources for detailed information regarding the
// Microsoft Foundation Classes product.
#include "stdafx.h"
#include "VisualStudioDemo.h"
#include "MainFrm.h"
#include "PropertiesViewBar.h"
#include <memory>
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
/////////////////////////////////////////////////////////////////////////////
// CResourceViewBar
CPropertiesViewBar::CPropertiesViewBar()
{
}
CPropertiesViewBar::~CPropertiesViewBar()
{
}
BEGIN_MESSAGE_MAP(CPropertiesViewBar, CDockablePane)
ON_WM_CREATE()
ON_WM_SIZE()
ON_COMMAND(ID_SORTINGPROP, OnSortingprop)
ON_UPDATE_COMMAND_UI(ID_SORTINGPROP, OnUpdateSortingprop)
ON_COMMAND(ID_PROPERIES1, OnProperies1)
ON_UPDATE_COMMAND_UI(ID_PROPERIES1, OnUpdateProperies1)
ON_COMMAND(ID_PROPERIES2, OnProperies2)
ON_UPDATE_COMMAND_UI(ID_PROPERIES2, OnUpdateProperies2)
ON_COMMAND(ID_EXPAND, OnExpand)
ON_UPDATE_COMMAND_UI(ID_EXPAND, OnUpdateExpand)
ON_WM_SETFOCUS()
ON_WM_SETTINGCHANGE()
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CResourceViewBar message handlers
void CPropertiesViewBar::AdjustLayout()
{
if (GetSafeHwnd() == NULL)
{
return;
}
CRect rectClient,rectCombo;
GetClientRect(rectClient);
m_wndObjectCombo.GetWindowRect(&rectCombo);
int cyCmb = rectCombo.Size().cy;
int cyTlb = m_wndToolBar.CalcFixedLayout(FALSE, TRUE).cy;
m_wndObjectCombo.SetWindowPos(NULL, rectClient.left, rectClient.top, rectClient.Width(), 200, SWP_NOACTIVATE | SWP_NOZORDER);
m_wndToolBar.SetWindowPos(NULL, rectClient.left, rectClient.top + cyCmb, rectClient.Width(), cyTlb, SWP_NOACTIVATE | SWP_NOZORDER);
m_wndPropList.SetWindowPos(NULL, rectClient.left, rectClient.top + cyCmb + cyTlb, rectClient.Width(), rectClient.Height() -(cyCmb+cyTlb), SWP_NOACTIVATE | SWP_NOZORDER);
}
int CPropertiesViewBar::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CDockablePane::OnCreate(lpCreateStruct) == -1)
return -1;
CRect rectDummy;
rectDummy.SetRectEmpty();
// Create combo:
const DWORD dwViewStyle = WS_CHILD | WS_VISIBLE | CBS_DROPDOWNLIST
| WS_BORDER | CBS_SORT | WS_CLIPSIBLINGS | WS_CLIPCHILDREN;
if (!m_wndObjectCombo.Create(dwViewStyle, rectDummy, this, 1))
{
TRACE0("Failed to create Properies Combo \n");
return -1; // fail to create
}
m_wndObjectCombo.AddString(_T("IDD_ABOUTBOX(Dialog)"));
m_wndObjectCombo.SetCurSel(0);
if (!m_wndPropList.Create(WS_VISIBLE | WS_CHILD, rectDummy, this, 2))
{
TRACE0("Failed to create Properies Grid \n");
return -1; // fail to create
}
InitPropList();
m_wndToolBar.Create(this, AFX_DEFAULT_TOOLBAR_STYLE, IDR_PROPERTIES);
m_wndToolBar.LoadToolBar(IDR_PROPERTIES, 0, 0, TRUE /* Is locked */);
OnChangeVisualStyle();
m_wndToolBar.SetPaneStyle(m_wndToolBar.GetPaneStyle() | CBRS_TOOLTIPS | CBRS_FLYBY);
m_wndToolBar.SetPaneStyle(m_wndToolBar.GetPaneStyle() & ~(CBRS_GRIPPER | CBRS_SIZE_DYNAMIC | CBRS_BORDER_TOP | CBRS_BORDER_BOTTOM | CBRS_BORDER_LEFT | CBRS_BORDER_RIGHT));
m_wndToolBar.SetOwner(this);
// All commands will be routed via this control , not via the parent frame:
m_wndToolBar.SetRouteCommandsViaFrame(FALSE);
AdjustLayout();
return 0;
}
void CPropertiesViewBar::OnSize(UINT nType, int cx, int cy)
{
CDockablePane::OnSize(nType, cx, cy);
AdjustLayout();
}
void CPropertiesViewBar::OnSortingprop()
{
m_wndPropList.SetAlphabeticMode();
}
void CPropertiesViewBar::OnUpdateSortingprop(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck(m_wndPropList.IsAlphabeticMode());
}
void CPropertiesViewBar::OnExpand()
{
m_wndPropList.SetAlphabeticMode(FALSE);
}
void CPropertiesViewBar::OnUpdateExpand(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck(!m_wndPropList.IsAlphabeticMode());
}
void CPropertiesViewBar::OnProperies1()
{
// TODO: Add your command handler code here
}
void CPropertiesViewBar::OnUpdateProperies1(CCmdUI* /*pCmdUI*/)
{
// TODO: Add your command update UI handler code here
}
void CPropertiesViewBar::OnProperies2()
{
// TODO: Add your command handler code here
}
void CPropertiesViewBar::OnUpdateProperies2(CCmdUI* /*pCmdUI*/)
{
// TODO: Add your command update UI handler code here
}
void CPropertiesViewBar::InitPropList()
{
SetPropListFont();
m_wndPropList.EnableHeaderCtrl(FALSE);
m_wndPropList.EnableDescriptionArea();
m_wndPropList.SetVSDotNetLook();
m_wndPropList.MarkModifiedProperties();
std::auto_ptr<CMFCPropertyGridProperty> apGroup1(new CMFCPropertyGridProperty(_T("Appearance")));
apGroup1->AddSubItem(new CMFCPropertyGridProperty(_T("3D Look"), (_variant_t) false, _T("Specifies the dialog's font will be nonbold and controls will have a 3D border")));
CMFCPropertyGridProperty* pProp = new CMFCPropertyGridProperty(_T("Border"), _T("Dialog Frame"), _T("One of: None, Thin, Resizable, or Dialog Frame"));
pProp->AddOption(_T("None"));
pProp->AddOption(_T("Thin"));
pProp->AddOption(_T("Resizable"));
pProp->AddOption(_T("Dialog Frame"));
pProp->AllowEdit(FALSE);
apGroup1->AddSubItem(pProp);
apGroup1->AddSubItem(new CMFCPropertyGridProperty(_T("Caption"), (_variant_t) _T("About"), _T("Specifies the text that will be displayed in the dialog's title bar")));
m_wndPropList.AddProperty(apGroup1.release());
std::auto_ptr<CMFCPropertyGridProperty> apSize(new CMFCPropertyGridProperty(_T("Window Size"), 0, TRUE));
pProp = new CMFCPropertyGridProperty(_T("Height"), (_variant_t) 250l, _T("Specifies the dialog's height"));
pProp->EnableSpinControl(TRUE, 0, 1000);
apSize->AddSubItem(pProp);
pProp = new CMFCPropertyGridProperty( _T("Width"), (_variant_t) 150l, _T("Specifies the dialog's width"));
pProp->EnableSpinControl(TRUE, 1, 500);
apSize->AddSubItem(pProp);
m_wndPropList.AddProperty(apSize.release());
std::auto_ptr<CMFCPropertyGridProperty> apGroup2(new CMFCPropertyGridProperty(_T("Font")));
LOGFONT lf;
CFont* font = CFont::FromHandle((HFONT) GetStockObject(DEFAULT_GUI_FONT));
font->GetLogFont(&lf);
lstrcpy(lf.lfFaceName, _T("Arial"));
apGroup2->AddSubItem(new CMFCPropertyGridFontProperty(_T("Font"), lf, CF_EFFECTS | CF_SCREENFONTS, _T("Specifies the default font for the dialog")));
apGroup2->AddSubItem(new CMFCPropertyGridProperty(_T("Use System Font"), (_variant_t) true, _T("Specifies that the dialog uses MS Shell Dlg font")));
m_wndPropList.AddProperty(apGroup2.release());
std::auto_ptr<CMFCPropertyGridProperty> apGroup3(new CMFCPropertyGridProperty(_T("Misc")));
pProp = new CMFCPropertyGridProperty(_T("(Name)"), _T("IDD_ABOUT_BOX(dialog)"));
pProp->Enable(FALSE);
apGroup3->AddSubItem(pProp);
CMFCPropertyGridColorProperty* pColorProp = new CMFCPropertyGridColorProperty(_T("Window Color"), RGB(210, 192, 254), NULL, _T("Specifies the default dialog color"));
pColorProp->EnableOtherButton(_T("Other..."));
pColorProp->EnableAutomaticButton(_T("Default"), ::GetSysColor(COLOR_3DFACE));
apGroup3->AddSubItem(pColorProp);
static TCHAR BASED_CODE szFilter[] = _T("Icon Files(*.ico)|*.ico|All Files(*.*)|*.*||");
apGroup3->AddSubItem(new CMFCPropertyGridFileProperty(_T("Icon"), TRUE, _T(""), _T("ico"), 0, szFilter, _T("Specifies the dialog icon")));
apGroup3->AddSubItem(new CMFCPropertyGridFileProperty(_T("Folder"), _T("c:\\")));
m_wndPropList.AddProperty(apGroup3.release());
std::auto_ptr<CMFCPropertyGridProperty> apGroup4(new CMFCPropertyGridProperty(_T("Hierarchy")));
CMFCPropertyGridProperty* pGroup41 = new CMFCPropertyGridProperty(_T("First sub-level"));
apGroup4->AddSubItem(pGroup41);
CMFCPropertyGridProperty* pGroup411 = new CMFCPropertyGridProperty(_T("Second sub-level"));
pGroup41->AddSubItem(pGroup411);
pGroup411->AddSubItem(new CMFCPropertyGridProperty(_T("Item 1"), (_variant_t) _T("Value 1"), _T("This is a description")));
pGroup411->AddSubItem(new CMFCPropertyGridProperty(_T("Item 2"), (_variant_t) _T("Value 2"), _T("This is a description")));
pGroup411->AddSubItem(new CMFCPropertyGridProperty(_T("Item 3"), (_variant_t) _T("Value 3"), _T("This is a description")));
apGroup4->Expand(FALSE);
m_wndPropList.AddProperty(apGroup4.release());
}
void CPropertiesViewBar::OnSetFocus(CWnd* pOldWnd)
{
CDockablePane::OnSetFocus(pOldWnd);
m_wndPropList.SetFocus();
}
void CPropertiesViewBar::OnSettingChange(UINT uFlags, LPCTSTR lpszSection)
{
CDockablePane::OnSettingChange(uFlags, lpszSection);
SetPropListFont();
}
void CPropertiesViewBar::SetPropListFont()
{
::DeleteObject (m_fntPropList.Detach ());
LOGFONT lf;
afxGlobalData.fontRegular.GetLogFont (&lf);
NONCLIENTMETRICS info;
info.cbSize = sizeof(info);
afxGlobalData.GetNonClientMetrics (info);
lf.lfHeight = info.lfMenuFont.lfHeight;
lf.lfWeight = info.lfMenuFont.lfWeight;
lf.lfItalic = info.lfMenuFont.lfItalic;
m_fntPropList.CreateFontIndirect (&lf);
m_wndPropList.SetFont(&m_fntPropList);
m_wndObjectCombo.SetFont(&m_fntPropList);
}
void CPropertiesViewBar::OnChangeVisualStyle()
{
m_wndToolBar.CleanUpLockedImages();
m_wndToolBar.LoadBitmap(theApp.m_bHiColorIcons ? IDB_PROP24 : IDR_PROPERTIES, 0, 0, TRUE /* Locked */);
}
| 32.58885
| 173
| 0.755373
|
alonmm
|
be0a77ef2bc95116abf1dc0136905aea561d0411
| 2,816
|
cpp
|
C++
|
src/equation/lu/lu_mumps_cpu.cpp
|
rigarash/monolish-debian-package
|
70b4917370184bcf07378e1907c5239a1ad9579b
|
[
"Apache-2.0"
] | 172
|
2021-04-05T10:04:40.000Z
|
2022-03-28T14:30:38.000Z
|
src/equation/lu/lu_mumps_cpu.cpp
|
rigarash/monolish-debian-package
|
70b4917370184bcf07378e1907c5239a1ad9579b
|
[
"Apache-2.0"
] | 96
|
2021-04-06T01:53:44.000Z
|
2022-03-09T07:27:09.000Z
|
src/equation/lu/lu_mumps_cpu.cpp
|
termoshtt/monolish
|
1cba60864002b55bc666da9baa0f8c2273578e01
|
[
"Apache-2.0"
] | 8
|
2021-04-05T13:21:07.000Z
|
2022-03-09T23:24:06.000Z
|
#include "../../../include/monolish_blas.hpp"
#include "../../../include/monolish_equation.hpp"
#include "../../internal/monolish_internal.hpp"
// #include "dmumps_c.h"
// #include "mpi.h"
#define JOB_INIT -1
#define JOB_END -2
#define USE_COMM_WORLD -987654
namespace monolish {
// mumps is choushi warui..
template <>
int equation::LU<matrix::CRS<double>, double>::mumps_LU(matrix::CRS<double> &A,
vector<double> &x,
vector<double> &b) {
Logger &logger = Logger::get_instance();
logger.func_in(monolish_func);
(void)(&A);
(void)(&x);
(void)(&b);
if (1) {
throw std::runtime_error("error sparse LU on CPU does not impl.");
}
// DMUMPS_STRUC_C id;
// MUMPS_INT n = A.get_row();
// MUMPS_INT8 nnz = A.get_nnz();
//
// // covert mumps format (CRS -> 1-origin COO)
// std::vector<int>tmp_row(nnz);
// std::vector<int>tmp_col(nnz);
// for(int i=0; i<n; i++){
// for(int j = A.row_ptr[i]; j < A.row_ptr[i+1]; j++){
// tmp_row[j] = i+1;
// tmp_row[j] = A.col_ind[j]+1;
// }
// }
// MUMPS_INT* irn = A.row_ptr.data();
// MUMPS_INT* jcn = A.col_ind.data();
//
// double* a = A.val.data();
// double* rhs = b.data();
//
// MUMPS_INT myid, ierr;
// int* dummy;
// char*** dummyc;
//
// int error = 0;
// #if defined(MAIN_COMP)
// argv = &name;
// #endif
// ierr = MPI_Init(dummy, dummyc);
// ierr = MPI_Comm_rank(MPI_COMM_WORLD, &myid);
//
// /* Initialize a MUMPS instance. Use MPI_COMM_WORLD */
// id.comm_fortran=USE_COMM_WORLD;
// id.par=1; id.sym=0;
// id.job=JOB_INIT;
// dmumps_c(&id);
//
// /* Define the problem on the host */
// if (myid == 0) {
// id.n = n; id.nnz =nnz; id.irn=irn; id.jcn=jcn;
// id.a = a; id.rhs = rhs;
// }
//
// #define ICNTL(I) icntl[(I)-1] /* macro s.t. indices match documentation */
// /* No outputs */
// id.ICNTL(1)=-1; id.ICNTL(2)=-1; id.ICNTL(3)=-1; id.ICNTL(4)=0;
//
// /* Call the MUMPS package (analyse, factorization and solve). */
// id.job=6;
// dmumps_c(&id);
// if (id.infog[0]<0) {
// printf(" (PROC %d) ERROR RETURN: \tINFOG(1)=
// %d\n\t\t\t\tINFOG(2)=
// %d\n", myid, id.infog[0], id.infog[1]);
// error = 1;
// }
//
// /* Terminate instance. */
// id.job=JOB_END;
// dmumps_c(&id);
// if (myid == 0) {
// if (!error) {
// printf("Solution is : (%8.2f %8.2f)\n",
// rhs[0],rhs[1]); } else {
// printf("An error has occured, please check error code returned by
// MUMPS.\n");
// }
// }
// ierr = MPI_Finalize();
logger.func_out();
return 0;
}
} // namespace monolish
| 27.607843
| 79
| 0.51669
|
rigarash
|
be1f640bb7ae1ac25391a191f2a10783811cc823
| 8,373
|
cpp
|
C++
|
SerialPrograms/Source/PokemonLA/Programs/ShinyHunting/PokemonLA_CrobatFinder.cpp
|
Gin890/Arduino-Source
|
9047ff584010d8ddc3558068874f16fb3c7bb46d
|
[
"MIT"
] | null | null | null |
SerialPrograms/Source/PokemonLA/Programs/ShinyHunting/PokemonLA_CrobatFinder.cpp
|
Gin890/Arduino-Source
|
9047ff584010d8ddc3558068874f16fb3c7bb46d
|
[
"MIT"
] | null | null | null |
SerialPrograms/Source/PokemonLA/Programs/ShinyHunting/PokemonLA_CrobatFinder.cpp
|
Gin890/Arduino-Source
|
9047ff584010d8ddc3558068874f16fb3c7bb46d
|
[
"MIT"
] | null | null | null |
/* Alpha Crobat Hunter
*
* From: https://github.com/PokemonAutomation/Arduino-Source
*
*/
#include "Common/Cpp/Exceptions.h"
#include "CommonFramework/Notifications/ProgramNotifications.h"
#include "CommonFramework/VideoPipeline/VideoFeed.h"
#include "CommonFramework/InferenceInfra/InferenceRoutines.h"
#include "CommonFramework/Inference/BlackScreenDetector.h"
#include "CommonFramework/Tools/StatsTracking.h"
#include "NintendoSwitch/NintendoSwitch_Settings.h"
#include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h"
#include "PokemonLA/PokemonLA_Settings.h"
#include "PokemonLA/Inference/PokemonLA_MapDetector.h"
#include "PokemonLA/Inference/PokemonLA_DialogDetector.h"
#include "PokemonLA/Inference/PokemonLA_OverworldDetector.h"
#include "PokemonLA/Inference/Sounds/PokemonLA_ShinySoundDetector.h"
#include "PokemonLA/Programs/PokemonLA_GameEntry.h"
#include "PokemonLA/Programs/PokemonLA_RegionNavigation.h"
#include "PokemonLA_CrobatFinder.h"
namespace PokemonAutomation{
namespace NintendoSwitch{
namespace PokemonLA{
CrobatFinder_Descriptor::CrobatFinder_Descriptor()
: RunnableSwitchProgramDescriptor(
"PokemonLA:CrobatFinder",
STRING_POKEMON + " LA", "Alpha Crobat Hunter",
"ComputerControl/blob/master/Wiki/Programs/PokemonLA/AlphaCrobatHunter.md",
"Constantly reset the cave to find Shiny Alpha Crobat.",
FeedbackType::REQUIRED, false,
PABotBaseLevel::PABOTBASE_12KB
)
{}
CrobatFinder::CrobatFinder(const CrobatFinder_Descriptor& descriptor)
: SingleSwitchProgramInstance(descriptor)
, SHINY_DETECTED_ENROUTE(
"Enroute Shiny Action",
"This applies if you are still traveling to the Crobat.",
"2 * TICKS_PER_SECOND"
)
, SHINY_DETECTED_DESTINATION(
"Destination Shiny Action",
"This applies if you are near the Crobat.",
"2 * TICKS_PER_SECOND"
)
, NOTIFICATION_STATUS("Status Update", true, false, std::chrono::seconds(3600))
, NOTIFICATIONS({
&NOTIFICATION_STATUS,
&SHINY_DETECTED_ENROUTE.NOTIFICATIONS,
&SHINY_DETECTED_DESTINATION.NOTIFICATIONS,
&NOTIFICATION_PROGRAM_FINISH,
// &NOTIFICATION_ERROR_RECOVERABLE,
&NOTIFICATION_ERROR_FATAL,
})
{
PA_ADD_STATIC(SHINY_REQUIRES_AUDIO);
PA_ADD_OPTION(SHINY_DETECTED_ENROUTE);
PA_ADD_OPTION(SHINY_DETECTED_DESTINATION);
PA_ADD_OPTION(NOTIFICATIONS);
}
class CrobatFinder::Stats : public StatsTracker, public ShinyStatIncrementer{
public:
Stats()
: attempts(m_stats["Attempts"])
, errors(m_stats["Errors"])
, shinies(m_stats["Shinies"])
{
m_display_order.emplace_back("Attempts");
m_display_order.emplace_back("Errors", true);
m_display_order.emplace_back("Shinies", true);
}
virtual void add_shiny() override{
shinies++;
}
std::atomic<uint64_t>& attempts;
std::atomic<uint64_t>& errors;
std::atomic<uint64_t>& shinies;
};
std::unique_ptr<StatsTracker> CrobatFinder::make_stats() const{
return std::unique_ptr<StatsTracker>(new Stats());
}
void CrobatFinder::run_iteration(SingleSwitchProgramEnvironment& env, BotBaseContext& context){
// NOTE: there's no "stunned by alpha" detection in case any of the close ones are alphas!
Stats& stats = env.stats<Stats>();
stats.attempts++;
// program should be started right in front of the entrance
// so enter the sub region
env.console.log("Entering Wayward Cave...");
mash_A_to_enter_sub_area(env, env.console, context);
env.console.log("Beginning navigation to the Alpha Crobat...");
// Switch to Wrydeer.
bool error = true;
MountDetector mount_detector;
for (size_t c = 0; c < 10; c++){
MountState mount = mount_detector.detect(env.console.video().snapshot());
if (mount == MountState::WYRDEER_OFF){
pbf_press_button(context, BUTTON_PLUS, 20, 105);
error = false;
break;
}
if (mount == MountState::WYRDEER_ON){
pbf_wait(context, 5 * TICKS_PER_SECOND);
error = false;
break;
}
pbf_press_dpad(context, DPAD_LEFT, 20, 50);
context.wait_for_all_requests();
}
if (error){
throw OperationFailedException(env.console, "Unable to find Wyrdeer after 10 attempts.");
}
env.console.log("Beginning Shiny Detection...");
// start the shiny detection, there's nothing initially
{
float shiny_coefficient = 1.0;
std::atomic<ShinyDetectedActionOption*> shiny_action = &SHINY_DETECTED_ENROUTE;
ShinySoundDetector shiny_detector(env.console.logger(), env.console, [&](float error_coefficient) -> bool{
// Warning: This callback will be run from a different thread than this function.
stats.shinies++;
shiny_coefficient = error_coefficient;
ShinyDetectedActionOption* action = shiny_action.load(std::memory_order_acquire);
return on_shiny_callback(env, env.console, *action, error_coefficient);
});
int ret = run_until(
env.console, context,
[&](BotBaseContext& context){
// FORWARD PORTION OF CAVE UNTIL LEDGE
pbf_press_button(context, BUTTON_B, (uint16_t)(2.2 * TICKS_PER_SECOND), 80); // wyrdeer sprint
pbf_move_left_joystick(context, 0, 128, 10, 20); // turn left
pbf_press_button(context, BUTTON_ZL, 20, 50); // align camera
// ASCEND THE LEDGE WITH BRAVIARY
pbf_press_dpad(context, DPAD_RIGHT, 20, 50); // swap to braviary
pbf_wait(context, (uint16_t)(0.6 * TICKS_PER_SECOND)); // wait for the ascent
pbf_press_button(context, BUTTON_Y, (uint16_t)(2.4 * TICKS_PER_SECOND), 20); // descend to swap to Wyrdeer automatically
// TO CROBAT PORTION
pbf_press_button(context, BUTTON_B, (uint16_t)(1.05 * TICKS_PER_SECOND), 80); // sprint forward for a split second
pbf_move_left_joystick(context, 255, 150, 10, 20); // rotate slightly right
pbf_press_button(context, BUTTON_ZL, 20, 70); // align camera
context.wait_for_all_requests();
shiny_action.store(&SHINY_DETECTED_DESTINATION, std::memory_order_release);
pbf_move_left_joystick(context, 128, 0, (uint16_t)(3.8 * TICKS_PER_SECOND), 0); // forward to crobat check
},
{{shiny_detector}}
);
shiny_detector.throw_if_no_sound();
if (ret == 0){
ShinyDetectedActionOption* action = shiny_action.load(std::memory_order_acquire);
on_shiny_sound(env, env.console, context, *action, shiny_coefficient);
}
};
// then reset since no shiny was found
env.console.log("No shiny detected, restarting the game!");
pbf_press_button(context, BUTTON_HOME, 20, GameSettings::instance().GAME_TO_HOME_DELAY);
reset_game_from_home(env, env.console, context, ConsoleSettings::instance().TOLERATE_SYSTEM_UPDATE_MENU_FAST);
}
void CrobatFinder::program(SingleSwitchProgramEnvironment& env, BotBaseContext& context){
Stats& stats = env.stats<Stats>();
// Connect the controller.
pbf_press_button(context, BUTTON_LCLICK, 5, 5);
while (true){
env.update_stats();
send_program_status_notification(
env.logger(), NOTIFICATION_STATUS,
env.program_info(),
"",
stats.to_str()
);
try{
run_iteration(env, context);
}catch (OperationFailedException&){
stats.errors++;
pbf_press_button(context, BUTTON_HOME, 20, GameSettings::instance().GAME_TO_HOME_DELAY);
reset_game_from_home(env, env.console, context, ConsoleSettings::instance().TOLERATE_SYSTEM_UPDATE_MENU_FAST);
}
}
env.update_stats();
send_program_finished_notification(
env.logger(), NOTIFICATION_PROGRAM_FINISH,
env.program_info(),
"",
stats.to_str()
);
}
}
}
}
| 37.716216
| 137
| 0.655798
|
Gin890
|
be20ee6191c0133a8fd3b2c9cd606ddd40ee012b
| 1,733
|
cpp
|
C++
|
src/basic/adt/ApSInt.cpp
|
PHP-OPEN-HUB/polarphp
|
70ff4046e280fd99d718d4761686168fa8012aa5
|
[
"PHP-3.01"
] | null | null | null |
src/basic/adt/ApSInt.cpp
|
PHP-OPEN-HUB/polarphp
|
70ff4046e280fd99d718d4761686168fa8012aa5
|
[
"PHP-3.01"
] | null | null | null |
src/basic/adt/ApSInt.cpp
|
PHP-OPEN-HUB/polarphp
|
70ff4046e280fd99d718d4761686168fa8012aa5
|
[
"PHP-3.01"
] | null | null | null |
// This source file is part of the polarphp.org open source project
//
// Copyright (c) 2017 - 2019 polarphp software foundation
// Copyright (c) 2017 - 2019 zzu_softboy <zzu_softboy@163.com>
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://polarphp.org/LICENSE.txt for license information
// See https://polarphp.org/CONTRIBUTORS.txt for the list of polarphp project authors
//
// Created by polarboy on 2018/06/16.
//===----------------------------------------------------------------------===//
//
// This file implements the ApSInt class, which is a simple class that
// represents an arbitrary sized integer that knows its signedness.
//
//===----------------------------------------------------------------------===//
#include "polarphp/basic/adt/ApSInt.h"
#include "polarphp/basic/adt/FoldingSet.h"
#include "polarphp/basic/adt/StringRef.h"
namespace polar {
namespace basic {
ApSInt::ApSInt(StringRef str)
{
assert(!str.empty() && "Invalid string length");
// (Over-)estimate the required number of bits.
unsigned numBits = ((str.getSize() * 64) / 19) + 2;
ApInt temp(numBits, str, /*Radix=*/10);
if (str[0] == '-') {
unsigned minBits = temp.getMinSignedBits();
if (minBits > 0 && minBits < numBits) {
temp = temp.trunc(minBits);
}
*this = ApSInt(temp, /*isUnsigned=*/false);
return;
}
unsigned activeBits = temp.getActiveBits();
if (activeBits > 0 && activeBits < numBits) {
temp = temp.trunc(activeBits);
}
*this = ApSInt(temp, /*isUnsigned=*/true);
}
void ApSInt::profile(FoldingSetNodeId &id) const
{
id.addInteger((unsigned) (m_isUnsigned ? 1 : 0));
ApInt::profile(id);
}
} // basic
} // polar
| 30.946429
| 85
| 0.612233
|
PHP-OPEN-HUB
|
be23611dc134a0bacfb74518ac7874cb12086dd1
| 2,988
|
cc
|
C++
|
Geometry/CaloEventSetup/test/CaloAlignmentRcdWrite.cc
|
knash/cmssw
|
d4f63ec2b2c322e3be4c4d78ce20ebddbcd88ca7
|
[
"Apache-2.0"
] | null | null | null |
Geometry/CaloEventSetup/test/CaloAlignmentRcdWrite.cc
|
knash/cmssw
|
d4f63ec2b2c322e3be4c4d78ce20ebddbcd88ca7
|
[
"Apache-2.0"
] | 1
|
2021-06-28T14:25:47.000Z
|
2021-06-30T10:12:29.000Z
|
Geometry/CaloEventSetup/test/CaloAlignmentRcdWrite.cc
|
knash/cmssw
|
d4f63ec2b2c322e3be4c4d78ce20ebddbcd88ca7
|
[
"Apache-2.0"
] | null | null | null |
#include <string>
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/ServiceRegistry/interface/Service.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/one/EDAnalyzer.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "Utilities/General/interface/ClassName.h"
#include "FWCore/Utilities/interface/ESGetToken.h"
#include "CondCore/DBOutputService/interface/PoolDBOutputService.h"
#include "CondFormats/Alignment/interface/Alignments.h"
#include "CondFormats/Alignment/interface/AlignTransform.h"
#include "CondFormats/AlignmentRecord/interface/EBAlignmentRcd.h"
#include "CondFormats/AlignmentRecord/interface/EEAlignmentRcd.h"
#include "CondFormats/AlignmentRecord/interface/ESAlignmentRcd.h"
class CaloAlignmentRcdWrite : public edm::one::EDAnalyzer<>
{
public:
explicit CaloAlignmentRcdWrite(const edm::ParameterSet& /*iConfig*/)
:ebToken_{esConsumes<Alignments, EBAlignmentRcd>(edm::ESInputTag{})},
eeToken_{esConsumes<Alignments, EEAlignmentRcd>(edm::ESInputTag{})},
esToken_{esConsumes<Alignments, ESAlignmentRcd>(edm::ESInputTag{})},
nEventCalls_(0) {}
~CaloAlignmentRcdWrite() override {}
template<typename T>
void writeAlignments(const edm::EventSetup& evtSetup, edm::ESGetToken<Alignments, T>& token);
void beginJob() override {}
void analyze(edm::Event const& iEvent, edm::EventSetup const&) override;
void endJob() override {}
private:
edm::ESGetToken<Alignments, EBAlignmentRcd> ebToken_;
edm::ESGetToken<Alignments, EEAlignmentRcd> eeToken_;
edm::ESGetToken<Alignments, ESAlignmentRcd> esToken_;
unsigned int nEventCalls_;
};
template<typename T>
void CaloAlignmentRcdWrite::writeAlignments(const edm::EventSetup& evtSetup, edm::ESGetToken<Alignments, T>& token)
{
const auto& alignmentsES = evtSetup.getData(token);
std::string recordName = Demangle(typeid(T).name())();
std::cout << "Uploading alignments to the database: " << recordName << std::endl;
edm::Service<cond::service::PoolDBOutputService> poolDbService;
if (!poolDbService.isAvailable())
throw cms::Exception("NotAvailable") << "PoolDBOutputService not available";
Alignments * alignments = new Alignments(alignmentsES);
poolDbService->writeOne<Alignments>(&(*alignments),
poolDbService->currentTime(),
recordName);
}
void CaloAlignmentRcdWrite::analyze(const edm::Event& /*evt*/, const edm::EventSetup& evtSetup)
{
if (nEventCalls_ > 0) {
std::cout << "Writing to DB to be done only once, "
<< "set 'untracked PSet maxEvents = {untracked int32 input = 1}'."
<< "(Your writing should be fine.)" << std::endl;
return;
}
writeAlignments<EBAlignmentRcd>(evtSetup, ebToken_);
writeAlignments<EEAlignmentRcd>(evtSetup, eeToken_);
writeAlignments<ESAlignmentRcd>(evtSetup, esToken_);
std::cout << "done!" << std::endl;
nEventCalls_++;
}
DEFINE_FWK_MODULE(CaloAlignmentRcdWrite);
| 35.152941
| 115
| 0.745315
|
knash
|
be26304c1812023d42cb498cbf7686409bc6d23a
| 7,933
|
cpp
|
C++
|
src/BldRecons/SPB2OBJ/MeshGrid.cpp
|
liuxinren/UrbanReconstruction
|
079d9b0c9089aa9cdb15d31d76155e50a5e72f00
|
[
"MIT"
] | 94
|
2017-07-20T05:32:07.000Z
|
2022-03-02T03:38:54.000Z
|
src/BldRecons/SPB2OBJ/MeshGrid.cpp
|
GucciPrada/UrbanReconstruction
|
8b058349fd860ea9029623a92d705dd93a4e4878
|
[
"MIT"
] | 3
|
2017-09-12T00:07:05.000Z
|
2020-03-08T21:12:36.000Z
|
src/BldRecons/SPB2OBJ/MeshGrid.cpp
|
GucciPrada/UrbanReconstruction
|
8b058349fd860ea9029623a92d705dd93a4e4878
|
[
"MIT"
] | 38
|
2017-07-25T06:00:52.000Z
|
2022-03-19T10:01:06.000Z
|
#include "StdAfx.h"
#include "MeshGrid.h"
#include "ParamManager.h"
#include "Miscs\TimeMeter.h"
CMeshGrid::CMeshGrid(void)
{
}
CMeshGrid::~CMeshGrid(void)
{
}
void CMeshGrid::Mesh()
{
CParamManager * manager = CParamManager::GetParamManager();
CTimeMeter timer;
timer.Start();
fprintf_s( stderr, "==================== Pass 1, meshing ====================\n" );
Init();
fprintf_s( stderr, "Processing progress ... " );
InitPrintProgress();
int index;
while ( ( index = ReadNextChunk() ) != -1 ) {
PrintProgress( );
CMeshChunk * chunk = m_vecPointer[ index ];
chunk->BuildGridIndex();
ComputeGroundHeight( chunk );
delete m_vecPointer[ index ];
m_vecPointer[ index ] = NULL;
}
fprintf_s( stderr, " ... done!\n" );
Fin();
fprintf_s( stderr, "Total processing time is " );
timer.End();
timer.Print();
fprintf_s( stderr, ".\n\n" );
timer.Start();
fprintf_s( stderr, "==================== Pass 2, interpolate holes ====================\n" );
fprintf_s( stderr, "Processing ... " );
Interpolate();
fprintf_s( stderr, "done!\n" );
fprintf_s( stderr, "Total processing time is " );
timer.End();
timer.Print();
fprintf_s( stderr, ".\n\n" );
timer.Start();
fprintf_s( stderr, "==================== Pass 3, output ====================\n" );
fprintf_s( stderr, "Writing %s ...", manager->m_pOutputFile );
WriteMesh( manager->m_nSampleGrid );
fprintf_s( stderr, "succeed!\n" );
fprintf_s( stderr, "Total %d vertices and %d faces written in ", m_nVertexNumber, m_nFaceNumber );
timer.End();
timer.Print();
fprintf_s( stderr, ".\n" );
}
int CMeshGrid::ReadNextChunk()
{
// return the index of the finalized chunk
// return -1 indicating a EOF has been read
bool bNoneChunkEnd = true;
int index;
while ( bNoneChunkEnd ) {
if ( m_cReader.ReadNextElement() ) { // read chunk information
SPBCell * cell = m_cReader.GetCell();
switch ( cell->type ) {
case 0: // begin chunk
m_vecPointer[ cell->chunk_index ] = new CMeshChunk( cell->chunk_index, cell->point_number, this );
break;
case 1: // end chunk
bNoneChunkEnd = false;
index = cell->chunk_index;
break;
case -1: // EOF
bNoneChunkEnd = false;
index = -1;
break;
}
} else {
SPBPoint * point = m_cReader.GetPoint();
CVector3D v( point->pos[0], point->pos[1], point->pos[2] );
CMeshChunk * chunk = m_vecPointer[ Index( v ) ];
chunk->PushPoint( point );
IncReadNumber();
}
}
return index;
}
//////////////////////////////////////////////////////////////////////////
// main functions
//////////////////////////////////////////////////////////////////////////
void CMeshGrid::Init()
{
CParamManager * manager = CParamManager::GetParamManager();
m_cReader.OpenFile( manager->m_pInputFile );
m_cReader.RegisterGrid( this );
m_cReader.ReadHeader();
m_vecPointer.clear();
m_vecPointer.resize( m_nSideNumber * m_nSideNumber, NULL );
InitClip();
}
void CMeshGrid::ComputeGroundHeight( CMeshChunk * chunk )
{
for ( int x = 0; x < m_nUnitNumber[ 0 ]; x++ )
for ( int y = 0; y < m_nUnitNumber[ 1 ]; y++ ) {
int index = ClipIndex( x + chunk->m_iX * m_nUnitNumber[ 0 ], y + chunk->m_iY * m_nUnitNumber[ 1 ] );
if ( index != -1 ) {
PatchPointDataVector & cell_vector = chunk->m_vecGridIndex[ chunk->Index( x, y ) ];
m_vecHeight[ index ] = 1e300;
for ( int i = 0; i < ( int )cell_vector.size(); i++ ) {
PatchPointData & point = *( cell_vector[ i ] );
if ( point.type == PT_Ground && point.v[ 2 ] < m_vecHeight[ index ] ) {
m_vecHeight[ index ] = point.v[ 2 ];
}
}
}
}
}
void CMeshGrid::Fin()
{
m_cReader.CloseFile();
}
void CMeshGrid::Interpolate()
{
int last_solid;
double last_height, height;
for ( int y = m_nClip[ 1 ][ 0 ]; y <= m_nClip[ 1 ][ 1 ]; y++ ) {
last_solid = m_nClip[ 0 ][ 0 ] - 1;
for ( int x = m_nClip[ 0 ][ 0 ]; x <= m_nClip[ 0 ][ 1 ]; x++ ) {
int index = ClipIndex( x, y );
if ( m_vecHeight[ index ] != 1e300 ) {
// has data, solid!
height = m_vecHeight[ index ];
if ( last_solid == m_nClip[ 0 ][ 0 ] - 1 ) {
last_height = height;
} else {
last_height = m_vecHeight[ ClipIndex( last_solid, y ) ];
}
for ( int i = last_solid + 1; i < x; i++ ) {
m_vecHeight[ ClipIndex( i, y ) ] = height * ( double )( i - last_solid ) / ( double )( x - last_solid )
+ last_height * ( double )( x - i ) / ( double )( x - last_solid );
}
last_solid = x;
}
}
if ( last_solid != m_nClip[ 0 ][ 1 ] ) {
int x = m_nClip[ 0 ][ 1 ] + 1;
if ( last_solid == m_nClip[ 0 ][ 0 ] - 1 ) {
last_height = height = 0.0; // default height
} else {
last_height = height = m_vecHeight[ ClipIndex( last_solid, y ) ];
}
for ( int i = last_solid + 1; i < x; i++ ) {
m_vecHeight[ ClipIndex( i, y ) ] = height * ( double )( i - last_solid ) / ( double )( x - last_solid )
+ last_height * ( double )( x - i ) / ( double )( x - last_solid );
}
}
}
}
void CMeshGrid::WriteMesh( int sample_grid )
{
CParamManager * manager = CParamManager::GetParamManager();
m_cWriter.OpenFile( manager->m_pOutputFile );
m_cWriter.WriteHeader();
m_nVertexNumber = m_nFaceNumber = 0;
double data[3];
int idata[3];
for ( int x = m_nClip[ 0 ][ 0 ]; x <= m_nClip[ 0 ][ 1 ]; x += sample_grid )
for ( int y = m_nClip[ 1 ][ 0 ]; y <= m_nClip[ 1 ][ 1 ]; y += sample_grid ) {
data[0] = m_cBoundingBox.m_vMin[0] + m_dbGridLength * ( x + 0.5 );
data[1] = m_cBoundingBox.m_vMin[1] + m_dbGridLength * ( y + 0.5 );
data[2] = m_vecHeight[ ClipIndex( x, y ) ];
m_cWriter.WriteVertex( data );
m_nVertexNumber++;
}
int y_range = ( m_nClip[ 1 ][ 1 ] - m_nClip[ 1 ][ 0 ] ) / sample_grid + 1;
for ( int x = m_nClip[ 0 ][ 0 ]; x <= m_nClip[ 0 ][ 1 ] - sample_grid; x += sample_grid )
for ( int y = m_nClip[ 1 ][ 0 ]; y <= m_nClip[ 1 ][ 1 ] - sample_grid; y += sample_grid ) {
int truex = ( x - m_nClip[ 0 ][ 0 ] ) / sample_grid;
int truey = ( y - m_nClip[ 1 ][ 0 ] ) / sample_grid;
idata[0] = ( truex ) * y_range + ( truey );
idata[1] = ( truex + 1 ) * y_range + ( truey );
idata[2] = ( truex + 1 ) * y_range + ( truey + 1 );
m_cWriter.WriteFace( idata );
m_nFaceNumber++;
idata[0] = ( truex ) * y_range + ( truey );
idata[1] = ( truex + 1 ) * y_range + ( truey + 1 );
idata[2] = ( truex ) * y_range + ( truey + 1 );
m_cWriter.WriteFace( idata );
m_nFaceNumber++;
}
m_cWriter.CloseFile();
}
//////////////////////////////////////////////////////////////////////////
// auxiliary functions
//////////////////////////////////////////////////////////////////////////
void CMeshGrid::InitClip()
{
CParamManager * manager = CParamManager::GetParamManager();
if ( manager->m_bClip == false ) {
manager->m_dbClip[ 0 ][ 0 ] = m_cBoundingBox.m_vMin[ 0 ];
manager->m_dbClip[ 0 ][ 1 ] = m_cBoundingBox.m_vMax[ 0 ];
manager->m_dbClip[ 1 ][ 0 ] = m_cBoundingBox.m_vMin[ 1 ];
manager->m_dbClip[ 1 ][ 1 ] = m_cBoundingBox.m_vMax[ 1 ];
}
m_nClip[ 0 ][ 0 ] = ( int )( ( manager->m_dbClip[ 0 ][ 0 ] - m_cBoundingBox.m_vMin[ 0 ] ) / m_dbGridLength );
m_nClip[ 0 ][ 1 ] = ( int )( ( manager->m_dbClip[ 0 ][ 1 ] - m_cBoundingBox.m_vMin[ 0 ] ) / m_dbGridLength );
m_nClip[ 1 ][ 0 ] = ( int )( ( manager->m_dbClip[ 1 ][ 0 ] - m_cBoundingBox.m_vMin[ 1 ] ) / m_dbGridLength );
m_nClip[ 1 ][ 1 ] = ( int )( ( manager->m_dbClip[ 1 ][ 1 ] - m_cBoundingBox.m_vMin[ 1 ] ) / m_dbGridLength );
m_vecHeight.clear();
m_vecHeight.resize( ( m_nClip[ 0 ][ 1 ] - m_nClip[ 0 ][ 0 ] + 1 ) * ( m_nClip[ 1 ][ 1 ] - m_nClip[ 1 ][ 0 ] + 1 ), 1e300 );
}
int CMeshGrid::ClipIndex( int x, int y )
{
if ( x < m_nClip[ 0 ][ 0 ] || x > m_nClip[ 0 ][ 1 ] || y < m_nClip[ 1 ][ 0 ] || y > m_nClip[ 1 ][ 1 ] )
return -1;
else
return ( ( x - m_nClip[ 0 ][ 0 ] ) * ( m_nClip[ 1 ][ 1 ] - m_nClip[ 1 ][ 0 ] + 1 ) + ( y - m_nClip[ 1 ][ 0 ] ) );
}
| 26.982993
| 124
| 0.556284
|
liuxinren
|
be27d9ac8acb3f9a5aaa1968cd7eced13c4325e2
| 5,471
|
cpp
|
C++
|
src/WWWAPIHandler.cpp
|
backuperator/daemon
|
ae30bb57ceb5a989752cdde322c300c9208d3a50
|
[
"BSD-2-Clause"
] | null | null | null |
src/WWWAPIHandler.cpp
|
backuperator/daemon
|
ae30bb57ceb5a989752cdde322c300c9208d3a50
|
[
"BSD-2-Clause"
] | null | null | null |
src/WWWAPIHandler.cpp
|
backuperator/daemon
|
ae30bb57ceb5a989752cdde322c300c9208d3a50
|
[
"BSD-2-Clause"
] | null | null | null |
#include "WWWAPIHandler.hpp"
#include "IOLib.h"
#include <stdlib.h>
#include <glog/logging.h>
#include <boost/regex.hpp>
using json = nlohmann::json;
using namespace boost;
using namespace std;
// Create regexes for all URLs we support.
static regex _exprLibraries("^\\/api\\/libraries$");
/**
* Initializes the handler.
*/
WWWAPIHandler::WWWAPIHandler() {
}
WWWAPIHandler::~WWWAPIHandler() {
}
/**
* Handles a request.
*
* @param method HTTP method; may be GET or POST.
* @param params Input parameters for the request.
*/
json WWWAPIHandler::handle(string method, string url, json params) {
cmatch what;
// Print
LOG(INFO) << "API Request " << method << " " << url << ": " << params;
// Listing all libraries?
if(regex_match(url.c_str(), what, _exprLibraries)) {
return _getAllLibraries();
}
// Unknown API request; log it.
else {
LOG(WARNING) << "Unknown API Request " << method << " " << url << ": " << params;
}
// We should never get down here
return {
{ "error", "Unknown API request" }
};
}
/**
* Fetches all libraries, including drives and loaders.
*/
json WWWAPIHandler::_getAllLibraries() {
vector<json> libraries;
vector<json> drives;
vector<json> loaders;
vector<json> elements;
// Fetch all libraries
iolib_library_t libs[8];
size_t numLibs = iolibEnumerateDevices((iolib_library_t *) &libs, 8, NULL);
for(size_t i = 0; i < numLibs; i++) {
vector<string> driveIds;
vector<string> loaderIds;
// Create JSON objects for any drives.
for(size_t j = 0; j < libs[i].numDrives; j++) {
iolib_drive_t drive = libs[i].drives[j];
// Get UUID
string uuid = _stdStringFromIoLibString(iolibDriveGetUuid(drive));
// Create drive object
drives.push_back({
{"id", uuid},
{"name", _stdStringFromIoLibString(iolibDriveGetName(drive))},
{"file", _stdStringFromIoLibString(iolibDriveGetDevFile(drive))}
// {"library", libs[i].id}
});
driveIds.push_back(uuid);
}
// Create JSON objects for any loaders.
for(size_t j = 0; j < libs[i].numLoaders; j++) {
iolib_loader_t loader = libs[i].loaders[j];
string uuid = _stdStringFromIoLibString(iolibLoaderGetUuid(loader));
// Process all of the elements
vector<string> loaderElementIds;
size_t numElements = 0;
static const iolib_storage_element_type_t types[] = {
kStorageElementTransport,
kStorageElementDrive,
kStorageElementPortal,
kStorageElementSlot
};
for(size_t i = 0; i < (sizeof(types) / sizeof(*types)); i++) {
// Get the number of elements
size_t elmsOfType = iolibLoaderGetNumElements(loader, types[i]);
numElements += elmsOfType;
iolib_storage_element_t elms[elmsOfType];
// Get all the elements
iolibLoaderGetElements(loader, types[i],
reinterpret_cast<iolib_storage_element_t *>(&elms),
elmsOfType);
// ...and now, process them.
for(size_t j = 0; j < elmsOfType; j++) {
iolib_storage_element_t element = elms[j];
json elementJson = _jsonForElement(element);
elements.push_back(elementJson);
loaderElementIds.push_back(elementJson["id"]);
}
}
// Create loader entry
loaders.push_back({
{"id", uuid},
{"name", _stdStringFromIoLibString(iolibLoaderGetName(loader))},
{"file", _stdStringFromIoLibString(iolibLoaderGetDevFile(loader))},
{"elements", loaderElementIds}
// {"library", libs[i].id}
});
loaderIds.push_back(uuid);
}
// Insert the JSON object for the library.
libraries.push_back({
{"id", _stdStringFromIoLibString(libs[i].id)},
{"name", _stdStringFromIoLibString(libs[i].name)},
{"drives", driveIds},
{"loaders", loaderIds},
});
}
// Construct the response
return {
{"libraries", libraries},
{"drives", drives},
{"loaders", loaders},
{"elements", elements},
};
}
/**
* Constructs a json object for a loader's storage element.
*/
json WWWAPIHandler::_jsonForElement(iolib_storage_element_t element) {
json elementJson;
// Get UUID
elementJson["id"] = _stdStringFromIoLibString(iolibElementGetUuid(element));
// Get logical element address
elementJson["address"] = iolibElementGetAddress(element);
// Check the flags - is it empty?
elementJson["isEmpty"] = !(iolibElementGetFlags(element) & kStorageElementFull);
// Populate the type
switch(iolibElementGetType(element)) {
case kStorageElementDrive:
elementJson["kind"] = "drive";
break;
case kStorageElementSlot:
elementJson["kind"] = "storage";
break;
case kStorageElementPortal:
elementJson["kind"] = "portal";
break;
case kStorageElementTransport:
elementJson["kind"] = "transport";
break;
default:
break;
}
// And lastly, the volume tag.
iolib_string_t rawLabel = iolibElementGetLabel(element);
string label = string(rawLabel);
iolibStringFree(rawLabel);
elementJson["label"] = label;
return elementJson;
}
/**
* Creates a standard library string from an iolib string, freeing that iolib
* string once done.
*/
string WWWAPIHandler::_stdStringFromIoLibString(iolib_string_t in) {
string out = string(in);
iolibStringFree(in);
return out;
}
| 25.211982
| 89
| 0.640468
|
backuperator
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.