hexsha stringlengths 40 40 | size int64 22 2.4M | ext stringclasses 5
values | lang stringclasses 1
value | max_stars_repo_path stringlengths 3 260 | max_stars_repo_name stringlengths 5 109 | max_stars_repo_head_hexsha stringlengths 40 78 | max_stars_repo_licenses listlengths 1 9 | max_stars_count float64 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 3 260 | max_issues_repo_name stringlengths 5 109 | max_issues_repo_head_hexsha stringlengths 40 78 | max_issues_repo_licenses listlengths 1 9 | max_issues_count float64 1 67k ⌀ | max_issues_repo_issues_event_min_datetime stringlengths 24 24 ⌀ | max_issues_repo_issues_event_max_datetime stringlengths 24 24 ⌀ | max_forks_repo_path stringlengths 3 260 | max_forks_repo_name stringlengths 5 109 | max_forks_repo_head_hexsha stringlengths 40 78 | max_forks_repo_licenses listlengths 1 9 | max_forks_count float64 1 105k ⌀ | max_forks_repo_forks_event_min_datetime stringlengths 24 24 ⌀ | max_forks_repo_forks_event_max_datetime stringlengths 24 24 ⌀ | content stringlengths 22 2.4M | avg_line_length float64 5 169k | max_line_length int64 5 786k | alphanum_fraction float64 0.06 0.95 | matches listlengths 1 11 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
782f99093b221c81b642cfe7c647e64f46848d60 | 2,181 | h | C | CLHEP/Alist/AIteratorBase.h | brownd1978/FastSim | 05f590d72d8e7f71856fd833114a38b84fc7fd48 | [
"Apache-2.0"
] | null | null | null | CLHEP/Alist/AIteratorBase.h | brownd1978/FastSim | 05f590d72d8e7f71856fd833114a38b84fc7fd48 | [
"Apache-2.0"
] | null | null | null | CLHEP/Alist/AIteratorBase.h | brownd1978/FastSim | 05f590d72d8e7f71856fd833114a38b84fc7fd48 | [
"Apache-2.0"
] | null | null | null | // -*- C++ -*-
// CLASSDOC OFF
// $Id: AIteratorBase.h 478 2010-01-22 08:54:39Z stroili $
// CLASSDOC ON
//
// This file is a part of what might beome the CLHEP -
// a Class Library for High Energy Physics.
//
// This is the definition of the HepAListIteratorBase class. It is the base
// class used by the template classes HepAListIterator and
// HepConstAListIterator
//
// .SS See Also
//
// AList.h, AIterator.h, ConstAList.h, ConstAIterator.h, AListBase.h
//
// .SS History
// HepConstAListIterator was developed from an original (non-template) list
// iterator class written by Dag Bruck.
//
// Author: Leif Lonnblad
//
#ifndef _AITERATORBASE_H_
#define _AITERATORBASE_H_
#ifdef GNUPRAGMA
#pragma interface
#endif
#include "CLHEP/config/CLHEP.h"
#include "CLHEP/Alist/AListBase.h"
#ifdef HEP_NO_INLINE_IN_DECLARATION
#define inline
#endif
class HepAListIteratorBase {
protected:
inline HepAListIteratorBase(const HepAListBase &);
// Constructor taking a corresponding list as argument. Starting at the
// first element.
inline HepAListIteratorBase(const HepAListIteratorBase &);
// Copy constructor.
inline ~HepAListIteratorBase();
inline void * next();
// Returns a pointer to the current object in the associated list, moving
// forward to the next. Returns 0 if all objects are done.
inline void * prev();
// Moves backward one step in the list and returns the object found there.
// If current object is the first in the list, no stepping is done and 0 is
// returned.
inline void * current() const;
// Returns a pointer to the current object in the associated list,
// without incrementing the index.
public:
inline int index() const;
inline void rewind();
// Rewinds the iterator to the first element of the list.
void skip(int);
// Move iterator forward or backward.
inline void skipAll();
// Move iterator past last element.
private:
const HepAListBase * l;
// Pointer to the associated list.
int i;
// Current position in the associated list.
};
#ifdef HEP_NO_INLINE_IN_DECLARATION
#undef inline
#endif
#ifndef HEP_DEBUG_INLINE
#include "CLHEP/Alist/AIteratorBase.icc"
#endif
#endif
| 22.71875 | 77 | 0.728106 | [
"object"
] |
78329fee01bbabf94ef6779e8abdb9a363dd3e19 | 790 | h | C | average-salary-excluding-the-minimum-and-maximum-salary.h | kiddliu/midnight-leetcode | 1c5638102111ff7509b1bc125ba66741ba6b149e | [
"MIT"
] | null | null | null | average-salary-excluding-the-minimum-and-maximum-salary.h | kiddliu/midnight-leetcode | 1c5638102111ff7509b1bc125ba66741ba6b149e | [
"MIT"
] | null | null | null | average-salary-excluding-the-minimum-and-maximum-salary.h | kiddliu/midnight-leetcode | 1c5638102111ff7509b1bc125ba66741ba6b149e | [
"MIT"
] | null | null | null | #ifndef AVERAGE_SALARY_EXCLUDING_THE_MINIMUM_AND_MAXIMUM_SALARY_H_
#define AVERAGE_SALARY_EXCLUDING_THE_MINIMUM_AND_MAXIMUM_SALARY_H_
#include <vector>
namespace solution {
double average(std::vector<int>& salary) {
// straight forward
// Runtime: 0 ms, faster than 100.00% of C++ online submissions for Average Salary Excluding the Minimum and Maximum Salary.
// Memory Usage: 7.1 MB, less than 81.59% of C++ online submissions for Average Salary Excluding the Minimum and Maximum Salary.
//
auto max{INT_MIN}, min{INT_MAX};
auto sum{0.};
for (const auto& s : salary) {
max = std::max(max, s);
min = std::min(min, s);
sum += s;
}
return (sum - max - min) / (salary.size() - 2);
}
}
#endif // AVERAGE_SALARY_EXCLUDING_THE_MINIMUM_AND_MAXIMUM_SALARY_H_
| 28.214286 | 130 | 0.718987 | [
"vector"
] |
7836770f7e7a2a36fc015b1d82e7dd0e4fe7d30b | 8,291 | h | C | list/OList.h | mikelsv/msvcore2 | 128b4b9523218da1eb056f6b11ada0bdc72b5c93 | [
"MIT"
] | 1 | 2017-09-11T11:50:07.000Z | 2017-09-11T11:50:07.000Z | list/OList.h | mikelsv/msvcore2 | 128b4b9523218da1eb056f6b11ada0bdc72b5c93 | [
"MIT"
] | null | null | null | list/OList.h | mikelsv/msvcore2 | 128b4b9523218da1eb056f6b11ada0bdc72b5c93 | [
"MIT"
] | null | null | null | //NEW OBJECT MATRIX -- updated to --> Object List -- updated to --> Very new Object List
template<class OListEl, int AListOps = AListCon | AListDes | AListClear>
class OList;
template<class OListEl>
class OListP;
// My: http://pastebin.com/wxjZ3vsL
// Extended Element
template<class OListEl>
class OListElEx{
public:
OListElEx *_p, *_n;
OListEl el;
#ifdef OLIST_TEST
uint64 test;
#endif
};
// Jump
template<class OListEl>
class OListJ{
private:
// Pointers
OList<OListEl> *olist;
OListEl *el;
// Locked
int lock;
public:
OListJ(){
olist = 0;
el = 0;
lock = 0;
}
OListJ(OList<OListEl> *o, OListEl *e){
olist = o;
el = e;
if(olist){
o->Lock();
lock = 1;
} else
lock = 0;
}
// Move
OListJ(OListJ &j){
olist = j.olist;
el = j.el;
lock = j.lock;
j.lock = 0;
}
OListJ(OListP<OListEl> &p){
olist = p.olist;
el = p.el;
if(olist){
olist->Lock();
lock = 1;
} else
lock = 0;
}
// Move
OListJ& operator=(OListJ &j){
olist = j.olist;
el = j.el;
lock = j.lock;
j.lock = 0;
return *this;
}
#if __cplusplus >= 201103L || WIN32 && !__GNUC__
OListJ(OListJ &&j){
olist = j.olist;
el = j.el;
lock = j.lock;
j.lock = 0;
}
#endif
~OListJ(){
if(olist && lock)
olist->UnLock();
olist = 0;
el = 0;
lock = 0;
}
//template<class OListEl>
friend class OListP<OListEl>;
};
// Pointer
template<class OListEl>
class OListP : public TLock{
private:
// Pointers list in OList
OListP *_p, *_n;
// Pointers
OList<OListEl> *olist;
OListEl *el;
public:
OListP(){
_p = 0;
_n = 0;
olist = 0;
el = 0;
}
private:
OListP(OListP &o){}
OListP& operator=(OListP &o){ return this; }
public:
OListP(const OList<OListEl> &o){
_p = 0;
_n = 0;
olist = o.GetThis();
el = 0;
Lock();
olist->NewLink(this);
}
OListP(const OListJ<OListEl> &j){
_p = 0;
_n = 0;
olist = j.olist;
el = j.el;
Lock();
olist->NewLink(this);
}
OListP& operator=(const OListJ<OListEl> &j){
Clean();
olist = j.olist;
el = j.el;
Lock();
olist->NewLink(this);
return *this;
}
OListEl* First(){
if(!olist)
return 0;
UnLock();
UGLOCK(olist);
el = olist->First();
Lock();
return el;
}
OListEl* Next(){
if(!olist)
return 0;
UnLock();
UGLOCK(olist);
el = olist->Next(el);
Lock();
return el;
}
OListEl* operator ->(){
return el;
}
operator OListEl*(){
return el;
}
void Free(){
if(!olist)
return ;
OListEl *del = el;
UnLock();
UGLOCK(olist);
if(del == el){
el = olist->Next(el);
olist->Free(del);
}
Lock();
return ;
}
void Clean(){
if(olist){
UnLock();
olist->FreeLink(this);
}
_p = 0;
_n = 0;
olist = 0;
el = 0;
}
~OListP(){
Clean();
}
//template<class OListEl, int AListOps>
friend class OList<OListEl>;
friend class OListJ<OListEl>;
};
//template<class OListEl>
//typedef int (*OLIST_SORTFUNC)(OListEl *l, OListEl *r);
template<class OListEl, int AListOps>
class OList : public AListAllocOList<OListElEx<OListEl>, AListOps>, public TLock{
// Linked elements
OListElEx<OListEl> *_a, *_e;
// Linked pointers
OListP<OListEl> *_ap, *_ep;
// Size
int sz;
public:
OList(){
_a = 0;
_e = 0;
_ap = 0;
_ep = 0;
sz = 0;
}
OListEl* NewE(){
UGLOCK(this);
OListElEx<OListEl> *el = this->AllocNew();
OMatrixTemplateAdd(_a, _e, el);
#ifdef OLIST_TEST
el->test = 0xfacedeadfeedcade;
#endif
sz ++;
return &el->el;
}
OListJ<OListEl> New(){
UGLOCK(this);
OListJ<OListEl> j(this, NewE());
return j;
}
OListEl* First(){
UGLOCK(this);
if(!_a)
return 0;
return &_a->el;
}
OListEl* Prev(OListEl *el){
UGLOCK(this);
if(!_a)
return 0;
if(!el)
return &_e->el;
OListElEx<OListEl> *p = GetEx(el);
if(p->_p)
return &p->_p->el;
return 0;
}
OListEl* Next(OListEl *el){
UGLOCK(this);
if(!_a)
return 0;
if(!el)
return &_a->el;
OListElEx<OListEl> *p = GetEx(el);
if(p->_n)
return &p->_n->el;
return 0;
}
OList<OListEl>* GetThis() const{
return (OList<OListEl>*)this;
}
template <typename SortFunc>
void Sort(SortFunc func){
UGLOCK(this);
int sorted = 1;
while(sorted){
OListElEx<OListEl> *p = _a, *n;
sorted = 0;
while(p && p->_n){
if(func(&p->el, &p->_n->el)){
n = p->_n;
OMatrixTemplateDel(_a, _e, p);
OMatrixTemplateAddP(_a, _e, n, p);
sorted = 1;
continue;
}
p = p->_n;
}
}
return ;
}
template <typename SeaFunc, class SeaClass>
OListEl* Search(SeaFunc func, SeaClass cls){
UGLOCK(this);
OListElEx<OListEl> *p = _a;
while(p){
if(func(p->el, cls))
return &p->el;
p = p->_n;
}
return 0;
}
void Free(OListEl *el){
UGLOCK(this);
if(!el)
return ;
OListElEx<OListEl> *e = GetEx(el);
#ifdef OLIST_TEST
if(e->test != 0xfacedeadfeedcade)
globalerror("OMATRIX TEST FAIL!");
e->test = 0xfacedeadfeedcada;
#endif
OListP<OListEl> *p = _ap;
while(p){
if(p->el == el){
p->Lock();
p->el = e->_p != 0 ? &e->_p->el : 0;
p->UnLock();
}
p = p->_n;
}
OMatrixTemplateDel(_a, _e, e);
this->AllocFree(e);
sz --;
return ;
}
private:
OListElEx<OListEl>* GetEx(OListEl *el){
if(!el)
return 0;
return (OListElEx<OListEl>*)((char*)el - 2 * sizeof(void*));
}
void NewLink(OListP<OListEl> *p){
UGLOCK(this);
if(p->_n)
globalerror("void NewLink(OListP<OListEl> *p){ Allready pointed! }");
OMatrixTemplateAdd(_ap, _ep, p);
return ;
}
void FreeLink(OListP<OListEl> *p){
UGLOCK(this);
OMatrixTemplateDel(_ap, _ep, p);
return ;
}
public:
unsigned int Size(){
return sz;
}
void Clean(){
UGLOCK(this);
OListElEx<OListEl> *p = _a, *d;
while(p){
d = p;
p = p->_n;
this->AllocFree(d);
}
_a = 0;
_e = 0;
sz = 0;
return ;
}
~OList(){
Clean();
}
//template<class OListEl>
friend class OListP<OListEl>;
};
// Single Thread
template<class OListEl, int AListOps = AListCon | AListDes | AListClear>
class OListSingle;
template<class OListEl, int AListOps>
class OListSingle : public AListAllocOList<OListElEx<OListEl>, AListOps>{
// Linked elements
OListElEx<OListEl> *_a, *_e;
// Size
int sz;
public:
OListSingle(){
_a = 0;
_e = 0;
sz = 0;
}
OListEl* New(){
OListElEx<OListEl> *el = this->AllocNew();
OMatrixTemplateAdd(_a, _e, el);
#ifdef OLIST_TEST
el->test = 0xfacedeadfeedcade;
#endif
sz ++;
return &el->el;
}
OListEl* First(){
if(!_a)
return 0;
return &_a->el;
}
OListEl* Prev(OListEl *el){
if(!_a)
return 0;
if(!el)
return &_e->el;
OListElEx<OListEl> *p = GetEx(el);
if(p->_p)
return &p->_p->el;
return 0;
}
OListEl* Next(OListEl *el){
if(!_a)
return 0;
if(!el)
return &_a->el;
OListElEx<OListEl> *p = GetEx(el);
if(p->_n)
return &p->_n->el;
return 0;
}
OList<OListEl>* GetThis() const{
return (OList<OListEl>*)this;
}
template <typename SortFunc>
void Sort(SortFunc func){
int sorted = 1;
while(sorted){
OListElEx<OListEl> *p = _a, *n;
sorted = 0;
while(p && p->_n){
if(func(&p->el, &p->_n->el)){
n = p->_n;
OMatrixTemplateDel(_a, _e, p);
OMatrixTemplateAddP(_a, _e, n, p);
sorted = 1;
continue;
}
p = p->_n;
}
}
return ;
}
template <typename SeaFunc, class SeaClass>
OListEl* Search(SeaFunc func, SeaClass cls){
OListElEx<OListEl> *p = _a;
while(p){
if(func(p->el, cls))
return &p->el;
p = p->_n;
}
return 0;
}
void Free(OListEl *el){
if(!el)
return ;
OListElEx<OListEl> *e = GetEx(el);
#ifdef OLIST_TEST
if(e->test != 0xfacedeadfeedcade)
globalerror("OMATRIX TEST FAIL!");
e->test = 0xfacedeadfeedcada;
#endif
OMatrixTemplateDel(_a, _e, e);
this->AllocFree(e);
sz --;
return ;
}
private:
OListElEx<OListEl>* GetEx(OListEl *el){
if(!el)
return 0;
return (OListElEx<OListEl>*)((char*)el - 2 * sizeof(void*));
}
public:
unsigned int Size(){
return sz;
}
void Clean(){
OListElEx<OListEl> *p = _a, *d;
while(p){
d = p;
p = p->_n;
this->AllocFree(d);
}
_a = 0;
_e = 0;
sz = 0;
return ;
}
~OListSingle(){
Clean();
}
//template<class OListEl>
friend class OListP<OListEl>;
}; | 13.077287 | 88 | 0.580509 | [
"object"
] |
784a3e6c69757d3d59c57b24348ff3011468cc94 | 9,092 | h | C | source/direct3d11/EffectVariable11.h | HeavenWu/slimdx | e014bb34b89bbf694d01c8f6d6b6dfa3cba58aac | [
"MIT"
] | 85 | 2015-04-06T05:37:10.000Z | 2022-03-22T19:53:03.000Z | source/direct3d11/EffectVariable11.h | HeavenWu/slimdx | e014bb34b89bbf694d01c8f6d6b6dfa3cba58aac | [
"MIT"
] | 10 | 2016-03-17T11:18:24.000Z | 2021-05-11T09:21:43.000Z | source/direct3d11/EffectVariable11.h | HeavenWu/slimdx | e014bb34b89bbf694d01c8f6d6b6dfa3cba58aac | [
"MIT"
] | 45 | 2015-09-14T03:54:01.000Z | 2022-03-22T19:53:09.000Z | /*
* Copyright (c) 2007-2012 SlimDX Group
*
* 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 "../ComObject.h"
#include "Enums11.h"
namespace SlimDX
{
namespace Direct3D11
{
ref class EffectConstantBuffer;
ref class EffectMatrixVariable;
ref class EffectResourceVariable;
ref class EffectShaderVariable;
ref class EffectScalarVariable;
ref class EffectVectorVariable;
ref class EffectStringVariable;
ref class EffectUnorderedAccessViewVariable;
ref class EffectBlendVariable;
ref class EffectClassInstanceVariable;
ref class EffectDepthStencilVariable;
ref class EffectDepthStencilViewVariable;
ref class EffectInterfaceVariable;
ref class EffectRasterizerVariable;
ref class EffectRenderTargetViewVariable;
ref class EffectSamplerVariable;
value class EffectVariableDescription;
ref class EffectType;
/// <summary>
/// Defines a base class for all effect variables.
/// </summary>
/// <unmanaged>ID3DX11EffectVariable</unmanaged>
public ref class EffectVariable
{
private:
ID3DX11EffectVariable* m_Pointer;
internal:
EffectVariable( ID3DX11EffectVariable* pointer );
public:
/// <summary>
/// Initializes a new instance of the <see cref="EffectVariable"/> class.
/// </summary>
/// <param name="pointer">A pointer to the unmanaged interface.</param>
EffectVariable( System::IntPtr pointer );
/// <summary>
/// Gets the effect variable's description.
/// </summary>
property EffectVariableDescription Description
{
EffectVariableDescription get();
}
/// <summary>
/// Indicates whether the data type matches the data stored after casting to a specific interface.
/// </summary>
property bool IsValid
{
bool get();
}
/// <summary>
/// Gets the parent constant buffer for this variable.
/// </summary>
property EffectConstantBuffer^ ParentConstantBuffer
{
EffectConstantBuffer^ get();
}
/// <summary>
/// Get an annotation by index.
/// </summary>
/// <param name="index">The zero-based index of the annotation to retrieve.</param>
/// <returns>The annotation at the specified index.</returns>
EffectVariable^ GetAnnotationByIndex( int index );
/// <summary>
/// Get an annotation by name.
/// </summary>
/// <param name="name">The name of the annotation to retrieve.</param>
/// <returns>The annotation with the given name.</returns>
EffectVariable^ GetAnnotationByName( System::String^ name );
/// <summary>
/// Gets an element of an array variable.
/// </summary>
/// <param name="index">The zero-based index of the element to retrieve.</param>
/// <returns>The element at the specified index in the array.</returns>
EffectVariable^ GetElement( int index );
/// <summary>
/// Get a structure member by index.
/// </summary>
/// <param name="index">The zero-based index of the structure member to retrieve.</param>
/// <returns>The structure member at the specified index.</returns>
EffectVariable^ GetMemberByIndex( int index );
/// <summary>
/// Get a structure member by name.
/// </summary>
/// <param name="name">The name of the structure member to retrieve.</param>
/// <returns>The structure member with the given name.</returns>
EffectVariable^ GetMemberByName( System::String^ name );
/// <summary>
/// Get a structure member by semantic.
/// </summary>
/// <param name="name">The semantic of the structure member to retrieve.</param>
/// <returns>The structure member with the given semantic.</returns>
EffectVariable^ GetMemberBySemantic( System::String^ name );
/// <summary>
/// Reinterprets the effect variable as a more specialized blend-state variable.
/// </summary>
/// <returns>The specialized effect variable.</returns>
EffectBlendVariable^ AsBlend();
/// <summary>
/// Reinterprets the effect variable as a more specialized class instance variable.
/// </summary>
/// <returns>The specialized effect variable.</returns>
EffectClassInstanceVariable^ AsClassInstance();
/// <summary>
/// Reinterprets the effect variable as a more specialized constant buffer variable.
/// </summary>
/// <returns>The specialized effect variable.</returns>
EffectConstantBuffer^ AsConstantBuffer();
/// <summary>
/// Reinterprets the effect variable as a more specialized depth-stencil-state variable.
/// </summary>
/// <returns>The specialized effect variable.</returns>
EffectDepthStencilVariable^ AsDepthStencil();
/// <summary>
/// Reinterprets the effect variable as a more specialized depth-stencil view variable.
/// </summary>
/// <returns>The specialized effect variable.</returns>
EffectDepthStencilViewVariable^ AsDepthStencilView();
/// <summary>
/// Reinterprets the effect variable as a more specialized interface variable.
/// </summary>
/// <returns>The specialized effect variable.</returns>
EffectInterfaceVariable^ AsInterface();
/// <summary>
/// Reinterprets the effect variable as a more specialized matrix variable.
/// </summary>
/// <returns>The specialized effect variable.</returns>
EffectMatrixVariable^ AsMatrix();
/// <summary>
/// Reinterprets the effect variable as a more specialized rasterizer-state variable.
/// </summary>
/// <returns>The specialized effect variable.</returns>
EffectRasterizerVariable^ AsRasterizer();
/// <summary>
/// Reinterprets the effect variable as a more specialized render target view variable.
/// </summary>
/// <returns>The specialized effect variable.</returns>
EffectRenderTargetViewVariable^ AsRenderTargetView();
/// <summary>
/// Reinterprets the effect variable as a more specialized sampler state variable.
/// </summary>
/// <returns>The specialized effect variable.</returns>
EffectSamplerVariable^ AsSampler();
/// <summary>
/// Reinterprets the effect variable as a more specialized shader resource variable.
/// </summary>
/// <returns>The specialized effect variable.</returns>
EffectResourceVariable^ AsResource();
/// <summary>
/// Reinterprets the effect variable as a more specialized scalar variable.
/// </summary>
/// <returns>The specialized effect variable.</returns>
EffectScalarVariable^ AsScalar();
/// <summary>
/// Reinterprets the effect variable as a more specialized shader variable.
/// </summary>
/// <returns>The specialized effect variable.</returns>
EffectShaderVariable^ AsShader();
/// <summary>
/// Reinterprets the effect variable as a more specialized string variable.
/// </summary>
/// <returns>The specialized effect variable.</returns>
EffectStringVariable^ AsString();
/// <summary>
/// Reinterprets the effect variable as a more specialized unordered access view variable.
/// </summary>
/// <returns>The specialized effect variable.</returns>
EffectUnorderedAccessViewVariable^ AsUnorderedAccessView();
/// <summary>
/// Reinterprets the effect variable as a more specialized vector variable.
/// </summary>
/// <returns>The specialized effect variable.</returns>
EffectVectorVariable^ AsVector();
/// <summary>
/// Gets information about the variable type.
/// </summary>
/// <returns>A type descriptor containing information about the variable type.</returns>
EffectType^ GetVariableType();
/// <summary>
/// Sets the value of the variable using raw bytes.
/// </summary>
/// <param name="count">The number of bytes to set.</param>
/// <returns>A <see cref="SlimDX::Result"/> object describing the result of the operation.</returns>
Result SetRawValue(DataStream^ data, int count);
/// <summary>
/// Gets the value of the variable in raw bytes.
/// </summary>
/// <param name="count">The number of bytes to retrieve.</param>
/// <returns>The raw data representing the value of the variable.</returns>
DataStream^ GetRawValue(int count);
};
}
}; | 35.936759 | 103 | 0.704575 | [
"render",
"object",
"vector"
] |
7a825771981fc72cf80d992cdf32a4ae61050d15 | 5,080 | h | C | src/AstUtils.h | LaudateCorpus1/souffle | 66feafbc7b9b9b4318695c271aabaa48669900fa | [
"UPL-1.0"
] | 61 | 2016-03-07T23:52:52.000Z | 2020-10-19T06:23:50.000Z | src/AstUtils.h | LaudateCorpus1/souffle | 66feafbc7b9b9b4318695c271aabaa48669900fa | [
"UPL-1.0"
] | 11 | 2016-03-08T06:11:59.000Z | 2017-07-20T17:58:13.000Z | src/AstUtils.h | LaudateCorpus1/souffle | 66feafbc7b9b9b4318695c271aabaa48669900fa | [
"UPL-1.0"
] | 25 | 2016-03-08T03:36:39.000Z | 2022-02-18T04:50:33.000Z | /*
* Copyright (c) 2013, 2015, Oracle and/or its affiliates. All Rights reserved
*
* The Universal Permissive License (UPL), Version 1.0
*
* Subject to the condition set forth below, permission is hereby granted to any person obtaining a copy of this software,
* associated documentation and/or data (collectively the "Software"), free of charge and under any and all copyright rights in the
* Software, and any and all patent rights owned or freely licensable by each licensor hereunder covering either (i) the unmodified
* Software as contributed to or provided by such licensor, or (ii) the Larger Works (as defined below), to deal in both
*
* (a) the Software, and
* (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if one is included with the Software (each a “Larger
* Work” to which the Software is contributed by such licensors),
*
* without restriction, including without limitation the rights to copy, create derivative works of, display, perform, and
* distribute the Software and make, use, sell, offer for sale, import, export, have made, and have sold the Software and the
* Larger Work(s), and to sublicense the foregoing rights on either these or other terms.
*
* This license is subject to the following condition:
* The above copyright notice and either this complete permission notice or at a minimum a reference to the UPL must be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
* IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/************************************************************************
*
* @file AstUtils.h
*
* A collection of utilities operating on AST constructs.
*
***********************************************************************/
#pragma once
#include <map>
#include <vector>
#include <set>
// some forward declarations
class AstNode;
class AstVariable;
class AstRelation;
class AstAtom;
class AstClause;
class AstProgram;
class AstLiteral;
// ---------------------------------------------------------------
// General Utilities
// ---------------------------------------------------------------
/**
* Obtains a list of all variables referenced within the AST rooted
* by the given root node.
*
* @param root the root of the AST to be searched
* @return a list of all variables referenced within
*/
std::vector<const AstVariable*> getVariables(const AstNode& root);
/**
* Obtains a list of all variables referenced within the AST rooted
* by the given root node.
*
* @param root the root of the AST to be searched
* @return a list of all variables referenced within
*/
std::vector<const AstVariable*> getVariables(const AstNode* root);
/**
* Returns the relation referenced by the given atom.
* @param atom the atom
* @param program the program containing the relations
* @return relation referenced by the atom
*/
const AstRelation *getAtomRelation(const AstAtom *atom, const AstProgram *program);
/**
* Returns the relation referenced by the head of the given clause.
* @param clause the clause
* @param program the program containing the relations
* @return relation referenced by the clause head
*/
const AstRelation *getHeadRelation(const AstClause *clause, const AstProgram *program);
/**
* Returns the relations referenced in the body of the given clause.
* @param clause the clause
* @param program the program containing the relations
* @return relation referenced in the clause body
*/
std::set<const AstRelation *> getBodyRelations(const AstClause *clause, const AstProgram *program);
/**
* Returns whether the given relation has any clauses which contain a negation of a specific relation.
* @param relation the relation to search the clauses of
* @param negRelation the relation to search for negations of in clause bodies
* @param program the program containing the relations
* @param foundLiteral set to the negation literal that was found
*/
bool hasClauseWithNegatedRelation(const AstRelation *relation, const AstRelation *negRelation, const AstProgram *program, const AstLiteral *&foundLiteral);
/**
* Returns whether the given relation has any clauses which contain an aggregation over of a specific relation.
* @param relation the relation to search the clauses of
* @param aggRelation the relation to search for in aggregations in clause bodies
* @param program the program containing the relations
* @param foundLiteral set to the literal found in an aggregation
*/
bool hasClauseWithAggregatedRelation(const AstRelation *relation, const AstRelation *aggRelation, const AstProgram *program, const AstLiteral *&foundLiteral);
| 43.050847 | 158 | 0.719488 | [
"vector"
] |
7a89c10ca807aa4357c1ba43fecae4ec00133740 | 744 | h | C | Kodgen/Include/Kodgen/InfoStructures/EnumValueInfo.h | jsoysouvanh/Kodgen | bd6892b3578229652120d30abb96cd12444f72bb | [
"MIT"
] | 19 | 2020-08-07T05:50:09.000Z | 2022-03-27T18:44:46.000Z | Kodgen/Include/Kodgen/InfoStructures/EnumValueInfo.h | Angelysse/Kodgen | a647bc1e552e8e57db4e60de77c853379e4ca4d8 | [
"MIT"
] | 2 | 2021-11-19T05:44:16.000Z | 2022-03-27T22:43:30.000Z | Kodgen/Include/Kodgen/InfoStructures/EnumValueInfo.h | Angelysse/Kodgen | a647bc1e552e8e57db4e60de77c853379e4ca4d8 | [
"MIT"
] | 2 | 2020-06-12T17:26:42.000Z | 2021-12-01T07:07:50.000Z | /**
* Copyright (c) 2020 Julien SOYSOUVANH - All Rights Reserved
*
* This file is part of the Kodgen library project which is released under the MIT License.
* See the LICENSE.md file for full license details.
*/
#pragma once
#include <vector>
#include <clang-c/Index.h>
#include "Kodgen/InfoStructures/EntityInfo.h"
#include "Kodgen/Misc/FundamentalTypes.h"
namespace kodgen
{
class EnumValueInfo final : public EntityInfo
{
public:
static constexpr EEntityType nestedEntityTypes = EEntityType::Undefined;
/** Default integer value for this enum value. */
int64 value = 0;
EnumValueInfo() = default;
EnumValueInfo(CXCursor const& cursor,
std::vector<Property>&& properties) noexcept;
};
} | 24 | 90 | 0.711022 | [
"vector"
] |
7aa4b5887d6b8ac6b211e92816ee931bd7f15f28 | 10,677 | c | C | libwapiti/src/api.c | adsva/python-wapiti | 518736e35895191952d6db622788a259695cf7f7 | [
"MIT"
] | 47 | 2015-05-10T16:01:03.000Z | 2021-07-24T10:24:19.000Z | libwapiti/src/api.c | adsva/python-wapiti | 518736e35895191952d6db622788a259695cf7f7 | [
"MIT"
] | 3 | 2015-04-27T17:51:23.000Z | 2019-12-10T19:59:07.000Z | libwapiti/src/api.c | adsva/python-wapiti | 518736e35895191952d6db622788a259695cf7f7 | [
"MIT"
] | 21 | 2015-03-30T09:34:43.000Z | 2020-11-09T01:01:23.000Z | #include <ctype.h>
#include <float.h>
#include <stddef.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <inttypes.h>
#include "wapiti.h"
#include "gradient.h"
#include "model.h"
#include "quark.h"
#include "reader.h"
#include "sequence.h"
#include "thread.h"
#include "tools.h"
#include "decoder.h"
#include "api.h"
#include "progress.h"
#include "trainers.h"
/* Converts a BIO-formatted string to a raw sequence type */
static raw_t *api_str2raw(char *seq) {
int size = 32; // Initial number of lines in raw_t
int cnt = 0;
char *line;
char *tmp_seq = xstrdup(seq);
raw_t *raw = xmalloc(sizeof(raw_t) + sizeof(char *) * size);
for (line = strtok(tmp_seq, "\n") ; line ; line = strtok(NULL, "\n")) {
// Make sure there's room and add the line
if (cnt == size) {
size *= 1.4;
raw = xrealloc(raw, sizeof(raw_t) + sizeof(char *) * size);
}
raw->lines[cnt++] = xstrdup(line);
}
raw = xrealloc(raw, sizeof(raw_t) + sizeof(char *) * cnt);
raw->len = cnt;
free(tmp_seq);
return raw;
}
/*
* Redeclarations of necessary unexported wapiti data
*/
/* Default training algorithm */
static void trn_auto(mdl_t *mdl) {
const int maxiter = mdl->opt->maxiter;
mdl->opt->maxiter = 3;
trn_sgdl1(mdl);
mdl->opt->maxiter = maxiter;
trn_lbfgs(mdl);
}
/* Available model types*/
static const char *typ_lst[] = {
"maxent",
"memm",
"crf"
};
static const uint32_t typ_cnt = sizeof(typ_lst) / sizeof(typ_lst[0]);
/* Available training algorithms*/
static const struct {
char *name;
void (* train)(mdl_t *mdl);
} trn_lst[] = {
{"l-bfgs", trn_lbfgs},
{"sgd-l1", trn_sgdl1},
{"bcd", trn_bcd },
{"rprop", trn_rprop},
{"rprop+", trn_rprop},
{"rprop-", trn_rprop},
{"auto", trn_auto }
};
static const int trn_cnt = sizeof(trn_lst) / sizeof(trn_lst[0]);
/* Initializes model */
mdl_t *api_new_model(opt_t *options, char *patterns) {
mdl_t *mdl = mdl_new(rdr_new(options->maxent));
mdl->opt = options;
// Make sure the selected model type is valid
uint32_t typ;
for (typ = 0; typ < typ_cnt; typ++)
if (!strcmp(mdl->opt->type, typ_lst[typ]))
break;
if (typ == typ_cnt)
fatal("unknown model type '%s'", mdl->opt->type);
mdl->type = typ;
// Load patterns from a string
if (patterns != NULL) {
api_load_patterns(mdl, patterns);
}
// Initialize training data
dat_t *dat = xmalloc(sizeof(dat_t));
dat->nseq = 0;
dat->mlen = 0;
dat->lbl = true;
dat->seq = NULL;
mdl->train = dat;
return mdl;
}
/* Initializes a model and loads data from model file */
mdl_t *api_load_model(char *filename, opt_t *options) {
mdl_t *mdl = api_new_model(options, NULL);
FILE *file = fopen(filename, "r");
if (file == NULL)
pfatal("cannot open input model file: %s", filename);
mdl_load(mdl, file);
fclose(file);
return mdl;
}
/*
* Splits a raw BIO-formatted string into lines, annotates them and
* returns a column of labels. If the input flag is true the input
* columns are also included in the output string.
*/
char *api_label_seq(mdl_t *mdl, char *lines, bool input, double *scs) {
size_t outsize = 0;
// If the output string should contain the input,
// it needs to be at least that big
if (input) {
outsize += strlen(lines);
}
qrk_t *lbls = mdl->reader->lbl;
raw_t *raw = api_str2raw(lines);
seq_t *seq = rdr_raw2seq(mdl->reader, raw, mdl->opt->check);
const int T = seq->len;
// When empty sequence is passed, return an empty string as response:
// subsequent mallocs will fail otherwise because of zero T.
if (!T) {
rdr_freeraw(raw);
rdr_freeseq(seq);
return xstrdup("");
}
const uint32_t N = mdl->opt->nbest;
uint32_t *out = xmalloc(sizeof(uint32_t) * T * N);
double *psc = xmalloc(sizeof(double) * T * N);
if(N == 1)
tag_viterbi(mdl, seq, out, scs, psc);
else
tag_nbviterbi(mdl, seq, N, out, scs, psc);
// Allocate some intial memory for the output string.
outsize += 5 * T * N;
char *lblseq = xmalloc(outsize);
const char *lblstr;
size_t rowsize;
size_t pos = 0;
// Build the output string
for (uint32_t n = 0; n < N; n++) {
for (int t = 0; t < T; t++) {
lblstr = qrk_id2str(lbls, out[t * N + n]);
// Size: label + \n + \0
rowsize = strlen(lblstr) + 2;
if (input) {
// Add: input line + \t
rowsize += strlen(raw->lines[t]) + 1;
}
if (pos+rowsize > outsize) {
outsize += rowsize * ((T - t) * (N - n));
lblseq = xrealloc(lblseq, outsize);
}
if (input) {
pos += snprintf(lblseq+pos, outsize-pos, "%s\t", raw->lines[t]);
}
pos += snprintf(lblseq+pos, outsize-pos, "%s\n", lblstr);
}
if(N > 1 && n < N - 1){
pos += snprintf(lblseq+pos, outsize-pos, "\n");
}
}
// Reallocate the final string to save memory
lblseq = xrealloc(lblseq, pos+1);
// Terminate the output string
lblseq[pos] = '\0';
// Free memory used for this sequence
free(psc);
free(out);
rdr_freeraw(raw);
rdr_freeseq(seq);
return lblseq;
}
/* Compiles lines of patterns and stores them in the model */
void api_load_patterns(mdl_t *mdl, char *lines) {
rdr_t *rdr = mdl->reader;
for (char *line = strtok(lines, "\n") ; line ; line = strtok(NULL, "\n")) {
// Remove comments and trailing spaces
int end = strcspn(line, "#");
while (end != 0 && isspace(line[end - 1]))
end--;
if (end == 0)
continue;
line[end] = '\0';
line[0] = tolower(line[0]);
// Avoid messing with the original pattern string
char *patstr = xstrdup(line);
// Compile pattern and add it to the list
pat_t *pat = pat_comp(patstr);
rdr->npats++;
switch (line[0]) {
case 'u': rdr->nuni++; break;
case 'b': rdr->nbi++; break;
case '*': rdr->nuni++;
rdr->nbi++; break;
default:
fatal("unknown pattern type '%c'", line[0]);
}
rdr->pats = xrealloc(rdr->pats, sizeof(char *) * rdr->npats);
rdr->pats[rdr->npats - 1] = pat;
rdr->ntoks = max(rdr->ntoks, pat->ntoks);
}
}
/* Adds a sequence of BIO-formatted training data to the model. */
void api_add_train_seq(mdl_t *mdl, char *lines) {
dat_t *dat = mdl->train;
raw_t *raw = api_str2raw(lines);
seq_t *seq = rdr_raw2seq(mdl->reader, raw, true);
// Make room
dat->seq = xrealloc(dat->seq, sizeof(seq_t *) * (dat->nseq + 1));
// And store the sequence
dat->seq[dat->nseq++] = seq;
dat->mlen = max(dat->mlen, seq->len);
}
/* Trains the model on loaded training data. */
void api_train(mdl_t *mdl) {
// Get the training method
int trn;
for (trn = 0; trn < trn_cnt; trn++)
if (!strcmp(mdl->opt->algo, trn_lst[trn].name))
break;
if (trn == trn_cnt)
fatal("unknown algorithm '%s'", mdl->opt->algo);
mdl_sync(mdl); // Finalize model structure for training
uit_setup(mdl); // Setup signal handling to abort training
trn_lst[trn].train(mdl);
uit_cleanup(mdl);
}
/* Saves the model to a file. */
void api_save_model(mdl_t *mdl, char *filename) {
// If requested compact the model.
if (mdl->opt->compact) {
const uint64_t O = mdl->nobs;
const uint64_t F = mdl->nftr;
info("* Compacting the model\n");
mdl_compact(mdl);
info(" %8"PRIu64" observations removed\n", O - mdl->nobs);
info(" %8"PRIu64" features removed\n", F - mdl->nftr);
}
FILE *file = fopen(filename, "w");
if (file == NULL)
pfatal("cannot open output model file: %s", filename);
mdl_save(mdl, file);
fclose(file);
}
/* Frees all memory used by the model. */
void api_free_model(mdl_t *mdl) {
mdl_free(mdl);
}
/* Silly tricks to wrap wapiti's logging/error calls.
*
* The Makefile uses the --wrap linker flag to route wapiti's logging
* and error function calls to the corresponding __wrap_-fuctions.
*
* To make it easier to hook in custom logging functions, the wrapped
* functions in turn call the corresponding functions in the logs
* array with the log messag as a string. To customize the
* info-logger, for example, simply assign logs[INFO] a pointer to
* your logging function.
*
*/
/* These are the default logging functions */
void inf_log(char *msg) {
fprintf(stdout, "%s", msg);
}
void wrn_log(char *msg) {
fprintf(stderr, "wrn: %s\n", msg);
}
void err_log(char *msg) {
fprintf(stderr, "err: %s\n", msg);
exit(EXIT_FAILURE);
}
/*
* The 4 logging levels. FATAL and PFATAL are actually more like final
* words and and not logging. See wapiti src for more info.
*/
enum loglvl {
FATAL,
PFATAL,
WARNING,
INFO
};
/* Customize by replacing with logging function pointers */
void (* api_logs[4])(char *msg) = {
err_log,
err_log,
wrn_log,
inf_log
};
/*
* Too avoid bloating this with clever allocation logic, log messages
* are truncated to 1400 chars. Look, it's 10 tweets!
*/
const int MAXLOGMSG = 1400;
char *OOMMSG = "out of memory\n";
/*
* After fatal log messages the program state should be considered
* unknown and no resources are freed. The only reason these wrappers
* don't call exit is to allow custom error handlers to quit on their
* own terms.
*/
void __wrap_fatal(const char *msg, ...) {
va_list args;
char *message = malloc(MAXLOGMSG);
if (message == NULL) {
message = OOMMSG;
} else {
va_start(args, msg);
vsnprintf(message, MAXLOGMSG, msg, args);
va_end(args);
}
api_logs[FATAL](message);
}
void __wrap_pfatal(const char *msg, ...) {
va_list args;
const char *err = strerror(errno);
char *message = malloc(MAXLOGMSG + strlen(err) + 4);
if (message == NULL) {
message = OOMMSG;
} else {
va_start(args, msg);
vsnprintf(message, MAXLOGMSG, msg, args);
va_end(args);
size_t msglen = strlen(message);
snprintf(message+msglen, MAXLOGMSG-msglen, " <%s>", err);
}
api_logs[PFATAL](message);
}
/*
* Non-fatal log functions don't need to stop execution, and the error
* message will be freed after the logs-call
*/
void __wrap_warning(const char *msg, ...) {
va_list args;
char *message = malloc(MAXLOGMSG);
if (message == NULL) {
message = OOMMSG;
} else {
va_start(args, msg);
vsnprintf(message, MAXLOGMSG, msg, args);
va_end(args);
}
api_logs[WARNING](message);
free(message);
}
void __wrap_info(const char *msg, ...) {
va_list args;
char *message = malloc(MAXLOGMSG);
if (message == NULL) {
message = OOMMSG;
} else {
va_start(args, msg);
vsnprintf(message, MAXLOGMSG, msg, args);
va_end(args);
}
api_logs[INFO](message);
free(message);
}
| 25.915049 | 77 | 0.625176 | [
"model"
] |
7aa73a10bd66e6245d906f2cdaadb95101bcf276 | 704 | h | C | network/HttpServer/Request.h | highinit/hiaux | 39af5d9572ab4a16177fa31756cc0e0369090a3e | [
"BSD-2-Clause"
] | null | null | null | network/HttpServer/Request.h | highinit/hiaux | 39af5d9572ab4a16177fa31756cc0e0369090a3e | [
"BSD-2-Clause"
] | null | null | null | network/HttpServer/Request.h | highinit/hiaux | 39af5d9572ab4a16177fa31756cc0e0369090a3e | [
"BSD-2-Clause"
] | null | null | null | #ifndef _REQUEST_H_
#define _REQUEST_H_
#include "hiconfig.h"
#include <boost/shared_ptr.hpp>
#include "hiaux/structs/hashtable.h"
#include "hiaux/strings/string_utils.h"
namespace hiaux {
class HttpRequest {
public:
std::string url;
std::string path;
std::map<std::string, std::string> headers;
std::map<std::string, std::string> values_GET;
std::map<std::string, std::string> cookies;
std::string body;
//std::vector<> attachments;
HttpRequest() { }
HttpRequest(const std::string &_url);
bool getField(const std::string &_key, std::string &_value);
bool getCookie(const std::string &_name, std::string &_value);
};
typedef boost::shared_ptr<HttpRequest> HttpRequestPtr;
}
#endif
| 20.705882 | 63 | 0.724432 | [
"vector"
] |
7aa8e671318fc371ce8f52ac22cf082c8dedba2b | 2,129 | h | C | includes/Atlas/Core/LocalSpace.h | Uedaki/Atlas | 32960472d369dffbf4fa44eae5ba7a2dec4ceae1 | [
"MIT"
] | null | null | null | includes/Atlas/Core/LocalSpace.h | Uedaki/Atlas | 32960472d369dffbf4fa44eae5ba7a2dec4ceae1 | [
"MIT"
] | 12 | 2021-04-20T15:09:43.000Z | 2021-06-15T20:44:10.000Z | includes/Atlas/Core/LocalSpace.h | Uedaki/Atlas | 32960472d369dffbf4fa44eae5ba7a2dec4ceae1 | [
"MIT"
] | null | null | null | #pragma once
#include "Atlas/Atlas.h"
#include "Atlas/Core/Geometry.h"
#include "Atlas/Core/Vectors.h"
namespace atlas
{
namespace ls // Local Space
{
static constexpr Normal normal() { return Normal(0, 0, 1); }
template <typename Real>
inline bool sameHemisphere(const Vector3<Real> &w, const Vector3<Real> &x) { return w.z * x.z > 0; }
template <typename Real>
inline Real phi(const Vector3<Real> &w) { return Atan2(w.y, w.x); }
template <typename Real>
inline Real theta(const Vector3<Real> &w) { return acos(clamp<Real>(w.z, -1, 1)); }
template <typename Real>
inline Real sinThetaCosPhi(const Vector3<Real> &w) { return w.x; }
template <typename Real>
inline Real sinThetaSinPhi(const Vector3<Real> &w) { return w.y; }
template <typename Real>
inline Real cosTheta(const Vector3<Real> &w) { return w.z; }
template <typename Real>
inline Real sin2ThetaCos2Phi(const Vector3<Real> &w) { return w.x * w.x; }
template <typename Real>
inline Real sin2ThetaSin2Phi(const Vector3<Real> &w) { return w.y * w.y; }
template <typename Real>
inline Real cos2Theta(const Vector3<Real> &w) { return w.z * w.z; }
template <typename Real>
inline Real absCosTheta(const Vector3<Real> &w) { return abs(w.z); }
template <typename Real>
inline Real sin2Theta(const Vector3<Real> &w) { return std::max(Real(0), Real(1) - cos2Theta(w)); }
template <typename Real>
inline Real sinTheta(const Vector3<Real> &w) { return sqrt(sin2Theta(w)); }
template <typename Real>
inline Real tanTheta(const Vector3<Real> &w) { return sinTheta(w) / cosTheta(w); }
template <typename Real>
inline Real tan2Theta(const Vector3<Real> &w) { return sin2Theta(w) / cos2Theta(w); }
inline bool refract(const Vec3f& wi, Float eta, Vec3f& wt)
{
Float cosThetaI = ls::cosTheta(wi);
Float sin2ThetaI = ls::sin2Theta(wi);
Float sin2ThetaT = eta * eta * sin2ThetaI;
Float cosThetaT = std::sqrt(1 - sin2ThetaT);
wt = eta * -wi + (eta * cosThetaI - cosThetaT) * faceForward(ls::normal(), wi);
return true;
}
}
} | 32.753846 | 103 | 0.661813 | [
"geometry"
] |
7aabd19ae156f54dab034b2e84f3efb1167943e9 | 7,045 | h | C | population/population_unit.h | Andrettin/Metternich | 513a7d3cddacad5d5efd2fa5faeed03bc55a190c | [
"MIT"
] | 12 | 2019-08-03T05:58:12.000Z | 2022-01-20T20:46:41.000Z | population/population_unit.h | Andrettin/Metternich | 513a7d3cddacad5d5efd2fa5faeed03bc55a190c | [
"MIT"
] | 6 | 2019-08-03T11:46:49.000Z | 2022-01-22T10:20:32.000Z | population/population_unit.h | Andrettin/Metternich | 513a7d3cddacad5d5efd2fa5faeed03bc55a190c | [
"MIT"
] | null | null | null | #pragma once
#include "population/population_unit_base.h"
#include "database/simple_data_type.h"
#include <set>
namespace metternich {
class culture;
class employment;
class holding;
class phenotype;
class population_type;
class province;
class religion;
class terrain_type;
class population_unit final : public population_unit_base, public simple_data_type<population_unit>
{
Q_OBJECT
Q_PROPERTY(metternich::population_type* type READ get_type WRITE set_type NOTIFY type_changed)
Q_PROPERTY(metternich::culture* culture READ get_culture WRITE set_culture NOTIFY culture_changed)
Q_PROPERTY(metternich::religion* religion READ get_religion WRITE set_religion NOTIFY religion_changed)
Q_PROPERTY(metternich::phenotype* phenotype READ get_phenotype WRITE set_phenotype NOTIFY phenotype_changed)
Q_PROPERTY(metternich::holding* holding READ get_holding WRITE set_holding NOTIFY holding_changed)
Q_PROPERTY(int unemployed_size READ get_unemployed_size NOTIFY unemployed_size_changed)
Q_PROPERTY(int wealth READ get_wealth NOTIFY wealth_changed)
Q_PROPERTY(bool discount_any_type READ discounts_any_type WRITE set_discount_any_type NOTIFY discount_types_changed)
Q_PROPERTY(QVariantList discount_types READ get_discount_types_qvariant_list NOTIFY discount_types_changed)
public:
static constexpr const char *database_folder = "population_units";
static constexpr int mixing_factor_permyriad = 1; //up to this fraction of people will "mix" per month per mixing check
static void process_history_database();
population_unit(population_type *type) : type(type)
{
connect(this, &population_unit::type_changed, this, &population_unit_base::icon_path_changed);
connect(this, &population_unit::culture_changed, this, &population_unit_base::icon_path_changed);
connect(this, &population_unit::religion_changed, this, &population_unit_base::icon_path_changed);
connect(this, &population_unit::phenotype_changed, this, &population_unit_base::icon_path_changed);
}
virtual ~population_unit() override
{
}
virtual void initialize_history() override;
virtual void check_history() const override
{
if (this->get_culture() == nullptr) {
throw std::runtime_error("Population unit has no culture.");
}
if (this->get_religion() == nullptr) {
throw std::runtime_error("Population unit has no religion.");
}
if (this->get_phenotype() == nullptr) {
throw std::runtime_error("Population unit has no phenotype.");
}
}
void do_month();
void do_mixing();
void do_cultural_derivation();
std::vector<std::vector<std::string>> get_tag_suffix_list_with_fallbacks() const;
population_type *get_type() const
{
return this->type;
}
void set_type(population_type *type)
{
if (type == this->get_type()) {
return;
}
this->type = type;
emit type_changed();
}
metternich::culture *get_culture() const
{
return this->culture;
}
void set_culture(culture *culture);
metternich::religion *get_religion() const
{
return this->religion;
}
void set_religion(religion *religion)
{
if (religion == this->get_religion()) {
return;
}
this->religion = religion;
emit religion_changed();
}
metternich::phenotype *get_phenotype() const
{
return this->phenotype;
}
void set_phenotype(phenotype *phenotype)
{
if (phenotype == this->get_phenotype()) {
return;
}
this->phenotype = phenotype;
emit phenotype_changed();
}
void mix_with(population_unit *other_population_unit);
virtual void set_size(const int size) override;
metternich::holding *get_holding() const
{
return this->holding;
}
void set_holding(holding *holding);
virtual void set_discount_existing(const bool discount_existing) override
{
if (discount_existing == this->discounts_existing()) {
return;
}
if (discount_existing) {
this->discount_types.insert(this->get_type()); //this population unit's type is implicitly added to the discount types if discount_existing is set to true
} else {
//if is being set to false, set the discount_any_type to false as well, and clear the discount types, as both are no longer applicable
this->discount_types.clear();
}
population_unit_base::set_discount_existing(discount_existing);
}
bool discounts_any_type() const;
void set_discount_any_type(const bool discount_any_type);
const std::set<population_type *> &get_discount_types() const
{
return this->discount_types;
}
QVariantList get_discount_types_qvariant_list() const;
Q_INVOKABLE void add_discount_type(population_type *type)
{
this->discount_types.insert(type);
emit discount_types_changed();
}
Q_INVOKABLE void remove_discount_type(population_type *type)
{
this->discount_types.erase(type);
emit discount_types_changed();
}
void subtract_existing_sizes();
void subtract_existing_sizes_in_holding(const holding *holding);
void subtract_existing_sizes_in_holdings(const std::vector<holding *> &holdings);
bool can_distribute_to_holding(const holding *holding) const;
void distribute_to_holdings(const std::vector<holding *> &holdings);
int get_unemployed_size() const
{
return this->unemployed_size;
}
void set_unemployed_size(const int size)
{
if (size == this->get_unemployed_size()) {
return;
}
this->unemployed_size = size;
emit unemployed_size_changed();
}
void change_unemployed_size(const int change)
{
this->set_unemployed_size(this->get_unemployed_size() + change);
}
void add_employment(employment *employment)
{
this->employments.insert(employment);
}
void remove_employment(employment *employment)
{
this->employments.erase(employment);
}
void seek_employment();
int get_wealth() const
{
return this->wealth;
}
void set_wealth(const int wealth)
{
if (wealth == this->get_wealth()) {
return;
}
this->wealth = wealth;
emit wealth_changed();
}
void change_wealth(const int change)
{
this->set_wealth(this->get_wealth() + change);
}
virtual const std::filesystem::path &get_icon_path() const override;
const terrain_type *get_terrain() const;
signals:
void type_changed();
void culture_changed();
void religion_changed();
void phenotype_changed();
void holding_changed();
void terrain_changed();
void discount_types_changed();
void unemployed_size_changed();
void wealth_changed();
private:
population_type *type = nullptr;
metternich::culture *culture = nullptr;
metternich::religion *religion = nullptr;
metternich::phenotype *phenotype = nullptr;
metternich::holding *holding = nullptr; //the settlement holding where this population unit lives
bool discount_any_type = false; //whether to discount the size of any existing population units from that of this one
std::set<population_type *> discount_types; //the sizes of population units belonging to these types will be discounted from that of this population unit
std::set<employment *> employments;
int unemployed_size = 0; //the amount of people from this population unit which are unemployed
int wealth = 0; //the wealth belonging to the population unit
};
}
| 26.889313 | 157 | 0.76494 | [
"vector"
] |
7ab62057cc3b4cf74f82330ed4998e0aba0a696f | 2,701 | h | C | src/test/util/FCString.h | andreapiacentini/oops | 48c923c210a75773e2457eea8b1a8eee29837bb5 | [
"Apache-2.0"
] | 2 | 2021-03-10T18:33:19.000Z | 2022-01-05T08:37:31.000Z | src/test/util/FCString.h | andreapiacentini/oops | 48c923c210a75773e2457eea8b1a8eee29837bb5 | [
"Apache-2.0"
] | 3 | 2020-10-30T21:38:31.000Z | 2020-11-02T18:14:29.000Z | src/test/util/FCString.h | andreapiacentini/oops | 48c923c210a75773e2457eea8b1a8eee29837bb5 | [
"Apache-2.0"
] | 6 | 2017-08-03T23:36:57.000Z | 2017-09-15T15:14:17.000Z | /*
* (C) Copyright 2019 UCAR
*
* This software is licensed under the terms of the Apache Licence Version 2.0
* which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
*
*/
#ifndef TEST_UTIL_FCSTRING_H_
#define TEST_UTIL_FCSTRING_H_
#include <cmath>
#include <iostream>
#include <limits>
#include <memory>
#include <string>
#include <vector>
#define ECKIT_TESTING_SELF_REGISTER_CASES 0
#include <boost/noncopyable.hpp>
#include "eckit/config/LocalConfiguration.h"
#include "eckit/testing/Test.h"
#include "oops/runs/Test.h"
#include "oops/util/Logger.h"
#include "oops/util/Random.h"
#include "test/TestEnvironment.h"
#include "test/util/Fortran.h"
namespace test {
// -----------------------------------------------------------------------------
/*! Test Fixture for Fortran-C Interface Tools */
class FCStringFixture : private boost::noncopyable {
public:
static const eckit::Configuration & test() {return *getInstance().test_;}
private:
static FCStringFixture & getInstance() {
static FCStringFixture theFCStringFixture;
return theFCStringFixture;
}
FCStringFixture() {
test_.reset(new eckit::LocalConfiguration(TestEnvironment::config(), "test_f_c_string"));
}
~FCStringFixture() {}
std::unique_ptr<const eckit::LocalConfiguration> test_;
};
// -----------------------------------------------------------------------------
/*! Test transfer of string array from Fortran to C++
*
* \details This is intended to test the **f_c_push_string_vector()** utility
* for passing a string vector from Fortran to C++
*
*/
void testPushStringVector() {
typedef FCStringFixture Test_;
const eckit::Configuration * config = &Test_::test();
std::vector<std::string> vec;
test_push_string_vector_f(&config, vec);
// retrieve directly from config file for comparison
std::vector<std::string> vec_check(config->getStringVector("string_vec"));
EXPECT(vec.size() == vec_check.size());
for (std::size_t jj = 0; jj < vec_check.size(); ++jj) {
EXPECT(vec[jj] == vec_check[jj]);
}
}
// -----------------------------------------------------------------------------
class FCString : public oops::Test {
public:
FCString() {}
virtual ~FCString() {}
private:
std::string testid() const override {return "test::FCString";}
void register_tests() const override {
std::vector<eckit::testing::Test>& ts = eckit::testing::specification();
ts.emplace_back(CASE("util/FCString/testPushStringVector")
{ testPushStringVector(); });
}
void clear() const override {}
};
// -----------------------------------------------------------------------------
} // namespace test
#endif // TEST_UTIL_FCSTRING_H_
| 25.72381 | 93 | 0.626805 | [
"vector"
] |
7acfcbb6262575df513d596df12be7376e700f64 | 5,312 | h | C | src/modules/system/network-stack/Ipv4.h | jmolloy/pedigree | 4f02647d8237cc19cff3c20584c0fdd27b14a7d4 | [
"0BSD"
] | 37 | 2015-01-11T20:08:48.000Z | 2022-01-06T17:25:22.000Z | src/modules/system/network-stack/Ipv4.h | jmolloy/pedigree | 4f02647d8237cc19cff3c20584c0fdd27b14a7d4 | [
"0BSD"
] | 4 | 2016-05-20T01:01:59.000Z | 2016-06-22T00:03:27.000Z | src/modules/system/network-stack/Ipv4.h | jmolloy/pedigree | 4f02647d8237cc19cff3c20584c0fdd27b14a7d4 | [
"0BSD"
] | 6 | 2015-09-14T14:44:20.000Z | 2019-01-11T09:52:21.000Z | /*
* Copyright (c) 2008 James Molloy, Jörg Pfähler, Matthew Iselin
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#ifndef MACHINE_IPV4_H
#define MACHINE_IPV4_H
#include <utilities/String.h>
#include <utilities/Vector.h>
#include <processor/types.h>
#include <process/Semaphore.h>
#include <machine/Network.h>
#include <LockGuard.h>
#include <Spinlock.h>
#include "NetworkStack.h"
#include "Ethernet.h"
/// \todo Move to a proper utilities header, called RingBuffer or something
#include "TcpMisc.h"
#include "IpCommon.h"
#define IP_FLAG_RSVD (1 << 3)
/// If used, this specifies to software at each hop that the packet must not
/// be fragmented. This means it will drop packets that are too small for a
/// link's MTU, even if that link is between two hosts on the Internet.
#define IP_FLAG_DF (1 << 2)
/// More fragments flag: this means the packet is part of a set of packets
/// that are to be reassembled by the IPv4 code.
#define IP_FLAG_MF (1 << 1)
/**
* The Pedigree network stack - IPv4 layer
*/
class Ipv4 : public IpBase
{
public:
Ipv4();
virtual ~Ipv4();
/** For access to the stack without declaring an instance of it */
static Ipv4& instance()
{
return ipInstance;
}
/** Packet arrival callback */
void receive(size_t nBytes, uintptr_t packet, Network* pCard, uint32_t offset);
/** Sends an IP packet */
virtual bool send(IpAddress dest, IpAddress from, uint8_t type, size_t nBytes, uintptr_t packet, Network *pCard = 0);
/** Injects an IPv4 header into a given buffer and returns the size
* of the header. */
virtual size_t injectHeader(uintptr_t packet, IpAddress dest, IpAddress from, uint8_t type);
virtual void injectChecksumAndDataFields(uintptr_t ipv4HeaderStart, size_t payloadSize);
/**
* Calculates a checksum for an upper-layer protocol.
* Will return zero on an incoming packet with a non-zero checksum if the
* calculated checksum matches.
* @param length Length of data to checksum, in HOST byte order.
*/
virtual uint16_t ipChecksum(IpAddress &from, IpAddress &to, uint8_t proto, uintptr_t data, uint16_t length);
struct ipHeader
{
#ifdef LITTLE_ENDIAN
uint32_t header_len : 4;
uint32_t ipver : 4;
#else
uint32_t ipver : 4;
uint32_t header_len : 4;
#endif
uint8_t tos;
uint16_t len;
uint16_t id;
uint16_t frag_offset;
uint8_t ttl;
uint8_t type;
uint16_t checksum;
uint32_t ipSrc;
uint32_t ipDest;
} __attribute__ ((packed));
/** Gets the next IP Packet ID */
uint16_t getNextId()
{
LockGuard<Spinlock> guard(m_NextIdLock);
return m_IpId++;
}
private:
static Ipv4 ipInstance;
/// IPv4 psuedo-header for upper-layer checksums.
struct PsuedoHeader
{
uint32_t src_addr;
uint32_t dest_addr;
uint8_t zero;
uint8_t proto;
uint16_t datalen;
} __attribute__ ((packed));
/// An actual fragment
struct fragment
{
char *data;
size_t length;
};
/// Stores all the segments for an IPv4 fragmented packet.
/// In its own type so that it can be extended in the future as needed.
struct fragmentWrapper
{
/// Original IPv4 header to be applied to the packet during reassembly
char *originalIpHeader;
/// Original IPv4 header length
size_t originalIpHeaderLen;
/// Map of offsets to actual buffers
Tree<size_t, fragment *> fragments;
};
/// Identifies an IPv4 packet by linking the ID and IP together
class Ipv4Identifier
{
public:
Ipv4Identifier() : m_Id(0), m_Ip(IpAddress::IPv4)
{
}
Ipv4Identifier(uint16_t id, IpAddress ip) : m_Id(id), m_Ip(ip)
{
}
inline uint16_t getId()
{
return m_Id;
}
inline IpAddress &getIp()
{
return m_Ip;
}
inline bool operator < (Ipv4Identifier &a)
{
return (m_Id < a.m_Id);
}
inline bool operator > (Ipv4Identifier &a)
{
return (m_Id > a.m_Id);
}
inline bool operator == (Ipv4Identifier &a)
{
return ((m_Id == a.m_Id) && (m_Ip == a.m_Ip));
}
private:
/// ID for all ipv4 packets in this identification block
uint16_t m_Id;
/// The IP address the ID is linked to
IpAddress m_Ip;
};
/// Lock for the "Next ID" variable
Spinlock m_NextIdLock;
/// Next ID to use for an IPv4 packet
uint16_t m_IpId;
/// Maps IP packet IDs to fragment blocks
Tree<Ipv4Identifier, fragmentWrapper *> m_Fragments;
};
#endif
| 26.56 | 119 | 0.668298 | [
"vector"
] |
7ad477594b9deb295a3051b2d938553ad8e95999 | 2,383 | h | C | include/num_collect/logging/log_tag.h | MusicScience37/numerical-collection-cpp | 490c24aae735ba25f1060b2941cff39050a41f8f | [
"Apache-2.0"
] | null | null | null | include/num_collect/logging/log_tag.h | MusicScience37/numerical-collection-cpp | 490c24aae735ba25f1060b2941cff39050a41f8f | [
"Apache-2.0"
] | null | null | null | include/num_collect/logging/log_tag.h | MusicScience37/numerical-collection-cpp | 490c24aae735ba25f1060b2941cff39050a41f8f | [
"Apache-2.0"
] | null | null | null | /*
* Copyright 2022 MusicScience37 (Kenta Kabashima)
*
* 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.
*/
/*!
* \file
* \brief Definition of log_tag class.
*/
#pragma once
#include <compare>
#include <string>
#include <string_view>
#include "num_collect/util/hash_string.h"
namespace num_collect::logging {
/*!
* \brief Class of tags of logs.
*/
class log_tag {
public:
/*!
* \brief Constructor.
*
* \param[in] name Name of this tag.
*/
explicit log_tag(std::string_view name)
: name_(name), hash_(util::hash_string(name)) {}
/*!
* \brief Get the name of this tag.
*
* \return Name.
*/
[[nodiscard]] auto name() const noexcept -> const std::string& {
return name_;
}
/*!
* \brief Get the hash number of this tag.
*
* \return Hash number.
*/
[[nodiscard]] auto hash() const noexcept -> std::size_t { return hash_; }
/*!
* \brief Compare two tags.
*
* \param[in] right Right-hand-side object.
* \return Result.
*/
auto operator<=>(const log_tag& right) const noexcept
-> std::strong_ordering {
return this->name().compare(right.name()) <=> 0;
}
/*!
* \brief Compare two tags.
*
* \param[in] right Right-hand-side object.
* \return Result.
*/
auto operator==(const log_tag& right) const noexcept -> bool {
if (this->hash() != right.hash()) {
return false;
}
return this->name() == right.name();
}
/*!
* \brief Compare two tags.
*
* \param[in] right Right-hand-side object.
* \return Result.
*/
auto operator!=(const log_tag& right) const noexcept -> bool = default;
private:
//! Name.
std::string name_;
//! Hash number.
std::size_t hash_;
};
} // namespace num_collect::logging
| 23.83 | 77 | 0.60512 | [
"object"
] |
7ad59ec6045fc811931662daa572a730831f50ac | 19,283 | h | C | wutil/wutil.h | w1n5t0n99/wutil | 9b8b1aa829640fc0f67404ae33befafe96a174d3 | [
"MIT"
] | null | null | null | wutil/wutil.h | w1n5t0n99/wutil | 9b8b1aa829640fc0f67404ae33befafe96a174d3 | [
"MIT"
] | null | null | null | wutil/wutil.h | w1n5t0n99/wutil | 9b8b1aa829640fc0f67404ae33befafe96a174d3 | [
"MIT"
] | null | null | null | #ifndef WUTIL_INCLUDED
#define WUTIL_INCLUDED
#include <optional>
#if defined(WIN32) || defined(_WIN32) || defined(_WIN64)
#define OS_WIN
#else
#error "No Windows OS macro defined"
#endif
#ifdef OS_WIN
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#include <Windows.h>
#include <windef.h>
#include <ShellScalingApi.h>
#if !defined(DPI_AWARENESS_CONTEXT_UNAWARE)
DECLARE_HANDLE(DPI_AWARENESS_CONTEXT);
typedef enum DPI_AWARENESS {
DPI_AWARENESS_INVALID = -1,
DPI_AWARENESS_UNAWARE = 0,
DPI_AWARENESS_SYSTEM_AWARE = 1,
DPI_AWARENESS_PER_MONITOR_AWARE = 2
} DPI_AWARENESS;
#define DPI_AWARENESS_CONTEXT_UNAWARE ((DPI_AWARENESS_CONTEXT)-1)
#define DPI_AWARENESS_CONTEXT_SYSTEM_AWARE ((DPI_AWARENESS_CONTEXT)-2)
#define DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE ((DPI_AWARENESS_CONTEXT)-3)
#endif
#ifndef WM_DPICHANGED
#define WM_DPICHANGED 0x02E0
#endif
#ifndef SPI_GETICONTITLELOGFONT
#define SPI_GETICONTITLELOGFONT 0x001F
#endif
#ifndef SPI_GETICONMETRICS
#define SPI_GETICONMETRICS 0x002D
#endif
#ifndef SPI_GETNONCLIENTMETRICS
#define SPI_GETNONCLIENTMETRICS 0x0029
#endif
#ifndef DPI_ENUMS_DECLARED
#define DPI_ENUMS_DECLARED
typedef enum PROCESS_DPI_AWARENESS {
PROCESS_DPI_UNAWARE = 0,
PROCESS_SYSTEM_DPI_AWARE = 1,
PROCESS_PER_MONITOR_DPI_AWARE = 2
} PROCESS_DPI_AWARENESS;
typedef enum MONITOR_DPI_TYPE {
MDT_EFFECTIVE_DPI = 0,
MDT_ANGULAR_DPI = 1,
MDT_RAW_DPI = 2,
MDT_DEFAULT = MDT_EFFECTIVE_DPI
} MONITOR_DPI_TYPE;
#endif
#endif
#include <vector>
#include <string>
#include <sstream>
namespace wutil
{
namespace detail
{
typedef DPI_AWARENESS_CONTEXT(WINAPI * SetThreadDpiAwarenessContextProc)(DPI_AWARENESS_CONTEXT);
typedef DPI_AWARENESS_CONTEXT(WINAPI * GetThreadDpiAwarenessContextProc)();
typedef BOOL(WINAPI * EnableNonClientDpiScalingProc)(HWND);
typedef UINT(WINAPI * GetDpiForWindowProc)(HWND);
typedef BOOL(WINAPI * AreDpiAwarenessContextsEqualProc)(DPI_AWARENESS_CONTEXT, DPI_AWARENESS_CONTEXT);
typedef BOOL(WINAPI * SystemParametersInfoForDpiProc)(UINT, UINT, PVOID, UINT, UINT);
typedef HRESULT(WINAPI * SetProcessDpiAwarenessProc)(PROCESS_DPI_AWARENESS);
typedef HRESULT(WINAPI * GetProcessDpiAwarenessProc)(HANDLE, PROCESS_DPI_AWARENESS*);
typedef HRESULT(WINAPI * GetDpiForMonitorProc)(HMONITOR, MONITOR_DPI_TYPE, UINT*, UINT*);
// functions dependent on windows version may not be available
static SetThreadDpiAwarenessContextProc set_thread_dpi_awareness_context;
static GetThreadDpiAwarenessContextProc get_thread_dpi_awareness_context;
static EnableNonClientDpiScalingProc enable_nonclient_dpi_scaling;
static GetDpiForWindowProc get_dpi_for_window;
static AreDpiAwarenessContextsEqualProc are_dpi_awareness_contexts_equal;
static SystemParametersInfoForDpiProc system_parameters_info_for_dpi;
static SetProcessDpiAwarenessProc set_process_dpi_awareness;
static GetProcessDpiAwarenessProc get_process_dpi_awareness;
static GetDpiForMonitorProc get_dpi_for_monitor;
static const int Default_DPI = 96;
static const int SYMBOLS_NOT_LOADED = 0;
static const int SYMBOLS_LOADED_AND_FOUND = 1;
static const int SYMBOLS_LOADED_AND_NOT_FOUND = 2;
//=========================================================================
// dynamically load dpi functions to support older windows versions
//===========================================================================
int load_shcore_symbols()
{
static int symbol_status = SYMBOLS_NOT_LOADED;
if (symbol_status > SYMBOLS_NOT_LOADED)
return symbol_status;
HMODULE shcore = LoadLibrary(TEXT("Shcore"));
set_process_dpi_awareness = reinterpret_cast<detail::SetProcessDpiAwarenessProc>(GetProcAddress(shcore, "SetProcessDpiAwareness"));
get_process_dpi_awareness = reinterpret_cast<detail::GetProcessDpiAwarenessProc>(GetProcAddress(shcore, "GetProcessDpiAwareness"));
get_dpi_for_monitor = reinterpret_cast<detail::GetDpiForMonitorProc>(GetProcAddress(shcore, "GetDpiForMonitor"));
if (set_process_dpi_awareness)
symbol_status = SYMBOLS_LOADED_AND_FOUND;
else
symbol_status = SYMBOLS_LOADED_AND_NOT_FOUND;
return symbol_status;
}
int load_user32_symbols()
{
static int symbol_status = SYMBOLS_NOT_LOADED;
if (symbol_status > SYMBOLS_NOT_LOADED)
return symbol_status;
HMODULE user32 = LoadLibrary(TEXT("User32"));
set_thread_dpi_awareness_context = reinterpret_cast<detail::SetThreadDpiAwarenessContextProc>(GetProcAddress(user32, "SetThreadDpiAwarenessContext"));
get_thread_dpi_awareness_context = reinterpret_cast<detail::GetThreadDpiAwarenessContextProc>(GetProcAddress(user32, "GetThreadDpiAwarenessContext"));
enable_nonclient_dpi_scaling = reinterpret_cast<detail::EnableNonClientDpiScalingProc>(GetProcAddress(user32, "EnableNonClientDpiScaling"));
get_dpi_for_window = reinterpret_cast<detail::GetDpiForWindowProc>(GetProcAddress(user32, "GetDpiForWindow"));
are_dpi_awareness_contexts_equal = reinterpret_cast<detail::AreDpiAwarenessContextsEqualProc>(GetProcAddress(user32, "AreDpiAwarenessContextsEqual"));
system_parameters_info_for_dpi = reinterpret_cast<detail::SystemParametersInfoForDpiProc>(GetProcAddress(user32, "SystemParametersInfoForDpi"));
if (set_thread_dpi_awareness_context)
symbol_status = SYMBOLS_LOADED_AND_FOUND;
else
symbol_status = SYMBOLS_LOADED_AND_NOT_FOUND;
return symbol_status;
}
//======================================================
// win32 callback functions
//======================================================
BOOL CALLBACK monitor_info_enum_proc(HMONITOR hmonitor, HDC hdc_monitor, LPRECT lprc_monitor, LPARAM dw_data)
{
auto monitor_vec = reinterpret_cast<std::vector<MONITORINFOEX>*>(dw_data);
if (monitor_vec == nullptr)
return false;
MONITORINFOEX mi{};
mi.cbSize = sizeof(mi);
GetMonitorInfo(hmonitor, &mi);
monitor_vec->push_back(mi);
if (mi.dwFlags & MONITORINFOF_PRIMARY)
std::swap(monitor_vec->back(), monitor_vec->front());
return true;
}
}
using tstring = std::basic_string<TCHAR>;
using tstringstream = std::basic_stringstream<TCHAR>;
struct WindowInfo
{
WINDOWPLACEMENT placement = {};
RECT rect = {};
LONG style = 0;
LONG ex_style = 0;
};
//=============================================================================
// return container of all display devices, first item will be primary device
//=============================================================================
std::vector<DISPLAY_DEVICE> get_all_display_devices()
{
std::vector<DISPLAY_DEVICE> ddevs;
DISPLAY_DEVICE d;
d.cb = sizeof(d);
int device_num = 0;
while (EnumDisplayDevices(NULL, device_num, &d, 0))
{
ddevs.push_back(d);
++device_num;
if (d.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE)
std::swap(ddevs.back(), ddevs.front());
}
return ddevs;
}
//==========================================================================
// return container of all monitor info, first item will be primary monitor
//==========================================================================
std::vector<MONITORINFOEX> get_all_monitor_info()
{
std::vector<MONITORINFOEX> info_vec;
EnumDisplayMonitors(NULL, NULL, detail::monitor_info_enum_proc, reinterpret_cast<LPARAM>(&info_vec));
return info_vec;
}
//=============================================================
// return monitor info for given device name
//=============================================================
std::optional<MONITORINFOEX> get_monitor_info(const tstring& device_name)
{
std::vector<MONITORINFOEX> info_vec;
EnumDisplayMonitors(NULL, NULL, detail::monitor_info_enum_proc, reinterpret_cast<LPARAM>(&info_vec));
for (const auto& mi : info_vec)
{
if (device_name.compare(mi.szDevice) == 0)
return mi;
}
return {};
}
//==========================================================
// return container of all display settings for monitor,
// first item will be current display settings
//===========================================================
std::vector<DEVMODE> get_monitor_display_settings(const tstring& device_name)
{
DEVMODE dm;
dm.dmSize = sizeof(dm);
dm.dmDriverExtra = 0;
std::vector<DEVMODE> disp_vec;
int i = 0;
while (EnumDisplaySettingsEx(device_name.c_str(), i, &dm, 0))
{
disp_vec.push_back(dm);
++i;
}
EnumDisplaySettingsEx(device_name.c_str(), ENUM_CURRENT_SETTINGS, &dm, 0);
for (int i = 0; i < disp_vec.size(); ++i)
{
// orientation and position appear to only be set for ENUM_CURRENT_SETTINGS
if (disp_vec[i].dmBitsPerPel == dm.dmBitsPerPel &&
disp_vec[i].dmPelsWidth == dm.dmPelsWidth &&
disp_vec[i].dmPelsHeight == dm.dmPelsHeight &&
disp_vec[i].dmDisplayFlags == dm.dmDisplayFlags &&
//disp_vec[i].dmDisplayOrientation == dm.dmDisplayOrientation &&
//disp_vec[i].dmPosition.x == dm.dmPosition.x &&
//disp_vec[i].dmPosition.y == dm.dmPosition.y &&
disp_vec[i].dmDisplayFrequency == dm.dmDisplayFrequency)
{
std::swap(disp_vec[i], disp_vec[0]);
break;
}
}
return disp_vec;
}
//================================================================
// set window as fullscreen, change to monitor dimensions
//================================================================
std::optional<WindowInfo> set_window_fullscreen(HWND hwnd, const MONITORINFOEX& mi)
{
WindowInfo saved_window_info;
saved_window_info.style = GetWindowLong(hwnd, GWL_STYLE);
saved_window_info.ex_style = GetWindowLong(hwnd, GWL_EXSTYLE);
GetWindowPlacement(hwnd, &saved_window_info.placement);
GetWindowRect(hwnd, &saved_window_info.rect);
WINDOWPLACEMENT fullscreen_placement = saved_window_info.placement;
fullscreen_placement.showCmd = SW_SHOWNORMAL;
fullscreen_placement.rcNormalPosition = { mi.rcMonitor.left,
mi.rcMonitor.top,
mi.rcMonitor.right - mi.rcMonitor.left,
mi.rcMonitor.bottom - mi.rcMonitor.top };
LONG res = 0;
res += SetWindowLong(hwnd, GWL_STYLE, saved_window_info.style & ~(WS_CAPTION | WS_THICKFRAME));
res += SetWindowLong(hwnd, GWL_EXSTYLE, saved_window_info.ex_style & ~(WS_EX_DLGMODALFRAME |
WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE | WS_EX_STATICEDGE));
res += SetWindowPlacement(hwnd, &fullscreen_placement);
if (res == 0)
return {};
else
return saved_window_info;
}
//===================================================================
// set window as fullscreen, change to nearest monitor dimensions
//===================================================================
std::optional<WindowInfo> set_window_fullscreen(HWND hwnd)
{
WindowInfo saved_window_info;
saved_window_info.style = GetWindowLong(hwnd, GWL_STYLE);
saved_window_info.ex_style = GetWindowLong(hwnd, GWL_EXSTYLE);
GetWindowPlacement(hwnd, &saved_window_info.placement);
GetWindowRect(hwnd, &saved_window_info.rect);
MONITORINFOEX mi;
mi.cbSize = sizeof(mi);
auto hmonitor = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST);
if (GetMonitorInfo(hmonitor, &mi) == 0)
return {};
WINDOWPLACEMENT fullscreen_placement = saved_window_info.placement;
fullscreen_placement.showCmd = SW_SHOWNORMAL;
fullscreen_placement.rcNormalPosition = { mi.rcMonitor.left,
mi.rcMonitor.top,
mi.rcMonitor.right - mi.rcMonitor.left,
mi.rcMonitor.bottom - mi.rcMonitor.top };
LONG res = 0;
res += SetWindowLong(hwnd, GWL_STYLE, saved_window_info.style & ~(WS_CAPTION | WS_THICKFRAME));
res += SetWindowLong(hwnd, GWL_EXSTYLE, saved_window_info.ex_style & ~(WS_EX_DLGMODALFRAME |
WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE | WS_EX_STATICEDGE));
res += SetWindowPlacement(hwnd, &fullscreen_placement);
if (res == 0)
return {};
else
return saved_window_info;
}
//====================================================
// set window to given settings
//======================================================
bool set_window_to(HWND hwnd, const WindowInfo& wi)
{
LONG res = 0;
res += SetWindowLong(hwnd, GWL_STYLE, wi.style);
res += SetWindowLong(hwnd, GWL_EXSTYLE, wi.ex_style);
res += SetWindowPlacement(hwnd, &wi.placement);
if (res == 0)
return false;
else
return true;
}
//====================================================================
// change display settings, enable fullscreen flag
//====================================================================
std::optional<MONITORINFOEX> changes_display_settings_fullscreen(const tstring& device_name, DEVMODE& dev_mode)
{
auto res = ChangeDisplaySettingsEx(device_name.c_str(), &dev_mode, NULL, CDS_FULLSCREEN, NULL);
if (res == DISP_CHANGE_SUCCESSFUL)
return get_monitor_info(device_name);
else
return {};
}
//=====================================================
// reset display settings to previously saved
//======================================================
bool reset_display_settings_fullscreen(const tstring& device_name)
{
auto res = ChangeDisplaySettingsEx(device_name.c_str(), NULL, NULL, 0, NULL);
if (res == DISP_CHANGE_SUCCESSFUL)
return true;
else
return false;
}
//============================================
// get dpi from window
//===========================================
UINT get_dpi(HWND hwnd)
{
if (detail::load_user32_symbols() == detail::SYMBOLS_LOADED_AND_FOUND)
{
return detail::get_dpi_for_window(hwnd);
}
else if (detail::load_shcore_symbols() == detail::SYMBOLS_LOADED_AND_FOUND)
{
auto hmonitor = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST);
UINT dpi_x = 0, dpi_y = 0;
auto hr = detail::get_dpi_for_monitor(hmonitor, MDT_EFFECTIVE_DPI, &dpi_x, &dpi_y);
if (hr == S_OK)
return dpi_x;
else
return detail::Default_DPI;
}
else
return detail::Default_DPI;
}
//======================================
// get dpi from point
//=======================================
UINT get_dpi(const POINT& point)
{
if (detail::load_shcore_symbols() == detail::SYMBOLS_LOADED_AND_FOUND)
{
auto hmonitor = MonitorFromPoint(point, MONITOR_DEFAULTTONEAREST);
UINT dpi_x = 0, dpi_y = 0;
auto hr = detail::get_dpi_for_monitor(hmonitor, MDT_EFFECTIVE_DPI, &dpi_x, &dpi_y);
if (hr == S_OK)
return dpi_x;
else
return detail::Default_DPI;
}
else
return detail::Default_DPI;
}
//===============================================
// enable per monitor awareness
//================================================
bool enable_per_monitor_dpi_aware()
{
if (detail::load_user32_symbols() == detail::SYMBOLS_LOADED_AND_FOUND)
{
auto previous_context_ = detail::set_thread_dpi_awareness_context(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE);
auto current_context = detail::get_thread_dpi_awareness_context();
if (detail::are_dpi_awareness_contexts_equal(current_context, DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE))
return true;
else
return false;
}
else if (detail::load_shcore_symbols() == detail::SYMBOLS_LOADED_AND_FOUND)
{
auto result = detail::set_process_dpi_awareness(PROCESS_PER_MONITOR_DPI_AWARE);
PROCESS_DPI_AWARENESS current_awareness;
detail::get_process_dpi_awareness(NULL, ¤t_awareness);
if (current_awareness == PROCESS_PER_MONITOR_DPI_AWARE)
return true;
else
return false;
}
else
{
return false;
}
}
//================================================
// enable system awareness
//===============================================
bool enable_system_dpi_aware()
{
if (detail::load_user32_symbols() == detail::SYMBOLS_LOADED_AND_FOUND)
{
auto previous_context_ = detail::set_thread_dpi_awareness_context(DPI_AWARENESS_CONTEXT_SYSTEM_AWARE);
auto current_context = detail::get_thread_dpi_awareness_context();
if (detail::are_dpi_awareness_contexts_equal(current_context, DPI_AWARENESS_CONTEXT_SYSTEM_AWARE))
return true;
else
return false;
}
else if (detail::load_shcore_symbols() == detail::SYMBOLS_LOADED_AND_FOUND)
{
auto result = detail::set_process_dpi_awareness(PROCESS_SYSTEM_DPI_AWARE);
PROCESS_DPI_AWARENESS current_awareness;
detail::get_process_dpi_awareness(NULL, ¤t_awareness);
if (current_awareness == PROCESS_SYSTEM_DPI_AWARE)
return true;
else
return false;
}
else
{
return false;
}
}
//===========================================
// enable unaware
//==========================================
bool enable_dpi_unaware()
{
if (detail::load_user32_symbols() == detail::SYMBOLS_LOADED_AND_FOUND)
{
auto previous_context_ = detail::set_thread_dpi_awareness_context(DPI_AWARENESS_CONTEXT_UNAWARE);
auto current_context = detail::get_thread_dpi_awareness_context();
if (detail::are_dpi_awareness_contexts_equal(current_context, DPI_AWARENESS_CONTEXT_UNAWARE))
return true;
else
return false;
}
else if (detail::load_shcore_symbols() == detail::SYMBOLS_LOADED_AND_FOUND)
{
auto result = detail::set_process_dpi_awareness(PROCESS_DPI_UNAWARE);
PROCESS_DPI_AWARENESS current_awareness;
detail::get_process_dpi_awareness(NULL, ¤t_awareness);
if (current_awareness == PROCESS_DPI_UNAWARE)
return true;
else
return false;
}
else
{
return false;
}
}
//===================================================
// is dpi awareness enabled
//===================================================
bool is_dpi_aware()
{
if (detail::load_user32_symbols() == detail::SYMBOLS_LOADED_AND_FOUND)
{
auto current_context = detail::get_thread_dpi_awareness_context();
if (detail::are_dpi_awareness_contexts_equal(current_context, DPI_AWARENESS_CONTEXT_UNAWARE))
return false;
else
return true;
}
else if (detail::load_shcore_symbols() == detail::SYMBOLS_LOADED_AND_FOUND)
{
PROCESS_DPI_AWARENESS current_awareness;
detail::get_process_dpi_awareness(NULL, ¤t_awareness);
if (current_awareness == PROCESS_DPI_UNAWARE)
return false;
else
return true;
}
else
{
return false;
}
}
//==================================================
// dpi scaling helper functions
//==================================================
int scale_value(int value, UINT dpi)
{
auto dpi_scale_ = MulDiv(dpi, 100, detail::Default_DPI);
return MulDiv(value, dpi_scale_, 100);
}
RECT scale_rect(const RECT& rect, UINT dpi)
{
auto dpi_scale_ = MulDiv(dpi, 100, detail::Default_DPI);
auto scaled_rect = rect;
scaled_rect.bottom = MulDiv(scaled_rect.bottom, dpi_scale_, 100);
scaled_rect.top = MulDiv(scaled_rect.top, dpi_scale_, 100);
scaled_rect.left = MulDiv(scaled_rect.left, dpi_scale_, 100);
scaled_rect.right = MulDiv(scaled_rect.right, dpi_scale_, 100);
return scaled_rect;
}
POINT scale_point(const POINT& point, UINT dpi)
{
auto dpi_scale_ = MulDiv(dpi, 100, detail::Default_DPI);
auto scaled_point = point;
scaled_point.x = MulDiv(scaled_point.x, dpi_scale_, 100);
scaled_point.y = MulDiv(scaled_point.y, dpi_scale_, 100);
return scaled_point;
}
HFONT scale_font(const HFONT hfont, UINT dpi)
{
LOGFONT log_font;
GetObject(hfont, sizeof(log_font), &log_font);
log_font.lfHeight = -1 * scale_value(abs(log_font.lfHeight), dpi);
auto scaled_font = CreateFontIndirect(&log_font);
return scaled_font;
}
}
#endif | 31.76771 | 153 | 0.67448 | [
"vector"
] |
7ae31ea7777d65f5a4a46da56f7b97d5d4567fb1 | 279 | h | C | framework.h | xnti/AssaultCubeHack | 6e4250840c3bcb5ea08bba6360ab6d7f7f5db754 | [
"MIT"
] | null | null | null | framework.h | xnti/AssaultCubeHack | 6e4250840c3bcb5ea08bba6360ab6d7f7f5db754 | [
"MIT"
] | null | null | null | framework.h | xnti/AssaultCubeHack | 6e4250840c3bcb5ea08bba6360ab6d7f7f5db754 | [
"MIT"
] | null | null | null | #pragma once
#define WIN32_LEAN_AND_MEAN
#define ANTI_API __declspec(dllimport)
// Exclude rarely-used stuff from Windows headers
// Windows Header Files
#include <iostream>
#include "Offsets.h"
#include <windows.h>
#include <vector>
#include "Hack.h"
#include "Render.h"
| 16.411765 | 49 | 0.752688 | [
"render",
"vector"
] |
18fd39690754eef2702159518c51b5962d39ad61 | 1,337 | h | C | src/irr/asset/IGLSLEmbeddedIncludeLoader.h | Crisspl/Nabla | 8e2ff2551113b2837513b188a8f16ef70adc9f81 | [
"Apache-2.0"
] | null | null | null | src/irr/asset/IGLSLEmbeddedIncludeLoader.h | Crisspl/Nabla | 8e2ff2551113b2837513b188a8f16ef70adc9f81 | [
"Apache-2.0"
] | 2 | 2021-04-28T21:42:36.000Z | 2021-06-02T22:52:33.000Z | src/irr/asset/IGLSLEmbeddedIncludeLoader.h | Crisspl/Nabla | 8e2ff2551113b2837513b188a8f16ef70adc9f81 | [
"Apache-2.0"
] | 1 | 2021-05-31T20:33:28.000Z | 2021-05-31T20:33:28.000Z | #ifndef __IRR_ASSET_I_GLSL_EMBEDDED_INCLUDE_LOADER_H_INCLUDED__
#define __IRR_ASSET_I_GLSL_EMBEDDED_INCLUDE_LOADER_H_INCLUDED__
#include "irr/system/system.h"
#include "IFileSystem.h"
#include "irr/asset/IBuiltinIncludeLoader.h"
namespace irr
{
namespace asset
{
class IGLSLEmbeddedIncludeLoader : public IBuiltinIncludeLoader
{
protected:
virtual ~IGLSLEmbeddedIncludeLoader() = default;
inline core::vector<std::pair<std::regex,HandleFunc_t>> getBuiltinNamesToFunctionMapping() const override
{
std::string pattern(getVirtualDirectoryName());
pattern += ".*";
HandleFunc_t tmp = [this](const std::string& _name) -> std::string {return getFromDiskOrEmbedding(_name);};
return {{std::regex{pattern},std::move(tmp)}};
}
io::IFileSystem* fs;
public:
IGLSLEmbeddedIncludeLoader(io::IFileSystem* filesystem) : fs(filesystem) {}
//
const char* getVirtualDirectoryName() const override { return ""; }
//
inline std::string getFromDiskOrEmbedding(const std::string& _name) const
{
auto path = "irr/builtin/" + _name;
auto data = fs->loadBuiltinData(path);
if (!data)
return "";
auto begin = reinterpret_cast<const char*>(data->getPointer());
auto end = begin+data->getSize();
return std::string(begin,end);
}
};
}
}
#endif//__IRR_I_BUILTIN_INCLUDE_LOADER_H_INCLUDED__
| 25.226415 | 110 | 0.732236 | [
"vector"
] |
7a05077475c9f5a2ddb4d23e8b52af97248c2a52 | 86,107 | c | C | slprj/_sfprj/testPersonaliSpace_Kinect/_self/sfun/src/c1_testPersonaliSpace_Kinect.c | maryamsab/realact | 90fbf3fcb4696353c8a14d76797e5908126a9525 | [
"BSD-3-Clause"
] | 1 | 2020-12-02T21:41:36.000Z | 2020-12-02T21:41:36.000Z | slprj/_sfprj/testPersonaliSpace_Kinect/_self/sfun/src/c1_testPersonaliSpace_Kinect.c | maryamsab/realact | 90fbf3fcb4696353c8a14d76797e5908126a9525 | [
"BSD-3-Clause"
] | null | null | null | slprj/_sfprj/testPersonaliSpace_Kinect/_self/sfun/src/c1_testPersonaliSpace_Kinect.c | maryamsab/realact | 90fbf3fcb4696353c8a14d76797e5908126a9525 | [
"BSD-3-Clause"
] | 1 | 2018-06-23T11:59:06.000Z | 2018-06-23T11:59:06.000Z | /* Include files */
#include <stddef.h>
#include "blas.h"
#include "testPersonaliSpace_Kinect_sfun.h"
#include "c1_testPersonaliSpace_Kinect.h"
#define CHARTINSTANCE_CHARTNUMBER (chartInstance->chartNumber)
#define CHARTINSTANCE_INSTANCENUMBER (chartInstance->instanceNumber)
#include "testPersonaliSpace_Kinect_sfun_debug_macros.h"
#define _SF_MEX_LISTEN_FOR_CTRL_C(S) sf_mex_listen_for_ctrl_c(sfGlobalDebugInstanceStruct,S);
/* Type Definitions */
/* Named Constants */
#define c1_event_secs (0)
#define CALL_EVENT (-1)
#define c1_IN_NO_ACTIVE_CHILD ((uint8_T)0U)
#define c1_IN_gazeIdle ((uint8_T)1U)
#define c1_IN_gazeLeft ((uint8_T)2U)
#define c1_IN_gazeRight ((uint8_T)3U)
/* Variable Declarations */
/* Variable Definitions */
static real_T _sfTime_;
static const char * c1_debug_family_names[2] = { "nargin", "nargout" };
static const char * c1_b_debug_family_names[9] = { "maxarrsize", "arr", "ss",
"padsize", "tt", "mystr", "nargin", "nargout", "myarr256" };
static const char * c1_c_debug_family_names[2] = { "nargin", "nargout" };
static const char * c1_d_debug_family_names[9] = { "maxarrsize", "arr", "ss",
"padsize", "tt", "mystr", "nargin", "nargout", "myarr256" };
static const char * c1_e_debug_family_names[2] = { "nargin", "nargout" };
static const char * c1_f_debug_family_names[9] = { "maxarrsize", "arr", "ss",
"padsize", "tt", "mystr", "nargin", "nargout", "myarr256" };
static const char * c1_g_debug_family_names[3] = { "nargin", "nargout",
"sf_internal_predicateOutput" };
static const char * c1_h_debug_family_names[3] = { "nargin", "nargout",
"sf_internal_predicateOutput" };
static const char * c1_i_debug_family_names[3] = { "nargin", "nargout",
"sf_internal_predicateOutput" };
static const char * c1_j_debug_family_names[3] = { "nargin", "nargout",
"sf_internal_predicateOutput" };
static const char * c1_k_debug_family_names[3] = { "nargin", "nargout",
"sf_internal_predicateOutput" };
static const char * c1_l_debug_family_names[3] = { "nargin", "nargout",
"sf_internal_predicateOutput" };
static const char * c1_m_debug_family_names[3] = { "nargin", "nargout",
"sf_internal_predicateOutput" };
static const char * c1_n_debug_family_names[3] = { "nargin", "nargout",
"sf_internal_predicateOutput" };
static const char * c1_o_debug_family_names[3] = { "nargin", "nargout",
"sf_internal_predicateOutput" };
static const char * c1_p_debug_family_names[3] = { "nargin", "nargout",
"sf_internal_predicateOutput" };
static const char * c1_q_debug_family_names[3] = { "nargin", "nargout",
"sf_internal_predicateOutput" };
static const char * c1_r_debug_family_names[3] = { "nargin", "nargout",
"sf_internal_predicateOutput" };
/* Function Declarations */
static void initialize_c1_testPersonaliSpace_Kinect
(SFc1_testPersonaliSpace_KinectInstanceStruct *chartInstance);
static void initialize_params_c1_testPersonaliSpace_Kinect
(SFc1_testPersonaliSpace_KinectInstanceStruct *chartInstance);
static void enable_c1_testPersonaliSpace_Kinect
(SFc1_testPersonaliSpace_KinectInstanceStruct *chartInstance);
static void disable_c1_testPersonaliSpace_Kinect
(SFc1_testPersonaliSpace_KinectInstanceStruct *chartInstance);
static void c1_update_debugger_state_c1_testPersonaliSpace_Kinect
(SFc1_testPersonaliSpace_KinectInstanceStruct *chartInstance);
static const mxArray *get_sim_state_c1_testPersonaliSpace_Kinect
(SFc1_testPersonaliSpace_KinectInstanceStruct *chartInstance);
static void set_sim_state_c1_testPersonaliSpace_Kinect
(SFc1_testPersonaliSpace_KinectInstanceStruct *chartInstance, const mxArray
*c1_st);
static void c1_set_sim_state_side_effects_c1_testPersonaliSpace_Kinect
(SFc1_testPersonaliSpace_KinectInstanceStruct *chartInstance);
static void finalize_c1_testPersonaliSpace_Kinect
(SFc1_testPersonaliSpace_KinectInstanceStruct *chartInstance);
static void sf_gateway_c1_testPersonaliSpace_Kinect
(SFc1_testPersonaliSpace_KinectInstanceStruct *chartInstance);
static void c1_chartstep_c1_testPersonaliSpace_Kinect
(SFc1_testPersonaliSpace_KinectInstanceStruct *chartInstance);
static void initSimStructsc1_testPersonaliSpace_Kinect
(SFc1_testPersonaliSpace_KinectInstanceStruct *chartInstance);
static void c1_enter_atomic_gazeLeft
(SFc1_testPersonaliSpace_KinectInstanceStruct *chartInstance);
static void c1_enter_atomic_gazeIdle
(SFc1_testPersonaliSpace_KinectInstanceStruct *chartInstance);
static void c1_enter_atomic_gazeRight
(SFc1_testPersonaliSpace_KinectInstanceStruct *chartInstance);
static void init_script_number_translation(uint32_T c1_machineNumber, uint32_T
c1_chartNumber, uint32_T c1_instanceNumber);
static const mxArray *c1_sf_marshallOut(void *chartInstanceVoid, void *c1_inData);
static real_T c1_emlrt_marshallIn(SFc1_testPersonaliSpace_KinectInstanceStruct
*chartInstance, const mxArray *c1_u, const emlrtMsgIdentifier *c1_parentId);
static void c1_sf_marshallIn(void *chartInstanceVoid, const mxArray
*c1_mxArrayInData, const char_T *c1_varName, void *c1_outData);
static const mxArray *c1_b_sf_marshallOut(void *chartInstanceVoid, void
*c1_inData);
static void c1_b_emlrt_marshallIn(SFc1_testPersonaliSpace_KinectInstanceStruct
*chartInstance, const mxArray *c1_u, const emlrtMsgIdentifier *c1_parentId,
real_T c1_y[256]);
static void c1_b_sf_marshallIn(void *chartInstanceVoid, const mxArray
*c1_mxArrayInData, const char_T *c1_varName, void *c1_outData);
static const mxArray *c1_c_sf_marshallOut(void *chartInstanceVoid, void
*c1_inData);
static const mxArray *c1_d_sf_marshallOut(void *chartInstanceVoid, void
*c1_inData);
static const mxArray *c1_e_sf_marshallOut(void *chartInstanceVoid, void
*c1_inData);
static const mxArray *c1_f_sf_marshallOut(void *chartInstanceVoid, void
*c1_inData);
static const mxArray *c1_g_sf_marshallOut(void *chartInstanceVoid, void
*c1_inData);
static boolean_T c1_c_emlrt_marshallIn
(SFc1_testPersonaliSpace_KinectInstanceStruct *chartInstance, const mxArray
*c1_u, const emlrtMsgIdentifier *c1_parentId);
static void c1_c_sf_marshallIn(void *chartInstanceVoid, const mxArray
*c1_mxArrayInData, const char_T *c1_varName, void *c1_outData);
static void c1_info_helper(const mxArray **c1_info);
static const mxArray *c1_emlrt_marshallOut(const char * c1_u);
static const mxArray *c1_b_emlrt_marshallOut(const uint32_T c1_u);
static void c1_sendBML(SFc1_testPersonaliSpace_KinectInstanceStruct
*chartInstance, real_T c1_arg[256]);
static const mxArray *c1_h_sf_marshallOut(void *chartInstanceVoid, void
*c1_inData);
static int8_T c1_d_emlrt_marshallIn(SFc1_testPersonaliSpace_KinectInstanceStruct
*chartInstance, const mxArray *c1_u, const emlrtMsgIdentifier *c1_parentId);
static void c1_d_sf_marshallIn(void *chartInstanceVoid, const mxArray
*c1_mxArrayInData, const char_T *c1_varName, void *c1_outData);
static const mxArray *c1_i_sf_marshallOut(void *chartInstanceVoid, void
*c1_inData);
static int32_T c1_e_emlrt_marshallIn
(SFc1_testPersonaliSpace_KinectInstanceStruct *chartInstance, const mxArray
*c1_u, const emlrtMsgIdentifier *c1_parentId);
static void c1_e_sf_marshallIn(void *chartInstanceVoid, const mxArray
*c1_mxArrayInData, const char_T *c1_varName, void *c1_outData);
static const mxArray *c1_j_sf_marshallOut(void *chartInstanceVoid, void
*c1_inData);
static uint8_T c1_f_emlrt_marshallIn
(SFc1_testPersonaliSpace_KinectInstanceStruct *chartInstance, const mxArray
*c1_b_tp_gazeLeft, const char_T *c1_identifier);
static uint8_T c1_g_emlrt_marshallIn
(SFc1_testPersonaliSpace_KinectInstanceStruct *chartInstance, const mxArray
*c1_u, const emlrtMsgIdentifier *c1_parentId);
static void c1_f_sf_marshallIn(void *chartInstanceVoid, const mxArray
*c1_mxArrayInData, const char_T *c1_varName, void *c1_outData);
static const mxArray *c1_k_sf_marshallOut(void *chartInstanceVoid, void
*c1_inData);
static void c1_h_emlrt_marshallIn(SFc1_testPersonaliSpace_KinectInstanceStruct
*chartInstance, const mxArray *c1_u, const emlrtMsgIdentifier *c1_parentId,
real_T c1_y[256]);
static void c1_g_sf_marshallIn(void *chartInstanceVoid, const mxArray
*c1_mxArrayInData, const char_T *c1_varName, void *c1_outData);
static const mxArray *c1_i_emlrt_marshallIn
(SFc1_testPersonaliSpace_KinectInstanceStruct *chartInstance, const mxArray
*c1_b_setSimStateSideEffectsInfo, const char_T *c1_identifier);
static const mxArray *c1_j_emlrt_marshallIn
(SFc1_testPersonaliSpace_KinectInstanceStruct *chartInstance, const mxArray
*c1_u, const emlrtMsgIdentifier *c1_parentId);
static void init_dsm_address_info(SFc1_testPersonaliSpace_KinectInstanceStruct
*chartInstance);
/* Function Definitions */
static void initialize_c1_testPersonaliSpace_Kinect
(SFc1_testPersonaliSpace_KinectInstanceStruct *chartInstance)
{
_sfTime_ = sf_get_time(chartInstance->S);
chartInstance->c1_doSetSimStateSideEffects = 0U;
chartInstance->c1_setSimStateSideEffectsInfo = NULL;
chartInstance->c1_tp_gazeIdle = 0U;
chartInstance->c1_temporalCounter_i1 = 0U;
chartInstance->c1_tp_gazeLeft = 0U;
chartInstance->c1_temporalCounter_i1 = 0U;
chartInstance->c1_tp_gazeRight = 0U;
chartInstance->c1_temporalCounter_i1 = 0U;
chartInstance->c1_is_active_c1_testPersonaliSpace_Kinect = 0U;
chartInstance->c1_is_c1_testPersonaliSpace_Kinect = c1_IN_NO_ACTIVE_CHILD;
}
static void initialize_params_c1_testPersonaliSpace_Kinect
(SFc1_testPersonaliSpace_KinectInstanceStruct *chartInstance)
{
(void)chartInstance;
}
static void enable_c1_testPersonaliSpace_Kinect
(SFc1_testPersonaliSpace_KinectInstanceStruct *chartInstance)
{
_sfTime_ = sf_get_time(chartInstance->S);
sf_call_output_fcn_enable(chartInstance->S, 0, "sendBML", 0);
}
static void disable_c1_testPersonaliSpace_Kinect
(SFc1_testPersonaliSpace_KinectInstanceStruct *chartInstance)
{
_sfTime_ = sf_get_time(chartInstance->S);
sf_call_output_fcn_disable(chartInstance->S, 0, "sendBML", 0);
}
static void c1_update_debugger_state_c1_testPersonaliSpace_Kinect
(SFc1_testPersonaliSpace_KinectInstanceStruct *chartInstance)
{
uint32_T c1_prevAniVal;
c1_prevAniVal = _SFD_GET_ANIMATION();
_SFD_SET_ANIMATION(0U);
_SFD_SET_HONOR_BREAKPOINTS(0U);
if (chartInstance->c1_is_active_c1_testPersonaliSpace_Kinect == 1U) {
_SFD_CC_CALL(CHART_ACTIVE_TAG, 0U, chartInstance->c1_sfEvent);
}
if (chartInstance->c1_is_c1_testPersonaliSpace_Kinect == c1_IN_gazeLeft) {
_SFD_CS_CALL(STATE_ACTIVE_TAG, 1U, chartInstance->c1_sfEvent);
} else {
_SFD_CS_CALL(STATE_INACTIVE_TAG, 1U, chartInstance->c1_sfEvent);
}
if (chartInstance->c1_is_c1_testPersonaliSpace_Kinect == c1_IN_gazeIdle) {
_SFD_CS_CALL(STATE_ACTIVE_TAG, 0U, chartInstance->c1_sfEvent);
} else {
_SFD_CS_CALL(STATE_INACTIVE_TAG, 0U, chartInstance->c1_sfEvent);
}
if (chartInstance->c1_is_c1_testPersonaliSpace_Kinect == c1_IN_gazeRight) {
_SFD_CS_CALL(STATE_ACTIVE_TAG, 2U, chartInstance->c1_sfEvent);
} else {
_SFD_CS_CALL(STATE_INACTIVE_TAG, 2U, chartInstance->c1_sfEvent);
}
_SFD_SET_ANIMATION(c1_prevAniVal);
_SFD_SET_HONOR_BREAKPOINTS(1U);
_SFD_ANIMATE();
}
static const mxArray *get_sim_state_c1_testPersonaliSpace_Kinect
(SFc1_testPersonaliSpace_KinectInstanceStruct *chartInstance)
{
const mxArray *c1_st;
const mxArray *c1_y = NULL;
uint8_T c1_hoistedGlobal;
uint8_T c1_u;
const mxArray *c1_b_y = NULL;
uint8_T c1_b_hoistedGlobal;
uint8_T c1_b_u;
const mxArray *c1_c_y = NULL;
uint8_T c1_c_hoistedGlobal;
uint8_T c1_c_u;
const mxArray *c1_d_y = NULL;
c1_st = NULL;
c1_st = NULL;
c1_y = NULL;
sf_mex_assign(&c1_y, sf_mex_createcellmatrix(3, 1), false);
c1_hoistedGlobal = chartInstance->c1_is_active_c1_testPersonaliSpace_Kinect;
c1_u = c1_hoistedGlobal;
c1_b_y = NULL;
sf_mex_assign(&c1_b_y, sf_mex_create("y", &c1_u, 3, 0U, 0U, 0U, 0), false);
sf_mex_setcell(c1_y, 0, c1_b_y);
c1_b_hoistedGlobal = chartInstance->c1_is_c1_testPersonaliSpace_Kinect;
c1_b_u = c1_b_hoistedGlobal;
c1_c_y = NULL;
sf_mex_assign(&c1_c_y, sf_mex_create("y", &c1_b_u, 3, 0U, 0U, 0U, 0), false);
sf_mex_setcell(c1_y, 1, c1_c_y);
c1_c_hoistedGlobal = chartInstance->c1_temporalCounter_i1;
c1_c_u = c1_c_hoistedGlobal;
c1_d_y = NULL;
sf_mex_assign(&c1_d_y, sf_mex_create("y", &c1_c_u, 3, 0U, 0U, 0U, 0), false);
sf_mex_setcell(c1_y, 2, c1_d_y);
sf_mex_assign(&c1_st, c1_y, false);
return c1_st;
}
static void set_sim_state_c1_testPersonaliSpace_Kinect
(SFc1_testPersonaliSpace_KinectInstanceStruct *chartInstance, const mxArray
*c1_st)
{
const mxArray *c1_u;
c1_u = sf_mex_dup(c1_st);
chartInstance->c1_is_active_c1_testPersonaliSpace_Kinect =
c1_f_emlrt_marshallIn(chartInstance, sf_mex_dup(sf_mex_getcell(c1_u, 0)),
"is_active_c1_testPersonaliSpace_Kinect");
chartInstance->c1_is_c1_testPersonaliSpace_Kinect = c1_f_emlrt_marshallIn
(chartInstance, sf_mex_dup(sf_mex_getcell(c1_u, 1)),
"is_c1_testPersonaliSpace_Kinect");
chartInstance->c1_temporalCounter_i1 = c1_f_emlrt_marshallIn(chartInstance,
sf_mex_dup(sf_mex_getcell(c1_u, 2)), "temporalCounter_i1");
sf_mex_assign(&chartInstance->c1_setSimStateSideEffectsInfo,
c1_i_emlrt_marshallIn(chartInstance, sf_mex_dup(sf_mex_getcell
(c1_u, 3)), "setSimStateSideEffectsInfo"), true);
sf_mex_destroy(&c1_u);
chartInstance->c1_doSetSimStateSideEffects = 1U;
c1_update_debugger_state_c1_testPersonaliSpace_Kinect(chartInstance);
sf_mex_destroy(&c1_st);
}
static void c1_set_sim_state_side_effects_c1_testPersonaliSpace_Kinect
(SFc1_testPersonaliSpace_KinectInstanceStruct *chartInstance)
{
if (chartInstance->c1_doSetSimStateSideEffects != 0) {
if (chartInstance->c1_is_c1_testPersonaliSpace_Kinect == c1_IN_gazeIdle) {
chartInstance->c1_tp_gazeIdle = 1U;
if (sf_mex_sub(chartInstance->c1_setSimStateSideEffectsInfo,
"setSimStateSideEffectsInfo", 1, 2) == 0.0) {
chartInstance->c1_temporalCounter_i1 = 0U;
}
} else {
chartInstance->c1_tp_gazeIdle = 0U;
}
if (chartInstance->c1_is_c1_testPersonaliSpace_Kinect == c1_IN_gazeLeft) {
chartInstance->c1_tp_gazeLeft = 1U;
if (sf_mex_sub(chartInstance->c1_setSimStateSideEffectsInfo,
"setSimStateSideEffectsInfo", 1, 3) == 0.0) {
chartInstance->c1_temporalCounter_i1 = 0U;
}
} else {
chartInstance->c1_tp_gazeLeft = 0U;
}
if (chartInstance->c1_is_c1_testPersonaliSpace_Kinect == c1_IN_gazeRight) {
chartInstance->c1_tp_gazeRight = 1U;
if (sf_mex_sub(chartInstance->c1_setSimStateSideEffectsInfo,
"setSimStateSideEffectsInfo", 1, 4) == 0.0) {
chartInstance->c1_temporalCounter_i1 = 0U;
}
} else {
chartInstance->c1_tp_gazeRight = 0U;
}
chartInstance->c1_doSetSimStateSideEffects = 0U;
}
}
static void finalize_c1_testPersonaliSpace_Kinect
(SFc1_testPersonaliSpace_KinectInstanceStruct *chartInstance)
{
sf_mex_destroy(&chartInstance->c1_setSimStateSideEffectsInfo);
}
static void sf_gateway_c1_testPersonaliSpace_Kinect
(SFc1_testPersonaliSpace_KinectInstanceStruct *chartInstance)
{
real_T *c1_moved;
c1_moved = (real_T *)ssGetInputPortSignal(chartInstance->S, 0);
c1_set_sim_state_side_effects_c1_testPersonaliSpace_Kinect(chartInstance);
_SFD_SYMBOL_SCOPE_PUSH(0U, 0U);
_sfTime_ = sf_get_time(chartInstance->S);
_SFD_CC_CALL(CHART_ENTER_SFUNCTION_TAG, 0U, chartInstance->c1_sfEvent);
_SFD_DATA_RANGE_CHECK(*c1_moved, 0U);
if (chartInstance->c1_temporalCounter_i1 < 3U) {
chartInstance->c1_temporalCounter_i1++;
}
chartInstance->c1_sfEvent = c1_event_secs;
_SFD_CE_CALL(EVENT_BEFORE_BROADCAST_TAG, c1_event_secs,
chartInstance->c1_sfEvent);
c1_chartstep_c1_testPersonaliSpace_Kinect(chartInstance);
_SFD_CE_CALL(EVENT_AFTER_BROADCAST_TAG, c1_event_secs,
chartInstance->c1_sfEvent);
_SFD_SYMBOL_SCOPE_POP();
_SFD_CHECK_FOR_STATE_INCONSISTENCY(_testPersonaliSpace_KinectMachineNumber_,
chartInstance->chartNumber, chartInstance->instanceNumber);
}
static void c1_chartstep_c1_testPersonaliSpace_Kinect
(SFc1_testPersonaliSpace_KinectInstanceStruct *chartInstance)
{
uint32_T c1_debug_family_var_map[3];
real_T c1_nargin = 0.0;
real_T c1_nargout = 1.0;
boolean_T c1_out;
real_T c1_b_nargin = 0.0;
real_T c1_b_nargout = 1.0;
boolean_T c1_b_out;
real_T c1_c_nargin = 0.0;
real_T c1_c_nargout = 1.0;
boolean_T c1_c_out;
real_T c1_d_nargin = 0.0;
real_T c1_d_nargout = 1.0;
boolean_T c1_d_out;
real_T c1_e_nargin = 0.0;
real_T c1_e_nargout = 1.0;
boolean_T c1_e_out;
real_T c1_f_nargin = 0.0;
real_T c1_f_nargout = 1.0;
boolean_T c1_f_out;
real_T *c1_moved;
boolean_T guard1 = false;
boolean_T guard2 = false;
boolean_T guard3 = false;
boolean_T guard4 = false;
boolean_T guard5 = false;
boolean_T guard6 = false;
c1_moved = (real_T *)ssGetInputPortSignal(chartInstance->S, 0);
_SFD_CC_CALL(CHART_ENTER_DURING_FUNCTION_TAG, 0U, chartInstance->c1_sfEvent);
if (chartInstance->c1_is_active_c1_testPersonaliSpace_Kinect == 0U) {
_SFD_CC_CALL(CHART_ENTER_ENTRY_FUNCTION_TAG, 0U, chartInstance->c1_sfEvent);
chartInstance->c1_is_active_c1_testPersonaliSpace_Kinect = 1U;
_SFD_CC_CALL(EXIT_OUT_OF_FUNCTION_TAG, 0U, chartInstance->c1_sfEvent);
_SFD_CT_CALL(TRANSITION_ACTIVE_TAG, 0U, chartInstance->c1_sfEvent);
chartInstance->c1_is_c1_testPersonaliSpace_Kinect = c1_IN_gazeLeft;
_SFD_CS_CALL(STATE_ACTIVE_TAG, 1U, chartInstance->c1_sfEvent);
chartInstance->c1_temporalCounter_i1 = 0U;
chartInstance->c1_tp_gazeLeft = 1U;
c1_enter_atomic_gazeLeft(chartInstance);
} else {
switch (chartInstance->c1_is_c1_testPersonaliSpace_Kinect) {
case c1_IN_gazeIdle:
CV_CHART_EVAL(0, 0, 1);
_SFD_CT_CALL(TRANSITION_BEFORE_PROCESSING_TAG, 2U,
chartInstance->c1_sfEvent);
_SFD_SYMBOL_SCOPE_PUSH_EML(0U, 3U, 3U, c1_h_debug_family_names,
c1_debug_family_var_map);
_SFD_SYMBOL_SCOPE_ADD_EML_IMPORTABLE(&c1_nargin, 0U, c1_sf_marshallOut,
c1_sf_marshallIn);
_SFD_SYMBOL_SCOPE_ADD_EML_IMPORTABLE(&c1_nargout, 1U, c1_sf_marshallOut,
c1_sf_marshallIn);
_SFD_SYMBOL_SCOPE_ADD_EML_IMPORTABLE(&c1_out, 2U, c1_g_sf_marshallOut,
c1_c_sf_marshallIn);
guard6 = false;
if (CV_EML_COND(2, 0, 0, (chartInstance->c1_sfEvent == c1_event_secs) &&
(chartInstance->c1_temporalCounter_i1 >= 1))) {
if (CV_EML_COND(2, 0, 1, *c1_moved == 1.0)) {
CV_EML_MCDC(2, 0, 0, true);
CV_EML_IF(2, 0, 0, true);
c1_out = true;
} else {
guard6 = true;
}
} else {
guard6 = true;
}
if (guard6 == true) {
CV_EML_MCDC(2, 0, 0, false);
CV_EML_IF(2, 0, 0, false);
c1_out = false;
}
_SFD_SYMBOL_SCOPE_POP();
if (c1_out) {
_SFD_CT_CALL(TRANSITION_ACTIVE_TAG, 2U, chartInstance->c1_sfEvent);
chartInstance->c1_tp_gazeIdle = 0U;
_SFD_CS_CALL(STATE_INACTIVE_TAG, 0U, chartInstance->c1_sfEvent);
chartInstance->c1_is_c1_testPersonaliSpace_Kinect = c1_IN_gazeLeft;
_SFD_CS_CALL(STATE_ACTIVE_TAG, 1U, chartInstance->c1_sfEvent);
chartInstance->c1_temporalCounter_i1 = 0U;
chartInstance->c1_tp_gazeLeft = 1U;
c1_enter_atomic_gazeLeft(chartInstance);
} else {
_SFD_CT_CALL(TRANSITION_BEFORE_PROCESSING_TAG, 3U,
chartInstance->c1_sfEvent);
_SFD_SYMBOL_SCOPE_PUSH_EML(0U, 3U, 3U, c1_k_debug_family_names,
c1_debug_family_var_map);
_SFD_SYMBOL_SCOPE_ADD_EML_IMPORTABLE(&c1_b_nargin, 0U, c1_sf_marshallOut,
c1_sf_marshallIn);
_SFD_SYMBOL_SCOPE_ADD_EML_IMPORTABLE(&c1_b_nargout, 1U,
c1_sf_marshallOut, c1_sf_marshallIn);
_SFD_SYMBOL_SCOPE_ADD_EML_IMPORTABLE(&c1_b_out, 2U, c1_g_sf_marshallOut,
c1_c_sf_marshallIn);
guard5 = false;
if (CV_EML_COND(3, 0, 0, (chartInstance->c1_sfEvent == c1_event_secs) &&
(chartInstance->c1_temporalCounter_i1 >= 1))) {
if (CV_EML_COND(3, 0, 1, *c1_moved == 2.0)) {
CV_EML_MCDC(3, 0, 0, true);
CV_EML_IF(3, 0, 0, true);
c1_b_out = true;
} else {
guard5 = true;
}
} else {
guard5 = true;
}
if (guard5 == true) {
CV_EML_MCDC(3, 0, 0, false);
CV_EML_IF(3, 0, 0, false);
c1_b_out = false;
}
_SFD_SYMBOL_SCOPE_POP();
if (c1_b_out) {
_SFD_CT_CALL(TRANSITION_ACTIVE_TAG, 3U, chartInstance->c1_sfEvent);
chartInstance->c1_tp_gazeIdle = 0U;
_SFD_CS_CALL(STATE_INACTIVE_TAG, 0U, chartInstance->c1_sfEvent);
chartInstance->c1_is_c1_testPersonaliSpace_Kinect = c1_IN_gazeRight;
_SFD_CS_CALL(STATE_ACTIVE_TAG, 2U, chartInstance->c1_sfEvent);
chartInstance->c1_temporalCounter_i1 = 0U;
chartInstance->c1_tp_gazeRight = 1U;
c1_enter_atomic_gazeRight(chartInstance);
} else {
_SFD_CS_CALL(STATE_ENTER_DURING_FUNCTION_TAG, 0U,
chartInstance->c1_sfEvent);
}
}
_SFD_CS_CALL(EXIT_OUT_OF_FUNCTION_TAG, 0U, chartInstance->c1_sfEvent);
break;
case c1_IN_gazeLeft:
CV_CHART_EVAL(0, 0, 2);
_SFD_CT_CALL(TRANSITION_BEFORE_PROCESSING_TAG, 1U,
chartInstance->c1_sfEvent);
_SFD_SYMBOL_SCOPE_PUSH_EML(0U, 3U, 3U, c1_g_debug_family_names,
c1_debug_family_var_map);
_SFD_SYMBOL_SCOPE_ADD_EML_IMPORTABLE(&c1_c_nargin, 0U, c1_sf_marshallOut,
c1_sf_marshallIn);
_SFD_SYMBOL_SCOPE_ADD_EML_IMPORTABLE(&c1_c_nargout, 1U, c1_sf_marshallOut,
c1_sf_marshallIn);
_SFD_SYMBOL_SCOPE_ADD_EML_IMPORTABLE(&c1_c_out, 2U, c1_g_sf_marshallOut,
c1_c_sf_marshallIn);
guard4 = false;
if (CV_EML_COND(1, 0, 0, (chartInstance->c1_sfEvent == c1_event_secs) &&
(chartInstance->c1_temporalCounter_i1 >= 1))) {
if (CV_EML_COND(1, 0, 1, *c1_moved == 0.0)) {
CV_EML_MCDC(1, 0, 0, true);
CV_EML_IF(1, 0, 0, true);
c1_c_out = true;
} else {
guard4 = true;
}
} else {
guard4 = true;
}
if (guard4 == true) {
CV_EML_MCDC(1, 0, 0, false);
CV_EML_IF(1, 0, 0, false);
c1_c_out = false;
}
_SFD_SYMBOL_SCOPE_POP();
if (c1_c_out) {
_SFD_CT_CALL(TRANSITION_ACTIVE_TAG, 1U, chartInstance->c1_sfEvent);
chartInstance->c1_tp_gazeLeft = 0U;
_SFD_CS_CALL(STATE_INACTIVE_TAG, 1U, chartInstance->c1_sfEvent);
chartInstance->c1_is_c1_testPersonaliSpace_Kinect = c1_IN_gazeIdle;
_SFD_CS_CALL(STATE_ACTIVE_TAG, 0U, chartInstance->c1_sfEvent);
chartInstance->c1_temporalCounter_i1 = 0U;
chartInstance->c1_tp_gazeIdle = 1U;
c1_enter_atomic_gazeIdle(chartInstance);
} else {
_SFD_CT_CALL(TRANSITION_BEFORE_PROCESSING_TAG, 4U,
chartInstance->c1_sfEvent);
_SFD_SYMBOL_SCOPE_PUSH_EML(0U, 3U, 3U, c1_j_debug_family_names,
c1_debug_family_var_map);
_SFD_SYMBOL_SCOPE_ADD_EML_IMPORTABLE(&c1_d_nargin, 0U, c1_sf_marshallOut,
c1_sf_marshallIn);
_SFD_SYMBOL_SCOPE_ADD_EML_IMPORTABLE(&c1_d_nargout, 1U,
c1_sf_marshallOut, c1_sf_marshallIn);
_SFD_SYMBOL_SCOPE_ADD_EML_IMPORTABLE(&c1_d_out, 2U, c1_g_sf_marshallOut,
c1_c_sf_marshallIn);
guard3 = false;
if (CV_EML_COND(4, 0, 0, (chartInstance->c1_sfEvent == c1_event_secs) &&
(chartInstance->c1_temporalCounter_i1 >= 1))) {
if (CV_EML_COND(4, 0, 1, *c1_moved == 2.0)) {
CV_EML_MCDC(4, 0, 0, true);
CV_EML_IF(4, 0, 0, true);
c1_d_out = true;
} else {
guard3 = true;
}
} else {
guard3 = true;
}
if (guard3 == true) {
CV_EML_MCDC(4, 0, 0, false);
CV_EML_IF(4, 0, 0, false);
c1_d_out = false;
}
_SFD_SYMBOL_SCOPE_POP();
if (c1_d_out) {
_SFD_CT_CALL(TRANSITION_ACTIVE_TAG, 4U, chartInstance->c1_sfEvent);
chartInstance->c1_tp_gazeLeft = 0U;
_SFD_CS_CALL(STATE_INACTIVE_TAG, 1U, chartInstance->c1_sfEvent);
chartInstance->c1_is_c1_testPersonaliSpace_Kinect = c1_IN_gazeRight;
_SFD_CS_CALL(STATE_ACTIVE_TAG, 2U, chartInstance->c1_sfEvent);
chartInstance->c1_temporalCounter_i1 = 0U;
chartInstance->c1_tp_gazeRight = 1U;
c1_enter_atomic_gazeRight(chartInstance);
} else {
_SFD_CS_CALL(STATE_ENTER_DURING_FUNCTION_TAG, 1U,
chartInstance->c1_sfEvent);
}
}
_SFD_CS_CALL(EXIT_OUT_OF_FUNCTION_TAG, 1U, chartInstance->c1_sfEvent);
break;
case c1_IN_gazeRight:
CV_CHART_EVAL(0, 0, 3);
_SFD_CT_CALL(TRANSITION_BEFORE_PROCESSING_TAG, 5U,
chartInstance->c1_sfEvent);
_SFD_SYMBOL_SCOPE_PUSH_EML(0U, 3U, 3U, c1_l_debug_family_names,
c1_debug_family_var_map);
_SFD_SYMBOL_SCOPE_ADD_EML_IMPORTABLE(&c1_e_nargin, 0U, c1_sf_marshallOut,
c1_sf_marshallIn);
_SFD_SYMBOL_SCOPE_ADD_EML_IMPORTABLE(&c1_e_nargout, 1U, c1_sf_marshallOut,
c1_sf_marshallIn);
_SFD_SYMBOL_SCOPE_ADD_EML_IMPORTABLE(&c1_e_out, 2U, c1_g_sf_marshallOut,
c1_c_sf_marshallIn);
guard2 = false;
if (CV_EML_COND(5, 0, 0, (chartInstance->c1_sfEvent == c1_event_secs) &&
(chartInstance->c1_temporalCounter_i1 >= 1))) {
if (CV_EML_COND(5, 0, 1, *c1_moved == 0.0)) {
CV_EML_MCDC(5, 0, 0, true);
CV_EML_IF(5, 0, 0, true);
c1_e_out = true;
} else {
guard2 = true;
}
} else {
guard2 = true;
}
if (guard2 == true) {
CV_EML_MCDC(5, 0, 0, false);
CV_EML_IF(5, 0, 0, false);
c1_e_out = false;
}
_SFD_SYMBOL_SCOPE_POP();
if (c1_e_out) {
_SFD_CT_CALL(TRANSITION_ACTIVE_TAG, 5U, chartInstance->c1_sfEvent);
chartInstance->c1_tp_gazeRight = 0U;
_SFD_CS_CALL(STATE_INACTIVE_TAG, 2U, chartInstance->c1_sfEvent);
chartInstance->c1_is_c1_testPersonaliSpace_Kinect = c1_IN_gazeIdle;
_SFD_CS_CALL(STATE_ACTIVE_TAG, 0U, chartInstance->c1_sfEvent);
chartInstance->c1_temporalCounter_i1 = 0U;
chartInstance->c1_tp_gazeIdle = 1U;
c1_enter_atomic_gazeIdle(chartInstance);
} else {
_SFD_CT_CALL(TRANSITION_BEFORE_PROCESSING_TAG, 6U,
chartInstance->c1_sfEvent);
_SFD_SYMBOL_SCOPE_PUSH_EML(0U, 3U, 3U, c1_i_debug_family_names,
c1_debug_family_var_map);
_SFD_SYMBOL_SCOPE_ADD_EML_IMPORTABLE(&c1_f_nargin, 0U, c1_sf_marshallOut,
c1_sf_marshallIn);
_SFD_SYMBOL_SCOPE_ADD_EML_IMPORTABLE(&c1_f_nargout, 1U,
c1_sf_marshallOut, c1_sf_marshallIn);
_SFD_SYMBOL_SCOPE_ADD_EML_IMPORTABLE(&c1_f_out, 2U, c1_g_sf_marshallOut,
c1_c_sf_marshallIn);
guard1 = false;
if (CV_EML_COND(6, 0, 0, (chartInstance->c1_sfEvent == c1_event_secs) &&
(chartInstance->c1_temporalCounter_i1 >= 1))) {
if (CV_EML_COND(6, 0, 1, *c1_moved == 1.0)) {
CV_EML_MCDC(6, 0, 0, true);
CV_EML_IF(6, 0, 0, true);
c1_f_out = true;
} else {
guard1 = true;
}
} else {
guard1 = true;
}
if (guard1 == true) {
CV_EML_MCDC(6, 0, 0, false);
CV_EML_IF(6, 0, 0, false);
c1_f_out = false;
}
_SFD_SYMBOL_SCOPE_POP();
if (c1_f_out) {
_SFD_CT_CALL(TRANSITION_ACTIVE_TAG, 6U, chartInstance->c1_sfEvent);
chartInstance->c1_tp_gazeRight = 0U;
_SFD_CS_CALL(STATE_INACTIVE_TAG, 2U, chartInstance->c1_sfEvent);
chartInstance->c1_is_c1_testPersonaliSpace_Kinect = c1_IN_gazeLeft;
_SFD_CS_CALL(STATE_ACTIVE_TAG, 1U, chartInstance->c1_sfEvent);
chartInstance->c1_temporalCounter_i1 = 0U;
chartInstance->c1_tp_gazeLeft = 1U;
c1_enter_atomic_gazeLeft(chartInstance);
} else {
_SFD_CS_CALL(STATE_ENTER_DURING_FUNCTION_TAG, 2U,
chartInstance->c1_sfEvent);
}
}
_SFD_CS_CALL(EXIT_OUT_OF_FUNCTION_TAG, 2U, chartInstance->c1_sfEvent);
break;
default:
CV_CHART_EVAL(0, 0, 0);
chartInstance->c1_is_c1_testPersonaliSpace_Kinect = c1_IN_NO_ACTIVE_CHILD;
_SFD_CS_CALL(STATE_INACTIVE_TAG, 0U, chartInstance->c1_sfEvent);
break;
}
}
_SFD_CC_CALL(EXIT_OUT_OF_FUNCTION_TAG, 0U, chartInstance->c1_sfEvent);
}
static void initSimStructsc1_testPersonaliSpace_Kinect
(SFc1_testPersonaliSpace_KinectInstanceStruct *chartInstance)
{
(void)chartInstance;
}
static void c1_enter_atomic_gazeLeft
(SFc1_testPersonaliSpace_KinectInstanceStruct *chartInstance)
{
uint32_T c1_debug_family_var_map[2];
real_T c1_nargin = 0.0;
real_T c1_nargout = 0.0;
uint32_T c1_b_debug_family_var_map[9];
real_T c1_maxarrsize;
real_T c1_arr[143];
real_T c1_ss;
real_T c1_padsize;
real_T c1_tt[256];
char_T c1_mystr[143];
real_T c1_b_nargin = 1.0;
real_T c1_b_nargout = 1.0;
real_T c1_myarr256[256];
int32_T c1_i0;
static char_T c1_cv0[143] = { '<', '?', 'x', 'm', 'l', ' ', 'v', 'e', 'r', 's',
'i', 'o', 'n', '=', '\"', '1', '.', '0', '\"', ' ', '?', '>', '<', 'a', 'c',
't', '>', '<', 'b', 'm', 'l', '>', '<', 'g', 'a', 'z', 'e', ' ', 'a', 'n',
'g', 'l', 'e', '=', '\"', '1', '2', '\"', ' ', 'd', 'i', 'r', 'e', 'c', 't',
'i', 'o', 'n', '=', '\"', 'L', 'E', 'F', 'T', '\"', ' ', 's', 'b', 'm', ':',
'j', 'o', 'i', 'n', 't', '-', 'r', 'a', 'n', 'g', 'e', '=', '\"', 'H', 'E',
'A', 'D', ' ', 'B', 'A', 'C', 'K', '\"', ' ', 's', 'b', 'm', ':', 't', 'i',
'm', 'e', '-', 'h', 'i', 'n', 't', '=', '\"', '1', '.', '5', '\"', ' ', 't',
'a', 'r', 'g', 'e', 't', '=', '\"', 'c', 'a', 'm', 'e', 'r', 'a', '\"', '/',
'>', '<', '/', 'b', 'm', 'l', '>', '<', '/', 'a', 'c', 't', '>' };
int32_T c1_i1;
static real_T c1_dv0[143] = { 60.0, 63.0, 120.0, 109.0, 108.0, 32.0, 118.0,
101.0, 114.0, 115.0, 105.0, 111.0, 110.0, 61.0, 34.0, 49.0, 46.0, 48.0, 34.0,
32.0, 63.0, 62.0, 60.0, 97.0, 99.0, 116.0, 62.0, 60.0, 98.0, 109.0, 108.0,
62.0, 60.0, 103.0, 97.0, 122.0, 101.0, 32.0, 97.0, 110.0, 103.0, 108.0,
101.0, 61.0, 34.0, 49.0, 50.0, 34.0, 32.0, 100.0, 105.0, 114.0, 101.0, 99.0,
116.0, 105.0, 111.0, 110.0, 61.0, 34.0, 76.0, 69.0, 70.0, 84.0, 34.0, 32.0,
115.0, 98.0, 109.0, 58.0, 106.0, 111.0, 105.0, 110.0, 116.0, 45.0, 114.0,
97.0, 110.0, 103.0, 101.0, 61.0, 34.0, 72.0, 69.0, 65.0, 68.0, 32.0, 66.0,
65.0, 67.0, 75.0, 34.0, 32.0, 115.0, 98.0, 109.0, 58.0, 116.0, 105.0, 109.0,
101.0, 45.0, 104.0, 105.0, 110.0, 116.0, 61.0, 34.0, 49.0, 46.0, 53.0, 34.0,
32.0, 116.0, 97.0, 114.0, 103.0, 101.0, 116.0, 61.0, 34.0, 99.0, 97.0, 109.0,
101.0, 114.0, 97.0, 34.0, 47.0, 62.0, 60.0, 47.0, 98.0, 109.0, 108.0, 62.0,
60.0, 47.0, 97.0, 99.0, 116.0, 62.0 };
int32_T c1_i2;
int32_T c1_i3;
int32_T c1_i4;
int32_T c1_i5;
real_T c1_b_myarr256[256];
_SFD_SYMBOL_SCOPE_PUSH_EML(0U, 2U, 2U, c1_debug_family_names,
c1_debug_family_var_map);
_SFD_SYMBOL_SCOPE_ADD_EML_IMPORTABLE(&c1_nargin, 0U, c1_sf_marshallOut,
c1_sf_marshallIn);
_SFD_SYMBOL_SCOPE_ADD_EML_IMPORTABLE(&c1_nargout, 1U, c1_sf_marshallOut,
c1_sf_marshallIn);
_SFD_SYMBOL_SCOPE_PUSH_EML(0U, 9U, 9U, c1_b_debug_family_names,
c1_b_debug_family_var_map);
_SFD_SYMBOL_SCOPE_ADD_EML_IMPORTABLE(&c1_maxarrsize, 0U, c1_sf_marshallOut,
c1_sf_marshallIn);
_SFD_SYMBOL_SCOPE_ADD_EML(c1_arr, 1U, c1_d_sf_marshallOut);
_SFD_SYMBOL_SCOPE_ADD_EML(&c1_ss, 2U, c1_sf_marshallOut);
_SFD_SYMBOL_SCOPE_ADD_EML_IMPORTABLE(&c1_padsize, 3U, c1_sf_marshallOut,
c1_sf_marshallIn);
_SFD_SYMBOL_SCOPE_ADD_EML_IMPORTABLE(c1_tt, 4U, c1_b_sf_marshallOut,
c1_b_sf_marshallIn);
_SFD_SYMBOL_SCOPE_ADD_EML(c1_mystr, 5U, c1_c_sf_marshallOut);
_SFD_SYMBOL_SCOPE_ADD_EML_IMPORTABLE(&c1_b_nargin, 6U, c1_sf_marshallOut,
c1_sf_marshallIn);
_SFD_SYMBOL_SCOPE_ADD_EML_IMPORTABLE(&c1_b_nargout, 7U, c1_sf_marshallOut,
c1_sf_marshallIn);
_SFD_SYMBOL_SCOPE_ADD_EML_IMPORTABLE(c1_myarr256, 8U, c1_b_sf_marshallOut,
c1_b_sf_marshallIn);
for (c1_i0 = 0; c1_i0 < 143; c1_i0++) {
c1_mystr[c1_i0] = c1_cv0[c1_i0];
}
CV_SCRIPT_FCN(0, 0);
_SFD_SCRIPT_CALL(0U, chartInstance->c1_sfEvent, 3);
_SFD_SCRIPT_CALL(0U, chartInstance->c1_sfEvent, 4);
c1_maxarrsize = 256.0;
_SFD_SCRIPT_CALL(0U, chartInstance->c1_sfEvent, 6);
for (c1_i1 = 0; c1_i1 < 143; c1_i1++) {
c1_arr[c1_i1] = c1_dv0[c1_i1];
}
_SFD_SCRIPT_CALL(0U, chartInstance->c1_sfEvent, 7);
c1_ss = 143.0;
_SFD_SCRIPT_CALL(0U, chartInstance->c1_sfEvent, 8);
c1_padsize = c1_maxarrsize - c1_ss;
_SFD_SCRIPT_CALL(0U, chartInstance->c1_sfEvent, 9);
for (c1_i2 = 0; c1_i2 < 256; c1_i2++) {
c1_tt[c1_i2] = 0.0;
}
_SFD_SCRIPT_CALL(0U, chartInstance->c1_sfEvent, 10);
for (c1_i3 = 0; c1_i3 < 143; c1_i3++) {
c1_tt[c1_i3] = c1_arr[c1_i3];
}
_SFD_SCRIPT_CALL(0U, chartInstance->c1_sfEvent, 11);
for (c1_i4 = 0; c1_i4 < 256; c1_i4++) {
c1_myarr256[c1_i4] = c1_tt[c1_i4];
}
_SFD_SCRIPT_CALL(0U, chartInstance->c1_sfEvent, -11);
_SFD_SYMBOL_SCOPE_POP();
for (c1_i5 = 0; c1_i5 < 256; c1_i5++) {
c1_b_myarr256[c1_i5] = c1_myarr256[c1_i5];
}
c1_sendBML(chartInstance, c1_b_myarr256);
_SFD_SYMBOL_SCOPE_POP();
}
static void c1_enter_atomic_gazeIdle
(SFc1_testPersonaliSpace_KinectInstanceStruct *chartInstance)
{
uint32_T c1_debug_family_var_map[2];
real_T c1_nargin = 0.0;
real_T c1_nargout = 0.0;
uint32_T c1_b_debug_family_var_map[9];
real_T c1_maxarrsize;
real_T c1_arr[87];
real_T c1_ss;
real_T c1_padsize;
real_T c1_tt[256];
char_T c1_mystr[87];
real_T c1_b_nargin = 1.0;
real_T c1_b_nargout = 1.0;
real_T c1_myarr256[256];
int32_T c1_i6;
static char_T c1_cv1[87] = { '<', '?', 'x', 'm', 'l', ' ', 'v', 'e', 'r', 's',
'i', 'o', 'n', '=', '\"', '1', '.', '0', '\"', ' ', '?', '>', '<', 'a', 'c',
't', '>', '<', 'b', 'm', 'l', '>', '<', 'g', 'a', 'z', 'e', ' ', 's', 'b',
'm', ':', 't', 'i', 'm', 'e', '-', 'h', 'i', 'n', 't', '=', '\"', '1', '.',
'5', '\"', ' ', 't', 'a', 'r', 'g', 'e', 't', '=', '\"', 'c', 'a', 'm', 'e',
'r', 'a', '\"', '/', '>', '<', '/', 'b', 'm', 'l', '>', '<', '/', 'a', 'c',
't', '>' };
int32_T c1_i7;
static real_T c1_dv1[87] = { 60.0, 63.0, 120.0, 109.0, 108.0, 32.0, 118.0,
101.0, 114.0, 115.0, 105.0, 111.0, 110.0, 61.0, 34.0, 49.0, 46.0, 48.0, 34.0,
32.0, 63.0, 62.0, 60.0, 97.0, 99.0, 116.0, 62.0, 60.0, 98.0, 109.0, 108.0,
62.0, 60.0, 103.0, 97.0, 122.0, 101.0, 32.0, 115.0, 98.0, 109.0, 58.0, 116.0,
105.0, 109.0, 101.0, 45.0, 104.0, 105.0, 110.0, 116.0, 61.0, 34.0, 49.0,
46.0, 53.0, 34.0, 32.0, 116.0, 97.0, 114.0, 103.0, 101.0, 116.0, 61.0, 34.0,
99.0, 97.0, 109.0, 101.0, 114.0, 97.0, 34.0, 47.0, 62.0, 60.0, 47.0, 98.0,
109.0, 108.0, 62.0, 60.0, 47.0, 97.0, 99.0, 116.0, 62.0 };
int32_T c1_i8;
int32_T c1_i9;
int32_T c1_i10;
int32_T c1_i11;
real_T c1_b_myarr256[256];
_SFD_SYMBOL_SCOPE_PUSH_EML(0U, 2U, 2U, c1_c_debug_family_names,
c1_debug_family_var_map);
_SFD_SYMBOL_SCOPE_ADD_EML_IMPORTABLE(&c1_nargin, 0U, c1_sf_marshallOut,
c1_sf_marshallIn);
_SFD_SYMBOL_SCOPE_ADD_EML_IMPORTABLE(&c1_nargout, 1U, c1_sf_marshallOut,
c1_sf_marshallIn);
_SFD_SYMBOL_SCOPE_PUSH_EML(0U, 9U, 9U, c1_d_debug_family_names,
c1_b_debug_family_var_map);
_SFD_SYMBOL_SCOPE_ADD_EML_IMPORTABLE(&c1_maxarrsize, 0U, c1_sf_marshallOut,
c1_sf_marshallIn);
_SFD_SYMBOL_SCOPE_ADD_EML(c1_arr, 1U, c1_f_sf_marshallOut);
_SFD_SYMBOL_SCOPE_ADD_EML(&c1_ss, 2U, c1_sf_marshallOut);
_SFD_SYMBOL_SCOPE_ADD_EML_IMPORTABLE(&c1_padsize, 3U, c1_sf_marshallOut,
c1_sf_marshallIn);
_SFD_SYMBOL_SCOPE_ADD_EML_IMPORTABLE(c1_tt, 4U, c1_b_sf_marshallOut,
c1_b_sf_marshallIn);
_SFD_SYMBOL_SCOPE_ADD_EML(c1_mystr, 5U, c1_e_sf_marshallOut);
_SFD_SYMBOL_SCOPE_ADD_EML_IMPORTABLE(&c1_b_nargin, 6U, c1_sf_marshallOut,
c1_sf_marshallIn);
_SFD_SYMBOL_SCOPE_ADD_EML_IMPORTABLE(&c1_b_nargout, 7U, c1_sf_marshallOut,
c1_sf_marshallIn);
_SFD_SYMBOL_SCOPE_ADD_EML_IMPORTABLE(c1_myarr256, 8U, c1_b_sf_marshallOut,
c1_b_sf_marshallIn);
for (c1_i6 = 0; c1_i6 < 87; c1_i6++) {
c1_mystr[c1_i6] = c1_cv1[c1_i6];
}
CV_SCRIPT_FCN(0, 0);
_SFD_SCRIPT_CALL(0U, chartInstance->c1_sfEvent, 3);
_SFD_SCRIPT_CALL(0U, chartInstance->c1_sfEvent, 4);
c1_maxarrsize = 256.0;
_SFD_SCRIPT_CALL(0U, chartInstance->c1_sfEvent, 6);
for (c1_i7 = 0; c1_i7 < 87; c1_i7++) {
c1_arr[c1_i7] = c1_dv1[c1_i7];
}
_SFD_SCRIPT_CALL(0U, chartInstance->c1_sfEvent, 7);
c1_ss = 87.0;
_SFD_SCRIPT_CALL(0U, chartInstance->c1_sfEvent, 8);
c1_padsize = c1_maxarrsize - c1_ss;
_SFD_SCRIPT_CALL(0U, chartInstance->c1_sfEvent, 9);
for (c1_i8 = 0; c1_i8 < 256; c1_i8++) {
c1_tt[c1_i8] = 0.0;
}
_SFD_SCRIPT_CALL(0U, chartInstance->c1_sfEvent, 10);
for (c1_i9 = 0; c1_i9 < 87; c1_i9++) {
c1_tt[c1_i9] = c1_arr[c1_i9];
}
_SFD_SCRIPT_CALL(0U, chartInstance->c1_sfEvent, 11);
for (c1_i10 = 0; c1_i10 < 256; c1_i10++) {
c1_myarr256[c1_i10] = c1_tt[c1_i10];
}
_SFD_SCRIPT_CALL(0U, chartInstance->c1_sfEvent, -11);
_SFD_SYMBOL_SCOPE_POP();
for (c1_i11 = 0; c1_i11 < 256; c1_i11++) {
c1_b_myarr256[c1_i11] = c1_myarr256[c1_i11];
}
c1_sendBML(chartInstance, c1_b_myarr256);
_SFD_SYMBOL_SCOPE_POP();
}
static void c1_enter_atomic_gazeRight
(SFc1_testPersonaliSpace_KinectInstanceStruct *chartInstance)
{
uint32_T c1_debug_family_var_map[2];
real_T c1_nargin = 0.0;
real_T c1_nargout = 0.0;
uint32_T c1_b_debug_family_var_map[9];
real_T c1_maxarrsize;
real_T c1_arr[143];
real_T c1_ss;
real_T c1_padsize;
real_T c1_tt[256];
char_T c1_mystr[143];
real_T c1_b_nargin = 1.0;
real_T c1_b_nargout = 1.0;
real_T c1_myarr256[256];
int32_T c1_i12;
static char_T c1_cv2[143] = { '<', '?', 'x', 'm', 'l', ' ', 'v', 'e', 'r', 's',
'i', 'o', 'n', '=', '\"', '1', '.', '0', '\"', ' ', '?', '>', '<', 'a', 'c',
't', '>', '<', 'b', 'm', 'l', '>', '<', 'g', 'a', 'z', 'e', ' ', 'a', 'n',
'g', 'l', 'e', '=', '\"', '7', '\"', ' ', 'd', 'i', 'r', 'e', 'c', 't', 'i',
'o', 'n', '=', '\"', 'R', 'I', 'G', 'H', 'T', '\"', ' ', 's', 'b', 'm', ':',
'j', 'o', 'i', 'n', 't', '-', 'r', 'a', 'n', 'g', 'e', '=', '\"', 'H', 'E',
'A', 'D', ' ', 'B', 'A', 'C', 'K', '\"', ' ', 's', 'b', 'm', ':', 't', 'i',
'm', 'e', '-', 'h', 'i', 'n', 't', '=', '\"', '1', '.', '5', '\"', ' ', 't',
'a', 'r', 'g', 'e', 't', '=', '\"', 'c', 'a', 'm', 'e', 'r', 'a', '\"', '/',
'>', '<', '/', 'b', 'm', 'l', '>', '<', '/', 'a', 'c', 't', '>' };
int32_T c1_i13;
static real_T c1_dv2[143] = { 60.0, 63.0, 120.0, 109.0, 108.0, 32.0, 118.0,
101.0, 114.0, 115.0, 105.0, 111.0, 110.0, 61.0, 34.0, 49.0, 46.0, 48.0, 34.0,
32.0, 63.0, 62.0, 60.0, 97.0, 99.0, 116.0, 62.0, 60.0, 98.0, 109.0, 108.0,
62.0, 60.0, 103.0, 97.0, 122.0, 101.0, 32.0, 97.0, 110.0, 103.0, 108.0,
101.0, 61.0, 34.0, 55.0, 34.0, 32.0, 100.0, 105.0, 114.0, 101.0, 99.0, 116.0,
105.0, 111.0, 110.0, 61.0, 34.0, 82.0, 73.0, 71.0, 72.0, 84.0, 34.0, 32.0,
115.0, 98.0, 109.0, 58.0, 106.0, 111.0, 105.0, 110.0, 116.0, 45.0, 114.0,
97.0, 110.0, 103.0, 101.0, 61.0, 34.0, 72.0, 69.0, 65.0, 68.0, 32.0, 66.0,
65.0, 67.0, 75.0, 34.0, 32.0, 115.0, 98.0, 109.0, 58.0, 116.0, 105.0, 109.0,
101.0, 45.0, 104.0, 105.0, 110.0, 116.0, 61.0, 34.0, 49.0, 46.0, 53.0, 34.0,
32.0, 116.0, 97.0, 114.0, 103.0, 101.0, 116.0, 61.0, 34.0, 99.0, 97.0, 109.0,
101.0, 114.0, 97.0, 34.0, 47.0, 62.0, 60.0, 47.0, 98.0, 109.0, 108.0, 62.0,
60.0, 47.0, 97.0, 99.0, 116.0, 62.0 };
int32_T c1_i14;
int32_T c1_i15;
int32_T c1_i16;
int32_T c1_i17;
real_T c1_b_myarr256[256];
_SFD_SYMBOL_SCOPE_PUSH_EML(0U, 2U, 2U, c1_e_debug_family_names,
c1_debug_family_var_map);
_SFD_SYMBOL_SCOPE_ADD_EML_IMPORTABLE(&c1_nargin, 0U, c1_sf_marshallOut,
c1_sf_marshallIn);
_SFD_SYMBOL_SCOPE_ADD_EML_IMPORTABLE(&c1_nargout, 1U, c1_sf_marshallOut,
c1_sf_marshallIn);
_SFD_SYMBOL_SCOPE_PUSH_EML(0U, 9U, 9U, c1_f_debug_family_names,
c1_b_debug_family_var_map);
_SFD_SYMBOL_SCOPE_ADD_EML_IMPORTABLE(&c1_maxarrsize, 0U, c1_sf_marshallOut,
c1_sf_marshallIn);
_SFD_SYMBOL_SCOPE_ADD_EML(c1_arr, 1U, c1_d_sf_marshallOut);
_SFD_SYMBOL_SCOPE_ADD_EML(&c1_ss, 2U, c1_sf_marshallOut);
_SFD_SYMBOL_SCOPE_ADD_EML_IMPORTABLE(&c1_padsize, 3U, c1_sf_marshallOut,
c1_sf_marshallIn);
_SFD_SYMBOL_SCOPE_ADD_EML_IMPORTABLE(c1_tt, 4U, c1_b_sf_marshallOut,
c1_b_sf_marshallIn);
_SFD_SYMBOL_SCOPE_ADD_EML(c1_mystr, 5U, c1_c_sf_marshallOut);
_SFD_SYMBOL_SCOPE_ADD_EML_IMPORTABLE(&c1_b_nargin, 6U, c1_sf_marshallOut,
c1_sf_marshallIn);
_SFD_SYMBOL_SCOPE_ADD_EML_IMPORTABLE(&c1_b_nargout, 7U, c1_sf_marshallOut,
c1_sf_marshallIn);
_SFD_SYMBOL_SCOPE_ADD_EML_IMPORTABLE(c1_myarr256, 8U, c1_b_sf_marshallOut,
c1_b_sf_marshallIn);
for (c1_i12 = 0; c1_i12 < 143; c1_i12++) {
c1_mystr[c1_i12] = c1_cv2[c1_i12];
}
CV_SCRIPT_FCN(0, 0);
_SFD_SCRIPT_CALL(0U, chartInstance->c1_sfEvent, 3);
_SFD_SCRIPT_CALL(0U, chartInstance->c1_sfEvent, 4);
c1_maxarrsize = 256.0;
_SFD_SCRIPT_CALL(0U, chartInstance->c1_sfEvent, 6);
for (c1_i13 = 0; c1_i13 < 143; c1_i13++) {
c1_arr[c1_i13] = c1_dv2[c1_i13];
}
_SFD_SCRIPT_CALL(0U, chartInstance->c1_sfEvent, 7);
c1_ss = 143.0;
_SFD_SCRIPT_CALL(0U, chartInstance->c1_sfEvent, 8);
c1_padsize = c1_maxarrsize - c1_ss;
_SFD_SCRIPT_CALL(0U, chartInstance->c1_sfEvent, 9);
for (c1_i14 = 0; c1_i14 < 256; c1_i14++) {
c1_tt[c1_i14] = 0.0;
}
_SFD_SCRIPT_CALL(0U, chartInstance->c1_sfEvent, 10);
for (c1_i15 = 0; c1_i15 < 143; c1_i15++) {
c1_tt[c1_i15] = c1_arr[c1_i15];
}
_SFD_SCRIPT_CALL(0U, chartInstance->c1_sfEvent, 11);
for (c1_i16 = 0; c1_i16 < 256; c1_i16++) {
c1_myarr256[c1_i16] = c1_tt[c1_i16];
}
_SFD_SCRIPT_CALL(0U, chartInstance->c1_sfEvent, -11);
_SFD_SYMBOL_SCOPE_POP();
for (c1_i17 = 0; c1_i17 < 256; c1_i17++) {
c1_b_myarr256[c1_i17] = c1_myarr256[c1_i17];
}
c1_sendBML(chartInstance, c1_b_myarr256);
_SFD_SYMBOL_SCOPE_POP();
}
static void init_script_number_translation(uint32_T c1_machineNumber, uint32_T
c1_chartNumber, uint32_T c1_instanceNumber)
{
(void)c1_machineNumber;
_SFD_SCRIPT_TRANSLATION(c1_chartNumber, c1_instanceNumber, 0U,
sf_debug_get_script_id(
"C:\\Users\\root180\\Documents\\affective-project\\4-6-2015-Matlab-M+M\\encStr2Arr.m"));
}
static const mxArray *c1_sf_marshallOut(void *chartInstanceVoid, void *c1_inData)
{
const mxArray *c1_mxArrayOutData = NULL;
real_T c1_u;
const mxArray *c1_y = NULL;
SFc1_testPersonaliSpace_KinectInstanceStruct *chartInstance;
chartInstance = (SFc1_testPersonaliSpace_KinectInstanceStruct *)
chartInstanceVoid;
c1_mxArrayOutData = NULL;
c1_u = *(real_T *)c1_inData;
c1_y = NULL;
sf_mex_assign(&c1_y, sf_mex_create("y", &c1_u, 0, 0U, 0U, 0U, 0), false);
sf_mex_assign(&c1_mxArrayOutData, c1_y, false);
return c1_mxArrayOutData;
}
static real_T c1_emlrt_marshallIn(SFc1_testPersonaliSpace_KinectInstanceStruct
*chartInstance, const mxArray *c1_u, const emlrtMsgIdentifier *c1_parentId)
{
real_T c1_y;
real_T c1_d0;
(void)chartInstance;
sf_mex_import(c1_parentId, sf_mex_dup(c1_u), &c1_d0, 1, 0, 0U, 0, 0U, 0);
c1_y = c1_d0;
sf_mex_destroy(&c1_u);
return c1_y;
}
static void c1_sf_marshallIn(void *chartInstanceVoid, const mxArray
*c1_mxArrayInData, const char_T *c1_varName, void *c1_outData)
{
const mxArray *c1_nargout;
const char_T *c1_identifier;
emlrtMsgIdentifier c1_thisId;
real_T c1_y;
SFc1_testPersonaliSpace_KinectInstanceStruct *chartInstance;
chartInstance = (SFc1_testPersonaliSpace_KinectInstanceStruct *)
chartInstanceVoid;
c1_nargout = sf_mex_dup(c1_mxArrayInData);
c1_identifier = c1_varName;
c1_thisId.fIdentifier = c1_identifier;
c1_thisId.fParent = NULL;
c1_y = c1_emlrt_marshallIn(chartInstance, sf_mex_dup(c1_nargout), &c1_thisId);
sf_mex_destroy(&c1_nargout);
*(real_T *)c1_outData = c1_y;
sf_mex_destroy(&c1_mxArrayInData);
}
static const mxArray *c1_b_sf_marshallOut(void *chartInstanceVoid, void
*c1_inData)
{
const mxArray *c1_mxArrayOutData = NULL;
int32_T c1_i18;
real_T c1_b_inData[256];
int32_T c1_i19;
real_T c1_u[256];
const mxArray *c1_y = NULL;
SFc1_testPersonaliSpace_KinectInstanceStruct *chartInstance;
chartInstance = (SFc1_testPersonaliSpace_KinectInstanceStruct *)
chartInstanceVoid;
c1_mxArrayOutData = NULL;
for (c1_i18 = 0; c1_i18 < 256; c1_i18++) {
c1_b_inData[c1_i18] = (*(real_T (*)[256])c1_inData)[c1_i18];
}
for (c1_i19 = 0; c1_i19 < 256; c1_i19++) {
c1_u[c1_i19] = c1_b_inData[c1_i19];
}
c1_y = NULL;
sf_mex_assign(&c1_y, sf_mex_create("y", c1_u, 0, 0U, 1U, 0U, 1, 256), false);
sf_mex_assign(&c1_mxArrayOutData, c1_y, false);
return c1_mxArrayOutData;
}
static void c1_b_emlrt_marshallIn(SFc1_testPersonaliSpace_KinectInstanceStruct
*chartInstance, const mxArray *c1_u, const emlrtMsgIdentifier *c1_parentId,
real_T c1_y[256])
{
real_T c1_dv3[256];
int32_T c1_i20;
(void)chartInstance;
sf_mex_import(c1_parentId, sf_mex_dup(c1_u), c1_dv3, 1, 0, 0U, 1, 0U, 1, 256);
for (c1_i20 = 0; c1_i20 < 256; c1_i20++) {
c1_y[c1_i20] = c1_dv3[c1_i20];
}
sf_mex_destroy(&c1_u);
}
static void c1_b_sf_marshallIn(void *chartInstanceVoid, const mxArray
*c1_mxArrayInData, const char_T *c1_varName, void *c1_outData)
{
const mxArray *c1_myarr256;
const char_T *c1_identifier;
emlrtMsgIdentifier c1_thisId;
real_T c1_y[256];
int32_T c1_i21;
SFc1_testPersonaliSpace_KinectInstanceStruct *chartInstance;
chartInstance = (SFc1_testPersonaliSpace_KinectInstanceStruct *)
chartInstanceVoid;
c1_myarr256 = sf_mex_dup(c1_mxArrayInData);
c1_identifier = c1_varName;
c1_thisId.fIdentifier = c1_identifier;
c1_thisId.fParent = NULL;
c1_b_emlrt_marshallIn(chartInstance, sf_mex_dup(c1_myarr256), &c1_thisId, c1_y);
sf_mex_destroy(&c1_myarr256);
for (c1_i21 = 0; c1_i21 < 256; c1_i21++) {
(*(real_T (*)[256])c1_outData)[c1_i21] = c1_y[c1_i21];
}
sf_mex_destroy(&c1_mxArrayInData);
}
static const mxArray *c1_c_sf_marshallOut(void *chartInstanceVoid, void
*c1_inData)
{
const mxArray *c1_mxArrayOutData = NULL;
int32_T c1_i22;
char_T c1_b_inData[143];
int32_T c1_i23;
char_T c1_u[143];
const mxArray *c1_y = NULL;
SFc1_testPersonaliSpace_KinectInstanceStruct *chartInstance;
chartInstance = (SFc1_testPersonaliSpace_KinectInstanceStruct *)
chartInstanceVoid;
c1_mxArrayOutData = NULL;
for (c1_i22 = 0; c1_i22 < 143; c1_i22++) {
c1_b_inData[c1_i22] = (*(char_T (*)[143])c1_inData)[c1_i22];
}
for (c1_i23 = 0; c1_i23 < 143; c1_i23++) {
c1_u[c1_i23] = c1_b_inData[c1_i23];
}
c1_y = NULL;
sf_mex_assign(&c1_y, sf_mex_create("y", c1_u, 10, 0U, 1U, 0U, 2, 1, 143),
false);
sf_mex_assign(&c1_mxArrayOutData, c1_y, false);
return c1_mxArrayOutData;
}
static const mxArray *c1_d_sf_marshallOut(void *chartInstanceVoid, void
*c1_inData)
{
const mxArray *c1_mxArrayOutData = NULL;
int32_T c1_i24;
real_T c1_b_inData[143];
int32_T c1_i25;
real_T c1_u[143];
const mxArray *c1_y = NULL;
SFc1_testPersonaliSpace_KinectInstanceStruct *chartInstance;
chartInstance = (SFc1_testPersonaliSpace_KinectInstanceStruct *)
chartInstanceVoid;
c1_mxArrayOutData = NULL;
for (c1_i24 = 0; c1_i24 < 143; c1_i24++) {
c1_b_inData[c1_i24] = (*(real_T (*)[143])c1_inData)[c1_i24];
}
for (c1_i25 = 0; c1_i25 < 143; c1_i25++) {
c1_u[c1_i25] = c1_b_inData[c1_i25];
}
c1_y = NULL;
sf_mex_assign(&c1_y, sf_mex_create("y", c1_u, 0, 0U, 1U, 0U, 1, 143), false);
sf_mex_assign(&c1_mxArrayOutData, c1_y, false);
return c1_mxArrayOutData;
}
static const mxArray *c1_e_sf_marshallOut(void *chartInstanceVoid, void
*c1_inData)
{
const mxArray *c1_mxArrayOutData = NULL;
int32_T c1_i26;
char_T c1_b_inData[87];
int32_T c1_i27;
char_T c1_u[87];
const mxArray *c1_y = NULL;
SFc1_testPersonaliSpace_KinectInstanceStruct *chartInstance;
chartInstance = (SFc1_testPersonaliSpace_KinectInstanceStruct *)
chartInstanceVoid;
c1_mxArrayOutData = NULL;
for (c1_i26 = 0; c1_i26 < 87; c1_i26++) {
c1_b_inData[c1_i26] = (*(char_T (*)[87])c1_inData)[c1_i26];
}
for (c1_i27 = 0; c1_i27 < 87; c1_i27++) {
c1_u[c1_i27] = c1_b_inData[c1_i27];
}
c1_y = NULL;
sf_mex_assign(&c1_y, sf_mex_create("y", c1_u, 10, 0U, 1U, 0U, 2, 1, 87), false);
sf_mex_assign(&c1_mxArrayOutData, c1_y, false);
return c1_mxArrayOutData;
}
static const mxArray *c1_f_sf_marshallOut(void *chartInstanceVoid, void
*c1_inData)
{
const mxArray *c1_mxArrayOutData = NULL;
int32_T c1_i28;
real_T c1_b_inData[87];
int32_T c1_i29;
real_T c1_u[87];
const mxArray *c1_y = NULL;
SFc1_testPersonaliSpace_KinectInstanceStruct *chartInstance;
chartInstance = (SFc1_testPersonaliSpace_KinectInstanceStruct *)
chartInstanceVoid;
c1_mxArrayOutData = NULL;
for (c1_i28 = 0; c1_i28 < 87; c1_i28++) {
c1_b_inData[c1_i28] = (*(real_T (*)[87])c1_inData)[c1_i28];
}
for (c1_i29 = 0; c1_i29 < 87; c1_i29++) {
c1_u[c1_i29] = c1_b_inData[c1_i29];
}
c1_y = NULL;
sf_mex_assign(&c1_y, sf_mex_create("y", c1_u, 0, 0U, 1U, 0U, 1, 87), false);
sf_mex_assign(&c1_mxArrayOutData, c1_y, false);
return c1_mxArrayOutData;
}
static const mxArray *c1_g_sf_marshallOut(void *chartInstanceVoid, void
*c1_inData)
{
const mxArray *c1_mxArrayOutData = NULL;
boolean_T c1_u;
const mxArray *c1_y = NULL;
SFc1_testPersonaliSpace_KinectInstanceStruct *chartInstance;
chartInstance = (SFc1_testPersonaliSpace_KinectInstanceStruct *)
chartInstanceVoid;
c1_mxArrayOutData = NULL;
c1_u = *(boolean_T *)c1_inData;
c1_y = NULL;
sf_mex_assign(&c1_y, sf_mex_create("y", &c1_u, 11, 0U, 0U, 0U, 0), false);
sf_mex_assign(&c1_mxArrayOutData, c1_y, false);
return c1_mxArrayOutData;
}
static boolean_T c1_c_emlrt_marshallIn
(SFc1_testPersonaliSpace_KinectInstanceStruct *chartInstance, const mxArray
*c1_u, const emlrtMsgIdentifier *c1_parentId)
{
boolean_T c1_y;
boolean_T c1_b0;
(void)chartInstance;
sf_mex_import(c1_parentId, sf_mex_dup(c1_u), &c1_b0, 1, 11, 0U, 0, 0U, 0);
c1_y = c1_b0;
sf_mex_destroy(&c1_u);
return c1_y;
}
static void c1_c_sf_marshallIn(void *chartInstanceVoid, const mxArray
*c1_mxArrayInData, const char_T *c1_varName, void *c1_outData)
{
const mxArray *c1_sf_internal_predicateOutput;
const char_T *c1_identifier;
emlrtMsgIdentifier c1_thisId;
boolean_T c1_y;
SFc1_testPersonaliSpace_KinectInstanceStruct *chartInstance;
chartInstance = (SFc1_testPersonaliSpace_KinectInstanceStruct *)
chartInstanceVoid;
c1_sf_internal_predicateOutput = sf_mex_dup(c1_mxArrayInData);
c1_identifier = c1_varName;
c1_thisId.fIdentifier = c1_identifier;
c1_thisId.fParent = NULL;
c1_y = c1_c_emlrt_marshallIn(chartInstance, sf_mex_dup
(c1_sf_internal_predicateOutput), &c1_thisId);
sf_mex_destroy(&c1_sf_internal_predicateOutput);
*(boolean_T *)c1_outData = c1_y;
sf_mex_destroy(&c1_mxArrayInData);
}
const mxArray *sf_c1_testPersonaliSpace_Kinect_get_eml_resolved_functions_info
(void)
{
const mxArray *c1_nameCaptureInfo = NULL;
c1_nameCaptureInfo = NULL;
sf_mex_assign(&c1_nameCaptureInfo, sf_mex_createstruct("structure", 2, 1, 1),
false);
c1_info_helper(&c1_nameCaptureInfo);
sf_mex_emlrtNameCapturePostProcessR2012a(&c1_nameCaptureInfo);
return c1_nameCaptureInfo;
}
static void c1_info_helper(const mxArray **c1_info)
{
const mxArray *c1_rhs0 = NULL;
const mxArray *c1_lhs0 = NULL;
sf_mex_addfield(*c1_info, c1_emlrt_marshallOut(""), "context", "context", 0);
sf_mex_addfield(*c1_info, c1_emlrt_marshallOut("encStr2Arr"), "name", "name",
0);
sf_mex_addfield(*c1_info, c1_emlrt_marshallOut("char"), "dominantType",
"dominantType", 0);
sf_mex_addfield(*c1_info, c1_emlrt_marshallOut(
"[E]C:/Users/root180/Documents/affective-project/4-6-2015-Matlab-M+M/encStr2Arr.m"),
"resolved", "resolved", 0);
sf_mex_addfield(*c1_info, c1_b_emlrt_marshallOut(1435183461U), "fileTimeLo",
"fileTimeLo", 0);
sf_mex_addfield(*c1_info, c1_b_emlrt_marshallOut(0U), "fileTimeHi",
"fileTimeHi", 0);
sf_mex_addfield(*c1_info, c1_b_emlrt_marshallOut(0U), "mFileTimeLo",
"mFileTimeLo", 0);
sf_mex_addfield(*c1_info, c1_b_emlrt_marshallOut(0U), "mFileTimeHi",
"mFileTimeHi", 0);
sf_mex_assign(&c1_rhs0, sf_mex_createcellmatrix(0, 1), false);
sf_mex_assign(&c1_lhs0, sf_mex_createcellmatrix(0, 1), false);
sf_mex_addfield(*c1_info, sf_mex_duplicatearraysafe(&c1_rhs0), "rhs", "rhs", 0);
sf_mex_addfield(*c1_info, sf_mex_duplicatearraysafe(&c1_lhs0), "lhs", "lhs", 0);
sf_mex_destroy(&c1_rhs0);
sf_mex_destroy(&c1_lhs0);
}
static const mxArray *c1_emlrt_marshallOut(const char * c1_u)
{
const mxArray *c1_y = NULL;
c1_y = NULL;
sf_mex_assign(&c1_y, sf_mex_create("y", c1_u, 15, 0U, 0U, 0U, 2, 1, strlen
(c1_u)), false);
return c1_y;
}
static const mxArray *c1_b_emlrt_marshallOut(const uint32_T c1_u)
{
const mxArray *c1_y = NULL;
c1_y = NULL;
sf_mex_assign(&c1_y, sf_mex_create("y", &c1_u, 7, 0U, 0U, 0U, 0), false);
return c1_y;
}
static void c1_sendBML(SFc1_testPersonaliSpace_KinectInstanceStruct
*chartInstance, real_T c1_arg[256])
{
int32_T c1_i30;
int32_T c1_i31;
int32_T c1_i32;
real_T (*c1_b_arg)[256];
c1_b_arg = (real_T (*)[256])ssGetOutputPortSignal(chartInstance->S, 1);
for (c1_i30 = 0; c1_i30 < 256; c1_i30++) {
_SFD_DATA_RANGE_CHECK(c1_arg[c1_i30], 1U);
}
_SFD_SET_DATA_VALUE_PTR(1U, c1_arg);
_SFD_CS_CALL(FUNCTION_ACTIVE_TAG, 3U, chartInstance->c1_sfEvent);
_SFD_SYMBOL_SCOPE_PUSH(1U, 0U);
_SFD_SYMBOL_SCOPE_ADD_IMPORTABLE("arg", c1_arg, c1_k_sf_marshallOut,
c1_g_sf_marshallIn);
_SFD_CS_CALL(STATE_ENTER_DURING_FUNCTION_TAG, 3U, chartInstance->c1_sfEvent);
for (c1_i31 = 0; c1_i31 < 256; c1_i31++) {
(*c1_b_arg)[c1_i31] = c1_arg[c1_i31];
}
for (c1_i32 = 0; c1_i32 < 256; c1_i32++) {
_SFD_DATA_RANGE_CHECK((*c1_b_arg)[c1_i32], 1U);
}
sf_call_output_fcn_call(chartInstance->S, 0, "sendBML", 0);
_SFD_SYMBOL_SCOPE_POP();
_SFD_CS_CALL(FUNCTION_INACTIVE_TAG, 3U, chartInstance->c1_sfEvent);
_SFD_UNSET_DATA_VALUE_PTR(1U);
_SFD_CS_CALL(EXIT_OUT_OF_FUNCTION_TAG, 3U, chartInstance->c1_sfEvent);
}
static const mxArray *c1_h_sf_marshallOut(void *chartInstanceVoid, void
*c1_inData)
{
const mxArray *c1_mxArrayOutData = NULL;
int8_T c1_u;
const mxArray *c1_y = NULL;
SFc1_testPersonaliSpace_KinectInstanceStruct *chartInstance;
chartInstance = (SFc1_testPersonaliSpace_KinectInstanceStruct *)
chartInstanceVoid;
c1_mxArrayOutData = NULL;
c1_u = *(int8_T *)c1_inData;
c1_y = NULL;
sf_mex_assign(&c1_y, sf_mex_create("y", &c1_u, 2, 0U, 0U, 0U, 0), false);
sf_mex_assign(&c1_mxArrayOutData, c1_y, false);
return c1_mxArrayOutData;
}
static int8_T c1_d_emlrt_marshallIn(SFc1_testPersonaliSpace_KinectInstanceStruct
*chartInstance, const mxArray *c1_u, const emlrtMsgIdentifier *c1_parentId)
{
int8_T c1_y;
int8_T c1_i33;
(void)chartInstance;
sf_mex_import(c1_parentId, sf_mex_dup(c1_u), &c1_i33, 1, 2, 0U, 0, 0U, 0);
c1_y = c1_i33;
sf_mex_destroy(&c1_u);
return c1_y;
}
static void c1_d_sf_marshallIn(void *chartInstanceVoid, const mxArray
*c1_mxArrayInData, const char_T *c1_varName, void *c1_outData)
{
const mxArray *c1_secs;
const char_T *c1_identifier;
emlrtMsgIdentifier c1_thisId;
int8_T c1_y;
SFc1_testPersonaliSpace_KinectInstanceStruct *chartInstance;
chartInstance = (SFc1_testPersonaliSpace_KinectInstanceStruct *)
chartInstanceVoid;
c1_secs = sf_mex_dup(c1_mxArrayInData);
c1_identifier = c1_varName;
c1_thisId.fIdentifier = c1_identifier;
c1_thisId.fParent = NULL;
c1_y = c1_d_emlrt_marshallIn(chartInstance, sf_mex_dup(c1_secs), &c1_thisId);
sf_mex_destroy(&c1_secs);
*(int8_T *)c1_outData = c1_y;
sf_mex_destroy(&c1_mxArrayInData);
}
static const mxArray *c1_i_sf_marshallOut(void *chartInstanceVoid, void
*c1_inData)
{
const mxArray *c1_mxArrayOutData = NULL;
int32_T c1_u;
const mxArray *c1_y = NULL;
SFc1_testPersonaliSpace_KinectInstanceStruct *chartInstance;
chartInstance = (SFc1_testPersonaliSpace_KinectInstanceStruct *)
chartInstanceVoid;
c1_mxArrayOutData = NULL;
c1_u = *(int32_T *)c1_inData;
c1_y = NULL;
sf_mex_assign(&c1_y, sf_mex_create("y", &c1_u, 6, 0U, 0U, 0U, 0), false);
sf_mex_assign(&c1_mxArrayOutData, c1_y, false);
return c1_mxArrayOutData;
}
static int32_T c1_e_emlrt_marshallIn
(SFc1_testPersonaliSpace_KinectInstanceStruct *chartInstance, const mxArray
*c1_u, const emlrtMsgIdentifier *c1_parentId)
{
int32_T c1_y;
int32_T c1_i34;
(void)chartInstance;
sf_mex_import(c1_parentId, sf_mex_dup(c1_u), &c1_i34, 1, 6, 0U, 0, 0U, 0);
c1_y = c1_i34;
sf_mex_destroy(&c1_u);
return c1_y;
}
static void c1_e_sf_marshallIn(void *chartInstanceVoid, const mxArray
*c1_mxArrayInData, const char_T *c1_varName, void *c1_outData)
{
const mxArray *c1_b_sfEvent;
const char_T *c1_identifier;
emlrtMsgIdentifier c1_thisId;
int32_T c1_y;
SFc1_testPersonaliSpace_KinectInstanceStruct *chartInstance;
chartInstance = (SFc1_testPersonaliSpace_KinectInstanceStruct *)
chartInstanceVoid;
c1_b_sfEvent = sf_mex_dup(c1_mxArrayInData);
c1_identifier = c1_varName;
c1_thisId.fIdentifier = c1_identifier;
c1_thisId.fParent = NULL;
c1_y = c1_e_emlrt_marshallIn(chartInstance, sf_mex_dup(c1_b_sfEvent),
&c1_thisId);
sf_mex_destroy(&c1_b_sfEvent);
*(int32_T *)c1_outData = c1_y;
sf_mex_destroy(&c1_mxArrayInData);
}
static const mxArray *c1_j_sf_marshallOut(void *chartInstanceVoid, void
*c1_inData)
{
const mxArray *c1_mxArrayOutData = NULL;
uint8_T c1_u;
const mxArray *c1_y = NULL;
SFc1_testPersonaliSpace_KinectInstanceStruct *chartInstance;
chartInstance = (SFc1_testPersonaliSpace_KinectInstanceStruct *)
chartInstanceVoid;
c1_mxArrayOutData = NULL;
c1_u = *(uint8_T *)c1_inData;
c1_y = NULL;
sf_mex_assign(&c1_y, sf_mex_create("y", &c1_u, 3, 0U, 0U, 0U, 0), false);
sf_mex_assign(&c1_mxArrayOutData, c1_y, false);
return c1_mxArrayOutData;
}
static uint8_T c1_f_emlrt_marshallIn
(SFc1_testPersonaliSpace_KinectInstanceStruct *chartInstance, const mxArray
*c1_b_tp_gazeLeft, const char_T *c1_identifier)
{
uint8_T c1_y;
emlrtMsgIdentifier c1_thisId;
c1_thisId.fIdentifier = c1_identifier;
c1_thisId.fParent = NULL;
c1_y = c1_g_emlrt_marshallIn(chartInstance, sf_mex_dup(c1_b_tp_gazeLeft),
&c1_thisId);
sf_mex_destroy(&c1_b_tp_gazeLeft);
return c1_y;
}
static uint8_T c1_g_emlrt_marshallIn
(SFc1_testPersonaliSpace_KinectInstanceStruct *chartInstance, const mxArray
*c1_u, const emlrtMsgIdentifier *c1_parentId)
{
uint8_T c1_y;
uint8_T c1_u0;
(void)chartInstance;
sf_mex_import(c1_parentId, sf_mex_dup(c1_u), &c1_u0, 1, 3, 0U, 0, 0U, 0);
c1_y = c1_u0;
sf_mex_destroy(&c1_u);
return c1_y;
}
static void c1_f_sf_marshallIn(void *chartInstanceVoid, const mxArray
*c1_mxArrayInData, const char_T *c1_varName, void *c1_outData)
{
const mxArray *c1_b_tp_gazeLeft;
const char_T *c1_identifier;
emlrtMsgIdentifier c1_thisId;
uint8_T c1_y;
SFc1_testPersonaliSpace_KinectInstanceStruct *chartInstance;
chartInstance = (SFc1_testPersonaliSpace_KinectInstanceStruct *)
chartInstanceVoid;
c1_b_tp_gazeLeft = sf_mex_dup(c1_mxArrayInData);
c1_identifier = c1_varName;
c1_thisId.fIdentifier = c1_identifier;
c1_thisId.fParent = NULL;
c1_y = c1_g_emlrt_marshallIn(chartInstance, sf_mex_dup(c1_b_tp_gazeLeft),
&c1_thisId);
sf_mex_destroy(&c1_b_tp_gazeLeft);
*(uint8_T *)c1_outData = c1_y;
sf_mex_destroy(&c1_mxArrayInData);
}
static const mxArray *c1_k_sf_marshallOut(void *chartInstanceVoid, void
*c1_inData)
{
const mxArray *c1_mxArrayOutData = NULL;
int32_T c1_i35;
real_T c1_b_inData[256];
int32_T c1_i36;
real_T c1_u[256];
const mxArray *c1_y = NULL;
SFc1_testPersonaliSpace_KinectInstanceStruct *chartInstance;
chartInstance = (SFc1_testPersonaliSpace_KinectInstanceStruct *)
chartInstanceVoid;
c1_mxArrayOutData = NULL;
for (c1_i35 = 0; c1_i35 < 256; c1_i35++) {
c1_b_inData[c1_i35] = (*(real_T (*)[256])c1_inData)[c1_i35];
}
for (c1_i36 = 0; c1_i36 < 256; c1_i36++) {
c1_u[c1_i36] = c1_b_inData[c1_i36];
}
c1_y = NULL;
sf_mex_assign(&c1_y, sf_mex_create("y", c1_u, 0, 0U, 1U, 0U, 2, 256, 1), false);
sf_mex_assign(&c1_mxArrayOutData, c1_y, false);
return c1_mxArrayOutData;
}
static void c1_h_emlrt_marshallIn(SFc1_testPersonaliSpace_KinectInstanceStruct
*chartInstance, const mxArray *c1_u, const emlrtMsgIdentifier *c1_parentId,
real_T c1_y[256])
{
real_T c1_dv4[256];
int32_T c1_i37;
(void)chartInstance;
sf_mex_import(c1_parentId, sf_mex_dup(c1_u), c1_dv4, 1, 0, 0U, 1, 0U, 2, 256,
1);
for (c1_i37 = 0; c1_i37 < 256; c1_i37++) {
c1_y[c1_i37] = c1_dv4[c1_i37];
}
sf_mex_destroy(&c1_u);
}
static void c1_g_sf_marshallIn(void *chartInstanceVoid, const mxArray
*c1_mxArrayInData, const char_T *c1_varName, void *c1_outData)
{
const mxArray *c1_arg;
const char_T *c1_identifier;
emlrtMsgIdentifier c1_thisId;
real_T c1_y[256];
int32_T c1_i38;
SFc1_testPersonaliSpace_KinectInstanceStruct *chartInstance;
chartInstance = (SFc1_testPersonaliSpace_KinectInstanceStruct *)
chartInstanceVoid;
c1_arg = sf_mex_dup(c1_mxArrayInData);
c1_identifier = c1_varName;
c1_thisId.fIdentifier = c1_identifier;
c1_thisId.fParent = NULL;
c1_h_emlrt_marshallIn(chartInstance, sf_mex_dup(c1_arg), &c1_thisId, c1_y);
sf_mex_destroy(&c1_arg);
for (c1_i38 = 0; c1_i38 < 256; c1_i38++) {
(*(real_T (*)[256])c1_outData)[c1_i38] = c1_y[c1_i38];
}
sf_mex_destroy(&c1_mxArrayInData);
}
static const mxArray *c1_i_emlrt_marshallIn
(SFc1_testPersonaliSpace_KinectInstanceStruct *chartInstance, const mxArray
*c1_b_setSimStateSideEffectsInfo, const char_T *c1_identifier)
{
const mxArray *c1_y = NULL;
emlrtMsgIdentifier c1_thisId;
c1_y = NULL;
c1_thisId.fIdentifier = c1_identifier;
c1_thisId.fParent = NULL;
sf_mex_assign(&c1_y, c1_j_emlrt_marshallIn(chartInstance, sf_mex_dup
(c1_b_setSimStateSideEffectsInfo), &c1_thisId), false);
sf_mex_destroy(&c1_b_setSimStateSideEffectsInfo);
return c1_y;
}
static const mxArray *c1_j_emlrt_marshallIn
(SFc1_testPersonaliSpace_KinectInstanceStruct *chartInstance, const mxArray
*c1_u, const emlrtMsgIdentifier *c1_parentId)
{
const mxArray *c1_y = NULL;
(void)chartInstance;
(void)c1_parentId;
c1_y = NULL;
sf_mex_assign(&c1_y, sf_mex_duplicatearraysafe(&c1_u), false);
sf_mex_destroy(&c1_u);
return c1_y;
}
static void init_dsm_address_info(SFc1_testPersonaliSpace_KinectInstanceStruct
*chartInstance)
{
(void)chartInstance;
}
/* SFunction Glue Code */
#ifdef utFree
#undef utFree
#endif
#ifdef utMalloc
#undef utMalloc
#endif
#ifdef __cplusplus
extern "C" void *utMalloc(size_t size);
extern "C" void utFree(void*);
#else
extern void *utMalloc(size_t size);
extern void utFree(void*);
#endif
void sf_c1_testPersonaliSpace_Kinect_get_check_sum(mxArray *plhs[])
{
((real_T *)mxGetPr((plhs[0])))[0] = (real_T)(2509831182U);
((real_T *)mxGetPr((plhs[0])))[1] = (real_T)(3288321605U);
((real_T *)mxGetPr((plhs[0])))[2] = (real_T)(2484360455U);
((real_T *)mxGetPr((plhs[0])))[3] = (real_T)(3837299177U);
}
mxArray *sf_c1_testPersonaliSpace_Kinect_get_autoinheritance_info(void)
{
const char *autoinheritanceFields[] = { "checksum", "inputs", "parameters",
"outputs", "locals" };
mxArray *mxAutoinheritanceInfo = mxCreateStructMatrix(1,1,5,
autoinheritanceFields);
{
mxArray *mxChecksum = mxCreateString("20ZwQJqDcglDBcFuxEfG2D");
mxSetField(mxAutoinheritanceInfo,0,"checksum",mxChecksum);
}
{
const char *dataFields[] = { "size", "type", "complexity" };
mxArray *mxData = mxCreateStructMatrix(1,1,3,dataFields);
{
mxArray *mxSize = mxCreateDoubleMatrix(1,2,mxREAL);
double *pr = mxGetPr(mxSize);
pr[0] = (double)(1);
pr[1] = (double)(1);
mxSetField(mxData,0,"size",mxSize);
}
{
const char *typeFields[] = { "base", "fixpt" };
mxArray *mxType = mxCreateStructMatrix(1,1,2,typeFields);
mxSetField(mxType,0,"base",mxCreateDoubleScalar(10));
mxSetField(mxType,0,"fixpt",mxCreateDoubleMatrix(0,0,mxREAL));
mxSetField(mxData,0,"type",mxType);
}
mxSetField(mxData,0,"complexity",mxCreateDoubleScalar(0));
mxSetField(mxAutoinheritanceInfo,0,"inputs",mxData);
}
{
mxSetField(mxAutoinheritanceInfo,0,"parameters",mxCreateDoubleMatrix(0,0,
mxREAL));
}
{
mxSetField(mxAutoinheritanceInfo,0,"outputs",mxCreateDoubleMatrix(0,0,mxREAL));
}
{
mxSetField(mxAutoinheritanceInfo,0,"locals",mxCreateDoubleMatrix(0,0,mxREAL));
}
return(mxAutoinheritanceInfo);
}
mxArray *sf_c1_testPersonaliSpace_Kinect_third_party_uses_info(void)
{
mxArray * mxcell3p = mxCreateCellMatrix(1,0);
return(mxcell3p);
}
mxArray *sf_c1_testPersonaliSpace_Kinect_updateBuildInfo_args_info(void)
{
mxArray *mxBIArgs = mxCreateCellMatrix(1,0);
return mxBIArgs;
}
static const mxArray *sf_get_sim_state_info_c1_testPersonaliSpace_Kinect(void)
{
const char *infoFields[] = { "chartChecksum", "varInfo" };
mxArray *mxInfo = mxCreateStructMatrix(1, 1, 2, infoFields);
const char *infoEncStr[] = {
"100 S1x3'type','srcId','name','auxInfo'{{M[8],M[0],T\"is_active_c1_testPersonaliSpace_Kinect\",},{M[9],M[0],T\"is_c1_testPersonaliSpace_Kinect\",},{M[11],M[19],T\"temporalCounter_i1\",S'et','os','ct'{{T\"ev\",M1x3[1 2 6],M[1]}}}}"
};
mxArray *mxVarInfo = sf_mex_decode_encoded_mx_struct_array(infoEncStr, 3, 10);
mxArray *mxChecksum = mxCreateDoubleMatrix(1, 4, mxREAL);
sf_c1_testPersonaliSpace_Kinect_get_check_sum(&mxChecksum);
mxSetField(mxInfo, 0, infoFields[0], mxChecksum);
mxSetField(mxInfo, 0, infoFields[1], mxVarInfo);
return mxInfo;
}
static void chart_debug_initialization(SimStruct *S, unsigned int
fullDebuggerInitialization)
{
if (!sim_mode_is_rtw_gen(S)) {
SFc1_testPersonaliSpace_KinectInstanceStruct *chartInstance;
ChartRunTimeInfo * crtInfo = (ChartRunTimeInfo *)(ssGetUserData(S));
ChartInfoStruct * chartInfo = (ChartInfoStruct *)(crtInfo->instanceInfo);
chartInstance = (SFc1_testPersonaliSpace_KinectInstanceStruct *)
chartInfo->chartInstance;
if (ssIsFirstInitCond(S) && fullDebuggerInitialization==1) {
/* do this only if simulation is starting */
{
unsigned int chartAlreadyPresent;
chartAlreadyPresent = sf_debug_initialize_chart
(sfGlobalDebugInstanceStruct,
_testPersonaliSpace_KinectMachineNumber_,
1,
4,
7,
0,
2,
1,
0,
0,
0,
1,
&(chartInstance->chartNumber),
&(chartInstance->instanceNumber),
(void *)S);
/* Each instance must initialize ist own list of scripts */
init_script_number_translation(_testPersonaliSpace_KinectMachineNumber_,
chartInstance->chartNumber,chartInstance->instanceNumber);
if (chartAlreadyPresent==0) {
/* this is the first instance */
sf_debug_set_chart_disable_implicit_casting
(sfGlobalDebugInstanceStruct,
_testPersonaliSpace_KinectMachineNumber_,chartInstance->chartNumber,
1);
sf_debug_set_chart_event_thresholds(sfGlobalDebugInstanceStruct,
_testPersonaliSpace_KinectMachineNumber_,
chartInstance->chartNumber,
1,
1,
1);
_SFD_SET_DATA_PROPS(0,1,1,0,"moved");
_SFD_SET_DATA_PROPS(1,8,0,0,"");
_SFD_EVENT_SCOPE(0,1);
_SFD_STATE_INFO(0,0,0);
_SFD_STATE_INFO(1,0,0);
_SFD_STATE_INFO(2,0,0);
_SFD_STATE_INFO(3,0,2);
_SFD_CH_SUBSTATE_COUNT(3);
_SFD_CH_SUBSTATE_DECOMP(0);
_SFD_CH_SUBSTATE_INDEX(0,0);
_SFD_CH_SUBSTATE_INDEX(1,1);
_SFD_CH_SUBSTATE_INDEX(2,2);
_SFD_ST_SUBSTATE_COUNT(0,0);
_SFD_ST_SUBSTATE_COUNT(1,0);
_SFD_ST_SUBSTATE_COUNT(2,0);
}
_SFD_CV_INIT_CHART(3,1,0,0);
{
_SFD_CV_INIT_STATE(0,0,0,0,0,0,NULL,NULL);
}
{
_SFD_CV_INIT_STATE(1,0,0,0,0,0,NULL,NULL);
}
{
_SFD_CV_INIT_STATE(2,0,0,0,0,0,NULL,NULL);
}
{
_SFD_CV_INIT_STATE(3,0,0,0,0,0,NULL,NULL);
}
_SFD_CV_INIT_TRANS(0,0,NULL,NULL,0,NULL);
_SFD_CV_INIT_TRANS(1,0,NULL,NULL,0,NULL);
_SFD_CV_INIT_TRANS(2,0,NULL,NULL,0,NULL);
_SFD_CV_INIT_TRANS(6,0,NULL,NULL,0,NULL);
_SFD_CV_INIT_TRANS(4,0,NULL,NULL,0,NULL);
_SFD_CV_INIT_TRANS(3,0,NULL,NULL,0,NULL);
_SFD_CV_INIT_TRANS(5,0,NULL,NULL,0,NULL);
/* Initialization of MATLAB Function Model Coverage */
_SFD_CV_INIT_SCRIPT(0,1,0,0,0,0,0,0,0,0);
_SFD_CV_INIT_SCRIPT_FCN(0,0,"encStr2Arr",0,-1,436);
_SFD_CV_INIT_EML(1,1,0,0,0,0,0,0,0,0,0);
_SFD_CV_INIT_EML(0,1,0,0,0,0,0,0,0,0,0);
_SFD_CV_INIT_EML(2,1,0,0,0,0,0,0,0,0,0);
_SFD_CV_INIT_EML(1,0,0,1,0,0,0,0,0,2,1);
_SFD_CV_INIT_EML_IF(1,0,0,0,22,0,22);
{
static int condStart[] = { 0, 14 };
static int condEnd[] = { 13, 22 };
static int pfixExpr[] = { 0, 1, -3 };
_SFD_CV_INIT_EML_MCDC(1,0,0,0,22,2,0,&(condStart[0]),&(condEnd[0]),3,
&(pfixExpr[0]));
}
_SFD_CV_INIT_EML(2,0,0,1,0,0,0,0,0,2,1);
_SFD_CV_INIT_EML_IF(2,0,0,0,22,0,22);
{
static int condStart[] = { 0, 14 };
static int condEnd[] = { 13, 22 };
static int pfixExpr[] = { 0, 1, -3 };
_SFD_CV_INIT_EML_MCDC(2,0,0,0,22,2,0,&(condStart[0]),&(condEnd[0]),3,
&(pfixExpr[0]));
}
_SFD_CV_INIT_EML(6,0,0,1,0,0,0,0,0,2,1);
_SFD_CV_INIT_EML_IF(6,0,0,0,22,0,22);
{
static int condStart[] = { 0, 14 };
static int condEnd[] = { 13, 22 };
static int pfixExpr[] = { 0, 1, -3 };
_SFD_CV_INIT_EML_MCDC(6,0,0,0,22,2,0,&(condStart[0]),&(condEnd[0]),3,
&(pfixExpr[0]));
}
_SFD_CV_INIT_EML(4,0,0,1,0,0,0,0,0,2,1);
_SFD_CV_INIT_EML_IF(4,0,0,0,22,0,22);
{
static int condStart[] = { 0, 14 };
static int condEnd[] = { 13, 22 };
static int pfixExpr[] = { 0, 1, -3 };
_SFD_CV_INIT_EML_MCDC(4,0,0,0,22,2,0,&(condStart[0]),&(condEnd[0]),3,
&(pfixExpr[0]));
}
_SFD_CV_INIT_EML(3,0,0,1,0,0,0,0,0,2,1);
_SFD_CV_INIT_EML_IF(3,0,0,0,22,0,22);
{
static int condStart[] = { 0, 14 };
static int condEnd[] = { 13, 22 };
static int pfixExpr[] = { 0, 1, -3 };
_SFD_CV_INIT_EML_MCDC(3,0,0,0,22,2,0,&(condStart[0]),&(condEnd[0]),3,
&(pfixExpr[0]));
}
_SFD_CV_INIT_EML(5,0,0,1,0,0,0,0,0,2,1);
_SFD_CV_INIT_EML_IF(5,0,0,0,22,0,22);
{
static int condStart[] = { 0, 14 };
static int condEnd[] = { 13, 22 };
static int pfixExpr[] = { 0, 1, -3 };
_SFD_CV_INIT_EML_MCDC(5,0,0,0,22,2,0,&(condStart[0]),&(condEnd[0]),3,
&(pfixExpr[0]));
}
_SFD_SET_DATA_COMPILED_PROPS(0,SF_DOUBLE,0,NULL,0,0,0,0.0,1.0,0,0,
(MexFcnForType)c1_sf_marshallOut,(MexInFcnForType)NULL);
{
unsigned int dimVector[2];
dimVector[0]= 256;
dimVector[1]= 1;
_SFD_SET_DATA_COMPILED_PROPS(1,SF_DOUBLE,2,&(dimVector[0]),0,0,0,0.0,
1.0,0,0,(MexFcnForType)c1_k_sf_marshallOut,(MexInFcnForType)
c1_g_sf_marshallIn);
}
_SFD_SET_DATA_VALUE_PTR(1,(void *)(NULL));
{
real_T *c1_moved;
c1_moved = (real_T *)ssGetInputPortSignal(chartInstance->S, 0);
_SFD_SET_DATA_VALUE_PTR(0U, c1_moved);
}
}
} else {
sf_debug_reset_current_state_configuration(sfGlobalDebugInstanceStruct,
_testPersonaliSpace_KinectMachineNumber_,chartInstance->chartNumber,
chartInstance->instanceNumber);
}
}
}
static const char* sf_get_instance_specialization(void)
{
return "qRzlKPBYSqB3KYmTjRUHDF";
}
static void sf_opaque_initialize_c1_testPersonaliSpace_Kinect(void
*chartInstanceVar)
{
chart_debug_initialization(((SFc1_testPersonaliSpace_KinectInstanceStruct*)
chartInstanceVar)->S,0);
initialize_params_c1_testPersonaliSpace_Kinect
((SFc1_testPersonaliSpace_KinectInstanceStruct*) chartInstanceVar);
initialize_c1_testPersonaliSpace_Kinect
((SFc1_testPersonaliSpace_KinectInstanceStruct*) chartInstanceVar);
}
static void sf_opaque_enable_c1_testPersonaliSpace_Kinect(void *chartInstanceVar)
{
enable_c1_testPersonaliSpace_Kinect
((SFc1_testPersonaliSpace_KinectInstanceStruct*) chartInstanceVar);
}
static void sf_opaque_disable_c1_testPersonaliSpace_Kinect(void
*chartInstanceVar)
{
disable_c1_testPersonaliSpace_Kinect
((SFc1_testPersonaliSpace_KinectInstanceStruct*) chartInstanceVar);
}
static void sf_opaque_gateway_c1_testPersonaliSpace_Kinect(void
*chartInstanceVar)
{
sf_gateway_c1_testPersonaliSpace_Kinect
((SFc1_testPersonaliSpace_KinectInstanceStruct*) chartInstanceVar);
}
extern const mxArray* sf_internal_get_sim_state_c1_testPersonaliSpace_Kinect
(SimStruct* S)
{
ChartRunTimeInfo * crtInfo = (ChartRunTimeInfo *)(ssGetUserData(S));
ChartInfoStruct * chartInfo = (ChartInfoStruct *)(crtInfo->instanceInfo);
mxArray *plhs[1] = { NULL };
mxArray *prhs[4];
int mxError = 0;
prhs[0] = mxCreateString("chart_simctx_raw2high");
prhs[1] = mxCreateDoubleScalar(ssGetSFuncBlockHandle(S));
prhs[2] = (mxArray*) get_sim_state_c1_testPersonaliSpace_Kinect
((SFc1_testPersonaliSpace_KinectInstanceStruct*)chartInfo->chartInstance);/* raw sim ctx */
prhs[3] = (mxArray*) sf_get_sim_state_info_c1_testPersonaliSpace_Kinect();/* state var info */
mxError = sf_mex_call_matlab(1, plhs, 4, prhs, "sfprivate");
mxDestroyArray(prhs[0]);
mxDestroyArray(prhs[1]);
mxDestroyArray(prhs[2]);
mxDestroyArray(prhs[3]);
if (mxError || plhs[0] == NULL) {
sf_mex_error_message("Stateflow Internal Error: \nError calling 'chart_simctx_raw2high'.\n");
}
return plhs[0];
}
extern void sf_internal_set_sim_state_c1_testPersonaliSpace_Kinect(SimStruct* S,
const mxArray *st)
{
ChartRunTimeInfo * crtInfo = (ChartRunTimeInfo *)(ssGetUserData(S));
ChartInfoStruct * chartInfo = (ChartInfoStruct *)(crtInfo->instanceInfo);
mxArray *plhs[1] = { NULL };
mxArray *prhs[3];
int mxError = 0;
prhs[0] = mxCreateString("chart_simctx_high2raw");
prhs[1] = mxDuplicateArray(st); /* high level simctx */
prhs[2] = (mxArray*) sf_get_sim_state_info_c1_testPersonaliSpace_Kinect();/* state var info */
mxError = sf_mex_call_matlab(1, plhs, 3, prhs, "sfprivate");
mxDestroyArray(prhs[0]);
mxDestroyArray(prhs[1]);
mxDestroyArray(prhs[2]);
if (mxError || plhs[0] == NULL) {
sf_mex_error_message("Stateflow Internal Error: \nError calling 'chart_simctx_high2raw'.\n");
}
set_sim_state_c1_testPersonaliSpace_Kinect
((SFc1_testPersonaliSpace_KinectInstanceStruct*)chartInfo->chartInstance,
mxDuplicateArray(plhs[0]));
mxDestroyArray(plhs[0]);
}
static const mxArray* sf_opaque_get_sim_state_c1_testPersonaliSpace_Kinect
(SimStruct* S)
{
return sf_internal_get_sim_state_c1_testPersonaliSpace_Kinect(S);
}
static void sf_opaque_set_sim_state_c1_testPersonaliSpace_Kinect(SimStruct* S,
const mxArray *st)
{
sf_internal_set_sim_state_c1_testPersonaliSpace_Kinect(S, st);
}
static void sf_opaque_terminate_c1_testPersonaliSpace_Kinect(void
*chartInstanceVar)
{
if (chartInstanceVar!=NULL) {
SimStruct *S = ((SFc1_testPersonaliSpace_KinectInstanceStruct*)
chartInstanceVar)->S;
ChartRunTimeInfo * crtInfo = (ChartRunTimeInfo *)(ssGetUserData(S));
if (sim_mode_is_rtw_gen(S) || sim_mode_is_external(S)) {
sf_clear_rtw_identifier(S);
unload_testPersonaliSpace_Kinect_optimization_info();
}
finalize_c1_testPersonaliSpace_Kinect
((SFc1_testPersonaliSpace_KinectInstanceStruct*) chartInstanceVar);
utFree((void *)chartInstanceVar);
if (crtInfo != NULL) {
utFree((void *)crtInfo);
}
ssSetUserData(S,NULL);
}
}
static void sf_opaque_init_subchart_simstructs(void *chartInstanceVar)
{
initSimStructsc1_testPersonaliSpace_Kinect
((SFc1_testPersonaliSpace_KinectInstanceStruct*) chartInstanceVar);
}
extern unsigned int sf_machine_global_initializer_called(void);
static void mdlProcessParameters_c1_testPersonaliSpace_Kinect(SimStruct *S)
{
int i;
for (i=0;i<ssGetNumRunTimeParams(S);i++) {
if (ssGetSFcnParamTunable(S,i)) {
ssUpdateDlgParamAsRunTimeParam(S,i);
}
}
if (sf_machine_global_initializer_called()) {
ChartRunTimeInfo * crtInfo = (ChartRunTimeInfo *)(ssGetUserData(S));
ChartInfoStruct * chartInfo = (ChartInfoStruct *)(crtInfo->instanceInfo);
initialize_params_c1_testPersonaliSpace_Kinect
((SFc1_testPersonaliSpace_KinectInstanceStruct*)(chartInfo->chartInstance));
}
}
static void mdlSetWorkWidths_c1_testPersonaliSpace_Kinect(SimStruct *S)
{
if (sim_mode_is_rtw_gen(S) || sim_mode_is_external(S)) {
mxArray *infoStruct = load_testPersonaliSpace_Kinect_optimization_info();
int_T chartIsInlinable =
(int_T)sf_is_chart_inlinable(sf_get_instance_specialization(),infoStruct,1);
ssSetStateflowIsInlinable(S,chartIsInlinable);
ssSetRTWCG(S,sf_rtw_info_uint_prop(sf_get_instance_specialization(),
infoStruct,1,"RTWCG"));
ssSetEnableFcnIsTrivial(S,1);
ssSetDisableFcnIsTrivial(S,1);
ssSetNotMultipleInlinable(S,sf_rtw_info_uint_prop
(sf_get_instance_specialization(),infoStruct,1,
"gatewayCannotBeInlinedMultipleTimes"));
sf_update_buildInfo(sf_get_instance_specialization(),infoStruct,1);
sf_mark_output_events_with_multiple_callers(S,sf_get_instance_specialization
(),infoStruct,1,1);
if (chartIsInlinable) {
ssSetInputPortOptimOpts(S, 0, SS_REUSABLE_AND_LOCAL);
sf_mark_chart_expressionable_inputs(S,sf_get_instance_specialization(),
infoStruct,1,1);
}
ssSetInputPortOptimOpts(S, 1, SS_REUSABLE_AND_LOCAL);
{
unsigned int outPortIdx;
for (outPortIdx=1; outPortIdx<=1; ++outPortIdx) {
ssSetOutputPortOptimizeInIR(S, outPortIdx, 1U);
}
}
{
unsigned int inPortIdx;
for (inPortIdx=0; inPortIdx < 1; ++inPortIdx) {
ssSetInputPortOptimizeInIR(S, inPortIdx, 1U);
}
}
sf_set_rtw_dwork_info(S,sf_get_instance_specialization(),infoStruct,1);
ssSetHasSubFunctions(S,!(chartIsInlinable));
} else {
}
ssSetOptions(S,ssGetOptions(S)|SS_OPTION_WORKS_WITH_CODE_REUSE);
ssSetChecksum0(S,(962411050U));
ssSetChecksum1(S,(206664953U));
ssSetChecksum2(S,(3207438561U));
ssSetChecksum3(S,(4096209559U));
ssSetmdlDerivatives(S, NULL);
ssSetExplicitFCSSCtrl(S,1);
ssSupportsMultipleExecInstances(S,1);
}
static void mdlRTW_c1_testPersonaliSpace_Kinect(SimStruct *S)
{
if (sim_mode_is_rtw_gen(S)) {
ssWriteRTWStrParam(S, "StateflowChartType", "Stateflow");
}
}
static void mdlStart_c1_testPersonaliSpace_Kinect(SimStruct *S)
{
SFc1_testPersonaliSpace_KinectInstanceStruct *chartInstance;
ChartRunTimeInfo * crtInfo = (ChartRunTimeInfo *)utMalloc(sizeof
(ChartRunTimeInfo));
chartInstance = (SFc1_testPersonaliSpace_KinectInstanceStruct *)utMalloc
(sizeof(SFc1_testPersonaliSpace_KinectInstanceStruct));
memset(chartInstance, 0, sizeof(SFc1_testPersonaliSpace_KinectInstanceStruct));
if (chartInstance==NULL) {
sf_mex_error_message("Could not allocate memory for chart instance.");
}
chartInstance->chartInfo.chartInstance = chartInstance;
chartInstance->chartInfo.isEMLChart = 0;
chartInstance->chartInfo.chartInitialized = 0;
chartInstance->chartInfo.sFunctionGateway =
sf_opaque_gateway_c1_testPersonaliSpace_Kinect;
chartInstance->chartInfo.initializeChart =
sf_opaque_initialize_c1_testPersonaliSpace_Kinect;
chartInstance->chartInfo.terminateChart =
sf_opaque_terminate_c1_testPersonaliSpace_Kinect;
chartInstance->chartInfo.enableChart =
sf_opaque_enable_c1_testPersonaliSpace_Kinect;
chartInstance->chartInfo.disableChart =
sf_opaque_disable_c1_testPersonaliSpace_Kinect;
chartInstance->chartInfo.getSimState =
sf_opaque_get_sim_state_c1_testPersonaliSpace_Kinect;
chartInstance->chartInfo.setSimState =
sf_opaque_set_sim_state_c1_testPersonaliSpace_Kinect;
chartInstance->chartInfo.getSimStateInfo =
sf_get_sim_state_info_c1_testPersonaliSpace_Kinect;
chartInstance->chartInfo.zeroCrossings = NULL;
chartInstance->chartInfo.outputs = NULL;
chartInstance->chartInfo.derivatives = NULL;
chartInstance->chartInfo.mdlRTW = mdlRTW_c1_testPersonaliSpace_Kinect;
chartInstance->chartInfo.mdlStart = mdlStart_c1_testPersonaliSpace_Kinect;
chartInstance->chartInfo.mdlSetWorkWidths =
mdlSetWorkWidths_c1_testPersonaliSpace_Kinect;
chartInstance->chartInfo.extModeExec = NULL;
chartInstance->chartInfo.restoreLastMajorStepConfiguration = NULL;
chartInstance->chartInfo.restoreBeforeLastMajorStepConfiguration = NULL;
chartInstance->chartInfo.storeCurrentConfiguration = NULL;
chartInstance->chartInfo.debugInstance = sfGlobalDebugInstanceStruct;
chartInstance->S = S;
crtInfo->instanceInfo = (&(chartInstance->chartInfo));
crtInfo->isJITEnabled = false;
ssSetUserData(S,(void *)(crtInfo)); /* register the chart instance with simstruct */
init_dsm_address_info(chartInstance);
if (!sim_mode_is_rtw_gen(S)) {
}
sf_opaque_init_subchart_simstructs(chartInstance->chartInfo.chartInstance);
chart_debug_initialization(S,1);
}
void c1_testPersonaliSpace_Kinect_method_dispatcher(SimStruct *S, int_T method,
void *data)
{
switch (method) {
case SS_CALL_MDL_START:
mdlStart_c1_testPersonaliSpace_Kinect(S);
break;
case SS_CALL_MDL_SET_WORK_WIDTHS:
mdlSetWorkWidths_c1_testPersonaliSpace_Kinect(S);
break;
case SS_CALL_MDL_PROCESS_PARAMETERS:
mdlProcessParameters_c1_testPersonaliSpace_Kinect(S);
break;
default:
/* Unhandled method */
sf_mex_error_message("Stateflow Internal Error:\n"
"Error calling c1_testPersonaliSpace_Kinect_method_dispatcher.\n"
"Can't handle method %d.\n", method);
break;
}
}
| 37.535745 | 236 | 0.686077 | [
"model"
] |
7a0a1d849796dd3921ac26157e5dc3340dc7b2c0 | 278 | c | C | src/game_engine/text/display_text.c | Mikatech/my_rpg | 89d4d8ee362aeb247ad328cada032b01cb83f782 | [
"MIT"
] | 7 | 2021-07-05T20:19:50.000Z | 2021-10-15T12:29:49.000Z | src/game_engine/text/display_text.c | Davphla/my_rpg | 89d4d8ee362aeb247ad328cada032b01cb83f782 | [
"MIT"
] | null | null | null | src/game_engine/text/display_text.c | Davphla/my_rpg | 89d4d8ee362aeb247ad328cada032b01cb83f782 | [
"MIT"
] | 1 | 2021-07-05T20:46:04.000Z | 2021-07-05T20:46:04.000Z | /*
** EPITECH PROJECT, 2021
** my_rpg
** File description:
** display object
*/
#include "rpg.h"
void display_text(head_t *head, text_t *first)
{
while (first != NULL) {
sfRenderWindow_drawText(head->window, first->text, NULL);
first = first->next;
}
} | 17.375 | 65 | 0.625899 | [
"object"
] |
7a0fcd804134d96dc5c8a1f17ace1397f95594df | 1,721 | h | C | include/pga/rendering/Configuration.h | LucvandenBrand/OperatorGraph | a15f2c9acfc9265e5ed5cbd89a8d3f7f638cb565 | [
"MIT"
] | null | null | null | include/pga/rendering/Configuration.h | LucvandenBrand/OperatorGraph | a15f2c9acfc9265e5ed5cbd89a8d3f7f638cb565 | [
"MIT"
] | null | null | null | include/pga/rendering/Configuration.h | LucvandenBrand/OperatorGraph | a15f2c9acfc9265e5ed5cbd89a8d3f7f638cb565 | [
"MIT"
] | null | null | null | #pragma once
#include <vector>
#include <map>
#include <string>
#include <math/vector.h>
namespace PGA
{
namespace Rendering
{
class Configuration
{
public:
struct Material
{
unsigned int type;
bool backFaceCulling;
int blendMode;
std::map<std::string, std::string> attributes;
Material() : type(0), backFaceCulling(true), blendMode(-1) {}
std::string getAttribute(const std::string& attributeName) const;
float getFloatAttribute(const std::string& attributeName) const;
math::float2 getFloat2Attribute(const std::string& attributeName) const;
math::float4 getFloat4Attribute(const std::string& attributeName) const;
bool hasAttribute(const std::string& attributeName) const;
};
struct Buffer
{
std::string name;
int materialRef;
Buffer() : name(""), materialRef(-1) {}
};
struct TriangleMesh : Buffer
{
unsigned int maxNumVertices;
unsigned int maxNumIndices;
TriangleMesh() : maxNumVertices(0), maxNumIndices(0) {}
};
struct InstancedTriangleMesh : Buffer
{
enum Type
{
SHAPE,
OBJ
};
unsigned int maxNumElements;
Type type;
std::string shape;
std::string modelPath;
std::vector<math::float2> vertices;
InstancedTriangleMesh() : maxNumElements(0), shape("Box"), modelPath("") {}
};
std::string modelRootPath;
std::string textureRootPath;
std::map<unsigned int, TriangleMesh> triangleMeshes;
std::map<unsigned int, InstancedTriangleMesh> instancedTriangleMeshes;
std::map<int, Material> materials;
void reset();
void loadFromString(const std::string& xmlString);
void loadFromDisk(const std::string& fileName);
};
}
} | 20.247059 | 79 | 0.675189 | [
"shape",
"vector"
] |
7a225a15d78743dc44d5653b1897d308bb5a3f45 | 701 | h | C | src/propertyFactory/CleanUpPaths.h | toebs88/SCAM | 0b5a8f1c57593da40e85d0b8ce6a6cf5616379ca | [
"MIT"
] | 3 | 2018-08-31T21:35:27.000Z | 2018-10-29T04:06:46.000Z | src/propertyFactory/CleanUpPaths.h | toebs88/SCAM | 0b5a8f1c57593da40e85d0b8ce6a6cf5616379ca | [
"MIT"
] | 1 | 2018-04-20T12:38:22.000Z | 2018-04-20T12:38:55.000Z | src/propertyFactory/CleanUpPaths.h | toebs88/SCAM | 0b5a8f1c57593da40e85d0b8ce6a6cf5616379ca | [
"MIT"
] | null | null | null | //
// Created by ludwig on 01.08.16.
//
#ifndef SCAM_MERGEPATHS_H
#define SCAM_MERGEPATHS_H
#include "Path.h"
#include "ExprTranslator.h"
#include "z3++.h"
#include <PrintStmt.h>
namespace SCAM {
/**
* \brief Contains methods for removing paths
*/
typedef std::map<std::string, std::vector<SCAM::Path *>> SectionPathMap;
class CleanUpPaths {
public:
CleanUpPaths();
static const SectionPathMap deleteDuplicatedPaths(const SCAM::SectionPathMap& sectionPathMap);
static const SectionPathMap deleteUnreachablePaths(const SectionPathMap& sectionPathMap) ;
static const bool isPathUnreachable(Path * p);
};
}
#endif //SCAM_MERGEPATHS_H
| 22.612903 | 102 | 0.697575 | [
"vector"
] |
7a38154e4908a7a05a7c061501315ec0d90b62ab | 2,262 | h | C | arl-hourglass/arl-hourglass/MargolusNeighborhoodSimulatorOpenCL.h | bernhardrieder/Hourglass-Simulation | 737c756fc283859bb89d9c670b67a0be7aa979d6 | [
"Unlicense"
] | null | null | null | arl-hourglass/arl-hourglass/MargolusNeighborhoodSimulatorOpenCL.h | bernhardrieder/Hourglass-Simulation | 737c756fc283859bb89d9c670b67a0be7aa979d6 | [
"Unlicense"
] | null | null | null | arl-hourglass/arl-hourglass/MargolusNeighborhoodSimulatorOpenCL.h | bernhardrieder/Hourglass-Simulation | 737c756fc283859bb89d9c670b67a0be7aa979d6 | [
"Unlicense"
] | null | null | null | #pragma once
#include <CL/cl.hpp>
#include <SFML/Graphics.hpp>
class MargolusNeighborhoodSimulatorOpenCL
{
public:
MargolusNeighborhoodSimulatorOpenCL() = delete;
MargolusNeighborhoodSimulatorOpenCL(bool useGpu, int platformId, int deviceId);
~MargolusNeighborhoodSimulatorOpenCL();
void Initialize(const sf::Vector2u& imgSize, const char ruleLUT[16], const bool changesAvailableLUT[16], const sf::Color& particleColor, const sf::Color& obstacleColor, const sf::Color& idleColor);
void ApplyMargolusRules(sf::Uint8* pixelptr, const sf::Vector2u& imgSize, const unsigned& pixelOffset, const bool& refreshImageBuffer);
private:
const std::string m_sourceCodeFile = "kernel.cl";
cl::Program m_program;
cl::Platform m_usedPlatform;
cl::Device m_device;
cl::Context m_context;
cl::Kernel m_kernelSimpleGeneration;
cl::CommandQueue m_queue;
cl::Buffer m_bufferData;
cl::Buffer m_bufferDimensionX;
cl::Buffer m_bufferDimensionY;
cl::Buffer m_bufferPixelOffset;
cl::Buffer m_bufferRulesLUT;
cl::Buffer m_bufferChangesAvailableLUT;
cl::Buffer m_bufferParticleColor;
cl::Buffer m_bufferObstacleColor;
cl::Buffer m_bufferIdleColor;
cl::Buffer m_bufferRandomNumbers;
int m_deviceMaxWorkGroupSize;
cl::NDRange m_globalRange;
cl::NDRange m_localRange;
sf::Vector2u m_dataSize;
int m_sizeOfImage;
int m_randomNumbers[2];
void createKernel(const sf::Vector2u& imgSize, const char ruleLUT[16], const bool changesAvailableLUT[16], const sf::Color& particleColor, const sf::Color& obstacleColor, const sf::Color& idleColor);
std::vector<cl::Platform> getPlatforms() const;
void getDevice(bool useGpu, int platformId, int deviceId);
void createContext(const cl::Device& device);
void createProgram(const cl::Context& context, const std::string& sourceCodeFile);
void createCommandQueue(const cl::Context& context, const cl::Device& device);
cl::Device getDevice(const std::vector<cl::Platform>& platforms, int platformId, int deviceId);
cl::Device getDevice(const std::vector<cl::Platform>& platforms, int cl_device_type);
static void debugDeviceOutput(const cl::Device& device);
cl::Kernel createKernel(const std::string& functionName) const;
static std::string cl_errorstring(cl_int err);
static void handle_clerror(cl_int err);
};
| 39.684211 | 200 | 0.788683 | [
"vector"
] |
7a3a7bdf2fb50be711dff71264a518c90eb75b7b | 1,191 | c | C | 2IMA/OpenMP/BE2015/ConjugateGradient/kernels.c | LagOussama/enseeiht | d3247880c66cd3754d0bd29781ab1ddec9f6536f | [
"FTL"
] | 1 | 2021-02-26T11:38:34.000Z | 2021-02-26T11:38:34.000Z | 2IMA/OpenMP/BE2015/ConjugateGradient/kernels.c | LagOussama/enseeiht | d3247880c66cd3754d0bd29781ab1ddec9f6536f | [
"FTL"
] | null | null | null | 2IMA/OpenMP/BE2015/ConjugateGradient/kernels.c | LagOussama/enseeiht | d3247880c66cd3754d0bd29781ab1ddec9f6536f | [
"FTL"
] | 1 | 2021-04-10T11:39:01.000Z | 2021-04-10T11:39:01.000Z | #include <math.h>
/* This routine computes the 2-norm of a vector */
double norm2(int n, double *x){
int i;
double res;
res = 0.0;
for(i=0; i<n; i++)
res += x[i]*x[i];
res = sqrt(res);
return res;
}
/* This routine computes the dot-product of two vectors */
double dot(int n, double *x, double *y){
int i;
double res;
res = 0.0;
for(i=0; i<n; i++)
res += x[i]*y[i];
return res;
}
/* This routine computes the product of a sparse matrix A of size m
times a vector x and stores the result in a vector y :
y = alpha*A*x + beta*y */
void spmv(int n, int *rowptr, int *colind, double *val, double alpha, double *x, double beta, double *y){
int i, j;
for(i=0; i<n; i++){
/* for each row... */
y[i] = beta*y[i];
for(j=rowptr[i]; j<rowptr[i+1]; j++){
/* for each coefficient in the row... */
y[i] += alpha*val[j]*x[colind[j]];
}
}
return;
}
/* This routine computes the sum of two vectors x and y of size m and
stores the result in y
y = beta*y + alpha*x */
void axpby(int n, double alpha, double *x, double beta, double *y){
int i;
for(i=0; i<n; i++)
y[i] = beta*y[i]+alpha*x[i];
}
| 17.776119 | 105 | 0.566751 | [
"vector"
] |
7a4cd471e689192005901a33a55409b337a7b1a0 | 3,460 | h | C | release/src/router/vsftpd/ftpdataio.h | ghsecuritylab/tomato_egg | 50473a46347f4631eb4878a0f47955cc64c87293 | [
"FSFAP"
] | 278 | 2015-11-03T03:01:20.000Z | 2022-01-20T18:21:05.000Z | release/src/router/vsftpd/ftpdataio.h | ghsecuritylab/tomato_egg | 50473a46347f4631eb4878a0f47955cc64c87293 | [
"FSFAP"
] | 374 | 2015-11-03T12:37:22.000Z | 2021-12-17T14:18:08.000Z | release/src/router/vsftpd/ftpdataio.h | ghsecuritylab/tomato_egg | 50473a46347f4631eb4878a0f47955cc64c87293 | [
"FSFAP"
] | 96 | 2015-11-22T07:47:26.000Z | 2022-01-20T19:52:19.000Z | #ifndef VSF_FTPDATAIO_H
#define VSF_FTPDATAIO_H
#include "filesize.h"
struct mystr;
struct vsf_sysutil_sockaddr;
struct vsf_sysutil_dir;
struct vsf_session;
/* vsf_ftpdataio_dispose_transfer_fd()
* PURPOSE
* Close down the remote data transfer file descriptor. If unsent data reamins
* on the connection, this method blocks until it is transferred (or the data
* timeout goes off, or the connection is severed).
* PARAMETERS
* p_sess - the current FTP session object
* RETURNS
* 1 on success, 0 otherwise.
*
*/
int vsf_ftpdataio_dispose_transfer_fd(struct vsf_session* p_sess);
/* vsf_ftpdataio_get_pasv_fd()
* PURPOSE
* Return a connection data file descriptor obtained by the PASV connection
* method. This includes accept()'ing a connection from the remote.
* PARAMETERS
* p_sess - the current FTP session object
* RETURNS
* The file descriptor upon success, or -1 upon error.
*/
int vsf_ftpdataio_get_pasv_fd(struct vsf_session* p_sess);
/* vsf_ftpdataio_get_pasv_fd()
* PURPOSE
* Return a connection data file descriptor obtained by the PORT connection
* method. This includes connect()'ing to the remote.
* PARAMETERS
* p_sess - the current FTP session object
* RETURNS
* The file descriptor upon success, or -1 upon error.
*/
int vsf_ftpdataio_get_port_fd(struct vsf_session* p_sess);
/* vsf_ftpdataio_post_mark_connect()
* PURPOSE
* Perform any post-150-status-mark setup on the data connection. For example,
* the negotiation of SSL.
* PARAMETERS
* p_sess - the current FTP session object
* RETURNS
* 1 on success, 0 otherwise.
*/
int vsf_ftpdataio_post_mark_connect(struct vsf_session* p_sess);
/* vsf_ftpdataio_transfer_file()
* PURPOSE
* Send data between the network and a local file. Send and receive are
* supported, as well as ASCII mangling.
* PARAMETERS
* remote_fd - the file descriptor of the remote data connection
* file_fd - the file descriptor of the local file
* is_recv - 0 for sending to the remote, otherwise receive
* is_ascii - non zero for ASCII mangling
* RETURNS
* A structure, containing
* retval - 0 for success, failure otherwise
* (-1 = local problem -2 = remote problem)
* transferred - number of bytes transferred
*/
struct vsf_transfer_ret
{
int retval;
filesize_t transferred;
};
struct vsf_transfer_ret vsf_ftpdataio_transfer_file(
struct vsf_session* p_sess,
int remote_fd, int file_fd, int is_recv, int is_ascii);
/* vsf_ftpdataio_transfer_dir()
* PURPOSE
* Send an ASCII directory lising of the requested directory to the remote
* client.
* PARAMETERS
* p_sess - the current session object
* is_control - whether to send on the control connection or data connection
* p_dir - the local directory object
* p_base_dir_str - the directory we opened relative to the current one
* p_option_str - the options list provided to "ls"
* p_filter_str - the filter string provided to "ls"
* is_verbose - set to 0 if NLST used, 1 if LIST used
*/
int vsf_ftpdataio_transfer_dir(struct vsf_session* p_sess, int is_control,
struct vsf_sysutil_dir* p_dir,
const struct mystr* p_base_dir_str,
const struct mystr* p_option_str,
const struct mystr* p_filter_str,
int is_verbose);
#endif /* VSF_FTPDATAIO_H */
| 33.592233 | 80 | 0.709538 | [
"object"
] |
7a53b911ad2eab75c76f80ac827e4508998c3b3f | 5,918 | h | C | ObitSystem/ObitSD/include/ObitOTFUtil.h | sarrvesh/Obit | e4ce6029e9beb2a8c0316ee81ea710b66b2b7986 | [
"Linux-OpenIB"
] | 5 | 2019-08-26T06:53:08.000Z | 2020-10-20T01:08:59.000Z | ObitSystem/ObitSD/include/ObitOTFUtil.h | sarrvesh/Obit | e4ce6029e9beb2a8c0316ee81ea710b66b2b7986 | [
"Linux-OpenIB"
] | null | null | null | ObitSystem/ObitSD/include/ObitOTFUtil.h | sarrvesh/Obit | e4ce6029e9beb2a8c0316ee81ea710b66b2b7986 | [
"Linux-OpenIB"
] | 8 | 2017-08-29T15:12:32.000Z | 2022-03-31T12:16:08.000Z | /* $Id$ */
/*--------------------------------------------------------------------*/
/*; Copyright (C) 2003-2009 */
/*; Associated Universities, Inc. Washington DC, USA. */
/*; */
/*; This program is free software; you can redistribute it and/or */
/*; modify it under the terms of the GNU General Public License as */
/*; published by the Free Software Foundation; either version 2 of */
/*; the License, or (at your option) any later version. */
/*; */
/*; This program is distributed in the hope that it will be useful, */
/*; but WITHOUT ANY WARRANTY; without even the implied warranty of */
/*; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/*; GNU General Public License for more details. */
/*; */
/*; You should have received a copy of the GNU General Public */
/*; License along with this program; if not, write to the Free */
/*; Software Foundation, Inc., 675 Massachusetts Ave, Cambridge, */
/*; MA 02139, USA. */
/*; */
/*;Correspondence about this software should be addressed as follows: */
/*; Internet email: bcotton@nrao.edu. */
/*; Postal address: William Cotton */
/*; National Radio Astronomy Observatory */
/*; 520 Edgemont Road */
/*; Charlottesville, VA 22903-2475 USA */
/*--------------------------------------------------------------------*/
#ifndef OBITOTFUTIL_H
#define OBITOTFUTIL_H
#include "Obit.h"
#include "ObitErr.h"
#include "ObitThread.h"
#include "ObitInfoList.h"
#include "ObitIO.h"
#include "ObitImage.h"
#include "ObitOTF.h"
#include "ObitOTFArrayGeom.h"
#include "ObitOTFSkyModel.h"
#include "ObitOTFGrid.h"
#include "ObitFInterpolate.h"
#include "ObitTableCC.h"
#include "ObitTableOTFSoln.h"
/*-------- Obit: Merx mollis mortibus nuper ------------------*/
/**
* \file ObitOTFUtil.h
* Utility routines for the ObitOTF class.
*
* \section ObitOTFUtilparameters Control Parameters
* The imaging control parameters are passed through the info object
* on the OTF data, these control both the output image files and the
* processing parameters.
* OTF Data selection/calibration/editing control
* \li "doCalSelect" OBIT_bool (1,1,1) Select/calibrate/edit data?
* \li "doCalib" OBIT_int (1,1,1) >0 -> calibrate,
* \li "gainUse" OBIT_int (1,1,1) SN/CL table version number, 0-> use highest
* \li "flagVer" OBIT_int (1,1,1) Flag table version, 0-> use highest, <0-> none
* \li "Stokes" OBIT_string (4,1,1) Selected output Stokes parameters:
* "I", "V", " " -> "I"
* \li "BChan" OBIT_int (1,1,1) First spectral channel selected. [def all]
* \li "EChan" OBIT_int (1,1,1) Highest spectral channel selected. [def all]
* \li "Targets" OBIT_string (?,?,1) Target names selected. [def all]
* \li "timeRange" OBIT_float (2,1,1) Selected timerange in days. [def all]
* \li "Scans" OBIT_int (2,1,1) Lowest and highest selected scan numbers. [def all]
* \li "Feeds" OBIT_int (?,1,1) a list of selected feed numbers, [def all.]
*
* Gridding/imaging parameters
* \li "minWt" OBIT_float (1,1,1) Minimum summed gridding convolution weight
* as a fraction of the maximum [def 0.01]
*/
/*---------------Public functions---------------------------*/
/** Public: Subtract an image (ObitFarray) from an ObitOTF. */
void ObitOTFUtilSubImage(ObitOTF *inOTF, ObitOTF *outOTF, ObitFArray *image,
ObitImageDesc *desc, ObitErr *err);
/** Public: Replace data with an image (ObitFarray) model. */
void ObitOTFUtilModelImage(ObitOTF *inOTF, ObitOTF *outOTF, ObitFArray *image,
ObitImageDesc *desc, ObitErr *err);
/** Public: Scale an OTF data set. */
void ObitOTFUtilScale(ObitOTF *inOTF, ObitOTF *outOTF, ofloat scale, ofloat offset,
ObitErr *err);
/** Public: Scale and add Gaussian noise to an OTF data set. */
void ObitOTFUtilNoise(ObitOTF *inOTF, ObitOTF *outOTF, ofloat scale, ofloat offset,
ofloat sigma, ObitErr *err);
/** Public: Replace data with a sky model in a buffer of data. */
void ObitOTFUtilModelImageBuff (ObitOTF *in, ObitFInterpolate *image, ofloat factor,
ObitErr *err);
/** Public: Subtract a sky model from a buffer of data. */
void ObitOTFUtilSubSkyModelBuff (ObitOTF *in, ObitOTFSkyModel *sky, ofloat factor);
/** Public: Create an Image Object from an OTF */
ObitImage* ObitOTFUtilCreateImage (ObitOTF *inOTF, ObitErr *err);
/** Public: Convert an OTF to an image Object */
void ObitOTFUtilMakeImage (ObitOTF *inOTF, ObitImage *outImage, gboolean doBeam,
ObitImage *Beam, ObitImage *Wt, ObitErr *err);
/** Public:Index an OTF */
void ObitOTFUtilIndex (ObitOTF *inOTF, ObitErr *err);
/** Public: Get on-off differences in a nodding scan */
void ObitOTFUtilDiffNod (ObitOTF *inOTF, olong scan, ObitErr *err);
/** Public:Create image cube */
void
ObitOTFUtilMakeCube (ObitImageDesc *inDesc, ObitOTFDesc *OTFDesc,
ObitImageDesc *outDesc,
gchar *Stokes, olong bchan, olong echan, olong incr, ObitErr *err);
/** Public: Utility to convolve CCs with a beam */
ObitFArray* ObitOTFUtilConvBeam (ObitTableCC *CCTab, ObitImage *Beam,
ObitFArray *Template, ObitErr *err);
/** Public: Residual calibration */
ObitTableOTFSoln* ObitOTFUtilResidCal (ObitOTF *inOTF, ObitOTF *outOTF,
ObitImage *model, gboolean doModel,
ObitImage *PSF, ObitErr *err);
#endif /* OBITOTFUTIL_H */
| 47.725806 | 85 | 0.602906 | [
"object",
"model"
] |
7a6616acd3a59576b23e8ae08f56dbfda17e5f80 | 1,591 | h | C | src/framebuffer/framebuffer.h | onc/oncgl | 521de02321b612e1741a9f3bc6ee6c1a5ae2950b | [
"Apache-2.0"
] | 2 | 2015-05-11T18:52:33.000Z | 2015-05-19T17:15:31.000Z | src/framebuffer/framebuffer.h | onc/oncgl | 521de02321b612e1741a9f3bc6ee6c1a5ae2950b | [
"Apache-2.0"
] | null | null | null | src/framebuffer/framebuffer.h | onc/oncgl | 521de02321b612e1741a9f3bc6ee6c1a5ae2950b | [
"Apache-2.0"
] | null | null | null | #ifndef ONCGL_FRAMEBUFFER_FRAMEBUFFER_H
#define ONCGL_FRAMEBUFFER_FRAMEBUFFER_H
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <GL/glew.h>
#include "misc/constants.h"
#define ZERO_MEM(a) memset(a, 0, sizeof(a))
#define ARRAY_SIZE_IN_ELEMENTS(a) (sizeof(a)/sizeof(a[0]))
namespace oncgl {
class FrameBuffer {
public:
// Enum for the buffertypes
enum FRAMEBUFFER_TEXTURE_TYPE {
FRAMEBUFFER_TEXTURE_TYPE_POSITION,
FRAMEBUFFER_TEXTURE_TYPE_DIFFUSE,
FRAMEBUFFER_TEXTURE_TYPE_NORMAL,
FRAMEBUFFER_NUM_TEXTURES
};
FrameBuffer();
~FrameBuffer();
/**
* Initialize the framebuffer with given width and height
*
* @param window_width (pixel) width of framebuffer
* @param window_height (pixel) height of framebuffer
* @returns true - if framebuffer is created successfully, otherwise false
*/
bool Init(GLuint window_width, GLuint window_height);
/**
* Bind the framebuffer
*/
void StartFrame();
/**
* Bind the framebuffer for the geometry-pass
*/
void BindForGeometryPass();
/**
* Bind the framebuffer for the sencil-pass
*/
void BindForStencilPass();
/**
* Bind the framebuffer for the light-passes
*/
void BindForLightPass();
/**
* Bind the framebuffer for the final-rendering pass
* The final pass will draw the framebuffer to the backbuffer
*/
void BindForFinalPass();
private:
GLuint fbo_;
GLuint textures_[FRAMEBUFFER_NUM_TEXTURES];
GLuint depth_texture_;
GLuint final_texture_;
};
} // namespace oncgl
#endif // ONCGL_FRAMEBUFFER_FRAMEBUFFER_H
| 20.934211 | 76 | 0.719045 | [
"geometry"
] |
7a72ad0ab8719484ecb4564979e9cabe1c9aa239 | 430 | h | C | source/rendering/Instance.h | RaygenEngine/Raygen | 2e61afd35f594d06186c16397b536412ebf4298d | [
"MIT"
] | 2 | 2021-01-27T15:49:04.000Z | 2021-01-28T07:40:30.000Z | source/rendering/Instance.h | RaygenEngine/Raygen | 2e61afd35f594d06186c16397b536412ebf4298d | [
"MIT"
] | null | null | null | source/rendering/Instance.h | RaygenEngine/Raygen | 2e61afd35f594d06186c16397b536412ebf4298d | [
"MIT"
] | 1 | 2021-03-07T23:17:31.000Z | 2021-03-07T23:17:31.000Z | #pragma once
#include "rendering/wrappers/PhysicalDevice.h"
struct GLFWwindow;
namespace vl {
inline struct Instance_ : public vk::Instance {
vk::SurfaceKHR surface;
vk::DebugUtilsMessengerEXT debugUtilsMessenger;
std::vector<RPhysicalDevice> physicalDevices;
Instance_(const std::vector<const char*>&& requiredExtensions, GLFWwindow* window);
~Instance_();
} * Instance{};
} // namespace vl
void InitVulkanLoader();
| 19.545455 | 84 | 0.762791 | [
"vector"
] |
7a7749117079bddd89455e0d4a3bae02cd66be6e | 4,521 | h | C | include/simple_kf/kalman_filter.h | CesMak/simple_kf | d1ce3223f04fde4a0a714de19616274af35cb490 | [
"BSD-3-Clause"
] | null | null | null | include/simple_kf/kalman_filter.h | CesMak/simple_kf | d1ce3223f04fde4a0a714de19616274af35cb490 | [
"BSD-3-Clause"
] | null | null | null | include/simple_kf/kalman_filter.h | CesMak/simple_kf | d1ce3223f04fde4a0a714de19616274af35cb490 | [
"BSD-3-Clause"
] | null | null | null | /**************************************************************************//**
@author Markus Lamprecht
@date March 2019
@link www.simact.de/about_me
@Copyright (c) 2019 Markus Lamprecht. BSD
*****************************************************************************/
#ifndef KALMAN_FILTER_H__
#define KALMAN_FILTER_H__
namespace simple_kf
{
class KalmanFilter
{
public:
/**
* @brief Constructor of KalmanFilter class
* @param ball_model associated ball model which state is estimated using a Kalman filter
*/
KalmanFilter(cv::Point3d latest_detected_position, ros::Time last_observation_time);
/**
* @brief Constructor of KalmanFilter class with model selection!
* @param ball_model associated ball model which state is estimated using a Kalman filter
* @param state_size_ number of states options: [6,9]
* @param measurement_size_ number of measured states options: [3]
*/
KalmanFilter(cv::Point3d latest_detected_position, ros::Time last_observation_time, int state_size, int measurement_size);
/**
* @brief Destructor
*/
KalmanFilter();
/**
* @brief Resets state to current measurement
*/
void resetState();
/**
* @brief Updates the Measurement state[x, y, z, vx, vy, vz] vector with new measurement values
* @param position position of detected position of ball [m]
* @param stamp time stamp when detection was done
*/
void updateMeasurement(cv::Point3d position, ros::Time stamp);
/**
* @brief Performs time update on Kalman filter after transition matrix
* (and if implemented processNoiseCov) update and updates ball model
* @param dt time since last call
*/
void timeUpdateStep(double dt);
/**
* @brief Performs measurement update on Kalman filter and update ball model
*/
void correctionStep();
// Getter and setter
cv::Point3f getPredictedPosition() const { return cv::Point3f(state_.at<float>(0), state_.at<float>(1), state_.at<float>(2)); }
cv::Point3f getPredictedVelocity() const { return cv::Point3f(state_.at<float>(3), state_.at<float>(4), state_.at<float>(5)); }
cv::Point3f getPredictedAcceleration() const { return cv::Point3f(state_.at<float>(6), state_.at<float>(7), state_.at<float>(8)); }
cv::Point3f getKfPosition() const { return position_; }
cv::Point3f getKfVelocity() const { return velocity_; }
cv::Point3f getKfAcceleration() const { return acceleration_; }
int getStateSize() const { return state_size_;}
cv::Mat getErrorCovPre() const { return kf_.errorCovPre; }
cv::Mat getErrorCovPost() const { return kf_.errorCovPost; }
cv::Mat getGain() const { return kf_.gain;}
cv::Mat getMeasurement() const { return kf_.measurementMatrix;}
// Set and get ErrorEllipse:
void setErrorEllipseXY(const cv::RotatedRect& error_ellipse) { this->error_ellipse_xy_ = error_ellipse; }
const cv::RotatedRect& getErrorEllipseXY() const { return this->error_ellipse_xy_; }
void setErrorEllipseYZ(const cv::RotatedRect& error_ellipse) { this->error_ellipse_yz_ = error_ellipse; }
const cv::RotatedRect& getErrorEllipseYZ() const { return this->error_ellipse_yz_; }
// Set and get Covariance and Confidence @TODO
void setCovariance(double x, double y, double z, double angle_x, double angle_y, double angle_z);
void getCovariance(double& x, double& y, double& z, double& angle_x, double& angle_y, double& angle_z) const;
// void setConfidence(double confidence) { this->confidence = confidence; }
// double getConfidence() const { return this->confidence; }
/**
* @brief The state_size_ is used to select the correct model. For state_size_==6 constant vel., for state_size==9 no constant vel.
*/
int state_size_;
int measurement_size_;
float covariance_[6];
protected:
/**
* @brief Initializes member variables and OpenCV Kalman filter attributes
* @param state_size size of state vector
* @param measurement_size size of measurement vector
*/
// with the state_size 6 or 9 a kalman filter model is choosen!!!
void initKalman(int state_size = 6, int measurement_size = 3);
// Protected member variables
cv::KalmanFilter kf_;
cv::Mat state_;
cv::Mat measurement_;
// Input:
cv::Point3d latest_detected_position_;
ros::Time last_observation_time_;
// Output:
cv::Point3d position_;
cv::Point3d velocity_;
cv::Point3d acceleration_;
ros::Time time_stamp_;
cv::RotatedRect error_ellipse_xy_;
cv::RotatedRect error_ellipse_yz_; // @TODO
};
}
#endif
| 36.756098 | 133 | 0.695421 | [
"vector",
"model"
] |
a36e21d5ad76e9b6d77001a64e5a27338ba87734 | 2,726 | h | C | main/PISupervisor/common/include/ShareFolderCtrl.h | minku1024/endpointdlp | 931ab140eef053498907d1db74a5c055bea8ef93 | [
"Apache-2.0"
] | 33 | 2020-11-18T09:30:13.000Z | 2022-03-03T17:56:24.000Z | main/PISupervisor/common/include/ShareFolderCtrl.h | s4ngsuk-sms/endpointdlp | 9e87e352e23bff3b5e0701dd278756aadc8a0539 | [
"Apache-2.0"
] | 25 | 2020-07-31T01:43:17.000Z | 2020-11-27T12:32:09.000Z | main/PISupervisor/common/include/ShareFolderCtrl.h | s4ngsuk-sms/endpointdlp | 9e87e352e23bff3b5e0701dd278756aadc8a0539 | [
"Apache-2.0"
] | 26 | 2020-11-18T09:30:15.000Z | 2022-01-18T08:24:01.000Z | ///
///
#ifndef _PI_SHAREFOLDER_H_
#define _PI_SHAREFOLDER_H_
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
/*
#include <vector>
#include <string>
#include <algorithm>
*/
#include <sys/types.h>
#include <sys/stat.h>
#define MAX_PATH 260
#ifdef __cplusplus
extern "C"
{
#endif
typedef struct _SF_RECORD
{
char czSFRecord[MAX_PATH];
char czSFFilePath[MAX_PATH];
bool bEveryOne;
struct stat SFStat;
} SF_RECORD, *PSF_RECORD;
class CShareFolder
{
public:
CShareFolder() : m_bBlockAll(false), m_bBlockEveryOne(false), m_bBlockDefault(false), m_nCheckInterval(60) {}
~CShareFolder() {}
public:
bool getBlockAll() { return m_bBlockAll; }
bool getBlockEveryOne() { return m_bBlockEveryOne; }
bool getBlockDefault() { return m_bBlockDefault; }
int getCheckInterval() { return m_nCheckInterval; }
void setBlockAll(bool bBlockAll) { m_bBlockAll = bBlockAll; }
void setBlockEveryOne(bool bBlockEveryOne) { m_bBlockEveryOne = bBlockEveryOne; }
void setBlockDefault(bool bBlockDefault) { m_bBlockDefault = bBlockDefault; }
void setCheckInterval(int nCheckInterval) { m_nCheckInterval = nCheckInterval; }
bool IsExistPolicy() { return (m_bBlockAll || m_bBlockEveryOne || m_bBlockDefault); }
private:
bool m_bBlockAll;
bool m_bBlockEveryOne;
bool m_bBlockDefault;
int m_nCheckInterval;
};
class CShareFolderCtrl
{
public:
CShareFolderCtrl();
~CShareFolderCtrl();
public:
int SelectKextMenu();
bool ShellExecute(std::string strCommand, std::string& strResult);
bool ShellExecuteFetchSFRecordList(std::string strCommand, std::vector<SF_RECORD>& vecSFList);
bool ShellExecuteFetchSFFilePath(std::string strCommand, std::string& strOutFilePath);
std::string
StringReplaceAll( const std::string& strMessage, const std::string&& strPattern, const std::string&& strReplace );
void ShareFolderPrint();
bool ShareFolderEnum();
bool ShareFolderDelete(std::string strSFolder);
bool ShareFolderDisableAll();
bool ShareFolderDisableDefault();
bool ShareFolderDisableEveryOne();
public:
CShareFolder& GetSFPolicy() { return m_SFPolicy; }
protected:
CShareFolder m_SFPolicy;
std::vector<SF_RECORD> m_vecSFList;
};
#ifdef __cplusplus
};
#endif
#endif /* _PI_SHAREFOLDER_H_ */
| 28.395833 | 123 | 0.62179 | [
"vector"
] |
a37f934ccc7a7ad2d8692a8a132d1247604c528c | 1,784 | h | C | ds/ds/src/common/w32topl/schedman.h | npocmaka/Windows-Server-2003 | 5c6fe3db626b63a384230a1aa6b92ac416b0765f | [
"Unlicense"
] | 17 | 2020-11-13T13:42:52.000Z | 2021-09-16T09:13:13.000Z | ds/ds/src/common/w32topl/schedman.h | sancho1952007/Windows-Server-2003 | 5c6fe3db626b63a384230a1aa6b92ac416b0765f | [
"Unlicense"
] | 2 | 2020-10-19T08:02:06.000Z | 2020-10-19T08:23:18.000Z | ds/ds/src/common/w32topl/schedman.h | sancho1952007/Windows-Server-2003 | 5c6fe3db626b63a384230a1aa6b92ac416b0765f | [
"Unlicense"
] | 14 | 2020-11-14T09:43:20.000Z | 2021-08-28T08:59:57.000Z | /*++
Copyright (C) 2000 Microsoft Corporation
Module Name:
schedman.h
Abstract:
This file contains the definition of various structures used for the schedule
cache. These structures should be considered totally opaque -- the user
cannot see their internal structure.
These structures could be defined inside schedman.c, except we want them to
be visible to 'dsexts.dll', the debugger extension.
Author:
Nick Harvey (NickHar)
Revision History
14-7-2000 NickHar Created
--*/
/***** Header Files *****/
#include <ntrtl.h>
/***** Constants *****/
/* Magic numbers to ensure consistency of the Topl structures */
#define MAGIC_START 0xDEADBEEF
#define MAGIC_END 0x5EAC1C9
#define TOPL_ALWAYS_SCHEDULE NULL
/***** ToplSched *****/
/* The internal definition of a schedule object */
typedef struct {
LONG32 magicStart;
PSCHEDULE s;
DWORD duration; /* Calculated when schedule is created */
LONG32 magicEnd;
} ToplSched;
/***** ToplSchedCache *****/
/* The internal definition of a schedule cache */
typedef struct {
LONG32 magicStart;
RTL_GENERIC_TABLE table;
DWORD numEntries;
BOOLEAN deletionPhase; /* True if the schedule cache is being deleted */
PSCHEDULE pAlwaysSchedule; /* A cached copy of the always Pschedule. This is
* needed as a special case because the always
* schedule is the only one not actually stored
* in the cache. */
LONG32 magicEnd;
} ToplSchedCache;
| 27.875 | 94 | 0.582399 | [
"object"
] |
a3882c442664b126b91cc150b20a9dbd6e443f99 | 3,651 | h | C | src/C/Security-57031.40.6/Security/sec/securityd/OTATrustUtilities.h | GaloisInc/hacrypto | 5c99d7ac73360e9b05452ac9380c1c7dc6784849 | [
"BSD-3-Clause"
] | 34 | 2015-02-04T18:03:14.000Z | 2020-11-10T06:45:28.000Z | src/C/Security-57031.40.6/Security/sec/securityd/OTATrustUtilities.h | GaloisInc/hacrypto | 5c99d7ac73360e9b05452ac9380c1c7dc6784849 | [
"BSD-3-Clause"
] | 5 | 2015-06-30T21:17:00.000Z | 2016-06-14T22:31:51.000Z | src/C/Security-57031.40.6/Security/sec/securityd/OTATrustUtilities.h | GaloisInc/hacrypto | 5c99d7ac73360e9b05452ac9380c1c7dc6784849 | [
"BSD-3-Clause"
] | 15 | 2015-10-29T14:21:58.000Z | 2022-01-19T07:33:14.000Z | /*
* Copyright (c) 2003-2004,2006-2010,2013-2014 Apple Inc. All Rights Reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*
* OTATrustUtilities.h
*/
#ifndef _OTATRUSTUTILITIES_H_
#define _OTATRUSTUTILITIES_H_ 1
#include <CoreFoundation/CoreFoundation.h>
#include <sys/types.h>
#include <stdio.h>
__BEGIN_DECLS
// Opawue type that holds the data for a specific version of the OTA PKI assets
typedef struct _OpaqueSecOTAPKI *SecOTAPKIRef;
// Get a reference to the current OTA PKI asset data
// Caller is responsible for releasing the returned SecOTAPKIRef
CF_EXPORT
SecOTAPKIRef SecOTAPKICopyCurrentOTAPKIRef(void);
// Accessor to retrieve a copy of the current black listed key.
// Caller is responsible for releasing the returned CFSetRef
CF_EXPORT
CFSetRef SecOTAPKICopyBlackListSet(SecOTAPKIRef otapkiRef);
// Accessor to retrieve a copy of the current gray listed key.
// Caller is responsible for releasing the returned CFSetRef
CF_EXPORT
CFSetRef SecOTAPKICopyGrayList(SecOTAPKIRef otapkiRef);
// Accessor to retrieve the array of Escrow certificates
// Caller is responsible for releasing the returned CFArrayRef
CF_EXPORT
CFArrayRef SecOTAPKICopyEscrowCertificates(uint32_t escrowRootType, SecOTAPKIRef otapkiRef);
// Accessor to retrieve the dictionary of EV Policy OIDs to Anchor digest
// Caller is responsible for releasing the returned CFDictionaryRef
CF_EXPORT
CFDictionaryRef SecOTAPKICopyEVPolicyToAnchorMapping(SecOTAPKIRef otapkiRef);
// Accessor to retrieve the dictionary of anchor digest to file offest
// Caller is responsible for releasing the returned CFDictionaryRef
CF_EXPORT
CFDictionaryRef SecOTAPKICopyAnchorLookupTable(SecOTAPKIRef otapkiRef);
// Accessor to retrieve the ponter to the top of the anchor certs file
// Caller should NOT free the returned pointer. The caller should hold
// a reference to the SecOTAPKIRef object until finishing processing with
// the returned const char*
CF_EXPORT
const char* SecOTAPKIGetAnchorTable(SecOTAPKIRef otapkiRef);
// Accessor to retrieve the current OTA PKI asset version number
CF_EXPORT
int SecOTAPKIGetAssetVersion(SecOTAPKIRef otapkiRef);
// Signal that a new OTA PKI asset version is available. This call
// will update the current SecOTAPKIRef to now reference the latest
// asset data
CF_EXPORT
void SecOTAPKIRefreshData(void);
// SPI to return the array of currently trusted Escrow certificates
CF_EXPORT
CFArrayRef SecOTAPKICopyCurrentEscrowCertificates(uint32_t escrowRootType, CFErrorRef* error);
// SPI to return the current OTA PKI asset version
CF_EXPORT
int SecOTAPKIGetCurrentAssetVersion(CFErrorRef* error);
// SPI to signal securityd to get a new set of trust data
CF_EXPORT
int SecOTAPKISignalNewAsset(CFErrorRef* error);
__END_DECLS
#endif /* _OTATRUSTUTILITIES_H_ */
| 36.51 | 94 | 0.805807 | [
"object"
] |
a39655626a2a9a6d76926be22df5f6b3bde8e648 | 1,549 | h | C | src/GooseDEM/Ext/Friction/Friction.h | tdegeus/GooseDEM | cde2892f6a6b20509837b237f7153b985c73ea95 | [
"MIT"
] | null | null | null | src/GooseDEM/Ext/Friction/Friction.h | tdegeus/GooseDEM | cde2892f6a6b20509837b237f7153b985c73ea95 | [
"MIT"
] | 6 | 2018-05-08T09:11:06.000Z | 2019-10-12T21:11:25.000Z | src/GooseDEM/Ext/Friction/Friction.h | tdegeus/GooseDEM | cde2892f6a6b20509837b237f7153b985c73ea95 | [
"MIT"
] | null | null | null | /* =================================================================================================
(c - MIT) T.W.J. de Geus (Tom) | tom@geus.me | www.geus.me | github.com/tdegeus/GooseDEM
================================================================================================= */
#ifndef GOOSEDEM_EXT_FRICTION_H
#define GOOSEDEM_EXT_FRICTION_H
// -------------------------------------------------------------------------------------------------
#include "../../GooseDEM.h"
// -------------------------------------- version information --------------------------------------
#define GOOSEDEM_EXT_FRICTION_WORLD_VERSION 0
#define GOOSEDEM_EXT_FRICTION_MAJOR_VERSION 0
#define GOOSEDEM_EXT_FRICTION_MINOR_VERSION 1
#define GOOSEDEM_EXT_FRICTION_VERSION_AT_LEAST(x,y,z) \
(GOOSEDEM_EXT_FRICTION_WORLD_VERSION>x || (GOOSEDEM_EXT_FRICTION_WORLD_VERSION>=x && \
(GOOSEDEM_EXT_FRICTION_MAJOR_VERSION>y || (GOOSEDEM_EXT_FRICTION_MAJOR_VERSION>=y && \
GOOSEDEM_EXT_FRICTION_MINOR_VERSION>=z))))
#define GOOSEDEM_EXT_FRICTION_VERSION(x,y,z) \
(GOOSEDEM_EXT_FRICTION_WORLD_VERSION==x && \
GOOSEDEM_EXT_FRICTION_MAJOR_VERSION==y && \
GOOSEDEM_EXT_FRICTION_MINOR_VERSION==z)
// -------------------------------------------------------------------------------------------------
#include "PotentialAdhesion.h"
#include "PotentialAdhesion.cpp"
#include "Geometry.h"
#include "Geometry.cpp"
// -------------------------------------------------------------------------------------------------
#endif
| 37.780488 | 100 | 0.477728 | [
"geometry"
] |
a3aec1300d2c53d8ecf4a98384ed05e693d8645f | 7,244 | h | C | lib/sml/smlcomp.h | insop/transformer_simple | d07e6c3b9ddc9687d332ac3a980bbce22880ad46 | [
"Apache-2.0"
] | 1 | 2020-12-09T05:05:55.000Z | 2020-12-09T05:05:55.000Z | lib/sml/smlcomp.h | insop/transformer_simple | d07e6c3b9ddc9687d332ac3a980bbce22880ad46 | [
"Apache-2.0"
] | null | null | null | lib/sml/smlcomp.h | insop/transformer_simple | d07e6c3b9ddc9687d332ac3a980bbce22880ad46 | [
"Apache-2.0"
] | null | null | null | #ifndef _SMLCOMP_H_
#define _SMLCOMP_H_
/* smlcomp.h: Small Matrix library computations */
/***********************************************************/
/* configuration, data structures and access */
#include "smlbase.h"
REAL sml_hypot (REAL a, REAL b); /* sqrt(a*a + b*b) */
int Matmini (int a, int b);
int Matmaxi (int a, int b);
size_t Matminu (size_t a, size_t b);
size_t Matmaxu (size_t a, size_t b);
REAL Matminr (REAL a, REAL b);
REAL Matmaxr (REAL a, REAL b);
double Matmind (double a, double b);
double Matmaxd (double a, double b);
void MatSort (MATRIX A);
int MatIsSquare (MATRIX a);
int MatIsSymmetric(MATRIX a);
void MatI (MATRIX a, size_t n, REAL c); /* a = diag(c), n by n */
void MatJ (MATRIX a, size_t m, size_t n, REAL c); /* a = m by n, filled with c */
void MatFill (MATRIX a, REAL x); /* a[,] = x */
void MatFillAD (MATRIX a, REAL x); /* above diag(a) = x */
void MatFillBD (MATRIX a, REAL x); /* below diag(a) = x */
void MatFillD (MATRIX a, REAL x); /* diag(a) = x */
void MatBFill (MATRIX a, size_t i1, size_t i2, size_t j1, size_t j2, REAL x);
/* a[i1:i2, j1:j2] = x */
void MatFillCol (MATRIX a, size_t j, REAL x); /* a[, j] <- x */
void MatFillRow (MATRIX a, size_t i, REAL x); /* a[i, ] <- x */
void MatCopy (MATRIX a, MATRIX b); /* a = b */
void MatSetDiag (MATRIX a, MATRIX c); /* diag(a) = c */
void MatGetDiag (MATRIX a, MATRIX c); /* a = diag(c) */
void MatBCopy (MATRIX a, size_t ii1, size_t jj1,
MATRIX b, size_t i1, size_t i2, size_t j1, size_t j2);
/* a[ii1:ii2, jj1:jj2] = b[i1:i2, j1:j2] */
void MatTran (MATRIX a, MATRIX b); /* a = b' */
void MatL2U (MATRIX a); /* lower -> upper 1/2 */
void MatU2L (MATRIX a); /* upper -> lower 1/2 */
void MatAdd (MATRIX a, MATRIX b, MATRIX c); /* a = b + c */
void MatSub (MATRIX a, MATRIX b, MATRIX c); /* a = b - c */
void MatMul (MATRIX a, MATRIX b, MATRIX c); /* a = b * c */
void MatWMul (const char* op, MATRIX a, MATRIX b, MATRIX w, MATRIX c);
/*
Weighted matrix multiplication.
The string op[] specifies the operation as follows:
if op = "t " a <- b' * c
else if op = " t" a <- b * c'
else if op = "t t" a <- b' * c'
else if op = " w " a <- b * diag(w) * c
else if op = "tw " a <- b' * diag(w) * c
else if op = " wt" a <- b * diag(w) * c'
else if op = "twt" a <- b' * diag(w) * c'
else a <- b * c
*/
void MatAddDiag (MATRIX a, MATRIX b, MATRIX c); /* a = b + diag(c) */
void MatAddScalar (MATRIX a, MATRIX b, REAL c); /* a = b + c */
void MatMulScalar (MATRIX a, MATRIX b, REAL c); /* a = b * c */
void MatPreLower (MATRIX a, MATRIX l, MATRIX c); /* a = l * c */
void MatPreDiag (MATRIX a, MATRIX b, MATRIX c); /* a = diag(b) * c */
void MatMulE (MATRIX a, MATRIX b, MATRIX c); /* a = b * c elementwise */
void MatDivE (MATRIX a, MATRIX b, MATRIX c); /* a = b / c elementwise */
void MatDivE0 (MATRIX a, MATRIX b, MATRIX c); /* a = b / c el-wise, 1/0 = 0*/
void MatRecipE (MATRIX a, MATRIX b); /* a = 1/b elementwise */
void MatRecipE0 (MATRIX a, MATRIX b); /* a = 1/b elementwise, x/0=0 */
void MatSqrtE (MATRIX a, MATRIX b); /* a = b^0.5 elementwise */
void MatExpE (MATRIX a, MATRIX b); /* a = exp(b) elementwise */
void MatLogE (MATRIX a, MATRIX b); /* a = log(b) elementwise */
void MatApplyE (MATRIX a, REAL (*f)(REAL), MATRIX b); /* a=f(b) elementwise */
REAL MatMin (MATRIX a); /* min element of a */
REAL MatMax (MATRIX a); /* max element of a */
REAL MatMinAbs (MATRIX a); /* min |element| of a */
REAL MatMaxAbs (MATRIX a); /* max |element| of a */
REAL2 MatSum (MATRIX a); /* sum of elements of a */
REAL2 MatSumAbs (MATRIX a); /* sum of |elements| of a */
REAL2 MatSS (MATRIX a); /* sum of squares of a, ssq(a) */
REAL2 MatSS2 (MATRIX r, MATRIX a); /* ssq(a) == r[1,1]*r[1,1]*r[1,2] */
REAL2 MatTrace (MATRIX r); /* sum of diagonals */
size_t Matnzd (MATRIX a); /* # of non-zero diagonals */
void MatColSum (MATRIX a, MATRIX b); /* col sums of b */
void MatRowSum (MATRIX a, MATRIX b); /* row sums of b */
REAL2 MatCSum (MATRIX y, MATRIX x);/* y <- cumulative sum of x */
REAL2 MatCMean (MATRIX y, MATRIX x);/* y <- cumulative mean of x */
REAL2 MatRowxRow (MATRIX x, size_t i, MATRIX y, size_t j, MATRIX w, int use_w);
/* x[i,] * y[j,]' if use_w==0, x[i,] * diag(w) * y[j,]' if use_w==1 */
REAL2 MatColxCol (MATRIX x, size_t i, MATRIX y, size_t j, MATRIX w, int use_w);
/* x[,i]' * y[,j] if use_w==0, x[,i]' * diag(w) * y[,j] if use_w==1 */
REAL2 MatRowxCol (MATRIX x, size_t i, MATRIX y, size_t j, MATRIX w, int use_w);
/* x[i,] * y[,j] if use_w==0, x[i,] * diag(w) * y[,j] if use_w==1 */
void Matpwp (MATRIX a, MATRIX b);
/* a <- pairwise products of b, separately within each column */
int Matdaxpy_c (MATRIX z, size_t i, REAL a, MATRIX x, size_t j,
MATRIX y, size_t k); /* z[,i] <- a x[,j] + y[,k] */
/* vector norms */
REAL2 MatCol1norm (MATRIX A, size_t i); /* ||A[,i]||_1 */
REAL2 MatCol1normalize (MATRIX A, size_t i);
REAL2 MatCol2norm (MATRIX A, size_t i); /* ||A[,i]||_2 */
REAL2 MatCol2normalize (MATRIX A, size_t i);
REAL2 MatColinorm (MATRIX A, size_t i); /* ||A[,i]||_infty */
REAL2 MatColinormalize (MATRIX A, size_t i);
/* QR factoring of A, A = Q R, by Householder reflectors */
int MatQR (MATRIX Q, MATRIX R, MATRIX A);
int MatQRgetQR (MATRIX QR, MATRIX Rdiag, MATRIX A);
int MatQRgetQ (MATRIX Q, MATRIX QR);
int MatQRgetR (MATRIX R, MATRIX QR, MATRIX Rdiag);
int MatQRgetH (MATRIX H, MATRIX QR);
int MatQRsolve (MATRIX X, MATRIX B, MATRIX QR, MATRIX Rdiag);
/* The Singular Value Decomposition of A, A = U S V' */
int MatSVD (MATRIX U, MATRIX S, MATRIX V, MATRIX A);
/* Eigenvectors and Eigenvalues, A = V D V' */
int MatEigen (MATRIX V, MATRIX D_real, MATRIX D_imag, MATRIX A);
int MatCompanion (MATRIX companion, MATRIX poly_coeff);
/* SML - Cholesky */
int MatCholIP (MATRIX A); /* Cholesky, in-situ */
int MatChol (MATRIX L, MATRIX A); /* L <- root(A), A = L L' */
int MatSInvIP (MATRIX A);
/* g-inverts a symmetric non-negative definite matrix in-situ */
int MatSHInvIP(MATRIX A); /* lower A <- g-inverse of the Cholesky root of A */
int MatLtLIP (MATRIX L); /* L'L in-situ, L is a square lower triangular matrix */
int MatLLtIP (MATRIX L); /* L'L in-situ, L is a square lower triangular matrix */
int MatInvLIP (MATRIX L); /* g-invert a square lower triangular matrix L in situ */
int MatCholSolve (MATRIX X, MATRIX L, MATRIX B);
/* Solve a linear system A*X = B, using the previously computed
cholesky factorization of A, A = L L' */
#endif
| 46.435897 | 92 | 0.554666 | [
"vector"
] |
a3b57f53b50b7f5d85d0052c030ce13d0179f2bd | 4,612 | h | C | iOSOpenDev/frameworks/iLifeSlideshow.framework/Headers/MRRenderer.h | bzxy/cydia | f8c838cdbd86e49dddf15792e7aa56e2af80548d | [
"MIT"
] | 678 | 2017-11-17T08:33:19.000Z | 2022-03-26T10:40:20.000Z | iOSOpenDev/frameworks/iLifeSlideshow.framework/Headers/MRRenderer.h | chenfanfang/Cydia | 5efce785bfd5f1064b9c0f0e29a9cc05aa24cad0 | [
"MIT"
] | 22 | 2019-04-16T05:51:53.000Z | 2021-11-08T06:18:45.000Z | iOSOpenDev/frameworks/iLifeSlideshow.framework/Headers/MRRenderer.h | chenfanfang/Cydia | 5efce785bfd5f1064b9c0f0e29a9cc05aa24cad0 | [
"MIT"
] | 170 | 2018-06-10T07:59:20.000Z | 2022-03-22T16:19:33.000Z | /**
* This header is generated by class-dump-z 0.2b.
*
* Source: /System/Library/PrivateFrameworks/iLifeSlideshow.framework/iLifeSlideshow
*/
#import <iLifeSlideshow/iLifeSlideshow-Structs.h>
#import <iLifeSlideshow/XXUnknownSuperclass.h>
@class EAGLContext, NSConditionLock, MCMontage, NSThread, NSLock, NSDictionary, MRLayerParallelizer;
@protocol MRLiveSlideshowDelegate;
@interface MRRenderer : XXUnknownSuperclass {
MCMontage *mMontage; // 4 = 0x4
MRLayerParallelizer *mTopMRLayer; // 8 = 0x8
NSLock *mRenderLock; // 12 = 0xc
NSConditionLock *mWarmUpLock; // 16 = 0x10
CGSize mSize; // 20 = 0x14
int mOrientation; // 28 = 0x1c
BOOL mNeedsToUpdateSize; // 32 = 0x20
BOOL mIsPlaying; // 33 = 0x21
id mDisplayLink; // 36 = 0x24
NSDictionary *mParameters; // 40 = 0x28
EAGLContext *mContext; // 44 = 0x2c
EAGLContext *mPreloadContext; // 48 = 0x30
unsigned mFramebuffer; // 52 = 0x34
unsigned mRenderbuffer; // 56 = 0x38
BOOL mFramebufferIsSetup; // 60 = 0x3c
NSThread *mRenderThread; // 64 = 0x40
double mTimeOffset; // 68 = 0x44
double mLastRenderedTime; // 76 = 0x4c
float mFadeAlpha; // 84 = 0x54
BOOL mShowFPS; // 88 = 0x58
BOOL mPauseWhenStill; // 89 = 0x59
BOOL mIsWarmingUp; // 90 = 0x5a
BOOL mWasForcedPaused; // 91 = 0x5b
id<MRLiveSlideshowDelegate> mLiveSlideshowDelegate; // 92 = 0x5c
}
@property(retain, nonatomic) MCMontage *montage; // G=0x8a609; S=0x8bd35; @synthesize=mMontage
@property(readonly, assign) EAGLContext *context; // G=0x8a5f9; @synthesize=mContext
@property(readonly, assign) EAGLContext *preloadContext; // G=0x8a5e9; @synthesize=mPreloadContext
@property(assign, nonatomic) CGSize size; // G=0x8a5d1; S=0x8a475; @synthesize=mSize
@property(assign, nonatomic) int orientation; // G=0x8a5c1; S=0x8a4f9; @synthesize=mOrientation
@property(readonly, assign) BOOL isPlaying; // G=0x8a5b1; @synthesize=mIsPlaying
@property(readonly, assign) BOOL isWarmingUp; // G=0x8a5a1; @synthesize=mIsWarmingUp
@property(assign) BOOL showFPS; // G=0x8a581; S=0x8a591; @synthesize=mShowFPS
@property(assign) float fadeAlpha; // G=0x8a561; S=0x8a571; @synthesize=mFadeAlpha
@property(assign) id<MRLiveSlideshowDelegate> liveSlideshowDelegate; // G=0x8a541; S=0x8a551; @synthesize=mLiveSlideshowDelegate
@property(assign) double time; // G=0x8b959; S=0x8b8d5;
- (id)init; // 0x8a619
- (void)dealloc; // 0x8c341
- (void)cleanup; // 0x8c125
- (void)setContext:(id)context frameBuffer:(unsigned)buffer renderBuffer:(unsigned)buffer3; // 0x8bf05
// declared property setter: - (void)setMontage:(id)montage; // 0x8bd35
// declared property setter: - (void)setSize:(CGSize)size; // 0x8a475
// declared property setter: - (void)setOrientation:(int)orientation; // 0x8a4f9
- (void)render; // 0x8bcd5
- (void)warmup; // 0x8bc99
- (void)warmupAndWhenDoneCallSelector:(SEL)selector withTarget:(id)target andObject:(id)object; // 0x8bbb5
- (void)_warmupWithCallback:(id)callback; // 0x8bb31
- (void)pause; // 0x8baf5
- (void)pauseWhenStill; // 0x8a519
- (void)resume; // 0x8ba95
- (void)stepForward; // 0x8ba3d
- (void)stepBackward; // 0x8b9e5
// declared property getter: - (double)time; // 0x8b959
// declared property setter: - (void)setTime:(double)time; // 0x8b8d5
- (void)setForcedPaused; // 0x8a52d
- (void)_startRenderThread; // 0x8b749
- (void)_exitRenderThread; // 0x8b739
- (void)_startRenderTimer; // 0x8b699
- (void)_stopRenderTimer; // 0x8b66d
- (void)_render; // 0x8b659
- (void)_render:(id)render; // 0x8af49
- (void)_postPlaybackOverNotification; // 0x8af05
- (void)_displayFPS; // 0x8ac29
- (void)_warmup; // 0x8ab31
- (void)_armWarmingUp; // 0x8aaf1
- (void)_warmingUpCompleted; // 0x8aab1
- (void)_pause:(BOOL)pause; // 0x8a9b1
- (void)_resume; // 0x8a911
- (void)hackCheckIfNeedsAdditionalEffectsAtTime:(double)time; // 0x8a875
// declared property getter: - (id)liveSlideshowDelegate; // 0x8a541
// declared property setter: - (void)setLiveSlideshowDelegate:(id)delegate; // 0x8a551
// declared property getter: - (float)fadeAlpha; // 0x8a561
// declared property setter: - (void)setFadeAlpha:(float)alpha; // 0x8a571
// declared property getter: - (BOOL)showFPS; // 0x8a581
// declared property setter: - (void)setShowFPS:(BOOL)fps; // 0x8a591
// declared property getter: - (BOOL)isWarmingUp; // 0x8a5a1
// declared property getter: - (BOOL)isPlaying; // 0x8a5b1
// declared property getter: - (int)orientation; // 0x8a5c1
// declared property getter: - (CGSize)size; // 0x8a5d1
// declared property getter: - (id)preloadContext; // 0x8a5e9
// declared property getter: - (id)context; // 0x8a5f9
// declared property getter: - (id)montage; // 0x8a609
@end
| 47.546392 | 128 | 0.73634 | [
"render",
"object"
] |
a3c5815e609fa9ec2ae78ddc96694b60934ad691 | 636 | h | C | common/src/partitioning/aabbtree/AABBNodeData.h | petitg1987/UrchinEngine | 32d4b62b1ab7e2aa781c99de11331e3738078b0c | [
"MIT"
] | 24 | 2015-10-05T00:13:57.000Z | 2020-05-06T20:14:06.000Z | common/src/partitioning/aabbtree/AABBNodeData.h | petitg1987/urchinEngine | a14a57ac49a19237d748d2eafc7c2a38a45b95d6 | [
"BSL-1.0"
] | 1 | 2019-11-01T08:00:55.000Z | 2019-11-01T08:00:55.000Z | common/src/partitioning/aabbtree/AABBNodeData.h | petitg1987/UrchinEngine | 32d4b62b1ab7e2aa781c99de11331e3738078b0c | [
"MIT"
] | 10 | 2015-11-25T07:33:13.000Z | 2020-03-02T08:21:10.000Z | #pragma once
#include <string>
#include <math/geometry/3d/object/AABBox.h>
namespace urchin {
template<class OBJ> class AABBNodeData {
public:
explicit AABBNodeData(OBJ);
virtual ~AABBNodeData() = default;
OBJ getNodeObject() const;
virtual std::unique_ptr<AABBNodeData<OBJ>> clone() const = 0;
virtual const std::string& getObjectId() const = 0;
virtual AABBox<float> retrieveObjectAABBox() const = 0;
virtual bool isObjectMoving() const = 0;
private:
OBJ nodeObject;
};
#include "AABBNodeData.inl"
}
| 21.931034 | 73 | 0.600629 | [
"geometry",
"object",
"3d"
] |
a3d74d3adfe15dadd9a000cf57fde43f0527b277 | 1,559 | h | C | Kebab Engine/Source/ResourceManager.h | MagiX7/Kebab-Engine | c50b99295e0f053d4ae3e84fe57180fbb4d61515 | [
"MIT"
] | null | null | null | Kebab Engine/Source/ResourceManager.h | MagiX7/Kebab-Engine | c50b99295e0f053d4ae3e84fe57180fbb4d61515 | [
"MIT"
] | null | null | null | Kebab Engine/Source/ResourceManager.h | MagiX7/Kebab-Engine | c50b99295e0f053d4ae3e84fe57180fbb4d61515 | [
"MIT"
] | 1 | 2021-09-21T11:23:02.000Z | 2021-09-21T11:23:02.000Z | #pragma once
#include "Vertex.h"
#include "Texture.h"
//#include "TextureProperties.h"
#include <vector>
#include <string>
#include <map>
#include <memory>
class Resource;
class KbModel;
class KbMesh;
enum class ResourceType;
class ResourceManager
{
public:
static ResourceManager* GetInstance();
void CleanUp();
std::shared_ptr<Resource> GetResource(int uuid) const;
void DeleteResource(int uuid);
void AddResource(KbMesh* res);
void AddResource(Texture* res);
bool IsAlreadyLoaded(int uuid);
std::shared_ptr<Resource> IsAlreadyLoaded(const char* assetsFile);
std::shared_ptr<Resource> IsAlreadyLoaded(const std::string& libraryFile);
int GetReferenceCount(int uuid);
std::shared_ptr<KbModel> CreateModel(const char* assetsFile);
std::shared_ptr<Resource> CreateMesh(const std::vector<Vertex>& vertices, const std::vector<uint32_t>& indices, const std::string& name);
std::shared_ptr<Texture> CreateTexture(const char* assetsFile, int modelUuid = 0, const TextureProperties& props = TextureProperties(), int texUuid = -1);
std::shared_ptr<Resource> LoadTexture(const char* libraryFile, int uuid);
int GenerateUUID();
std::shared_ptr<Resource> FindMetaData(const char* assetsFile);
std::shared_ptr<KbModel> LoadModelMetaData(const char* assetsFile);
std::shared_ptr<Texture> LoadTextureMetaData(const char* assetsFile);
private:
ResourceManager();
virtual ~ResourceManager();
private:
static ResourceManager* instance;
std::map<int, std::shared_ptr<Resource>> resources;
TextureProperties defaultTextureProps;
}; | 24.746032 | 155 | 0.7678 | [
"vector"
] |
a3d780b2a02fe99937ed5e8fc03bfd814be64348 | 680 | h | C | FaulhaberModulo.h | Bramicus/Faulhaber | 85de91412cb62f526060ac1001c07ea98786dc75 | [
"MIT"
] | null | null | null | FaulhaberModulo.h | Bramicus/Faulhaber | 85de91412cb62f526060ac1001c07ea98786dc75 | [
"MIT"
] | null | null | null | FaulhaberModulo.h | Bramicus/Faulhaber | 85de91412cb62f526060ac1001c07ea98786dc75 | [
"MIT"
] | null | null | null | #pragma once
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
class FaulhaberModulo
{
typedef map<int, long long> BernouilliCache;
public:
FaulhaberModulo(int maxPower, int modulo);
long long GetSumOfNSquared(long long n, int p);
private:
void InitialisePascalsTriangleCache();
void InitialiseBernoulliCache();
int ModularInverse(int a) const;
long long BernoulliNumberMod(int p);
long long GetBernouilliPolynomial(int p, int power);
long long SafePower(long long n, int p) const;
BernouilliCache m_answerCache;
vector<vector<long long>> m_pascalTriangles;
const int m_maxPower;
const int m_modulo;
}; | 21.25 | 54 | 0.738235 | [
"vector"
] |
a3e06f7dc5825e7bdeeec5d3ea217135b8ac7224 | 667 | h | C | src/bubo.h | juttle/bubo | 23983a82c7c12a58e90d453f0b3485d14f19e3e8 | [
"Apache-2.0"
] | 5 | 2016-02-19T01:16:16.000Z | 2021-06-16T08:54:51.000Z | src/bubo.h | juttle/bubo | 23983a82c7c12a58e90d453f0b3485d14f19e3e8 | [
"Apache-2.0"
] | 4 | 2015-12-01T21:26:08.000Z | 2016-02-09T22:42:08.000Z | src/bubo.h | juttle/bubo | 23983a82c7c12a58e90d453f0b3485d14f19e3e8 | [
"Apache-2.0"
] | 3 | 2016-03-28T21:39:10.000Z | 2016-10-24T19:07:02.000Z | #pragma once
#include "node.h"
#include "nan.h"
#include "js-method.h"
#include "attrs-table.h"
#include "strings-table.h"
#include <unordered_set>
class Bubo : public Nan::ObjectWrap {
public:
static void Init(v8::Handle<v8::Object> exports);
static NAN_METHOD(New);
static Nan::Persistent<v8::Function> constructor;
private:
explicit Bubo();
~Bubo();
NAN_METHOD(Initialize);
JS_METHOD_DECL(Add);
JS_METHOD_DECL(Contains);
JS_METHOD_DECL(Delete);
JS_METHOD_DECL(Stats);
JS_METHOD_DECL(Test);
AttributesTable* attrs_table_;
StringsTable* strings_table_;
std::vector<std::string> ignored_attributes_;
};
| 19.617647 | 53 | 0.698651 | [
"object",
"vector"
] |
a3e64f3784b0986c411aa157ad2aa5477edd4734 | 1,410 | h | C | include/ctranslate2/layers/attention.h | Parkchanjun/CTranslate2 | 62e3af774e0ba23e052e242c263dcbc00cd6c0c6 | [
"MIT"
] | null | null | null | include/ctranslate2/layers/attention.h | Parkchanjun/CTranslate2 | 62e3af774e0ba23e052e242c263dcbc00cd6c0c6 | [
"MIT"
] | null | null | null | include/ctranslate2/layers/attention.h | Parkchanjun/CTranslate2 | 62e3af774e0ba23e052e242c263dcbc00cd6c0c6 | [
"MIT"
] | null | null | null | #pragma once
#include "ctranslate2/layers/common.h"
namespace ctranslate2 {
namespace layers {
class DotProductAttention
{
public:
void operator()(const StorageView& queries,
const StorageView& keys,
const StorageView& values,
const StorageView* values_lengths,
StorageView& output,
StorageView* attention = nullptr,
float queries_scale = 1);
};
class MultiHeadAttention
{
public:
MultiHeadAttention(const models::Model& model, const std::string& scope, size_t num_heads);
void operator()(const StorageView& queries,
const StorageView* memory,
const StorageView* memory_lengths,
StorageView& output,
StorageView* cached_keys = nullptr,
StorageView* cached_values = nullptr,
StorageView* attention = nullptr);
private:
size_t _num_heads;
std::vector<Dense> _linear;
LayerNorm _layer_norm;
DotProductAttention _attention;
ops::Transpose _transpose_op;
void split_heads(const StorageView& x, StorageView& y);
void combine_heads(const StorageView& x, StorageView& y);
static void cache_proj(StorageView& proj, StorageView& cache);
};
}
}
| 31.333333 | 97 | 0.587234 | [
"vector",
"model"
] |
a3ebbbf5a3e90ee38b28e640aeb85c27baebb45c | 1,733 | h | C | cuddlySys/adminadduser.h | alisultan14/Pet_Matchmaker | 98b9b2261430ca52d56f5ad670b486c0533444a6 | [
"MIT"
] | null | null | null | cuddlySys/adminadduser.h | alisultan14/Pet_Matchmaker | 98b9b2261430ca52d56f5ad670b486c0533444a6 | [
"MIT"
] | null | null | null | cuddlySys/adminadduser.h | alisultan14/Pet_Matchmaker | 98b9b2261430ca52d56f5ad670b486c0533444a6 | [
"MIT"
] | null | null | null | /**
* adminadduser.h
* The header file for the admin group to add users.
*
* @author Team2_1
* @version 2.0
* @since 2021-5-15
*/
#ifndef ADMINADDUSER_H
#define ADMINADDUSER_H
#include "database.h"
#include "header.h"
#include "manageusers.h"
#include "usermanager.h"
#include <QWidget>
namespace Ui {
/**
* @brief adminAddUser class.
* It adds a single user to the system.
* The admin user uses this class.
*/
class adminAddUser;
}
class adminAddUser : public QWidget
{
Q_OBJECT
public:
/**
* @brief A default constructor.
* It construct a new adminAddUser object.
*/
explicit adminAddUser(QWidget *parent = 0);
/**
* @brief A destructor.
* It destructs an adminAddUser object.
*/
~adminAddUser();
private slots:
/**
* @brief A function
* It adds a single user to the system when the button is clicked.
*/
void on_PB_createAcc_clicked();
/**
* @brief A function
* It detects the "potential pet owner" selection, then
* it displays the potential pet owner preference fields
* @param index the comboBox's index
*/
void on_CB_AccType_currentIndexChanged(int index);
/**
* @brief A function
* It returns to the previous interface once "back" button is clicked.
*/
void on_back_clicked();
private:
/**
* @brief A pointer
* It references its ui.
*/
Ui::adminAddUser *ui;
/**
* @brief A function
* It switches displays/undisplays the potential pet owner preferences fields
* based on the input T/F boolval.
* @param boolval true (display) or false (hide)
*/
void switchVisibility(bool boolval);
};
#endif // ADMINADDUSER_H
| 22.217949 | 82 | 0.639931 | [
"object"
] |
a3ef591f8d3a5750c4749d03eb0d8e25f5fcaf80 | 6,518 | h | C | PrivateFrameworks/CoreRecognition/CDStructures.h | phatblat/macOSPrivateFrameworks | 9047371eb80f925642c8a7c4f1e00095aec66044 | [
"MIT"
] | 17 | 2018-11-13T04:02:58.000Z | 2022-01-20T09:27:13.000Z | PrivateFrameworks/CoreRecognition/CDStructures.h | phatblat/macOSPrivateFrameworks | 9047371eb80f925642c8a7c4f1e00095aec66044 | [
"MIT"
] | 3 | 2018-04-06T02:02:27.000Z | 2018-10-02T01:12:10.000Z | PrivateFrameworks/CoreRecognition/CDStructures.h | phatblat/macOSPrivateFrameworks | 9047371eb80f925642c8a7c4f1e00095aec66044 | [
"MIT"
] | 1 | 2018-09-28T13:54:23.000Z | 2018-09-28T13:54:23.000Z | //
// Generated by class-dump 3.5 (64 bit).
//
// class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2013 by Steve Nygard.
//
#pragma mark Blocks
typedef void (^CDUnknownBlockType)(void); // return type and parameters are unknown
#pragma mark Named Structures
struct CATransform3D {
double _field1;
double _field2;
double _field3;
double _field4;
double _field5;
double _field6;
double _field7;
double _field8;
double _field9;
double _field10;
double _field11;
double _field12;
double _field13;
double _field14;
double _field15;
double _field16;
};
struct CGPoint {
double x;
double y;
};
struct CGRect {
struct CGPoint origin;
struct CGSize size;
};
struct CGSize {
double width;
double height;
};
struct __tree_end_node<std::__1::__tree_node_base<void *>*> {
struct __tree_node_base<void *> *_field1;
};
struct map<int, std::__1::vector<float, std::__1::allocator<float>>, std::__1::less<int>, std::__1::allocator<std::__1::pair<const int, std::__1::vector<float, std::__1::allocator<float>>>>> {
struct __tree<std::__1::__value_type<int, std::__1::vector<float, std::__1::allocator<float>>>, std::__1::__map_value_compare<int, std::__1::__value_type<int, std::__1::vector<float, std::__1::allocator<float>>>, std::__1::less<int>, true>, std::__1::allocator<std::__1::__value_type<int, std::__1::vector<float, std::__1::allocator<float>>>>> {
struct __tree_end_node<std::__1::__tree_node_base<void *>*> *_field1;
struct __compressed_pair<std::__1::__tree_end_node<std::__1::__tree_node_base<void *>*>, std::__1::allocator<std::__1::__tree_node<std::__1::__value_type<int, std::__1::vector<float, std::__1::allocator<float>>>, void *>>> {
struct __tree_end_node<std::__1::__tree_node_base<void *>*> _field1;
} _field2;
struct __compressed_pair<unsigned long, std::__1::__map_value_compare<int, std::__1::__value_type<int, std::__1::vector<float, std::__1::allocator<float>>>, std::__1::less<int>, true>> {
unsigned long long _field1;
} _field3;
} _field1;
};
struct vImage_Buffer {
void *data;
unsigned long long height;
unsigned long long width;
unsigned long long rowBytes;
};
struct vector<float, std::__1::allocator<float>>;
struct vector<std::__1::vector<float, std::__1::allocator<float>>, std::__1::allocator<std::__1::vector<float, std::__1::allocator<float>>>> {
struct vector<float, std::__1::allocator<float>> *_field1;
struct vector<float, std::__1::allocator<float>> *_field2;
struct __compressed_pair<std::__1::vector<float, std::__1::allocator<float>>*, std::__1::allocator<std::__1::vector<float, std::__1::allocator<float>>>> {
struct vector<float, std::__1::allocator<float>> *_field1;
} _field3;
};
struct vector<std::__1::vector<std::__1::vector<float, std::__1::allocator<float>>, std::__1::allocator<std::__1::vector<float, std::__1::allocator<float>>>>, std::__1::allocator<std::__1::vector<std::__1::vector<float, std::__1::allocator<float>>, std::__1::allocator<std::__1::vector<float, std::__1::allocator<float>>>>>> {
vector_e130d805 *_field1;
vector_e130d805 *_field2;
struct __compressed_pair<std::__1::vector<std::__1::vector<float, std::__1::allocator<float>>, std::__1::allocator<std::__1::vector<float, std::__1::allocator<float>>>>*, std::__1::allocator<std::__1::vector<std::__1::vector<float, std::__1::allocator<float>>, std::__1::allocator<std::__1::vector<float, std::__1::allocator<float>>>>>> {
vector_e130d805 *_field1;
} _field3;
};
#pragma mark Typedef'd Structures
typedef struct {
long long value;
int timescale;
unsigned int flags;
long long epoch;
} CDStruct_1b6d18a9;
typedef struct {
struct *_field1;
int _field2;
double _field3;
double _field4;
} CDStruct_7012203e;
// Template types
typedef struct map<int, std::__1::vector<float, std::__1::allocator<float>>, std::__1::less<int>, std::__1::allocator<std::__1::pair<const int, std::__1::vector<float, std::__1::allocator<float>>>>> {
struct __tree<std::__1::__value_type<int, std::__1::vector<float, std::__1::allocator<float>>>, std::__1::__map_value_compare<int, std::__1::__value_type<int, std::__1::vector<float, std::__1::allocator<float>>>, std::__1::less<int>, true>, std::__1::allocator<std::__1::__value_type<int, std::__1::vector<float, std::__1::allocator<float>>>>> {
struct __tree_end_node<std::__1::__tree_node_base<void *>*> *_field1;
struct __compressed_pair<std::__1::__tree_end_node<std::__1::__tree_node_base<void *>*>, std::__1::allocator<std::__1::__tree_node<std::__1::__value_type<int, std::__1::vector<float, std::__1::allocator<float>>>, void *>>> {
struct __tree_end_node<std::__1::__tree_node_base<void *>*> _field1;
} _field2;
struct __compressed_pair<unsigned long, std::__1::__map_value_compare<int, std::__1::__value_type<int, std::__1::vector<float, std::__1::allocator<float>>>, std::__1::less<int>, true>> {
unsigned long long _field1;
} _field3;
} _field1;
} map_5c615d34;
typedef struct vector<std::__1::vector<float, std::__1::allocator<float>>, std::__1::allocator<std::__1::vector<float, std::__1::allocator<float>>>> {
struct vector<float, std::__1::allocator<float>> *_field1;
struct vector<float, std::__1::allocator<float>> *_field2;
struct __compressed_pair<std::__1::vector<float, std::__1::allocator<float>>*, std::__1::allocator<std::__1::vector<float, std::__1::allocator<float>>>> {
struct vector<float, std::__1::allocator<float>> *_field1;
} _field3;
} vector_e130d805;
typedef struct vector<std::__1::vector<std::__1::vector<float, std::__1::allocator<float>>, std::__1::allocator<std::__1::vector<float, std::__1::allocator<float>>>>, std::__1::allocator<std::__1::vector<std::__1::vector<float, std::__1::allocator<float>>, std::__1::allocator<std::__1::vector<float, std::__1::allocator<float>>>>>> {
vector_e130d805 *_field1;
vector_e130d805 *_field2;
struct __compressed_pair<std::__1::vector<std::__1::vector<float, std::__1::allocator<float>>, std::__1::allocator<std::__1::vector<float, std::__1::allocator<float>>>>*, std::__1::allocator<std::__1::vector<std::__1::vector<float, std::__1::allocator<float>>, std::__1::allocator<std::__1::vector<float, std::__1::allocator<float>>>>>> {
vector_e130d805 *_field1;
} _field3;
} vector_00ef371e;
| 49.007519 | 349 | 0.685026 | [
"vector"
] |
a3f5ebb24101f043fcb4643a3995fec98fc3169b | 6,251 | h | C | risc_msgs/msg_gen/cpp/include/foo_msgs/States.h | riscmaster/risc_maap | 48b0ab79c1938bc3ed36442894dd4bf3091a2942 | [
"BSD-2-Clause"
] | 1 | 2017-04-30T19:33:37.000Z | 2017-04-30T19:33:37.000Z | risc_msgs/msg_gen/cpp/include/foo_msgs/States.h | riscmaster/risc_maap | 48b0ab79c1938bc3ed36442894dd4bf3091a2942 | [
"BSD-2-Clause"
] | 1 | 2019-09-12T02:29:39.000Z | 2019-09-12T02:29:39.000Z | risc_msgs/msg_gen/cpp/include/foo_msgs/States.h | riscmaster/risc_maap | 48b0ab79c1938bc3ed36442894dd4bf3091a2942 | [
"BSD-2-Clause"
] | 2 | 2016-03-07T00:47:59.000Z | 2018-10-06T17:43:10.000Z | /* Auto-generated by genmsg_cpp for file /home/ece/ros_ws/src/foo_msgs/msg/States.msg */
#ifndef FOO_MSGS_MESSAGE_STATES_H
#define FOO_MSGS_MESSAGE_STATES_H
#include <string>
#include <vector>
#include <map>
#include <ostream>
#include "ros/serialization.h"
#include "ros/builtin_message_traits.h"
#include "ros/message_operations.h"
#include "ros/time.h"
#include "ros/macros.h"
#include "ros/assert.h"
namespace foo_msgs
{
template <class ContainerAllocator>
struct States_ {
typedef States_<ContainerAllocator> Type;
States_()
: name()
, visible(false)
, x(0.0)
, y(0.0)
, z(0.0)
, u(0.0)
, v(0.0)
, w(0.0)
, phi(0.0)
, theta(0.0)
, psi(0.0)
, p(0.0)
, q(0.0)
, r(0.0)
{
}
States_(const ContainerAllocator& _alloc)
: name(_alloc)
, visible(false)
, x(0.0)
, y(0.0)
, z(0.0)
, u(0.0)
, v(0.0)
, w(0.0)
, phi(0.0)
, theta(0.0)
, psi(0.0)
, p(0.0)
, q(0.0)
, r(0.0)
{
}
typedef std::basic_string<char, std::char_traits<char>, typename ContainerAllocator::template rebind<char>::other > _name_type;
std::basic_string<char, std::char_traits<char>, typename ContainerAllocator::template rebind<char>::other > name;
typedef uint8_t _visible_type;
uint8_t visible;
typedef double _x_type;
double x;
typedef double _y_type;
double y;
typedef double _z_type;
double z;
typedef double _u_type;
double u;
typedef double _v_type;
double v;
typedef double _w_type;
double w;
typedef double _phi_type;
double phi;
typedef double _theta_type;
double theta;
typedef double _psi_type;
double psi;
typedef double _p_type;
double p;
typedef double _q_type;
double q;
typedef double _r_type;
double r;
typedef boost::shared_ptr< ::foo_msgs::States_<ContainerAllocator> > Ptr;
typedef boost::shared_ptr< ::foo_msgs::States_<ContainerAllocator> const> ConstPtr;
boost::shared_ptr<std::map<std::string, std::string> > __connection_header;
}; // struct States
typedef ::foo_msgs::States_<std::allocator<void> > States;
typedef boost::shared_ptr< ::foo_msgs::States> StatesPtr;
typedef boost::shared_ptr< ::foo_msgs::States const> StatesConstPtr;
template<typename ContainerAllocator>
std::ostream& operator<<(std::ostream& s, const ::foo_msgs::States_<ContainerAllocator> & v)
{
ros::message_operations::Printer< ::foo_msgs::States_<ContainerAllocator> >::stream(s, "", v);
return s;}
} // namespace foo_msgs
namespace ros
{
namespace message_traits
{
template<class ContainerAllocator> struct IsMessage< ::foo_msgs::States_<ContainerAllocator> > : public TrueType {};
template<class ContainerAllocator> struct IsMessage< ::foo_msgs::States_<ContainerAllocator> const> : public TrueType {};
template<class ContainerAllocator>
struct MD5Sum< ::foo_msgs::States_<ContainerAllocator> > {
static const char* value()
{
return "8271f59b5179794f309908101ca21e03";
}
static const char* value(const ::foo_msgs::States_<ContainerAllocator> &) { return value(); }
static const uint64_t static_value1 = 0x8271f59b5179794fULL;
static const uint64_t static_value2 = 0x309908101ca21e03ULL;
};
template<class ContainerAllocator>
struct DataType< ::foo_msgs::States_<ContainerAllocator> > {
static const char* value()
{
return "foo_msgs/States";
}
static const char* value(const ::foo_msgs::States_<ContainerAllocator> &) { return value(); }
};
template<class ContainerAllocator>
struct Definition< ::foo_msgs::States_<ContainerAllocator> > {
static const char* value()
{
return "string name\n\
\n\
bool visible\n\
\n\
float64 x\n\
\n\
float64 y\n\
\n\
float64 z\n\
\n\
float64 u\n\
\n\
float64 v\n\
\n\
float64 w\n\
\n\
float64 phi\n\
\n\
float64 theta\n\
\n\
float64 psi\n\
\n\
float64 p\n\
\n\
float64 q\n\
\n\
float64 r\n\
\n\
";
}
static const char* value(const ::foo_msgs::States_<ContainerAllocator> &) { return value(); }
};
} // namespace message_traits
} // namespace ros
namespace ros
{
namespace serialization
{
template<class ContainerAllocator> struct Serializer< ::foo_msgs::States_<ContainerAllocator> >
{
template<typename Stream, typename T> inline static void allInOne(Stream& stream, T m)
{
stream.next(m.name);
stream.next(m.visible);
stream.next(m.x);
stream.next(m.y);
stream.next(m.z);
stream.next(m.u);
stream.next(m.v);
stream.next(m.w);
stream.next(m.phi);
stream.next(m.theta);
stream.next(m.psi);
stream.next(m.p);
stream.next(m.q);
stream.next(m.r);
}
ROS_DECLARE_ALLINONE_SERIALIZER;
}; // struct States_
} // namespace serialization
} // namespace ros
namespace ros
{
namespace message_operations
{
template<class ContainerAllocator>
struct Printer< ::foo_msgs::States_<ContainerAllocator> >
{
template<typename Stream> static void stream(Stream& s, const std::string& indent, const ::foo_msgs::States_<ContainerAllocator> & v)
{
s << indent << "name: ";
Printer<std::basic_string<char, std::char_traits<char>, typename ContainerAllocator::template rebind<char>::other > >::stream(s, indent + " ", v.name);
s << indent << "visible: ";
Printer<uint8_t>::stream(s, indent + " ", v.visible);
s << indent << "x: ";
Printer<double>::stream(s, indent + " ", v.x);
s << indent << "y: ";
Printer<double>::stream(s, indent + " ", v.y);
s << indent << "z: ";
Printer<double>::stream(s, indent + " ", v.z);
s << indent << "u: ";
Printer<double>::stream(s, indent + " ", v.u);
s << indent << "v: ";
Printer<double>::stream(s, indent + " ", v.v);
s << indent << "w: ";
Printer<double>::stream(s, indent + " ", v.w);
s << indent << "phi: ";
Printer<double>::stream(s, indent + " ", v.phi);
s << indent << "theta: ";
Printer<double>::stream(s, indent + " ", v.theta);
s << indent << "psi: ";
Printer<double>::stream(s, indent + " ", v.psi);
s << indent << "p: ";
Printer<double>::stream(s, indent + " ", v.p);
s << indent << "q: ";
Printer<double>::stream(s, indent + " ", v.q);
s << indent << "r: ";
Printer<double>::stream(s, indent + " ", v.r);
}
};
} // namespace message_operations
} // namespace ros
#endif // FOO_MSGS_MESSAGE_STATES_H
| 23.411985 | 156 | 0.660534 | [
"vector"
] |
430ca236972676050320dc2ea15ea8ec3113623f | 1,270 | h | C | Assets/Plugins/iOS/WebEngage.framework/Headers/WEGMobileBridge.h | WebEngage/webengage-unity-ios | 7e56bf9a108b08ce5cecf6e49b9ff304de1d0701 | [
"BSD-Source-Code"
] | 3 | 2019-05-02T10:18:39.000Z | 2020-01-17T12:09:51.000Z | Assets/Plugins/iOS/WebEngage.framework/Headers/WEGMobileBridge.h | WebEngage/webengage-unity-ios | 7e56bf9a108b08ce5cecf6e49b9ff304de1d0701 | [
"BSD-Source-Code"
] | 2 | 2017-09-21T23:00:23.000Z | 2020-07-13T12:16:10.000Z | Assets/Plugins/iOS/WebEngage.framework/Headers/WEGMobileBridge.h | WebEngage/webengage-unity-ios | 7e56bf9a108b08ce5cecf6e49b9ff304de1d0701 | [
"BSD-Source-Code"
] | 1 | 2017-09-21T17:15:19.000Z | 2017-09-21T17:15:19.000Z | //
// WEGMobileBridge.h
// WebEngage
//
// Copyright (c) 2015 Webklipper Technologies Pvt Ltd. All rights reserved.
//
#import <UIKit/UIKit.h>
#import <WebKit/WebKit.h>
/**
* @interface WEGMobileBridge
* This facade will provide an interface to initialize your WKWebView with WebEngage's api, so that if there's a website loaded in WKWebView has WebEngage SDK integrated, all the events in web view will be recorded from mobile rather than web.
* In order to achieve this bridging, it is assumed that you have followed the instructions on https://docs.webengage.com/docs/ under Mobile-Web bridge section
*/
@interface WEGMobileBridge : NSObject <WKScriptMessageHandler>
/**
* Enhance the configuration of your WKWebview by allowing WebEngage to add configuration.
* @warning : This method is to be called while initializing your WKWebView using initWithFrame:configuration, hence make sure that your web view is competely configured before you call this method on WEGMobileBridge object, because updating web view config after this method, will overwrite WebEngage's configuration.
*
* @param webConfig Your WKWebViewConfiguration object
*/
- (WKWebViewConfiguration *)enhanceWebConfigForMobileWebBridge:(WKWebViewConfiguration *)webConfig;
@end
| 43.793103 | 319 | 0.784252 | [
"object"
] |
4318811f0868f632fbd4092bc03e939ddaa934d8 | 8,121 | c | C | myproxy/source/myproxy_get_trustroots.c | chrisburr/gct | 26b739dbdedbc7c693d26aa31202de40af5391fa | [
"Apache-2.0"
] | 44 | 2015-02-04T22:01:05.000Z | 2021-01-27T21:18:47.000Z | myproxy/source/myproxy_get_trustroots.c | chrisburr/gct | 26b739dbdedbc7c693d26aa31202de40af5391fa | [
"Apache-2.0"
] | 108 | 2017-11-01T20:22:38.000Z | 2022-03-25T18:33:20.000Z | myproxy/source/myproxy_get_trustroots.c | chrisburr/gct | 26b739dbdedbc7c693d26aa31202de40af5391fa | [
"Apache-2.0"
] | 51 | 2015-04-07T14:29:47.000Z | 2021-09-23T08:44:18.000Z | /*
* myproxy-get-trustroots
*
* Webserver program to manage trustroots from a myproxy-server
*/
#include "myproxy_common.h" /* all needed headers included here */
static char usage[] = \
"\n"
"Syntax: myproxy-get-trustroots [-s server] [-p port]...\n"
" myproxy-get-trustroots [-usage|-help] [-version]\n"
"\n"
" Options\n"
" -h | --help Displays usage\n"
" -u | --usage \n"
" \n"
" -v | --verbose Display debugging messages\n"
" -V | --version Displays version\n"
" -s | --pshost <hostname> Hostname of the myproxy-server\n"
" -p | --psport <port #> Port of the myproxy-server\n"
" -q | --quiet Only output on error\n"
" -b | --bootstrap Bootstrap trust in myproxy-server\n"
"\n";
struct option long_options[] =
{
{"help", no_argument, NULL, 'h'},
{"pshost", required_argument, NULL, 's'},
{"psport", required_argument, NULL, 'p'},
{"usage", no_argument, NULL, 'u'},
{"verbose", no_argument, NULL, 'v'},
{"version", no_argument, NULL, 'V'},
{"quiet", no_argument, NULL, 'q'},
{"bootstrap", no_argument, NULL, 'b'},
{0, 0, 0, 0}
};
static char short_options[] = "hus:p:vVqb";
static char version[] =
"myproxy-get-trustroots version " MYPROXY_VERSION " (" MYPROXY_VERSION_DATE ") " "\n";
void
init_arguments(int argc, char *argv[],
myproxy_socket_attrs_t *attrs,
myproxy_request_t *request);
/*
* Use setvbuf() instead of setlinebuf() since cygwin doesn't support
* setlinebuf().
*/
#define my_setlinebuf(stream) setvbuf((stream), (char *) NULL, _IOLBF, 0)
static int quiet = 0;
static int bootstrap = 0;
int myproxy_set_trustroots_defaults(
myproxy_socket_attrs_t *socket_attrs,
myproxy_request_t *client_request)
{
char *pshost;
client_request->version = strdup(MYPROXY_VERSION);
client_request->command_type = MYPROXY_GET_TRUSTROOTS;
client_request->want_trusted_certs = 1;
client_request->username = strdup("");
myproxy_debug("Requesting trusted certificates.\n");
pshost = getenv("MYPROXY_SERVER");
if (pshost != NULL) {
socket_attrs->pshost = strdup(pshost);
}
if (getenv("MYPROXY_SERVER_PORT")) {
socket_attrs->psport = atoi(getenv("MYPROXY_SERVER_PORT"));
} else {
socket_attrs->psport = MYPROXY_SERVER_PORT;
}
return 0;
}
int myproxy_get_trustroots(
myproxy_socket_attrs_t *socket_attrs,
myproxy_request_t *client_request,
myproxy_response_t *server_response)
{
char *request_buffer = NULL;
int requestlen;
assert(socket_attrs != NULL);
assert(client_request != NULL);
assert(server_response != NULL);
/* Set up client socket attributes */
if (socket_attrs->gsi_socket == NULL) {
if (myproxy_init_client(socket_attrs) < 0) {
return(1);
}
}
/* Attempt anonymous-mode credential retrieval if we don't have a
credential. */
GSI_SOCKET_allow_anonymous(socket_attrs->gsi_socket, 1);
/* Authenticate client to server */
if (GSI_SOCKET_context_established(socket_attrs->gsi_socket) == 0) {
if (myproxy_authenticate_init(socket_attrs, NULL) < 0) {
return(1);
}
}
/* Serialize client request object */
requestlen = myproxy_serialize_request_ex(client_request, &request_buffer);
if (requestlen < 0) {
return(1);
}
/* Send request to the myproxy-server */
if (myproxy_send(socket_attrs, request_buffer, requestlen) < 0) {
return(1);
}
free(request_buffer);
request_buffer = 0;
/* Continue unless the response is not OK */
if (myproxy_recv_response_ex(socket_attrs, server_response,
client_request) != 0) {
return(1);
}
return(0);
}
int
main(int argc, char *argv[])
{
myproxy_socket_attrs_t *socket_attrs;
myproxy_request_t *client_request;
myproxy_response_t *server_response;
int return_value = 1;
/* check library version */
if (myproxy_check_version()) {
fprintf(stderr, "MyProxy library version mismatch.\n"
"Expecting %s. Found %s.\n",
MYPROXY_VERSION_DATE, myproxy_version(0,0,0));
exit(1);
}
myproxy_log_use_stream (stderr);
my_setlinebuf(stdout);
my_setlinebuf(stderr);
socket_attrs = malloc(sizeof(*socket_attrs));
memset(socket_attrs, 0, sizeof(*socket_attrs));
client_request = malloc(sizeof(*client_request));
memset(client_request, 0, sizeof(*client_request));
server_response = malloc(sizeof(*server_response));
memset(server_response, 0, sizeof(*server_response));
/* Setup defaults */
myproxy_set_trustroots_defaults(socket_attrs,client_request);
/* Initialize client arguments and create client request object */
init_arguments(argc, argv, socket_attrs, client_request);
/* Bootstrap trusted certificate directory if none exists. */
assert(client_request->want_trusted_certs);
/* Connect to server and authenticate.
Bootstrap trust roots as needed. */
if (myproxy_bootstrap_client(socket_attrs,
client_request->want_trusted_certs,
bootstrap) < 0) {
verror_print_error(stderr);
goto cleanup;
}
if (myproxy_get_trustroots(socket_attrs, client_request, server_response)!=0) {
fprintf(stderr, "Failed to receive trustroots.\n");
verror_print_error(stderr);
goto cleanup;
}
/* Store file in trusted directory if requested and returned */
assert(client_request->want_trusted_certs);
if (server_response->trusted_certs != NULL) {
if (myproxy_install_trusted_cert_files(server_response->trusted_certs) != 0) {
verror_print_error(stderr);
goto cleanup;
} else {
char *path;
path = get_trusted_certs_path();
if (path) {
if (!quiet) {
printf("Trust roots have been installed in %s.\n", path);
}
free(path);
}
}
} else {
myproxy_debug("Requested trusted certs but didn't get any.\n");
}
return_value = 0;
cleanup:
/* free memory allocated */
myproxy_free(socket_attrs, client_request, server_response);
return return_value;
}
void
init_arguments(int argc,
char *argv[],
myproxy_socket_attrs_t *attrs,
myproxy_request_t *request)
{
extern char *optarg;
int arg;
request->want_trusted_certs = 1;
while((arg = getopt_long(argc, argv, short_options,
long_options, NULL)) != EOF)
{
switch(arg)
{
case 's': /* pshost name */
attrs->pshost = strdup(optarg);
break;
case 'p': /* psport */
attrs->psport = atoi(optarg);
break;
case 'h': /* print help and exit */
case 'u': /* print help and exit */
printf("%s", usage);
exit(0);
break;
case 'q':
quiet = 1;
break;
case 'b':
bootstrap = 1;
break;
case 'v':
myproxy_debug_set_level(1);
break;
case 'V': /* print version and exit */
printf("%s", version);
exit(0);
break;
default: /* print usage and exit */
fprintf(stderr, "%s", usage);
exit(1);
break;
}
}
if (optind != argc) {
fprintf(stderr, "%s: invalid option -- %s\n", argv[0],
argv[optind]);
fprintf(stderr, "%s", usage);
exit(1);
}
/* Check to see if myproxy-server specified */
if (attrs->pshost == NULL) {
fprintf(stderr, "Unspecified myproxy-server. Please set the MYPROXY_SERVER environment variable\nor set the myproxy-server hostname via the -s flag.\n");
exit(1);
}
return;
}
| 28.900356 | 154 | 0.595863 | [
"object"
] |
431fb1f10ace3f489e2abd34d33e395037d12af2 | 3,339 | h | C | Plugins/StreamingView/VTK/vtkImageNetCDFPOPReader.h | UV-CDAT/ParaView | 095ac28404a85fd86676491b8952884805842223 | [
"Apache-2.0"
] | 17 | 2015-02-17T00:30:26.000Z | 2022-03-17T06:13:02.000Z | Plugins/StreamingView/VTK/vtkImageNetCDFPOPReader.h | UV-CDAT/ParaView | 095ac28404a85fd86676491b8952884805842223 | [
"Apache-2.0"
] | null | null | null | Plugins/StreamingView/VTK/vtkImageNetCDFPOPReader.h | UV-CDAT/ParaView | 095ac28404a85fd86676491b8952884805842223 | [
"Apache-2.0"
] | 10 | 2015-08-31T18:20:17.000Z | 2022-02-02T15:16:21.000Z | /*=========================================================================
Program: Visualization Toolkit
Module: vtkImageNetCDFPOPReader.h
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
// .NAME vtkImageNetCDFPOPReader - read ImageNetCDF files
// .Author Joshua Wu 09.15.2009
// .SECTION Description
// vtkImageNetCDFPOPReader is a source object that reads ImageNetCDF files.
// It should be able to read most any ImageNetCDF file that wants to output a
// rectilinear grid. The ordering of the variables is changed such that
// the ImageNetCDF x, y, z directions correspond to the vtkRectilinearGrid
// z, y, x directions, respectively. The striding is done with
// respect to the vtkRectilinearGrid ordering. Additionally, the
// z coordinates of the vtkRectilinearGrid are negated so that the
// first slice/plane has the highest z-value and the last slice/plane
// has the lowest z-value.
#ifndef __vtkImageNetCDFPOPReader_h
#define __vtkImageNetCDFPOPReader_h
#include "vtkImageAlgorithm.h"
class vtkDataArraySelection;
class vtkCallbackCommand;
class VTK_EXPORT vtkImageNetCDFPOPReader : public vtkImageAlgorithm
{
public:
static vtkImageNetCDFPOPReader *New();
vtkTypeMacro(vtkImageNetCDFPOPReader, vtkImageAlgorithm);
virtual void PrintSelf(ostream& os, vtkIndent indent);
//Description:
//The file to open
vtkSetStringMacro(FileName);
vtkGetStringMacro(FileName);
vtkSetVector3Macro(Origin, double);
vtkGetVector3Macro(Origin, double);
vtkSetVector3Macro(Spacing, double);
vtkGetVector3Macro(Spacing, double);
// Description:
// Variable array selection
virtual int GetNumberOfVariableArrays();
virtual const char *GetVariableArrayName(int index);
virtual int GetVariableArrayStatus(const char *name);
virtual void SetVariableArrayStatus(const char *name, int status);
protected:
vtkImageNetCDFPOPReader();
~vtkImageNetCDFPOPReader();
virtual int ProcessRequest
(vtkInformation *request,
vtkInformationVector** inputVector,
vtkInformationVector* outputVector);
virtual int RequestData
(vtkInformation*,
vtkInformationVector**,
vtkInformationVector*);
virtual int RequestInformation
(vtkInformation* request,
vtkInformationVector** inputVector,
vtkInformationVector* outputVector);
static void SelectionModifiedCallback(vtkObject *caller, unsigned long eid,
void *clientdata, void *calldata);
static void EventCallback(vtkObject* caller, unsigned long eid,
void* clientdata, void* calldata);
vtkCallbackCommand* SelectionObserver;
char *FileName;
double Origin[3];
double Spacing[3];
int NCDFFD; //netcdf file descriptor
private:
vtkImageNetCDFPOPReader(const vtkImageNetCDFPOPReader&); // Not implemented.
void operator=(const vtkImageNetCDFPOPReader&); // Not implemented.
class Internal;
Internal* Internals;
};
#endif
| 32.417476 | 79 | 0.72357 | [
"object"
] |
43252fa2b19045b4a6f8bd872a3cec2ec9de9d8f | 442 | h | C | src/search_local/index_read/process/term_query_process.h | jdisearch/isearch1 | 272bd4ab0dc82d9e33c8543474b1294569947bb3 | [
"Apache-2.0"
] | 3 | 2021-08-18T09:59:42.000Z | 2021-09-07T03:11:28.000Z | src/search_local/index_read/process/term_query_process.h | jdisearch/isearch1 | 272bd4ab0dc82d9e33c8543474b1294569947bb3 | [
"Apache-2.0"
] | null | null | null | src/search_local/index_read/process/term_query_process.h | jdisearch/isearch1 | 272bd4ab0dc82d9e33c8543474b1294569947bb3 | [
"Apache-2.0"
] | null | null | null | #ifndef TERM_QUERY_PROCESS_H_
#define TERM_QUERY_PROCESS_H_
#include "query_process.h"
class TermQueryProcess : public QueryProcess{
public:
TermQueryProcess(const Json::Value& value);
virtual ~TermQueryProcess();
public:
virtual int ParseContent(int logic_type);
virtual int GetValidDoc(int logic_type, const std::vector<FieldInfo>& keys);
private:
virtual int ParseContent();
virtual int GetValidDoc();
};
#endif | 23.263158 | 80 | 0.757919 | [
"vector"
] |
4336f13cd47159e3027b42ac97b98a4546165b28 | 1,891 | h | C | src/util/shader.h | JyotiSunkara/PUBJ | bf2cf7fee89af4fd6e6f0e2b4f0a76ee81b01087 | [
"MIT"
] | 1 | 2021-03-21T00:31:42.000Z | 2021-03-21T00:31:42.000Z | src/util/shader.h | JyotiSunkara/PUBJ | bf2cf7fee89af4fd6e6f0e2b4f0a76ee81b01087 | [
"MIT"
] | null | null | null | src/util/shader.h | JyotiSunkara/PUBJ | bf2cf7fee89af4fd6e6f0e2b4f0a76ee81b01087 | [
"MIT"
] | null | null | null | #pragma once
#include <string>
#include "GL/glew.h"
#include "glm/glm.hpp"
// Shader wrapper class
class Shader
{
private:
GLuint fragmentShader; // ID for fragment/pixel shader
GLuint vertexShader; // ID for vertex shader
GLuint program; // ID for entire damn thing
GLint getUniLoc(GLuint, const char*); // used internally when setting uniform variables
void printShaderLogInfo(GLuint); // used for error reporting/compiler errors
char *textFileRead(const char*); // used to load shader source from file
public:
static void unbind(); // unattach shader from OpenGL context
Shader(std::string vertexFile, std::string fragmentFile); // specify vertex and fragment shaders separately and compile them together
~Shader();
void bind(); // used to bring shader into current GL context (to render with or specify uniform vars)
void link(); // called only once, after attributions have been bound via bindAttrib()
void bindAttrib(const char*, unsigned int); // specify the locations of the named vertex attributes
// various methods for setting uniform variables
void uniform1i(const char*, int);
void uniform1f(const char*, float);
void uniform1fv(const char*, int, float*);
void uniform2f(const char*, float, float);
void uniform2fv(const char*, int, float*);
void uniformVec2(const char*, glm::vec2);
void uniform3iv(const char*, int, int*);
void uniform3fv(const char*, int, float*);
void uniform3f(const char*, const float, const float, const float);
void uniformVec3(const char*, glm::vec3);
void uniformMatrix3fv(const char*, int, GLfloat*, bool = false);
void uniform4iv(const char*, int, int*);
void uniform4fv(const char*, int, float*);
void uniform4f(const char*, float, float, float, float);
void uniformVec4(const char*, glm::vec4);
void uniformMatrix4fv(const char*, int, GLfloat*, bool = false);
};
| 38.591837 | 134 | 0.722898 | [
"render"
] |
4359f29e22c279eb2f2307f603285bc74aa73c1c | 37,076 | c | C | wood-shader/wood.c | mckennapsean/wood-shader | ef642a5d5bee99ef3f743df1f1dd8d4bbcb1ccb0 | [
"MIT"
] | 10 | 2015-11-17T22:30:21.000Z | 2021-11-28T23:01:44.000Z | wood-shader/wood.c | mckennapsean/wood-shader | ef642a5d5bee99ef3f743df1f1dd8d4bbcb1ccb0 | [
"MIT"
] | null | null | null | wood-shader/wood.c | mckennapsean/wood-shader | ef642a5d5bee99ef3f743df1f1dd8d4bbcb1ccb0 | [
"MIT"
] | 3 | 2017-01-29T01:46:13.000Z | 2020-05-21T13:54:02.000Z | // renders a wood shading model, using several shaders
// most notably, wood.frag is the bulk of the wood shading
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <math.h>
#include "GL/glew.h"
#include "GL/glut.h"
#include "GL/glui.h"
#include "GL/glu.h"
#include "lib/texture.h"
#include "lib/texture.c"
using namespace std;
int main_window;
// shader variables
GLuint v0, f0, p0;
GLuint v1, f1, p1;
GLuint v2, f2, p2;
GLuint v3, f3, p3;
GLuint p1t, p2t, p2t2, p2t3, p2t4, p2t5, p2t6, p2t7, p3t;
// swap between wood and non-wood shader
bool wood = true;
// whether to debug shaders or not
bool debug = false;
// track wood object rotation
int live_rotate_object;
double rotation = 0.0;
// store which wood type to load
// 1 for maple, 4 for paduak, 7 for walnut1, 10 for walnut2, 0 for all
int woodType = 1;
int live_object_wood_type;
GLUI_RadioGroup *object_type_radio;
// algorithm control variables
float live_algo_eta;
float live_algo_width;
float live_algo_rough;
// camera info
float eye[3];
float lookat[3];
// pointers for all of the object controls
GLUI *glui;
GLUI_Rollout *object_rollout;
GLUI_Rotation *object_rotation;
GLUI_Translation *object_xz_trans;
GLUI_Translation *object_y_trans;
// algorithm controls
GLUI_Rollout *algo_rollout;
// light position controls
GLUI_Rollout *light_rollout;
GLUI_Translation *light_xz_trans;
GLUI_Translation *light_y_trans;
// disable / enable features
GLUI_Checkbox *rotate_object_check;
GLUI_Checkbox *draw_floor_check;
GLUI_Checkbox *draw_walls_check;
GLUI_Checkbox *draw_object_check;
// the user id's that we can use to identify control callbacks
#define CB_DEPTH_BUFFER 0
// live variables
// each of these are associated with a control in the interface
// when the control is modified, these variables are automatically updated
float live_object_rotation[16];
float live_object_xz_trans[2];
float live_object_y_trans;
float live_light_xz_trans[2];
float live_light_y_trans;
float live_light_intensity;
int live_draw_floor;
int live_draw_walls;
int live_draw_object;
// normalize a three-dimensional vector
void normalize(float v[3]){
float l = v[0]*v[0] + v[1]*v[1] + v[2]*v[2];
l = 1 / (float)sqrt(l);
v[0] *= l;
v[1] *= l;
v[2] *= l;
}
// dot-product of two three-dimensional vectors into a scalar
float dotproduct(float a[3], float b[3]){
return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
}
// cross-product of two three-dimensional vectors into a third vector
void crossproduct(float a[3], float b[3], float res[3]){
res[0] = (a[1] * b[2] - a[2] * b[1]);
res[1] = (a[2] * b[0] - a[0] * b[2]);
res[2] = (a[0] * b[1] - a[1] * b[0]);
}
// length of a three-dimensional vector
float length(float v[3]){
return (float)sqrt(v[0]*v[0] + v[1]*v[1] + v[2]*v[2]);
}
// when program is idle
void myGlutIdle(void){
// make sure the main window is active
if(glutGetWindow() != main_window)
glutSetWindow(main_window);
// if you have moving objects, you can do that here
// just keep redrawing the scene over and over
glutPostRedisplay();
}
// mouse handling functions for the main window
// left mouse translates, middle zooms, right rotates
// keep track of which button is down and where the last position was
int cur_button = -1;
int last_x;
int last_y;
// when a mouse action is performed
void myGlutMouse(int button, int state, int x, int y){
if (state == GLUT_DOWN)
cur_button = button;
else{
if(button == cur_button)
cur_button = -1;
}
last_x = x;
last_y = y;
}
// when the mouse is moving around
void myGlutMotion(int x, int y){
// the change in mouse position
int dx = x-last_x;
int dy = y-last_y;
float scale, len, theta;
float neye[3], neye2[3];
float f[3], r[3], u[3];
switch(cur_button){
case GLUT_LEFT_BUTTON:
// translate
f[0] = lookat[0] - eye[0];
f[1] = lookat[1] - eye[1];
f[2] = lookat[2] - eye[2];
u[0] = 0;
u[1] = 1;
u[2] = 0;
// scale the change by how far away we are
scale = sqrt(length(f)) * 0.007;
crossproduct(f, u, r);
crossproduct(r, f, u);
normalize(r);
normalize(u);
eye[0] += -r[0]*dx*scale + u[0]*dy*scale;
eye[1] += -r[1]*dx*scale + u[1]*dy*scale;
eye[2] += -r[2]*dx*scale + u[2]*dy*scale;
lookat[0] += -r[0]*dx*scale + u[0]*dy*scale;
lookat[1] += -r[1]*dx*scale + u[1]*dy*scale;
lookat[2] += -r[2]*dx*scale + u[2]*dy*scale;
break;
case GLUT_MIDDLE_BUTTON:
// zoom
f[0] = lookat[0] - eye[0];
f[1] = lookat[1] - eye[1];
f[2] = lookat[2] - eye[2];
len = length(f);
normalize(f);
// scale the change by how far away we are
len -= sqrt(len)*dx*0.03;
eye[0] = lookat[0] - len*f[0];
eye[1] = lookat[1] - len*f[1];
eye[2] = lookat[2] - len*f[2];
// make sure the eye and lookat points are sufficiently far away
// push the lookat point forward if it is too close
if(len < 1){
printf("lookat move: %f\n", len);
lookat[0] = eye[0] + f[0];
lookat[1] = eye[1] + f[1];
lookat[2] = eye[2] + f[2];
}
break;
case GLUT_RIGHT_BUTTON:
// rotate
neye[0] = eye[0] - lookat[0];
neye[1] = eye[1] - lookat[1];
neye[2] = eye[2] - lookat[2];
// first rotate in the x/z plane
theta = -dx * 0.007;
neye2[0] = (float)cos(theta)*neye[0] + (float)sin(theta)*neye[2];
neye2[1] = neye[1];
neye2[2] =-(float)sin(theta)*neye[0] + (float)cos(theta)*neye[2];
// now rotate vertically
theta = -dy * 0.007;
f[0] = -neye2[0];
f[1] = -neye2[1];
f[2] = -neye2[2];
u[0] = 0;
u[1] = 1;
u[2] = 0;
crossproduct(f, u, r);
crossproduct(r, f, u);
len = length(f);
normalize(f);
normalize(u);
neye[0] = len * ((float)cos(theta)*f[0] + (float)sin(theta)*u[0]);
neye[1] = len * ((float)cos(theta)*f[1] + (float)sin(theta)*u[1]);
neye[2] = len * ((float)cos(theta)*f[2] + (float)sin(theta)*u[2]);
eye[0] = lookat[0] - neye[0];
eye[1] = lookat[1] - neye[1];
eye[2] = lookat[2] - neye[2];
break;
}
last_x = x;
last_y = y;
glutPostRedisplay();
}
// when a keyboard action is performed
void myGlutKeyboard(unsigned char key, int x, int y){
switch(key){
// toggle wood shader
case 'w':
case 'W':
if(wood){
wood = false;
cout<<"Wood shader deactivated"<<endl;
}else{
wood = true;
cout<<"Wood shader activated"<<endl;
}
break;
// quit
case 27:
case 'q':
case 'Q':
exit(0);
break;
}
glutPostRedisplay();
}
// when the window is resized
void myGlutReshape(int x, int y){
int tx, ty, tw, th;
GLUI_Master.get_viewport_area(&tx, &ty, &tw, &th);
glViewport(tx, ty, tw, th);
glutPostRedisplay();
}
char* readShader(const char *filename){
// try to open shader file contents
FILE *file = fopen(filename, "r");
char *contents;
int count = 0;
// if missing file
if(!file){
fprintf(stderr, "Unable to open %s\n", filename);
return NULL;
}
// prepare content to be read
fseek(file, 0, SEEK_END);
count = ftell(file);
rewind(file);
// read content into memory
if(count > 0){
contents = (char *) malloc(sizeof(char) * (count + 1));
count = fread(contents, sizeof(char), count, file);
contents[count] = '\0';
}
// clean-up
fclose(file);
return contents;
}
// create all shader programs
void createShaders(){
// info log variables
GLint Result = GL_FALSE;
int InfoLogLength;
//
// p0 - phong shader
//
// store file contents
char *vs0, *fs0;
// initialize shaders
v0 = glCreateShader(GL_VERTEX_SHADER);
f0 = glCreateShader(GL_FRAGMENT_SHADER);
// load shaders from file
vs0 = readShader("phong.vert");
fs0 = readShader("phong.frag");
const char * vv0 = vs0;
const char * ff0 = fs0;
glShaderSource(v0, 1, &vv0, NULL);
glShaderSource(f0, 1, &ff0, NULL);
free(vs0);
free(fs0);
// compile shaders & log errors
glCompileShader(v0);
glGetShaderiv(v0, GL_COMPILE_STATUS, &Result);
glGetShaderiv(v0, GL_INFO_LOG_LENGTH, &InfoLogLength);
std::vector<char> VertexShaderErrorMessage0(InfoLogLength);
glGetShaderInfoLog(v0, InfoLogLength, NULL, &VertexShaderErrorMessage0[0]);
if(debug)
fprintf(stdout, "%s\n", &VertexShaderErrorMessage0[0]);
glCompileShader(f0);
glGetShaderiv(f0, GL_COMPILE_STATUS, &Result);
glGetShaderiv(f0, GL_INFO_LOG_LENGTH, &InfoLogLength);
std::vector<char> FragmentShaderErrorMessage0(InfoLogLength);
glGetShaderInfoLog(f0, InfoLogLength, NULL, &FragmentShaderErrorMessage0[0]);
if(debug)
fprintf(stdout, "%s\n", &FragmentShaderErrorMessage0[0]);
// create shader programs & log errors
p0 = glCreateProgram();
glAttachShader(p0, v0);
glAttachShader(p0, f0);
glLinkProgram(p0);
glGetProgramiv(p0, GL_LINK_STATUS, &Result);
glGetProgramiv(p0, GL_INFO_LOG_LENGTH, &InfoLogLength);
std::vector<char> ProgramErrorMessage0(max(InfoLogLength, int(1)));
if(debug)
fprintf(stdout, "%s\n", &ProgramErrorMessage0[0]);
// clear shaders
glDeleteShader(v0);
glDeleteShader(f0);
//
// p1 - texture shader (phong shading)
//
// store file contents
char *vs1, *fs1;
// initialize shaders
v1 = glCreateShader(GL_VERTEX_SHADER);
f1 = glCreateShader(GL_FRAGMENT_SHADER);
// load shaders from file
vs1 = readShader("texture.vert");
fs1 = readShader("texture.frag");
const char * vv1 = vs1;
const char * ff1 = fs1;
glShaderSource(v1, 1, &vv1, NULL);
glShaderSource(f1, 1, &ff1, NULL);
free(vs1);
free(fs1);
// compile shaders & log errors
glCompileShader(v1);
glGetShaderiv(v1, GL_COMPILE_STATUS, &Result);
glGetShaderiv(v1, GL_INFO_LOG_LENGTH, &InfoLogLength);
std::vector<char> VertexShaderErrorMessage1(InfoLogLength);
glGetShaderInfoLog(v1, InfoLogLength, NULL, &VertexShaderErrorMessage1[0]);
if(debug)
fprintf(stdout, "%s\n", &VertexShaderErrorMessage1[0]);
glCompileShader(f1);
glGetShaderiv(f1, GL_COMPILE_STATUS, &Result);
glGetShaderiv(f1, GL_INFO_LOG_LENGTH, &InfoLogLength);
std::vector<char> FragmentShaderErrorMessage1(InfoLogLength);
glGetShaderInfoLog(f1, InfoLogLength, NULL, &FragmentShaderErrorMessage1[0]);
if(debug)
fprintf(stdout, "%s\n", &FragmentShaderErrorMessage1[0]);
// create shader programs & log erfrors
p1 = glCreateProgram();
glAttachShader(p1, v1);
glAttachShader(p1, f1);
glLinkProgram(p1);
glGetProgramiv(p1, GL_LINK_STATUS, &Result);
glGetProgramiv(p1, GL_INFO_LOG_LENGTH, &InfoLogLength);
std::vector<char> ProgramErrorMessage1(max(InfoLogLength, int(1)));
if(debug)
fprintf(stdout, "%s\n", &ProgramErrorMessage1[0]);
// add program variable
p1t = glGetUniformLocation(p1, "tex");
// clear shaders
glDeleteShader(v1);
glDeleteShader(f1);
//
// p2 - wood shader (surface phong shading)
//
// store file contents
char *vs2, *fs2;
// initialize shaders
v2 = glCreateShader(GL_VERTEX_SHADER);
f2 = glCreateShader(GL_FRAGMENT_SHADER);
// load shaders from file
vs2 = readShader("wood.vert");
fs2 = readShader("wood.frag");
const char * vv2 = vs2;
const char * ff2 = fs2;
glShaderSource(v2, 1, &vv2, NULL);
glShaderSource(f2, 1, &ff2, NULL);
free(vs2);
free(fs2);
// compile shaders & log errors
glCompileShader(v2);
glGetShaderiv(v2, GL_COMPILE_STATUS, &Result);
glGetShaderiv(v2, GL_INFO_LOG_LENGTH, &InfoLogLength);
std::vector<char> VertexShaderErrorMessage2(InfoLogLength);
glGetShaderInfoLog(v2, InfoLogLength, NULL, &VertexShaderErrorMessage2[0]);
if(debug)
fprintf(stdout, "%s\n", &VertexShaderErrorMessage2[0]);
glCompileShader(f2);
glGetShaderiv(f2, GL_COMPILE_STATUS, &Result);
glGetShaderiv(f2, GL_INFO_LOG_LENGTH, &InfoLogLength);
std::vector<char> FragmentShaderErrorMessage2(InfoLogLength);
glGetShaderInfoLog(f2, InfoLogLength, NULL, &FragmentShaderErrorMessage2[0]);
if(debug)
fprintf(stdout, "%s\n", &FragmentShaderErrorMessage2[0]);
// create shader programs & log erfrors
p2 = glCreateProgram();
glAttachShader(p2, v2);
glAttachShader(p2, f2);
glLinkProgram(p2);
glGetProgramiv(p2, GL_LINK_STATUS, &Result);
glGetProgramiv(p2, GL_INFO_LOG_LENGTH, &InfoLogLength);
std::vector<char> ProgramErrorMessage2(max(InfoLogLength, int(1)));
if(debug)
fprintf(stdout, "%s\n", &ProgramErrorMessage2[0]);
// add program variable
p2t = glGetUniformLocation(p2, "intensity");
p2t2 = glGetUniformLocation(p2, "tex");
p2t3 = glGetUniformLocation(p2, "texHighlight");
p2t4 = glGetUniformLocation(p2, "texFiber");
p2t5 = glGetUniformLocation(p2, "eta");
p2t6 = glGetUniformLocation(p2, "beta");
p2t7 = glGetUniformLocation(p2, "roughness");
// clear shaders
glDeleteShader(v2);
glDeleteShader(f2);
//
// p3 - light model shader
//
// store file contents
char *vs3, *fs3;
// initialize shaders
v3 = glCreateShader(GL_VERTEX_SHADER);
f3 = glCreateShader(GL_FRAGMENT_SHADER);
// load shaders from file
vs3 = readShader("light.vert");
fs3 = readShader("light.frag");
const char * vv3 = vs3;
const char * ff3 = fs3;
glShaderSource(v3, 1, &vv3, NULL);
glShaderSource(f3, 1, &ff3, NULL);
free(vs3);
free(fs3);
// compile shaders & log errors
glCompileShader(v3);
glGetShaderiv(v3, GL_COMPILE_STATUS, &Result);
glGetShaderiv(v3, GL_INFO_LOG_LENGTH, &InfoLogLength);
std::vector<char> VertexShaderErrorMessage3(InfoLogLength);
glGetShaderInfoLog(v3, InfoLogLength, NULL, &VertexShaderErrorMessage3[0]);
fprintf(stdout, "%s\n", &VertexShaderErrorMessage3[0]);
glCompileShader(f3);
glGetShaderiv(f3, GL_COMPILE_STATUS, &Result);
glGetShaderiv(f3, GL_INFO_LOG_LENGTH, &InfoLogLength);
std::vector<char> FragmentShaderErrorMessage3(InfoLogLength);
glGetShaderInfoLog(f3, InfoLogLength, NULL, &FragmentShaderErrorMessage3[0]);
fprintf(stdout, "%s\n", &FragmentShaderErrorMessage3[0]);
// create shader programs & log errors
p3 = glCreateProgram();
glAttachShader(p3, v3);
glAttachShader(p3, f3);
glLinkProgram(p3);
glGetProgramiv(p3, GL_LINK_STATUS, &Result);
glGetProgramiv(p3, GL_INFO_LOG_LENGTH, &InfoLogLength);
std::vector<char> ProgramErrorMessage3(max(InfoLogLength, int(1)));
fprintf(stdout, "%s\n", &ProgramErrorMessage3[0]);
// add program variable
p3t = glGetUniformLocation(p3, "intensity");
// clear shaders
glDeleteShader(v3);
glDeleteShader(f3);
}
// set up the scene lighting
void lightScene(void){
// lighting: white color, position, & direction
GLfloat lcol[3] = {live_light_intensity, live_light_intensity, live_light_intensity};
GLfloat lamb[3] = {0.10, 0.10, 0.10};
GLfloat lpos[4] = {live_light_xz_trans[0], live_light_y_trans, -live_light_xz_trans[1], 0.0};
GLfloat ldir[3] = {0.0, 0.0, 0.0};
// model light as an emissive sphere
glPushMatrix();
glTranslatef(lpos[0], lpos[1], lpos[2]);
glColor3f(0.0, 0.0, 0.0);
GLfloat emission[] = {1.0, 1.0, 1.0, 1.0};
GLfloat noEmission[] = {0.0, 0.0, 0.0, 1.0};
glMaterialfv(GL_FRONT, GL_EMISSION, emission);
glUseProgram(p3);
glUniform1f(p3t, live_light_intensity);
glutSolidSphere(0.3, 64, 64);
glUseProgram(p0);
glMaterialfv(GL_FRONT, GL_EMISSION, noEmission);
glPopMatrix();
// light setup
glLighti(GL_LIGHT0, GL_SPOT_CUTOFF, 180);
glLightfv(GL_LIGHT0, GL_SPOT_DIRECTION, ldir);
glLightfv(GL_LIGHT0, GL_POSITION, lpos);
glLightfv(GL_LIGHT0, GL_DIFFUSE, lcol);
glLightfv(GL_LIGHT0, GL_AMBIENT, lamb);
glLightfv(GL_LIGHT0, GL_SPECULAR, lamb);
}
// draw the objects in the scene
void drawObjects(){
// draw wood block
if(live_draw_object){
// get object position
glPushMatrix();
glTranslatef(live_object_xz_trans[0], live_object_y_trans, -live_object_xz_trans[1]);
glMultMatrixf(live_object_rotation);
// rotate around the y-axis & increment appropriately
glPushMatrix();
if(live_rotate_object)
glRotatef(rotation, 0.0, -1.0, 0.0);
rotation += 0.4;
if(rotation >= 360.0)
rotation -= 360.0;
// background wood color
GLfloat wood_amb[] = {0.27969, 0.14375, 0.00250, 1.0};
GLfloat wood_diff[] = {0.4375, 0.21875, 0.00391, 1.0};
GLfloat wood_spec[] = {0.9975, 0.68875, 0.12391, 1.0};
glMaterialfv(GL_FRONT, GL_AMBIENT, wood_amb);
glMaterialfv(GL_FRONT, GL_DIFFUSE, wood_diff);
glMaterialfv(GL_FRONT, GL_SPECULAR, wood_spec);
// set shader for wood, if active
if(wood){
// for a single wood type
if(woodType != 0){
glUseProgram(p2);
glUniform1f(p2t, live_light_intensity);
glUniform1i(p2t2, woodType);
glUniform1i(p2t3, woodType + 1);
glUniform1i(p2t4, woodType + 2);
glUniform1f(p2t5, live_algo_eta);
glUniform1f(p2t6, live_algo_width);
glUniform1f(p2t7, live_algo_rough);
glActiveTexture(GL_TEXTURE0 + woodType);
glBindTexture(GL_TEXTURE_2D, woodType);
glActiveTexture(GL_TEXTURE0 + woodType + 1);
glBindTexture(GL_TEXTURE_2D, woodType + 1);
glActiveTexture(GL_TEXTURE0 + woodType + 2);
glBindTexture(GL_TEXTURE_2D, woodType + 2);
// for all wood types
}else{
// set up wood shader & all textures
glUseProgram(p2);
glUniform1f(p2t, live_light_intensity);
glUniform1f(p2t5, live_algo_eta);
glUniform1f(p2t6, live_algo_width);
glUniform1f(p2t7, live_algo_rough);
glUniform1i(p2t2, 1);
glUniform1i(p2t3, 2);
glUniform1i(p2t4, 3);
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, 1);
glActiveTexture(GL_TEXTURE2);
glBindTexture(GL_TEXTURE_2D, 2);
glActiveTexture(GL_TEXTURE3);
glBindTexture(GL_TEXTURE_2D, 3);
glActiveTexture(GL_TEXTURE4);
glBindTexture(GL_TEXTURE_2D, 4);
glActiveTexture(GL_TEXTURE5);
glBindTexture(GL_TEXTURE_2D, 5);
glActiveTexture(GL_TEXTURE6);
glBindTexture(GL_TEXTURE_2D, 6);
glActiveTexture(GL_TEXTURE7);
glBindTexture(GL_TEXTURE_2D, 7);
glActiveTexture(GL_TEXTURE8);
glBindTexture(GL_TEXTURE_2D, 8);
glActiveTexture(GL_TEXTURE9);
glBindTexture(GL_TEXTURE_2D, 9);
glActiveTexture(GL_TEXTURE10);
glBindTexture(GL_TEXTURE_2D, 10);
glActiveTexture(GL_TEXTURE11);
glBindTexture(GL_TEXTURE_2D, 11);
glActiveTexture(GL_TEXTURE12);
glBindTexture(GL_TEXTURE_2D, 12);
// draw wooden thin slab (maple)
glPopMatrix();
glPushMatrix();
glTranslatef(-5.0, 0.2, -5.0);
if(live_rotate_object)
glRotatef(rotation, 0.0, -1.0, 0.0);
glBegin(GL_TRIANGLE_FAN);
glNormal3f(0.0, -1.0, 0.0);
glMultiTexCoord2fARB(GL_TEXTURE1, 0.0, 0.0);
glVertex3f(-3, 0, -3);
glMultiTexCoord2fARB(GL_TEXTURE1, 1.0, 0.0);
glVertex3f( 3, 0, -3);
glMultiTexCoord2fARB(GL_TEXTURE1, 1.0, 1.0);
glVertex3f( 3, 0, 3);
glMultiTexCoord2fARB(GL_TEXTURE1, 0.0, 1.0);
glVertex3f(-3, 0, 3);
glEnd();
// draw wooden thin slab (padauk)
glUniform1i(p2t2, 4);
glUniform1i(p2t3, 5);
glUniform1i(p2t4, 6);
glPopMatrix();
glPushMatrix();
glTranslatef(5.0, 0.2, -5.0);
if(live_rotate_object)
glRotatef(rotation, 0.0, -1.0, 0.0);
glBegin(GL_TRIANGLE_FAN);
glNormal3f(0.0, -1.0, 0.0);
glMultiTexCoord2fARB(GL_TEXTURE1, 0.0, 0.0);
glVertex3f(-3, 0, -3);
glMultiTexCoord2fARB(GL_TEXTURE1, 1.0, 0.0);
glVertex3f( 3, 0, -3);
glMultiTexCoord2fARB(GL_TEXTURE1, 1.0, 1.0);
glVertex3f( 3, 0, 3);
glMultiTexCoord2fARB(GL_TEXTURE1, 0.0, 1.0);
glVertex3f(-3, 0, 3);
glEnd();
// draw wooden thin slab (walnut 1)
glUniform1i(p2t2, 7);
glUniform1i(p2t3, 8);
glUniform1i(p2t4, 9);
glPopMatrix();
glPushMatrix();
glTranslatef(5.0, 0.2, 5.0);
if(live_rotate_object)
glRotatef(rotation, 0.0, -1.0, 0.0);
glBegin(GL_TRIANGLE_FAN);
glNormal3f(0.0, -1.0, 0.0);
glMultiTexCoord2fARB(GL_TEXTURE1, 0.0, 0.0);
glVertex3f(-3, 0, -3);
glMultiTexCoord2fARB(GL_TEXTURE1, 1.0, 0.0);
glVertex3f( 3, 0, -3);
glMultiTexCoord2fARB(GL_TEXTURE1, 1.0, 1.0);
glVertex3f( 3, 0, 3);
glMultiTexCoord2fARB(GL_TEXTURE1, 0.0, 1.0);
glVertex3f(-3, 0, 3);
glEnd();
// draw wooden thin slab (walnut 2)
glUniform1i(p2t2, 10);
glUniform1i(p2t3, 11);
glUniform1i(p2t4, 12);
glPopMatrix();
glPushMatrix();
glTranslatef(-5.0, 0.2, 5.0);
if(live_rotate_object)
glRotatef(rotation, 0.0, -1.0, 0.0);
glBegin(GL_TRIANGLE_FAN);
glNormal3f(0.0, -1.0, 0.0);
glMultiTexCoord2fARB(GL_TEXTURE1, 0.0, 0.0);
glVertex3f(-3, 0, -3);
glMultiTexCoord2fARB(GL_TEXTURE1, 1.0, 0.0);
glVertex3f( 3, 0, -3);
glMultiTexCoord2fARB(GL_TEXTURE1, 1.0, 1.0);
glVertex3f( 3, 0, 3);
glMultiTexCoord2fARB(GL_TEXTURE1, 0.0, 1.0);
glVertex3f(-3, 0, 3);
glEnd();
rotation += 0.4;
if(rotation >= 360.0)
rotation -= 360.0;
}
}else{
glUseProgram(p0);
}
// draw wooden thin slab (only one)
if(woodType != 0){
glTranslatef(0, 0.2, 0);
glBegin(GL_TRIANGLE_FAN);
glNormal3f(0.0, -1.0, 0.0);
glMultiTexCoord2fARB(GL_TEXTURE1, 0.0, 0.0);
glVertex3f(-7, 0, -7);
glMultiTexCoord2fARB(GL_TEXTURE1, 1.0, 0.0);
glVertex3f( 7, 0, -7);
glMultiTexCoord2fARB(GL_TEXTURE1, 1.0, 1.0);
glVertex3f( 7, 0, 7);
glMultiTexCoord2fARB(GL_TEXTURE1, 0.0, 1.0);
glVertex3f(-7, 0, 7);
glEnd();
}
// clean-up
glUseProgram(p0);
glPopMatrix();
glPopMatrix();
}
}
// draw the floor
void drawFloor(){
// activate texturing
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, 0);
// make floor with white base
GLfloat white_amb[] = {1.00, 1.00, 1.00, 1.0};
GLfloat white_diff[] = {0.50, 0.50, 0.50, 1.0};
GLfloat white_spec[] = {0.75, 0.75, 0.75, 1.0};
GLfloat white_shin[] = {70.0};
glMaterialfv(GL_FRONT, GL_AMBIENT, white_amb);
glMaterialfv(GL_FRONT, GL_DIFFUSE, white_diff);
glMaterialfv(GL_FRONT, GL_SPECULAR, white_spec);
glMaterialfv(GL_FRONT, GL_SHININESS, white_shin);
// activate texture shader
glUseProgram(p1);
glUniform1i(p1t, 0);
// draw the floor with textures (mip-mapped checkerboard)
glBegin(GL_TRIANGLE_FAN);
glNormal3f(0.0, 1.0, 0.0);
glMultiTexCoord2fARB(GL_TEXTURE0, 0.0, 0.0);
glVertex3f(-10, 0, -10);
glMultiTexCoord2fARB(GL_TEXTURE0, 0.0, 1.5);
glVertex3f( 10, 0, -10);
glMultiTexCoord2fARB(GL_TEXTURE0, 1.5, 1.5);
glVertex3f( 10, 0, 10);
glMultiTexCoord2fARB(GL_TEXTURE0, 1.5, 0.0);
glVertex3f(-10, 0, 10);
glEnd();
// clean-up
glUseProgram(p0);
}
// draw the walls with shadows
void drawWalls(void){
// activate culling for all walls
glEnable(GL_CULL_FACE);
glCullFace(GL_FRONT);
// make walls light-blue
GLfloat blue_amb[] = {0.13, 0.11, 0.23, 1.0};
GLfloat blue_diff[] = {0.24, 0.23, 0.49, 1.0};
GLfloat blue_spec[] = {0.33, 0.49, 1.00, 1.0};
GLfloat blue_shin[] = {30.0};
glMaterialfv(GL_FRONT, GL_AMBIENT, blue_amb);
glMaterialfv(GL_FRONT, GL_DIFFUSE, blue_diff);
glMaterialfv(GL_FRONT, GL_SPECULAR, blue_spec);
glMaterialfv(GL_FRONT, GL_SHININESS, blue_shin);
glBegin(GL_QUADS);
glNormal3f(0.0, 0.0, 1.0);
glVertex3f(-10, 0, -10);
glVertex3f(-10, 20, -10);
glVertex3f(10, 20, -10);
glVertex3f(10, 0, -10);
glEnd();
// draw closest wall
glBegin(GL_QUADS);
glNormal3f(0.0, 0.0, -1.0);
glVertex3f(10, 0, 10);
glVertex3f(10, 20, 10);
glVertex3f(-10, 20, 10);
glVertex3f(-10, 0, 10);
glEnd();
// draw left side wall
glBegin(GL_QUADS);
glNormal3f(1.0, 0.0, 0.0);
glVertex3f(-10, 0, 10);
glVertex3f(-10, 20, 10);
glVertex3f(-10, 20, -10);
glVertex3f(-10, 0, -10);
glEnd();
// draw right side wall
glBegin(GL_QUADS);
glNormal3f(-1.0, 0.0, 0.0);
glVertex3f(10, 0, -10);
glVertex3f(10, 20, -10);
glVertex3f(10, 20, 10);
glVertex3f(10, 0, 10);
glEnd();
// deactivate culling
glDisable(GL_CULL_FACE);
}
// drawing the scene
void myGlutDisplay(void){
// clear screen
glClearColor(0, 0, 0, 0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// projection transform
glMatrixMode(GL_PROJECTION);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glFrustum(-1, 1, -1, 1, 1, 1000);
myGlutReshape(1000, 600);
// camera transform
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(eye[0], eye[1], eye[2], lookat[0], lookat[1], lookat[2], 0, 1, 0);
// clear what's left
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// set the wood type
if(live_object_wood_type == 0)
woodType = 1;
else if(live_object_wood_type == 1)
woodType = 4;
else if(live_object_wood_type == 2)
woodType = 7;
else if(live_object_wood_type == 3)
woodType = 10;
else if(live_object_wood_type == 4)
woodType = 0;
// activate the base shader
glUseProgram(p0);
// start drawing the scene
lightScene();
// drawing the walls
if(live_draw_walls)
drawWalls();
// drawing the floor
if(live_draw_floor)
drawFloor();
// draw the objects (wood)
drawObjects();
// update the canvas with the next view
glutSwapBuffers();
}
// callback for certain GLUI controls
void glui_cb(int control){
glutPostRedisplay();
}
// initial setup
void init(void){
GLenum err = glewInit();
if(GLEW_OK != err){
//failed to initialize GLEW!
printf("failed !!!!!!!!!!!!");
}
printf("%s", glewGetString(GLEW_VERSION));
// texture variables
static unsigned *image;
static int width, height, components;
// import checkerboard image for textures
image = read_texture("tex/board.rgb", &width, &height, &components);
glBindTexture(GL_TEXTURE_2D, 0);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
// automatic mip-mapping
gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, width, height, GL_RGBA, GL_UNSIGNED_BYTE, (const GLvoid *) image);
free(image);
// import maple wood image
image = read_texture("tex/maple.rgb", &width, &height, &components);
glBindTexture(GL_TEXTURE_2D, 1);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, image);
free(image);
// import maple wood highlight image
image = read_texture("tex/mapleHighlight.rgb", &width, &height, &components);
glBindTexture(GL_TEXTURE_2D, 2);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, image);
free(image);
// import maple wood fiber texture
image = read_texture("tex/mapleFiber.rgb", &width, &height, &components);
glBindTexture(GL_TEXTURE_2D, 3);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, image);
free(image);
// import maple wood image
image = read_texture("tex/padauk.rgb", &width, &height, &components);
glBindTexture(GL_TEXTURE_2D, 4);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, image);
free(image);
// import maple wood highlight image
image = read_texture("tex/padaukHighlight.rgb", &width, &height, &components);
glBindTexture(GL_TEXTURE_2D, 5);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, image);
free(image);
// import maple wood fiber texture
image = read_texture("tex/padaukFiber.rgb", &width, &height, &components);
glBindTexture(GL_TEXTURE_2D, 6);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, image);
free(image);
// import maple wood image
image = read_texture("tex/walnut1.rgb", &width, &height, &components);
glBindTexture(GL_TEXTURE_2D, 7);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, image);
free(image);
// import maple wood highlight image
image = read_texture("tex/walnut1Highlight.rgb", &width, &height, &components);
glBindTexture(GL_TEXTURE_2D, 8);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, image);
free(image);
// import maple wood fiber texture
image = read_texture("tex/walnut1Fiber.rgb", &width, &height, &components);
glBindTexture(GL_TEXTURE_2D, 9);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, image);
free(image);
// import maple wood image
image = read_texture("tex/walnut2.rgb", &width, &height, &components);
glBindTexture(GL_TEXTURE_2D, 10);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, image);
free(image);
// import maple wood highlight image
image = read_texture("tex/walnut2Highlight.rgb", &width, &height, &components);
glBindTexture(GL_TEXTURE_2D, 11);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, image);
free(image);
// import maple wood fiber texture
image = read_texture("tex/walnut2Fiber.rgb", &width, &height, &components);
glBindTexture(GL_TEXTURE_2D, 12);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, image);
free(image);
// create all the shaders
createShaders();
}
// main running method
int main(int argc, char* argv[]){
// set up GLUT
glutInit(&argc, argv);
// create the GLUT window with parameters
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_STENCIL | GLUT_DEPTH);
glutInitWindowSize(1000, 600);
glutInitWindowPosition(100,100);
main_window = glutCreateWindow("Wood");
init();
//printf("came into main func");
// set callbacks for different actions
glutDisplayFunc(myGlutDisplay);
GLUI_Master.set_glutReshapeFunc(myGlutReshape);
GLUI_Master.set_glutIdleFunc(myGlutIdle);
GLUI_Master.set_glutKeyboardFunc(myGlutKeyboard);
GLUI_Master.set_glutMouseFunc(myGlutMouse);
glutMotionFunc(myGlutMotion);
// create the interface subwindow and add widgets
glui = GLUI_Master.create_glui_subwindow(main_window, GLUI_SUBWINDOW_LEFT);
// initialize live variables
live_object_wood_type = 0;
live_rotate_object = 1;
live_object_xz_trans[0] = 0;
live_object_xz_trans[1] = 0;
live_object_y_trans = 0;
live_light_xz_trans[0] = 7;
live_light_xz_trans[1] = 7;
live_light_y_trans = 13;
live_draw_floor = 1;
live_draw_walls = 1;
live_draw_object = 1;
live_light_intensity = 1;
live_algo_eta = 1.50;
live_algo_width = 0.1745;
live_algo_rough = 0.20;
// quit button
glui->add_button("Quit", 0, (GLUI_Update_CB)exit);
// empty space
glui->add_statictext("");
// the object rollout
object_rollout = glui->add_rollout("Object");
// select the wood type
glui->add_statictext_to_panel(object_rollout, "Wood Type");
object_type_radio = glui->add_radiogroup_to_panel(object_rollout, &live_object_wood_type);
glui->add_radiobutton_to_group(object_type_radio, "maple");
glui->add_radiobutton_to_group(object_type_radio, "padauk");
glui->add_radiobutton_to_group(object_type_radio, "walnut1");
glui->add_radiobutton_to_group(object_type_radio, "walnut2");
glui->add_radiobutton_to_group(object_type_radio, "all types");
glui->add_column_to_panel(object_rollout, false);
// object rotation and translation controls
// we need an extra panel to keep things grouped properly
GLUI_Panel *transform_panel = glui->add_panel_to_panel(object_rollout, "", GLUI_PANEL_NONE);
object_rotation = glui->add_rotation_to_panel(transform_panel, "Rotation", live_object_rotation);
object_rotation->reset();
glui->add_column_to_panel(transform_panel, false);
object_xz_trans = glui->add_translation_to_panel(transform_panel, "Translate XZ", GLUI_TRANSLATION_XY, live_object_xz_trans);
glui->add_column_to_panel(transform_panel, false);
object_y_trans = glui->add_translation_to_panel(transform_panel, "Translate Y", GLUI_TRANSLATION_Y, &live_object_y_trans);
object_xz_trans->scale_factor = 0.1f;
object_y_trans->scale_factor = 0.1f;
glui->add_checkbox_to_panel(object_rollout, "Auto-Rotate Object", &live_rotate_object);
// empty space
glui->add_statictext("");
// lighting controls
light_rollout = glui->add_rollout("Lighting Controls");
GLUI_Panel *light_panel = glui->add_panel_to_panel(light_rollout, "", GLUI_PANEL_NONE);
light_xz_trans = glui->add_translation_to_panel(light_panel, "Translate XZ", GLUI_TRANSLATION_XY, live_light_xz_trans);
glui->add_column_to_panel(light_panel, false);
light_y_trans = glui->add_translation_to_panel(light_panel, "Translate Y", GLUI_TRANSLATION_Y, &live_light_y_trans);
GLUI_Spinner *int_l = glui->add_spinner_to_panel(light_panel, "Intensity", GLUI_SPINNER_FLOAT, &live_light_intensity);
int_l->set_float_limits(0.0, 1.0);
// empty space
glui->add_statictext("");
// algorithm controls
algo_rollout = glui->add_rollout("BRDF Controls");
GLUI_Panel *algo_panel = glui->add_panel_to_panel(algo_rollout, "", GLUI_PANEL_NONE);
GLUI_Spinner *int_m = glui->add_spinner_to_panel(algo_panel, "Index of Refraction", GLUI_SPINNER_FLOAT, &live_algo_eta);
int_m->set_float_limits(1.0, 2.0);
GLUI_Spinner *int_n = glui->add_spinner_to_panel(algo_panel, "Highlight Width", GLUI_SPINNER_FLOAT, &live_algo_width);
int_n->set_float_limits(0.0, 1.0);
GLUI_Spinner *int_o = glui->add_spinner_to_panel(algo_panel, "Specular Roughness", GLUI_SPINNER_FLOAT, &live_algo_rough);
int_o->set_float_limits(0.0, 1.0);
glui->add_statictext("");
// our checkbox options for deciding what to draw
glui->add_checkbox("Draw Floor", &live_draw_floor);
glui->add_checkbox("Draw Walls", &live_draw_walls);
glui->add_checkbox("Draw Object", &live_draw_object);
// empty space
glui->set_main_gfx_window(main_window);
// initialize the camera
eye[0] = -3;
eye[1] = 13;
eye[2] = 7;
lookat[0] = 0;
lookat[1] = 0;
lookat[2] = 0;
// activate GL modes
glEnable(GL_DEPTH_TEST);
// give control over to GLUT for continuous drawing
glutMainLoop();
return 0;
}
| 31.446989 | 127 | 0.676961 | [
"object",
"vector",
"model",
"transform"
] |
435c8c4703df58f303ff8231d12730228ca1e855 | 3,998 | h | C | radgpu/VulkanCore/VulkanPhysicalDevice.h | radcpp/radcpp | c06ba9ada18d3b8058baa88b709ac8ca91d11c38 | [
"MIT"
] | 1 | 2022-01-01T10:39:25.000Z | 2022-01-01T10:39:25.000Z | radgpu/VulkanCore/VulkanPhysicalDevice.h | radcpp/radcpp | c06ba9ada18d3b8058baa88b709ac8ca91d11c38 | [
"MIT"
] | null | null | null | radgpu/VulkanCore/VulkanPhysicalDevice.h | radcpp/radcpp | c06ba9ada18d3b8058baa88b709ac8ca91d11c38 | [
"MIT"
] | null | null | null | #ifndef VULKAN_PHYSICAL_DEVICE_H
#define VULKAN_PHYSICAL_DEVICE_H
#pragma once
#include "VulkanCommon.h"
class VulkanPhysicalDevice : public std::enable_shared_from_this<VulkanPhysicalDevice>
{
public:
VulkanPhysicalDevice(Shared<VulkanInstance> instance, VkPhysicalDevice handle);
~VulkanPhysicalDevice();
RAD_DISABLE_COPY(VulkanPhysicalDevice);
VkPhysicalDevice GetHandle() const { return m_handle; }
const VkPhysicalDeviceFeatures& GetFeatures() const { return m_features; }
const VkPhysicalDeviceProperties& GetProperties() const { return m_properties; }
const VkPhysicalDeviceFeatures2& GetFeatures2() const { return m_features2; }
const VkPhysicalDeviceProperties2& GetProperties2() const { return m_properties2; }
const VkPhysicalDeviceVulkan11Features& GetVulkan11Features() const { return m_vulkan11Features; }
const VkPhysicalDeviceVulkan12Features& GetVulkan12Features() const { return m_vulkan12Features; }
const VkPhysicalDeviceRayTracingPipelinePropertiesKHR& GetRayTracingPipelineProperties() const { return m_rayTracingPipelineProperties; }
const char* GetDeviceName() const { return m_properties.deviceName; }
const VkPhysicalDeviceMemoryProperties& GetMemoryProperties() const { return m_memoryProperties; }
const std::vector<VkQueueFamilyProperties>& GetQueueFamilyProperties() const { return m_queueFamilyProperties; }
const std::vector<VkExtensionProperties>& GetDeviceExtensionProperties() const { return m_extensionProperties; }
bool SupportsDeviceExtension(std::string_view extensionName) const;
VkFormatProperties GetFormatProperties(VkFormat format) const;
VkFormat FindFormat(ReadOnlySpan<VkFormat> candidates, VkImageTiling tiling, VkFormatFeatureFlags features);
bool SupportsSurface(uint32_t queueFamilyIndex, VkSurfaceKHR surface) const;
VkSurfaceCapabilitiesKHR GetSurfaceCapabilities(VkSurfaceKHR surface);
std::vector<VkPresentModeKHR> GetSurfacePresentModes(VkSurfaceKHR surface);
std::vector<VkSurfaceFormatKHR> GetSurfaceFormats(VkSurfaceKHR surface);
Shared<VulkanDevice> CreateDevice(const std::vector<std::string>& extensionNames);
Shared<VulkanDevice> CreateDevice();
private:
void EnumerateDeviceExtensions();
Shared<VulkanInstance> m_instance;
VkPhysicalDevice m_handle;
VkPhysicalDeviceFeatures m_features;
VkPhysicalDeviceProperties m_properties;
VkPhysicalDeviceMemoryProperties m_memoryProperties;
std::vector<VkQueueFamilyProperties> m_queueFamilyProperties;
std::vector<VkExtensionProperties> m_extensionProperties;
void QueryFeaturesAndProperties2();
VkPhysicalDeviceFeatures2 m_features2{ VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2 };
VkPhysicalDeviceProperties2 m_properties2{ VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2 };
VkPhysicalDeviceVulkan11Features m_vulkan11Features = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_1_FEATURES };
VkPhysicalDeviceVulkan12Features m_vulkan12Features = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES };
VkPhysicalDeviceSynchronization2FeaturesKHR m_synchronization2Features = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SYNCHRONIZATION_2_FEATURES_KHR };
VkPhysicalDeviceAccelerationStructureFeaturesKHR m_accelerationStructureFeatures{ VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ACCELERATION_STRUCTURE_FEATURES_KHR };
VkPhysicalDeviceAccelerationStructurePropertiesKHR m_accelerationStructureProperties{ VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ACCELERATION_STRUCTURE_PROPERTIES_KHR };
VkPhysicalDeviceRayTracingPipelineFeaturesKHR m_rayTracingPipelineFeatures{ VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RAY_TRACING_PIPELINE_FEATURES_KHR };
VkPhysicalDeviceRayTracingPipelinePropertiesKHR m_rayTracingPipelineProperties{ VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RAY_TRACING_PIPELINE_PROPERTIES_KHR };
}; // class VulkanPhysicalDevice
#endif // VULKAN_PHYSICAL_DEVICE_H
| 60.575758 | 164 | 0.823662 | [
"vector"
] |
43627a0813c026279862c18e056752141706fa2c | 4,472 | h | C | include/mtao/opengl/Window.h | mtao/core | 91f9bc6e852417989ed62675e2bb372e6afc7325 | [
"MIT"
] | null | null | null | include/mtao/opengl/Window.h | mtao/core | 91f9bc6e852417989ed62675e2bb372e6afc7325 | [
"MIT"
] | 4 | 2020-04-18T16:16:05.000Z | 2020-04-18T16:17:36.000Z | include/mtao/opengl/Window.h | mtao/core | 91f9bc6e852417989ed62675e2bb372e6afc7325 | [
"MIT"
] | null | null | null | #ifndef WINDOW_H
#define WINDOW_H
#include <Magnum/Platform/GlfwApplication.h>
#include <Magnum/GL/Context.h>
#include <Magnum/ImGuiIntegration/Context.hpp>
#include <functional>
#include "mtao/hotkey_manager.hpp"
#include <array>
#include "mtao/opengl/objects/types.h"
#include <Magnum/Mesh.h>
#include <Magnum/Math/Vector.h>
#include <Magnum/SceneGraph/Camera.h>
#include <Magnum/SceneGraph/Drawable.h>
#include <Magnum/GL/Version.h>
namespace mtao::opengl {
using namespace Magnum;
class WindowBase: public Magnum::Platform::Application {
public:
explicit WindowBase(const Arguments& arguments, GL::Version = GL::Version::None);
void drawEvent() override;
virtual void draw();
virtual void gui() = 0;
virtual void viewportEvent(ViewportEvent& event) override;
virtual void keyPressEvent(KeyEvent& event) override;
virtual void keyReleaseEvent(KeyEvent& event) override;
virtual void mousePressEvent(MouseEvent& event) override;
virtual void mouseReleaseEvent(MouseEvent& event) override;
virtual void mouseMoveEvent(MouseMoveEvent& event) override;
virtual void mouseScrollEvent(MouseScrollEvent& event) override;
virtual void textInputEvent(TextInputEvent& event) override;
bool supportsGeometryShader() const;
template <typename T>
bool isExtensionSupported() const;
private:
Magnum::ImGuiIntegration::Context _imgui{Magnum::NoCreate};
};
class Window2: public WindowBase {
public:
explicit Window2(const Arguments& arguments, GL::Version = GL::Version::None);
virtual void draw() override;
virtual void viewportEvent(ViewportEvent& event) override;
virtual void mousePressEvent(MouseEvent& event) override;
virtual void mouseReleaseEvent(MouseEvent& event) override;
virtual void mouseMoveEvent(MouseMoveEvent& event) override;
virtual void mouseScrollEvent(MouseScrollEvent& event) override;
Magnum::Vector2 cameraPosition(const Vector2i& position) const;//[0,1]^2 position of the camera
//position in 2D space with respect to the root node
Magnum::Vector2 localPosition(const Vector2i& position) const;
Object2D& root() { return _root; }
Object2D& scene() { return _scene; }
Object2D& cameraObject() { return _cameraObject; }
Magnum::SceneGraph::Camera2D& camera() { return _camera; }
Magnum::SceneGraph::DrawableGroup2D& drawables() { return _drawables; }
const Object2D& root() const { return _root; }
const Object2D& scene() const { return _scene; }
const Object2D& cameraObject() const { return _cameraObject; }
const Magnum::SceneGraph::Camera2D& camera() const { return _camera; }
const Magnum::SceneGraph::DrawableGroup2D& drawables() const { return _drawables; }
void updateTransformation();
private:
Scene2D _scene;
Object2D _root, _cameraObject;
Magnum::SceneGraph::Camera2D _camera;
Magnum::SceneGraph::DrawableGroup2D _drawables;
Magnum::Vector2 _previousPosition;
Magnum::Vector2 translation;
float scale = 1.0;
};
class Window3: public WindowBase {
public:
explicit Window3(const Arguments& arguments, GL::Version = GL::Version::None);
virtual void draw() override;
virtual void viewportEvent(ViewportEvent& event) override;
virtual void mousePressEvent(MouseEvent& event) override;
virtual void mouseReleaseEvent(MouseEvent& event) override;
virtual void mouseMoveEvent(MouseMoveEvent& event) override;
virtual void mouseScrollEvent(MouseScrollEvent& event) override;
Magnum::Vector3 positionOnSphere(const Magnum::Vector2i& position) const;
Object3D& root() { return _root; }
Object3D& scene() { return _scene; }
Magnum::SceneGraph::Camera3D& camera() { return _camera; }
Magnum::SceneGraph::DrawableGroup3D& drawables() { return _drawables; }
private:
Scene3D _scene;
Object3D _root, _cameraObject;
Magnum::SceneGraph::Camera3D _camera;
Magnum::SceneGraph::DrawableGroup3D _drawables;
Magnum::Vector3 _previousPosition;
};
template <typename T>
bool WindowBase::isExtensionSupported() const {
return Magnum::GL::Context::current().isExtensionSupported<T>();
}
}
#endif//WINDOW_H
| 36.064516 | 103 | 0.693873 | [
"mesh",
"vector"
] |
436396894d779b7deebea1db667cfbc35c1dddc6 | 777 | h | C | src/water/anim/AnimatorGerstner.h | WannaBeFaster/water | bcda6c5cfd17ad3fef7b0fdce03353827c6e7ee4 | [
"MIT"
] | 5 | 2019-09-18T18:59:30.000Z | 2019-09-23T14:25:15.000Z | src/water/anim/AnimatorGerstner.h | WannaBeFaster/water | bcda6c5cfd17ad3fef7b0fdce03353827c6e7ee4 | [
"MIT"
] | null | null | null | src/water/anim/AnimatorGerstner.h | WannaBeFaster/water | bcda6c5cfd17ad3fef7b0fdce03353827c6e7ee4 | [
"MIT"
] | null | null | null | #pragma once
#include "Animator.h"
//-------------------------------------------------------------------------------------------------
// Gerstner waves
class AnimatorGerstner : public Animator
{
public:
struct WaveSettings
{
// waves movement direction (vector length is the wind's velocity, meters/sec)
glm::vec2 k;
// unit wavevector
glm::vec2 k1;
// wave size, meters
float L;
// waves amplitude, meters
float A;
};
AnimatorGerstner() {}
void init();
void addWave(const WaveSettings& s);
virtual void update(double time);
protected:
// initial (unanimated) mesh points positions (x0, y0 array)
std::vector<glm::vec3> x0_;
std::vector<WaveSettings> waves_;
};
| 20.447368 | 99 | 0.535393 | [
"mesh",
"vector"
] |
abf2b2efae5fad56f31223ca2dc5a9397a8a76d5 | 1,209 | h | C | include/SatOps/Gyroscope.h | srenevey/satops | 7051d7734d5761c49ae23e446b6b2dfc893daf04 | [
"Apache-2.0"
] | 3 | 2021-02-16T07:37:45.000Z | 2022-03-29T07:07:09.000Z | include/SatOps/Gyroscope.h | srenevey/satops | 7051d7734d5761c49ae23e446b6b2dfc893daf04 | [
"Apache-2.0"
] | null | null | null | include/SatOps/Gyroscope.h | srenevey/satops | 7051d7734d5761c49ae23e446b6b2dfc893daf04 | [
"Apache-2.0"
] | null | null | null | //
// Created by Sylvain on 5/26/20.
//
#ifndef SATOPS_GYROSCOPE_H
#define SATOPS_GYROSCOPE_H
#include "Sensor.h"
#include "Vector.h"
#include "Matrix.h"
#include <array>
#include <random>
#include <functional>
class StateVector;
/** Model of a gyroscope (work in progress) */
class Gyroscope: public Sensor {
public:
/**
* @param[in] rotation_matrix Rotation matrix to go from body-fixed to sensor-fixed frame
* @param[in] covariance_matrix Covariance matrix in the sensor-fixed frame used to generate white noise
* @param[in] drift_rate Function returning the biases as a function of the absolute ephemeris time in the sensor-fixed frame
*/
Gyroscope(Matrix3d rotation_matrix, Matrix3d covariance_matrix, std::function<Vector3d(double)> drift_rate = {});
~Gyroscope();
/** Measures the angular rates.
*
* @param[in] state State vector of the spacecraft
* @return Angular rates in the sensor-fixed frame (in rad/s).
*/
[[nodiscard]] Vector3d measure(const StateVector& state);
private:
Matrix3d m_covariance_matrix;
std::function<Vector3d(double)> m_drift_rate;
};
#endif //SATOPS_GYROSCOPE_H
| 28.785714 | 140 | 0.692308 | [
"vector",
"model"
] |
abfbc76780fe2dcb8182907ad7f1f65d4edb5afa | 550 | h | C | include/gui/guibutton.h | Xienex/Solis | 0648b036c167e00c53b06e5c316ac25921a6395d | [
"BSD-3-Clause"
] | null | null | null | include/gui/guibutton.h | Xienex/Solis | 0648b036c167e00c53b06e5c316ac25921a6395d | [
"BSD-3-Clause"
] | null | null | null | include/gui/guibutton.h | Xienex/Solis | 0648b036c167e00c53b06e5c316ac25921a6395d | [
"BSD-3-Clause"
] | null | null | null | #pragma once
#include "solisdevice.h"
#include "guiimage.h"
#include <functional>
class GUIButton {
public:
GUIButton(const std::string& name, const Rectangle &rect = Rectangle()) :
name(std::move(name)),
transform(rect) {};
void init(Scene *);
void update(std::shared_ptr<SolisDevice>);
void draw(const VideoDriver *) const;
inline void setCallback(std::function<void()> cb) { callback = cb; };
private:
std::string name;
Rectangle transform;
std::unique_ptr<GUIImage> image;
std::function<void()> callback;
}; | 23.913043 | 75 | 0.681818 | [
"transform"
] |
abfdb64adae514ab26f79b6ae75a9df2b44c6cd8 | 4,940 | h | C | common/ObservableBase.h | CaptainSifff/QMC_Zombie | d3c843bb6ac136d1b84e04040fe71740358277a9 | [
"MIT"
] | null | null | null | common/ObservableBase.h | CaptainSifff/QMC_Zombie | d3c843bb6ac136d1b84e04040fe71740358277a9 | [
"MIT"
] | null | null | null | common/ObservableBase.h | CaptainSifff/QMC_Zombie | d3c843bb6ac136d1b84e04040fe71740358277a9 | [
"MIT"
] | null | null | null | /***************************************************************************
* Copyright (C) 2009 - 2011 by Florian Goth *
* fgoth@wthp095 *
* *
* 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 <ORGANIZATION> 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. *
***************************************************************************/
#ifndef OBSERVABLEBASE_H
#define OBSERVABLEBASE_H
#include <string>
#include <complex>
#include <vector>
#include <valarray>
#include "CacheGlue.h"
template <class Obs>
struct Mean
{
static Obs mean(const std::vector<Obs>& cont) MTL_PURE_FUNCTION
{
Obs ret(cont[0]);
for (unsigned int k = 1; k < cont.size(); ++k)
ret += cont[k];
return ret / Obs(cont.size());
}
};
template <class Obs>
struct Mean<std::valarray<Obs> >
{
static std::valarray<Obs> mean(const std::vector<std::valarray<Obs> >& cont) MTL_PURE_FUNCTION
{
std::valarray<Obs> ret(cont[0]);
for (unsigned int k = 1; k < cont.size(); ++k)
ret += cont[k];
return ret / Obs(cont.size());
}
};
template <class Obs>
struct Mean<std::valarray<std::valarray<Obs> > >
{
static std::valarray<std::valarray<Obs> > mean(const std::vector<std::valarray<std::valarray<Obs> > >& cont) MTL_PURE_FUNCTION
{
std::valarray<std::valarray<Obs> > ret(cont[0]);
for (unsigned int k = 1; k < cont.size(); ++k)
ret += cont[k];
for (unsigned int i = 0; i < ret.size(); ++i)
for (unsigned int j = 0; j < ret[i].size(); ++j)
ret[i][j] /= Obs(cont.size());
return ret;
}
};
/**
Abstract base class for all Observables
*/
template <class C, class Sign>
class ObservableBase
{
public:
typedef C Configuration;///< a typedef for the type of the Configuration
/**
virtual Destructor. For correctly tidying up all derived objects
*/
ObservableBase(std::string b) : name(b) {}
virtual ~ObservableBase() {}
virtual void dryrun(DryRun<typename C::value_type, Sign>&) = 0;
virtual void evaluate(const Configuration&, const DoWick<typename C::value_type, Sign>&) = 0;
virtual void senddata() = 0;
const std::string name;
typedef Sign GFRetVal;
protected:
private:
};
template <class Obs_Config, class Obs_Type>
class Network_Cache : public ObservableBase<typename Obs_Config::Configuration, typename Obs_Config::SignType>
{
public:
typedef typename Obs_Config::Comm Net;
inline void senddata();
inline void add_bin( const Obs_Type& val);
inline Network_Cache(Net& n, std::string name) : ObservableBase<typename Obs_Config::Configuration, typename Obs_Config::SignType>(name), net(n) {}
virtual ~Network_Cache() {}
protected:
std::vector<Obs_Type> bincache;
Net& net;
private:
};
template <class Obs_Config, class Obs_Type>
void Network_Cache<Obs_Config, Obs_Type>::add_bin(const Obs_Type& val)
{
bincache.push_back(val);
}
template <class Obs_Config, class Obs_Type>
void Network_Cache<Obs_Config, Obs_Type>::senddata()
{
Obs_Type temp (Mean<Obs_Type>::mean(bincache));
net.template sendtoserver<Obs_Type>(temp);
bincache.clear();
return;
}
#endif
| 40.162602 | 213 | 0.624494 | [
"vector"
] |
abfec259ba655105302eb92a68a96315c4c19581 | 295 | h | C | src/net_tool/net_tool.h | ClangTools/clangTools | ef2e092de04008dc312b4de28881c14eb3e5f115 | [
"Apache-2.0"
] | 7 | 2020-03-15T13:23:39.000Z | 2020-08-29T15:50:25.000Z | src/net_tool/net_tool.h | kekxv/clangTools | 44a57d0fe74d82f19eaeeeb7838158177e0415bd | [
"Apache-2.0"
] | 1 | 2021-04-11T14:04:36.000Z | 2021-04-11T14:04:36.000Z | src/net_tool/net_tool.h | kekxv/clangTools | 44a57d0fe74d82f19eaeeeb7838158177e0415bd | [
"Apache-2.0"
] | 1 | 2020-07-02T09:34:04.000Z | 2020-07-02T09:34:04.000Z | //
// Created by caesar kekxv on 2020/3/30.
//
#ifndef TOOLS_NET_TOOL_H
#define TOOLS_NET_TOOL_H
#include <vector>
#include <string>
class net_tool {
public:
static const char *TAG;
static int GetIP(std::vector<std::string> &ip, bool hasIpv6 = false);
};
#endif //TOOLS_NET_TOOL_H
| 14.75 | 73 | 0.701695 | [
"vector"
] |
28124ed284cda99769594194dd793ec7c5887310 | 3,202 | h | C | windows_sysroot/include/msvc/mm3dnow.h | ci-fuzz/bazel-toolchain | 4f42c70f17fd1a64bff2aa53a1a3d97a0b55dcdd | [
"Apache-2.0"
] | null | null | null | windows_sysroot/include/msvc/mm3dnow.h | ci-fuzz/bazel-toolchain | 4f42c70f17fd1a64bff2aa53a1a3d97a0b55dcdd | [
"Apache-2.0"
] | null | null | null | windows_sysroot/include/msvc/mm3dnow.h | ci-fuzz/bazel-toolchain | 4f42c70f17fd1a64bff2aa53a1a3d97a0b55dcdd | [
"Apache-2.0"
] | null | null | null | /***
* Copyright (C) 2007-2020 Advanced Micro Devices Inc. All rights reserved.
*
* Boost Software License - Version 1.0 - August 17th, 2003
*
* Permission is hereby granted, free of charge, to any person or organization
* obtaining a copy of the software and accompanying documentation covered by
* this license (the "Software") to use, reproduce, display, distribute,
* execute, and transmit the Software, and to prepare derivative works of the
* Software, and to permit third-parties to whom the Software is furnished to
* do so, all subject to the following:
*
* The copyright notices in the Software and this entire statement, including
* the above license grant, this restriction and the following disclaimer,
* must be included in all copies of the Software, in whole or in part, and
* all derivative works of the Software, unless such copies or derivative
* works are solely in the form of machine-executable object code generated by
* a source language processor.
*
* 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, TITLE AND NON-INFRINGEMENT. IN NO EVENT
* SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
* FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
****/
/*
* mm3dnow.h
*
*/
#pragma once
#if !defined(_M_IX86)
#error This header is specific to X86 targets
#endif
#ifndef _MM3DNOW_H_INCLUDED
#define _MM3DNOW_H_INCLUDED
#ifndef __midl
#if !defined _M_IX86
#error This header is specific to the X86 target
#endif
#include <vcruntime.h>
#include <mmintrin.h>
#include <xmmintrin.h>
#pragma warning(push)
#pragma warning(disable: _VCRUNTIME_DISABLED_WARNINGS)
#if defined __cplusplus
extern "C" { /* Intrinsics use C name-mangling. */
#endif /* defined __cplusplus */
/* 3DNOW intrinsics */
void _m_femms(void);
__m64 _m_pavgusb(__m64, __m64);
__m64 _m_pf2id(__m64);
__m64 _m_pfacc(__m64, __m64);
__m64 _m_pfadd(__m64, __m64);
__m64 _m_pfcmpeq(__m64, __m64);
__m64 _m_pfcmpge(__m64, __m64);
__m64 _m_pfcmpgt(__m64, __m64);
__m64 _m_pfmax(__m64, __m64);
__m64 _m_pfmin(__m64, __m64);
__m64 _m_pfmul(__m64, __m64);
__m64 _m_pfrcp(__m64);
__m64 _m_pfrcpit1(__m64, __m64);
__m64 _m_pfrcpit2(__m64, __m64);
__m64 _m_pfrsqrt(__m64);
__m64 _m_pfrsqit1(__m64, __m64);
__m64 _m_pfsub(__m64, __m64);
__m64 _m_pfsubr(__m64, __m64);
__m64 _m_pi2fd(__m64);
__m64 _m_pmulhrw(__m64, __m64);
void _m_prefetch(void*);
void _m_prefetchw(volatile const void*_Source);
__m64 _m_from_float(float);
float _m_to_float(__m64);
/* Athlon DSP intrinsics */
__m64 _m_pf2iw(__m64);
__m64 _m_pfnacc(__m64, __m64);
__m64 _m_pfpnacc(__m64, __m64);
__m64 _m_pi2fw(__m64);
__m64 _m_pswapd(__m64);
#if defined __cplusplus
}; /* End "C" */
#endif /* defined __cplusplus */
#pragma warning(pop) // _VCRUNTIME_DISABLED_WARNINGS
#endif /* __midl */
#endif /* _MM3DNOW_H_INCLUDED */
| 31.70297 | 79 | 0.733916 | [
"object"
] |
281b8237a0ca25aa8dca4fd22dcd0c0e32f30f38 | 582 | h | C | psx/psxbios.h | kermitdafrog8/REDasm-Loaders | b401849f9aa54dfd9562aed1a6d2e03f75ac455f | [
"MIT"
] | 4 | 2019-06-09T10:22:28.000Z | 2022-02-12T13:11:43.000Z | psx/psxbios.h | kermitdafrog8/REDasm-Loaders | b401849f9aa54dfd9562aed1a6d2e03f75ac455f | [
"MIT"
] | 1 | 2019-07-15T13:55:31.000Z | 2022-01-10T08:06:31.000Z | psx/psxbios.h | kermitdafrog8/REDasm-Loaders | b401849f9aa54dfd9562aed1a6d2e03f75ac455f | [
"MIT"
] | 2 | 2020-10-11T13:13:46.000Z | 2021-09-10T22:35:04.000Z | #pragma once
#include <rdapi/rdapi.h>
#include <vector>
#include <array>
class PsxBiosLoader
{
public:
PsxBiosLoader() = delete;
static const char* test(const RDLoaderRequest* request);
static bool load(RDContext*ctx);
private:
static void parseStrings(rd_address startaddress, const std::vector<std::string> strings, RDDocument* doc, RDContext* ctx);
static void parseROM(RDDocument* doc, RDContext* ctx);
static void parseRAM(RDDocument* doc, RDBuffer* b);
private:
static const u32 BIOS_SIGNATURE_CRC32;
};
| 26.454545 | 131 | 0.683849 | [
"vector"
] |
281c87490c3eb46d621a927bae90078a12c61b4d | 4,898 | h | C | schwarzwald/core/point_source/PointSource.h | igd-geo/schwarzwald | e3e041f87c93985394444ee056ce8ba7ae62194b | [
"Apache-2.0"
] | 10 | 2021-01-06T14:16:31.000Z | 2022-02-13T00:15:17.000Z | schwarzwald/core/point_source/PointSource.h | igd-geo/schwarzwald | e3e041f87c93985394444ee056ce8ba7ae62194b | [
"Apache-2.0"
] | 1 | 2022-03-25T08:37:30.000Z | 2022-03-30T06:28:06.000Z | schwarzwald/core/point_source/PointSource.h | igd-geo/schwarzwald | e3e041f87c93985394444ee056ce8ba7ae62194b | [
"Apache-2.0"
] | 3 | 2020-12-03T13:50:42.000Z | 2022-02-08T11:45:45.000Z | #pragma once
#include <experimental/filesystem>
#include <functional>
#include <mutex>
#include <optional>
#include <vector>
#include "algorithms/Hash.h"
#include "datastructures/PointBuffer.h"
#include "io/PointcloudFactory.h"
#include "pointcloud/PointAttributes.h"
#include "util/Error.h"
namespace fs = std::experimental::filesystem;
struct PointSource
{
using Transform = std::function<void(PointBuffer&)>;
PointSource(std::vector<fs::path> files, util::IgnoreErrors errors_to_ignore);
std::optional<PointBuffer> read_next(size_t count,
const PointAttributes& point_attributes);
void add_transformation(Transform transform);
private:
// TODO We can create this type through some meta-programming from the
// PointFile type
using CurrentFileCursor = std::variant<typename LASFile::const_iterator>;
bool try_open_file(std::vector<fs::path>::const_iterator file_cursor);
bool move_to_next_file();
std::vector<fs::path> _files;
util::IgnoreErrors _errors_to_ignore;
std::vector<fs::path>::const_iterator _file_cursor;
std::optional<PointFile> _current_file;
std::optional<CurrentFileCursor> _current_file_cursor;
std::vector<Transform> _transformations;
};
/**
* A point cloud file source that allows multiple (concurrent) readers at once.
* Concurrent reading is implemented on a file-basis, so the maximum number of
* concurrent readers will be equal to the number of files that the
* MultiReaderPointSource manages
*/
struct MultiReaderPointSource
{
/**
* API description:
*
* Readers have to request a unique source for reading:
* auto source = async_source.lock_source();
* if(!source) return;
* auto points = source.read_next(count, attributes);
*
* Once a reader is done, it has to release the source:
* async_source.release(source);
*/
using Transform =
std::function<void(util::Range<PointBuffer::PointIterator>)>;
// TODO HACK Storing the file types as variants and then storing a SEPARATE
// variant for the iterators won't compile with more than one type in the
// variants, as we have to do a double-visit on both variants I don't how to
// change this code at the moment, maybe we can get rid of the variants by
// using some regular polymorphism?
using PointFileCursor = std::variant<typename LASFile::const_iterator>;
struct PointFileEntry
{
PointFileEntry(PointFile point_file,
const fs::path& file_path,
size_t file_index);
PointFile point_file;
PointFileCursor cursor;
bool available;
fs::path file_path;
size_t file_index;
};
/**
* Handle for an open PointSource that is currently in use by some reader
*/
struct PointSourceHandle
{
friend struct MultiReaderPointSource;
std::optional<PointBuffer> read_next(
size_t count,
const PointAttributes& point_attributes);
PointBuffer::PointIterator read_next_into(
util::Range<PointBuffer::PointIterator> point_range,
const PointAttributes& point_attributes);
private:
PointSourceHandle(PointFileEntry* point_file_entry,
MultiReaderPointSource* multi_reader_source);
PointFileEntry* _point_file_entry;
MultiReaderPointSource* _multi_reader_source;
};
friend struct PointSourceHandle;
MultiReaderPointSource(std::vector<fs::path> files,
util::IgnoreErrors errors_to_ignore);
MultiReaderPointSource(MultiReaderPointSource&&) = default;
std::optional<PointSourceHandle> lock_source();
std::optional<PointSourceHandle> lock_specific_source(
const fs::path& file_name);
void release_source(const PointSourceHandle& source_handle);
size_t max_concurrent_reads();
void add_transformation(Transform transform);
private:
/**
* Reasons why 'get_specific_open_file' might fail
*/
enum class GetSpecificOpenFileFailure
{
// File requested was not yet opened
NotYetOpened,
// File requested is open, but has been locked already by a different thread
NotAvailable
};
std::unique_ptr<PointFileEntry> try_open_next_file();
std::unique_ptr<PointFileEntry> try_open_specific_file(const fs::path& file);
std::unique_ptr<PointFileEntry> do_open_file(
std::unordered_set<fs::path, util::PathHash>::iterator file_iter);
PointFileEntry* find_next_available_open_file();
tl::expected<PointFileEntry*, GetSpecificOpenFileFailure>
get_specific_open_file(const fs::path& file) const;
bool point_file_entry_is_at_end(const PointFileEntry& point_file_entry) const;
std::vector<fs::path> _files;
std::unordered_set<fs::path, util::PathHash> _next_files;
util::IgnoreErrors _errors_to_ignore;
std::vector<std::unique_ptr<PointFileEntry>> _open_files;
std::unique_ptr<std::mutex> _open_files_lock;
std::vector<Transform> _transformations;
}; | 31 | 80 | 0.734177 | [
"vector",
"transform"
] |
28399dede8c079a7b5231c9c3406a4f799a03013 | 2,680 | h | C | src/canvas.h | Jgorenburg/canvas-drawer | 082e3a97d8537956a9b4c8e2f0a6bb5f871dc8f8 | [
"MIT"
] | null | null | null | src/canvas.h | Jgorenburg/canvas-drawer | 082e3a97d8537956a9b4c8e2f0a6bb5f871dc8f8 | [
"MIT"
] | null | null | null | src/canvas.h | Jgorenburg/canvas-drawer | 082e3a97d8537956a9b4c8e2f0a6bb5f871dc8f8 | [
"MIT"
] | null | null | null | #ifndef canvas_H_
#define canvas_H_
#include <string>
#include <vector>
#include <list>
#include <map>
#include "ppm_image.h"
namespace agl
{
enum PrimitiveType {UNDEFINED, LINES, TRIANGLES, CIRCLES, ADJACENTTRIANGLES};
class canvas
{
public:
canvas(int w, int h);
virtual ~canvas();
// Save to file
void save(const std::string& filename);
// Draw primitives with a given type (either LINES or TRIANGLES)
// For example, the following draws a red line followed by a green line
// begin(LINES);
// color(255,0,0);
// vertex(0,0);
// vertex(100,0);
// color(0,255,0);
// vertex(0, 0);
// vertex(0,100);
// end();
void begin(PrimitiveType type);
void end();
// Specifiy a vertex at raster position (x,y)
// x corresponds to the column; y to the row
void vertex(int x, int y);
// Specify a color. Color components are in range [0,255]
void color(unsigned char r, unsigned char g, unsigned char b);
// Fill the canvas with the given background color
void background(unsigned char r, unsigned char g, unsigned char b);
// Turns border on and sets a color for it
// Border color defaults to white
void setBorder(unsigned char r, unsigned char g, unsigned char b);
// Toggles fill and border for shapes that aren't lines
// Deciding whether to fill is based on the first vertex
void fill();
void border();
private:
ppm_image _canvas;
bool running = false;
ppm_pixel curColor{0};
int shapeV;
PrimitiveType curtype;
bool bordr = false;
bool fillCond = true;
ppm_pixel borderColor{ 255, 255, 255 };
std::map<int, std::vector<int>> vertices;
std::map<int, ppm_pixel> colors;
// where to fill or outline shape
std::map<int, std::pair<bool, bool>> fbsit;
int clamp(int, int, int);
void drawLine(int, int);
void drawLineX(int, int);
void drawLineY(int, int);
void drawTriangle(int, int, int);
float relPosFromLine(std::vector<int>, std::vector<int>, std::vector<int>);
// takes two values, the first is the center and the second is on the perimeter
void drawCircle(int, int);
// takes an int corrosponding to the number of vertices in the shape
// draws triangles between every set of two adjacent vertices and the first vertex
// with the fill, and outline of the first vertex
// if only 2 vertices, draws a line
// if only 1, a point
// if none, do nothing
void drawUndefined(int);
};
}
#endif
| 27.916667 | 88 | 0.620522 | [
"shape",
"vector"
] |
283daa785bd53ab0fe8f8e1d42c574ce240a3b66 | 1,684 | h | C | include/nmg/globals.h | dservin/brlcad | 34b72d3efd24ac2c84abbccf9452323231751cd1 | [
"BSD-4-Clause",
"BSD-3-Clause"
] | null | null | null | include/nmg/globals.h | dservin/brlcad | 34b72d3efd24ac2c84abbccf9452323231751cd1 | [
"BSD-4-Clause",
"BSD-3-Clause"
] | null | null | null | include/nmg/globals.h | dservin/brlcad | 34b72d3efd24ac2c84abbccf9452323231751cd1 | [
"BSD-4-Clause",
"BSD-3-Clause"
] | null | null | null | /* G L O B A L S . H
* BRL-CAD
*
* Copyright (c) 2004-2022 United States Government as represented by
* the U.S. Army Research Laboratory.
*
* 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.
*
* 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 file; see the file named COPYING for more
* information.
*/
/*----------------------------------------------------------------------*/
/** @addtogroup nmg_global
*
*/
/** @{ */
/** @file nmg/globals.h */
#ifndef NMG_GLOBALS_H
#define NMG_GLOBALS_H
#include "common.h"
#include "vmath.h"
#include "bu/list.h"
#include "nmg/defines.h"
__BEGIN_DECLS
/**
* @brief debug bits for NMG's
*/
NMG_EXPORT extern uint32_t nmg_debug;
/**
* @brief
* global nmg animation vblock callback
*/
NMG_EXPORT extern void (*nmg_vlblock_anim_upcall)(void);
/**
* @brief
* global nmg mged display debug callback (ew)
*/
NMG_EXPORT extern void (*nmg_mged_debug_display_hack)(void);
/**
* @brief
* edge use distance tolerance
*/
NMG_EXPORT extern double nmg_eue_dist;
__END_DECLS
#endif /* NMG_GLOBALS_H */
/** @} */
/*
* Local Variables:
* mode: C
* tab-width: 8
* indent-tabs-mode: t
* c-file-style: "stroustrup"
* End:
* ex: shiftwidth=4 tabstop=8
*/
| 22.157895 | 74 | 0.662114 | [
"cad"
] |
284dc83f711377aff5184fe318dec95a6c5adea8 | 702 | h | C | lib/pulse_adapter/include/list_devices.h | UsatiyNyan/ledmusicrework | bfb6686d993421875a93ee3770e2f659bf932607 | [
"Apache-2.0"
] | 3 | 2020-05-05T21:25:16.000Z | 2020-05-06T07:36:56.000Z | lib/pulse_adapter/include/list_devices.h | UsatiyNyan/ledmusicrework | bfb6686d993421875a93ee3770e2f659bf932607 | [
"Apache-2.0"
] | null | null | null | lib/pulse_adapter/include/list_devices.h | UsatiyNyan/ledmusicrework | bfb6686d993421875a93ee3770e2f659bf932607 | [
"Apache-2.0"
] | null | null | null | #ifndef __LIST_DEVICES_LIB_H__
#define __LIST_DEVICES_LIB_H__
#include <pulse/pulseaudio.h>
#include <vector>
namespace pa {
struct Device {
size_t index;
char name[256];
char description[256];
};
bool operator==(const Device &device1, const Device &device2);
using DeviceVector = std::vector<Device>;
using ReadyAndDeviceVector = std::pair<bool, DeviceVector>;
class DeviceList {
public:
DeviceList();
~DeviceList();
DeviceVector get_sinks();
DeviceVector get_sources();
private:
pa_mainloop *_mainloop;
pa_mainloop_api *_mainloop_api;
pa_context *_context;
pa_operation *_operation = nullptr;
bool _ready = false;
};
} // namespace pa
#endif
| 19.5 | 62 | 0.713675 | [
"vector"
] |
284f7b43804984ebd28d762876d7b51062adb31d | 3,541 | h | C | SubtitleFontHelper/FontDatabase.h | Masaiki/SubtitleFontHelper | a81991f89b5eba0e6c6b3bd2c411351bea5b805f | [
"Apache-2.0"
] | 32 | 2020-07-28T06:51:42.000Z | 2022-03-30T02:56:48.000Z | SubtitleFontHelper/FontDatabase.h | Masaiki/SubtitleFontHelper | a81991f89b5eba0e6c6b3bd2c411351bea5b805f | [
"Apache-2.0"
] | 2 | 2022-02-22T07:09:24.000Z | 2022-02-24T09:29:08.000Z | SubtitleFontHelper/FontDatabase.h | Masaiki/SubtitleFontHelper | a81991f89b5eba0e6c6b3bd2c411351bea5b805f | [
"Apache-2.0"
] | 5 | 2021-05-24T03:24:32.000Z | 2022-03-30T02:56:40.000Z |
#pragma once
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#include <deque>
#include <list>
#include <memory>
#include <type_traits>
#include <functional>
struct FontItem {
std::wstring name;
std::wstring path;
};
class _impl_SystemFontManager;
class SystemFontManager {
private:
_impl_SystemFontManager* impl;
public:
SystemFontManager();
~SystemFontManager();
SystemFontManager(const SystemFontManager&) = delete;
SystemFontManager(SystemFontManager&&) = delete;
SystemFontManager& operator=(const SystemFontManager&) = delete;
SystemFontManager& operator=(SystemFontManager&&) = delete;
/**
@brief Query system font by name
@param name - Font name
@param exact - true: match whole name, false: match first 31 characters(workaround for the length limit of LOGFONT)
@return bool - true: font in system, false: font not in system
*/
bool QuerySystemFont(const std::wstring& name, bool exact = true);
/**
@brief Export system font by name
@param name - Font name
@param path - file to store font
@return true for success
*/
bool ExportSystemFont(const std::wstring& name, const std::wstring& path, bool exact = true);
std::pair<std::unique_ptr<char[]>, size_t> ExportSystemFontToMemory(const std::wstring& name, bool exact = true);
/**
@brief Free tempory memory
*/
void ClearState();
/**
@brief Do non export query
@param name - Font name
@return bool - true: font in system, false: font not in system
*/
bool QuerySystemFontNoExport(const std::wstring& name);
};
template<typename T>
struct PointerHasher {
typedef typename std::remove_pointer<T>::type _ValT;
typedef typename std::decay<_ValT>::type _HashFnT;
std::hash<_HashFnT> hash_func;
size_t operator()(const T& p) const {
return hash_func(*p);
}
};
template<typename T>
struct PointerEqual {
bool operator()(const T& a, const T& b)const {
return *a == *b;
}
};
class FontDatabase {
private:
typedef std::set<std::wstring>::const_iterator FontPathIter;
std::set<std::wstring> fontpath_set;
std::unordered_map<std::wstring, FontPathIter> fontname_map;
public:
FontDatabase();
~FontDatabase();
FontDatabase(FontDatabase&&) = delete;
FontDatabase(const FontDatabase&) = delete;
FontDatabase& operator=(FontDatabase&&) = delete;
FontDatabase& operator=(const FontDatabase&) = delete;
/**
@brief Open a database and add entries into memory
@param path - Path to database
@return true for success, false for failure
*/
bool LoadDatabase(const std::wstring& path);
/**
@brief Add a new font to database
@param item - Font item to be added
@return void
*/
void AddItem(const FontItem& item);
void AddItem(FontItem&& item);
/**
@brief Query a certain font in database
@param name - Display name or unique name
@return The font item. Will throw std::out_of_range if not exist
*/
FontItem QueryFont(const std::wstring& name);
/**
@brief Get count of font names
@return count
*/
size_t GetCount()const;
/**
@brief Get count of font files
@return count
*/
size_t GetFileCount()const;
};
std::wstring GetUndecoratedFontName(const std::wstring& name);
typedef std::function<void(const std::wstring&)> VisitCallback;
bool WalkDirectoryAndBuildDatabase(const std::wstring& dir, const std::wstring& db_path, VisitCallback cb,
bool recursive = true, const std::vector<std::wstring>& ext = { {L".ttf"}, {L".ttc"}, {L".otf"} }); | 27.664063 | 118 | 0.696978 | [
"vector"
] |
28554ff8844b7fa3bacfd0c8b60edff719331073 | 2,486 | h | C | include/robotics/system/system-base.h | ItsSitanshu/CppRobotics | 122a6e7897fb5a90e2ef04f76a352462d06cf25b | [
"Unlicense"
] | 1 | 2022-02-05T10:01:24.000Z | 2022-02-05T10:01:24.000Z | include/robotics/system/system-base.h | ItsSitanshu/CppRobotics | 122a6e7897fb5a90e2ef04f76a352462d06cf25b | [
"Unlicense"
] | null | null | null | include/robotics/system/system-base.h | ItsSitanshu/CppRobotics | 122a6e7897fb5a90e2ef04f76a352462d06cf25b | [
"Unlicense"
] | null | null | null | #pragma once
#include <robotics/common.h>
#include <Eigen/Dense>
namespace Robotics::Model {
/**
* @brief A class for implemeting a generic dynamical system. Mostly serves to describe an
* interface.
*/
template <int StateSize, int InputSize, int OutputSize>
class SystemBase {
public:
using State = ColumnVector<StateSize>;
using Input = ColumnVector<InputSize>;
using Output = ColumnVector<OutputSize>;
using StateMatrix = SquareMatrix<StateSize>;
using InputMatrix = Matrix<StateSize, InputSize>;
using OutputMatrix = Matrix<OutputSize, StateSize>;
using FeedthroughMatrix = Matrix<OutputSize, StateSize>;
/**
* @brief Propagates the state for one time step
* @param u system input
*/
virtual void PropagateDynamics(const Input& u) = 0;
/**
* @brief Sets the time step used to propagate the dynamics
* @param step desired time step
*/
void SetTimeStep(double step) { dt = step; };
/**
* @brief Updates the internal state of the system, which will become the new initial
* condition
* @param state new state
*/
void SetInitialState(State state) { x = state; }
/**
* @brief Gets the latest state computed
* @return the latest state
*/
State GetState() const { return x; }
/**
* @brief Gets the current output of the system
* @return the current output
*/
Output GetOutput()
{
y = C * x;
return y;
}
/**
* @brief Gets the system's output matrix
* @return theoutput matrix
*/
OutputMatrix GetOutputMatrix() const { return C; }
/**
* @brief Gets a noisy output reading
* @param noise noise statistic for the output reading
* @return the noisy output reading
*/
Output GetNoisyMeasurement(const SquareMatrix<OutputSize>& noise)
{
return C * x + noise * random.GetColumnVector<OutputSize>();
}
protected:
double dt{0.1};
State x{State::Zero()};
Output y{Output::Zero()};
StateMatrix A;
InputMatrix B;
OutputMatrix C;
FeedthroughMatrix D;
Robotics::NormalDistributionRandomGenerator random;
};
} // namespace Robotics::Model | 27.932584 | 94 | 0.574014 | [
"model"
] |
285e1ff1cff35224670dfcf60ff9d475da98f749 | 11,355 | c | C | user-contributed/lblOLD/hips/sources/isobuild/misc.c | mikelandy/HIPS | fb5440573848cd22d55771484e3c036b6007f780 | [
"MIT"
] | null | null | null | user-contributed/lblOLD/hips/sources/isobuild/misc.c | mikelandy/HIPS | fb5440573848cd22d55771484e3c036b6007f780 | [
"MIT"
] | null | null | null | user-contributed/lblOLD/hips/sources/isobuild/misc.c | mikelandy/HIPS | fb5440573848cd22d55771484e3c036b6007f780 | [
"MIT"
] | null | null | null |
/* misc.c Brian Tierney */
/* for use with the isobuild program:
* routines for array allocation / deallocation / initilization, etc
*
* 3d arrays are all allocated as arrays of pointer to arrays or pointers
* to arrays of data. This takes a bit more memory, but array element
* access is somewhat faster because there is no additions/multiplication
* used in the access, only indirection. -BT
*/
/* $Id: misc.c,v 1.3 1992/01/31 02:05:45 tierney Exp $ */
/* $Log: misc.c,v $
* Revision 1.3 1992/01/31 02:05:45 tierney
* y
*
* Revision 1.2 1991/12/19 01:42:20 davidr
* added RCS identification markers
* */
static char rcsid[] = "$Id: misc.c,v 1.3 1992/01/31 02:05:45 tierney Exp $" ;
#include "isobuild.h"
/**************************** get_max_min ****************************/
void
get_max_min(size, max, min)
int size;
Data_type *max, *min;
/* This subroutine finds the maximum & minimum data values */
{
register int i;
register Data_type *dptr;
Data_type lmin, lmax; /* local min and max variable */
dptr = data[0][0];
lmax = lmin = dptr[0];
for (i = 0; i < size; i++) {
if (dptr[i] > lmax)
lmax = dptr[i];
else if (dptr[i] < lmin)
lmin = dptr[i];
}
*max = lmax;
*min = lmin;
return;
}
/**************************************************/
Data_type ***
alloc_3d_data_array(nx, ny, nz)
int nx, ny, nz;
{
register int i, j;
Data_type ***array;
/* allocate 3-d array for input image data */
/* allocate 2 arrays of pointers */
if ((array = Calloc(nx, Data_type **)) == NULL)
perror("calloc error: data array ");
if ((array[0] = Calloc(nx * ny, Data_type *)) == NULL)
perror("calloc error: data array ");
/* allocate array for data */
if ((array[0][0] = Calloc(nx * ny * nz, Data_type)) == NULL)
perror("calloc error: data array ");
/* initialize pointer arrays */
for (i = 1; i < ny; i++)
array[0][i] = **array + (nz * i);
for (i = 1; i < nx; i++) {
array[i] = *array + (ny * i);
array[i][0] = **array + (ny * nz * i);
for (j = 1; j < ny; j++)/* initialize pointer array */
array[i][j] = array[i][0] + (nz * j);
}
return (array);
}
/***********************************************************/
Grid_type ***
alloc_3d_grid_array(nx, ny, nz) /* in hips terminology: col,row,frame */
int nx, ny, nz;
{
register int i, j;
/* allocate 3-d array for grid */
Grid_type ***array;
/* allocate 2 arrays of pointers */
if ((array = Calloc(nx, Grid_type **)) == NULL)
perror("calloc error: grid array ");
if ((array[0] = Calloc(nx * ny, Grid_type *)) == NULL)
perror("calloc error: grid array ");
/* allocate array for data */
if ((array[0][0] = Calloc(nx * ny * nz, Grid_type)) == NULL)
perror("calloc error: grid array ");
/* initialize pointer arrays */
for (i = 1; i < ny; i++)
array[0][i] = **array + (nz * i);
for (i = 1; i < nx; i++) {
array[i] = *array + (ny * i);
array[i][0] = **array + (nz * ny * i);
for (j = 1; j < ny; j++)/* initialize pointer array */
array[i][j] = array[i][0] + (nz * j);
}
return (array);
}
/***********************************************************/
NORMAL_VECT ***
alloc_3d_normal_array(nx, ny, nz) /* in hips terminology: col,row,frame */
int nx, ny, nz;
{
register int i, j;
NORMAL_VECT ***array;
/* allocate 3-d array for array */
/* allocate 2 arrays of pointers */
if ((array = Calloc(nx, NORMAL_VECT **)) == NULL)
perror("calloc error: norm array ");
if ((array[0] = Calloc(nx * ny, NORMAL_VECT *)) == NULL)
perror("calloc error: norm array ");
/* allocate array for data */
if ((array[0][0] = Calloc(nx * ny * nz, NORMAL_VECT)) == NULL)
perror("calloc error: norm array ");
/* initialize pointer arrays */
for (i = 1; i < ny; i++)
array[0][i] = **array + (nz * i);
for (i = 1; i < nx; i++) {
array[i] = *array + (ny * i);
array[i][0] = **array + (nz * ny * i);
for (j = 1; j < ny; j++)/* initialize pointer array */
array[i][j] = array[i][0] + (nz * j);
}
return (array);
}
/***********************************************************/
NORMAL_VECT **
alloc_2d_normal_array(nx, ny) /* in hips terminology: col,row,frame */
int nx, ny;
{
register int i;
NORMAL_VECT **array;
/* allocate array of pointers */
if ((array = Calloc(nx, NORMAL_VECT *)) == NULL)
perror("calloc error: 2d normal array ");
/* allocate array for data */
if ((array[0] = Calloc(nx * ny, NORMAL_VECT)) == NULL)
perror("calloc error: 2d normal array ");
/* initialize pointer arrays */
for (i = 0; i < nx; i++)
array[i] = *array + (ny * i);
return (array);
}
/***********************************************************/
FLOAT_VECT **
alloc_2d_vector_array(nx, ny) /* in hips terminology: col,row,frame */
int nx, ny;
{
register int i;
FLOAT_VECT **array;
/* allocate array of pointers */
if ((array = Calloc(nx, FLOAT_VECT *)) == NULL)
perror("calloc error: 2d vector array ");
/* allocate array for data */
if ((array[0] = Calloc(nx * ny, FLOAT_VECT)) == NULL)
perror("calloc error: 2d vector array ");
/* initialize pointer arrays */
for (i = 0; i < nx; i++)
array[i] = *array + (ny * i);
return (array);
}
/**********************************/
Data_type **
alloc_2d_data_array(nx, ny)
int nx, ny;
{
Data_type **array;
register int i;
/* allocate 2-d array for input image data */
/* allocate array of pointers */
if ((array = Calloc(nx, Data_type *)) == NULL)
perror("calloc error: 2d data array ");
/* allocate array for data */
if ((array[0] = Calloc(nx * ny, Data_type)) == NULL)
perror("calloc error: 2d data array ");
/* initialize pointer arrays */
for (i = 0; i < nx; i++)
array[i] = *array + (ny * i);
return (array);
}
/*********************************************************/
CUBE_TRIANGLES **
alloc_2d_cube_array(nx, ny)
int nx, ny;
{
CUBE_TRIANGLES **array;
register int i;
/* allocate 2-d array for input image data */
/* allocate array of pointers */
if ((array = Calloc(nx, CUBE_TRIANGLES *)) == NULL)
perror("calloc error: cube array ");
/* allocate array for data */
if ((array[0] = Calloc(nx * ny, CUBE_TRIANGLES)) == NULL)
perror("calloc error: cube array ");
/* initialize pointer arrays */
for (i = 1; i < nx; i++)
array[i] = array[0] + (ny * i);
return (array);
}
/**********************************/
Grid_type **
alloc_2d_grid_array(nx, ny)
int nx, ny;
{
Grid_type **array;
register int i;
/* allocate 2-d array for input image data */
/* allocate array of pointers */
if ((array = Calloc(nx, Grid_type *)) == NULL)
perror("calloc error: array ");
/* allocate array for data */
if ((array[0] = Calloc(nx * ny, Grid_type)) == NULL)
perror("calloc error: array ");
/* initialize pointer arrays */
for (i = 0; i < nx; i++)
array[i] = *array + (ny * i);
return (array);
}
/**********************************/
BLOCK_INFO **
alloc_block_info_array(nx, ny)
int nx, ny;
{
BLOCK_INFO **array;
register int i;
/* allocate 2-d array for input image data */
/* allocate array of pointers */
if ((array = Calloc(nx, BLOCK_INFO *)) == NULL)
perror("calloc error: array ");
/* allocate array for data */
if ((array[0] = Calloc(nx * ny, BLOCK_INFO)) == NULL)
perror("calloc error: array ");
/* initialize pointer arrays */
for (i = 0; i < nx; i++)
array[i] = *array + (ny * i);
return (array);
}
/********************************/
int
free_block_info_array(array)
BLOCK_INFO **array;
{
#ifdef CRAY
cfree((char *) array[0],NULL,NULL);
cfree((char *) array,NULL,NULL);
#else
cfree((char *) array[0]);
cfree((char *) array);
#endif
}
/********************************/
int
free_3d_data_array(array)
Data_type ***array;
{
#ifdef CRAY
cfree((char *) array[0][0],NULL,NULL);
cfree((char *) array[0],NULL,NULL);
cfree((char *) array,NULL,NULL);
#else
cfree((char *) array[0][0]);
cfree((char *) array[0]);
cfree((char *) array);
#endif
}
/********************************/
int
free_3d_normal_array(array)
NORMAL_VECT ***array;
{
#ifdef CRAY
cfree((char *) array[0][0], NULL, NULL);
cfree((char *) array[0], NULL, NULL);
cfree((char *) array, NULL, NULL);
#else
cfree((char *) array[0][0]);
cfree((char *) array[0]);
cfree((char *) array);
#endif
}
/********************************/
int
free_2d_normal_array(array)
NORMAL_VECT **array;
{
#ifdef CRAY
cfree((char *) array[0], NULL, NULL);
cfree((char *) array, NULL, NULL);
#else
cfree((char *) array[0]);
cfree((char *) array);
#endif
}
/********************************/
int
free_2d_vector_array(array)
FLOAT_VECT **array;
{
#ifdef CRAY
cfree((char *) array[0], NULL, NULL);
cfree((char *) array, NULL, NULL);
#else
cfree((char *) array[0]);
cfree((char *) array);
#endif
}
/********************************/
int
free_3d_grid_array(array)
Grid_type ***array;
{
#ifdef CRAY
cfree((char *) array[0][0], NULL, NULL);
cfree((char *) array[0], NULL, NULL);
cfree((char *) array, NULL, NULL);
#else
cfree((char *) array[0][0]);
cfree((char *) array[0]);
cfree((char *) array);
#endif
}
/*********************************/
int
free_2d_data_array(array)
Data_type **array;
{
#ifdef CRAY
cfree((char *) array[0], NULL, NULL);
cfree((char *) array, NULL, NULL);
#else
cfree((char *) array[0]);
cfree((char *) array);
#endif
}
/*********************************/
int
free_2d_cube_array(array)
CUBE_TRIANGLES **array;
{
#ifdef CRAY
cfree((char *) array[0], NULL, NULL);
cfree((char *) array, NULL, NULL);
#else
cfree((char *) array[0]);
cfree((char *) array);
#endif
}
/*********************************/
int
free_2d_grid_array(array)
Grid_type **array;
{
#ifdef CRAY
cfree((char *) array[0], NULL, NULL);
cfree((char *) array, NULL, NULL);
#else
cfree((char *) array[0]);
cfree((char *) array);
#endif
}
/***************************************/
#ifdef DEBUG_SIZE
get_mem_size()
{
int pid;
char argstr[40];
pid = getpid();
sprintf(argstr, "show_prog_size %d", pid);
(void) system(argstr);
#ifdef WANT
/* execlp uses the shell's path for searching for the executable */
(void) execlp("show_prog_size", "show_prog_size", arg1, NULL);
#endif
}
#endif
/********************************************************/
init_dup_vertex_check_arrays()
{
register int i,j;
/* reset the currslice and prevslice info */
for (i=0; i< xdim; i++)
for (j=0; j< ydim; j++) {
currslice[j][i].edge_index = -1;
currslice[j][i].num_edges = 0;
prevslice[j][i].edge_index = -1;
prevslice[j][i].num_edges = 0;
}
}
/***************************************************************/
void
Error(mesg)
char *mesg;
{
fprintf(stderr,"\n%s: Error, %s \n", MY_NAME, mesg);
exit_handler();
}
/***************************************************************/
void
Status(mesg)
char *mesg;
{
fprintf(stderr,"%s: %s \n", MY_NAME, mesg);
}
| 23.316222 | 77 | 0.523646 | [
"vector",
"3d"
] |
2867cda4011265e5bd83a27e78312f946cc9c7f3 | 10,702 | h | C | common/emu_cfg.h | intel/cm-cpu-emulation | 22f9102c8702d97c0d2a0e1864c5bf974b83752b | [
"MIT"
] | null | null | null | common/emu_cfg.h | intel/cm-cpu-emulation | 22f9102c8702d97c0d2a0e1864c5bf974b83752b | [
"MIT"
] | null | null | null | common/emu_cfg.h | intel/cm-cpu-emulation | 22f9102c8702d97c0d2a0e1864c5bf974b83752b | [
"MIT"
] | 2 | 2020-12-08T14:11:46.000Z | 2021-01-04T10:17:09.000Z | /*===================== begin_copyright_notice ==================================
Copyright (c) 2021, Intel Corporation
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.
======================= end_copyright_notice ==================================*/
#pragma once
#include <limits>
#include <string>
#include <sstream>
#include <type_traits>
#include <functional>
#include <vector>
#include "emu_log.h"
#include "emu_utils.h"
#include "emu_api_export.h"
namespace GfxEmu {
GFX_EMU_API_IMPORT struct Cfg_& Cfg();
namespace CfgCache {
inline std::atomic<bool> IsCoopFibersMode {false};
inline std::atomic<int64_t> LogChannels {GfxEmu::Log::Flags::kDefaultLogFlagsMask};
inline std::atomic<int64_t> MinimalLevel {GfxEmu::Log::Flags::kDefaultLogLevel};
inline std::string LogFileMode = "w+";
};
struct Cfg_ {
GFX_EMU_API_IMPORT Cfg_();
GFX_EMU_API_IMPORT ~Cfg_();
GFX_EMU_API_IMPORT void printSummary ();
class Param {
public:
template<bool getPrevV = false>
std::string getDbgStr() const {
const auto& source = getPrevV ? prevV : actualV;
std::stringstream ss;
ss << "[";
if(isInt () || isString ()) {
ss << "str: " << source.vStr;
ss << " int: " << std::dec << source.vInt;
ss << "(0x" << std::hex << source.vInt << ")";
}
else if(isFp ()) ss << " fp: " << source.vFp;
else if(isBool ()) ss << " bool: " << source.vBool;
ss << "]";
return ss.str();
}
private:
struct SourceSpec {
std::string env;
std::string cli;
};
SourceSpec srcSpec;
std::string name, desc;
struct Value {
std::string vStr;
int64_t vInt;
double vFp;
bool vBool;
bool operator ==(const Value& o) {
return
vStr == o.vStr &&
vInt == o.vInt &&
vFp == o.vFp &&
vBool == o.vBool
;
}
bool operator !=(const Value& o) { return !(*this == o);}
};
Value actualV, defaultV, prevV;
bool isUserDefined_ = false,
isSettingDefaults_ = false;
enum class Type {
Bool, Int, Fp, String
};
using ValueCallback = std::function<bool(Param&)>;
Type type;
ValueCallback valueCallback;
std::string valueCallbackErrStr;
static const int64_t kIntValueInvalid;
static const double kFpValueInvalid;
enum SetParams {
kNoParams = 0,
kSetDefaults = 1,
kSetSubvalue = 1 << 1,
kFromCallback = 1 << 2
};
template<
SetParams params = kNoParams,
bool setDefaults = (bool)(params & kSetDefaults),
bool setAll = !(params & kSetSubvalue),
bool fromCallback = (bool)(params & kFromCallback),
class T>
void set_(T v) {
if constexpr (setDefaults)
isSettingDefaults_ = true;
else
isUserDefined_ = true;
Value& target = setDefaults ? defaultV : actualV;
if constexpr (std::is_same_v<bool,T>) {
if constexpr (setDefaults) type = Type::Bool;
if(setAll) {
target.vInt = static_cast<int64_t>(v);
target.vFp = static_cast<double>(v);
target.vStr = std::to_string(v);
}
target.vBool = v;
} else if constexpr (std::is_integral_v<T>) {
if constexpr (setDefaults) type = Type::Int;
target.vInt = static_cast<int64_t>(v);
if(setAll) {
target.vFp = static_cast<double>(v);
target.vBool = static_cast<bool>(v);
target.vStr = std::to_string(v);
}
} else if constexpr (std::is_floating_point_v<T>) {
if constexpr (setDefaults) type = Type::Fp;
target.vFp = static_cast<double>(v);
if(setAll) {
target.vInt = static_cast<int64_t>(v);
target.vBool = static_cast<bool>(v);
target.vStr = std::to_string(v);
}
} else if constexpr (
std::is_same_v<typename std::decay<T>::type, std::string> ||
std::is_same_v<typename std::decay<T>::type, const char*>
) {
if constexpr (setDefaults) type = Type::String;
target.vStr = v;
if(setAll) {
if(isBool()) {
target.vBool = GfxEmu::Utils::stringToBool(GfxEmu::Utils::toLower(v));
target.vInt = target.vFp = target.vBool;
} else {
try {
target.vInt = std::stoll(v);
} catch (...) {
const auto extractedInts =
GfxEmu::Utils::extractFromStr<decltype(target.vInt)>(v,std::regex("[+-]?[0-9]+"));
target.vInt = extractedInts.size () ? extractedInts[0] : kIntValueInvalid;
};
try {
target.vFp = std::stod(v);
} catch (...) {
const auto extractedFp =
GfxEmu::Utils::extractFromStr<decltype(target.vFp)>(v,std::regex("[+-]?[0-9]+([.,][0-9]+)?"));
target.vFp = extractedFp.size () ? extractedFp[0] : kIntValueInvalid;
};
target.vBool = target.vInt;
}
}
}
if constexpr (setDefaults) actualV = defaultV;
if constexpr (!fromCallback) {
if(!valueCallback(*this)) {
GFX_EMU_FAIL_WITH_MESSAGE(fCfg | fSticky,
"%s\n", valueCallbackErrStr.c_str ()
);
}
if(!setDefaults) {
if(actualV != prevV) {
GFX_EMU_MESSAGE(fCfg | fSticky,
"%s <- %s (old: %s)\n",
name.c_str(),
getDbgStr ().c_str (),
getDbgStr<true> ().c_str ()
);
}
}
prevV = actualV;
}
if constexpr (setDefaults) isSettingDefaults_ = false;
}
void setFromSources () {
// Environment source.
if(srcSpec.env != "") {
const auto envValPtr = std::getenv(srcSpec.env.c_str ());
if(envValPtr) {
isUserDefined_ = true;
const auto envVal = std::string {envValPtr};
GFX_EMU_MESSAGE(fCfg | fSticky,
"ENV: %s = %s\n",
srcSpec.env.c_str (), envVal.c_str ());
if(envVal != "") {
set_(envVal);
}
}
}
}
void addToRegistry ();
public:
bool isSettingDefaults () const { return isSettingDefaults_; }
template<class T>
void set(T v) {
set_<SetParams(kFromCallback)> (v);
}
template<class T>
void setSubValue(T v) {
set_<SetParams(kSetSubvalue | kFromCallback)> (v);
}
void setValidPredErrStr(std::string v) {valueCallbackErrStr = v;}
const std::string& getStr () const { return actualV.vStr; }
template<class TargetT = int64_t>
TargetT getInt () const { return static_cast<TargetT>(actualV.vInt); }
const int64_t& getIntRef () const { return actualV.vInt; }
double getFp () const { return actualV.vFp; }
bool getBool () const { return actualV.vBool; }
std::string getDefaultStr () const { return defaultV.vStr; }
int64_t getDefaultInt () const { return defaultV.vInt; }
double getDefaultFp () const { return defaultV.vFp; }
bool getDefaultBool () const { return defaultV.vBool; }
const std::string& getName () const { return name; }
const std::string& getDesc () const { return desc; }
bool isNotDefault () const {
return actualV.vStr != defaultV.vStr;
}
bool isUserDefined() const { return isUserDefined_; }
template<class T, class dT = typename std::decay<T>::type,
std::enable_if_t<
(std::is_integral_v<dT> && !std::is_same_v<dT,bool>) ||
std::is_enum_v<dT>
,int> = 0>
explicit operator T () const { return getInt (); }
explicit operator bool () const { return getBool(); }
template<class T, std::enable_if_t<std::is_floating_point_v<typename std::decay<T>::type>,int> = 0>
explicit operator T () const { return getFp (); }
explicit operator std::string () const { return getStr (); }
explicit operator const char* () const { return getStr ().c_str (); }
bool isInt() const { return type == Type::Int; }
bool isFp() const { return type == Type::Fp; }
bool isBool() const { return type == Type::Bool; }
bool isString() const { return type == Type::String; }
Param() = default;
template<class T>
Param(
std::string name_,
std::string desc_,
SourceSpec srcSpec_,
const T& defaultV_,
ValueCallback valueCallback_ = [](Param&){return true;},
std::string valueCallbackErrStr_ = ""
) :
name(name_),
desc(desc_),
srcSpec(srcSpec_),
valueCallback(valueCallback_),
valueCallbackErrStr (valueCallbackErrStr_)
{
addToRegistry ();
set_<kSetDefaults> (defaultV_);
setFromSources();
}
}; // class Param
GFX_EMU_API_IMPORT const std::vector<const class Param*>& getParamsRegistry() const;
Param
LogFile
,LogChannels
,LogLevel
,Platform
,Sku
,ParallelThreads
,ResidentGroups
;
}; // struct Cfg_
}; // namespace GfxEmu
| 32.041916 | 122 | 0.552327 | [
"vector"
] |
930301518792bec84e49d47334527cc0e563f24d | 6,913 | c | C | TranFault_RandomFFCPI_Nagatakiya/programs/Logic-BIST-Sim-master/src/lfsr.c | YamashitaTsuyoshi/Graduate-Research-2020 | d3d46e991e789836622cfccb529de871f94d28f1 | [
"MIT"
] | null | null | null | TranFault_RandomFFCPI_Nagatakiya/programs/Logic-BIST-Sim-master/src/lfsr.c | YamashitaTsuyoshi/Graduate-Research-2020 | d3d46e991e789836622cfccb529de871f94d28f1 | [
"MIT"
] | null | null | null | TranFault_RandomFFCPI_Nagatakiya/programs/Logic-BIST-Sim-master/src/lfsr.c | YamashitaTsuyoshi/Graduate-Research-2020 | d3d46e991e789836622cfccb529de871f94d28f1 | [
"MIT"
] | 15 | 2021-02-23T04:18:51.000Z | 2021-03-12T07:33:49.000Z | #include "declare.h"
#include "def_gtype.h"
#include "def_flt.h"
#include "math.h"
//#define DEBUG 1 //20140922
//#define ALPMODE 1 //0:AI-RTPG 1:Basic ALP-RTPG 2:Combination of AI&ALP
#define TAP_NUM 5
unsigned int TapGen_state[TAP_NUM];
void InternalLfsrGen(int *Xor);
void phase_shifter(int LFSR[], int nBit);
void phase_shifter(int LFSR[], int nBit)
{
int ia;
for (ia = 1; ia < nBit; ia++)
LFSR[ia] ^= LFSR[ia - 1];
}
void InternalLfsrGen(int *Xor)
{
int i, count = 0, tmp[LFSR_BIT + 1];
unsigned int feedbackbit = 0, mask = 0, temple = 0;
while (count < TAP_NUM / 2 + 1)
{
feedbackbit = TapGen_state[TAP_NUM / 2 + count] & 1;
temple = (feedbackbit << (LFSR_BIT - 1)) | (TapGen_state[TAP_NUM / 2 + count] >> 1);
mask = 0;
for (i = 2; i <= Xor[0]; i++)
mask |= (feedbackbit << (LFSR_BIT - Xor[i] - 1));
count++;
TapGen_state[TAP_NUM / 2 + count] = temple ^ mask;
#if PHASE
for (i = 0; i < LFSR_BIT; i++)
tmp[i] = TapGen_state[TAP_NUM / 2 + count] >> (LFSR_BIT - i - 1);
phase_shifter(tmp, LFSR_BIT);
#endif
}
}
void reseeding(lfsr_state, cnt) int lfsr_state[];
int cnt;
{
int ia;
unsigned int seed = 0;
FILE *fin;
#if RANDOMSEED
seed = (unsigned int)(rand() % 65535);
printf("seedcount=%d seed=%d--", cnt, seed);
for (ia = 16 - 1; ia >= 0; ia--)
printf("%d", (seed >> ia) & 0x0001);
printf("\n");
#elif SEEDMEMORY
if ((fin = fopen("seed.dat", "r")) == NULL)
{
printf("error: 'seed.dat' is not found\n");
exit(1);
}
for (ia = 0; ia < cnt; ia++)
fscanf(fin, "%d", &seed);
fclose(fin);
#endif
TapGen_state[TAP_NUM / 2] = seed;
printf("TapGen_state=%d\n", TapGen_state[TAP_NUM / 2]);
}
void initial_lfsr(EX_OR, lfsr_state, ff_state) int EX_OR[];
int lfsr_state[];
int ff_state[];
{
int ia, max;
char buf[20];
FILE *fin;
srand((unsigned)time(NULL));
for (ia = 0; ia <= LFSR_BIT; ia++)
{ //initialize SI's LFSR
if (ia % 4)
lfsr_state[ia] = 0;
else
lfsr_state[ia] = 1;
}
for (ia = 0; ia <= ffnum; ia++) //initialize FF state
ff_state[ia] = 0;
CHAINLENGTH = 100;
if (ffnum > LFSR_BIT * CHAINLENGTH)
{
printf("warning:ffnum is must smaller than LFSR_BIT*CHAINLENGTH\n");
CHAINLENGTH = (1 + ffnum / (LFSR_BIT * CHAINLENGTH)) * 100;
}
chainnum = (ffnum - 1) / CHAINLENGTH + 1;
#if POWEREVA
for (ia = 0; ia < chainnum; ia++)
ShiftPeak[ia] = 0.0;
#endif
schain = (SCAN_CHAIN *)calloc(chainnum, sizeof(SCAN_CHAIN));
if (schain == NULL)
printf("memory error @initial_lfsr\n"), exit(1);
fin = fopen("lfsr.dat", "r");
if (fin == NULL)
{
printf("error: 'lfsr.dat' is not found\n");
exit(1);
}
fscanf(fin, "%d", &max);
if ((LFSR_BIT > max) || (chainnum > max))
{
printf("error: too many LFSR bits!\n");
fclose(fin);
exit(1);
}
for (ia = 0; ia < LFSR_BIT; ia++)
if (fgets(buf, 20, fin) == NULL)
{
printf("error: too many fins!\n");
fclose(fin);
exit(1);
}
fscanf(fin, "%d", &EX_OR[0]);
for (ia = 1; ia <= EX_OR[0]; ia++)
fscanf(fin, "%d", &EX_OR[ia]);
fclose(fin);
for (ia = 0; ia < chainnum; ia++)
{
if (ia == 0)
schain[ia].top = 0;
else
schain[ia].top = schain[ia - 1].top + schain[ia - 1].length;
schain[ia].length = (ffnum - schain[ia].top) / (chainnum - ia);
//schain[ia].lastval = ff_state[schain[ia].top + schain[ia].length - 1];
schain[ia].lastval = ff_state[schain[ia].top];
}
}
int PeakTogCount(ff_state, chainum) int ff_state[];
{
int ia, bitval, togglecount = 0;
bitval = ff_state[schain[chainum].top];
//printf("bitval %d \n",bitval);
for (ia = schain[chainum].top + 1; ia < schain[chainum].top + schain[chainum].length; ia++)
{
if (ff_state[ia] != bitval)
{
togglecount++;
bitval = ff_state[ia];
}
}
return togglecount;
//printf("chain %d \n",togglecount);
}
void lfsr_next(EX_OR, lfsr_state, ff_state) int EX_OR[];
int lfsr_state[];
int ff_state[];
{
int ia, ib, i;
#if POWEREVA&&PEAK
int OrigPatTog[chainnum], TogPerClk[chainnum];
int Tem_state[ffnum];
for (ia = 0; ia < ffnum; ia++)
Tem_state[ia] = ff_state[ia];
for (ia = 0; ia < chainnum; ia++)
{
OrigPatTog[ia] = 0;
TogPerClk[ia] = 0;
OrigPatTog[ia] = PeakTogCount(ff_state, ia);
//printf("chain %d = %d \n",ia,OrigPatTog[ia]);
}
#endif
for (ia = 0; ia <= (ffnum - 1) / chainnum; ia++)
{
for (ib = 0; ib < chainnum; ib++)
{
if (schain[ib].length == (ffnum - 1) / chainnum)
{
if (ia != 0)
ff_state[schain[ib].top + schain[ib].length - ia] = lfsr_state[ib];
}
else
ff_state[schain[ib].top + schain[ib].length - ia - 1] = lfsr_state[ib];
#if POWEREVA
if (ff_state[schain[ib].top + schain[ib].length - ia - 1] != schain[ib].lastval)
{
toggle_scn += schain[ib].length - ia;
toggle_scn_in += schain[ib].length - ia;
toggle_shift_perpat += schain[ib].length - ia;
#if PEAK
TogPerClk[ib] = OrigPatTog[ib] + 1;
if (ia <= schain[ib].length - 2 && Tem_state[schain[ib].top + schain[ib].length - ia - 1] == Tem_state[schain[ib].top + schain[ib].length - ia - 2])
OrigPatTog[ib]++;
#endif
}
else
{
#if PEAK
TogPerClk[ib] = OrigPatTog[ib];
if (ia <= schain[ib].length - 2 && Tem_state[schain[ib].top + schain[ib].length - ia - 1] != Tem_state[schain[ib].top + schain[ib].length - ia - 2])
OrigPatTog[ib]--;
#endif
}
#endif
#if PEAK
if (TogPerClk[ib] > ShiftPeak[ib])
ShiftPeak[ib] = TogPerClk[ib];
#endif
schain[ib].lastval = ff_state[schain[ib].top + schain[ib].length - ia - 1];
}
#if DEBUG
if (ia == 0)
{
printf("\nLFSR state:\n");
printf(" ");
for (ib = 0; ib <= LFSR_BIT; ib++)
printf("%2d ", ib);
printf("\n");
printf(" ");
for (ib = 0; ib <= LFSR_BIT; ib++)
printf("===", ib);
printf("\n");
}
printf("%3d |", ia);
for (ib = 0; ib <= LFSR_BIT; ib++)
printf(" %d ", lfsr_state[ib]);
printf("\n");
#endif //LFSR pattern input
if (clocktime == 1 && ia == 0)
{
//phase_shifter(lfsr_state, LFSR_BIT);
for (i = 0; i < TAP_NUM; i++)
TapGen_state[i] = 0;
for (i = 0; i < LFSR_BIT; i++)
TapGen_state[TAP_NUM / 2] |= (lfsr_state[i] << (LFSR_BIT - i - 1));
}
InternalLfsrGen(EX_OR);
for (ib = 0; ib < LFSR_BIT; ib++)
lfsr_state[ib] = (TapGen_state[TAP_NUM / 2 + 1] >> (LFSR_BIT - ib - 1)) & 1;
TapGen_state[TAP_NUM / 2] = TapGen_state[TAP_NUM / 2 + 1];
TapGen_state[TAP_NUM / 2 + 1] = 0;
}
#if DEBUG
printf("\n");
for (ia = 0; ia < chainnum; ia++)
{
printf("sc%-2d:", ia);
for (ib = 0; ib < schain[ia].length; ib++)
printf("%d", ff_state[schain[ia].top + ib]);
printf("\n");
}
#endif
}
| 24.866906 | 156 | 0.557211 | [
"3d"
] |
9304daa2b2369165362781f56e7138ca2e074f5e | 929 | h | C | include/generators/image_batch_reader.h | omidsakhi/deepflow | f38190ca54047aba21abdcadd1fac776dd595053 | [
"BSD-3-Clause"
] | 11 | 2017-04-04T13:44:50.000Z | 2022-03-05T04:27:02.000Z | include/generators/image_batch_reader.h | omidsakhi/deepflow | f38190ca54047aba21abdcadd1fac776dd595053 | [
"BSD-3-Clause"
] | null | null | null | include/generators/image_batch_reader.h | omidsakhi/deepflow | f38190ca54047aba21abdcadd1fac776dd595053 | [
"BSD-3-Clause"
] | 3 | 2018-12-05T03:07:22.000Z | 2020-06-20T09:02:24.000Z | #pragma once
#include "core/node.h"
#include <filesystem>
class Initializer;
#include <opencv2/opencv.hpp>
class DeepFlowDllExport ImageBatchReader : public Node {
public:
ImageBatchReader(deepflow::NodeParam *param);
int minNumInputs() override { return 0; }
int minNumOutputs() override { return 1; }
std::string op_name() const override { return "image_batch_reader"; }
bool is_generator() override { return true; }
void init() override;
void forward() override;
void backward() override {}
bool is_last_batch() override;
std::string to_cpp() const override;
private:
std::string _folder_path;
std::array<int, 4> _dims;
std::vector<int> _indices;
std::vector<std::experimental::filesystem::path> _list_of_files;
int _current_batch = -1;
size_t _num_total_samples = 0;
int _num_batches = 0;
int _batch_size = 0;
bool _last_batch = false;
bool _randomize = false;
bool _between_0_and_1 = false;
};
| 25.108108 | 70 | 0.737352 | [
"vector"
] |
930f7c685f8a9ee8dc69c90e68397de1c20f0f7c | 3,225 | h | C | pratt_parser/PrattParser.h | a-downing/stuff | 0e44cb3fcdecf91a01f702fda797d7a32d7a9496 | [
"MIT"
] | null | null | null | pratt_parser/PrattParser.h | a-downing/stuff | 0e44cb3fcdecf91a01f702fda797d7a32d7a9496 | [
"MIT"
] | null | null | null | pratt_parser/PrattParser.h | a-downing/stuff | 0e44cb3fcdecf91a01f702fda797d7a32d7a9496 | [
"MIT"
] | null | null | null | #ifndef PRATT_PARSER_H
#define PRATT_PARSER_H
#include <cstddef>
#include <vector>
#include <memory>
#include <array>
#include <concepts>
template<typename T>
concept IndexableToken = requires(T a) {
{ a.value } -> std::convertible_to<typename T::value_type>;
{ T::index(a.value) } -> std::same_as<std::size_t>;
{ T::max_index_v } -> std::convertible_to<std::size_t>;
};
template<typename T>
concept MovableExpression = std::move_constructible<T>;
template<IndexableToken Token_T, MovableExpression Expression_T>
class PrattParser {
public:
using PrefixParselet_t = Expression_T (*)(int precedence, const Token_T &, PrattParser &parser);
using InfixParselet_t = Expression_T (*)(int precedence, Expression_T, const Token_T &, PrattParser &parser);
private:
struct PrefixParselet {
int precedence = 0;
PrefixParselet_t func = nullptr;
};
struct InfixParselet {
int precedence = 0;
InfixParselet_t func = nullptr;
};
std::array<PrefixParselet, Token_T::max_index_v + 1> m_prefixParselets;
std::array<InfixParselet, Token_T::max_index_v + 1> m_infixParselets;
const std::vector<Token_T> *m_tokens{};
std::size_t *m_index = nullptr;
int getPrecedence(typename Token_T::value_type value) const {
if(Token_T::index(value) < m_infixParselets.size()) {
return m_infixParselets[Token_T::index(value)].precedence;
} else {
return 0;
}
}
public:
Expression_T parseExpression(const std::vector<Token_T> &tokens, std::size_t &index) {
m_index = &index;
m_tokens = &tokens;
return parse();
}
void addPrefixParselet(typename Token_T::value_type value, int precedence, PrefixParselet_t prefixParselet) {
m_prefixParselets[Token_T::index(value)] = {precedence, prefixParselet};
}
void addInfixParselet(typename Token_T::value_type value, int precedence, InfixParselet_t infixParselet) {
m_infixParselets[Token_T::index(value)] = {precedence, infixParselet};
}
Expression_T parse(int precedence = 0) {
if(end()) {
return nullptr;
}
const Token_T &token_l = consume();
PrefixParselet prefixParselet = m_prefixParselets[Token_T::index(token_l.value)];
if(prefixParselet.func == nullptr) {
return nullptr;
}
Expression_T left = prefixParselet.func(prefixParselet.precedence, token_l, *this);
if(!left) {
return nullptr;
}
while(!end() && precedence < getPrecedence(peek().value)) {
const Token_T &token_r = consume();
InfixParselet infixParselet = m_infixParselets[Token_T::index(token_r.value)];
if(infixParselet.func == nullptr) {
break;
}
left = infixParselet.func(infixParselet.precedence, std::move(left), token_r, *this);
}
return left;
}
const Token_T &consume() {
return m_tokens->at((*m_index)++);
}
[[nodiscard]] const Token_T &peek() const {
return m_tokens->at(*m_index);
}
bool end() const {
return *m_index == m_tokens->size();
}
};
#endif
| 29.054054 | 113 | 0.642171 | [
"vector"
] |
931970f0e0fab527439b2e1632c29e7aaffeb0e3 | 1,671 | h | C | mindspore/ccsrc/cxx_api/model/acl/acl_vm/ms_tensor_ref.h | PowerOlive/mindspore | bda20724a94113cedd12c3ed9083141012da1f15 | [
"Apache-2.0"
] | 3,200 | 2020-02-17T12:45:41.000Z | 2022-03-31T20:21:16.000Z | mindspore/ccsrc/cxx_api/model/acl/acl_vm/ms_tensor_ref.h | zimo-geek/mindspore | 665ec683d4af85c71b2a1f0d6829356f2bc0e1ff | [
"Apache-2.0"
] | 176 | 2020-02-12T02:52:11.000Z | 2022-03-28T22:15:55.000Z | mindspore/ccsrc/cxx_api/model/acl/acl_vm/ms_tensor_ref.h | zimo-geek/mindspore | 665ec683d4af85c71b2a1f0d6829356f2bc0e1ff | [
"Apache-2.0"
] | 621 | 2020-03-09T01:31:41.000Z | 2022-03-30T03:43:19.000Z | /**
* Copyright 2021 Huawei Technologies Co., Ltd
*
* 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 MINDSPORE_CCSRC_CXX_API_ACL_VM_MS_TENSOR_REF_H
#define MINDSPORE_CCSRC_CXX_API_ACL_VM_MS_TENSOR_REF_H
#include <memory>
#include <string>
#include <vector>
#include "include/api/types.h"
#include "mindspore/core/base/base_ref.h"
namespace mindspore {
class MSTensorRef : public BaseRef {
public:
MS_DECLARE_PARENT(MSTensorRef, BaseRef);
static VectorRef Convert(const std::vector<MSTensor> &tensors);
static std::vector<MSTensor> Convert(const BaseRef &args);
explicit MSTensorRef(const MSTensor &tensor) : ms_tensor_(tensor) {}
~MSTensorRef() override = default;
const MSTensor &GetTensor() const { return ms_tensor_; }
std::shared_ptr<Base> copy() const override;
uint32_t type() const override { return tid(); }
std::string ToString() const override { return ms_tensor_.Name(); }
bool operator==(const BaseRef &other) const override;
private:
static std::vector<MSTensor> ConvertTuple(const VectorRef &args);
MSTensor ms_tensor_;
};
} // namespace mindspore
#endif // MINDSPORE_CCSRC_CXX_API_ACL_VM_MS_TENSOR_REF_H
| 33.42 | 75 | 0.75763 | [
"vector"
] |
93360b3e4967f2c40edc35d1624891fce39e843a | 3,023 | h | C | Source/Engine/Core/Math/Box.h | everard/SELENE-Device | 775bb5cf66ba9fdbc55eac7b216e035c36d82954 | [
"MIT"
] | null | null | null | Source/Engine/Core/Math/Box.h | everard/SELENE-Device | 775bb5cf66ba9fdbc55eac7b216e035c36d82954 | [
"MIT"
] | null | null | null | Source/Engine/Core/Math/Box.h | everard/SELENE-Device | 775bb5cf66ba9fdbc55eac7b216e035c36d82954 | [
"MIT"
] | null | null | null | // Copyright (c) 2012 Nezametdinov E. Ildus
// Licensed under the MIT License (see LICENSE.txt for details)
#ifndef BOX_H
#define BOX_H
#include "Vector.h"
#include "Volume.h"
#include "Sphere.h"
namespace selene
{
/**
* \addtogroup Math
* \brief Linear algebra and vector geometry.
* @{
*/
/**
* Represents box in 3D space.
*/
class Box
{
public:
/// Helper constants
enum
{
NUM_OF_VERTICES = 8
};
/**
* \brief Constructs box with given center, width, height and depth.
* \param[in] center center of the box
* \param[in] width width of the box
* \param[in] height height of the box
* \param[in] depth depth of the box
*/
Box(const Vector3d& center = Vector3d(), float width = 1.0f,
float height = 1.0f, float depth = 1.0f);
/**
* \brief Constructs box with given eight vertices.
* \param[in] vertices array of the vertices of the box
*/
Box(const Vector3d* vertices);
Box(const Box&) = default;
~Box();
Box& operator =(const Box&) = default;
/**
* \brief Defines box with given center, width, height and depth.
* \param[in] center center of the box
* \param[in] width width of the box
* \param[in] height height of the box
* \param[in] depth depth of the box
*/
void define(const Vector3d& center, float width, float height, float depth);
/**
* \brief Defines box with given eight vertices.
* \param[in] vertices array of the vertices of the box
*/
void define(const Vector3d* vertices);
/**
* \brief Returns vertices (box has eight vertices).
* \return array of the vertices of the box
*/
const Vector3d* getVertices() const;
/**
* \brief Determines relation between box and volume.
* \param[in] volume volume
* \return OUTSIDE if box is outside the volume, INTERSECTS if
* box intersects the volume and INSIDE if box is inside the volume
*/
RELATION determineRelation(const Volume& volume) const;
/**
* \brief Transforms box.
* \param[in] matrix transformation matrix
*/
void transform(const Matrix& matrix);
private:
Vector3d vertices_[NUM_OF_VERTICES];
};
/**
* @}
*/
}
#endif
| 31.164948 | 92 | 0.467747 | [
"geometry",
"vector",
"transform",
"3d"
] |
93804d0f25a3f2bc6468889aef3bdb1111caa76a | 1,114 | h | C | cuj/inc/cuj/core/stat.h | AirGuanZ/cuj | 81030a35e1cb8f3f2134d267d8a416aa348348cd | [
"MIT"
] | 23 | 2021-04-24T12:08:40.000Z | 2022-01-18T14:26:00.000Z | cuj/inc/cuj/core/stat.h | AirGuanZ/cuj | 81030a35e1cb8f3f2134d267d8a416aa348348cd | [
"MIT"
] | null | null | null | cuj/inc/cuj/core/stat.h | AirGuanZ/cuj | 81030a35e1cb8f3f2134d267d8a416aa348348cd | [
"MIT"
] | 4 | 2021-04-24T12:08:56.000Z | 2022-01-20T07:46:41.000Z | #pragma once
#include <cuj/core/expr.h>
CUJ_NAMESPACE_BEGIN(cuj::core)
struct Store;
struct Copy;
struct Block;
struct Return;
struct If;
struct Loop;
struct Break;
struct Continue;
struct Switch;
struct CallFuncStat;
using Stat = Variant<
Store,
Copy,
Block,
Return,
If,
Loop,
Break,
Continue,
Switch,
CallFuncStat>;
struct Store
{
Expr dst_addr;
Expr val;
};
struct Copy
{
Expr dst_addr;
Expr src_addr;
};
struct Block
{
std::vector<RC<Stat>> stats;
};
struct Return
{
const Type *return_type;
Expr val;
};
struct If
{
RC<Block> calc_cond;
Expr cond;
RC<Stat> then_body;
RC<Stat> else_body;
};
struct Loop
{
RC<Block> body;
};
struct Break
{
};
struct Continue
{
};
struct Switch
{
struct Branch
{
Immediate cond;
RC<Block> body;
bool fallthrough = false;
};
Expr value;
std::vector<Branch> branches;
RC<Block> default_body;
};
struct CallFuncStat
{
CallFunc call_expr;
};
CUJ_NAMESPACE_END(cuj::core)
| 11.604167 | 38 | 0.596948 | [
"vector"
] |
9382498470abe5c3641a27c36cb019077ddbabf5 | 47,417 | h | C | booster/booster/locale/boundary/index.h | gatehouse/cppcms | 61da055ffeb349b4eda14bc9ac393af9ce842364 | [
"MIT"
] | 388 | 2017-03-01T07:39:21.000Z | 2022-03-30T19:38:41.000Z | booster/booster/locale/boundary/index.h | gatehouse/cppcms | 61da055ffeb349b4eda14bc9ac393af9ce842364 | [
"MIT"
] | 81 | 2017-03-08T20:28:00.000Z | 2022-01-23T08:19:31.000Z | booster/booster/locale/boundary/index.h | gatehouse/cppcms | 61da055ffeb349b4eda14bc9ac393af9ce842364 | [
"MIT"
] | 127 | 2017-03-05T21:53:40.000Z | 2022-02-25T02:31:01.000Z | //
// Copyright (c) 2009-2011 Artyom Beilis (Tonkikh)
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef BOOSTER_LOCALE_BOUNDARY_INDEX_H_INCLUDED
#define BOOSTER_LOCALE_BOUNDARY_INDEX_H_INCLUDED
#include <booster/config.h>
#include <booster/locale/boundary/types.h>
#include <booster/locale/boundary/facets.h>
#include <booster/locale/boundary/segment.h>
#include <booster/locale/boundary/boundary_point.h>
#include <booster/iterator/iterator_facade.h>
#include <booster/traits/is_base_of.h>
#include <booster/shared_ptr.h>
#include <booster/cstdint.h>
#include <booster/assert.h>
#ifdef BOOSTER_MSVC
# pragma warning(push)
# pragma warning(disable : 4275 4251 4231 4660)
#endif
#include <string>
#include <locale>
#include <vector>
#include <iterator>
#include <algorithm>
#include <booster/backtrace.h>
#include <iostream>
namespace booster {
namespace locale {
namespace boundary {
///
/// \defgroup boundary Boundary Analysis
///
/// This module contains all operations required for %boundary analysis of text: character, word, like and sentence boundaries
///
/// @{
///
/// \cond INTERNAL
namespace details {
template<typename IteratorType,typename CategoryType = typename std::iterator_traits<IteratorType>::iterator_category>
struct mapping_traits {
typedef typename std::iterator_traits<IteratorType>::value_type char_type;
static index_type map(boundary_type t,IteratorType b,IteratorType e,std::locale const &l)
{
std::basic_string<char_type> str(b,e);
return std::use_facet<boundary_indexing<char_type> >(l).map(t,str.c_str(),str.c_str()+str.size());
}
};
template<typename CharType,typename SomeIteratorType>
struct linear_iterator_traits {
static const bool is_linear =
is_same<SomeIteratorType,CharType*>::value
|| is_same<SomeIteratorType,CharType const*>::value
|| is_same<SomeIteratorType,typename std::basic_string<CharType>::iterator>::value
|| is_same<SomeIteratorType,typename std::basic_string<CharType>::const_iterator>::value
|| is_same<SomeIteratorType,typename std::vector<CharType>::iterator>::value
|| is_same<SomeIteratorType,typename std::vector<CharType>::const_iterator>::value
;
};
template<typename IteratorType>
struct mapping_traits<IteratorType,std::random_access_iterator_tag> {
typedef typename std::iterator_traits<IteratorType>::value_type char_type;
static index_type map(boundary_type t,IteratorType b,IteratorType e,std::locale const &l)
{
index_type result;
//
// Optimize for most common cases
//
// C++0x requires that string is continious in memory and all known
// string implementations
// do this because of c_str() support.
//
if(linear_iterator_traits<char_type,IteratorType>::is_linear && b!=e)
{
char_type const *begin = &*b;
char_type const *end = begin + (e-b);
index_type tmp=std::use_facet<boundary_indexing<char_type> >(l).map(t,begin,end);
result.swap(tmp);
}
else {
std::basic_string<char_type> str(b,e);
index_type tmp = std::use_facet<boundary_indexing<char_type> >(l).map(t,str.c_str(),str.c_str()+str.size());
result.swap(tmp);
}
return result;
}
};
template<typename BaseIterator>
class mapping {
public:
typedef BaseIterator base_iterator;
typedef typename std::iterator_traits<base_iterator>::value_type char_type;
mapping(boundary_type type,
base_iterator begin,
base_iterator end,
std::locale const &loc)
:
index_(new index_type()),
begin_(begin),
end_(end)
{
index_type idx=details::mapping_traits<base_iterator>::map(type,begin,end,loc);
index_->swap(idx);
}
mapping()
{
}
index_type const &index() const
{
return *index_;
}
base_iterator begin() const
{
return begin_;
}
base_iterator end() const
{
return end_;
}
private:
booster::shared_ptr<index_type> index_;
base_iterator begin_,end_;
};
template<typename BaseIterator>
class segment_index_iterator :
public booster::iterator_facade<
segment_index_iterator<BaseIterator>,
segment<BaseIterator>,
booster::bidirectional_traversal_tag,
segment<BaseIterator> const &
>
{
public:
typedef BaseIterator base_iterator;
typedef mapping<base_iterator> mapping_type;
typedef segment<base_iterator> segment_type;
segment_index_iterator() : current_(0,0),map_(0)
{
}
segment_index_iterator(base_iterator p,mapping_type const *map,rule_type mask,bool full_select) :
map_(map),
mask_(mask),
full_select_(full_select)
{
set(p);
}
segment_index_iterator(bool is_begin,mapping_type const *map,rule_type mask,bool full_select) :
map_(map),
mask_(mask),
full_select_(full_select)
{
if(is_begin)
set_begin();
else
set_end();
}
segment_type const &dereference() const
{
return value_;
}
bool equal(segment_index_iterator const &other) const
{
return map_ == other.map_ && current_.second == other.current_.second;
}
void increment()
{
std::pair<size_t,size_t> next = current_;
if(full_select_) {
next.first = next.second;
while(next.second < size()) {
next.second++;
if(valid_offset(next.second))
break;
}
if(next.second == size())
next.first = next.second - 1;
}
else {
while(next.second < size()) {
next.first = next.second;
next.second++;
if(valid_offset(next.second))
break;
}
}
update_current(next);
}
void decrement()
{
std::pair<size_t,size_t> next = current_;
if(full_select_) {
while(next.second >1) {
next.second--;
if(valid_offset(next.second))
break;
}
next.first = next.second;
while(next.first >0) {
next.first--;
if(valid_offset(next.first))
break;
}
}
else {
while(next.second >1) {
next.second--;
if(valid_offset(next.second))
break;
}
next.first = next.second - 1;
}
update_current(next);
}
private:
void set_end()
{
current_.first = size() - 1;
current_.second = size();
value_ = segment_type(map_->end(),map_->end(),0);
}
void set_begin()
{
current_.first = current_.second = 0;
value_ = segment_type(map_->begin(),map_->begin(),0);
increment();
}
void set(base_iterator p)
{
size_t dist=std::distance(map_->begin(),p);
index_type::const_iterator b=map_->index().begin(),e=map_->index().end();
index_type::const_iterator
boundary_point=std::upper_bound(b,e,break_info(dist));
while(boundary_point != e && (boundary_point->rule & mask_)==0)
boundary_point++;
current_.first = current_.second = boundary_point - b;
if(full_select_) {
while(current_.first > 0) {
current_.first --;
if(valid_offset(current_.first))
break;
}
}
else {
if(current_.first > 0)
current_.first --;
}
value_.first = map_->begin();
std::advance(value_.first,get_offset(current_.first));
value_.second = value_.first;
std::advance(value_.second,get_offset(current_.second) - get_offset(current_.first));
update_rule();
}
void update_current(std::pair<size_t,size_t> pos)
{
std::ptrdiff_t first_diff = get_offset(pos.first) - get_offset(current_.first);
std::ptrdiff_t second_diff = get_offset(pos.second) - get_offset(current_.second);
std::advance(value_.first,first_diff);
std::advance(value_.second,second_diff);
current_ = pos;
update_rule();
}
void update_rule()
{
if(current_.second != size()) {
value_.rule(index()[current_.second].rule);
}
}
size_t get_offset(size_t ind) const
{
if(ind == size())
return index().back().offset;
return index()[ind].offset;
}
bool valid_offset(size_t offset) const
{
return offset == 0
|| offset == size() // make sure we not acess index[size]
|| (index()[offset].rule & mask_)!=0;
}
size_t size() const
{
return index().size();
}
index_type const &index() const
{
return map_->index();
}
segment_type value_;
std::pair<size_t,size_t> current_;
mapping_type const *map_;
rule_type mask_;
bool full_select_;
};
template<typename BaseIterator>
class boundary_point_index_iterator :
public booster::iterator_facade<
boundary_point_index_iterator<BaseIterator>,
boundary_point<BaseIterator>,
booster::bidirectional_traversal_tag,
boundary_point<BaseIterator> const &
>
{
public:
typedef BaseIterator base_iterator;
typedef mapping<base_iterator> mapping_type;
typedef boundary_point<base_iterator> boundary_point_type;
boundary_point_index_iterator() : current_(0),map_(0)
{
}
boundary_point_index_iterator(bool is_begin,mapping_type const *map,rule_type mask) :
map_(map),
mask_(mask)
{
if(is_begin)
set_begin();
else
set_end();
}
boundary_point_index_iterator(base_iterator p,mapping_type const *map,rule_type mask) :
map_(map),
mask_(mask)
{
set(p);
}
boundary_point_type const &dereference() const
{
return value_;
}
bool equal(boundary_point_index_iterator const &other) const
{
return map_ == other.map_ && current_ == other.current_;
}
void increment()
{
size_t next = current_;
while(next < size()) {
next++;
if(valid_offset(next))
break;
}
update_current(next);
}
void decrement()
{
size_t next = current_;
while(next>0) {
next--;
if(valid_offset(next))
break;
}
update_current(next);
}
private:
void set_end()
{
current_ = size();
value_ = boundary_point_type(map_->end(),0);
}
void set_begin()
{
current_ = 0;
value_ = boundary_point_type(map_->begin(),0);
}
void set(base_iterator p)
{
size_t dist = std::distance(map_->begin(),p);
index_type::const_iterator b=index().begin();
index_type::const_iterator e=index().end();
index_type::const_iterator ptr = std::lower_bound(b,e,break_info(dist));
if(ptr==index().end())
current_=size()-1;
else
current_=ptr - index().begin();
while(!valid_offset(current_))
current_ ++;
std::ptrdiff_t diff = get_offset(current_) - dist;
std::advance(p,diff);
value_.iterator(p);
update_rule();
}
void update_current(size_t pos)
{
std::ptrdiff_t diff = get_offset(pos) - get_offset(current_);
base_iterator i=value_.iterator();
std::advance(i,diff);
current_ = pos;
value_.iterator(i);
update_rule();
}
void update_rule()
{
if(current_ != size()) {
value_.rule(index()[current_].rule);
}
}
size_t get_offset(size_t ind) const
{
if(ind == size())
return index().back().offset;
return index()[ind].offset;
}
bool valid_offset(size_t offset) const
{
return offset == 0
|| offset + 1 >= size() // last and first are always valid regardless of mark
|| (index()[offset].rule & mask_)!=0;
}
size_t size() const
{
return index().size();
}
index_type const &index() const
{
return map_->index();
}
boundary_point_type value_;
size_t current_;
mapping_type const *map_;
rule_type mask_;
};
} // details
/// \endcond
template<typename BaseIterator>
class segment_index;
template<typename BaseIterator>
class boundary_point_index;
///
/// \brief This class holds an index of segments in the text range and allows to iterate over them
///
/// This class is provides \ref begin() and \ref end() member functions that return bidirectional iterators
/// to the \ref segment objects.
///
/// It provides two options on way of selecting segments:
///
/// - \ref rule(rule_type mask) - a mask that allows to select only specific types of segments according to
/// various masks %as \ref word_any.
/// \n
/// The default is to select any types of boundaries.
/// \n
/// For example: using word %boundary analysis, when the provided mask is \ref word_kana then the iterators
/// would iterate only over the words containing Kana letters and \ref word_any would select all types of
/// words excluding ranges that consist of white space and punctuation marks. So iterating over the text
/// "to be or not to be?" with \ref word_any rule would return segments "to", "be", "or", "not", "to", "be", instead
/// of default "to", " ", "be", " ", "or", " ", "not", " ", "to", " ", "be", "?".
/// - \ref full_select(bool how) - a flag that defines the way a range is selected if the rule of the previous
/// %boundary point does not fit the selected rule.
/// \n
/// For example: We want to fetch all sentences from the following text: "Hello! How\nare you?".
/// \n
/// This text contains three %boundary points separating it to sentences by different rules:
/// - The exclamation mark "!" ends the sentence "Hello!"
/// - The line feed that splits the sentence "How\nare you?" into two parts.
/// - The question mark that ends the second sentence.
/// \n
/// If you would only change the \ref rule() to \ref sentence_term then the segment_index would
/// provide two sentences "Hello!" and "are you?" %as only them actually terminated with required
/// terminator "!" or "?". But changing \ref full_select() to true, the selected segment would include
/// all the text up to previous valid %boundary point and would return two expected sentences:
/// "Hello!" and "How\nare you?".
///
/// This class allows to find a segment according to the given iterator in range using \ref find() member
/// function.
///
/// \note
///
/// - Changing any of the options - \ref rule() or \ref full_select() and of course re-indexing the text
/// invalidates existing iterators and they can't be used any more.
/// - segment_index can be created from boundary_point_index or other segment_index that was created with
/// same \ref boundary_type. This is very fast operation %as they shared same index
/// and it does not require its regeneration.
///
/// \see
///
/// - \ref boundary_point_index
/// - \ref segment
/// - \ref boundary_point
///
template<typename BaseIterator>
class segment_index {
public:
///
/// The type of the iterator used to iterate over the original text
///
typedef BaseIterator base_iterator;
#ifdef BOOSTER_LOCALE_DOXYGEN
///
/// The bidirectional iterator that iterates over \ref value_type objects.
///
/// - The iterators may be invalidated by use of any non-const member function
/// including but not limited to \ref rule(rule_type) and \ref full_select(bool).
/// - The returned value_type object is valid %as long %as iterator points to it.
/// So this following code is wrong %as t used after p was updated:
/// \code
/// segment_index<some_iterator>::iterator p=index.begin();
/// segment<some_iterator> &t = *p;
/// ++p;
/// cout << t.str() << endl;
/// \endcode
///
typedef unspecified_iterator_type iterator;
///
/// \copydoc iterator
///
typedef unspecified_iterator_type const_iterator;
#else
typedef details::segment_index_iterator<base_iterator> iterator;
typedef details::segment_index_iterator<base_iterator> const_iterator;
#endif
///
/// The type dereferenced by the \ref iterator and \ref const_iterator. It is
/// an object that represents selected segment.
///
typedef segment<base_iterator> value_type;
///
/// Default constructor.
///
/// \note
///
/// When this object is constructed by default it does not include a valid index, thus
/// calling \ref begin(), \ref end() or \ref find() member functions would lead to undefined
/// behavior
///
segment_index() : mask_(0xFFFFFFFFu),full_select_(false)
{
}
///
/// Create a segment_index for %boundary analysis \ref boundary_type "type" of the text
/// in range [begin,end) using a rule \a mask for locale \a loc.
///
segment_index(boundary_type type,
base_iterator begin,
base_iterator end,
rule_type mask,
std::locale const &loc=std::locale())
:
map_(type,begin,end,loc),
mask_(mask),
full_select_(false)
{
}
///
/// Create a segment_index for %boundary analysis \ref boundary_type "type" of the text
/// in range [begin,end) selecting all possible segments (full mask) for locale \a loc.
///
segment_index(boundary_type type,
base_iterator begin,
base_iterator end,
std::locale const &loc=std::locale())
:
map_(type,begin,end,loc),
mask_(0xFFFFFFFFu),
full_select_(false)
{
}
///
/// Create a segment_index from a \ref boundary_point_index. It copies all indexing information
/// and used default rule (all possible segments)
///
/// This operation is very cheap, so if you use boundary_point_index and segment_index on same text
/// range it is much better to create one from another rather then indexing the same
/// range twice.
///
/// \note \ref rule() flags are not copied
///
segment_index(boundary_point_index<base_iterator> const &);
///
/// Copy an index from a \ref boundary_point_index. It copies all indexing information
/// and uses the default rule (all possible segments)
///
/// This operation is very cheap, so if you use boundary_point_index and segment_index on same text
/// range it is much better to create one from another rather then indexing the same
/// range twice.
///
/// \note \ref rule() flags are not copied
///
segment_index const &operator = (boundary_point_index<base_iterator> const &);
///
/// Create a new index for %boundary analysis \ref boundary_type "type" of the text
/// in range [begin,end) for locale \a loc.
///
/// \note \ref rule() and \ref full_select() remain unchanged.
///
void map(boundary_type type,base_iterator begin,base_iterator end,std::locale const &loc=std::locale())
{
map_ = mapping_type(type,begin,end,loc);
}
///
/// Get the \ref iterator on the beginning of the segments range.
///
/// Preconditions: the segment_index should have a mapping
///
/// \note
///
/// The returned iterator is invalidated by access to any non-const member functions of this object
///
iterator begin() const
{
return iterator(true,&map_,mask_,full_select_);
}
///
/// Get the \ref iterator on the ending of the segments range.
///
/// Preconditions: the segment_index should have a mapping
///
/// The returned iterator is invalidated by access to any non-const member functions of this object
///
iterator end() const
{
return iterator(false,&map_,mask_,full_select_);
}
///
/// Find a first valid segment following a position \a p.
///
/// If \a p is inside a valid segment this segment is selected:
///
/// For example: For \ref word %boundary analysis with \ref word_any rule():
///
/// - "to| be or ", would point to "be",
/// - "t|o be or ", would point to "to",
/// - "to be or| ", would point to end.
///
///
/// Preconditions: the segment_index should have a mapping and \a p should be valid iterator
/// to the text in the mapped range.
///
/// The returned iterator is invalidated by access to any non-const member functions of this object
///
iterator find(base_iterator p) const
{
return iterator(p,&map_,mask_,full_select_);
}
///
/// Get the mask of rules that are used
///
rule_type rule() const
{
return mask_;
}
///
/// Set the mask of rules that are used
///
void rule(rule_type v)
{
mask_ = v;
}
///
/// Get the full_select property value - should segment include in the range
/// values that not belong to specific \ref rule() or not.
///
/// The default value is false.
///
/// For example for \ref sentence %boundary with rule \ref sentence_term the segments
/// of text "Hello! How\nare you?" are "Hello!\", "are you?" when full_select() is false
/// because "How\n" is selected %as sentence by a rule spits the text by line feed. If full_select()
/// is true the returned segments are "Hello! ", "How\nare you?" where "How\n" is joined with the
/// following part "are you?"
///
bool full_select() const
{
return full_select_;
}
///
/// Set the full_select property value - should segment include in the range
/// values that not belong to specific \ref rule() or not.
///
/// The default value is false.
///
/// For example for \ref sentence %boundary with rule \ref sentence_term the segments
/// of text "Hello! How\nare you?" are "Hello!\", "are you?" when full_select() is false
/// because "How\n" is selected %as sentence by a rule spits the text by line feed. If full_select()
/// is true the returned segments are "Hello! ", "How\nare you?" where "How\n" is joined with the
/// following part "are you?"
///
void full_select(bool v)
{
full_select_ = v;
}
private:
friend class boundary_point_index<base_iterator>;
typedef details::mapping<base_iterator> mapping_type;
mapping_type map_;
rule_type mask_;
bool full_select_;
};
///
/// \brief This class holds an index of \ref boundary_point "boundary points" and allows iterating
/// over them.
///
/// This class is provides \ref begin() and \ref end() member functions that return bidirectional iterators
/// to the \ref boundary_point objects.
///
/// It provides an option that affects selecting %boundary points according to different rules:
/// using \ref rule(rule_type mask) member function. It allows to set a mask that select only specific
/// types of %boundary points like \ref sentence_term.
///
/// For example for a sentence %boundary analysis of a text "Hello! How\nare you?" when the default
/// rule is used the %boundary points would be:
///
/// - "|Hello! How\nare you?"
/// - "Hello! |How\nare you?"
/// - "Hello! How\n|are you?"
/// - "Hello! How\nare you?|"
///
/// However if \ref rule() is set to \ref sentence_term then the selected %boundary points would be:
///
/// - "|Hello! How\nare you?"
/// - "Hello! |How\nare you?"
/// - "Hello! How\nare you?|"
///
/// Such that a %boundary point defined by a line feed character would be ignored.
///
/// This class allows to find a boundary_point according to the given iterator in range using \ref find() member
/// function.
///
/// \note
/// - Even an empty text range [x,x) considered to have a one %boundary point x.
/// - \a a and \a b points of the range [a,b) are always considered %boundary points
/// regardless the rules used.
/// - Changing any of the option \ref rule() or course re-indexing the text
/// invalidates existing iterators and they can't be used any more.
/// - boundary_point_index can be created from segment_index or other boundary_point_index that was created with
/// same \ref boundary_type. This is very fast operation %as they shared same index
/// and it does not require its regeneration.
///
/// \see
///
/// - \ref segment_index
/// - \ref boundary_point
/// - \ref segment
///
template<typename BaseIterator>
class boundary_point_index {
public:
///
/// The type of the iterator used to iterate over the original text
///
typedef BaseIterator base_iterator;
#ifdef BOOSTER_LOCALE_DOXYGEN
///
/// The bidirectional iterator that iterates over \ref value_type objects.
///
/// - The iterators may be invalidated by use of any non-const member function
/// including but not limited to \ref rule(rule_type) member function.
/// - The returned value_type object is valid %as long %as iterator points to it.
/// So this following code is wrong %as t used after p was updated:
/// \code
/// boundary_point_index<some_iterator>::iterator p=index.begin();
/// boundary_point<some_iterator> &t = *p;
/// ++p;
/// rule_type r = t->rule();
/// \endcode
///
typedef unspecified_iterator_type iterator;
///
/// \copydoc iterator
///
typedef unspecified_iterator_type const_iterator;
#else
typedef details::boundary_point_index_iterator<base_iterator> iterator;
typedef details::boundary_point_index_iterator<base_iterator> const_iterator;
#endif
///
/// The type dereferenced by the \ref iterator and \ref const_iterator. It is
/// an object that represents the selected \ref boundary_point "boundary point".
///
typedef boundary_point<base_iterator> value_type;
///
/// Default constructor.
///
/// \note
///
/// When this object is constructed by default it does not include a valid index, thus
/// calling \ref begin(), \ref end() or \ref find() member functions would lead to undefined
/// behavior
///
boundary_point_index() : mask_(0xFFFFFFFFu)
{
}
///
/// Create a segment_index for %boundary analysis \ref boundary_type "type" of the text
/// in range [begin,end) using a rule \a mask for locale \a loc.
///
boundary_point_index(boundary_type type,
base_iterator begin,
base_iterator end,
rule_type mask,
std::locale const &loc=std::locale())
:
map_(type,begin,end,loc),
mask_(mask)
{
}
///
/// Create a segment_index for %boundary analysis \ref boundary_type "type" of the text
/// in range [begin,end) selecting all possible %boundary points (full mask) for locale \a loc.
///
boundary_point_index(boundary_type type,
base_iterator begin,
base_iterator end,
std::locale const &loc=std::locale())
:
map_(type,begin,end,loc),
mask_(0xFFFFFFFFu)
{
}
///
/// Create a boundary_point_index from a \ref segment_index. It copies all indexing information
/// and uses the default rule (all possible %boundary points)
///
/// This operation is very cheap, so if you use boundary_point_index and segment_index on same text
/// range it is much better to create one from another rather then indexing the same
/// range twice.
///
/// \note \ref rule() flags are not copied
///
boundary_point_index(segment_index<base_iterator> const &other);
///
/// Copy a boundary_point_index from a \ref segment_index. It copies all indexing information
/// and keeps the current \ref rule() unchanged
///
/// This operation is very cheap, so if you use boundary_point_index and segment_index on same text
/// range it is much better to create one from another rather then indexing the same
/// range twice.
///
/// \note \ref rule() flags are not copied
///
boundary_point_index const &operator=(segment_index<base_iterator> const &other);
///
/// Create a new index for %boundary analysis \ref boundary_type "type" of the text
/// in range [begin,end) for locale \a loc.
///
/// \note \ref rule() remains unchanged.
///
void map(boundary_type type,base_iterator begin,base_iterator end,std::locale const &loc=std::locale())
{
map_ = mapping_type(type,begin,end,loc);
}
///
/// Get the \ref iterator on the beginning of the %boundary points range.
///
/// Preconditions: this boundary_point_index should have a mapping
///
/// \note
///
/// The returned iterator is invalidated by access to any non-const member functions of this object
///
iterator begin() const
{
return iterator(true,&map_,mask_);
}
///
/// Get the \ref iterator on the ending of the %boundary points range.
///
/// Preconditions: this boundary_point_index should have a mapping
///
/// \note
///
/// The returned iterator is invalidated by access to any non-const member functions of this object
///
iterator end() const
{
return iterator(false,&map_,mask_);
}
///
/// Find a first valid %boundary point on a position \a p or following it.
///
/// For example: For \ref word %boundary analysis of the text "to be or"
///
/// - "|to be", would return %boundary point at "|to be",
/// - "t|o be", would point to "to| be"
///
/// Preconditions: the boundary_point_index should have a mapping and \a p should be valid iterator
/// to the text in the mapped range.
///
/// The returned iterator is invalidated by access to any non-const member functions of this object
///
iterator find(base_iterator p) const
{
return iterator(p,&map_,mask_);
}
///
/// Get the mask of rules that are used
///
rule_type rule() const
{
return mask_;
}
///
/// Set the mask of rules that are used
///
void rule(rule_type v)
{
mask_ = v;
}
private:
friend class segment_index<base_iterator>;
typedef details::mapping<base_iterator> mapping_type;
mapping_type map_;
rule_type mask_;
};
/// \cond INTERNAL
template<typename BaseIterator>
segment_index<BaseIterator>::segment_index(boundary_point_index<BaseIterator> const &other) :
map_(other.map_),
mask_(0xFFFFFFFFu),
full_select_(false)
{
}
template<typename BaseIterator>
boundary_point_index<BaseIterator>::boundary_point_index(segment_index<BaseIterator> const &other) :
map_(other.map_),
mask_(0xFFFFFFFFu)
{
}
template<typename BaseIterator>
segment_index<BaseIterator> const &segment_index<BaseIterator>::operator=(boundary_point_index<BaseIterator> const &other)
{
map_ = other.map_;
return *this;
}
template<typename BaseIterator>
boundary_point_index<BaseIterator> const &boundary_point_index<BaseIterator>::operator=(segment_index<BaseIterator> const &other)
{
map_ = other.map_;
return *this;
}
/// \endcond
typedef segment_index<std::string::const_iterator> ssegment_index; ///< convenience typedef
typedef segment_index<std::wstring::const_iterator> wssegment_index; ///< convenience typedef
#ifdef BOOSTER_HAS_CHAR16_T
typedef segment_index<std::u16string::const_iterator> u16ssegment_index;///< convenience typedef
#endif
#ifdef BOOSTER_HAS_CHAR32_T
typedef segment_index<std::u32string::const_iterator> u32ssegment_index;///< convenience typedef
#endif
typedef segment_index<char const *> csegment_index; ///< convenience typedef
typedef segment_index<wchar_t const *> wcsegment_index; ///< convenience typedef
#ifdef BOOSTER_HAS_CHAR16_T
typedef segment_index<char16_t const *> u16csegment_index; ///< convenience typedef
#endif
#ifdef BOOSTER_HAS_CHAR32_T
typedef segment_index<char32_t const *> u32csegment_index; ///< convenience typedef
#endif
typedef boundary_point_index<std::string::const_iterator> sboundary_point_index;///< convenience typedef
typedef boundary_point_index<std::wstring::const_iterator> wsboundary_point_index;///< convenience typedef
#ifdef BOOSTER_HAS_CHAR16_T
typedef boundary_point_index<std::u16string::const_iterator> u16sboundary_point_index;///< convenience typedef
#endif
#ifdef BOOSTER_HAS_CHAR32_T
typedef boundary_point_index<std::u32string::const_iterator> u32sboundary_point_index;///< convenience typedef
#endif
typedef boundary_point_index<char const *> cboundary_point_index; ///< convenience typedef
typedef boundary_point_index<wchar_t const *> wcboundary_point_index; ///< convenience typedef
#ifdef BOOSTER_HAS_CHAR16_T
typedef boundary_point_index<char16_t const *> u16cboundary_point_index;///< convenience typedef
#endif
#ifdef BOOSTER_HAS_CHAR32_T
typedef boundary_point_index<char32_t const *> u32cboundary_point_index;///< convenience typedef
#endif
} // boundary
} // locale
} // boost
///
/// boundary.cpp
/// Example of using segment_index
/// wboundary.cpp
/// Example of using segment_index over wide strings
///
#ifdef BOOSTER_MSVC
#pragma warning(pop)
#endif
#endif
// vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
| 43.382434 | 141 | 0.456946 | [
"object",
"vector"
] |
1a97bfa03386e307a236193fa3b74f8e16857981 | 540 | h | C | src/gamma.h | tgstoecker/CAFE5 | bfc745ef7cf3ca8b11cfe984b4aadf4a90795868 | [
"ECL-2.0"
] | 33 | 2020-11-23T02:15:17.000Z | 2022-03-17T17:12:57.000Z | src/gamma.h | tgstoecker/CAFE5 | bfc745ef7cf3ca8b11cfe984b4aadf4a90795868 | [
"ECL-2.0"
] | 33 | 2020-11-11T18:58:38.000Z | 2022-03-28T14:04:13.000Z | src/gamma.h | tgstoecker/CAFE5 | bfc745ef7cf3ca8b11cfe984b4aadf4a90795868 | [
"ECL-2.0"
] | 11 | 2021-03-11T21:15:28.000Z | 2022-03-24T20:44:37.000Z | #ifndef GAMMA_H
#define GAMMA_H
#include <vector>
#define point_gamma(prob, alpha, beta) point_chi2(prob, 2.0*(alpha))/(2.0*(beta)) // Simon: what is this macro doing?
double point_chi2(double prob, double v);
double incomplete_gamma(double x, double alpha, double ln_gamma_alpha);
double point_normal(double prob);
int discrete_gamma(double freqK[], double rK[], double alpha, double beta, int K, int median);
void get_gamma(std::vector<double> &v_freq, std::vector<double> &v_rate, double alpha); // wrapper
#endif /* GAMMA_H */
| 27 | 117 | 0.735185 | [
"vector"
] |
1ac1d24bf3cde9163e4239c7b0ddbc158e7fc74c | 35,327 | h | C | include/cmsis-plus/rtos/os-c-decls.h | micro-os-plus/micro-os-plus-iii-DEPRECATED | a6b44103535beeb79bad6da7c21665e2e46f9f92 | [
"MIT"
] | 78 | 2016-07-07T06:25:56.000Z | 2022-03-22T07:18:06.000Z | include/cmsis-plus/rtos/os-c-decls.h | micro-os-plus/micro-os-plus-iii-DEPRECATED | a6b44103535beeb79bad6da7c21665e2e46f9f92 | [
"MIT"
] | 64 | 2016-11-09T18:05:56.000Z | 2021-03-11T17:34:51.000Z | include/cmsis-plus/rtos/os-c-decls.h | micro-os-plus/micro-os-plus-iii-DEPRECATED | a6b44103535beeb79bad6da7c21665e2e46f9f92 | [
"MIT"
] | 18 | 2016-08-19T16:18:59.000Z | 2021-02-05T01:30:47.000Z | /*
* This file is part of the µOS++ distribution.
* (https://github.com/micro-os-plus)
* Copyright (c) 2016 Liviu Ionescu.
*
* 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.
*/
/*
* The structures declared in this file are used both in the C API
* and in the legacy CMSIS API.
*
* Since there is no method to automatically sync them with the C++
* definitions, they must be manually adjusted to match them, otherwise
* the validation checks in os-c-wrapper.cpp will fail.
*/
#ifndef CMSIS_PLUS_RTOS_OS_C_DECLS_H_
#define CMSIS_PLUS_RTOS_OS_C_DECLS_H_
// ----------------------------------------------------------------------------
#include <cmsis-plus/os-versions.h>
#include <cmsis-plus/os-app-config.h>
#include <cmsis-plus/rtos/port/os-decls.h>
#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>
// ----------------------------------------------------------------------------
#ifdef __cplusplus
extern "C"
{
#endif
// ==========================================================================
typedef struct os_internal_double_list_links_s
{
void* prev;
void* next;
} os_internal_double_list_links_t;
typedef os_internal_double_list_links_t os_internal_threads_waiting_list_t;
typedef struct os_internal_thread_children_list_s
{
os_internal_double_list_links_t links;
} os_internal_thread_children_list_t;
typedef struct os_internal_waiting_thread_node_s
{
os_internal_double_list_links_t links;
void* thread;
} os_internal_waiting_thread_node_t;
typedef struct os_internal_clock_timestamps_list_s
{
os_internal_double_list_links_t links;
} os_internal_clock_timestamps_list_t;
/**
* @addtogroup cmsis-plus-rtos-c-core
* @{
*/
/**
* @brief Type of values returned by RTOS functions.
*
* @details
* For error processing reasons, most µOS++ RTOS functions
* return a numeric result, which, according to POSIX,
* when the call was successful, must be `0`
* (`os_ok`) or an error code defined in `<errno.h>` otherwise.
*
* @see os::rtos::result_t
*/
typedef uint32_t os_result_t;
/**
* @brief Type of variables holding flags modes.
*
* @details
* An unsigned type used to hold the mode bits passed to
* functions returning flags.
*
* Both thread event flags and generic event flags use this definition.
*
* @see os::rtos::flags::mode_t
*/
typedef uint32_t os_flags_mode_t;
/**
* @brief Type of variables holding flags masks.
*
* @details
* An unsigned type large enough to store all the flags, usually
* 32-bits wide.
*
* Both thread event flags and generic event flags use this definition.
*
* @see os::rtos::flags::mask_t
*/
typedef uint32_t os_flags_mask_t;
/**
* @brief Bits used to specify the flags modes.
*
* @see os::rtos::flags::mode
*/
enum
{
os_flags_mode_all = 1, //
os_flags_mode_any = 2, //
os_flags_mode_clear = 4, //
};
/**
* @brief Special mask to represent any flag.
*/
#define os_flags_any 0
/**
* Special mask to represent all flags.
*/
#define os_flags_all 0xFFFFFFFF
// --------------------------------------------------------------------------
/**
* @brief Type of variables holding scheduler state codes.
*
* @details
* Usually a boolean telling if the scheduler is
* locked or not, but for recursive locks it might also be a
* numeric counter.
*
* @see os::rtos::scheduler::state_t
*/
typedef os_port_scheduler_state_t os_sched_state_t;
/**
* @brief Type of variables holding interrupts priority values.
*
* @details
* Usually an integer large enough to hold the CPU register
* where the interrupt priorities are stored.
*
* Used to temporarily store the CPU register
* during critical sections.
*
* @see os::rtos::interrupts::state_t
*/
typedef os_port_irq_state_t os_irq_state_t;
// --------------------------------------------------------------------------
// Define clock types based on port definitions.
/**
* @brief Type of variables holding clock time stamps.
*
* @details
* A numeric type intended to store a clock timestamp, either in ticks
* cycles or seconds.
*
* @see os::rtos::clock::timestamp_t
*/
typedef os_port_clock_timestamp_t os_clock_timestamp_t;
/**
* @brief Type of variables holding clock durations.
*
* @details
* A numeric type intended to store a clock duration, either in ticks
* cycles, or seconds.
*
* @see os::rtos::clock::duration_t
*/
typedef os_port_clock_duration_t os_clock_duration_t;
/**
* @brief Type of variables holding clock offsets.
*
* @details
* A numeric type intended to store a clock offset
* (difference to epoch), either in ticks
* or in seconds.
*
* @see os::rtos::clock::duration_t
*/
typedef os_port_clock_offset_t os_clock_offset_t;
// --------------------------------------------------------------------------
/**
* @brief Generic iterator, implemented as a pointer.
*
* @details
* To simplify things, the C implementation of iterators
* includes a single pointer to a C++ object instance. Internally,
* the functions
* used to iterate must cast this pointer properly, but this
* should be transparent for the user.
*/
typedef void* os_iterator_t;
// --------------------------------------------------------------------------
/**
* @brief Type of variables holding context switches counters.
*
* @see os::rtos::statistics::counter_t
*/
typedef uint64_t os_statistics_counter_t;
/**
* @brief Type of variables holding durations in CPU cycles.
*
* @see os::rtos::statistics::duration_t
*/
typedef uint64_t os_statistics_duration_t;
/**
* @}
*/
/**
* @brief Internal event flags.
*
* @see os::rtos::internal::event_flags
*/
typedef struct os_internal_evflags_s
{
os_flags_mask_t flags_mask;
} os_internal_evflags_t;
// ==========================================================================
#define OS_THREAD_PRIO_SHIFT (4)
/**
* @addtogroup cmsis-plus-rtos-c-thread
* @{
*/
/**
* @brief Thread priorities; intermediate values are also possible.
*
* @see os::rtos::thread::state
*/
enum
{
// Ordered, with **none** as the first and **error** as the last.
os_thread_priority_none = 0, // not defined
os_thread_priority_idle = (1 << OS_THREAD_PRIO_SHIFT),
os_thread_priority_lowest = (2 << OS_THREAD_PRIO_SHIFT), // lowest
os_thread_priority_low = (2 << OS_THREAD_PRIO_SHIFT),
os_thread_priority_below_normal = (4 << OS_THREAD_PRIO_SHIFT),
os_thread_priority_normal = (6 << OS_THREAD_PRIO_SHIFT), // default
os_thread_priority_above_normal = (8 << OS_THREAD_PRIO_SHIFT),
os_thread_priority_high = (10 << OS_THREAD_PRIO_SHIFT),
os_thread_priority_realtime = (12 << OS_THREAD_PRIO_SHIFT),
os_thread_priority_highest = (((13 + 1) << OS_THREAD_PRIO_SHIFT) - 1),
os_thread_priority_isr = (((14 + 1) << OS_THREAD_PRIO_SHIFT) - 1),
os_thread_priority_error = (((15 + 1) << OS_THREAD_PRIO_SHIFT) - 1)
};
/**
* @brief An enumeration with all possible thread states.
*
* @see os::rtos::thread::state
*/
enum
{
/**
* @brief Used to catch uninitialised threads.
*/
os_thread_state_undefined = 0,
/**
* @brief Present in the READY list and competing for CPU.
*/
os_thread_state_ready = 1,
/**
* @brief Has the CPU and runs.
*/
os_thread_state_running = 2,
/**
* @brief Not present in the READY list, waiting for an event.
*/
os_thread_state_suspended = 3,
/**
* @brief No longer usable, but resources not yet released.
*/
os_thread_state_terminated = 4,
/**
* @brief Terminated and resources (like stack) released.
*/
os_thread_state_destroyed = 5
};
/**
* @brief Type of thread function arguments.
* @details
* Useful to cast other similar types
* to silence possible compiler warnings.
*
* @see os::rtos::thread::func_args_t
*/
typedef void* os_thread_func_args_t;
/**
* @brief Type of thread function.
*
* @details
* Useful to cast other similar types
* to silence possible compiler warnings.
*
* @see os::rtos::thread::func_t
*/
typedef void*
(*os_thread_func_t) (os_thread_func_args_t args);
/**
* @brief Type of variables holding thread states.
*
* @see os::rtos::thread::state_t
*/
typedef uint8_t os_thread_state_t;
/**
* @brief Type of variables holding thread priorities.
*
* @details
* A numeric type used to hold thread priorities, affecting the thread
* behaviour, like scheduling and thread wakeup due to events;
* usually an unsigned 8-bits type.
*
* Higher values represent higher priorities.
*
* @see os::rtos::thread::priority_t
*/
typedef uint8_t os_thread_prio_t;
// --------------------------------------------------------------------------
/**
* @brief Type of variables holding stack words.
*
* @details
* A numeric type intended to store a stack word
* as stored by push instructions.
*
* @see os::rtos::stack::element_t
*/
typedef os_port_thread_stack_element_t os_thread_stack_element_t;
/**
* @brief Type of variables holding aligned stack elements.
*
* @details
* A numeric type intended to be used for stack allocations.
*
* @see os::rtos::stack::allocation_element_t
*/
typedef os_port_thread_stack_allocation_element_t os_thread_stack_allocation_element_t;
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpadded"
/**
* @brief Thread stack.
* @headerfile os-c-api.h <cmsis-plus/rtos/os-c-api.h>
*
* @details
* The members of this structure are hidden and should not
* be accessed directly, but through associated functions.
*
* @see os::rtos::thread::stack
*/
typedef struct os_thread_stack_s
{
/**
* @cond ignore
*/
void* stack_addr;
size_t stack_size_bytes;
/**
* @endcond
*/
} os_thread_stack_t;
/**
* @brief Thread context.
* @headerfile os-c-api.h <cmsis-plus/rtos/os-c-api.h>
*
* @details
* The members of this structure are hidden and should not
* be accessed directly, but through associated functions.
*
* @see os::rtos::thread::context
*/
typedef struct os_thread_context_s
{
/**
* @cond ignore
*/
os_thread_stack_t stack;
#if !defined(OS_USE_RTOS_PORT_SCHEDULER)
os_port_thread_context_t port;
#endif
/**
* @endcond
*/
} os_thread_context_t;
#if defined(OS_INCLUDE_RTOS_STATISTICS_THREAD_CONTEXT_SWITCHES) \
|| defined(OS_INCLUDE_RTOS_STATISTICS_THREAD_CPU_CYCLES)
/**
* @brief Thread statistics.
* @headerfile os-c-api.h <cmsis-plus/rtos/os-c-api.h>
*
* @details
* The members of this structure are hidden and should not
* be accessed directly, but through associated functions.
*
* @see os::rtos::thread::statistics
*/
typedef struct os_thread_statistics_s
{
/**
* @cond ignore
*/
#if defined(OS_INCLUDE_RTOS_STATISTICS_THREAD_CONTEXT_SWITCHES)
os_statistics_counter_t context_switches;
#endif /* defined(OS_INCLUDE_RTOS_STATISTICS_THREAD_CONTEXT_SWITCHES) */
#if defined(OS_INCLUDE_RTOS_STATISTICS_THREAD_CPU_CYCLES)
os_statistics_duration_t cpu_cycles;
#endif /* defined(OS_INCLUDE_RTOS_STATISTICS_THREAD_CPU_CYCLES) */
/**
* @endcond
*/
} os_thread_statistics_t;
#endif
/**
* @brief Thread attributes.
* @headerfile os-c-api.h <cmsis-plus/rtos/os-c-api.h>
*
* @details
* Initialise this structure with `os_thread_attr_init()`, and then
* set any of the individual members directly.
*
* @see os::rtos::thread::attributes
*/
typedef struct os_thread_attr_s
{
/**
* @brief Address of the clock to use for timeouts.
*
* @details
* It may be `os_clock_get_sysclock()`, `os_clock_get_rtclock()`,
* or any other user object derived from class `clock`.
*
* If `NULL`, the default is `sysclock`.
*/
void* clock;
/**
* @brief Address of the user defined storage for the thread stack.
*
* @details
* If `NULL`, the default is to dynamically allocate the stack.
*/
void* th_stack_address;
/**
* @brief Size of the user defined storage for the thread
* stack, in bytes.
*
* @details
* If 0, the default is `os_thread_stack_get_default_size()`.
*
* A convenient and explicit variant to this attribute
* is to call `os_thread_stack_set_default_size ()` just before
* creating the thread. However mind setting this from different
* threads at the same time.
*/
size_t th_stack_size_bytes;
/**
* @brief Thread initial priority.
*
* @details
* If 0, the default is `os_thread_priority_normal`.
*
* A convenient and explicit variant to this attribute
* is to call `os_thread_set_priority()` at the beginning of the thread
* function.
*/
os_thread_prio_t th_priority;
} os_thread_attr_t;
/**
* @brief Thread object storage.
* @headerfile os-c-api.h <cmsis-plus/rtos/os-c-api.h>
*
* @details
* This C structure has the same size as the C++ `os::rtos::thread` object
* and must be initialised with `os_thread_create()`.
*
* Later on a pointer to it can be used both in C and C++
* to refer to the thread object instance.
*
* The members of this structure are hidden and should not
* be used directly, but only through specific functions.
*
* @see os::rtos::thread
*/
typedef struct os_thread_s
{
/**
* @cond ignore
*/
void* vtbl;
const char* name;
int errno_; // Prevent the macro to expand (for example with a prefix).
os_internal_waiting_thread_node_t ready_node;
os_thread_func_t func;
os_thread_func_args_t func_args;
void* func_result_;
void* parent;
os_internal_double_list_links_t child_links;
os_internal_thread_children_list_t children;
os_internal_double_list_links_t mutexes;
void* joiner;
void* waiting_node;
void* clock_node;
void* clock;
void* allocator;
void* allocted_stack_address;
size_t acquired_mutexes;
size_t allocated_stack_size_elements;
os_thread_state_t state;
os_thread_prio_t prio_assigned;
os_thread_prio_t prio_inherited;
bool interrupted;
os_internal_evflags_t event_flags;
#if defined(OS_INCLUDE_RTOS_CUSTOM_THREAD_USER_STORAGE)
os_thread_user_storage_t user_storage; //
#endif /* defined(OS_INCLUDE_RTOS_CUSTOM_THREAD_USER_STORAGE) */
#if defined(OS_INCLUDE_RTOS_STATISTICS_THREAD_CONTEXT_SWITCHES) \
|| defined(OS_INCLUDE_RTOS_STATISTICS_THREAD_CPU_CYCLES)
os_thread_statistics_t statistics;
#endif /* defined(OS_INCLUDE_RTOS_STATISTICS_THREAD_CONTEXT_SWITCHES) */
#if defined(OS_USE_RTOS_PORT_SCHEDULER)
os_thread_port_data_t port;
#endif
os_thread_context_t context;
/**
* @endcond
*/
} os_thread_t;
#pragma GCC diagnostic pop
/**
* @}
*/
// ==========================================================================
/**
* @addtogroup cmsis-plus-rtos-c-clock
* @{
*/
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpadded"
/**
* @brief Clock object storage.
* @headerfile os-c-api.h <cmsis-plus/rtos/os-c-api.h>
*
* @details
* This C structure has the same size as the C++ `os::rtos::clock` object.
*
* The members of this structure are hidden and should not
* be used directly, but only through specific functions.
*
* @see os::rtos::clock
*/
typedef struct os_clock_s
{
/**
* @cond ignore
*/
void* vtbl;
const char* name;
os_internal_clock_timestamps_list_t steady_list;
os_clock_duration_t sleep_count;
os_clock_timestamp_t steady_count;
/**
* @endcond
*/
} os_clock_t;
#pragma GCC diagnostic pop
/**
* @}
*/
// ==========================================================================
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpadded"
typedef struct os_clock_node_s
{
void* next;
void* prev;
void* list;
os_clock_timestamp_t timestamp;
void* timer;
} os_internal_clock_timer_node_t;
#pragma GCC diagnostic pop
/**
* @addtogroup cmsis-plus-rtos-c-timer
* @{
*/
/**
* @brief An enumeration with the timer types.
*/
enum
{
os_timer_once = 0, //
os_timer_periodic = 1 //
};
/**
* @brief Type of timer function arguments.
*
* @details
* Useful to cast other similar types
* to silence possible compiler warnings.
*
* @see os::rtos::timer::func_args_t
*/
typedef void* os_timer_func_args_t;
/**
* @brief Type of timer function.
*
* @details
* Useful to cast other similar types
* to silence possible compiler warnings.
*
* @see os::rtos::timer::func_t
*/
typedef void
(*os_timer_func_t) (os_timer_func_args_t args);
/**
* @brief Type of variables holding timer types.
*
* @see os::rtos::timer::type_t
*/
typedef uint8_t os_timer_type_t;
/**
* @brief Type of variables holding timer states.
*
* @see os::rtos::timer::state_t
*/
typedef uint8_t os_timer_state_t;
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpadded"
/**
* @brief Timer attributes.
* @headerfile os-c-api.h <cmsis-plus/rtos/os-c-api.h>
*
* @details
* Initialise this structure with `os_timer_attr_init()` and then
* set any of the individual members directly.
*
* @see os::rtos::timer::attributes
*/
typedef struct os_timer_attr_s
{
/**
* @brief Pointer to clock object instance.
*/
void* clock;
/**
* @brief Timer type.
*/
os_timer_type_t tm_type;
} os_timer_attr_t;
/**
* @brief Timer object storage.
* @headerfile os-c-api.h <cmsis-plus/rtos/os-c-api.h>
*
* @details
* This C structure has the same size as the C++ `os::rtos::timer` object
* and must be initialised with `os_timer_create()`.
*
* Later on a pointer to it can be used both in C and C++
* to refer to the timer object instance.
*
* The members of this structure are hidden and should not
* be used directly, but only through specific functions.
*
* @see os::rtos::timer
*/
typedef struct os_timer_s
{
/**
* @cond ignore
*/
const char* name;
os_timer_func_t func;
os_timer_func_args_t func_args;
#if !defined(OS_USE_RTOS_PORT_TIMER)
void* clock;
os_internal_clock_timer_node_t clock_node;
os_clock_duration_t period;
#endif
#if defined(OS_USE_RTOS_PORT_TIMER)
os_timer_port_data_t port_;
#endif
os_timer_type_t type;
os_timer_state_t state;
/**
* @endcond
*/
} os_timer_t;
#pragma GCC diagnostic pop
/**
* @}
*/
// ==========================================================================
typedef int16_t os_mutex_count_t;
typedef uint8_t os_mutex_type_t;
typedef uint8_t os_mutex_protocol_t;
typedef uint8_t os_mutex_robustness_t;
/**
* @addtogroup cmsis-plus-rtos-c-mutex
* @{
*/
/**
* @brief An enumeration with mutex protocols.
*
* @see os::rtos::mutex::protocol
*/
enum
{
/**
* @brief Priority and scheduling not affected by mutex ownership.
*/
os_mutex_protocol_none = 0,
/**
* @brief Inherit priority from highest priority thread.
*/
os_mutex_protocol_inherit = 1,
/**
* @brief Execute at the highest priority.
*/
os_mutex_protocol_protect = 2,
/**
* @brief Default mutex protocol.
*/
os_mutex_protocol_default = os_mutex_protocol_inherit,
};
/**
* @brief An enumeration with mutex robustness.
*
* @see os::rtos::mutex::robustness
*/
enum
{
/**
* @brief Normal robustness.
*/
os_mutex_robustness_stalled = 0,
/**
* @brief Enhanced robustness at thread termination.
*/
os_mutex_robustness_robust = 1,
/**
* @brief Default mutex robustness.
*/
os_mutex_robustness_default = os_mutex_robustness_stalled,
};
/**
* @brief An enumeration with mutex types.
*
* @see os::rtos::mutex::type
*/
enum
{
/**
* @brief Normal mutex behaviour.
*/
os_mutex_type_normal = 0,
/**
* @brief Check mutex behaviour.
*/
os_mutex_type_errorcheck = 1,
/**
* @brief Recursive mutex behaviour.
*/
os_mutex_type_recursive = 2,
/**
* @brief Default mutex type.
*/
os_mutex_type_default = os_mutex_type_normal,
};
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpadded"
/**
* @brief Mutex attributes.
* @headerfile os-c-api.h <cmsis-plus/rtos/os-c-api.h>
*
* @details
* Initialise this structure with `os_mutex_attr_init()` and then
* set any of the individual members directly.
*
* @see os::rtos::mutex::attributes
*/
typedef struct os_mutex_attr_s
{
/**
* @brief Pointer to clock object instance.
*/
void* clock;
/**
* @brief Mutex priority ceiling.
*/
os_thread_prio_t mx_priority_ceiling;
/**
* @brief Mutex protocol.
*/
os_mutex_protocol_t mx_protocol;
/**
* @brief Mutex robustness.
*/
os_mutex_robustness_t mx_robustness;
/**
* @brief Mutex type.
*/
os_mutex_type_t mx_type;
/**
* @brief Recursive mutex max count.
*/
os_mutex_count_t mx_max_count;
} os_mutex_attr_t;
/**
* @brief Mutex object storage.
* @headerfile os-c-api.h <cmsis-plus/rtos/os-c-api.h>
*
* @details
* This C structure has the same size as the C++ `os::rtos::mutex` object
* and must be initialised with `os_mutex_create()`.
*
* Later on a pointer to it can be used both in C and C++
* to refer to the mutex object instance.
*
* The members of this structure are hidden and should not
* be used directly, but only through specific functions.
*
* @see os::rtos::mutex
*/
typedef struct os_mutex_s
{
/**
* @cond ignore
*/
const char* name;
void* owner;
#if !defined(OS_USE_RTOS_PORT_MUTEX)
os_internal_threads_waiting_list_t list;
void* clock;
#endif
os_internal_double_list_links_t owner_links;
#if defined(OS_USE_RTOS_PORT_MUTEX)
os_mutex_port_data_t port;
#endif
os_mutex_count_t count;
os_thread_prio_t initial_prio_ceiling;
os_thread_prio_t prio_ceiling;
os_thread_prio_t bosted_prio;
bool owner_dead;
bool consistent;
bool recoverable;
os_mutex_type_t type;
os_mutex_protocol_t protocol;
os_mutex_robustness_t robustness;
os_mutex_count_t max_count;
/**
* @endcond
*/
} os_mutex_t;
#pragma GCC diagnostic pop
/**
* @}
*/
// ==========================================================================
/**
* @addtogroup cmsis-plus-rtos-c-condvar
* @{
*/
/**
* @brief Condition variable attributes.
* @headerfile os-c-api.h <cmsis-plus/rtos/os-c-api.h>
*
* @details
* Initialise this structure with `os_condvar_attr_init()` and then
* set any of the individual members directly.
*
* @see os::rtos::condition_variable::attributes
*/
typedef struct os_condvar_attr_s
{
/**
* @brief Pointer to clock object instance.
*/
void* clock;
} os_condvar_attr_t;
/**
* @brief Condition variable object storage.
* @headerfile os-c-api.h <cmsis-plus/rtos/os-c-api.h>
*
* @details
* This C structure has the same size as the C++
* @ref os::rtos::condition_variable
* object and must be initialised with os_condvar_create().
*
* Later on a pointer to it can be used both in C and C++
* to refer to the timer object instance.
*
* The members of this structure are hidden and should not
* be used directly, but only through specific functions.
*
* @see os::rtos::condition_variable
*/
typedef struct os_condvar_s
{
/**
* @cond ignore
*/
const char* name;
#if !defined(OS_USE_RTOS_PORT_CONDITION_VARIABLE)
os_internal_threads_waiting_list_t list;
// void* clock;
#endif
/**
* @endcond
*/
} os_condvar_t;
/**
* @}
*/
// ==========================================================================
/**
* @addtogroup cmsis-plus-rtos-c-semaphore
* @{
*/
/**
* @brief Type of variables holding semaphore counts.
*
* @see os::rtos::semaphore::count_t
*/
typedef int16_t os_semaphore_count_t;
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpadded"
/**
* @brief Semaphore attributes.
* @headerfile os-c-api.h <cmsis-plus/rtos/os-c-api.h>
*
* @details
* Initialise this structure with `os_semaphore_attr_init()` and then
* set any of the individual members directly.
*
* @see os::rtos::semaphore::attributes
*/
typedef struct os_semaphore_attr_s
{
/**
* @brief Pointer to clock object instance.
*/
void* clock;
/**
* @brief Semaphore max count value.
*/
os_semaphore_count_t sm_max_value;
/**
* @brief Semaphore initial count value.
*/
os_semaphore_count_t sm_initial_value;
} os_semaphore_attr_t;
/**
* @brief Semaphore object storage.
* @headerfile os-c-api.h <cmsis-plus/rtos/os-c-api.h>
*
* @details
* This C structure has the same size as the C++ `os::rtos::semaphore`
* object and must be initialised with `os_semaphore_create()`.
*
* Later on a pointer to it can be used both in C and C++
* to refer to the semaphore object instance.
*
* The members of this structure are hidden and should not
* be used directly, but only through specific functions.
*
* @see os::rtos::semaphore
*/
typedef struct os_semaphore_s
{
/**
* @cond ignore
*/
const char* name;
#if !defined(OS_USE_RTOS_PORT_SEMAPHORE)
os_internal_threads_waiting_list_t list;
void* clock;
#endif
#if defined(OS_USE_RTOS_PORT_SEMAPHORE)
os_semaphore_port_data_t port;
#endif
os_semaphore_count_t initial_count;
os_semaphore_count_t count;
os_semaphore_count_t max_count;
/**
* @endcond
*/
} os_semaphore_t;
#pragma GCC diagnostic pop
/**
* @}
*/
// ==========================================================================
typedef uint16_t os_mempool_size_t;
/**
* @addtogroup cmsis-plus-rtos-c-mempool
* @{
*/
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpadded"
/**
* @brief Memory pool attributes.
* @headerfile os-c-api.h <cmsis-plus/rtos/os-c-api.h>
*
* @details
* Initialise this structure with `os_mempool_attr_init()` and then
* set any of the individual members directly.
*
* @see os::rtos::memory_pool::attributes
*/
typedef struct os_mempool_attr_s
{
/**
* @brief Pointer to clock object instance.
*/
void* clock;
/**
* @brief Pointer to user provided memory pool area.
*/
void* mp_pool_address;
/**
* @brief Size of user provided memory pool area, in bytes.
*/
size_t mp_pool_size_bytes;
} os_mempool_attr_t;
/**
* @brief Memory pool object storage.
* @headerfile os-c-api.h <cmsis-plus/rtos/os-c-api.h>
*
* @details
* This C structure has the same size as the C++ `os::rtos::memory_pool`
* object and must be initialised with `os_mempool_create()`.
*
* Later on a pointer to it can be used both in C and C++
* to refer to the memory pool object instance.
*
* The members of this structure are hidden and should not
* be used directly, but only through specific functions.
*
* @see os::rtos::memory_pool
*/
typedef struct os_mempool_s
{
/**
* @cond ignore
*/
void* vtbl;
const char* name;
#if !defined(OS_USE_RTOS_PORT_MEMORY_POOL)
os_internal_threads_waiting_list_t list;
void* clock;
#endif
void* pool_addr;
void* allocated_pool_addr;
void* allocator;
#if defined(OS_USE_RTOS_PORT_MEMORY_POOL)
os_mempool_port_data_t port;
#endif
size_t pool_size_bytes;
size_t allocated_pool_size_elements_;
os_mempool_size_t blocks;
os_mempool_size_t block_size_bytes;
os_mempool_size_t count;
void* first;
/**
* @endcond
*/
} os_mempool_t;
#pragma GCC diagnostic pop
/**
* @}
*/
// ==========================================================================
#if defined(OS_BOOL_RTOS_MESSAGE_QUEUE_SIZE_16BITS)
typedef uint16_t os_mqueue_size_t;
#else
typedef uint8_t os_mqueue_size_t;
#endif
typedef uint16_t os_mqueue_msg_size_t;
typedef os_mqueue_size_t os_mqueue_index_t;
/**
* @addtogroup cmsis-plus-rtos-c-mqueue
* @{
*/
/**
* @brief Type of variables holding message queue priorities.
*
* @see os::rtos::message_queue::priority_t
*/
typedef uint8_t os_mqueue_prio_t;
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpadded"
/**
* @brief Message queue attributes.
* @headerfile os-c-api.h <cmsis-plus/rtos/os-c-api.h>
*
* @details
* Initialise this structure with `os_mqueue_attr_init()` and then
* set any of the individual members directly.
*
* @see os::rtos::message_queue::attributes
*/
typedef struct os_mqueue_attr_s
{
/**
* @brief Pointer to clock object instance.
*/
void* clock;
/**
* @brief Pointer to user provided message queue area.
*/
void* mq_queue_addr;
/**
* @brief Size of user provided message queue area, in bytes.
*/
size_t mq_queue_size_bytes;
} os_mqueue_attr_t;
/**
* @brief Message queue object storage.
* @headerfile os-c-api.h <cmsis-plus/rtos/os-c-api.h>
*
* @details
* This C structure has the same size as the C++ `os::rtos::message_queue`
* object and must be initialised with `os_mqueue_create()`.
*
* Later on a pointer to it can be used both in C and C++
* to refer to the message queue object instance.
*
* The members of this structure are hidden and should not
* be used directly, but only through specific functions.
*
* @see os::rtos::message_queue
*/
typedef struct os_mqueue_s
{
/**
* @cond ignore
*/
void* vtbl;
const char* name;
#if !defined(OS_USE_RTOS_PORT_MESSAGE_QUEUE)
os_internal_threads_waiting_list_t send_list;
os_internal_threads_waiting_list_t receive_list;
void* clock;
os_mqueue_index_t* prev_array;
os_mqueue_index_t* next_array;
os_mqueue_prio_t* prio_array;
void* first_free;
#endif
void* queue_addr;
void* allocated_queue_addr;
void* allocator;
#if defined(OS_USE_RTOS_PORT_MESSAGE_QUEUE)
os_mqueue_port_data_t port;
#endif
size_t queue_size_bytes;
size_t allocated_queue_size_elements;
os_mqueue_msg_size_t msg_size_bytes;
os_mqueue_size_t msgs;
os_mqueue_size_t count;
#if !defined(OS_USE_RTOS_PORT_MESSAGE_QUEUE)
os_mqueue_index_t head;
#endif
/**
* @endcond
*/
} os_mqueue_t;
#pragma GCC diagnostic pop
/**
* @}
*/
// ==========================================================================
/**
* @addtogroup cmsis-plus-rtos-c-evflag
* @{
*/
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpadded"
/**
* @brief Event flags attributes.
* @headerfile os-c-api.h <cmsis-plus/rtos/os-c-api.h>
*
* @details
* Initialise this structure with `os_evflags_attr_init()` and then
* set any of the individual members directly.
*
* @see os::rtos::event_flags::attributes
*/
typedef struct os_evflags_attr_s
{
/**
* @brief Pointer to clock object instance.
*/
void* clock;
} os_evflags_attr_t;
/**
* @brief Event flags object storage.
* @headerfile os-c-api.h <cmsis-plus/rtos/os-c-api.h>
*
* @details
* This C structure has the same size as the C++ `os::rtos::event_flags`
* object and must be initialised with `os_evflags_create()`.
*
* Later on a pointer to it can be used both in C and C++
* to refer to the event flags object instance.
*
* The members of this structure are hidden and should not
* be used directly, but only through specific functions.
*
* @see os::rtos::event_flags
*/
typedef struct os_evflags_s
{
/**
* @cond ignore
*/
const char* name;
#if !defined(OS_USE_RTOS_PORT_EVENT_FLAGS)
os_internal_threads_waiting_list_t list;
void* clock;
#endif
#if defined(OS_USE_RTOS_PORT_EVENT_FLAGS)
os_evflags_port_data_t port_;
#endif
os_internal_evflags_t flags;
/**
* @endcond
*/
} os_evflags_t;
#pragma GCC diagnostic pop
/**
* @}
*/
// ==========================================================================
/**
* @addtogroup cmsis-plus-rtos-c-clock
* @{
*/
/**
* @name Clock handlers
* @{
*/
/**
* @brief SysTick interrupt handler.
*/
void
os_systick_handler (void);
/**
* @brief RTC interrupt handler.
*/
void
os_rtc_handler (void);
/**
* @}
*/
/**
* @}
*/
// ==========================================================================
/**
* @addtogroup cmsis-plus-rtos-c-memres
* @{
*/
/**
* @brief Memory resource object storage.
* @headerfile os-c-api.h <cmsis-plus/rtos/os-c-api.h>
*
* @details
* A pointer to this structure can be used as a pointer to the
* `os::rtos::memory::memory_resource` object.
*
* The members of this structure are hidden and should not
* be used directly, but only through specific functions.
*
* @see os::rtos::memory::memory_resource
*/
typedef struct os_memory_s
{
char dummy; // Content is not relevant.
} os_memory_t;
/**
* @}
*/
// ============================================================================
#ifdef __cplusplus
}
#endif
#endif /* CMSIS_PLUS_RTOS_OS_C_STRUCTS_H_ */
| 23.614305 | 89 | 0.630934 | [
"object"
] |
1ace6d12b8295d1cf8cfe28e4f82748dcdc7dc70 | 44,068 | c | C | sdk-6.5.20/src/bcm/ltsw/ser.c | copslock/broadcom_cpri | 8e2767676e26faae270cf485591902a4c50cf0c5 | [
"Spencer-94"
] | null | null | null | sdk-6.5.20/src/bcm/ltsw/ser.c | copslock/broadcom_cpri | 8e2767676e26faae270cf485591902a4c50cf0c5 | [
"Spencer-94"
] | null | null | null | sdk-6.5.20/src/bcm/ltsw/ser.c | copslock/broadcom_cpri | 8e2767676e26faae270cf485591902a4c50cf0c5 | [
"Spencer-94"
] | null | null | null | /*! \file ser.c
*
* SER Module Emulator above SDKLT.
*/
/*
* This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file.
*
* Copyright 2007-2020 Broadcom Inc. All rights reserved.
*/
#include <bcm_int/control.h>
#include <bcm_int/ltsw/property.h>
#include <bcm_int/ltsw/ser.h>
#include <bcm_int/ltsw/dev.h>
#include <bcm_int/ltsw/switch.h>
#include <bcm_int/ltsw/event_mgr.h>
#include <bcm_int/ltsw/lt_intf.h>
#include <bcmlt/bcmlt.h>
#include <shr/shr_debug.h>
#include <bcmltd/chip/bcmltd_str.h>
#include <sal/core/boot.h>
/******************************************************************************
* Local definitions
*/
#define MAX_PT_WSIZE 32
#define BSL_LOG_MODULE BSL_LS_SOC_SER
/*!
* SER error type defined in SDKLT.
*/
typedef enum ser_error_type_e {
/*! Parity error. */
SER_ERR_PARITY = 0,
/*! ECC 1bit error. */
SER_ERR_ECC_1BIT = 1,
/*! ECC 2bit error. */
SER_ERR_ECC_2BIT = 2
} ser_error_type_t;
/*!
* SER recovery type defined in SDKLT.
*/
typedef enum ser_recovery_type_e {
/*! Correct SER error entry with cache data */
SER_RECOVERY_CACHE_RESTORE = 1,
/*! Clear SER error entry. */
SER_RECOVERY_ENTRY_CLEAR = 2,
/*! Do not handle SER error. */
SER_RECOVERY_NO_OPERATION = 3
} ser_recovery_type_t;
/*!
* SER block type defined in SDKLT.
*/
typedef enum ser_blk_type_e {
/*! Memory Management Unit. */
SER_BLK_MMU = 1,
/*! Ingress pipeline. */
SER_BLK_IPIPE = 2,
/*! Egress pipeline. */
SER_BLK_EPIPE = 3,
/*! Packet gateWay. */
SER_BLK_PGW = 4,
/*! PORT. */
SER_BLK_PORT = 5
} ser_blk_type_t;
/*!
* SER check type defined in SDKLT.
*/
typedef enum ser_check_type_e {
/*! No SER check */
SER_NO_CHECK = 0,
/*! Parity check */
SER_PARITY_CHECK = 1,
/*! ECC check */
SER_ECC_CHECK = 2
} ser_check_type_t;
/* Top level parity error info returned in event callbacks, enum value are same with SDK6. */
typedef enum {
/* Parity SER protection */
SER_SWITCH_EVENT_DATA_ERROR_PARITY = 1,
/* ECC SER protection */
SER_SWITCH_EVENT_DATA_ERROR_ECC,
/* Not used */
SER_SWITCH_EVENT_DATA_ERROR_UNSPECIFIED,
/* Fatal error. Double-bits ECC error of MMU or H/W fault */
SER_SWITCH_EVENT_DATA_ERROR_FATAL,
/* Not used */
SER_SWITCH_EVENT_DATA_ERROR_CORRECTED,
/* Report ID of SER_LOG. */
SER_SWITCH_EVENT_DATA_ERROR_LOG,
/*
* Double-bits ECC error or parity error, and SER recovery type is 'NO_OPERATION'.
* Error entry data can't be read successfully, and can't be corrected.
*/
SER_SWITCH_EVENT_DATA_ERROR_UNCORRECTABLE,
/*
* Single-bit ECC error, and SER recovery type is 'NO_OPERATION'.
* Error entry data can be read successfully, but can't be corrected.
*/
SER_SWITCH_EVENT_DATA_ERROR_AUTO_CORRECTED,
/* Fail to correct SER error due to SW reasons */
SER_SWITCH_EVENT_DATA_ERROR_FAILEDTOCORRECT,
/* Single-bit ECC corrected, no traffic loss */
SER_SWITCH_EVENT_DATA_ERROR_ECC_1BIT_CORRECTED,
/* Double-bit ECC corrected, potential traffic loss */
SER_SWITCH_EVENT_DATA_ERROR_ECC_2BIT_CORRECTED,
/* Parity error correction */
SER_SWITCH_EVENT_DATA_ERROR_PARITY_CORRECTED,
/* Not used */
SER_SWITCH_EVENT_DATA_ERROR_CFAP_MEM_FAIL
} ser_switch_data_error_t;
/* SER LOG updated notify info. */
typedef struct ser_log_s {
/* SER log ID. */
uint32 ser_log_id;
/* Time stamp. */
uint32 timestamp;
/* Physical table name */
const char *pt_name;
/* Physical table ID */
uint32 pt_id;
/* Instance number */
int pt_inst;
/* Index */
int pt_index;
/* SER error type */
ser_error_type_t ser_err_type;
/* Corrected */
int ser_err_corrected;
/* SER recovery type for single bit */
ser_recovery_type_t ser_resp_type_for_1bit;
/* SER recovery type for double bit */
ser_recovery_type_t ser_resp_type_for_2bit;
/* SER block type */
ser_blk_type_t blk_type;
/* H/W fault */
int hw_fault;
/* Error entry content */
uint32 err_entry_content[MAX_PT_WSIZE];
} ser_log_t;
/******************************************************************************
* Private functions
*/
/*!
* \brief Check whether functionality is enabled or not.
*
* \param [in] unit Unit number.
* \param [out] is_enabled 1: SER functionality is enabled otherwise: disabled
*
* \return BCM_E_NONE on success, error code otherwise.
*/
static int
ser_config_is_enabled(int unit, int *is_enabled)
{
int dunit, rv;
bcmlt_entry_handle_t eh = BCMLT_INVALID_HDL;
uint64 fld_val;
uint32 bootf = 0;
SHR_FUNC_ENTER(unit);
bootf = sal_boot_flags_get();
if (bootf & (BOOT_F_BCMSIM | BOOT_F_XGSSIM)) {
fld_val = 0;
} else {
dunit = bcmi_ltsw_dev_dunit(unit);
SHR_IF_ERR_EXIT
(bcmlt_entry_allocate(dunit, SER_CONFIGs, &eh));
SHR_IF_ERR_EXIT
(bcmlt_entry_commit(eh, BCMLT_OPCODE_LOOKUP, BCMLT_PRIORITY_NORMAL));
rv = bcmlt_entry_field_get(eh, SER_ENABLEs, &fld_val);
SHR_IF_ERR_EXIT(rv);
}
*is_enabled = fld_val ? 1 : 0;
exit:
if (eh != BCMLT_INVALID_HDL) {
bcmlt_entry_free(eh);
}
SHR_FUNC_EXIT();
}
/*!
* \brief Get information of one PT from LT SER_PT_STATUS.
* Lookup SER_PT_STATUS by key field PT_IDs.
*
* \param [in] unit Unit number.
* \param [in] pt_name Name of PT.
* \param [int] pt_id Sid of PT, is used only when pt_name is NULL.
* \param [out] index_num Index number.
* \param [out] inst_num Instance number.
* \param [out] copy_num Copy number.
* \param [out] ser_check_type SER check type: ECC, Parity, None.
* \param [out] ser_resp_type SER recovery type.
*
* \return BCM_E_NONE on success, error code otherwise.
*/
static int
ser_pt_status_info_get(int unit, const char *pt_name, uint32 pt_id,
int *index_num, int *inst_num,
int *copy_num, ser_check_type_t *ser_check_type,
ser_recovery_type_t *resp_type_1bit,
ser_recovery_type_t *resp_type_2bit)
{
int dunit, rv;
bcmlt_entry_handle_t eh = BCMLT_INVALID_HDL;
uint64 fld_val;
SHR_FUNC_ENTER(unit);
dunit = bcmi_ltsw_dev_dunit(unit);
SHR_IF_ERR_EXIT
(bcmlt_entry_allocate(dunit, SER_PT_STATUSs, &eh));
if (pt_name != NULL) {
SHR_IF_ERR_EXIT
(bcmlt_entry_field_symbol_add(eh, PT_IDs, pt_name));
} else {
fld_val = pt_id;
SHR_IF_ERR_EXIT
(bcmlt_entry_field_add(eh, PT_IDs, fld_val));
}
SHR_IF_ERR_EXIT
(bcmlt_entry_commit(eh, BCMLT_OPCODE_LOOKUP, BCMLT_PRIORITY_NORMAL));
if (index_num) {
rv = bcmlt_entry_field_get(eh, PT_INDEX_NUMs, &fld_val);
SHR_IF_ERR_EXIT(rv);
*index_num = fld_val;
}
if (inst_num) {
rv = bcmlt_entry_field_get(eh, PT_INST_NUMs, &fld_val);
SHR_IF_ERR_EXIT(rv);
*inst_num = fld_val;
}
if (copy_num) {
rv = bcmlt_entry_field_get(eh, PT_COPY_NUMs, &fld_val);
SHR_IF_ERR_EXIT(rv);
*copy_num = fld_val;
}
if (ser_check_type) {
rv = bcmlt_entry_field_get(eh, SER_CHECK_TYPEs, &fld_val);
SHR_IF_ERR_EXIT(rv);
*ser_check_type = fld_val;
}
if (resp_type_1bit) {
rv = bcmlt_entry_field_get(eh, SER_RECOVERY_TYPE_FOR_SINGLE_BITs, &fld_val);
SHR_IF_ERR_EXIT(rv);
*resp_type_1bit = fld_val;
}
if (resp_type_2bit) {
rv = bcmlt_entry_field_get(eh, SER_RECOVERY_TYPE_FOR_DOUBLE_BITs, &fld_val);
SHR_IF_ERR_EXIT(rv);
*resp_type_2bit = fld_val;
}
exit:
if (eh != BCMLT_INVALID_HDL) {
bcmlt_entry_free(eh);
}
SHR_FUNC_EXIT();
}
/*!
* \brief Get SER injection status by looking up LT SER_INJECTION_STATUS.
*
* \param [in] unit Unit number.
* \param [out] ser_err_injected 1: SER error is injected successfully.
* \param [out] ser_err_corrected 1: SER error is corrected successfully.
*
* \return BCM_E_NONE on success, error code otherwise.
*/
static int
ser_injection_status_info_get(int unit,
int *ser_err_injected, int *ser_err_corrected)
{
int dunit, rv;
bcmlt_entry_handle_t eh = BCMLT_INVALID_HDL;
uint64 fld_val;
SHR_FUNC_ENTER(unit);
dunit = bcmi_ltsw_dev_dunit(unit);
SHR_IF_ERR_EXIT
(bcmlt_entry_allocate(dunit, SER_INJECTION_STATUSs, &eh));
SHR_IF_ERR_EXIT
(bcmlt_entry_commit(eh, BCMLT_OPCODE_LOOKUP, BCMLT_PRIORITY_NORMAL));
rv = bcmlt_entry_field_get(eh, SER_ERR_INJECTEDs, &fld_val);
SHR_IF_ERR_EXIT(rv);
*ser_err_injected = fld_val;
rv = bcmlt_entry_field_get(eh, SER_ERR_CORRECTEDs, &fld_val);
SHR_IF_ERR_EXIT(rv);
*ser_err_corrected = fld_val;
exit:
if (eh != BCMLT_INVALID_HDL) {
bcmlt_entry_free(eh);
}
SHR_FUNC_EXIT();
}
/*!
* \brief Report SER event to application, so application can get SER LOG ID.
* Then the application can get SER LOG according to SER LOG ID.
*
* \param [in] unit Unit number.
* \param [in] event String event.
* \param [in] notif_info SER LOG information.
* \param [in] user_data User data.
*
* \return NONE.
*/
static void
ser_log_lt_cb(int unit, const char *event, void *notif_info,
void *user_data)
{
ser_log_t *ser_log = NULL;
if (notif_info == NULL) {
return;
}
ser_log = (ser_log_t *)notif_info;
(void)bcmi_ltsw_switch_event_generate(unit, BCM_SWITCH_EVENT_PARITY_ERROR,
SER_SWITCH_EVENT_DATA_ERROR_LOG,
ser_log->ser_log_id, 0);
if (ser_log->ser_err_type == SER_ERR_PARITY) {
if (ser_log->ser_err_corrected) {
(void)bcmi_ltsw_switch_event_generate(unit, BCM_SWITCH_EVENT_PARITY_ERROR,
SER_SWITCH_EVENT_DATA_ERROR_PARITY_CORRECTED,
ser_log->pt_id, ser_log->pt_index);
} else {
(void)bcmi_ltsw_switch_event_generate(unit, BCM_SWITCH_EVENT_PARITY_ERROR,
SER_SWITCH_EVENT_DATA_ERROR_PARITY,
ser_log->pt_id, ser_log->pt_index);
if (ser_log->ser_resp_type_for_1bit == SER_RECOVERY_NO_OPERATION) {
(void)bcmi_ltsw_switch_event_generate(unit, BCM_SWITCH_EVENT_PARITY_ERROR,
SER_SWITCH_EVENT_DATA_ERROR_UNCORRECTABLE,
ser_log->pt_id, ser_log->pt_index);
} else {
(void)bcmi_ltsw_switch_event_generate(unit, BCM_SWITCH_EVENT_PARITY_ERROR,
SER_SWITCH_EVENT_DATA_ERROR_FAILEDTOCORRECT,
ser_log->pt_id, ser_log->pt_index);
}
}
} else if (ser_log->ser_err_type == SER_ERR_ECC_1BIT) {
if (ser_log->ser_err_corrected) {
(void)bcmi_ltsw_switch_event_generate(unit, BCM_SWITCH_EVENT_PARITY_ERROR,
SER_SWITCH_EVENT_DATA_ERROR_ECC_1BIT_CORRECTED,
ser_log->pt_id, ser_log->pt_index);
} else {
(void)bcmi_ltsw_switch_event_generate(unit, BCM_SWITCH_EVENT_PARITY_ERROR,
SER_SWITCH_EVENT_DATA_ERROR_ECC,
ser_log->pt_id, ser_log->pt_index);
if (ser_log->ser_resp_type_for_1bit == SER_RECOVERY_NO_OPERATION) {
(void)bcmi_ltsw_switch_event_generate(unit, BCM_SWITCH_EVENT_PARITY_ERROR,
SER_SWITCH_EVENT_DATA_ERROR_AUTO_CORRECTED,
ser_log->pt_id, ser_log->pt_index);
} else {
(void)bcmi_ltsw_switch_event_generate(unit, BCM_SWITCH_EVENT_PARITY_ERROR,
SER_SWITCH_EVENT_DATA_ERROR_FAILEDTOCORRECT,
ser_log->pt_id, ser_log->pt_index);
}
}
} else if (ser_log->ser_err_type == SER_ERR_ECC_2BIT) {
if (ser_log->ser_err_corrected) {
(void)bcmi_ltsw_switch_event_generate(unit, BCM_SWITCH_EVENT_PARITY_ERROR,
SER_SWITCH_EVENT_DATA_ERROR_ECC_2BIT_CORRECTED,
ser_log->pt_id, ser_log->pt_index);
} else {
(void)bcmi_ltsw_switch_event_generate(unit, BCM_SWITCH_EVENT_PARITY_ERROR,
SER_SWITCH_EVENT_DATA_ERROR_ECC,
ser_log->pt_id, ser_log->pt_index);
if (ser_log->ser_resp_type_for_2bit == SER_RECOVERY_NO_OPERATION) {
(void)bcmi_ltsw_switch_event_generate(unit, BCM_SWITCH_EVENT_PARITY_ERROR,
SER_SWITCH_EVENT_DATA_ERROR_UNCORRECTABLE,
ser_log->pt_id, ser_log->pt_index);
} else {
(void)bcmi_ltsw_switch_event_generate(unit, BCM_SWITCH_EVENT_PARITY_ERROR,
SER_SWITCH_EVENT_DATA_ERROR_FAILEDTOCORRECT,
ser_log->pt_id, ser_log->pt_index);
}
}
}
if (ser_log->hw_fault) {
(void)bcmi_ltsw_switch_event_generate(unit, BCM_SWITCH_EVENT_PARITY_ERROR,
SER_SWITCH_EVENT_DATA_ERROR_FATAL,
ser_log->pt_id, ser_log->pt_index);
}
}
/*!
* \brief Block type defined in SDKLT is different from in SDK6.
* Get block type in SDKLT according to block type in SDKLT.
*
* \param [in] unit Unit number.
* \param [in] blk_type_api Block type defined in SDK6.
* \param [out] blk_type Block type defined in SDKLT.
*
* \return BCM_E_NONE on success, error code otherwise.
*/
static int
ser_blk_type_map(int unit, bcm_switch_block_type_t blk_type_api,
const char **blk_type)
{
switch (blk_type_api) {
case bcmSwitchBlockTypeMmu:
case bcmSwitchBlockTypeMmuGlb:
case bcmSwitchBlockTypeMmuXpe:
case bcmSwitchBlockTypeMmuSc:
case bcmSwitchBlockTypeMmuSed:
*blk_type = SER_BLK_MMUs;
break;
case bcmSwitchBlockTypeIpipe:
*blk_type = SER_BLK_IPIPEs;
break;
case bcmSwitchBlockTypeEpipe:
*blk_type = SER_BLK_EPIPEs;
break;
case bcmSwitchBlockTypeClport:
case bcmSwitchBlockTypeXlport:
case bcmSwitchBlockTypePort:
*blk_type = SER_BLK_PORTs;
break;
case bcmSwitchBlockTypePgw:
*blk_type = SER_BLK_PGWs;
break;
case bcmSwitchBlockTypeAll:
*blk_type = SER_BLK_ALLs;
break;
default:
return SHR_E_BADID;
}
return SHR_E_NONE;
}
/*!
* \brief Correction type defined in SDKLT is different from in SDK6.
* Get SDKLT correction type according to SDK6 correction type.
*
* \param [in] unit Unit number.
* \param [in] correction_type Correction type defined in SDK6.
* \param [out] rep_type Correction type defined in SDKLT.
*
* \return BCM_E_NONE on success, error code otherwise.
*/
static int
ser_rep_type_map(int unit, bcm_switch_correction_type_t correction_type,
const char **rep_type)
{
switch (correction_type) {
case bcmSwitchCorrectTypeNoAction:
*rep_type = SER_RECOVERY_NO_OPERATIONs;
break;
case bcmSwitchCorrectTypeEntryClear:
*rep_type = SER_RECOVERY_ENTRY_CLEARs;
break;
case bcmSwitchCorrectTypeCacheRestore:
case bcmSwitchCorrectTypeSpecial:
*rep_type = SER_RECOVERY_CACHE_RESTOREs;
break;
case bcmSwitchCorrectTypeAll:
*rep_type = SER_RECOVERY_ALLs;
break;
default:
return SHR_E_UNAVAIL;
}
return SHR_E_NONE;
}
/*!
* \brief Transform data structure defined by HSDK to
* API data structure defined by SDK6.
*
* \param [in] unit Unit number.
* \param [in] log_info Data structure defined by HSDK.
* \param [out] info Data structure defined by SDK6.
*
* \return BCM_E_NONE on success, error code otherwise.
*/
static int
ser_log_entry_transform(int unit, ser_log_t *log_info,
bcm_switch_ser_log_info_t *info)
{
int name_len = 0, i, rv;
int inst_num, copy_num, inst_num_per_pipe;
ser_recovery_type_t recovery_type = 0;
info->time = log_info->timestamp;
name_len = sal_strlen(log_info->pt_name);
if (name_len >= BCM_MAX_MEM_REG_NAME) {
return SHR_E_MEMORY;
}
sal_memcpy(info->name, log_info->pt_name, name_len);
if (info->name[name_len] == 'm') {
info->flags |= BCM_SWITCH_SER_LOG_MEM;
} else if (info->name[name_len] == 'r') {
info->flags |= BCM_SWITCH_SER_LOG_REG;
} else {
/* Internal buffer or bus */
}
if (log_info->ser_err_corrected) {
info->flags |= BCM_SWITCH_SER_LOG_CORRECTED;
}
info->flags |= BCM_SWITCH_SER_LOG_ENTRY;
for (i = 0; i < BCM_MAX_MEM_WORDS && i < MAX_PT_WSIZE; i++) {
info->entry_data[i] = log_info->err_entry_content[i];
}
info->index = log_info->pt_index;
switch (log_info->blk_type) {
case SER_BLK_MMU:
info->block_type = bcmSwitchBlockTypeMmu;
info->instance = log_info->pt_inst;
break;
case SER_BLK_IPIPE:
case SER_BLK_EPIPE:
if (log_info->blk_type == SER_BLK_IPIPE) {
info->block_type = bcmSwitchBlockTypeIpipe;
} else {
info->block_type = bcmSwitchBlockTypeEpipe;
}
rv = ser_pt_status_info_get(unit, log_info->pt_name, 0, NULL,
&inst_num, ©_num, NULL, NULL, NULL);
if (SHR_FAILURE(rv)) {
return rv;
}
if (copy_num > 1) {
/*
* Access type of such PTs is Address-Split-Split,
* Application can get pipe number according to index number.
*/
inst_num_per_pipe = inst_num / copy_num;
info->pipe = log_info->pt_inst / inst_num_per_pipe;
info->index = log_info->pt_inst;
} else {
info->pipe = log_info->pt_inst;
}
break;
case SER_BLK_PORT:
info->block_type = bcmSwitchBlockTypePort;
info->port = log_info->pt_inst;
break;
case SER_BLK_PGW:
info->block_type = bcmSwitchBlockTypePgw;
info->instance = log_info->pt_inst;
break;
default:
return SHR_E_INTERNAL;
}
switch (log_info->ser_err_type) {
case SER_ERR_PARITY:
info->error_type = bcmSwitchErrorTypeParity;
recovery_type = log_info->ser_resp_type_for_1bit;
break;
case SER_ERR_ECC_1BIT:
info->error_type = bcmSwitchErrorTypeEccSingleBit;
recovery_type = log_info->ser_resp_type_for_1bit;
break;
case SER_ERR_ECC_2BIT:
info->error_type = bcmSwitchErrorTypeEccDoubleBit;
recovery_type = log_info->ser_resp_type_for_2bit;
break;
default:
info->error_type = bcmSwitchErrorTypeUnknown;
}
switch (recovery_type) {
case SER_RECOVERY_CACHE_RESTORE:
info->correction_type = bcmSwitchCorrectTypeCacheRestore;
break;
case SER_RECOVERY_ENTRY_CLEAR:
info->correction_type = bcmSwitchCorrectTypeEntryClear;
break;
case SER_RECOVERY_NO_OPERATION:
info->correction_type = bcmSwitchCorrectTypeNoAction;
break;
default:
info->correction_type = bcmSwitchCorrectTypeFailToCorrect;
}
return SHR_E_NONE;
}
/*!
* \brief Get SER log from LT entry handler, and save the SER log to
* data structure defined by HSDK.
*
* \param [in] unit Unit number.
* \param [in] lt_name LT name.
* \param [in] eh SER_LOG LT entry handler.
* \param [out] ser_log_info Pointer of data structure of SER LOG.
* \param [out] status Parser callback returned status, NULL for not care.
*
* \return BCM_E_NONE on success, error code otherwise.
*/
static void
ser_log_entry_parse(int unit, const char *lt_name,
bcmlt_entry_handle_t eh, void *ser_log_info,
bcmi_ltsw_event_status_t *status)
{
uint64 data = 0LL, data_array[MAX_PT_WSIZE];
int rv = BCM_E_NONE;
ser_log_t *ser_log = NULL;
const char *fld_name = NULL, *pt_name = NULL;
uint32 num_element = 1, i;
SHR_FUNC_ENTER(unit);
if (ser_log_info == NULL) {
SHR_ERR_EXIT(SHR_E_PARAM);
}
ser_log = (ser_log_t *)ser_log_info;
fld_name = SER_LOG_IDs;
rv = bcmlt_entry_field_get(eh, fld_name, &data);
SHR_IF_ERR_EXIT(rv);
ser_log->ser_log_id = (uint32)data;
fld_name = TIMESTAMPs;
rv = bcmlt_entry_field_get(eh, fld_name, &data);
SHR_IF_ERR_EXIT(rv);
ser_log->timestamp = (uint32)data;
fld_name = PT_IDs;
rv = bcmlt_entry_field_symbol_get(eh, fld_name, &pt_name);
SHR_IF_ERR_EXIT(rv);
ser_log->pt_name = pt_name;
rv = bcmlt_entry_field_get(eh, fld_name, &data);
SHR_IF_ERR_EXIT(rv);
ser_log->pt_id = data;
fld_name = PT_INSTANCEs;
rv = bcmlt_entry_field_get(eh, fld_name, &data);
SHR_IF_ERR_EXIT(rv);
ser_log->pt_inst = (int)data;
fld_name = PT_INDEXs;
rv = bcmlt_entry_field_get(eh, fld_name, &data);
SHR_IF_ERR_EXIT(rv);
ser_log->pt_index = (int)data;
fld_name = SER_ERR_TYPEs;
rv = bcmlt_entry_field_get(eh, fld_name, &data);
SHR_IF_ERR_EXIT(rv);
ser_log->ser_err_type = (ser_error_type_t)data;
fld_name = SER_ERR_CORRECTEDs;
rv = bcmlt_entry_field_get(eh, fld_name, &data);
SHR_IF_ERR_EXIT(rv);
ser_log->ser_err_corrected = (int)data;
fld_name = SER_RECOVERY_TYPEs;
rv = bcmlt_entry_field_get(eh, fld_name, &data);
SHR_IF_ERR_EXIT(rv);
if (ser_log->ser_err_type == SER_ERR_PARITY ||
ser_log->ser_err_type == SER_ERR_ECC_1BIT) {
ser_log->ser_resp_type_for_1bit = (ser_recovery_type_t)data;
} else {
ser_log->ser_resp_type_for_2bit = (ser_recovery_type_t)data;
}
fld_name = BLK_TYPEs;
rv = bcmlt_entry_field_get(eh, fld_name, &data);
SHR_IF_ERR_EXIT(rv);
ser_log->blk_type = (ser_blk_type_t)data;
fld_name = HW_FAULTs;
rv = bcmlt_entry_field_get(eh, fld_name, &data);
SHR_IF_ERR_EXIT(rv);
ser_log->hw_fault = (int)data;
fld_name = ERR_ENTRY_CONTENTs;
rv = bcmlt_entry_field_array_get(eh, fld_name, 0, data_array,
MAX_PT_WSIZE, &num_element);
SHR_IF_ERR_EXIT(rv);
if (num_element != MAX_PT_WSIZE) {
rv = SHR_E_INTERNAL;
SHR_IF_ERR_EXIT(rv);
}
for (i = 0; i < MAX_PT_WSIZE; i++) {
ser_log->err_entry_content[i] = data_array[i];
}
exit:
if (SHR_FUNC_ERR() && fld_name != NULL) {
LOG_WARN(BSL_LOG_MODULE,
(BSL_META_U(unit,
"Failed to parse %s.%s (%d).\n"),
lt_name, fld_name, rv));
}
}
/*!
* \brief Enable or disable SER event reporting.
*
* \param [in] unit Unit number.
* \param [in] enable Enable.
*
* \return BCM_E_NONE on success, error code otherwise.
*/
static int
ser_event_reporting_enable(int unit, int enable)
{
SHR_FUNC_ENTER(unit);
if (enable) {
SHR_IF_ERR_EXIT_EXCEPT_IF
(bcmi_lt_table_unsubscribe(unit, SER_LOGs, ser_log_lt_cb),
SHR_E_NOT_FOUND);
/* Set parser function for SER_LOG. */
SHR_IF_ERR_VERBOSE_EXIT
(bcmi_lt_table_parser_set(unit, SER_LOGs,
ser_log_entry_parse,
sizeof(ser_log_t)));
/* Subscribe SER_LOG LT. */
SHR_IF_ERR_VERBOSE_EXIT
(bcmi_lt_table_subscribe(unit, SER_LOGs, ser_log_lt_cb, NULL));
} else {
/* Unsubscribe SER_LOG. */
SHR_IF_ERR_EXIT_EXCEPT_IF
(bcmi_lt_table_unsubscribe(unit, SER_LOGs, ser_log_lt_cb),
SHR_E_NOT_FOUND);
}
exit:
SHR_FUNC_EXIT();
}
/******************************************************************************
* Public Functions
*/
int
bcmi_ltsw_ser_init(int unit)
{
int dunit;
bcmlt_entry_handle_t eh = BCMLT_INVALID_HDL;
uint64 fld_val;
int is_enabled;
int warm = bcmi_warmboot_get(unit);
SHR_FUNC_ENTER(unit);
SHR_IF_ERR_EXIT
(ser_config_is_enabled(unit, &is_enabled));
if (is_enabled == 0) {
SHR_EXIT();
}
dunit = bcmi_ltsw_dev_dunit(unit);
if (!warm) {
SHR_IF_ERR_EXIT
(bcmlt_entry_allocate(dunit, SER_CONTROLs, &eh));
fld_val = bcmi_ltsw_property_get(unit,
BCMI_CPN_SRAM_SCAN_CHUNK_SIZE,
256);
SHR_IF_ERR_EXIT
(bcmlt_entry_field_add(eh, SRAM_SCAN_CHUNK_SIZEs, fld_val));
fld_val = bcmi_ltsw_property_get(unit,
BCMI_CPN_SRAM_SCAN_ENABLE,
1);
SHR_IF_ERR_EXIT
(bcmlt_entry_field_add(eh, SRAM_SCANs, fld_val));
fld_val = bcmi_ltsw_property_get(unit,
BCMI_CPN_SRAM_SCAN_RATE,
4096);
SHR_IF_ERR_EXIT
(bcmlt_entry_field_add(eh, SRAM_ENTRIES_READ_PER_INTERVALs, fld_val));
fld_val = bcmi_ltsw_property_get(unit,
BCMI_CPN_SRAM_SCAN_INTERVAL,
100000);
SHR_IF_ERR_EXIT
(bcmlt_entry_field_add(eh, SRAM_SCAN_INTERVALs, fld_val));
/* Record erroneous entry */
SHR_IF_ERR_EXIT
(bcmlt_entry_field_add(eh, ERRONEOUS_ENTRIES_LOGGINGs, 1));
/* Enable H/W fault check */
SHR_IF_ERR_EXIT
(bcmlt_entry_field_add(eh, HW_FAULTs, 1));
/* 10s */
SHR_IF_ERR_EXIT
(bcmlt_entry_field_add(eh, SQUASH_DUPLICATED_SER_EVENT_INTERVALs, 10000));
SHR_IF_ERR_EXIT
(bcmlt_entry_field_add(eh, TCAM_SCANs, 1));
SHR_IF_ERR_EXIT
(bcmlt_entry_commit(eh, BCMLT_OPCODE_UPDATE, BCMLT_PRIORITY_NORMAL));
}
SHR_IF_ERR_EXIT
(ser_event_reporting_enable(unit, 1));
exit:
if (eh != BCMLT_INVALID_HDL) {
bcmlt_entry_free(eh);
}
SHR_FUNC_EXIT();
}
int
bcmi_ltsw_ser_detach(int unit)
{
int is_enabled;
SHR_FUNC_ENTER(unit);
SHR_IF_ERR_EXIT
(ser_config_is_enabled(unit, &is_enabled));
if (is_enabled == 0) {
SHR_EXIT();
}
SHR_IF_ERR_EXIT
(ser_event_reporting_enable(unit, 0));
exit:
SHR_FUNC_EXIT();
}
int
bcmi_ltsw_ser_single_bit_error_set(int unit, int enable)
{
int dunit;
bcmlt_entry_handle_t eh = BCMLT_INVALID_HDL;
uint64 fld_val;
int is_enabled;
SHR_FUNC_ENTER(unit);
SHR_IF_ERR_EXIT
(ser_config_is_enabled(unit, &is_enabled));
if (is_enabled == 0) {
SHR_IF_ERR_EXIT(SHR_E_UNAVAIL);
}
dunit = bcmi_ltsw_dev_dunit(unit);
SHR_IF_ERR_EXIT
(bcmlt_entry_allocate(dunit, SER_CONTROLs, &eh));
fld_val = enable ? 1 : 0;
SHR_IF_ERR_EXIT
(bcmlt_entry_field_add(eh, REPORT_SINGLE_BIT_ECCs, fld_val));
SHR_IF_ERR_EXIT
(bcmlt_entry_commit(eh, BCMLT_OPCODE_UPDATE, BCMLT_PRIORITY_NORMAL));
exit:
if (eh != BCMLT_INVALID_HDL) {
bcmlt_entry_free(eh);
}
SHR_FUNC_EXIT();
}
int
bcmi_ltsw_ser_single_bit_error_get(int unit, int *enable)
{
int dunit;
bcmlt_entry_handle_t eh = BCMLT_INVALID_HDL;
uint64 fld_val;
int is_enabled;
SHR_FUNC_ENTER(unit);
SHR_IF_ERR_EXIT
(ser_config_is_enabled(unit, &is_enabled));
if (is_enabled == 0) {
SHR_IF_ERR_EXIT(SHR_E_UNAVAIL);
}
dunit = bcmi_ltsw_dev_dunit(unit);
SHR_IF_ERR_EXIT
(bcmlt_entry_allocate(dunit, SER_CONTROLs, &eh));
SHR_IF_ERR_EXIT
(bcmlt_entry_commit(eh, BCMLT_OPCODE_LOOKUP, BCMLT_PRIORITY_NORMAL));
SHR_IF_ERR_EXIT
(bcmlt_entry_field_get(eh, REPORT_SINGLE_BIT_ECCs, &fld_val));
*enable = fld_val ? 1 : 0;
exit:
if (eh != BCMLT_INVALID_HDL) {
bcmlt_entry_free(eh);
}
SHR_FUNC_EXIT();
}
int
bcmi_ltsw_cmd_ser_inject(int unit, char *pt_name, int inst,
int index, int xor_bank, int validation)
{
int dunit;
bcmlt_entry_handle_t eh = BCMLT_INVALID_HDL;
uint64 fld_val;
int index_num, inst_num, copy_num;
ser_check_type_t check_type;
ser_recovery_type_t resp_type_1bit, resp_type_2bit;
int injected = 0, corrected = 0;
int is_enabled;
const char *validate_str = NULL;
SHR_FUNC_ENTER(unit);
SHR_IF_ERR_EXIT
(ser_config_is_enabled(unit, &is_enabled));
if (is_enabled == 0) {
SHR_IF_ERR_EXIT(SHR_E_UNAVAIL);
}
SHR_IF_ERR_EXIT
(ser_pt_status_info_get(unit, pt_name, 0, &index_num,
&inst_num, ©_num, &check_type,
&resp_type_1bit, &resp_type_2bit));
if (check_type == SER_NO_CHECK) {
SHR_IF_ERR_EXIT(SHR_E_UNAVAIL);
}
dunit = bcmi_ltsw_dev_dunit(unit);
SHR_IF_ERR_EXIT
(bcmlt_entry_allocate(dunit, SER_INJECTIONs, &eh));
SHR_IF_ERR_EXIT
(bcmlt_entry_field_symbol_add(eh, PT_IDs, pt_name));
if (copy_num > 1) {
fld_val = inst;
SHR_IF_ERR_EXIT
(bcmlt_entry_field_add(eh, PT_COPYs, fld_val));
fld_val = 0;
SHR_IF_ERR_EXIT
(bcmlt_entry_field_add(eh, PT_INDEXs, fld_val));
fld_val = index;
SHR_IF_ERR_EXIT
(bcmlt_entry_field_add(eh, PT_INSTANCEs, fld_val));
} else {
fld_val = 0;
SHR_IF_ERR_EXIT
(bcmlt_entry_field_add(eh, PT_COPYs, fld_val));
fld_val = index;
SHR_IF_ERR_EXIT
(bcmlt_entry_field_add(eh, PT_INDEXs, fld_val));
fld_val = inst;
SHR_IF_ERR_EXIT
(bcmlt_entry_field_add(eh, PT_INSTANCEs, fld_val));
}
if (check_type == SER_PARITY_CHECK) {
SHR_IF_ERR_EXIT
(bcmlt_entry_field_symbol_add(eh, INJECT_ERR_BIT_NUMs, SER_SINGLE_BIT_ERRs));
} else {
SHR_IF_ERR_EXIT
(bcmlt_entry_field_symbol_add(eh, INJECT_ERR_BIT_NUMs, SER_DOUBLE_BIT_ERRs));
}
if (xor_bank) {
SHR_IF_ERR_EXIT
(bcmlt_entry_field_add(eh, XOR_BANKs, 1));
}
validate_str = validation ? SER_VALIDATIONs : SER_NO_VALIDATIONs;
SHR_IF_ERR_EXIT
(bcmlt_entry_field_symbol_add(eh, INJECT_VALIDATEs, validate_str));
if (validation) {
SHR_IF_ERR_EXIT
(bcmlt_entry_field_add(eh, TIME_TO_WAITs, 50));
}
SHR_IF_ERR_EXIT
(bcmlt_entry_commit(eh, BCMLT_OPCODE_UPDATE, BCMLT_PRIORITY_NORMAL));
SHR_IF_ERR_EXIT
(ser_injection_status_info_get(unit, &injected, &corrected));
if (injected == 0) {
SHR_IF_ERR_EXIT(SHR_E_FAIL);
}
if (((check_type == SER_PARITY_CHECK && resp_type_1bit != SER_RECOVERY_NO_OPERATION) ||
(check_type == SER_ECC_CHECK && resp_type_2bit != SER_RECOVERY_NO_OPERATION)) &&
(validation && corrected == 0)) {
SHR_IF_ERR_EXIT(SHR_E_FAIL);
}
exit:
if (eh != BCMLT_INVALID_HDL) {
bcmlt_entry_free(eh);
}
SHR_FUNC_EXIT();
}
int
bcmi_ltsw_cmd_ser_scan_config(int unit, bool tcam, int rate, int internal, int enable)
{
int is_enabled;
int dunit;
bcmlt_entry_handle_t eh = BCMLT_INVALID_HDL;
uint64 fld_val;
const char *field_str = tcam ? TCAM_SCANs : SRAM_SCANs;
SHR_FUNC_ENTER(unit);
SHR_IF_ERR_EXIT
(ser_config_is_enabled(unit, &is_enabled));
if (is_enabled == 0) {
SHR_IF_ERR_EXIT(SHR_E_UNAVAIL);
}
dunit = bcmi_ltsw_dev_dunit(unit);
SHR_IF_ERR_EXIT
(bcmlt_entry_allocate(dunit, SER_CONTROLs, &eh));
fld_val = enable ? 1 : 0;
SHR_IF_ERR_EXIT
(bcmlt_entry_field_add(eh, field_str, fld_val));
if (tcam) {
SHR_IF_ERR_EXIT
(bcmlt_entry_commit(eh, BCMLT_OPCODE_UPDATE, BCMLT_PRIORITY_NORMAL));
/* Exit */
SHR_EXIT();
}
fld_val = internal / 1000;
SHR_IF_ERR_EXIT
(bcmlt_entry_field_add(eh, SRAM_SCAN_INTERVALs, fld_val));
fld_val = rate;
SHR_IF_ERR_EXIT
(bcmlt_entry_field_add(eh, SRAM_ENTRIES_READ_PER_INTERVALs, fld_val));
SHR_IF_ERR_EXIT
(bcmlt_entry_commit(eh, BCMLT_OPCODE_UPDATE, BCMLT_PRIORITY_NORMAL));
exit:
if (eh != BCMLT_INVALID_HDL) {
bcmlt_entry_free(eh);
}
SHR_FUNC_EXIT();
}
int
bcmi_ltsw_cmd_ser_scan_get(int unit, bool tcam, int *rate, int *interal, int *en)
{
int is_enabled;
int dunit;
bcmlt_entry_handle_t eh = BCMLT_INVALID_HDL;
uint64 fld_val;
const char *field_str = tcam ? TCAM_SCANs : SRAM_SCANs;
SHR_FUNC_ENTER(unit);
SHR_IF_ERR_EXIT
(ser_config_is_enabled(unit, &is_enabled));
if (is_enabled == 0) {
SHR_IF_ERR_EXIT(SHR_E_UNAVAIL);
}
dunit = bcmi_ltsw_dev_dunit(unit);
SHR_IF_ERR_EXIT
(bcmlt_entry_allocate(dunit, SER_CONTROLs, &eh));
SHR_IF_ERR_EXIT
(bcmlt_entry_commit(eh, BCMLT_OPCODE_LOOKUP, BCMLT_PRIORITY_NORMAL));
SHR_IF_ERR_EXIT
(bcmlt_entry_field_get(eh, field_str, &fld_val));
*en = fld_val ? 1 : 0;
if (tcam) {
/* Exit */
SHR_EXIT();
}
SHR_IF_ERR_EXIT
(bcmlt_entry_field_get(eh, SRAM_SCAN_INTERVALs, &fld_val));
/* milliseconds -> microseconds */
*interal = fld_val * 1000;
SHR_IF_ERR_EXIT
(bcmlt_entry_field_get(eh, SRAM_ENTRIES_READ_PER_INTERVALs, &fld_val));
*rate = fld_val;
exit:
if (eh != BCMLT_INVALID_HDL) {
bcmlt_entry_free(eh);
}
SHR_FUNC_EXIT();
}
int
bcmi_ltsw_cmd_ser_control_set(int unit, bcmi_ltsw_ser_control_t *ser_ctrl)
{
int is_enabled;
int dunit;
bcmlt_entry_handle_t eh = BCMLT_INVALID_HDL;
uint64 fld_val;
SHR_FUNC_ENTER(unit);
SHR_IF_ERR_EXIT
(ser_config_is_enabled(unit, &is_enabled));
if (is_enabled == 0) {
SHR_IF_ERR_EXIT(SHR_E_UNAVAIL);
}
SHR_NULL_CHECK(ser_ctrl, SHR_E_PARAM);
dunit = bcmi_ltsw_dev_dunit(unit);
SHR_IF_ERR_EXIT
(bcmlt_entry_allocate(dunit, SER_CONTROLs, &eh));
fld_val = ser_ctrl->squash_duplicated_interval;
SHR_IF_ERR_EXIT
(bcmlt_entry_field_add(eh, SQUASH_DUPLICATED_SER_EVENT_INTERVALs,
fld_val));
SHR_IF_ERR_EXIT
(bcmlt_entry_commit(eh, BCMLT_OPCODE_UPDATE, BCMLT_PRIORITY_NORMAL));
exit:
if (eh != BCMLT_INVALID_HDL) {
bcmlt_entry_free(eh);
}
SHR_FUNC_EXIT();
}
int
bcmi_ltsw_cmd_ser_control_get(int unit, bcmi_ltsw_ser_control_t *ser_ctrl)
{
int is_enabled;
int dunit;
bcmlt_entry_handle_t eh = BCMLT_INVALID_HDL;
uint64 fld_val;
SHR_FUNC_ENTER(unit);
SHR_IF_ERR_EXIT
(ser_config_is_enabled(unit, &is_enabled));
if (is_enabled == 0) {
SHR_IF_ERR_EXIT(SHR_E_UNAVAIL);
}
SHR_NULL_CHECK(ser_ctrl, SHR_E_PARAM);
dunit = bcmi_ltsw_dev_dunit(unit);
SHR_IF_ERR_EXIT
(bcmlt_entry_allocate(dunit, SER_CONTROLs, &eh));
SHR_IF_ERR_EXIT
(bcmlt_entry_commit(eh, BCMLT_OPCODE_LOOKUP, BCMLT_PRIORITY_NORMAL));
SHR_IF_ERR_EXIT
(bcmlt_entry_field_get(eh, SQUASH_DUPLICATED_SER_EVENT_INTERVALs,
&fld_val));
ser_ctrl->squash_duplicated_interval = (uint32_t)fld_val;
exit:
if (eh != BCMLT_INVALID_HDL) {
bcmlt_entry_free(eh);
}
SHR_FUNC_EXIT();
}
int
bcm_ltsw_switch_ser_log_info_get(int unit, int id,
bcm_switch_ser_log_info_t *info)
{
int dunit;
bcmlt_entry_handle_t eh = BCMLT_INVALID_HDL;
uint64 fld_val;
ser_log_t ser_log_info;
int is_enabled;
SHR_FUNC_ENTER(unit);
SHR_IF_ERR_EXIT
(ser_config_is_enabled(unit, &is_enabled));
if (is_enabled == 0) {
SHR_IF_ERR_EXIT(SHR_E_UNAVAIL);
}
dunit = bcmi_ltsw_dev_dunit(unit);
SHR_IF_ERR_EXIT
(bcmlt_entry_allocate(dunit, SER_LOGs, &eh));
fld_val = id;
SHR_IF_ERR_VERBOSE_EXIT
(bcmlt_entry_field_add(eh, SER_LOG_IDs, fld_val));
SHR_IF_ERR_EXIT
(bcmlt_entry_commit(eh, BCMLT_OPCODE_LOOKUP, BCMLT_PRIORITY_NORMAL));
sal_memset(&ser_log_info, 0, sizeof(ser_log_t));
ser_log_entry_parse(unit, SER_LOGs, eh, &ser_log_info, NULL);
sal_memset(info, 0, sizeof(bcm_switch_ser_log_info_t));
SHR_IF_ERR_EXIT
(ser_log_entry_transform(unit, &ser_log_info, info));
exit:
if (eh != BCMLT_INVALID_HDL) {
bcmlt_entry_free(eh);
}
SHR_FUNC_EXIT();
}
int
bcm_ltsw_switch_ser_error_stat_get(int unit,
bcm_switch_ser_error_stat_type_t stat_type,
uint32 *value)
{
const char *blk_type = NULL;
const char *rep_type = NULL;
int dunit, rv;
bcmlt_entry_handle_t eh = BCMLT_INVALID_HDL;
uint64 fld_val;
int is_enabled;
SHR_FUNC_ENTER(unit);
SHR_IF_ERR_EXIT
(ser_config_is_enabled(unit, &is_enabled));
if (is_enabled == 0) {
SHR_IF_ERR_EXIT(SHR_E_UNAVAIL);
}
SHR_IF_ERR_EXIT
(ser_blk_type_map(unit, stat_type.block_type, &blk_type));
SHR_IF_ERR_EXIT
(ser_rep_type_map(unit, stat_type.correction_type, &rep_type));
dunit = bcmi_ltsw_dev_dunit(unit);
SHR_IF_ERR_EXIT
(bcmlt_entry_allocate(dunit, SER_STATSs, &eh));
SHR_IF_ERR_EXIT
(bcmlt_entry_field_symbol_add(eh, BLK_TYPEs, blk_type));
SHR_IF_ERR_EXIT
(bcmlt_entry_field_symbol_add(eh, RECOVERY_TYPEs, rep_type));
SHR_IF_ERR_EXIT
(bcmlt_entry_commit(eh, BCMLT_OPCODE_LOOKUP, BCMLT_PRIORITY_NORMAL));
*value = 0;
switch (stat_type.error_type) {
case bcmSwitchErrorTypeParity:
case bcmSwitchErrorTypeAll:
rv = bcmlt_entry_field_get(eh, PARITY_ERR_REG_CNTs, &fld_val);
SHR_IF_ERR_EXIT(rv);
*value += (uint32)fld_val;
rv = bcmlt_entry_field_get(eh, PARITY_ERR_MEM_CNTs, &fld_val);
SHR_IF_ERR_EXIT(rv);
*value += (uint32)fld_val;
rv = bcmlt_entry_field_get(eh, PARITY_ERR_CTR_CNTs, &fld_val);
SHR_IF_ERR_EXIT(rv);
*value += (uint32)fld_val;
rv = bcmlt_entry_field_get(eh, PARITY_ERR_TCAM_CNTs, &fld_val);
SHR_IF_ERR_EXIT(rv);
*value += (uint32)fld_val;
rv = bcmlt_entry_field_get(eh, ECC_PARITY_ERR_INT_MEM_CNTs, &fld_val);
SHR_IF_ERR_EXIT(rv);
*value += (uint32)fld_val;
rv = bcmlt_entry_field_get(eh, ECC_PARITY_ERR_INT_BUS_CNTs, &fld_val);
SHR_IF_ERR_EXIT(rv);
*value += (uint32)fld_val;
if (stat_type.error_type != bcmSwitchErrorTypeAll) {
break;
}
case bcmSwitchErrorTypeEccSingleBit:
rv = bcmlt_entry_field_get(eh, ECC_SBE_REG_CNTs, &fld_val);
SHR_IF_ERR_EXIT(rv);
*value += (uint32)fld_val;
rv = bcmlt_entry_field_get(eh, ECC_SBE_MEM_CNTs, &fld_val);
SHR_IF_ERR_EXIT(rv);
*value += (uint32)fld_val;
rv = bcmlt_entry_field_get(eh, ECC_SBE_CTR_CNTs, &fld_val);
SHR_IF_ERR_EXIT(rv);
*value += (uint32)fld_val;
if (stat_type.error_type != bcmSwitchErrorTypeAll) {
break;
}
case bcmSwitchErrorTypeEccDoubleBit:
rv = bcmlt_entry_field_get(eh, ECC_DBE_REG_CNTs, &fld_val);
SHR_IF_ERR_EXIT(rv);
*value += (uint32)fld_val;
rv = bcmlt_entry_field_get(eh, ECC_DBE_MEM_CNTs, &fld_val);
SHR_IF_ERR_EXIT(rv);
*value += (uint32)fld_val;
rv = bcmlt_entry_field_get(eh, ECC_DBE_CTR_CNTs, &fld_val);
SHR_IF_ERR_EXIT(rv);
*value += (uint32)fld_val;
break;
default:
SHR_IF_ERR_EXIT(SHR_E_UNAVAIL);
}
exit:
if (eh != BCMLT_INVALID_HDL) {
bcmlt_entry_free(eh);
}
SHR_FUNC_EXIT();
}
int
bcm_ltsw_switch_ser_error_stat_clear(int unit,
bcm_switch_ser_error_stat_type_t stat_type)
{
const char *blk_type = NULL;
const char *rep_type = NULL;
int dunit, rv;
bcmlt_entry_handle_t eh = BCMLT_INVALID_HDL;
int is_enabled;
SHR_FUNC_ENTER(unit);
SHR_IF_ERR_EXIT
(ser_config_is_enabled(unit, &is_enabled));
if (is_enabled == 0) {
SHR_IF_ERR_EXIT(SHR_E_UNAVAIL);
}
SHR_IF_ERR_EXIT
(ser_blk_type_map(unit, stat_type.block_type, &blk_type));
SHR_IF_ERR_EXIT
(ser_rep_type_map(unit, stat_type.correction_type, &rep_type));
dunit = bcmi_ltsw_dev_dunit(unit);
SHR_IF_ERR_EXIT
(bcmlt_entry_allocate(dunit, SER_STATSs, &eh));
SHR_IF_ERR_EXIT
(bcmlt_entry_field_symbol_add(eh, BLK_TYPEs, blk_type));
SHR_IF_ERR_EXIT
(bcmlt_entry_field_symbol_add(eh, RECOVERY_TYPEs, rep_type));
switch (stat_type.error_type) {
case bcmSwitchErrorTypeParity:
case bcmSwitchErrorTypeAll:
rv = bcmlt_entry_field_add(eh, PARITY_ERR_REG_CNTs, 0);
SHR_IF_ERR_EXIT(rv);
rv = bcmlt_entry_field_add(eh, PARITY_ERR_MEM_CNTs, 0);
SHR_IF_ERR_EXIT(rv);
rv = bcmlt_entry_field_add(eh, PARITY_ERR_CTR_CNTs, 0);
SHR_IF_ERR_EXIT(rv);
rv = bcmlt_entry_field_add(eh, PARITY_ERR_TCAM_CNTs, 0);
SHR_IF_ERR_EXIT(rv);
rv = bcmlt_entry_field_add(eh, ECC_PARITY_ERR_INT_MEM_CNTs, 0);
SHR_IF_ERR_EXIT(rv);
rv = bcmlt_entry_field_add(eh, ECC_PARITY_ERR_INT_BUS_CNTs, 0);
SHR_IF_ERR_EXIT(rv);
if (stat_type.error_type != bcmSwitchErrorTypeAll) {
break;
}
case bcmSwitchErrorTypeEccSingleBit:
rv = bcmlt_entry_field_add(eh, ECC_SBE_REG_CNTs, 0);
SHR_IF_ERR_EXIT(rv);
rv = bcmlt_entry_field_add(eh, ECC_SBE_MEM_CNTs, 0);
SHR_IF_ERR_EXIT(rv);
rv = bcmlt_entry_field_add(eh, ECC_SBE_CTR_CNTs, 0);
SHR_IF_ERR_EXIT(rv);
if (stat_type.error_type != bcmSwitchErrorTypeAll) {
break;
}
case bcmSwitchErrorTypeEccDoubleBit:
rv = bcmlt_entry_field_add(eh, ECC_DBE_REG_CNTs, 0);
SHR_IF_ERR_EXIT(rv);
rv = bcmlt_entry_field_add(eh, ECC_DBE_MEM_CNTs, 0);
SHR_IF_ERR_EXIT(rv);
rv = bcmlt_entry_field_add(eh, ECC_DBE_CTR_CNTs, 0);
SHR_IF_ERR_EXIT(rv);
break;
default:
SHR_IF_ERR_EXIT(SHR_E_UNAVAIL);
}
SHR_IF_ERR_EXIT
(bcmlt_entry_commit(eh, BCMLT_OPCODE_UPDATE, BCMLT_PRIORITY_NORMAL));
exit:
if (eh != BCMLT_INVALID_HDL) {
bcmlt_entry_free(eh);
}
SHR_FUNC_EXIT();
}
| 30.060027 | 134 | 0.620927 | [
"transform"
] |
1ace836cf73bcfdab0b5d1f33cf6a529f16a3cdb | 1,108 | h | C | src/compiler/Symbol Table/class_tree.h | dimashky/compiler | 0b772d16aec1a327698886b1f28f3abdfa60c1a1 | [
"MIT"
] | 5 | 2018-07-06T04:05:05.000Z | 2021-08-05T23:59:44.000Z | src/compiler/Symbol Table/class_tree.h | maheralkassir/compiler | 0b772d16aec1a327698886b1f28f3abdfa60c1a1 | [
"MIT"
] | 4 | 2018-07-05T22:19:30.000Z | 2018-07-05T22:19:30.000Z | src/compiler/Symbol Table/class_tree.h | maheralkassir/compiler | 0b772d16aec1a327698886b1f28f3abdfa60c1a1 | [
"MIT"
] | 3 | 2018-12-08T10:13:32.000Z | 2021-03-27T02:04:18.000Z | #pragma once
#include <bits\stdc++.h>
using namespace::std;
class node
{
public:
node* parent;
string name;
void* stPTR;
map<string, node*> childs;
vector<pair<string, node*> > bases;
int visited;
node(string name, node* parent, void* stPTR);
~node();
};
class class_tree
{
private:
node *root, *current;
bool is_parent(node* &child, node* &parent);
node* find_in_graph(node* &curr, string &class_name, stack<node*>&path);
int print_defination_tree(node *curr, int id, vector<string>* nodes, vector<string>* edges);
public:
class_tree();
node* add_node(string name, void* stPTR);
void end_node();
void add_base(string name, node* child_ptr, node* parent_ptr);
void down_specific_child(string name);
pair<void*, bool> find(node* curr, queue<string> list, node* current_class);
pair<void*, bool> find(node* curr, queue<string> list);
void check_cycle(node* curr, node* parent, vector<node*> &cycle_path);
node* check_using_namespace(queue<string>&list);
node* get_root();
void print_defination_tree(node *curr);
void print_inhertince_tree(node *curr);
~class_tree();
};
| 22.16 | 93 | 0.712094 | [
"vector"
] |
1adbfbc4e34b0bfc05c67f5b91222e5d5fbf6d82 | 432 | h | C | JammaLib/src/audio/FallingValue.h | malisimo/Jamma | 69831e79a64e652e82aa41f8141e082c3899896b | [
"MIT"
] | null | null | null | JammaLib/src/audio/FallingValue.h | malisimo/Jamma | 69831e79a64e652e82aa41f8141e082c3899896b | [
"MIT"
] | null | null | null | JammaLib/src/audio/FallingValue.h | malisimo/Jamma | 69831e79a64e652e82aa41f8141e082c3899896b | [
"MIT"
] | null | null | null | #pragma once
#include <vector>
#include <memory>
namespace audio
{
class FallingValue
{
public:
class FallingValueParams
{
public:
double FallRate;
};
public:
FallingValue(FallingValueParams fallingParams);
public:
virtual double Next();
virtual double Current() const;
virtual void SetTarget(double target);
protected:
double _target;
double _lastValue;
FallingValueParams _fallingParams;
};
}
| 13.935484 | 49 | 0.729167 | [
"vector"
] |
1adbffb07a2ae39b6c3ed66d7ba34bdecc74b069 | 3,922 | h | C | smtk/extension/paraview/widgets/plugin/pqSMTKConeItemWidget.h | jcfr/SMTK | 0069ea37f8f71a440b8f10a157b84a56ca004551 | [
"BSD-3-Clause-Clear"
] | 40 | 2015-02-21T19:55:54.000Z | 2022-01-06T13:13:05.000Z | smtk/extension/paraview/widgets/plugin/pqSMTKConeItemWidget.h | jcfr/SMTK | 0069ea37f8f71a440b8f10a157b84a56ca004551 | [
"BSD-3-Clause-Clear"
] | 127 | 2015-01-15T20:55:45.000Z | 2021-08-19T17:34:15.000Z | smtk/extension/paraview/widgets/plugin/pqSMTKConeItemWidget.h | jcfr/SMTK | 0069ea37f8f71a440b8f10a157b84a56ca004551 | [
"BSD-3-Clause-Clear"
] | 27 | 2015-03-04T14:17:51.000Z | 2021-12-23T01:05:42.000Z | //=========================================================================
// Copyright (c) Kitware, Inc.
// All rights reserved.
// See LICENSE.txt for details.
//
// This software is distributed WITHOUT ANY WARRANTY; without even
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE. See the above copyright notice for more information.
//=========================================================================
#ifndef smtk_extension_paraview_widgets_pqSMTKConeItemWidget_h
#define smtk_extension_paraview_widgets_pqSMTKConeItemWidget_h
#include "smtk/extension/paraview/widgets/pqSMTKAttributeItemWidget.h"
/**\brief Display an interactive 3-D cone (or cylinder) frustum widget.
*
* The widget currently accepts 2 endpoints that define an
* axis for the cone and, at the same time, 2 parallel planes
* that cut the cone.
* Each endpoint may have an associated radius, one of which may
* be zero.
*
* If setForceCylindrical(true) is called, then the cone is forced to be a
* cylinder with a single radius value accepted.
*
* Note that the widget does not allow an interior apex (i.e., neither
* of the the radii may be negative).
* In the future, other item types (such as a GroupItem holding
* children specifying a center, Euler angles, and a length)
* may be supported.
*
* Currently, there is no support to initialize the placement to
* a given set of bounds; if you use this widget as part of the
* user interface to an operation, implement a configure() method
* on the operation to contextually place the widget based on
* associations.
*/
class pqSMTKConeItemWidget : public pqSMTKAttributeItemWidget
{
Q_OBJECT
public:
pqSMTKConeItemWidget(
const smtk::extension::qtAttributeItemInfo& info,
Qt::Orientation orient = Qt::Horizontal);
~pqSMTKConeItemWidget() override;
/// Create an instance of the widget that allows users to define a cone.
static qtItem* createConeItemWidget(const qtAttributeItemInfo& info);
/// Create an instance of the widget that allows users to define a cylinder.
static qtItem* createCylinderItemWidget(const qtAttributeItemInfo& info);
bool createProxyAndWidget(vtkSMProxy*& proxy, pqInteractivePropertyWidget*& widget) override;
protected slots:
/// Retrieve property values from ParaView proxy and store them in the attribute's Item.
void updateItemFromWidgetInternal() override;
/// Retrieve property values from the attribute's Item and update the ParaView proxy.
void updateWidgetFromItemInternal() override;
public slots:
/**\brief Change the user interface so that only cylinders are accepted (when passed true).
*
* This method returns true when the user interface changes state
* as a result of the call and false otherwise.
*/
bool setForceCylindrical(bool);
protected:
/// Describe how an attribute's items specify a cone or cylinder.
enum class ItemBindings
{
/// 2 items with 3 values, 2 items with 1 value (x0, y0, z0, x1, y1, z1, r0, r1).
ConePointsRadii,
/// 2 items with 3 values, 1 item with 1 value (x0, y0, z0, x1, y1, z1, radius).
CylinderPointsRadius,
/// No consistent set of items detected.
Invalid
};
/**\brief Starting with the widget's assigned item (which must currently
* be a GroupItem), determine and return bound items.
*
* The named item must be a Group holding items as called out by
* one of the valid ItemBindings enumerants.
* The items inside the Group must currently be Double items.
*
* If errors (such as a lack of matching item names or an
* unexpected number of values per item) are encountered,
* this method returns false.
*/
bool fetchConeItems(ItemBindings& binding, std::vector<smtk::attribute::DoubleItemPtr>& items);
bool m_forceCylinder;
};
#endif // smtk_extension_paraview_widgets_pqSMTKConeItemWidget_h
| 40.43299 | 97 | 0.711627 | [
"vector"
] |
1ae396979b1d006e99542a351342d6bc049b4f45 | 611 | h | C | dnn_project/dnn/util/accum.h | alexeyche/dnn_old | 58305cf486187575312cef0a753c86a8c7792196 | [
"MIT"
] | null | null | null | dnn_project/dnn/util/accum.h | alexeyche/dnn_old | 58305cf486187575312cef0a753c86a8c7792196 | [
"MIT"
] | null | null | null | dnn_project/dnn/util/accum.h | alexeyche/dnn_old | 58305cf486187575312cef0a753c86a8c7792196 | [
"MIT"
] | null | null | null | #pragma once
#include <vector>
namespace dnn {
template <typename T>
class Accum {
public:
Accum() {}
Accum(const T &v) {
acc.push_back(v);
}
void operator = (const T &v) {
acc.push_back(v);
}
void operator = (const Accum<T> &v) {
acc.insert(acc.end(), v.acc.begin(), v.acc.end());
}
template <typename NT>
void operator = (const NT &v) {
throw dnnException() << "Trying to accumulate value with different type " << v << "\n";
}
const vector<T>& getValues() {
return acc;
}
private:
vector<T> acc;
};
}
| 13.886364 | 95 | 0.538462 | [
"vector"
] |
1af0df38c683c3eb6e4d046424b65f80e8ed284d | 2,195 | h | C | content/public/browser/xr_consent_helper.h | sarang-apps/darshan_browser | 173649bb8a7c656dc60784d19e7bb73e07c20daa | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | null | null | null | content/public/browser/xr_consent_helper.h | sarang-apps/darshan_browser | 173649bb8a7c656dc60784d19e7bb73e07c20daa | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | null | null | null | content/public/browser/xr_consent_helper.h | sarang-apps/darshan_browser | 173649bb8a7c656dc60784d19e7bb73e07c20daa | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | null | null | null | // Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CONTENT_PUBLIC_BROWSER_XR_CONSENT_HELPER_H_
#define CONTENT_PUBLIC_BROWSER_XR_CONSENT_HELPER_H_
#include "base/callback_forward.h"
#include "content/common/content_export.h"
#include "content/public/browser/xr_consent_prompt_level.h"
namespace content {
using OnXrUserConsentCallback =
base::OnceCallback<void(XrConsentPromptLevel, bool)>;
// Interface class to provide the opportunity for runtimes to ensure that any
// necessary UI is shown to request the appropriate level of user consent
// for the requested session. This is acquired via the |XrInstallHelperFactory|.
// Generally, these steps are specific per runtime, so likely this should be
// implemented for each runtime that has browser-specific installation steps.
// This should be implemented by embedders.
class CONTENT_EXPORT XrConsentHelper {
public:
virtual ~XrConsentHelper() = default;
XrConsentHelper(const XrConsentHelper&) = delete;
XrConsentHelper& operator=(const XrConsentHelper&) = delete;
// Shows UI necessary to prompt the user for the given level of consent.
// render_process_id and render_frame_id are passed in order to ensure that
// any tab specific UI can be shown.
// The callback should be guaranteed to run in the event that the object is
// destroyed, and the object should handle being destroyed as an indication
// that any displayed UI should be cleaned up.
// The Callback should return either the highest level of consent that was
// granted and true (if e.g. the user only granted consent to a lower level
// than was initially requested), or the requested level of consent and false,
// if the user denied consent.
virtual void ShowConsentPrompt(int render_process_id,
int render_frame_id,
XrConsentPromptLevel consent_level,
OnXrUserConsentCallback) = 0;
protected:
XrConsentHelper() = default;
};
} // namespace content
#endif // CONTENT_PUBLIC_BROWSER_XR_CONSENT_HELPER_H_
| 42.211538 | 80 | 0.749431 | [
"object"
] |
ffa4332abe348a7c11cd2c2e7238e80bd8a43224 | 3,960 | h | C | user/lib/libdriver/include/driver/BufferPool.h | tristanseifert/kush-os | 1ffd595aae8f3dc880e798eff72365b8b6c631f0 | [
"0BSD"
] | 4 | 2021-06-22T20:52:30.000Z | 2022-02-04T00:19:44.000Z | user/lib/libdriver/include/driver/BufferPool.h | tristanseifert/kush-os | 1ffd595aae8f3dc880e798eff72365b8b6c631f0 | [
"0BSD"
] | null | null | null | user/lib/libdriver/include/driver/BufferPool.h | tristanseifert/kush-os | 1ffd595aae8f3dc880e798eff72365b8b6c631f0 | [
"0BSD"
] | null | null | null | #ifndef LIBDRIVER_DMA_BUFFERPOOL_H
#define LIBDRIVER_DMA_BUFFERPOOL_H
#include <compare>
#include <cstddef>
#include <cstdint>
#include <list>
#include <memory>
#include <driver/DmaBuffer.h>
namespace libdriver {
/**
* Represents a contiguous region of virtual memory, with a particular maximum size, from which
* smaller buffers can be allocated for IO.
*/
class BufferPool {
public:
/**
* Represents a buffer that was created from this pool.
*/
class Buffer: public DmaBuffer {
friend class BufferPool;
public:
~Buffer();
/// Gets the size of this buffer
size_t getSize() const override {
return this->size;
}
/// Return the physical pages that make up this buffer
const std::vector<Extent> &getExtents() const override {
return this->extents;
}
/// Gets pointer to this buffer's data
void * _Nonnull data() const override {
return reinterpret_cast<void *>(
reinterpret_cast<uintptr_t>(this->parent->base) + this->offset);
}
/// Gets the offset into the buffer pool.
constexpr uintptr_t getPoolOffset() const {
return this->offset;
}
private:
Buffer(BufferPool * _Nonnull pool, const uintptr_t offset, const size_t length);
private:
int status{0};
/// Pool from which the buffer was allocated
BufferPool * _Nonnull parent;
/// Size of this buffer's allocation
size_t size;
/// Offset into the buffer pool's allocation region
uintptr_t offset;
std::vector<Extent> extents;
};
public:
~BufferPool();
/// Attempts to allocate a sub-region of the buffer pool.
[[nodiscard]] int getBuffer(const size_t length, std::shared_ptr<Buffer> &outBuffer);
/// Return the handle of the underlying VM object.
constexpr auto getHandle() const {
return this->vmHandle;
}
/// Return the maximum size of the buffer pool.
constexpr auto getMaxSize() const {
return this->maxSize;
}
/// Return the currently allocated size of the buffer pool.
constexpr auto getSize() const {
return this->allocatedSize;
}
/// Allocate a new buffer pool.
[[nodiscard]] static int Alloc(const size_t initial, const size_t maxSize,
std::shared_ptr<BufferPool> &outPtr);
private:
/// Represents a free region of the buffer.
struct FreeRegion {
/// Offset from the start of the region
uintptr_t offset;
/// Length of the free region
size_t length;
inline auto operator<=>(const FreeRegion &r) const {
return this->offset <=> r.offset;
}
};
private:
BufferPool(const size_t initial, const size_t maxSize);
void freeRange(const uintptr_t offset, const size_t size);
void defragFreeList();
private:
/// Status code used to abort initialization if needed
int status{0};
/**
* Maximum size to which the buffer pool can grow. We reserve this entire size in the
* virtual memory space to begin with, but only allocate a small subset of it.
*/
size_t maxSize{0};
/// Actual number of bytes allocated
size_t allocatedSize{0};
/// VM handle for this region
uintptr_t vmHandle{0};
/// Base of the mapping
void * _Nonnull base;
/// All free regions
std::list<FreeRegion> freeList;
};
};
#endif
| 30.9375 | 96 | 0.558586 | [
"object",
"vector"
] |
ffafb0c5e70f19fd902f139354a23606223092a1 | 828 | h | C | inc/MyServerApp.h | LongLeonardoLe/SimpleHTTPServer | 51ab30e260cb3360995e41dec49cd046bf3fea86 | [
"MIT"
] | null | null | null | inc/MyServerApp.h | LongLeonardoLe/SimpleHTTPServer | 51ab30e260cb3360995e41dec49cd046bf3fea86 | [
"MIT"
] | null | null | null | inc/MyServerApp.h | LongLeonardoLe/SimpleHTTPServer | 51ab30e260cb3360995e41dec49cd046bf3fea86 | [
"MIT"
] | null | null | null | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/*
* File: MyServerApp.h
* Author: LongLNT
*
* Created on August 14, 2018, 10:58 AM
*/
#ifndef MYSERVERAPP_H
#define MYSERVERAPP_H
#include <Poco/Util/ServerApplication.h>
#include <Poco/Util/OptionSet.h>
#include <vector>
#include <string>
//#include "dispatcher.h"
using namespace Poco::Util;
class MyServerApp : public ServerApplication {
public:
MyServerApp();
MyServerApp(const MyServerApp& orig);
virtual ~MyServerApp();
void defineOptions(OptionSet& options) {}
int main(const std::vector<std::string> &) {}
private:
//dispatcher _dispatcher;
};
#endif /* MYSERVERAPP_H */
| 19.714286 | 79 | 0.687198 | [
"vector"
] |
ffb91e439fb4ab3daa20b1c475ab14987ba2e84d | 14,535 | c | C | libgu/gu_pcs.c | david672orford/PPR | 417ea5cbc9c644fa801d6ee0b9986cf70451d839 | [
"MIT"
] | 2 | 2016-03-20T13:42:59.000Z | 2019-08-21T11:18:01.000Z | libgu/gu_pcs.c | david672orford/PPR | 417ea5cbc9c644fa801d6ee0b9986cf70451d839 | [
"MIT"
] | null | null | null | libgu/gu_pcs.c | david672orford/PPR | 417ea5cbc9c644fa801d6ee0b9986cf70451d839 | [
"MIT"
] | null | null | null | /*
** mouse:~ppr/src/libgu/gu_pcs.c
** Copyright 1995--2005, Trinity College Computing Center.
** Written by David Chappell.
**
** 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.
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS 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.
**
** Last modified 17 October 2005.
*/
/*! \file
\brief Perl Compatible Strings
This module implements a string library. This library is designed to make it
easier to port Perl code to C. The strings are stored in objects known
as PCS (Perl Compatible String).
PCS objects can contain strings with embedded zero chars, but such string cannot
be converted to C strings because C strings can't contain embedded NULLs.
Note that most of the functions require a pointer to a pointer to the
PCS object. This is because when a "snapshot" has been taken, functions
which modify the object must clone it and change the pointer to point
to the clone.
*/
#include "config.h"
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
#include "gu.h"
struct PCS {
char *storage; /* the actual storage for the strings chars */
int storage_size; /* number of allocated byte at storage */
int length; /* number currently used */
int refcount; /* how many have pointers to this PCS or to its storage? */
int lurkers; /* how many of those have pointers only to the storage? */
};
/** create a PCS object
This function creates a new PCS (Perl compatible string) object and returns
a void pointer which should be passed to other gu_pcs_*() functions in order
to use it.
*/
void *gu_pcs_new(void)
{
struct PCS *p = gu_alloc(1, sizeof(struct PCS));
p->storage = NULL;
p->storage_size = 0;
p->length = 0;
p->refcount = 1;
p->lurkers = 0;
return (void *)p;
}
/** create new PCS and initialize from a PCS
This function creates a new PCS and copies the string value from the a
pre-existing PCS supplied as an argument.
*/
void *gu_pcs_new_pcs(void **pcs)
{
void *p = gu_pcs_new();
gu_pcs_set_pcs(&p, pcs);
return p;
}
/** create new PCS and initialize from a char[]
This function creates a new PCS and initializes it from the C character
array (string) provided.
*/
void *gu_pcs_new_cstr(const char cstr[])
{
void *p = gu_pcs_new();
gu_pcs_set_cstr(&p, cstr);
return p;
}
/** destroy a PCS object
This function decrements the reference count of a PCS object and sets the
pointer pointed to by pcs to NULL. If the reference counter reaches zero,
then the object is freed.
*/
void gu_pcs_free(void **pcs)
{
struct PCS *p = (struct PCS *)*pcs;
p->refcount--;
if((p->refcount - p->lurkers) == 0)
{
if(p->storage && p->lurkers == 0)
{
gu_free(p->storage);
p->storage = NULL;
}
gu_free(*pcs);
}
*pcs = (void*)NULL;
} /* end of gu_pcs_free() */
/** Destroy a PCS object reference but keep the C string
*
* The caller should not edit the string and should not
* free it until all PCS references to it have been destroyed.
*/
char *gu_pcs_free_keep_cstr(void **pcs)
{
struct PCS *p = (struct PCS *)*pcs;
char *strptr;
gu_pcs_grow(pcs, 0); /* ensure there is storage allocated */
strptr = p->storage;
p->lurkers++;
if((p->refcount - p->lurkers) == 0)
gu_free(*pcs);
*pcs = (void*)NULL;
return strptr;
} /* end of gu_pcs_free_keep_cstr() */
/** print a description of a PCS object on stdout
*/
void gu_pcs_debug(void **pcs, const char name[])
{
struct PCS *p = (struct PCS *)*pcs;
printf("%s (%p) = {storage=%p, storage[]=\"%s\", storage_size=%d, length=%d, refcount=%d, lurkers=%d}\n",
name,
p,
p->storage,
p->storage,
p->storage_size,
p->length,
p->refcount,
p->lurkers);
}
/** obtain a copy of a PCS object that won't be unexpectedly changed
This function increments the reference count of a PCS object. A function
should call this if it is going to keep a pointer to a PCS object that was
passed to it as an argument. If an attempt is made to modify a PCS object
with a non-zero reference count, a copy is made and the caller gets a
modified copy, but the copy held by other code is unmodified.
*/
void *gu_pcs_snapshot(void **pcs)
{
struct PCS *p = (struct PCS *)*pcs;
p->refcount++;
return *pcs;
}
/** expand the internal storage of a PCS in anticipation of future growth
This function enlarges the specified PCS so that it can hold a string of the
specified size (excluding final NULL). If the requested size is smaller
than the current storage size, this has no effect.
*/
void gu_pcs_grow(void **pcs, int new_size)
{
struct PCS *p = (struct PCS *)*pcs;
if((new_size + 1) > p->storage_size)
{
p->storage = gu_realloc(p->storage, (new_size + 1), sizeof(char));
p->storage_size = (new_size + 1);
p->storage[new_size] = '\0'; /* in case 'growing' to zero size */
}
}
/** copy a char[] into an existing PCS
This function copies the contents of a C string (a NULL terminated character
array) into the PCS object. The function may have to allocate a new object
and change the pointer pointed to by I<pcs> to point to the new object. A new
object will be allocated if the value has a reference count greater than one
(which means it should be copied on write).
*/
void gu_pcs_set_cstr(void **pcs, const char cstr[])
{
struct PCS *p = (struct PCS *)*pcs;
if(p->refcount > 1) /* if we share it, */
{
gu_pcs_free(pcs); /* detach from it */
*pcs = gu_pcs_new(); /* create a new object */
p = (struct PCS *)*pcs;
}
p->length = strlen(cstr);
gu_pcs_grow(pcs, p->length); /* expand if necessary */
memcpy(p->storage, cstr, p->length + 1);
}
/** copy a PCS into an existing PCS
This function copies the contents of a PCS into the PCS object. The function
may have to allocate a new object and change the pointer pointed to by I<pcs>
to point to the new object. A new object will be allocated if the value has a
reference count greater than one (which means it should be copied on write).
*/
void gu_pcs_set_pcs(void **pcs, void **pcs2)
{
struct PCS *p = (struct PCS *)*pcs;
#if 1
printf("gu_pcs_set_pcs(pcs=%p{refcount=%d,length=%d}, pcs2=%p{refcount=%d,length=%d})\n",
pcs,
p->refcount,
p->length,
pcs2,
((struct PCS *)*pcs2)->refcount,
((struct PCS *)*pcs2)->length
);
#endif
if(p->refcount > 1) /* if we share target, */
{
gu_pcs_free(pcs); /* detach from it */
*pcs = gu_pcs_new_pcs(pcs2); /* replace it with a copy of pcs2 */
}
else
{
struct PCS *p2 = (struct PCS *)*pcs2;
p->length = p2->length;
gu_pcs_grow(pcs, p->length);
memcpy(p->storage, p2->storage, p->length + 1);
}
}
/** get pointer to const char[] within PCS
This function returns a pointer to a NULL terminated C string which contains
the value of the PCS object. This pointer may cease to be valid if the PCS
object is modified or freed, so if you won't be using the value imediately,
you should call gu_strdup() on the result. Also, the string should not be
modified by using this pointer.
*/
const char *gu_pcs_get_cstr(void **pcs)
{
struct PCS *p = (struct PCS *)*pcs;
gu_pcs_grow(pcs, 0); /* ensure there is storage allocated */
return p->storage;
}
/** Get pointer to an editable char[] within PCS
This function should be called if you intend to edit the string in place. If
there are any other references to this PCS, a new copy will be made just for
you. If you will change the length of the string, call gu_pcs_length() to
determine the initial length. If you are enlarging the string, you need to
call gu_pcs_grow() first. If you are making the string smaller, you should
call gu_pcs_truncate() when you are done.
*/
char *gu_pcs_get_editable_cstr(void **pcs)
{
struct PCS *p = (struct PCS *)*pcs;
/*gu_pcs_debug(pcs, "gu_pcs_get_editable_cstr");*/
if(p->refcount > 1)
{
void *new_pcs = gu_pcs_new_pcs(pcs);
gu_pcs_free(pcs);
*pcs = new_pcs;
p = (struct PCS *)*pcs;
}
gu_pcs_grow(pcs, 0); /* ensure there is storage allocated */
return p->storage;
}
/** get length of PCS in bytes
This function returns the length in bytes of the PCS in bytes.
*/
int gu_pcs_length(void **pcs)
{
struct PCS *p = (struct PCS *)*pcs;
return p->length;
}
/** Truncate a PCS to a specified length in bytes.
*/
int gu_pcs_truncate(void **pcs, size_t newlen)
{
const char function[] = "gu_pcs_truncate";
struct PCS *p = (struct PCS *)*pcs;
if(newlen < 0)
gu_Throw("%s(): newlen=%d", function, (int)newlen);
if(newlen < p->length)
{
if(p->refcount > 1)
{
void *new_pcs = gu_pcs_new_pcs(pcs);
gu_pcs_free(pcs);
*pcs = new_pcs;
p = (struct PCS *)*pcs;
}
p->length = newlen;
p->storage[newlen] = '\0';
}
return p->length;
}
/** append char to PCS
This function appends a C char to the the PCS object.
*/
void gu_pcs_append_char(void **pcs, int c)
{
struct PCS *p = (struct PCS *)*pcs;
int new_length;
if(p->refcount > 1)
{
void *new_pcs = gu_pcs_new_pcs(pcs);
gu_pcs_free(pcs);
*pcs = new_pcs;
p = (struct PCS *)*pcs;
}
new_length = p->length + 1;
gu_pcs_grow(pcs, new_length);
p->storage[p->length] = c;
p->storage[new_length] = '\0'; /* keep it null terminated */
p->length = new_length;
} /* end of gu_pcs_append_char() */
/** append C char[] to PCS
This function appends a C string the the PCS object.
*/
void gu_pcs_append_cstr(void **pcs, const char cstr[])
{
struct PCS *p = (struct PCS *)*pcs;
int cstr_len;
if(p->refcount > 1)
{
void *new_pcs = gu_pcs_new_pcs(pcs);
gu_pcs_free(pcs);
*pcs = new_pcs;
p = (struct PCS *)*pcs;
}
cstr_len = strlen(cstr);
gu_pcs_grow(pcs, p->length + cstr_len);
memcpy(p->storage + p->length, cstr, cstr_len + 1);
p->length += cstr_len;
} /* end of gu_pcs_append_cstr() */
/** append PCS to existing PCS
This function appends a PCS object to the the PCS object.
*/
void gu_pcs_append_pcs(void **pcs, void **pcs2)
{
struct PCS *p, *p2;
int new_length;
p = (struct PCS *)*pcs;
if(p->refcount > 1)
{
void *new_pcs = gu_pcs_new_pcs(pcs);
gu_pcs_free(pcs);
*pcs = new_pcs;
p = (struct PCS *)*pcs;
}
p2 = (struct PCS *)*pcs2;
new_length = p->length + p2->length;
gu_pcs_grow(pcs, new_length);
memcpy(p->storage + p->length, p2->storage, p2->length + 1);
p->length = new_length;
}
/** append an sprintf() formatted string
*/
void gu_pcs_append_sprintf(void **pcs, const char format[], ...)
{
struct PCS *p = (struct PCS *)*pcs;
int sprintf_len;
va_list va;
va_start(va, format);
sprintf_len = gu_vsnprintf(NULL, 0, format, va);
if(sprintf_len == 0)
return;
if(sprintf_len < 0)
gu_Throw("sprintf_len=%d < 0!", sprintf_len);
if(p->refcount > 1)
{
void *new_pcs = gu_pcs_new_pcs(pcs);
gu_pcs_free(pcs);
*pcs = new_pcs;
p = (struct PCS *)*pcs;
}
gu_pcs_grow(pcs, p->length + sprintf_len);
gu_vsnprintf(p->storage + p->length, sprintf_len + 1, format, va);
p->length += sprintf_len;
va_end(va);
}
/** compare PCSs
This function does for PCSs what strcmp() does for C strings.
*/
int gu_pcs_cmp(void **pcs1, void **pcs2)
{
struct PCS *p1 = (struct PCS *)*pcs1;
struct PCS *p2 = (struct PCS *)*pcs2;
int remaining1 = p1->length + 1; /* include the terminating nulls */
int remaining2 = p2->length + 1;
char *cp1 = p1->storage;
char *cp2 = p2->storage;
int cmp = -1; /* initialized only to keep GCC happy */
while(remaining1-- && remaining2--)
{
if((cmp = (*cp1++ - *cp2++)) != 0)
break;
}
return cmp;
}
/*
** Test program
** gcc -Wall -DTEST -I../include -o gu_pcs gu_pcs.c ../libgu.a
*/
#ifdef TEST
int main(int argc, char *argv[])
{
void *pcs_a, *pcs_b, *pcs_c;
printf("pcs_a initialized to string \"Hello, World!\".\n");
pcs_a = gu_pcs_new_cstr("Hello, World!");
gu_pcs_debug(&pcs_a, "pcs_a");
printf("length: %d\n", gu_pcs_length(&pcs_a));
printf("\n");
printf("pcs_b is a snapshot of pcs_a\n");
pcs_b = gu_pcs_snapshot(&pcs_a);
gu_pcs_debug(&pcs_a, "pcs_a");
gu_pcs_debug(&pcs_b, "pcs_b");
printf("\n");
printf("append to pcs_a shouldn't change pcs_b.\n");
gu_pcs_append_cstr(&pcs_a, " What do you want to do today?");
gu_pcs_debug(&pcs_a, "pcs_a");
gu_pcs_debug(&pcs_b, "pcs_b");
printf("\n");
printf("create empty pcs_c\n");
pcs_c = gu_pcs_new();
gu_pcs_debug(&pcs_c, "pcs_c");
printf("Set it to a string...\n");
gu_pcs_set_cstr(&pcs_c, "The sky is blue.");
gu_pcs_debug(&pcs_c, "pcs_c");
printf("\n");
printf("Append a character to pcs_a...\n");
gu_pcs_append_char(&pcs_a, ' ');
gu_pcs_debug(&pcs_a, "pcs_a");
printf("Append a C string to pcs_a...\n");
gu_pcs_append_cstr(&pcs_a, "--");
gu_pcs_debug(&pcs_a, "pcs_a");
printf("Append pcs_c to pcs_a and pcs_b...\n");
gu_pcs_append_pcs(&pcs_a, &pcs_c);
gu_pcs_append_pcs(&pcs_b, &pcs_c);
gu_pcs_debug(&pcs_a, "pcs_a");
gu_pcs_debug(&pcs_b, "pcs_b");
printf("\n");
printf("Set pcs_a and pcs_b to pcs_c...\n");
gu_pcs_set_pcs(&pcs_a, &pcs_c);
gu_pcs_set_pcs(&pcs_b, &pcs_c);
gu_pcs_debug(&pcs_a, "pcs_a");
gu_pcs_debug(&pcs_b, "pcs_b");
printf("\n");
printf("pcs_a=%p, pcs_b=%p, pcs_c=%p\n", pcs_a, pcs_b, pcs_c);
gu_pcs_free(&pcs_a);
gu_pcs_debug(&pcs_b, "pcs_b");
gu_pcs_free(&pcs_b);
printf("pcs_a=%p, pcs_b=%p, pcs_c=%p\n", pcs_a, pcs_b, pcs_c);
printf("\n");
pcs_a = gu_pcs_new_cstr("test=");
gu_pcs_append_sprintf(&pcs_a, "%s,%s", "smith", "jones");
gu_pcs_debug(&pcs_a, "pcs_a");
gu_pcs_free(&pcs_a);
printf("\n");
return 0;
}
#endif
/* end of file */
| 26.669725 | 106 | 0.680083 | [
"object"
] |
ffce689dfe1762e7126db8207f36ab2eaeeb0beb | 2,627 | h | C | lab_03/libs/driver/include/driver/commands/model_command.h | migregal/bmstu_iu7_oop | a17b2b5b5eaa175ae3ad4fa5a217b2664d4aa331 | [
"MIT"
] | 5 | 2021-05-24T20:03:38.000Z | 2021-06-22T23:32:52.000Z | lab_03/libs/driver/include/driver/commands/model_command.h | migregal/bmstu_iu7_oop | a17b2b5b5eaa175ae3ad4fa5a217b2664d4aa331 | [
"MIT"
] | null | null | null | lab_03/libs/driver/include/driver/commands/model_command.h | migregal/bmstu_iu7_oop | a17b2b5b5eaa175ae3ad4fa5a217b2664d4aa331 | [
"MIT"
] | 1 | 2021-06-17T19:32:26.000Z | 2021-06-17T19:32:26.000Z | #pragma once
#include <cstddef>
#include <memory>
#include <commands/base_command.h>
#include <objects/object.h>
class ModelBaseCommand : public BaseCommand {};
class MoveModel : public ModelBaseCommand {
public:
MoveModel() = delete;
MoveModel(const double &dx, const double &dy, const double &dz, const std::size_t &mnumb);
~MoveModel() override = default;
void execute() override;
private:
std::size_t model_numb;
double dx, dy, dz;
};
class ScaleModel : public ModelBaseCommand {
public:
ScaleModel() = delete;
ScaleModel(const double &kx, const double &ky, const double &kz, const std::size_t &mnumb);
~ScaleModel() override = default;
void execute() override;
private:
std::size_t model_numb;
double kx, ky, kz;
};
class RotateModel : public ModelBaseCommand {
public:
RotateModel() = delete;
RotateModel(const double &ox, const double &oy, const double &oz, const std::size_t &mnumb);
~RotateModel() override = default;
void execute() override;
private:
std::size_t model_numb;
double ox, oy, oz;
};
class ReformModel : public ModelBaseCommand {
public:
ReformModel() = delete;
ReformModel(const std::size_t &numb, const Point &move, const Point &scale, const Point &turn);
~ReformModel() override = default;
void execute() override;
private:
std::size_t model_numb;
Point move, scale, turn;
};
class LoadModel : public ModelBaseCommand {
public:
LoadModel() = delete;
explicit LoadModel(std::string fname);
~LoadModel() override = default;
void execute() override;
private:
std::string fname;
};
class ExportModel : public ModelBaseCommand {
public:
ExportModel() = delete;
explicit ExportModel(std::string fname);
~ExportModel() override = default;
void execute() override;
private:
std::string fname;
};
class AddModel : public ModelBaseCommand {
public:
AddModel() = delete;
explicit AddModel(std::shared_ptr<Object> model);
~AddModel() override = default;
void execute() override;
private:
std::shared_ptr<Object> model;
};
class RemoveModel : public ModelBaseCommand {
public:
RemoveModel() = delete;
explicit RemoveModel(const std::size_t &model_numb);
~RemoveModel() override = default;
void execute() override;
private:
std::size_t model_numb;
};
class ModelCount : public ModelBaseCommand {
public:
ModelCount() = delete;
explicit ModelCount(std::shared_ptr<size_t> &count);
~ModelCount() override = default;
void execute() override;
private:
std::shared_ptr<size_t> &_count;
};
| 20.685039 | 99 | 0.687096 | [
"object",
"model"
] |
ffd9fcfd1bde3ac15aba038c1f8e4651d85c42c7 | 3,861 | h | C | src/QuasiCanonical.h | g1257/PsimagLite | 1cdeb4530c66cd41bd0c59af9ad2ecb1069ca010 | [
"Unlicense"
] | 8 | 2015-08-19T16:06:52.000Z | 2021-12-05T02:37:47.000Z | src/QuasiCanonical.h | g1257/PsimagLite | 1cdeb4530c66cd41bd0c59af9ad2ecb1069ca010 | [
"Unlicense"
] | 5 | 2016-02-02T20:28:21.000Z | 2019-07-08T22:56:12.000Z | src/QuasiCanonical.h | g1257/PsimagLite | 1cdeb4530c66cd41bd0c59af9ad2ecb1069ca010 | [
"Unlicense"
] | 5 | 2016-04-29T17:28:00.000Z | 2019-11-22T03:33:19.000Z | #ifndef QUASICANONICAL_H
#define QUASICANONICAL_H
#include "Vector.h"
#include "PsimagLite.h"
#include "CmplxOrReal.h"
namespace PsimagLite {
// level one parens only
// TODO FIXME : Generalize to multiple levels
template<typename ComplexOrRealType>
class QuasiCanonical {
public:
typedef Vector<String>::Type VectorStringType;
typedef Vector<bool>::Type VectorBoolType;
typedef typename Vector<ComplexOrRealType>::Type VectorType;
typedef typename Real<ComplexOrRealType>::Type RealType;
typedef std::complex<RealType> ComplexType;
QuasiCanonical(String str)
: str_(str)
{
const SizeType len = str_.length();
String tempBuffer;
String status = "closed";
char prev = '\0';
for (SizeType i = 0; i < len; ++i) {
if (str_[i] == '-' && i > 0) {
if (prev != '(' && prev != '+') {
throw RuntimeError("The - sign must be preceded by nothing, parens, or +\n");
}
}
prev = str_[i];
if (str_[i] == '(') {
if (status == "open")
throw RuntimeError("Too many parens levels (one only supported for now)\n");
status = "open";
continue;
}
if (str_[i] == ')') {
if (status == "closed")
throw RuntimeError("Unbalanced parens, closed\n");
status = "closed";
mainBuffer_ += "@" + ttos(ats_.size()) + "@";
ats_.push_back(tempBuffer);
tempBuffer = "";
continue;
}
if (status == "closed") {
mainBuffer_ += str_[i];
} else {
tempBuffer += str_[i];
}
}
if (status == "open")
throw RuntimeError("Unbalanced parens, open\n");
split(terms_, mainBuffer_, "+");
const SizeType nscalars = ats_.size();
cachedValues_.resize(nscalars);
for (SizeType i = 0; i < nscalars; ++i)
cachedValues_[i] = strToRealOrImag(ats_[i]);
}
SizeType numberOfTerms() const { return terms_.size(); }
const String& term(SizeType i) const
{
assert(i < terms_.size());
return terms_[i];
}
int scalarIndex(String str) const
{
const SizeType len = str.length();
if (len < 3) return -1;
if (str[0] != '@' || str[len - 1] != '@')
return -1;
String snumber = str.substr(1, len - 2);
SizeType number = PsimagLite::atoi(snumber);
if (number >= ats_.size())
return -1;
return number;
}
ComplexOrRealType scalarFromIndex(SizeType ind) const
{
assert(ind < cachedValues_.size());
return cachedValues_[ind];
}
static bool isPureComplex(String t)
{
if (t == "i") return true;
const SizeType n = t.length();
if (n < 2) return false;
String tmp = t.substr(0, n - 1);
return isRealScalar(tmp);
}
static ComplexOrRealType pureComplex(String t)
{
static const bool isComplex = IsComplexNumber<ComplexOrRealType>::True;
if (!isComplex)
err("i = sqrt(-1) found in code path that is real\n");
CpmlxOrReal<RealType, (isComplex) ? 1 : 0> cmplxOrReal(t);
return cmplxOrReal.value();
}
static bool isRealScalar(String termStr)
{
const SizeType n = termStr.length();
if (n == 0)
err("CanonicalExpression: term must not be empty\n");
for (SizeType i = 0; i < n; ++i) {
char c = termStr[i];
bool isDigit = (c >= '0' && c <= '9');
if (c == '.' || c == '-' || c == '+' || isDigit)
continue;
return false;
}
return true;
}
private:
static ComplexOrRealType pureRealOrPureImag(String t)
{
static const bool isComplex = IsComplexNumber<ComplexOrRealType>::True;
CpmlxOrReal<RealType, (isComplex) ? 1 : 0> cmplxOrReal(t);
return cmplxOrReal.value();
}
static ComplexOrRealType strToRealOrImag(String content)
{
VectorStringType terms;
split(terms, content, "+");
ComplexOrRealType sum = 0;
const SizeType n = terms.size();
for (SizeType i = 0; i < n; ++i) {
sum += pureRealOrPureImag(terms[i]);
}
return sum;
}
String str_;
String mainBuffer_;
VectorStringType ats_;
VectorStringType terms_;
VectorType cachedValues_;
};
}
#endif // QUASICANONICAL_H
| 22.711765 | 82 | 0.643098 | [
"vector"
] |
ffddbdde545cf875694a18e00b0e980075982227 | 7,236 | h | C | src/rosecommon/include/epackettype.h | JDoeBoy/osIROSE-new | 2a50d52b79f38ebf311b2724323a517d1e195c13 | [
"Apache-2.0"
] | null | null | null | src/rosecommon/include/epackettype.h | JDoeBoy/osIROSE-new | 2a50d52b79f38ebf311b2724323a517d1e195c13 | [
"Apache-2.0"
] | null | null | null | src/rosecommon/include/epackettype.h | JDoeBoy/osIROSE-new | 2a50d52b79f38ebf311b2724323a517d1e195c13 | [
"Apache-2.0"
] | null | null | null | // Copyright 2016 Chirstopher Torres (Raven), L3nn0x
//
// 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.
/*
* epackettype.h
*
* Created on: Nov 10, 2015
* Author: ctorres
*/
#ifndef EPACKETTYPE_H_
#define EPACKETTYPE_H_
#include <string>
#include <stdint.h>
namespace RoseCommon {
#ifdef _WIN32
#ifndef __MINGW32__
#define PACK(...) __pragma(pack(push, 1)) __VA_ARGS__ __pragma(pack(pop))
#else
#define PACK(...) __VA_ARGS__ __attribute__((__packed__))
#endif
#else
#define PACK(...) __VA_ARGS__ __attribute__((__packed__))
#endif
#ifndef MAX_PACKET_SIZE
#define MAX_PACKET_SIZE 0x7FF
#endif
// CS = Client -> server
// SC = server -> server
// SS = server -> server
// LC = Login -> server
// CC = Char -> Client
// WC = World -> client
enum class ePacketType : uint16_t {
ISCSTART = 0x300,
ISC_ALIVE,
ISC_SERVER_REGISTER,
ISC_TRANSFER, // transfer to specific map(s)
ISC_TRANSFER_CHAR, // transfer to specific character(s) (map(s) is/are determined automatically for you)
ISC_SHUTDOWN,
ISCEND,
// CLIENT PACKETS START HERE!!!
PAKSTART = 0x700,
PAKCS_ALIVE = PAKSTART,
PAKSS_ERROR = PAKCS_ALIVE,
PAKSS_ANNOUNCE_TEXT,
PAKSW_ANNOUNCE_CHAT,
PAKCS_ACCEPT_REQ,
PAKCS_CHANNEL_LIST_REQ,
PAKLC_CHANNEL_LIST_REPLY = PAKCS_CHANNEL_LIST_REQ,
PAKCS_LOGOUT_REQ = 0x707,
PAKWC_LOGOUT_REPLY = PAKCS_LOGOUT_REQ,
PAKCS_LOGIN_REQ,
PAKLC_LOGIN_REPLY = PAKCS_LOGIN_REQ,
PAKGC_LOGIN_REPLY,
PAKCS_SRV_SELECT_REQ = 0x70a,
PAKLC_SRV_SELECT_REPLY = PAKCS_SRV_SELECT_REQ,
PAKCS_JOIN_SERVER_REQ,
PAKSC_JOIN_SERVER_REPLY,
PAKWC_GM_COMMAND,
PAKWC_GLOBAL_VARS,
PAKWC_GLOBAL_FLAGS,
PAKCC_SWITCH_SERVER = 0x711,
PAKCS_CHAR_LIST_REQ,
PAKCC_CHAR_LIST_REPLY = PAKCS_CHAR_LIST_REQ,
PAKCS_CREATE_CHAR_REQ,
PAKCC_CREATE_CHAR_REPLY = PAKCS_CREATE_CHAR_REQ, // 0x713
PAKCS_DELETE_CHAR_REQ,
PAKCC_DELETE_CHAR_REPLY = PAKCS_DELETE_CHAR_REQ,
PAKCS_SELECT_CHAR_REQ, // 0x715
PAKWC_SELECT_CHAR_REPLY = PAKCS_SELECT_CHAR_REQ,
PAKWC_INVENTORY_DATA,
PAKWC_SET_MONEY_AND_ITEM,
PAKWC_SET_ITEM,
PAKWC_SERVER_DATA, // 0x719
PAKWC_QUEST_DATA = 0x71b,
PAKCS_CHANGE_CHAR_REQ,
PAKCC_CHAN_CHAR_REPLY = PAKCS_CHANGE_CHAR_REQ,
PAKWC_SET_MONEY, // 0x71d
PAKWC_QUEST_REWARD_MONEY,
PAKWC_QUEST_REWARD_ITEM,
PAKWC_QUEST_REWARD_ADD_STAT,
PAKWC_QUEST_REWARD_SET_STAT,
PAKCS_CANCEL_LOGOUT,
PAKWC_QUEST_UPDATE,
PAKWC_WISH_LIST, // 0x724
PAKCS_QUEST_DATA_REQ = 0x730,
PAKWC_QUEST_DATA_REPLY = PAKCS_QUEST_DATA_REQ,
PAKWC_NPC_EVENT,
PAKWC_GM_COMMAND_CODE = 0x751, // This is for updating client side varibles
PAKCS_CHANGE_MAP_REQ = 0x753,
PAKWC_CHANGE_MAP_REPLY = PAKCS_CHANGE_MAP_REQ,
PAKWC_INIT_DATA,
PAKCS_REVIVE_REQ,
PAKWC_REVIVE_REPLY = PAKCS_REVIVE_REQ,
PAKWC_SET_REVIVE_POS_REPLY,
PAKCS_SET_SERVER_VAR_REQ, // 0x757
PAKWC_SET_SERVER_VAR_REPLY = PAKCS_SET_SERVER_VAR_REQ,
PAKCS_CHAR_INFO_REQ,
PAKWC_CHAR_INFO_REPLY = PAKCS_CHAR_INFO_REQ,
PAKCS_SET_WEIGHT_REQ,
PAKWC_SET_WEIGHT_REPLY = PAKCS_SET_WEIGHT_REQ,
PAKWC_ADJUST_POSITION = 0x770,
PAKCS_STOP_MOVING = 0x771, // because it can't anymore
PAKWC_STOP_MOVING = PAKCS_STOP_MOVING, // This needs to be Impl in the client, client should stop because it can't move anymore
PAKCS_UPDATE_NPC = 0x774,
PAKCS_SUMMON_CMD,
PAKWC_SUMMON_CMD = PAKCS_SUMMON_CMD,
PAKCS_SET_ANIMATION = 0x781,
PACWC_SET_ANIMATION = PAKCS_SET_ANIMATION,
PAKCS_TOGGLE,
PAKWC_TOGGLE = PAKCS_TOGGLE,
PAKCS_NORMAL_CHAT,
PAKWC_NORMAL_CHAT = PAKCS_NORMAL_CHAT,
PAKCS_WHISPER_CHAT,
PAKWC_WHISPER_CHAT = PAKCS_WHISPER_CHAT,
PAKCS_SHOUT_CHAT,
PAKWC_SHOUT_CHAT = PAKCS_SHOUT_CHAT,
PAKCS_PARTY_CHAT,
PAKWC_PARTY_CHAT = PAKCS_PARTY_CHAT,
PAKCS_CLAN_CHAT,
PAKWC_CLAN_CHAT = PAKCS_CLAN_CHAT,
PAKCS_ALLIED_CHAT,
PAKWC_ALLIED_CHAT = PAKCS_ALLIED_CHAT,
PAKCS_ALLIED_SHOUT_CHAT,
PAKWC_ALLIED_SHOUT_CHAT = PAKCS_ALLIED_SHOUT_CHAT,
PAKWC_EVENT_STATUS = 0x790,
PAKWC_NPC_CHAR,
PAKWC_MOB_CHAR,
PAKWC_PLAYER_CHAR,
PAKWC_REMOVE_OBJECT,
PAKCS_SET_POSITION,
PAKCS_STOP, // client wants to stop
PAKWC_STOP = PAKCS_STOP, // object stops at position x
PAKWC_MOVE, // mouse cmd with move mode in it??
PAKCS_ATTACK,
PAKWC_ATTACK = PAKCS_ATTACK,
PAKCS_DAMAGE,
PAKWC_DAMAGE = PAKCS_DAMAGE,
PAKCS_MOUSE_CMD = 0x79A, // client wants to move or click on an object
PAKWC_MOUSE_CMD = PAKCS_MOUSE_CMD, // answer from the server
PAKWC_SETEXP,
PAKWC_LEVELUP = 0x79E,
PAKCS_HP_REQ = 0x79F,
PAKWC_HP_REPLY = PAKCS_HP_REQ,
PAKWC_SET_HP_AND_MP,
PAKCS_STORE_TRADE_REQ,
PAKWC_STORE_TRADE_REPLY = PAKCS_STORE_TRADE_REQ,
PAKCS_USE_ITEM = 0x07a3,
PAKWC_USE_ITEM_REPLY = PAKCS_USE_ITEM,
PAKCS_DROP_ITEM = 0x7A4,
PAKCS_EQUIP_ITEM = 0x7A5,
PAKWC_EQUIP_ITEM = PAKCS_EQUIP_ITEM,
PAKWC_DROP_ITEM = 0x07a6,
PAKCS_FIELDITEM_REQ = 0x07a7,
PAKWC_FIELDITEM_REPLY = PAKCS_FIELDITEM_REQ,
PAKCS_TELEPORT_REQ = 0x07a8,
PAKWC_TELEPORT_REPLY = PAKCS_TELEPORT_REQ,
PAKCS_SET_HOTBAR_ICON_REQ = 0x07aa,
PAKWC_SET_HOTBAR_ICON_REPLY = PAKCS_SET_HOTBAR_ICON_REQ,
PAKCS_STORAGE_LIST_REQ = 0x07ad,
PAKWC_STORAGE_LIST_REPLY = PAKCS_STORAGE_LIST_REQ,
PAKCS_MOVE_ITEM_REQ = 0x07ae,
PAKWC_MOVE_ITEM_REPLY = PAKCS_MOVE_ITEM_REQ,
PAKWC_LEARN_SKILL = 0x07b0,
PAKCS_LEVEL_SKILL_REQ = 0x07b1,
PAKWC_LEVEL_SKILL_REPLY = PAKCS_LEVEL_SKILL_REQ,
//TODO: 0x07b2 -> 0x07bd all skill related
//TODO: 0x07c0 -> 0x07c7 all trading and private store related
PAKCS_PARTY_REQ = 0x7d0,
PAKWC_PARTY_REQ = PAKCS_PARTY_REQ,
PAKCS_PARTY_REPLY,
PAKWC_PARTY_REPLY = PAKCS_PARTY_REPLY,
PAKWC_PARTY_MEMBER,
PAKWC_PARTY_ITEM,
PAKWC_PARTY_LVLXP,
PAKCS_PARTY_RULE = 0x7d7,
PAKWC_PARTY_RULE = PAKCS_PARTY_RULE,
PAKWC_BILLING_MESSAGE = 0x7de,
PAKCS_SCREEN_SHOT_TIME_REQ = 0x7eb,
PAKSC_SCREEN_SHOT_TIME_REPLY = PAKCS_SCREEN_SHOT_TIME_REQ,
PAKSS_ACCEPT_REPLY = 0x7ff,
EPACKETMAX,
STRESS = 0x6F6D
};
inline bool operator!(const ePacketType& rhs) {
return static_cast<int16_t>(rhs) == 0;
}
inline bool operator!=(const uint32_t& lhs, const ePacketType& rhs) {
return (lhs != static_cast<uint32_t>(rhs));
}
template <typename E>
constexpr auto to_underlying(E e) noexcept {
return static_cast<typename std::underlying_type_t<E>>(e);
}
struct EPacketTypeHash {
template <typename T>
std::size_t operator()(T t) const noexcept {
return to_underlying(t);
}
};
//TODO: put it in its correct place
struct tChannelInfo {
uint16_t ChannelID;
uint16_t Port;
uint32_t MinRight;
std::string channelName;
std::string IPAddress;
tChannelInfo()
: ChannelID(0), Port(0), MinRight(0), channelName(""), IPAddress("") {}
};
}
#endif /* EPACKETTYPE_H_ */
| 26.312727 | 129 | 0.764787 | [
"object"
] |
ffe4045a8c9eae9989851cf640ed2b2ed1cadb04 | 9,838 | c | C | model1_client.c | irjudson/heatworks-model1 | a5344c9e00778202288f22efca281917987c5dbf | [
"MIT"
] | null | null | null | model1_client.c | irjudson/heatworks-model1 | a5344c9e00778202288f22efca281917987c5dbf | [
"MIT"
] | null | null | null | model1_client.c | irjudson/heatworks-model1 | a5344c9e00778202288f22efca281917987c5dbf | [
"MIT"
] | null | null | null | /******************************************************************************
* Copyright (c) 2015, Ivan R. Judson. All rights reserved.
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
******************************************************************************/
#define AJ_MODULE MODEL1_CLIENT
#include <stdio.h>
#include <stdlib.h>
#include <aj_debug.h>
#include <alljoyn.h>
#include "model1.h"
uint8_t dbgMODEL1_CLIENT = 0;
/*
* The value of the arguments are the indices of the
* object path in AppObjects (above), interface in sampleInterfaces (above), and
* member indices in the interface.
* The first index is 1 because the first entry in sampleInterface is the interface name.
* This makes the first index (index 0 of the methods) the second string in
* sampleInterface[].
*
* See also aj_introspect.h
*/
#define BASIC_CLIENT_SETPOINT AJ_PRX_MESSAGE_ID(0, 0, 0)
#define BASIC_CLIENT_CURRENT_TEMP AJ_PRX_MESSAGE_ID(0, 0, 1)
#define BASIC_CLIENT_SOFT_CURRENT_LIMIT AJ_PRX_MESSAGE_ID(0, 0, 2)
#define BASIC_CLIENT_CURRENT_DRAW_INSTANT AJ_PRX_MESSAGE_ID(0, 0, 3)
#define BASIC_CLIENT_TIME_ODOMETER AJ_PRX_MESSAGE_ID(0, 0, 4)
#define BASIC_CLIENT_CURRENT_ODOMETER AJ_PRX_MESSAGE_ID(0, 0, 5)
void SetPoint(AJ_BusAttachment *bus, uint32_t sessionId, uint8_t setPoint)
{
AJ_Status status = AJ_OK;
AJ_Message msg;
status = AJ_MarshalMethodCall(bus, &msg, BASIC_CLIENT_SETPOINT, fullServiceName, sessionId, 0, METHOD_TIMEOUT);
if (status == AJ_OK) {
status = AJ_MarshalArgs(&msg, "y", setPoint);
}
if (status == AJ_OK) {
status = AJ_DeliverMsg(&msg);
}
AJ_InfoPrintf(("SetSetPoint() resulted in a status of 0x%04x.\n", status));
}
void GetCurrentTemp(AJ_BusAttachment *bus, uint32_t sessionId)
{
AJ_Status status = AJ_OK;
AJ_Message msg;
status = AJ_MarshalMethodCall(bus, &msg, BASIC_CLIENT_CURRENT_TEMP, fullServiceName, sessionId, 0, METHOD_TIMEOUT);
if (status == AJ_OK) {
status = AJ_DeliverMsg(&msg);
}
AJ_InfoPrintf(("GetCurrentTemp() resulted in a status of 0x%04x.\n", status));
}
void SetSoftCurrentLimit(AJ_BusAttachment *bus, uint32_t sessionId, uint8_t currentLimit)
{
AJ_Status status = AJ_OK;
AJ_Message msg;
status = AJ_MarshalMethodCall(bus, &msg, BASIC_CLIENT_SOFT_CURRENT_LIMIT, fullServiceName, sessionId, 0, METHOD_TIMEOUT);
if (status == AJ_OK) {
status = AJ_MarshalArgs(&msg, "y", currentLimit);
}
if (status == AJ_OK) {
status = AJ_DeliverMsg(&msg);
}
AJ_InfoPrintf(("SetSoftCurrentLimit() resulted in a status of 0x%04x.\n", status));
}
void GetCurrentDraw(AJ_BusAttachment *bus, uint32_t sessionId)
{
AJ_Status status = AJ_OK;
AJ_Message msg;
status = AJ_MarshalMethodCall(bus, &msg, BASIC_CLIENT_CURRENT_DRAW_INSTANT, fullServiceName, sessionId, 0, METHOD_TIMEOUT);
if (status == AJ_OK) {
status = AJ_DeliverMsg(&msg);
}
AJ_InfoPrintf(("GetCurrentDraw() resulted in a status of 0x%04x.\n", status));
}
void GetTimeOdometer(AJ_BusAttachment *bus, uint32_t sessionId)
{
AJ_Status status = AJ_OK;
AJ_Message msg;
status = AJ_MarshalMethodCall(bus, &msg, BASIC_CLIENT_TIME_ODOMETER, fullServiceName, sessionId, 0, METHOD_TIMEOUT);
if (status == AJ_OK) {
status = AJ_DeliverMsg(&msg);
}
AJ_InfoPrintf(("GetTimeOdometer() resulted in a status of 0x%04x.\n", status));
}
void GetCurrentOdometer(AJ_BusAttachment *bus, uint32_t sessionId)
{
AJ_Status status = AJ_OK;
AJ_Message msg;
status = AJ_MarshalMethodCall(bus, &msg, BASIC_CLIENT_CURRENT_ODOMETER, fullServiceName, sessionId, 0, METHOD_TIMEOUT);
if (status == AJ_OK) {
status = AJ_DeliverMsg(&msg);
}
AJ_InfoPrintf(("GetCurrentOdometer() resulted in a status of 0x%04x.\n", status));
}
int main(int argc, char **argv)
{
AJ_Status status = AJ_OK;
AJ_BusAttachment bus;
uint8_t connected = FALSE;
uint8_t done = FALSE;
uint32_t sessionId = 0;
/*
* One time initialization before calling any other AllJoyn APIs
*/
AJ_Initialize();
AJ_PrintXML(AppObjects);
AJ_RegisterObjects(NULL, AppObjects);
while (!done) {
AJ_Message msg;
if (!connected) {
status = AJ_StartClientByName(&bus,
NULL,
CONNECT_TIMEOUT,
FALSE,
ServiceName,
ServicePort,
&sessionId,
NULL,
fullServiceName);
if (status == AJ_OK) {
AJ_InfoPrintf(("StartClient returned %d, sessionId=%u.\n", status, sessionId));
connected = TRUE;
SetPoint(&bus, sessionId, 50);
GetCurrentTemp(&bus, sessionId);
SetSoftCurrentLimit(&bus, sessionId, 48);
GetCurrentDraw(&bus, sessionId);
GetTimeOdometer(&bus, sessionId);
GetCurrentOdometer(&bus, sessionId);
} else {
AJ_InfoPrintf(("StartClient returned 0x%04x.\n", status));
break;
}
}
status = AJ_UnmarshalMsg(&bus, &msg, UNMARSHAL_TIMEOUT);
if (AJ_ERR_TIMEOUT == status) {
continue;
}
if (AJ_OK == status) {
switch (msg.msgId) {
case AJ_REPLY_ID(BASIC_CLIENT_CURRENT_TEMP):
{
AJ_Arg arg;
status = AJ_UnmarshalArg(&msg, &arg);
if (AJ_OK == status) {
AJ_AlwaysPrintf(("'%s.%s' (path='%s') returned '%d'.\n", fullServiceName, "currentTemp",
ServicePath, (int)*(arg.val.v_byte)));
} else {
AJ_InfoPrintf(("AJ_UnmarshalArg() returned status %d.\n", status));
GetCurrentTemp(&bus, sessionId);
}
}
break;
case AJ_REPLY_ID(BASIC_CLIENT_CURRENT_DRAW_INSTANT):
{
AJ_Arg arg;
status = AJ_UnmarshalArg(&msg, &arg);
if (AJ_OK == status) {
AJ_AlwaysPrintf(("'%s.%s' (path='%s') returned '%d'.\n", fullServiceName, "currentDrawInstant",
ServicePath, (int)*(arg.val.v_byte)));
} else {
AJ_InfoPrintf(("AJ_UnmarshalArg() returned status %d.\n", status));
GetCurrentTemp(&bus, sessionId);
}
}
break;
case AJ_REPLY_ID(BASIC_CLIENT_TIME_ODOMETER):
{
AJ_Arg arg;
status = AJ_UnmarshalArg(&msg, &arg);
if (AJ_OK == status) {
AJ_AlwaysPrintf(("'%s.%s' (path='%s') returned '%d'.\n", fullServiceName, "timeOdometerValue",
ServicePath, (int)*(arg.val.v_int32)));
} else {
AJ_InfoPrintf(("AJ_UnmarshalArg() returned status %d.\n", status));
GetCurrentTemp(&bus, sessionId);
}
}
break;
case AJ_REPLY_ID(BASIC_CLIENT_CURRENT_ODOMETER):
{
AJ_Arg arg;
status = AJ_UnmarshalArg(&msg, &arg);
if (AJ_OK == status) {
AJ_AlwaysPrintf(("'%s.%s' (path='%s') returned '%d'.\n", fullServiceName, "currentOdometerValue",
ServicePath, (int)*(arg.val.v_int32)));
} else {
AJ_InfoPrintf(("AJ_UnmarshalArg() returned status %d.\n", status));
GetCurrentTemp(&bus, sessionId);
}
}
break;
case AJ_SIGNAL_SESSION_LOST_WITH_REASON:
/* A session was lost so return error to force a disconnect. */
{
uint32_t id, reason;
AJ_UnmarshalArgs(&msg, "uu", &id, &reason);
AJ_AlwaysPrintf(("Session lost. ID = %u, reason = %u", id, reason));
}
status = AJ_ERR_SESSION_LOST;
break;
default:
/* Pass to the built-in handlers. */
status = AJ_BusHandleBusMessage(&msg);
break;
}
}
/* Messages MUST be discarded to free resources. */
AJ_CloseMsg(&msg);
if (status == AJ_ERR_SESSION_LOST) {
AJ_AlwaysPrintf(("AllJoyn disconnect.\n"));
AJ_Disconnect(&bus);
exit(0);
}
}
AJ_AlwaysPrintf(("Basic client exiting with status %d.\n", status));
return status;
}
| 39.195219 | 127 | 0.555702 | [
"object"
] |
ffee236bc523fa80e1384c03227dcd945bf3c36a | 3,154 | h | C | osal/linux/PeriodicPosixTask.h | bl4ckic3/fsfw | c76fc8c703e19d917c45a25710b4642e5923c68a | [
"Apache-2.0"
] | null | null | null | osal/linux/PeriodicPosixTask.h | bl4ckic3/fsfw | c76fc8c703e19d917c45a25710b4642e5923c68a | [
"Apache-2.0"
] | null | null | null | osal/linux/PeriodicPosixTask.h | bl4ckic3/fsfw | c76fc8c703e19d917c45a25710b4642e5923c68a | [
"Apache-2.0"
] | null | null | null | #ifndef FRAMEWORK_OSAL_LINUX_PERIODICPOSIXTASK_H_
#define FRAMEWORK_OSAL_LINUX_PERIODICPOSIXTASK_H_
#include "../../tasks/PeriodicTaskIF.h"
#include "../../objectmanager/ObjectManagerIF.h"
#include "PosixThread.h"
#include "../../tasks/ExecutableObjectIF.h"
#include <vector>
class PeriodicPosixTask: public PosixThread, public PeriodicTaskIF {
public:
/**
* Create a generic periodic task.
* @param name_
* Name, maximum allowed size of linux is 16 chars, everything else will
* be truncated.
* @param priority_
* Real-time priority, ranges from 1 to 99 for Linux.
* See: https://man7.org/linux/man-pages/man7/sched.7.html
* @param stackSize_
* @param period_
* @param deadlineMissedFunc_
*/
PeriodicPosixTask(const char* name_, int priority_, size_t stackSize_,
uint32_t period_, void(*deadlineMissedFunc_)());
virtual ~PeriodicPosixTask();
/**
* @brief The method to start the task.
* @details The method starts the task with the respective system call.
* Entry point is the taskEntryPoint method described below.
* The address of the task object is passed as an argument
* to the system call.
*/
ReturnValue_t startTask() override;
/**
* Adds an object to the list of objects to be executed.
* The objects are executed in the order added.
* @param object Id of the object to add.
* @return RETURN_OK on success, RETURN_FAILED if the object could not be added.
*/
ReturnValue_t addComponent(object_id_t object) override;
uint32_t getPeriodMs() const override;
ReturnValue_t sleepFor(uint32_t ms) override;
private:
typedef std::vector<ExecutableObjectIF*> ObjectList; //!< Typedef for the List of objects.
/**
* @brief This attribute holds a list of objects to be executed.
*/
ObjectList objectList;
/**
* @brief Flag to indicate that the task was started and is allowed to run
*/
bool started;
/**
* @brief Period of the task in milliseconds
*/
uint32_t periodMs;
/**
* @brief The function containing the actual functionality of the task.
* @details The method sets and starts
* the task's period, then enters a loop that is repeated indefinitely. Within the loop, all performOperation methods of the added
* objects are called. Afterwards the task will be blocked until the next period.
* On missing the deadline, the deadlineMissedFunction is executed.
*/
virtual void taskFunctionality(void);
/**
* @brief This is the entry point in a new thread.
*
* @details This method, that is the entry point in the new thread and calls taskFunctionality of the child class.
* Needs a valid pointer to the derived class.
*/
static void* taskEntryPoint(void* arg);
/**
* @brief The pointer to the deadline-missed function.
* @details This pointer stores the function that is executed if the task's deadline is missed.
* So, each may react individually on a timing failure. The pointer may be NULL,
* then nothing happens on missing the deadline. The deadline is equal to the next execution
* of the periodic task.
*/
void (*deadlineMissedFunc)();
};
#endif /* FRAMEWORK_OSAL_LINUX_PERIODICPOSIXTASK_H_ */
| 34.659341 | 134 | 0.730184 | [
"object",
"vector"
] |
2b303a6a7a43fecafc4ebd4d046656c7c7a98aa8 | 15,736 | h | C | modules/v8/dmzJsModuleRuntimeV8Basic.h | ben-sangster/js | d99c1163f73f6571cd5a0398227696339863920d | [
"MIT"
] | 1 | 2019-03-15T12:35:13.000Z | 2019-03-15T12:35:13.000Z | modules/v8/dmzJsModuleRuntimeV8Basic.h | ben-sangster/js | d99c1163f73f6571cd5a0398227696339863920d | [
"MIT"
] | null | null | null | modules/v8/dmzJsModuleRuntimeV8Basic.h | ben-sangster/js | d99c1163f73f6571cd5a0398227696339863920d | [
"MIT"
] | null | null | null | #ifndef DMZ_JS_MODULE_RUNTIME_V8_BASIC_DOT_H
#define DMZ_JS_MODULE_RUNTIME_V8_BASIC_DOT_H
#include <dmzJsExtV8.h>
#include <dmzJsModuleRuntimeV8.h>
#include <dmzJsV8UtilConvert.h>
#include <dmzJsV8UtilHelpers.h>
#include <dmzJsV8UtilTypes.h>
#include <dmzRuntimeData.h>
#include <dmzRuntimeDataConverterTypesBase.h>
#include <dmzRuntimeDefinitions.h>
#include <dmzRuntimeLog.h>
#include <dmzRuntimeMessaging.h>
#include <dmzRuntimeObjectType.h>
#include <dmzRuntimePlugin.h>
#include <dmzRuntimeTime.h>
#include <dmzRuntimeUndo.h>
#include <dmzTypesHashTableHandleTemplate.h>
#include <dmzTypesSphere.h>
#include <v8.h>
namespace dmz {
class JsModuleTypesV8;
class JsModuleRuntimeV8Basic :
public Plugin,
public JsModuleRuntimeV8,
public JsExtV8,
public UndoObserver {
public:
static JsModuleRuntimeV8Basic *to_self (const v8::Arguments &Args);
JsModuleRuntimeV8Basic (const PluginInfo &Info, Config &local);
~JsModuleRuntimeV8Basic ();
// Plugin Interface
virtual void update_plugin_state (
const PluginStateEnum State,
const UInt32 Level);
virtual void discover_plugin (
const PluginDiscoverEnum Mode,
const Plugin *PluginPtr);
// JsModuleRuntimeV8 Interface
virtual v8::Handle<v8::Value> create_v8_config (const Config *Value);
virtual Boolean to_dmz_config (v8::Handle<v8::Value> value, Config &out);
virtual v8::Handle<v8::Value> create_v8_data (const Data *Value);
virtual Boolean to_dmz_data (v8::Handle<v8::Value> value, Data &out);
virtual v8::Handle<v8::Value> create_v8_event_type (const EventType *Value);
virtual Boolean to_dmz_event_type (v8::Handle<v8::Value> value, EventType &out);
virtual v8::Handle<v8::Value> create_v8_log (const String &Name);
virtual Log *to_dmz_log (v8::Handle<v8::Value> value);
virtual v8::Handle<v8::Value> create_v8_message (const String &Name);
virtual v8::Handle<v8::Value> create_v8_object_type (const ObjectType *Value);
virtual Boolean to_dmz_object_type (
v8::Handle<v8::Value> value,
ObjectType &out);
virtual v8::Handle<v8::Value> create_v8_sphere (const Sphere *Value);
virtual Sphere *to_dmz_sphere (v8::Handle<v8::Value> value);
// JsExtV8 Interface
virtual void update_js_module_v8 (const ModeEnum Mode, JsModuleV8 &module);
virtual void update_js_context_v8 (v8::Handle<v8::Context> context);
virtual void update_js_ext_v8_state (const StateEnum State);
virtual void release_js_instance_v8 (
const Handle InstanceHandle,
const String &InstanceName,
v8::Handle<v8::Object> &instance);
// UndoObserver Interface (implemented in dmzJsModuleRuntimeV8BasicUndo.cpp)
virtual void update_recording_state (
const UndoRecordingStateEnum RecordingState,
const UndoRecordingTypeEnum RecordingType,
const UndoTypeEnum UndoType);
virtual void update_current_undo_names (
const String *NextUndoName,
const String *NextRedoName);
// JsModuleRuntimeV8Basic Interface
void handle_v8_exception (const Handle Source, v8::TryCatch &tc);
// implemented in dmzJsModuleRuntimeV8BasicTimer.cpp
Boolean delete_timer (V8Object self, V8Function callback);
Boolean delete_all_timers (V8Object self);
protected:
struct MessageStruct;
struct TimerStruct;
struct UndoStruct;
// Static Functions
// Config bindings implemented in dmzJsModuleRuntimeV8BasicConfig.cpp
static V8Value _create_config (const v8::Arguments &Args);
static V8Value _config_is_type_of (const v8::Arguments &Args);
static V8Value _config_to_string (const v8::Arguments &Args);
static V8Value _config_attribute (const v8::Arguments &Args);
static V8Value _config_add (const v8::Arguments &Args);
static V8Value _config_get (const v8::Arguments &Args);
static V8Value _config_boolean (const v8::Arguments &Args);
static V8Value _config_string (const v8::Arguments &Args);
static V8Value _config_number (const v8::Arguments &Args);
static V8Value _config_vector (const v8::Arguments &Args);
static V8Value _config_matrix (const v8::Arguments &Args);
static V8Value _config_object_type (const v8::Arguments &Args);
static V8Value _config_event_type (const v8::Arguments &Args);
static V8Value _config_message (const v8::Arguments &Args);
static V8Value _config_named_handle (const v8::Arguments &Args);
// Event Type bindings implemented in dmzJsModuleRuntimeV8BasicEventType.cpp
static V8Value _event_type_lookup (const v8::Arguments &Args);
static V8Value _event_type_is_type_of (const v8::Arguments &Args);
static V8Value _event_type_to_string (const v8::Arguments &Args);
static V8Value _event_type_get_name (const v8::Arguments &Args);
static V8Value _event_type_get_handle (const v8::Arguments &Args);
static V8Value _event_type_get_parent (const v8::Arguments &Args);
static V8Value _event_type_get_children (const v8::Arguments &Args);
static V8Value _event_type_is_of_type (const v8::Arguments &Args);
static V8Value _event_type_is_of_exact_type (const v8::Arguments &Args);
static V8Value _event_type_get_config (const v8::Arguments &Args);
static V8Value _event_type_find_config (const v8::Arguments &Args);
// Data bindings implemented in dmzJsModuleRuntimeV8BasicData.cpp
static V8Value _create_data (const v8::Arguments &Args);
static V8Value _data_is_type_of (const v8::Arguments &Args);
static V8Value _data_wrap_boolean (const v8::Arguments &Args);
static V8Value _data_unwrap_boolean (const v8::Arguments &Args);
static V8Value _data_wrap_number (const v8::Arguments &Args);
static V8Value _data_unwrap_number (const v8::Arguments &Args);
static V8Value _data_wrap_string (const v8::Arguments &Args);
static V8Value _data_unwrap_string (const v8::Arguments &Args);
static V8Value _data_wrap_handle (const v8::Arguments &Args);
static V8Value _data_unwrap_handle (const v8::Arguments &Args);
static V8Value _data_to_string (const v8::Arguments &Args);
static V8Value _data_boolean (const v8::Arguments &Args);
static V8Value _data_number (const v8::Arguments &Args);
static V8Value _data_handle (const v8::Arguments &Args);
static V8Value _data_string (const v8::Arguments &Args);
static V8Value _data_matrix (const v8::Arguments &Args);
static V8Value _data_vector (const v8::Arguments &Args);
// Data bindings implemented in dmzJsModuleRuntimeV8BasicLog.cpp
static V8Value _create_log (const v8::Arguments &Args);
// Definitions bindings implemented in dmzJsModuleRuntimeV8BasicDefinitions.cpp
static V8Value _create_named_handle (const v8::Arguments &Args);
static V8Value _lookup_named_handle (const v8::Arguments &Args);
static V8Value _lookup_named_handle_name (const v8::Arguments &Args);
static V8Value _lookup_state (const v8::Arguments &Args);
static V8Value _lookup_state_name (const v8::Arguments &Args);
// Messaging bindings implemented in dmzJsModuleRuntimeV8BasicMessaging.cpp
static V8Value _create_message (const v8::Arguments &Args);
static V8Value _message_is_type_of (const v8::Arguments &Args);
static V8Value _message_global_subscribe (const v8::Arguments &Args);
static V8Value _message_global_unsubscribe (const v8::Arguments &Args);
static V8Value _message_to_string (const v8::Arguments &Args);
static V8Value _message_send (const v8::Arguments &Args);
static V8Value _message_subscribe (const v8::Arguments &Args);
static V8Value _message_unsubscribe (const v8::Arguments &Args);
// Object Type bindings implemented in dmzJsModuleRuntimeV8BasicObjectType.cpp
static V8Value _object_type_lookup (const v8::Arguments &Args);
static V8Value _object_type_is_type_of (const v8::Arguments &Args);
static V8Value _object_type_to_string (const v8::Arguments &Args);
static V8Value _object_type_get_name (const v8::Arguments &Args);
static V8Value _object_type_get_handle (const v8::Arguments &Args);
static V8Value _object_type_get_parent (const v8::Arguments &Args);
static V8Value _object_type_get_children (const v8::Arguments &Args);
static V8Value _object_type_is_of_type (const v8::Arguments &Args);
static V8Value _object_type_is_of_exact_type (const v8::Arguments &Args);
static V8Value _object_type_get_config (const v8::Arguments &Args);
static V8Value _object_type_find_config (const v8::Arguments &Args);
// Timer bindings implemented in dmzJsModuleRuntimeV8BasicTimer.cpp
static V8Value _set_timer (const v8::Arguments &Args);
static V8Value _set_repeating_timer (const v8::Arguments &Args);
static V8Value _set_base_timer (
const v8::Arguments &Args,
const Boolean Repeating);
static V8Value _cancel_timer (const v8::Arguments &Args);
static V8Value _cancel_all_timers (const v8::Arguments &Args);
static V8Value _get_frame_delta (const v8::Arguments &Args);
static V8Value _get_frame_time (const v8::Arguments &Args);
static V8Value _set_frame_time (const v8::Arguments &Args);
static V8Value _get_time_factor (const v8::Arguments &Args);
static V8Value _set_time_factor (const v8::Arguments &Args);
static V8Value _get_system_time (const v8::Arguments &Args);
// Sphere binding implemened in dJsModuleRuntimeV8BasicSphere.cpp
static V8Value _sphere_create (const v8::Arguments &Args);
static V8Value _sphere_origin (const v8::Arguments &Args);
static V8Value _sphere_radius (const v8::Arguments &Args);
static V8Value _sphere_contains_point (const v8::Arguments &Args);
// Undo bindings implemented in dmzJsModuleRuntimeV8BasicUndo.cpp
static V8Value _undo_reset (const v8::Arguments &Args);
static V8Value _undo_is_nested_handle (const v8::Arguments &Args);
static V8Value _undo_is_in_undo (const v8::Arguments &Args);
static V8Value _undo_is_recording (const v8::Arguments &Args);
static V8Value _undo_get_type (const v8::Arguments &Args);
static V8Value _undo_do_next (const v8::Arguments &Args);
static V8Value _undo_start_record (const v8::Arguments &Args);
static V8Value _undo_stop_record (const v8::Arguments &Args);
static V8Value _undo_abort_record (const v8::Arguments &Args);
static V8Value _undo_store_action (const v8::Arguments &Args);
static V8Value _undo_observe (const v8::Arguments &Args);
static V8Value _undo_release (const v8::Arguments &Args);
// JsModuleRuntimeV8Basic Interface
Handle _to_handle (V8Value value);
// implemented in dmzJsModuleRuntimeV8BasicData.cpp
void _init_config ();
V8Object _to_config (V8Value value);
Config *_to_config_ptr (V8Value value);
void _add_to_config (
const String &Name,
const Boolean InArray,
V8Value value,
Config &parent);
// implemented in dmzJsModuleRuntimeV8BasicData.cpp
void _init_data ();
V8Object _to_data (V8Value value);
Data *_to_data_ptr (V8Value value);
// implemented in dmzJsModuleRuntimeV8BasicDefinitions.cpp
void _init_definitions ();
// implemented in dmzJsModuleRuntimeV8BasicEventType.cpp
void _init_event_type ();
V8Object _to_event_type (V8Value value);
EventType *_to_event_type_ptr (V8Value value);
// implemented in dmzJsModuleRuntimeV8BasicMessaging.cpp
void _init_messaging ();
void _reset_messaging ();
void _release_message_observer (const Handle InstanceHandle);
Message * _to_message_ptr (V8Value value);
// implemented in dmzJsModuleRuntimeV8BasicLog.cpp
void _init_log ();
// implemented in dmzJsModuleRuntimeV8BasicObjectType.cpp
void _init_object_type ();
V8Object _to_object_type (V8Value value);
ObjectType *_to_object_type_ptr (V8Value value);
// implemented n dmzJsModuleRuntimeV8BasicSphere.cpp
void _init_sphere ();
Sphere *_to_sphere_ptr (V8Value value);
// implemented in dmzJsModuleRuntimeV8BasicTimer.cpp
void _init_time ();
void _reset_time ();
void _release_timer (const Handle InstanceHandle);
// implemented in dmzJsModuleRuntimeV8BasicUndo.cpp
void _init_undo ();
void _reset_undo ();
void _release_undo_observer (const Handle InstanceHandle);
// implemented in dmzJsModuleRuntimeV8Basic.cpp
void _init (Config &local);
Log _log;
Time _time;
Definitions _defs;
Undo _undo;
DataConverterBoolean _convertBool;
DataConverterFloat64 _convertNum;
DataConverterString _convertStr;
DataConverterHandle _convertHandle;
JsModuleV8 *_core;
JsModuleTypesV8 *_types;
v8::Handle<v8::Context> _v8Context;
V8ValuePersist _self;
V8InterfaceHelper _configApi;
V8InterfaceHelper _dataApi;
V8InterfaceHelper _defsApi;
V8InterfaceHelper _eventTypeApi;
V8InterfaceHelper _logApi;
V8InterfaceHelper _msgApi;
V8InterfaceHelper _objTypeApi;
V8InterfaceHelper _sphereApi;
V8InterfaceHelper _timeApi;
V8InterfaceHelper _undoApi;
HashTableHandleTemplate<MessageStruct> _msgTable;
HashTableHandleTemplate<TimerStruct> _timerTable;
HashTableHandleTemplate<UndoStruct> _undoStateTable;
HashTableHandleTemplate<UndoStruct> _undoNamesTable;
v8::Persistent<v8::FunctionTemplate> _configFuncTemplate;
v8::Persistent<v8::Function> _configFunc;
v8::Persistent<v8::FunctionTemplate> _dataFuncTemplate;
v8::Persistent<v8::Function> _dataFunc;
v8::Persistent<v8::FunctionTemplate> _eventTypeFuncTemplate;
v8::Persistent<v8::Function> _eventTypeFunc;
v8::Persistent<v8::FunctionTemplate> _logFuncTemplate;
v8::Persistent<v8::Function> _logFunc;
v8::Persistent<v8::FunctionTemplate> _msgFuncTemplate;
v8::Persistent<v8::Function> _msgFunc;
v8::Persistent<v8::FunctionTemplate> _sphereTemplate;
v8::Persistent<v8::Function> _sphereFunc;
v8::Persistent<v8::FunctionTemplate> _objTypeFuncTemplate;
v8::Persistent<v8::Function> _objTypeFunc;
private:
JsModuleRuntimeV8Basic ();
JsModuleRuntimeV8Basic (const JsModuleRuntimeV8Basic &);
JsModuleRuntimeV8Basic &operator= (const JsModuleRuntimeV8Basic &);
};
};
inline dmz::JsModuleRuntimeV8Basic *
dmz::JsModuleRuntimeV8Basic::to_self (const v8::Arguments &Args) {
return (dmz::JsModuleRuntimeV8Basic *)v8::External::Unwrap (Args.Data ());
}
#endif // DMZ_JS_MODULE_RUNTIME_V8_BASIC_DOT_H
| 48.122324 | 89 | 0.694459 | [
"object"
] |
2b36970ee766bb09b230a87977be704859c596c3 | 800 | c | C | r8vec_copy.c | SourangshuGhosh/Alpert_Rule_C | 2e9da734b49c5781d087c7199f0b3d5d6ea9ad8c | [
"MIT"
] | 3 | 2020-07-23T15:07:31.000Z | 2020-09-14T17:39:26.000Z | r8vec_copy.c | SourangshuGhosh/Alpert_Rule_C | 2e9da734b49c5781d087c7199f0b3d5d6ea9ad8c | [
"MIT"
] | null | null | null | r8vec_copy.c | SourangshuGhosh/Alpert_Rule_C | 2e9da734b49c5781d087c7199f0b3d5d6ea9ad8c | [
"MIT"
] | null | null | null | # include <math.h>
# include <stdio.h>
# include <stdlib.h>
# include <time.h>
# include "alpert_rule.h"
/******************************************************************************/
void r8vec_copy ( int n, double a1[], double a2[] )
/******************************************************************************/
/*
Purpose:
R8VEC_COPY copies an R8VEC.
Discussion:
An R8VEC is a vector of R8's.
Licensing:
This code is distributed under the GNU LGPL license.
Modified:
03 July 2005
Author:
John Burkardt
Parameters:
Input, int N, the number of entries in the vectors.
Input, double A1[N], the vector to be copied.
Input, double A2[N], the copy of A1.
*/
{
int i;
for ( i = 0; i < n; i++ )
{
a2[i] = a1[i];
}
return;
}
| 15.686275 | 80 | 0.48 | [
"vector"
] |
2b3a29b27834eb4e06bf343d2eeb942c81c5cc62 | 9,464 | h | C | application/simulator_common/SimNetworkCommon.h | jojochuang/eventwave | 6cb3a8569f12a9127bf326be3231123428cd754d | [
"BSD-3-Clause"
] | null | null | null | application/simulator_common/SimNetworkCommon.h | jojochuang/eventwave | 6cb3a8569f12a9127bf326be3231123428cd754d | [
"BSD-3-Clause"
] | null | null | null | application/simulator_common/SimNetworkCommon.h | jojochuang/eventwave | 6cb3a8569f12a9127bf326be3231123428cd754d | [
"BSD-3-Clause"
] | null | null | null | /*
* SimNetworkCommon.h : part of the Mace toolkit for building distributed systems
*
* Copyright (c) 2011, Charles Killian, James W. Anderson
* 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 names of the contributors, nor their associated universities
* or organizations 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.
*
* ----END-OF-LEGAL-STUFF---- */
#ifndef SIM_NET_COMMON_H
#define SIM_NET_COMMON_H
#include "Iterator.h"
#include "MaceTypes.h"
#include "ReceiveDataHandler.h"
#include "SimCommon.h"
#include "SimulatorTransport.h"
#include "Util.h"
#include "m_map.h"
#include "mace-macros.h"
#include "mset.h"
#include "mvector.h"
typedef mace::vector<SimulatorTransport*, mace::SoftState> NodeRecipientMap;
typedef mace::vector<NodeRecipientMap, mace::SoftState> PortNodeRecipientMap;
typedef mace::set<int> ErrorSet;
typedef mace::map<int, ErrorSet> ErrorMap;
class SimNetworkCommon : public SimCommon {
protected:
PortNodeRecipientMap simulatorTransportMap;
uint32_t currentMessageId;
int base_port;
static int failureCount;
const int MESSAGE_WEIGHT;
SimNetworkCommon()
: SimCommon(),
simulatorTransportMap(1, NodeRecipientMap(SimCommon::getNumNodes())),
currentMessageId(0), // XXX 1 in MC, 0 in PC
base_port(params::get("MACE_PORT", 5377)),
MESSAGE_WEIGHT(params::get("MESSAGE_WEIGHT", 8))
{ }
public:
uint32_t getMessageId() {
return currentMessageId++;
}
uint32_t hashState() const {
uint32_t hash = 0;
int port;
int node;
PortNodeRecipientMap::const_iterator i;
NodeRecipientMap::const_iterator j;
for(i = simulatorTransportMap.begin(), port = base_port; i != simulatorTransportMap.end(); i++, port++) {
for(j = i->begin(), node = 0; j != i->end(); j++, node++) {
hash += port ^ node ^ (*j)->hashState();
}
}
return hash;
}
void printInternal(std::ostream& out, bool printState = false) const {
int port;
int node;
PortNodeRecipientMap::const_iterator i;
NodeRecipientMap::const_iterator j;
for(i = simulatorTransportMap.begin(), port = base_port; i != simulatorTransportMap.end(); i++, port++) {
out << "[Port(" << port << ")]";
for(j = i->begin(), node = 0; j != i->end(); j++, node++) {
out << "[Node(" << node << ")]";
(*j)->printNetwork(out, printState);
out << "[/Node(" << node << ")]";
}
out << "[/Port(" << port << ")]";
}
}
void print(std::ostream& out) const {
printInternal(out);
}
void printState(std::ostream& out) const {
printInternal(out, true);
}
void registerHandler(int port, SimulatorTransport& trans) {
ADD_FUNC_SELECTORS;
maceout << "registering handler for node " << SimCommon::getCurrentMaceKey()
<< " on port " << port << " for node " << getCurrentNode()
<< " with transport " << &trans << Log::endl;
unsigned p2 = port;
p2 -= (base_port-1);
while(p2 > simulatorTransportMap.size()) { simulatorTransportMap.push_back(NodeRecipientMap(SimCommon::getNumNodes())); }
SimulatorTransport*& t = simulatorTransportMap[port-base_port][SimCommon::getCurrentNode()];
ASSERTMSG(t == NULL, "Two transports for a single node must use a different port in the model checker.");
t = &trans;
// simulatorTransportMap[port-base_port][SimCommon::getCurrentNode()] = &trans;
}
SimulatorTransport* getTransport(int node, int port) {
return simulatorTransportMap[port-base_port][node];
}
bool isListening(int node, int port) const {
return simulatorTransportMap[port-base_port][node] != NULL && simulatorTransportMap[port-base_port][node]->isListening();
}
void reset() {
for(PortNodeRecipientMap::iterator i = simulatorTransportMap.begin(); i != simulatorTransportMap.end(); i++) {
for(NodeRecipientMap::iterator j = i->begin(); j != i->end(); j++) {
// delete *j;
*j = NULL;
}
}
currentMessageId = 0;
failureCount = 0;
}
enum NetEventType { MESSAGE, DEST_NOT_READY, CTS, FLUSHED };
void signal(int source, int dest, int port, SimulatorTransport::TransportSignal sig) {
simulatorTransportMap[port-base_port][dest]->signal(source, sig);
}
/// Queue a DEST_NOT_READY when the receiver is not yet listening
virtual void queueDestNotReadyEvent(int destNode, int srcNode, int srcPort) = 0;
bool hasEventsWaiting() const {
// Check the event queue for any NETWORK event
const EventList& eventList = SimEvent::getEvents();
for (EventList::const_iterator ev = eventList.begin();
ev != eventList.end(); ++ev) {
if (ev->second.type == Event::NETWORK) {
return true;
}
}
return false;
}
std::string simulateEvent(const Event& e) {
ADD_SELECTORS("SimNetwork::simulateEvent");
const int net_event = e.simulatorVector[0];
const int src_node = e.simulatorVector[1];
const int src_port = e.simulatorVector[2];
maceout << "Simulating network event for " << e.node << " from " << src_node << " type " << net_event << " on port " << src_port << Log::endl;
SimulatorTransport* dest = getTransport(e.node, src_port);
std::ostringstream r;
switch(net_event) {
case SimNetworkCommon::MESSAGE:
{
if (!dest->isListening()) {
queueDestNotReadyEvent(e.node, src_node, src_port);
r << "Connection refused from " << src_node;
}
else {
SimulatorMessage msg = getTransport(src_node, src_port)->getMessage(e.node);
if(msg.messageType == SimulatorMessage::READ_ERROR) {
maceout << "Delivering socket error from " << msg.source << " to " << msg.destination
<< " messageId " << msg.messageId << Log::endl;
r << "error from " << msg.source << " on " << msg.destination << " id " << msg.messageId << " size " << msg.msg.size();
} else {
maceout << "Delivering messageId " << msg.messageId << " from "
<< msg.source << " to " << msg.destination << Log::endl;
r << "id " << msg.messageId << " from " << msg.source << " to " << msg.destination << " size " << msg.msg.size();
}
r << " " << dest->simulateEvent(msg);
}
break;
}
case SimNetworkCommon::DEST_NOT_READY: //XXX queue DEST_NOT_READY messages!!!
{
SimulatorMessage msg(src_node, e.node, getMessageId(), -1, -1, 0, 0,
SimulatorMessage::DEST_NOT_READY, -1, "");
maceout << "Event of " << msg.destination << " is a dest_not_ready error from node "
<< msg.source << Log::endl;
std::string s = dest->simulateEvent(msg);
r << s << " dest_not_ready error from " << msg.source << " on " << msg.destination;
break;
}
case SimNetworkCommon::CTS: {
maceout << "simulating CTS on " << e.node << " for " << src_node << Log::endl;
r << "CTS for " << src_node << " on " << e.node << " ";
r << dest->simulateCTS(src_node);
break;
}
case SimNetworkCommon::FLUSHED: {
maceout << "simulating flushed on " << src_node << Log::endl;
r << "notifying flushed on " << e.node << " ";
r << dest->simulateFlushed();
break;
}
default: ASSERT(net_event == SimNetworkCommon::MESSAGE || net_event == SimNetworkCommon::DEST_NOT_READY);
}
return r.str();
}
static int getFailureCount() {
return failureCount;
}
static void incrementFailureCount() {
failureCount++;
}
virtual ~SimNetworkCommon() { }
};
#endif // SIM_NET_COMMON_H
| 39.433333 | 148 | 0.613166 | [
"vector",
"model"
] |
2b3e028cb6c9a40bcc8afcd7dcbf39c50fd8bb58 | 7,953 | c | C | sksv.c | claby2/sksv | fb44aeb8ef5cce07a9dc3e31c8acd16c8d8d2ff6 | [
"MIT"
] | 1 | 2021-08-30T04:31:00.000Z | 2021-08-30T04:31:00.000Z | sksv.c | claby2/sksv | fb44aeb8ef5cce07a9dc3e31c8acd16c8d8d2ff6 | [
"MIT"
] | null | null | null | sksv.c | claby2/sksv | fb44aeb8ef5cce07a9dc3e31c8acd16c8d8d2ff6 | [
"MIT"
] | null | null | null | #include <X11/X.h>
#include <X11/XKBlib.h>
#include <X11/Xft/Xft.h>
#include <X11/Xutil.h>
#include <math.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#ifdef XINERAMA
#include <X11/extensions/Xinerama.h>
#endif
#define EXIT_FAILURE 1
#define EXIT_SUCCESS 0
#define ARG(a, b) !strcmp(a, b)
#define MAX(A, B) ((A) > (B) ? (A) : (B))
#define MIN(A, B) ((A) < (B) ? (A) : (B))
#define INTERSECT(x, y, w, h, r) \
(MAX(0, MIN((x) + (w), (r).x_org + (r).width) - MAX((x), (r).x_org)))
struct Key {
char *name;
int w; /* Width of key when rendered. */
struct Key *next;
};
typedef struct {
int x, y;
unsigned int w, h;
} Geometry;
typedef struct {
Display *dpy;
Drawable buf;
Window win;
XftDraw *draw;
int scr;
Geometry geom;
} XWindow;
typedef struct {
GC gc;
XftColor color;
XftFont *font;
} DC;
static Window root;
static XWindow xw;
static DC dc;
static char *font = "";
static char *usergeom = NULL;
static const double HEIGHT_SCALE_FACTOR = 1.5; /* Adds padding to window. */
static const unsigned int KEYS_RETURN_SIZE = 32;
static const long int DELAY = 5000000;
void die(const char *errstr, ...) {
va_list ap;
va_start(ap, errstr);
vfprintf(stderr, errstr, ap);
va_end(ap);
exit(EXIT_FAILURE);
}
void settitle(char *p) {
XTextProperty prop;
Xutf8TextListToTextProperty(xw.dpy, &p, 1, XUTF8StringStyle, &prop);
XSetWMName(xw.dpy, xw.win, &prop);
XFree(prop.value);
}
/* Sets window geometry dynamically. Uses XINERAMA if defined. */
void setwingeometry(Geometry *geom) {
XWindowAttributes wa;
#ifdef XINERAMA
Window dw;
XineramaScreenInfo *info;
int n, di, i;
int px, py;
unsigned int du;
if ((info = XineramaQueryScreens(xw.dpy, &n))) {
XQueryPointer(xw.dpy, root, &dw, &dw, &px, &py, &di, &di, &du);
/* Find the monitor the pointer intersects with. */
for (i = 0; i < n; i++)
if (INTERSECT(px, py, 1, 1, info[i])) break;
geom->x = info[i].x_org;
geom->y = info[i].y_org;
geom->w = info[i].width;
XFree(info);
} else
#endif
{
/* XINERAMA not defined, fallback to setting geometry based on root
* attributes. */
XGetWindowAttributes(xw.dpy, root, &wa);
geom->x = geom->y = 0;
geom->w = wa.width;
}
geom->h = dc.font->height * HEIGHT_SCALE_FACTOR;
}
/* Assuming s has enough space allocated, prepends t into s. */
void prepend(char *s, const char *t) {
size_t len = strlen(t);
memmove(s + len, s, strlen(s) + 1);
memcpy(s, t, len);
}
char *gettext(struct Key *head) {
char *text;
int first = 0;
int len = 0, total_w = 0;
struct Key *cur;
struct Key *prev = NULL;
/* Calculate length of text string. */
for (cur = head; cur != NULL; cur = cur->next) {
if (total_w + cur->w > xw.geom.w) {
/* Free any keys that are not expected to be rendered as they exceed the
* window width. */
if (prev) prev->next = NULL;
free(cur);
} else {
total_w += cur->w;
len += strlen(cur->name);
prev = cur;
}
}
text = malloc(len + 1);
/* Build text to be rendered. */
for (cur = head; cur != NULL; cur = cur->next) {
if (first == 0) {
strcpy(text, cur->name);
first = 1;
} else
prepend(text, cur->name);
}
return text;
}
void draw(struct Key *head) {
char *text;
XClearWindow(xw.dpy, xw.win);
if (head) {
text = gettext(head);
XftDrawString8(xw.draw, &dc.color, dc.font, 0,
xw.geom.h / 2 + dc.font->descent, (XftChar8 *)text,
strlen(text));
XCopyArea(xw.dpy, xw.buf, xw.win, dc.gc, 0, 0, xw.geom.w, xw.geom.h, 0, 0);
free(text);
}
XSetForeground(xw.dpy, dc.gc, XBlackPixel(xw.dpy, xw.scr));
XFillRectangle(xw.dpy, xw.buf, dc.gc, 0, 0, xw.geom.w, xw.geom.h);
XFlush(xw.dpy);
}
void setup(void) {
Colormap cm;
Visual *vis;
XGCValues gcv;
XRenderColor rc;
XSetWindowAttributes swa;
XWindowAttributes wa;
if (!(xw.dpy = XOpenDisplay(NULL))) die("Can't open display\n");
xw.scr = XDefaultScreen(xw.dpy);
root = XRootWindow(xw.dpy, xw.scr);
dc.font = XftFontOpenName(xw.dpy, xw.scr, font);
if (usergeom) /* User has specified custom geometry, use the parsed value. */
XParseGeometry(usergeom, &xw.geom.x, &xw.geom.y, &xw.geom.w, &xw.geom.h);
else
setwingeometry(&xw.geom);
swa.override_redirect = True;
xw.win =
XCreateWindow(xw.dpy, root, xw.geom.x, xw.geom.y, xw.geom.w, xw.geom.h, 0,
CopyFromParent, CopyFromParent, CopyFromParent,
CWOverrideRedirect | CWBackPixel, &swa);
settitle("sksv");
XMapRaised(xw.dpy, xw.win);
XGetWindowAttributes(xw.dpy, xw.win, &wa);
xw.buf = XCreatePixmap(xw.dpy, xw.win, xw.geom.w, xw.geom.h, wa.depth);
gcv.graphics_exposures = 0;
dc.gc = XCreateGC(xw.dpy, xw.win,
GCForeground | GCBackground | GCGraphicsExposures, &gcv);
vis = XDefaultVisual(xw.dpy, xw.scr);
cm = XDefaultColormap(xw.dpy, xw.scr);
xw.draw = XftDrawCreate(xw.dpy, xw.buf, vis, cm);
rc.alpha = rc.red = rc.green = rc.blue = 0xFFFF;
XftColorAllocValue(xw.dpy, vis, cm, &rc, &dc.color);
draw(NULL);
}
/* Convert given keysym to key struct. Will return NULL if keysym is unable to
* be converted to a string. */
struct Key *keysymtokey(const unsigned long keysym) {
XGlyphInfo ext;
char *name;
char *str;
struct Key *key;
str = XKeysymToString(keysym);
if (!str) return NULL;
key = (struct Key *)malloc(sizeof(struct Key));
/* Malloc +2 to accommodate null terminator and additional space character. */
name = malloc(strlen(str) + 2);
strcpy(name, str);
strcat(name, " ");
XftTextExtentsUtf8(xw.dpy, dc.font, (XftChar8 *)name, strlen(name), &ext);
key->name = name;
key->w = ext.xOff;
return key;
}
int isshift(unsigned long keysym) {
return keysym == XK_Shift_L || keysym == XK_Shift_R;
}
int iscapslock() {
unsigned int n;
XkbGetIndicatorState(xw.dpy, XkbUseCoreKbd, &n);
return (n & 0x01) == 1;
}
void run(void) {
char kr[KEYS_RETURN_SIZE];
char pkr[KEYS_RETURN_SIZE];
int change;
int i;
int keycode;
int shift = 0;
struct Key *cur;
struct Key *head = NULL;
struct timespec ts = {.tv_sec = 0, .tv_nsec = DELAY};
unsigned long keysym;
memset(kr, 0, KEYS_RETURN_SIZE * sizeof(char));
memset(pkr, 0, KEYS_RETURN_SIZE * sizeof(char));
for (;;) {
/* Sleep for specified time to avoid expensive jump calls. */
nanosleep(&ts, NULL);
change = 0;
XQueryKeymap(xw.dpy, kr);
for (i = 0; i < KEYS_RETURN_SIZE; i++) {
keycode = i * 8 + log2((unsigned char)kr[i] ^ (unsigned char)pkr[i]);
keysym = XkbKeycodeToKeysym(xw.dpy, keycode, 0, shift || iscapslock());
if ((unsigned char)kr[i] > (unsigned char)pkr[i]) {
/* Key press. */
if (isshift(keysym)) shift = 1;
cur = keysymtokey(keysym);
if (cur) {
cur->next = head;
head = cur;
change = 1;
}
} else {
/* Key release. */
if (isshift(keysym)) shift = 0;
}
pkr[i] = kr[i];
}
if (change) draw(head);
}
/* Free linked list. */
for (cur = head; cur != NULL; cur = cur->next) {
free(cur->name);
free(cur);
}
}
void cleanup(void) {
XftDrawDestroy(xw.draw);
XftColorFree(xw.dpy, XDefaultVisual(xw.dpy, xw.scr),
DefaultColormap(xw.dpy, xw.scr), &dc.color);
XftFontClose(xw.dpy, dc.font);
XFreePixmap(xw.dpy, xw.buf);
XFreeGC(xw.dpy, dc.gc);
XDestroyWindow(xw.dpy, xw.win);
XCloseDisplay(xw.dpy);
exit(EXIT_SUCCESS);
}
void usage(void) {
fputs("usage: sksv [-fn font] [-g geometry]\n", stderr);
exit(EXIT_FAILURE);
}
int main(int argc, char *argv[]) {
int i;
for (i = 1; i < argc; i++) {
if (ARG(argv[i], "-fn"))
font = argv[++i];
else if (ARG(argv[i], "-g"))
usergeom = argv[++i];
else
usage();
}
setup();
run();
cleanup();
}
| 25.654839 | 80 | 0.610461 | [
"geometry"
] |
2b3f0fe3cdc7ecbce306226b95dcdd493d981ebd | 327 | h | C | PiecewiseConstant/myprint.h | vinayak2020/Skorokhod-Metric | 4e4696f8849fd3f936dc9d1259a4508dc88d98fc | [
"Apache-2.0"
] | 1 | 2020-02-29T08:53:11.000Z | 2020-02-29T08:53:11.000Z | PiecewiseConstant/myprint.h | vinayak2020/Skorokhod-Metric | 4e4696f8849fd3f936dc9d1259a4508dc88d98fc | [
"Apache-2.0"
] | null | null | null | PiecewiseConstant/myprint.h | vinayak2020/Skorokhod-Metric | 4e4696f8849fd3f936dc9d1259a4508dc88d98fc | [
"Apache-2.0"
] | null | null | null | /***
Author: Vinayak Prabhu
***/
#ifndef GUARD_Printvec
#define GUARD_Printvec
#include <vector>
#include <utility>
void printvec(const std::vector<double> & myvec);
void printvec_nonend(const std::vector<double> & myvec);
void indexPrint(const int & i);
void printpair(const std::pair<double, double> & p);
#endif
| 14.863636 | 56 | 0.712538 | [
"vector"
] |
2b5bc410303a2cfa1124916df2d3ae4d3f281683 | 1,295 | h | C | rh-/rh-/ModelSK.h | ShiroixD/Rh- | 33db74b21bb9a7255d72b14afd6746f142c1784b | [
"Apache-2.0"
] | null | null | null | rh-/rh-/ModelSK.h | ShiroixD/Rh- | 33db74b21bb9a7255d72b14afd6746f142c1784b | [
"Apache-2.0"
] | null | null | null | rh-/rh-/ModelSK.h | ShiroixD/Rh- | 33db74b21bb9a7255d72b14afd6746f142c1784b | [
"Apache-2.0"
] | null | null | null | #pragma once
#include <vector>
#include "ModelMaterial.h"
#include "pch.h"
class MyGame;
class MeshSK;
class ModelMaterial;
class AnimationClip;
class SceneNode;
class Bone;
struct aiNode;
class ModelSK
{
friend class MeshSK;
public:
ModelSK(MyGame& game, const std::string& filename, bool flipUVs = false);
~ModelSK();
MyGame& GetGame();
bool HasMeshes() const;
bool HasMaterials() const;
bool HasAnimations() const;
const std::vector<MeshSK*>& Meshes() const;
const std::vector<ModelMaterial*>& Materials() const;
const std::vector<AnimationClip*>& Animations() const;
const std::map<std::string, AnimationClip*>& AnimationsbyName() const;
const std::vector<Bone*> Bones() const;
const std::map<std::string, UINT> BoneIndexMapping() const;
SceneNode* RootNode();
private:
ModelSK(const ModelSK& rhs);
ModelSK& operator=(const ModelSK& rhs);
SceneNode* BuildSkeleton(aiNode& node, SceneNode* parentSceneNode);
void ValidateModel();
void DeleteSceneNode(SceneNode* sceneNode);
MyGame& mGame;
std::vector<MeshSK*> mMeshes;
std::vector<ModelMaterial*> mMaterials;
std::vector<AnimationClip*> mAnimations;
std::map<std::string, AnimationClip*> mAnimationsByName;
std::vector<Bone*> mBones;
std::map<std::string, UINT> mBoneIndexMapping;
SceneNode* mRootNode;
}; | 24.433962 | 74 | 0.742857 | [
"vector"
] |
2b63c86d5c508f4517385c8ab200930807f8406b | 10,824 | c | C | c6ers/msd200a/devtab.c | minblock/msdos | 479ffd237d9bb7cc83cb06361db2c4ef42dfbac0 | [
"Apache-2.0"
] | null | null | null | c6ers/msd200a/devtab.c | minblock/msdos | 479ffd237d9bb7cc83cb06361db2c4ef42dfbac0 | [
"Apache-2.0"
] | null | null | null | c6ers/msd200a/devtab.c | minblock/msdos | 479ffd237d9bb7cc83cb06361db2c4ef42dfbac0 | [
"Apache-2.0"
] | null | null | null | /*********************************************************************
* Microsoft Diagnostics Version 2.0
*
* A diagnostic utility to detect as much useful information about a
* customer's computer system as is possible.
*
* Microsoft Diagnostics: We detect the World.
*
* DEVTAB.C - Device Driver detection routines.
*********************************************************************/
/* Include Files */
#include "msd.h"
/* Made global to this file. This prevents filling the structure with */
/* more device driver info than was previously allocated (on the */
/* extremely odd case of finding more device drivers when we */
/* actually get the driver info than when we counted up how many */
/* there were. There is a way in DOS for an .EXE to install a */
/* device driver. Under multitasking systems, the addition of a new */
/* device driver while this program is running is a rare, though */
/* real possibility. */
WORD wDeviceDriverCount = 0; /* The number of device drivers */
/* installed in memory */
/*********************************************************************
* GetDeviceDriverSize - Gets number of bytes required to store the
* installed device driver's data.
*
* Returns: The bytes required for the structure.
*********************************************************************/
WORD GetDeviceDriversSize (VOID)
{
CHAR FAR * fpDevHeader = NULL; /* Pointer to the device header */
CHAR FAR * FAR * fpNextDevHeader = NULL;/* Pointer to next device header */
wDeviceDriverCount = 0; /* Zero out the driver count */
/* Point to the first device driver */
fpDevHeader = FindFirstDevHeader();
/* Count device drivers until the header's offset is 0xFFFF */
/* (0xFFFF signifies the end of the list */
while (FP_OFF (fpDevHeader) != 0xFFFF)
{
++wDeviceDriverCount;
/* Point to the next device driver */
fpNextDevHeader = (CHAR FAR * FAR *) fpDevHeader;
fpDevHeader = *fpNextDevHeader;
}
/* Account for the zeroed out Device Driver record at the end */
++wDeviceDriverCount;
/* Return the number of bytes required to store the structure */
return (wDeviceDriverCount * sizeof (DEVICE_DRIVER_STRUCT));
}
/*********************************************************************
* GetDeviceDriverInfo - Fills structure with installed device
* driver's data.
*
* Returns: TRUE if an error occured.
*********************************************************************/
BOOL GetDeviceDriversInfo (DEVICE_DRIVER_STRUCT *pDevStruct,
BOOL fMinimumInfo)
{
WORD wDevIndex; /* Index to pDevStruct */
WORD i; /* Looping variable */
CHAR FAR * fpDevHeader = NULL; /* Pointer to the device header */
CHAR FAR * fpDevFilename = NULL; /* Pointer to the DEVICE= filename */
WORD FAR * fwWordPointer = NULL; /* WORD pointer to obtain WORD */
/* values */
CHAR FAR * FAR * fpNextDevHeader = NULL;
/* Pointer to next device header */
/* There is no minimum info to return from this routine */
if (fMinimumInfo)
return (FALSE);
/* Point to the first device driver */
fpDevHeader = FindFirstDevHeader();
/* Count device drivers until the header's offset is 0xFFFF */
/* (0xFFFF signifies the end of the list */
for (wDevIndex = 0;
wDevIndex < wDeviceDriverCount - 1 &&
FP_OFF (fpDevHeader) != 0xFFFF;
++wDevIndex)
{
pDevStruct[wDevIndex].dwHeader = (DWORD) fpDevHeader;
/* Set the WORD pointer */
fwWordPointer = (WORD FAR *) fpDevHeader;
pDevStruct[wDevIndex].wAttributes = fwWordPointer[2];
/* Set the values for character or block devices */
if (pDevStruct[wDevIndex].wAttributes & 0x8000)
{
/* Bit 15 is set, this is a character device */
_fmemcpy ((CHAR FAR *) pDevStruct[wDevIndex].szDeviceName,
&fpDevHeader[10], 8);
pDevStruct[wDevIndex].szDeviceName[8] = '\0';
pDevStruct[wDevIndex].wUnits = 0;
}
else
{
/* Bit 15 is clear, this is a block device */
strcpy (pDevStruct[wDevIndex].szDeviceName, pszBlockDevice);
pDevStruct[wDevIndex].wUnits = (WORD) fpDevHeader[10];
}
/* Get the DEVICE= filename */
fpDevFilename = (CHAR FAR *)
((((DWORD) FP_SEG (fpDevHeader) - 1) << 16) +
FP_OFF (fpDevHeader));
/* Make sure all characters are printable */
for (i = 8; i < 16 && fpDevFilename[i] >= ' '; ++i)
;
/* Copy the DEVICE= filename to the structure if it's a Device (D) */
/* or an installable file system (I). */
if (i == 16 && (fpDevFilename[0] == 'D') || (fpDevFilename[0] == 'I'))
{
_fmemcpy ((CHAR FAR *) pDevStruct[wDevIndex].szDriverFilename,
&fpDevFilename[8], 8);
pDevStruct[wDevIndex].szDriverFilename[8] = '\0';
}
else
pDevStruct[wDevIndex].szDriverFilename[0] = '\0';
/* Point to the next device driver */
fpNextDevHeader = (CHAR FAR * FAR *) fpDevHeader;
fpDevHeader = *fpNextDevHeader;
}
/* Set the last record to zeroes */
pDevStruct[wDevIndex].dwHeader = 0;
pDevStruct[wDevIndex].wAttributes = 0;
pDevStruct[wDevIndex].szDeviceName[0] = '\0';
pDevStruct[wDevIndex].szDriverFilename[0] = '\0';
pDevStruct[wDevIndex].wUnits = 0;
return (FALSE);
}
/*********************************************************************
* SprintDeviceDriverInfo - Put installed device driver information
* into a set of strings to be printed or
* displayed.
*
* Returns: NULL if an error occured.
*********************************************************************/
QSZ * SprintDeviceDriverInfo (DEVICE_DRIVER_STRUCT *pDevStruct)
{
WORD wNmbrStrings; /* Number of strings */
WORD wNmbrChars; /* Number of characters in the strings */
WORD wUnderlineLength; /* Length of the underline string */
WORD wDevIndex; /* Index to the structure of device data */
WORD i, u, x; /* Looping variables */
QSZ *pqszStrings = NULL; /* Location for storing string pointers */
/* Calculate the amount of space required for the strings */
wUnderlineLength = strlen (pszDeviceUnderline);
wNmbrChars = strlen (pszDeviceHeader) + 1 +
wUnderlineLength + 1 +
(wDeviceDriverCount * (wUnderlineLength + 1));
/* The underline string is expected to be as long as a line of */
/* device driver info. */
wNmbrStrings = wDeviceDriverCount + 3;
/* "+ 3" is for the header line, the underline, and the NULL */
/* pointer at the end of the array. */
/* Allocate space for the pointer area and string area */
pqszStrings = AllocStringSpace (wNmbrStrings, wNmbrChars);
if (pqszStrings == NULL)
return (NULL);
/* Put the first two strings in place */
Qstrcpy (pqszStrings[0], pszDeviceHeader);
pqszStrings[1] = pqszStrings[0] + Qstrlen (pqszStrings[0]) + 1;
Qstrcpy (pqszStrings[1], pszDeviceUnderline);
pqszStrings[2] = pqszStrings[1] + wUnderlineLength + 1;
/* Put the device driver information in place */
for (i = 2, wDevIndex = 0; pDevStruct[wDevIndex].dwHeader != 0;
++i, ++wDevIndex)
{
WORD wLength; /* Current length of string */
CHAR chBuffer[80]; /* Buffer for string data */
/* Fill the line with spaces */
Qmemset (pqszStrings[i], ' ', wUnderlineLength);
pqszStrings[i][wUnderlineLength] = '\0';
/* Device Name */
Qstrncpy (pqszStrings[i], pDevStruct[wDevIndex].szDeviceName,
strlen (pDevStruct[wDevIndex].szDeviceName));
/* Device Filename */
Qstrncpy (&pqszStrings[i][DEV_FILENAME_COL],
pDevStruct[wDevIndex].szDriverFilename,
strlen (pDevStruct[wDevIndex].szDriverFilename));
/* Units */
if ((pDevStruct[wDevIndex].wAttributes & 0x8000) == 0)
{
wLength = sprintf (chBuffer, "% 3d", pDevStruct[wDevIndex].wUnits);
Qstrncpy (&pqszStrings[i][DEV_UNITS_COL], chBuffer, wLength);
}
/* Header */
wLength = sprintf (chBuffer, "%04X:%04X",
FP_SEG (pDevStruct[wDevIndex].dwHeader),
FP_OFF (pDevStruct[wDevIndex].dwHeader));
Qstrncpy (&pqszStrings[i][DEV_HEADER_COL], chBuffer, wLength);
/* Attributes */
itoa (pDevStruct[wDevIndex].wAttributes, chBuffer, 2);
wLength = strlen (chBuffer);
/* Set the Attribute area to periods */
Qmemset (&pqszStrings[i][DEV_ATTRIBUTE_COL], '.', 16);
for (x = 0, u = DEV_ATTRIBUTE_COL + 16 - wLength;
x < wLength; ++x, ++u)
{
if (chBuffer[x] == '1')
pqszStrings[i][u] = '1';
}
/* Set the next pointer */
PrepNextString (pqszStrings, i);
}
/* Set the last pointer to NULL */
pqszStrings[i] = NULL;
/* Return the pointer to pqszStrings */
return (pqszStrings);
}
/*********************************************************************
* FindFirstDevHeader - Finds the pointer to the list of DOS device
* drivers.
*
* Returns: Far pointer to the first DOS device driver (NUL).
*********************************************************************/
CHAR FAR * FindFirstDevHeader (VOID)
{
CHAR FAR *fpDevHeader = NULL;
union REGS regsIn, regsOut;
struct SREGS sregs;
/* Get the address of the start of DOS' list of lists (ES:BX) */
regsIn.h.ah = 0x52;
int86x (0x21, ®sIn, ®sOut, &sregs);
fpDevHeader = (VOID FAR *)
(((long)(sregs.es) << 16) + (long)(regsOut.x.bx));
/* Add the correct offset for the version of DOS being run
DOS Version Offset
----------- ------
3.0 28H
3.1-3.3 22H
4.x 22H
5.x 22H
*/
if (wDosMajor == 3 && wDosMinor == 0)
fpDevHeader = fpDevHeader + 0x28;
else
fpDevHeader = fpDevHeader + 0x22;
return (fpDevHeader);
}
| 31.835294 | 77 | 0.539911 | [
"3d"
] |
2b6e26f3f6975749d1592804393a041e22fe4cc5 | 711 | h | C | aws-cpp-sdk-rekognition/include/aws/rekognition/model/PersonTrackingSortBy.h | Neusoft-Technology-Solutions/aws-sdk-cpp | 88c041828b0dbee18a297c3cfe98c5ecd0706d0b | [
"Apache-2.0"
] | 1 | 2022-02-12T08:09:30.000Z | 2022-02-12T08:09:30.000Z | aws-cpp-sdk-rekognition/include/aws/rekognition/model/PersonTrackingSortBy.h | Neusoft-Technology-Solutions/aws-sdk-cpp | 88c041828b0dbee18a297c3cfe98c5ecd0706d0b | [
"Apache-2.0"
] | 1 | 2022-01-03T23:59:37.000Z | 2022-01-03T23:59:37.000Z | aws-cpp-sdk-rekognition/include/aws/rekognition/model/PersonTrackingSortBy.h | ravindra-wagh/aws-sdk-cpp | 7d5ff01b3c3b872f31ca98fb4ce868cd01e97696 | [
"Apache-2.0"
] | 1 | 2021-12-30T04:25:33.000Z | 2021-12-30T04:25:33.000Z | /**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#pragma once
#include <aws/rekognition/Rekognition_EXPORTS.h>
#include <aws/core/utils/memory/stl/AWSString.h>
namespace Aws
{
namespace Rekognition
{
namespace Model
{
enum class PersonTrackingSortBy
{
NOT_SET,
INDEX,
TIMESTAMP
};
namespace PersonTrackingSortByMapper
{
AWS_REKOGNITION_API PersonTrackingSortBy GetPersonTrackingSortByForName(const Aws::String& name);
AWS_REKOGNITION_API Aws::String GetNameForPersonTrackingSortBy(PersonTrackingSortBy value);
} // namespace PersonTrackingSortByMapper
} // namespace Model
} // namespace Rekognition
} // namespace Aws
| 22.21875 | 97 | 0.777778 | [
"model"
] |
d87ed38f30d59c5e2ffcbd0e9f22e05f96890394 | 8,718 | h | C | pxr/base/lib/gf/rgb.h | unity3d-jp/USD | 0f146383613e1efe872ea7c85aa3536f170fcda2 | [
"BSD-3-Clause"
] | 7 | 2016-12-13T00:53:38.000Z | 2020-04-02T13:25:50.000Z | pxr/base/lib/gf/rgb.h | unity3d-jp/USD | 0f146383613e1efe872ea7c85aa3536f170fcda2 | [
"BSD-3-Clause"
] | null | null | null | pxr/base/lib/gf/rgb.h | unity3d-jp/USD | 0f146383613e1efe872ea7c85aa3536f170fcda2 | [
"BSD-3-Clause"
] | 2 | 2016-12-13T00:53:40.000Z | 2020-05-04T07:32:53.000Z | //
// Copyright 2016 Pixar
//
// Licensed under the Apache License, Version 2.0 (the "Apache License")
// with the following modification; you may not use this file except in
// compliance with the Apache License and the following modification to it:
// Section 6. Trademarks. is deleted and replaced with:
//
// 6. Trademarks. This License does not grant permission to use the trade
// names, trademarks, service marks, or product names of the Licensor
// and its affiliates, except as required to comply with Section 4(c) of
// the License and to reproduce the content of the NOTICE file.
//
// You may obtain a copy of the Apache License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the Apache License with the above modification is
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the Apache License for the specific
// language governing permissions and limitations under the Apache License.
//
#ifndef GF_RGB_H
#define GF_RGB_H
#include "pxr/base/gf/math.h"
#include "pxr/base/gf/vec3f.h"
#include <iosfwd>
class GfMatrix4d;
//!
// \file rgb.h
// \ingroup group_gf_Color
//
//! \class GfRGB rgb.h "pxr/base/gf/rgb.h"
// \brief A color represented as 3 floats for red, green, and blue.
//
// The \c GfRGB class contains three floats that represent an RGB
// color, in the order red, green, blue.
// Conversions to and from some other color spaces are provided.
class GfRGB {
public:
//! The default constructor creates an invalid color.
GfRGB() { Set(NAN, NAN, NAN); }
//! This constructor initializes the color to grey.
explicit GfRGB(int bw) { _rgb[0] = _rgb[1] = _rgb[2] = bw; }
explicit GfRGB(GfVec3f const &v) : _rgb(v) {}
//! This constructor initializes the color to grey.
explicit GfRGB(float grey) : _rgb(grey, grey, grey) {}
//! Constructor that takes an array of 3 floats.
explicit GfRGB(const float rgb[3]) : _rgb(rgb) {}
//! Constructor that takes individual red, green, and blue values.
GfRGB(float red, float green, float blue) : _rgb(red, green, blue) {}
//! Sets the color from an array of 3 floats.
GfRGB &Set(const float rgb[3]) {
_rgb.Set(rgb);
return *this;
}
//! Sets the color to individual red, green, and blue values.
GfRGB &Set(float red, float green, float blue) {
_rgb.Set(red, green, blue);
return *this;
}
//! Returns whether or not the color is valid. By convention, a color
// is valid if the first color component is not NAN.
bool IsValid() const { return !isnan(_rgb[0]); }
//! Returns the RGB color as a \c GfVec3f.
const GfVec3f &GetVec() const { return _rgb; }
//! Returns the RGB color as an array of 3 floats.
const float *GetArray() const { return _rgb.GetArray(); }
//! Accesses indexed component of color as a modifiable l-value.
float &operator [](int i) { return _rgb[i]; }
//! Accesses indexed component of color as a \c const l-value.
const float &operator [](int i) const { return _rgb[i]; }
//! Clamps each component of the color to be in the given range.
void Clamp(float min = 0.0, float max = 1.0) {
_rgb[0] = GfClamp(_rgb[0], min, max);
_rgb[1] = GfClamp(_rgb[1], min, max);
_rgb[2] = GfClamp(_rgb[2], min, max);
}
//! All components must match exactly for colors to be considered equal.
bool operator ==(const GfRGB &c) const {
return _rgb == c._rgb;
}
//! Any component may differ
bool operator !=(const GfRGB &c) const {
return !(*this == c);
}
//! Check to see if all components are set to 0.
bool IsBlack() const {
return _rgb == GfVec3f(0);
}
//! Check to see if all components are set to 1.
bool IsWhite() const {
return _rgb == GfVec3f(1,1,1);
}
//! Component-wise color addition.
GfRGB &operator +=(const GfRGB &c) {
_rgb += c._rgb;
return *this;
}
//! Component-wise color subtraction.
GfRGB &operator -=(const GfRGB &c) {
_rgb -= c._rgb;
return *this;
}
//! Component-wise color multiplication.
GfRGB &operator *=(const GfRGB &c) {
_rgb = GfCompMult(_rgb, c._rgb);
return *this;
}
//! Component-wise color division.
GfRGB &operator /=(const GfRGB &c) {
_rgb = GfCompDiv(_rgb, c._rgb);
return *this;
}
//! Component-wise scalar multiplication.
GfRGB &operator *=(float d) {
_rgb *= d;
return *this;
}
//! Component-wise scalar division.
GfRGB &operator /=(float d) {
_rgb /= d;
return *this;
}
//! Returns component-wise multiplication of colors \p c1 and \p c2.
// \warning this is \em not a dot product operator, as it is with vectors.
friend GfRGB operator *(const GfRGB &c1, const GfRGB &c2) {
return GfRGB(GfCompMult(c1._rgb, c2._rgb));
}
//! quotient operator
friend GfRGB operator /(const GfRGB &c1, const GfRGB &c2) {
return GfRGB(GfCompDiv(c1._rgb, c2._rgb));
}
//! addition operator.
friend GfRGB operator +(const GfRGB &c1, const GfRGB &c2) {
return GfRGB(c1._rgb + c2._rgb);
}
//! subtraction operator.
friend GfRGB operator -(const GfRGB &c1, const GfRGB &c2) {
return GfRGB(c1._rgb - c2._rgb);
}
//! multiplication operator.
friend GfRGB operator *(const GfRGB &c, float s) {
return GfRGB(c._rgb * s);
}
//! Component-wise binary color/scalar multiplication operator.
friend GfRGB operator *(float s, const GfRGB &c) {
return c * s;
}
//! Component-wise binary color/scalar division operator.
friend GfRGB operator /(const GfRGB &c, float s) {
return c * (1./s);
}
//! Tests for equality within a given tolerance, returning true if the
// difference between each component is less than \p tolerance.
friend bool GfIsClose(const GfRGB &v1, const GfRGB &v2, double tolerance);
//! Returns \code (1-alpha) * a + alpha * b \endcode
// similar to GfLerp for other vector types.
friend GfRGB GfLerp(float alpha, const GfRGB &a, const GfRGB &b) {
return (1.0-alpha) * a + alpha * b;
}
//! \name Color-space conversions.
// The methods in this group convert between RGB and other color spaces.
//@{
//! Transform the color into an arbitrary space.
GfRGB Transform(const GfMatrix4d &m) const;
//! Transform the color into an arbitrary space.
friend GfRGB operator *(const GfRGB &c, const GfMatrix4d &m);
//! Return the complement of a color.
// (Note that this assumes normalized RGB channels in [0,1]
// and doesn't work with HDR color values.)
GfRGB GetComplement() const {
return GfRGB(1) - *this;
}
//! Return the luminance of a color given a set of RGB
// weighting values. Defaults are Rec.709 weights for
// linear RGB components.
float GetLuminance(float wr = 0.2126390,
float wg = 0.7151687,
float wb = 0.07219232) const {
return _rgb[0]*wr + _rgb[1]*wg + _rgb[2]*wb;
}
//! Return the luminance of a color given a set of RGB
// weighting values passed as a GfRGB color object.
float GetLuminance(const GfRGB &coeffs) const {
return _rgb[0]*coeffs._rgb[0] +
_rgb[1]*coeffs._rgb[1] +
_rgb[2]*coeffs._rgb[2];
}
//! Returns the equivalent of this color in HSV space
void GetHSV(float *hue, float *sat, float *value) const;
//! Sets this RGB to the RGB equivalent of the given HSV color.
void SetHSV(float hue, float sat, float value);
//! Given an RGB base and HSV offset, get an RGB color.
static GfRGB GetColorFromOffset(const GfRGB &offsetBase,
const GfRGB &offsetHSV);
//! Given an HSV offset color and an RGB base, get the HSV offset
static GfRGB GetOffsetFromColor(const GfRGB &offsetBase,
const GfRGB &offsetColor);
//@}
private:
//! Color storage.
GfVec3f _rgb;
};
// Friend functions must be declared.
bool GfIsClose(const GfRGB &v1, const GfRGB &v2, double tolerance);
GfRGB operator *(const GfRGB &c, const GfMatrix4d &m);
/// Output a GfRGB color using the format (r, g, b).
/// \ingroup group_gf_DebuggingOutput
std::ostream& operator<<(std::ostream& out, const GfRGB& c);
#endif // GF_RGB_H
| 32.651685 | 78 | 0.627093 | [
"object",
"vector",
"transform"
] |
d87fd6336ae0c9821536319ce16af2fbaff21122 | 489 | h | C | src/triangle_mesh.h | vieiraa/ray_tracer | 75665fd5b15f486ad52f3c5b61521fb394d40fe1 | [
"MIT"
] | null | null | null | src/triangle_mesh.h | vieiraa/ray_tracer | 75665fd5b15f486ad52f3c5b61521fb394d40fe1 | [
"MIT"
] | null | null | null | src/triangle_mesh.h | vieiraa/ray_tracer | 75665fd5b15f486ad52f3c5b61521fb394d40fe1 | [
"MIT"
] | null | null | null | #pragma once
#include "triangle.h"
#include <vector>
#include <memory>
class TriangleMesh {
std::vector<Triangle*> triangles_;
public:
explicit TriangleMesh(std::vector<Triangle*> &t, const char *name);
std::vector<Triangle*>& getTriangles();
std::string name_;
};
class Mesh {
std::vector<TriangleMesh> meshes_;
public:
explicit Mesh(const std::string &filename);
void loadMesh(const std::string &filename);
std::vector<TriangleMesh> getMeshes();
};
| 19.56 | 71 | 0.689162 | [
"mesh",
"vector"
] |
d888a54bc962786c874b97f281844188474eadaf | 6,677 | h | C | src/fcst/include/microscale/ICCP.h | OpenFcst/OpenFcst0.2 | 770a0d9b145cd39c3a065b653a53b5082dc5d85c | [
"MIT"
] | 16 | 2015-05-08T18:19:39.000Z | 2021-05-21T17:22:47.000Z | src/fcst/include/microscale/ICCP.h | OpenFcst/OpenFcst0.2 | 770a0d9b145cd39c3a065b653a53b5082dc5d85c | [
"MIT"
] | 3 | 2016-09-05T10:17:36.000Z | 2016-12-11T18:23:06.000Z | src/fcst/include/microscale/ICCP.h | OpenFcst/OpenFcst0.2 | 770a0d9b145cd39c3a065b653a53b5082dc5d85c | [
"MIT"
] | 1 | 2021-04-15T16:45:47.000Z | 2021-04-15T16:45:47.000Z | //---------------------------------------------------------------------------
// C++ Interface: agglomerate_ionomer_1D.h
//
// Description: Class that solves solid carbon particle, with Pt surface loading,
// surrounded by ionomer thin film
//
// Authors: Philip Wardlaw,
// University of Alberta.
//
// Copyright: See COPYING file that comes with this distribution
//
//---------------------------------------------------------------------------
#include<micro_scale_base.h>
//FCST materials and kinetics classes
#include <catalyst_base.h>
#include <polymer_electrolyte_material_base.h>
#include <base_kinetics.h>
#include <double_trap_kinetics.h>
#include <tafel_kinetics.h>
#include <dual_path_kinetics.h>
#ifndef ICCO_H_
#define ICCO_H_
namespace FuelCellShop
{
namespace MicroScale
{
/**
* \brief Class that solves solid carbon particle, with Pt surface loading, surrounded by ionomer thin film
*
* This class is a very basic representation of the CL micro structure, intended to analyize the CL/MEA's
* sensitivity to micro scale models for various operating conditions and material params.
*
* <h3> Input parameters </h3>
* LIST OF INPUT PARAMETERS FOR THE CLASS.
* @code
* ...
* subsection MicroScale
* subsection ICCP
* set Radius [nm] = 100.0 #Inner core radius
* set Film Thickness [nm] =5.0 #Surrounding ionomer film thickness
* set Non Equilibrium BC Rate constant = 0.13 #Non equilibrium Reaction rate coefficient
* set Use non equilibrium BC = false #Use non-equilibrium BC as described by Suzukhi et al.
* end
* end
* @endcode
*/
class ICCP: public MicroScaleBase {
public:
static const std::string concrete_name;
/**
* Function for setting the solution map(reactant concentration, phi_s, phi_m, etc.).
* First argument provide the map of SolutionVariable. The second argument provide
* the name of the primary reactant. The final argument is the index of the solution
* map that the micro scale object should solve for.
*
* This function should be called immediatly before <b>compute_current</b> or
* <b>compute_derivative_current</b>.
*
*/
virtual void set_solution(const std::map<VariableNames,SolutionVariable>& sols,const VariableNames& react, const int& index);
/**
* Function used to compute the current density produced by the micro structure.
* Effectiveness is returned by reference, and defined by child class.
*
* Solves for solution variables set by the last call to <b>set_solution</b>.
*/
virtual SolutionMap compute_current ( );
/**
* Returns true if the class instance can calculate
* current density derivatives. In this case it will return false.
*
*/
virtual bool has_derivatives(){
//numerical for the moment
return false;
}
/**
* Return name of class instance, i.e. concrete name.
*/
virtual std::string get_name(){
return concrete_name;
}
/**
* MicroScale object may have extra contribution to volume of layer, e.g. water.
* In this case it is zero.
*/
virtual double aux_volume_fraction(){
return 0;
}
/**
* Print out key micro-structural dimensions, defined by child.
*/
virtual void print_properties();
virtual void make_thread_safe(ParameterHandler ¶m, unsigned int thread_index);
protected:
/** Convenient typdef for getting properties */
typedef FuelCellShop::Layer::MultiScaleCL<deal_II_dimension> CLPropNames;
/**Default Constructor*/
ICCP():
F(Constants::F()),
pi(Constants::Pi()){
non_eq_BC = false;
}
/**Factory map registration constructor */
ICCP(std::string name);
virtual void set_structure ();
/*
* Protected pure virtual member function for declaring parameters, must be implemented
* by all children. Parameter structure is hierarchical, therefore children
* should call their parent's declare parameter function from their own declare
* parameter function.
*/
virtual void declare_parameters (ParameterHandler ¶m) const;
/*
* Protected pure virtual member function for initializing parameters, must be implemented
* by all children. Parameter structure is hierarchical, therefore children
* should call their parent's initialize function from their own initialize function.
*/
virtual void initialize (ParameterHandler ¶m);
/**
* This member function is used to create an object of type MicroScaleBase
*/
virtual boost::shared_ptr<MicroScaleBase> create_replica (){
return boost::shared_ptr<MicroScaleBase>( new ICCP());
}
static ICCP const* PROTOTYPE;
private:
double residual(const double & c_inner, const double & c_outer);
//Stored solutions
std::vector<SolutionVariable> reactants;
SolutionVariable proton_pot, electron_pot;
//Transport factors
double ActiveArea; //Scaled to agglomerate surface
bool non_eq_BC; //If true then use. See residual()
double non_eq_BC_coeff;
double P; //Pressure
double HO2N; //Henry's number for O2 in Nafion
double DO2N; // diffusion of oxygen in bulk nafion
//Pointers to assests obtained from the CL
boost::shared_ptr<FuelCellShop::Kinetics::BaseKinetics> kinetics;
boost::shared_ptr<FuelCellShop::Material::PolymerElectrolyteBase> electrolyte;
boost::shared_ptr<FuelCellShop::Material::CatalystBase> catalyst;
//Physical dimensions. Read in as [nm], coverted to [cm]
double film_thickness, core_radius;
//Some constants
const double F, pi;
};
}
}
#endif /* ICCO_H_ */
| 34.417526 | 137 | 0.582297 | [
"object",
"vector",
"solid"
] |
d8977923a3acc5c59d159b93c2c4f8836496130e | 6,989 | c | C | libs/sofia-sip/libsofia-sip-ua/nth/nth_tag_dll.c | bjqiwei/unimrcp | c081282cc5b9572d7ee6c9d01aa42bd5ce0628ba | [
"Apache-2.0"
] | null | null | null | libs/sofia-sip/libsofia-sip-ua/nth/nth_tag_dll.c | bjqiwei/unimrcp | c081282cc5b9572d7ee6c9d01aa42bd5ce0628ba | [
"Apache-2.0"
] | null | null | null | libs/sofia-sip/libsofia-sip-ua/nth/nth_tag_dll.c | bjqiwei/unimrcp | c081282cc5b9572d7ee6c9d01aa42bd5ce0628ba | [
"Apache-2.0"
] | 1 | 2020-08-02T12:23:25.000Z | 2020-08-02T12:23:25.000Z | #ifdef _WIN32
/*
* PLEASE NOTE:
*
* This file is automatically generated by tag_dll.awk.
* It contains magic required by Win32 DLLs to initialize
* tag_typedef_t variables.
*
* Do not, repeat, do not edit this file. Edit 'nth_tag.c' instead.
*
*/
#define EXPORT __declspec(dllexport)
/*
* This file is part of the Sofia-SIP package
*
* Copyright (C) 2005 Nokia Corporation.
*
* Contact: Pekka Pessi <pekka.pessi@nokia.com>
*
* 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 St, Fifth Floor, Boston, MA
* 02110-1301 USA
*
*/
/**@CFILE nth_tag.c
* @brief Tags for HTTP Transaction API
*
* @note This file is used to automatically generate
* nth_tag_ref.c and nth_tag_dll.c
*
* @author Pekka Pessi <Pekka.Pessi@nokia.com>
*
* @date Created: Tue Jul 24 22:28:34 2001 ppessi
*/
#include "config.h"
#include <string.h>
#include <assert.h>
#undef TAG_NAMESPACE
#define TAG_NAMESPACE "nth"
#define TAG_NAMESPACE "nth"
#include "sofia-sip/nth_tag.h"
#include <sofia-sip/su_tag_class.h>
#include <sofia-sip/http_tag_class.h>
#include <sofia-sip/url_tag_class.h>
#include <sofia-sip/http_protos.h>
tag_typedef_t nthtag_any;
/* Common */
EXPORT tag_typedef_t nthtag_mclass_ref;
tag_typedef_t nthtag_mclass;
EXPORT tag_typedef_t nthtag_message_ref;
tag_typedef_t nthtag_message;
EXPORT tag_typedef_t nthtag_mflags_ref;
tag_typedef_t nthtag_mflags;
EXPORT tag_typedef_t nthtag_streaming_ref;
tag_typedef_t nthtag_streaming;
/* Client */
EXPORT tag_typedef_t nthtag_proxy_ref;
tag_typedef_t nthtag_proxy;
EXPORT tag_typedef_t nthtag_expires_ref;
tag_typedef_t nthtag_expires;
EXPORT tag_typedef_t nthtag_error_msg_ref;
tag_typedef_t nthtag_error_msg;
EXPORT tag_typedef_t nthtag_template_ref;
tag_typedef_t nthtag_template;
EXPORT tag_typedef_t nthtag_authentication_ref;
tag_typedef_t nthtag_authentication;
/* Server */
EXPORT tag_typedef_t nthtag_root_ref;
tag_typedef_t nthtag_root;
EXPORT tag_typedef_t nthtag_strict_host_ref;
tag_typedef_t nthtag_strict_host;
/**@def NTHTAG_AUTH_MODULE()
*
* Pointer to authentication module.
*
* A site requires authentication from the clients if passed an
* authentication module pointer with NTHTAG_AUTH_MODULE(). Incoming client
* request is challenged with 401, upon successful authentication the
* authenticated username is stored in the #auth_status_t structure
* associated with the #nth_request_t object. It is up to application to
* authorize the user.
*
* @sa nth_site_create(), nth_site_set_params(), nth_request_auth().
*/
EXPORT tag_typedef_t nthtag_auth_module_ref;
tag_typedef_t nthtag_auth_module;
#include <windows.h>
BOOL WINAPI DllMain(HINSTANCE hInst, DWORD fwdReason, LPVOID fImpLoad)
{
tag_typedef_t _nthtag_mclass = PTRTAG_TYPEDEF(mclass);
tag_typedef_t _nthtag_mclass_ref =
REFTAG_TYPEDEF(nthtag_mclass);
tag_typedef_t _nthtag_any = NSTAG_TYPEDEF(*);
tag_typedef_t _nthtag_any_ref =
REFTAG_TYPEDEF(nthtag_any);
tag_typedef_t _nthtag_streaming = BOOLTAG_TYPEDEF(streaming);
tag_typedef_t _nthtag_streaming_ref =
REFTAG_TYPEDEF(nthtag_streaming);
tag_typedef_t _nthtag_strict_host = BOOLTAG_TYPEDEF(scrict_host);
tag_typedef_t _nthtag_strict_host_ref =
REFTAG_TYPEDEF(nthtag_strict_host);
tag_typedef_t _nthtag_mflags = INTTAG_TYPEDEF(mflags);
tag_typedef_t _nthtag_mflags_ref =
REFTAG_TYPEDEF(nthtag_mflags);
tag_typedef_t _nthtag_auth_module = PTRTAG_TYPEDEF(auth_module);
tag_typedef_t _nthtag_auth_module_ref =
REFTAG_TYPEDEF(nthtag_auth_module);
tag_typedef_t _nthtag_expires = UINTTAG_TYPEDEF(expires);
tag_typedef_t _nthtag_expires_ref =
REFTAG_TYPEDEF(nthtag_expires);
tag_typedef_t _nthtag_template = PTRTAG_TYPEDEF(template);
tag_typedef_t _nthtag_template_ref =
REFTAG_TYPEDEF(nthtag_template);
tag_typedef_t _nthtag_message = PTRTAG_TYPEDEF(message);
tag_typedef_t _nthtag_message_ref =
REFTAG_TYPEDEF(nthtag_message);
tag_typedef_t _nthtag_root = PTRTAG_TYPEDEF(root);
tag_typedef_t _nthtag_root_ref =
REFTAG_TYPEDEF(nthtag_root);
tag_typedef_t _nthtag_proxy = URLTAG_TYPEDEF(proxy);
tag_typedef_t _nthtag_proxy_ref =
REFTAG_TYPEDEF(nthtag_proxy);
tag_typedef_t _nthtag_authentication = PTRTAG_TYPEDEF(authentication);
tag_typedef_t _nthtag_authentication_ref =
REFTAG_TYPEDEF(nthtag_authentication);
tag_typedef_t _nthtag_error_msg = BOOLTAG_TYPEDEF(error_msg);
tag_typedef_t _nthtag_error_msg_ref =
REFTAG_TYPEDEF(nthtag_error_msg);
*(struct tag_type_s *)nthtag_mclass = *_nthtag_mclass;
*(struct tag_type_s *)nthtag_mclass_ref = *_nthtag_mclass_ref;
*(struct tag_type_s *)nthtag_any = *_nthtag_any;
*(struct tag_type_s *)nthtag_any_ref = *_nthtag_any_ref;
*(struct tag_type_s *)nthtag_streaming = *_nthtag_streaming;
*(struct tag_type_s *)nthtag_streaming_ref = *_nthtag_streaming_ref;
*(struct tag_type_s *)nthtag_strict_host = *_nthtag_strict_host;
*(struct tag_type_s *)nthtag_strict_host_ref = *_nthtag_strict_host_ref;
*(struct tag_type_s *)nthtag_mflags = *_nthtag_mflags;
*(struct tag_type_s *)nthtag_mflags_ref = *_nthtag_mflags_ref;
*(struct tag_type_s *)nthtag_auth_module = *_nthtag_auth_module;
*(struct tag_type_s *)nthtag_auth_module_ref = *_nthtag_auth_module_ref;
*(struct tag_type_s *)nthtag_expires = *_nthtag_expires;
*(struct tag_type_s *)nthtag_expires_ref = *_nthtag_expires_ref;
*(struct tag_type_s *)nthtag_template = *_nthtag_template;
*(struct tag_type_s *)nthtag_template_ref = *_nthtag_template_ref;
*(struct tag_type_s *)nthtag_message = *_nthtag_message;
*(struct tag_type_s *)nthtag_message_ref = *_nthtag_message_ref;
*(struct tag_type_s *)nthtag_root = *_nthtag_root;
*(struct tag_type_s *)nthtag_root_ref = *_nthtag_root_ref;
*(struct tag_type_s *)nthtag_proxy = *_nthtag_proxy;
*(struct tag_type_s *)nthtag_proxy_ref = *_nthtag_proxy_ref;
*(struct tag_type_s *)nthtag_authentication = *_nthtag_authentication;
*(struct tag_type_s *)nthtag_authentication_ref = *_nthtag_authentication_ref;
*(struct tag_type_s *)nthtag_error_msg = *_nthtag_error_msg;
*(struct tag_type_s *)nthtag_error_msg_ref = *_nthtag_error_msg_ref;
return TRUE;
}
#endif
| 37.175532 | 81 | 0.769495 | [
"object"
] |
d8a52cc3490a876f5c01f7fb8af1c79765c267c9 | 1,943 | h | C | Homework/HW03/ListIterator.h | rux616/c243 | 00a907cb4fb65909773aad0d6c7f17236231da31 | [
"MIT"
] | null | null | null | Homework/HW03/ListIterator.h | rux616/c243 | 00a907cb4fb65909773aad0d6c7f17236231da31 | [
"MIT"
] | null | null | null | Homework/HW03/ListIterator.h | rux616/c243 | 00a907cb4fb65909773aad0d6c7f17236231da31 | [
"MIT"
] | null | null | null | /*********************************************************************
Author: Dana Vrajitoru, IUSB, CS
Class: C243 Data Structures
File name: ListIterator.h
Last updated: September 4, 2014
Description: Definition of the list iterator class.
**********************************************************************/
#ifndef LIST_ITERATOR_H
#define LIST_ITERATOR_H
#include "ListNode.h"
class ListIterator {
private:
ListNode *current;
public:
// Default constructor. We need to make sure the pointer is initialized
// to NULL.
ListIterator();
// Constructor from a ListNode pointer.
ListIterator(ListNode *link);
// Assignment operator with a ListNode pointer
ListNode *operator=(ListNode *link);
// Comparison operator.
bool operator==(ListIterator &data);
// Operator to advance the pointer.
ListIterator &operator++();
// Operator to access the content of the node. If the pointer is null,
// it exits the program with an error message.
int &operator*();
// Operator to check if the pointer is not null.
operator bool();
// Operator to convert to a ListNodePtr.
operator ListNodePtr();
// Swaps the content of the target object with the other iterator if
// they are both not null. If one of them is null the function
// returns false, otherwise true.
bool swap(ListIterator &other);
// Functions to be implemented by the student.
// Locates the minimum in the list starting from the target object
// and returns a list iterator containing a pointer to this node.
ListIterator min();
// This operator should move the iterator forward by a number of
// nodes indicated by the parameter. If there are not enough nodes
// to skip that many steps forward, the current pointer should be
// made NULL.
ListIterator &moveForward(int steps);
friend class List;
};
#endif
| 31.33871 | 76 | 0.640247 | [
"object"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.